首页 文章

如何使用API覆盖ODF Root RSID

提问于
浏览
0

我正在使用openoffice / libreoffice API生成ODT文档,我希望每次都能使文件100%相同(通过MD5比较) .

此时我可以解压缩在不同时间生成的两个文件,并检查zip文件中的所有文件,它们都匹配100%,但Settings.xml除外,它有两个独特的差异(两者都与RSID相关) .

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

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

我知道这是为了合并和追溯到原始文档,但我希望它们是我控制的固定值,因为我不打算合并这些,但我无法找到设置的位置这些属性 .

我尝试了一些选项(下面)并输出属性,但到目前为止无法找到它 . 有没有办法覆盖RSID,没有我(编码)解压缩文件,修改XML,我现在已经做了,但感觉有点尴尬所以仍然在寻找这个 .

// 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 回答

  • 1

    简单的解决方案是简单地删除Zip包中的settings.xml部分 . 这是所有与实现相关的材料,对于您生成的文档而言无关紧要 .

    如果您担心它仍然在清单中,尽管不在包中,另一种方法是将settings.xml替换为您的创建的标准版本,以尊重模式,并且是实现该模式所需的最少的 .

    请注意,有些条件下openoffice / libreoffice的不同运行可能会在content.xml和包部件的名称中嵌入不同的UUID和基于UIID的标识符 . 看起来你的这一代通过API不会导致任何这些 .

相关问题