Erwin's StarOffice Tango
Erwin Tenhumberg's Insights into Open Source and Dancing
... or why Open Competition matters

20070629 Freitag Juni 29, 2007

OpenOffice.org API Tutorial
I'm not sure if I already mentioned the article "An Introduction to the OpenOffice.org API", but I think it's worth mentioning because it's seems to be a very detailed tutorial about the OpenOffice.org API.
( Jun 29 2007, 03:53:01 PM CEST ) Permalink


ODF conversion with Ant
I'm most likely not the world's best hacker and probably that's why I'm in marketing now, but I still thought it would be useful to share the following information. In case you did not know, it's quite easy to modify ODF files using Ant scripts. Here is the screenshot of a testdoc.odt file that includes some information which I want to remove with a script.



As you can see in the screenshot, the file contains change tracking information, a line that is marked with a style sheet called "Confidential", a phone number and an email address. I want to remove all these pieces of information with a script, so that other people can't see them anymore.

Important disclaimer: The sample script below just wants to illustrate the general concept, but does not necessarily try to be perfect. Thus, don't rely on the sample below to remove confidential information from your really confidential files!

First, if you haven't done it yet, you need to download and install Apache Ant. Depending on the platform you also will have to set a few environment variables, so that the system can find the Ant libraries:


export ANT_HOME=/odfdev/apache-ant-1.7.0
export JAVA_HOME=/usr/java
export PATH=${PATH}:${ANT_HOME}/bin



The following code shows an example of a Ant build.xml build script:


<?xml version="1.0"?>

<project default="update-content">

	<!--
	Names of the files that will be used by the Ant script
	-->

	<property name="document.src" value="testdoc.odt"/>
	<property name="document.dest" value="converteddoc.odt"/>
	<property name="unpack.dir" value="./unpack"/>
	<property name="content.src" value="${unpack.dir}/content.xml"/>
	<property name="content.dest" value="./newcontent.xml"/>
	<property name="conversion.style" value="./conversion.xsl"/>


	<!--
	Deleting files from previous conversions
	-->
	<target name="clean">

		<echo message="Deleting old temporary conversion files..."/>
		<delete file="${document.dest}"/>
		<delete file="${content.dest}"/>

	</target>


	<!--
	Unzipping the ODF document in order to get access to the content.xml file
	-->

	<target name="unzip" depends="clean">

		<echo message="Unzipping document..."/>
		<unzip src="${document.src}" dest="${unpack.dir}"/>

	</target>


	<!--
	Converting the content.xml file using XSLT
	-->

	<target name="convert" depends="unzip">

		<echo message="Converting..."/>
		<xslt in="${content.src}" out="${content.dest}"

			style="${conversion.style}">
			<outputproperty name="method" value="xml"/>
			<outputproperty name="indent" value="yes"/>

		</xslt>

	</target>


	<!--
	Updating the ZIP container, i.e. replacing the content.xml file	with the converted version
	-->

	<target name="update-content" depends="convert">

		<echo message="Updating..."/>
		<copy file="${document.src}" tofile="${document.dest}" preservelastmodified="true" />
		<delete file="${content.src}"/>
		<copy file="${content.dest}" tofile="${content.src}"/>
		<touch file="${content.src}"/>
		<zip update="true" destfile="${document.dest}" basedir="${unpack.dir}"/>

	</target>

</project>



The Ant build script unzips a testdoc.odt file into a folder called unpack, converts the content.xml file using an XSL file, creates a copy of the testdoc.odt file name converteddoc.odt, and then updates the ZIP container of the converteddoc.odt file with the new content.xml file. The used XSL file looks as follows:


<?xml version="1.0"?>

<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		version="1.0"
		xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
		xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
		xmlns:xalan="http://xml.apache.org/xalan"
		exclude-result-prefixes="xalan">


	<!--identity copy -->
	<xsl:template match="node()|@*" name="copy">
		<xsl:copy>
		<xsl:apply-templates select="node()|@*"/>
		</xsl:copy>
	</xsl:template>


	<!-- remove tracking information -->
	<xsl:template match="text:tracked-changes"/>
	<xsl:template match="text:change-end"/>
	<xsl:template match="text:change-start"/>
	<xsl:template match="text:change-region"/>
	<xsl:template match="text:change"/>


	<!-- remove confidential/private information -->
	<xsl:template match="text:p">
 		<xsl:choose>
		<xsl:when test="starts-with(., 'Phone')">
			<xsl:comment>
			<xsl:text>Removed phone number!</xsl:text>
			</xsl:comment>
			</xsl:when>

		<xsl:when test="contains(., '@sun.com')">
			<xsl:comment>
			<xsl:text>Removed email address!</xsl:text>
			</xsl:comment>
			</xsl:when>

		<xsl:when test="@text:style-name[contains(., 'Confidential')]">
			<xsl:comment>
			<xsl:text>Removed confidential information!</xsl:text>
			</xsl:comment>
			</xsl:when>

		<xsl:otherwise>
			<xsl:call-template name="copy"/>
			</xsl:otherwise>


		</xsl:choose>

	</xsl:template>

