How can i get user defined properties of an Open Office document

喜夏-厌秋 提交于 2019-12-13 09:18:45

问题


I am trying to get the UserdefinedProperties of an Open Office Writer Document.

My questions are first how can i adress the currently open file in the writer? And how can i access the metadata after I told the programmm from which file it should get the data?

hopefully someone of you can help me.

Thank you very much.


回答1:


Check this interface XDocumentProperties

Reference< XDocumentInfoSupplier > xDocumentInfoSupplier(xComponent, UNO_QUERY);
Reference< XDocumentInfo > xDocumentInfo = xDocumentInfoSupplier->getDocumentInfo();

Reference< XDocumentPropertiesSupplier > xDocumentPropertiesSupplier(xDocumentInfo, UNO_QUERY);
Reference< XDocumentProperties > xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();

Reference< XPropertyContainer > xPropertyContainer = xDocumentProperties->getUserDefinedProperties();
Reference< XPropertySet > xPropertySet(xPropertyContainer, UNO_QUERY);

Reference< XPropertySetInfo > xPropertySetInfo = xPropertySet->getPropertySetInfo();

Sample code 1. https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Properties#Example:_query_and_change_the_properties 2. https://incubator.apache.org/odftoolkit/simple/document/cookbook/Manipulate%20Metadata.html#Access%20the%20user%20defined%20element




回答2:


Here are links to Java code to do these things:

My questions are first how can i adress the currently open file in the writer?

See How to get the opened document using UNO?

And how can i access the metadata after I told the programmm from which file it should get the data?

See https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=80124.



来源:https://stackoverflow.com/questions/34942951/how-can-i-get-user-defined-properties-of-an-open-office-document

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