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";
}