The issue I have is that while saving as a PDF or an MS Word (docx) saves fine as a standalone document, saving as a Writer (odt) still saves with links. That means that the output document cannot (for example) be emailed to anyone as they won't have access to the original linked sub-documents.
The Navigator pane (F5) has a Save Content as well button, but I can't figure out how to do this with UNO.
Snippets of Python I'm using are:
Code: Select all
# Start a headless instance of libreoffice, then:
import uno
from com.sun.star.beans import PropertyValue
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
svcmgr = context.ServiceManager
desktop = svcmgr.createInstanceWithContext("com.sun.star.frame.Desktop", context)
model = desktop.loadComponentFromURL('file:///home/gareth/Master.odm', "_blank", 0, ())
model.updateLinks()
model.text.getString() # so that I can see it's updated
args = (PropertyValue('FilterName',0,'MS Word 2007 XML',0),)
model.storeToURL('file:///home/gareth/test.docx',args)
args = (PropertyValue('FilterName',0,'writer_pdf_Export',0),)
model.storeToURL('file:///home/gareth/test.pdf',args)
# This next one is the problem:
args = (PropertyValue('FilterName',0,'writer8',0),)
model.storeToURL('file:///home/gareth/test.odt',args)
Does anyone know the code required to force contents to be saved in the file instead of the link?