Re: API to retrieve document metadata
Ariel Constenla-Haile <[email protected]> Thu, 3 Nov 2011 06:50:14 -0300
| Newsgroups | gmane.comp.openoffice.questions |
|---|---|
| Message-ID | <20111103095014.GB28090@localhost> |
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
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJOsmPVAAoJEMjP1bm45QNW7w8P/3YuklLq37qscXeuoktcdTYq v33BbgI0K/G9MexJdJ9bdSOI2iZVnhVPbCRhLhqERTOjmsErc/eyEaLhWchDqcog W/jOzGzGkfILQl63jmmMem3kbqgk0t5m0p5zCT9iMoU/NEk8JYs/zMa6SUFm3GIJ 9SYRunzXzld1JKlPw2o650Z9QJJxl1BEVfcpVv+G4ojVpzx/wVM8e+ArYJMAknS5 MUAP3pdWZEr/kUnPaQaL2juWun7nP2uLQJyHPw5cRVkZ3caNT7JVVJTzU583C/5/ vNrTHaF3uLhn/jDqF9MPKpLSBCaFSTyTh2iX12uCntdWxrhvEpVGzHc3l87HUa25 i2QbgZD/EbTOogzwLfKJtPQo4Igr5YhocWSQsV1bLXdUdtkmhgyCBvFF4ecQ4SOP mtqFej6xG6uVLxoeEy8DPgpcG7wokQ7qi33oyYwBmf12HAQ3SvjGybPYLfxALhTB RICRCbpfQ1Nd6N3+OKWJwWvIq10ft01hVbTtAxKF8rwZ+pkHtPobuE3v2RLk7WP/ lSiLMpVJdLQSNPA2vZINxqrpTgqA7D05tMLLj4QndQZOwA/OqMuMkgEGbw402Bar e/KGfK2vpu6jz3+rAVW5wYCvUt92fg51ViR8SWcwEbbjRvO6WYfS+r7+unZdCHpk TU5EUHLoORlYeAzbwxcC =M9SO -----END PGP SIGNATURE-----