Got it.
For the record or any other person looking this up, here's a small (Scala)
snippet to read all variables and their default values.
Please note that trying to do TextDocument.getVariableFieldByName always
returns an empty field value…
val container = template.getVariableContainerElement()
val children = container.getElementsByTagName("text:user-field-decl")
var length = children.getLength()-1
for (i <- 0 to length) {
children.item(i) match {
case child: TextUserFieldDeclElement =>
println("Child Name : "+child.getTextNameAttribute())
println("Child Value: "+child.getOfficeStringValueAttribute())
case _ =>
}
}
Thanks,
Torsten.
Am 11.10.2013 um 18:06 schrieb Torsten Uhlmann <[email protected]>:
> Hi,
>
> I'm trying to find a way in the Simple Api to iterate through all defined
> (Variable) Fields of an ODT text document.
> I know there is the "getVariableFieldByName", but in my case I don't know the
> defined fields beforehand.
> I want to read through all of them and replace them with a value from a data
> store.
>
> Sorry if there is an example or post already explaining this- didn't find
> anything.
>
> I'm using simple-odf 0.7-incubating.
>
> Thanks for your help,
> Torsten.