I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-03-04 04:25:05.297151-08 by jmgdoc
How to extract the user field names from a document

I privately got the following question, whose answer may concern other users, about the document user fields:

"What is the method call sequence that will return a list of User Fields (preferably used within the document as distinguished from those defined but not used) in an Open Office Text Document?"

The specialized, mnemonic method to do that is not implemented yet, but it's easy to implement it using the generic getElementList() method with an appropriate XPath query. The following instruction (assuming that $doc is a properly initialized document content) returns the full list of declared user fields:
my $query = '//text:user-field-decl'; @fields = $doc->getElementList($query));

If we need to get the displayed fields (and not those which are declared but not used), the right query is '//text:user-field-get' instead of '//text:user-field-decl'.

Well, we know how to get a list of user field elemets, but what about the names of the selected elements ?

Like with many other Open Document named objects, the name of a user field is stored in a 'text:name' attribute, so it may be got using the generic getAttribute() method. The following example prints the field name for every user field occurrence in the document body (beware: the same name may appear more than one time, because the same user field may be displayed more than once through the document):
foreach my $uf ($doc->getElementList('//text:user-field-get')) { my $name = $doc->getAttribute($uf, 'text:name'); print "$name\n"; }

Direct Responses: 12526 | Write a response
Posted on 2010-03-10 08:38:18.210528-08 by jmgdoc in response to 12502
Re: How to extract the user field names from a document


With the latest release of OpenOffice::OODoc, the simplest way to print the names of the user-defined fields is shown below:
print $doc->objectName($_) . "\n" for $doc->getUserFields;

Direct Responses: Write a response