Hello everyone,
I’m trying to write a Python macro to export a .odm file into a “flat” .odt file, without links to external references. This is what I’ve written so far:
import os
import sys
import uno
from com.sun.star.beans import PropertyValue
def ExportMasterToOdt():
model = XSCRIPTCONTEXT.getDocument()
# Update links and delete sections
model.updateLinks()
sections = model.Links.Sections
for name in sections:
sections[name].dispose()
args = (PropertyValue(Name="FilterName", Value="writer8"),)
model.storeToURL(model.getURL().replace(".odm", ".odt"), args)
if __name__ == "__main__":
ExportMasterToOdt()
g_exportedScripts = (ExportMasterToOdt,)
It works, but problem is: the .odt that is created with this macro still has some .odm “features”. For example, most tracking options are unavailable. It is quite frustrating because if I do the same steps as my script on the LO UI (delete sections, then File → Export), the exported file is a proper odt.
I’ve found a workaround by exporting the odm with the soffice --convert-to odt
command line, but I really wish I could do this entirely from the Python macro.
Thank you for reading!