Re: API to retrieve document metadata
"Alona Rossen" <[email protected]> Thu, 3 Nov 2011 10:12:44 -0400
| Newsgroups | gmane.comp.openoffice.questions |
|---|---|
| Message-ID | <[email protected]> |
Hello Ariel, We access ODF files and we do not modify the files. Attached is a MS Visual Studio 9 project. Regards, Alona -----Original Message----- From: Ariel Constenla-Haile [mailto:[email protected]] Sent: Thursday, November 03, 2011 5:50 AM To: [email protected] Subject: [users] Re: API to retrieve document metadata Hello Alona, On Wed, Nov 02, 2011 at 04:39:29PM -0400, Alona Rossen wrote: > Hi Ariel, > > We created an ran the test application following your advice. > > We found that xDocProps->getKeywords() and > xDocProps->getDocumentStatistics() return empty sequences although OO > documents do have properties viewable via OO GUI. are you working with ODF files or with MSOffice files? Are you just loading the document and getting the doc. properties, or are you getting them after you have done some changes? In the later case, you have to refresh the document to get the actual statistics in the document properties. > > try > { > Sequence< OUString > aSNL = xDocProps->getKeywords(); > printf("Keywords:\n"); > OUString format(RTL_CONSTASCII_USTRINGPARAM(" %s\n")); > for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) > { > wprintf(format.getStr(),aSNL[i]); this cannot work: aSNL[i] is an rtl::OUString instance, not a NULL terminated character array. Look at the U2C macro in my example for a way to convert the rtl::OUString. > } > } > > aSNL.getLength() returns 0 > > > try > { > Sequence< ::com::sun::star::beans::NamedValue > aNV = > xDocProps->getDocumentStatistics(); > printf("DocumentStatistics:\n"); > OUString format(RTL_CONSTASCII_USTRINGPARAM("%s: > %s\n")); > for( sal_Int32 i = 0; i < aNV.getLength(); i++ ) > { > //some code goes here > } > > aNV.getLength() returns 0 this is strange, if you're working with OOo Writer documents. If you have set up the OOo SDK environment properly, you may try the following example http://people.apache.org/~arielch/api/DocumentProperties/ It has a Makefile and a sample document. You can modify the Makefile to load the document you are using in your tests, and compare the output of this program with yours. Simply replace in the Makefile TEST_DOC = DocumentProperties.odt with the name of your document, and place the document inside that folder. I tested the example both on Win (MS VS 2008 Express) and Linux. You will need an OOo 3.3 SDK because the example uses css.util.Duration, introduced in that version. If you have an earlier OOo SDK, you can adapt the code to make it compile. Regards -- Ariel Constenla-Haile La Plata, Argentina -- ----------------------------------------------------------------- To unsubscribe send email to [email protected] For additional commands send email to [email protected] with Subject: help
DocumentLoader.zip
(application/x-zip-compressed, 152.4 KB) - not displayed