Closer examination of the OpenOffice format reveals that a text document is in fact saved as a zipped collection of xml files. Moreover OpenOffice's word processor supports user-defined properties; from File choose Properties and select the user-defined tab. You can then put the text $Revision: $ in one of these properties as shown below:
(Actually any text could be used, but I chose $Revision: $ to be consistent with normal keyword substitution in cvs.) You can then use this property in your document by selecting Insert | Fields | Other and expand the User-Defined item to choose the one containing $Revision: $.
This still leaves the problem of how to update this value. The solution I came up with is a Python script that you invoke when checking in instead of the normal cvs checkin. You can download this script here.When you run it something like the following should appear:
[pmu@mblinux python]$ sxw_checkin.py testdoc2.sxw "Eighth version"
+++> unzip -o testdoc2.sxw meta.xml
Archive: testdoc2.sxw
inflating: meta.xml
+++> zip testdoc2.sxw meta.xml
updating: meta.xml (deflated 56%)
+++> cvs ci -m"Eighth version" testdoc2.sxw
Checking in testdoc2.sxw;
/software/cvsroot/scripts/python/testdoc2.sxw,v <-- testdoc2.sxw new revision: 1.8; previous revision: 1.7 done
And hey presto! the property in the OpenOffice document has been updated (in this example it would now have the value "1.8").
Small print: I have only used the script on OpenOffice text documents so I can't say whether it works for the other tools that OpenOffice provides; please let me know if you try it!
No comments:
Post a Comment