</xsl:stylesheet>



The conversion.xsl file removes change tracking information, removes lines that start with the word "Phone", removes lines that contain "@sun.com", and removes lines marked with a style called "Confidential". If Ant is run using the files mentioned above, the result looks as follows:



As said above, the build script and the XSL file are far from being perfect, but probably are sufficient to illustrate how Ant can be used to convert ODF files.
( Jun 29 2007, 12:15:26 PM CEST ) Permalink


German City of Freiburg joins the ODF Alliance
According to the latest ODF Alliance newsletter, the German City of Freiburg just joined the ODF Alliance. "The Alliance now includes 412 member organization in 52 countries."
( Jun 29 2007, 09:25:21 AM CEST ) Permalink Kommentare [2]


20070625 Montag Juni 25, 2007

NetBeans podcast talks about OpenOffice.org API plug-in
The NetBeans podcast #30 talks about the OpenOffice.org API plug-in for NetBeans. Check it out!
( Jun 25 2007, 11:28:23 AM CEST ) Permalink


20070622 Freitag Juni 22, 2007

Regarding OpenOffice.org development with NetBeans
People interested in OpenOffice.org development with NetBeans might be find the following NetBeans review useful:
"Ok, I admit the title is a bit inflammatory to Eclipse fans. But after working with NetBeans 6 over the last week, I have to say I am very impressed. This is not simply a minor upgrade, as is so common in IDEs these days even when they are given a new major version number. Quite the contrary, NetBeans 6 is a major new release, and a major improvement over NetBeans 5.5."
The full article can be found here.
In addition, there will be a session about "OpenOffice.org Development with NetBeans" at the OpenOffice.org Conference 2007. The NetBeans plug-in can be found here.
( Jun 22 2007, 12:57:57 PM CEST ) Permalink


Positive OpenOffice.org Review
"IT managers looking for alternatives to Microsoft Office—particularly those unwilling to make the leap to Office 2007—will find OpenOffice.org 2.2 well worth evaluating because, as the suite offers a good solution for cutting software costs while expanding platform options and minimizing compatibility issues."
The full review can be found here.
( Jun 22 2007, 12:46:22 PM CEST ) Permalink


20070613 Mittwoch Juni 13, 2007

DTP with OpenOffice.org
"Draw and Writer have similar tools for positioning text, but Draw is better suited for text mixed with graphics or for highly variable pages, while Writer is designed for text-heavy documents with minimal variation in the pages. Both lack some of the fine controls of a high-end layout program, but their features are complete enough that either can be used to produce professional-looking work.
...
Despite some limitations and omissions, both Draw and Writer are more than adequate for many desktop publishing tasks. Several publishing houses, including No Starch Press, have experimented with using Writer as their basic layout program -- a move that saves time, since writers can work in a standard template that designers do not have to reformat before sending books to the printer."
The full article by Bruce Byfield can be found here.
( Jun 13 2007, 03:32:24 PM CEST ) Permalink Kommentare [2]


20070612 Dienstag Juni 12, 2007

New OpenOffice.org extensions
I just was made aware of two new extensions for OpenOffice.org: "Groovy For OpenOffice" and "Writer's Tools". Groovy for OpenOffice "adds support for writing macros in Groovy" and Writer's Tools includes tools like Google Translate "which allows users to quickly translate selected text fragments between different languages using the Google Translate service".

People interested in developing their own extensions for OpenOffice.org might want to check out the OpenOffice.org API Plug-in for NetBeans and the Extensions Project on OpenOffice.org. Developers also might find this article by Kay Koll useful.
( Jun 12 2007, 10:39:20 AM CEST ) Permalink


OOXML vs. ODF comparison by Sam Hiser
Sam Hiser just published an OOXML vs. ODF comparison. The document can be found here.
( Jun 12 2007, 10:30:47 AM CEST ) Permalink


20070604 Montag Juni 04, 2007

Aqua developer snapshot available
A developer snapshot of the Aqua version of OpenOffice.org has been made available. More details can be found here.
( Jun 04 2007, 09:40:04 PM CEST ) Permalink Kommentare [3]


Positive usibility certification for Munich's Linux client
According to this German press release, Munich's Linux client "LiMux" just got a positive certification from TÜViT regarding its usability. The Linux client meets the requirements of the standards DIN EN ISO 9241 - 110 and - 11. From my point of view, this is just another proof point that the world is ready for alternative desktop clients.
( Jun 04 2007, 11:14:18 AM CEST ) Permalink


For the open source hackers
Open source hackers might want to check out the new Sun Studio 12 compiler tools. It's a free download! Linux tools are included.
( Jun 04 2007, 11:02:14 AM CEST ) Permalink


20070601 Freitag Juni 01, 2007

Good news for Sun
I just read "Worldwide Revenue from Standalone Open Source Software Will Grow 26% to Reach $5.8 Billion by 2011, IDC Research Indicates". This is good news for Sun considering Sun's strong commitment to open source.
( Jun 01 2007, 03:20:12 PM CEST ) Permalink Kommentare [1]



Archive
Links
Referenzierte URLs