Products

Microsoft Office and Subversion (Part 2)

In Part 1, we worked out how you access your documents located in a Subversion repository.
In this part we will discuss several ideas how you could expose Subversion meta data, like version information, (last) author, date and so on in your document.
Currently, it is very annoying always to update version number. Most time it will be forgotten and the document is being published to third parties with wrong version number leading to confusion. Let Subversion take care on document properties.

We have two possibilities to expose Subversion information, direct and via Microsoft Office document properties and field operators.

“Direct” Exposure


This method is pretty straight forward. Just type in somewhere in your document following placeholders:

$Author:: $
$Rev:: $
$Date:: $

You can put one these entries in any place, header page or page header and/or footer are usual locations. By entering blanks between the double colon “::” and the last “$” you reserve space even in the binary formats of Microsoft Office.
After committing you document back into server, Subversion replaces each time the placeholders and it looks like this:

$Author:: neherr $
$Rev:: 150 $
$Date:: 2007-09-26 07:52:07 +0200 (Wed, 26 Sep 2007)$

It does not look nice but it is useful. If you like to reformat this ugly information after an update, you need to throw an eye on the next method for Subversion meta data exposure.

Hint Experienced Subversion users should not play with plain placeholders you normally use in text files, like “$Rev$”, i.e. without blanks to preserve space for Subversion data. After a commit your document is scrambled and you cannot read nor open it anymore.

Exposure through Microsoft Office Fields


Before we can use fields, we define document properties which Subversion updates with each commit.
Open Microsoft Office document properties dialog as shown on the right side.

I added the screen-shot for proud owners of the new Microsoft Office 2007. In the first weeks, most time spending not with writing documents but to search features and functions known from former versions but moved (hidden?) to new locations. You click on this round Office symbol on the top left corner and you will find the properties under the topic “Prepare”.

A big bar above of your document opens. Click on the “I” info button and select “Advanced Properties…”.

Owners of the “old” versions just open the “Properties” to be found in the “File…” menu.

advancedproperties.gif

Finally, finally, we landed in the right dialogue to define our properties.

Click on the “Summary” tab and enter the Subversion placeholder for author as shown, if the document author should be maintained by Subversion here.
Please be aware that Subversion’s understanding of author is the person who updated the document most recently.

fixedlength.gif

Next click on “Custom” tab and enter two new custom properties. Please have a look on the screen-shot on the right hand side.

The name you enter is up to you. Define type as “Text” and in value you enter the Subversion placeholder as described in first section of this blog.

With the following step we are using fields to show Subversion meta data information in our document.
Click somewhere in your document where you like to show Subversion meta data and enter <Ctrl>F9. A pair of bracket appears. Enter following between the two brackets:
My first SVN property shown in my document: { DOCPROPERTY Author # MERGEFORMAT }.
Now the second follows: { DOCPROPERTY SVNRevision # MERGEFORMAT }.

Now the third one: { DOCPROPERTY SVNLastUpdate # MERGEFORMAT }.

The string after the “DOCPROPERTY” corresponds with the name of your custom property you entered above.
After you checked in your document select the entire document by pressing <Ctrl>A, et viol? .

Instead of the field definition you see the field content, like this:

My first SVN property shown in my document: $author:: neherr $.
Now the second follows: Revision: $Rev:: 151 $.

Now the third one: Last change date: $Date:: 2007-09-26 23:01:48 +0200 (Wed, 26 Sep 2007#$.

Due to the fact that the data exposed in both methods looks pretty ugly, macros could be triggered to cleanup and format Subversion revision information.
For this purpose it is much better to check out blogs on Microsoft’s web site.

Best Wishes
Robert

Stroebele Timothy

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at https://blogs.stage.sw.siemens.com/polarion/microsoft-office-and-subversion-part-2/