How can i get user defined properties of an Open O

2019-09-23 07:26发布

问题:

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.