I use OpenOffice.org for my home office suite. The only Microsoft Office product that is on one of my systems is Access 2000, and only because I use it for a personal-use application I have not gotten around to upgrading.

OpenOffice.org uses the OpenDocument Format specification as its internal file format. ODF is an XML-based file format, so an OpenOffice.org document is a collection of XML files stored in a ZIP archive. What a perfect opportunity to get acquainted with the CFZip tag in ColdFusion 8!

I created a simple document using OpenOffice.org Writer with a single line, This is a test document, and saved it as test.odt. The test sentence contains 24 characters...remember that number.

Like CFFile, the CFZip tag has an action attribute that specifies what action you would like to take on a ZIP archive. Since I am interested in seeing what files are in the archive, I will use the "list" action:

view plain print about
1<!--- Like CFFile, CFZip requires an absolute path to the ZIP archive. --->
2<cfset variables.odfTextDocument = getDirectoryFromPath(expandPath('test\')) & "test.odt" />
4<cfzip action="list"
5    file="#variables.odfTextDocument#"
6    name="variables.contents">

8<cfdump var="#variables.contents#">

The "list" action returns a query object:

As you can see, the archive contains a group of XML files which describe the document. The meta.xml file contains general information about the document. Reading in that file uses the "read" action for CFZip:

view plain print about
1<cfzip action="read"
2    file="#variables.odfTextDocument#"
3    entrypath="meta.xml"
4    variable="variables.meta">

6<cfdump var="#xmlParse(variables.meta)#">

Dumping the resulting XML gives us information about when the document was created, who created it, editing history, and document statistics, like character counts:

Remember the number of characters in the test sentence?