[[Thanks to Reza too!]]
I like the
File > Properties > Custom properties ...
Now, since the Ooo actually stores the documents in a zipped xml format, the variables can be accessed through the linux domain with for example:
unzip -pa $oooFile meta.xml | tr -s "<" "\n" | grep "$KEY" | tr -s ">" "\n" | tail -n 1
(Yes, there is a flaw, since if there would be $KEY’s that are substrings of each other, it could fail, I’ll leave to the happy hacker to fix that and post here in that case. I’ll solve it by choosing my property names.).
The Ooo file is unzipped, but only the
meta.xml is extracted. We then replace the “<" with carriage returns to split the XML tags from their contents. We also strip at the end of the value of the property.
Now, encapsulating this in a function, for example
daisyGetVarOoo.sh is easy as a cake. And multiple variables can be extracted on another level, for example:
docRepo=`daisyGetVarOoo.sh $oooFile "$KEY"`
docNo=`daisyGetVarOoo.sh $oooFile "$KEY"`
docType=`daisyGetVarOoo.sh $oooFile "$KEY"`
docTag=`daisyGetVarOoo.sh $oooFile "$KEY"`
docRev=`daisyGetVarOoo.sh $oooFile "$KEY"`
Using the same approach, it is also easy to modify the existing property and replace the
meta.xml file in the zipped archive. Through linux we can therefore create and change the variables. This is quite handy in a documention versioning system – or if you want to bulk change names or sanity check variables settings in large batch of files.