How do I override ODF Root RSID using the API

一世执手 提交于 2019-12-13 03:03:09

问题


I am generating ODT documents using the openoffice/libreoffice API, and I want the files to come out to be 100% identical every time (by MD5 comparison).

At this point I can unzip the two files generated at different times and check all the files within the zip file and they all match 100%, except for the Settings.xml which has two unique differences (both RSID related).

<config:config-item config:name="Rsid" config:type="int">1835643</config:config-item>

and

<config:config-item config:name="RsidRoot" config:type="int">1835643</config:config-item>

I learned this is for the purpose of merging and tracking back to the original document, but I want them to be a fixed value that I control, as I don't plan to merge these anyway, but I can't locate where to set these properties.

I have tried a few options (below) and outputting the properties, but been unable to find it so far. Is there a way to override the RSID, without me (coding) unzipping the file, and modifying the XML, which I have done for now, but feels a bit awkward so still looking for this.

// Looking for RSID in all the wrong places - test 1
XPropertySet xSettings = (XPropertySet) xRemoteServiceManager.createInstanceWithContext("com.sun.star.document.Settings", componentContext);

// Looking for RSID in all the wrong places - test 2
Object configProvider = xRemoteServiceManager.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", componentContext);
XMultiServiceFactory xConfigProvider = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, configProvider);

PropertyValue[] lParams = new PropertyValue[1];

lParams[0] = new PropertyValue();
lParams[0].Name = "nodepath";
lParams[0].Value = "/";

Object xAccess = xConfigProvider.createInstanceWithArguments( "com.sun.star.configuration.ConfigurationUpdateAccess" , lParams);

XNameAccess xNameAccess = (com.sun.star.container.XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xAccess);

回答1:


The simple solution is to simply delete the settings.xml part in the package Zip. This is all implementation-dependent material and it should not matter for a document you are generating.

If you are concerned that it is still in the manifest, although not in the package, an alternative is to replace settings.xml with a standard one of your creation that honors the schema and is the least needed to accomplish that.

Note that there are conditions under which different runs of openoffice/libreoffice may embed different UUIDs and UIID-based identifiers in the content.xml and in the names of package parts. It appears that your generation via the API does not lead to any of those.



来源:https://stackoverflow.com/questions/16636532/how-do-i-override-odf-root-rsid-using-the-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!