SVG Import Source Code

From Apache OpenOffice Wiki
Revision as of 20:42, 18 April 2006 by Haui (Talk | contribs)

Jump to: navigation, search
OOoSVG-110.png
SVG Import
(external impl.)
Overview
Download
Source code
Features
Restrictions
FAQ
TODO
OpenDocument
Gradients
Group opacity
Elliptic arcs
Path semantics
Coordinate systems

There is some interest in integrating the filter into the OpenOffice.org project. Until this completed, you can checkout the sources from my SVN repository. This pages describes how to get the sources and build the filter yourself.

Be warned: The sources are currently not in the best condition. Much documentation is still missing. To get started anyway, you need at least some overview of the project. I quote the following from my mail to dev@graphics.openoffice.org:

The SVG import filter project currently consists of four "sub-projects":

  1. The integration component svg-import. This provides a XImportFilter. This filter builds an annotated SVG DOM tree using Batik, transforms it into an OpenDocument DOM tree using svg2office and finally translates the resulting OpenDocument DOM into SAX events, which are fed into the XDocumentHandler that is provided by OpenOffice.org.
  2. The svg2office transformation is structured as visitor of a SVG DOM tree, which is provided by Batik. During its visit, the transformation builds OpenDocument DOM nodes. For the OpenDocument DOM, currently, a generic DOM implementation is used (provided by [Java:javax/xml/parsers/DocumentBuilder javax.xml]). To avoid writing string constants and to have at least some sort of type checking and IDE support, facade classes are generated directly from the RelaxNG schema of the OpenDocument specification. This is accomplished by rng2dom. The transformation itself mainly relies on the information provided by the SVG DOM API as specified by w3.org. Only where this is not sufficient, implementation details from the Apache Batik SVG engine are used. This means, that the transformation is not built as Batik backend (a transcoder that acts on behalf of the Batik-internal GVT rendering tree). The Batik-internal GVT rendering tree is therefore only consulted, where context information is required, which is not offered by the SVG DOM.
  3. rng2dom is a set of transformations that distill information out of a RelaxNG schema for data-binding. The transformations that are implemented are relatively advanced, but the generated facade classes do not make much use of theses features yet. The OpenDocument DOM facade simply provides a bunch of methods to create elements from the different OpenDocument namespaces and to get and set attributes for these elements in a more or less generic fashion. This sub-project is not an integral part of the filter, since the only dependency is the generated access code for the OpenDocument DOM. This generated code is included in the svg2office source tree. Therefore, you do not need this project to successfully compile your SVG import filter.
  4. A (minimally) hacked version of xml-batik. That's a pity, but batik was not primarily designed to offer it's SVG DOM to third parties. All transcoders in batik rely on the internal GVT tree for rendering, not for transformation. Therefore, the implementation of some "advanced" features of the SVG DOM (like non-exposed subtrees for certain elements) are not yet implemented. To make svg-import more complete, some more effort is necessary to evolve missing features in batik.

To get started, you have to check out all four projects from SVN. The best way to do that is to change to your (Eclipse) workspace directory and type the following commands:

1. Check out svg-import:

svn --username anonymous --password '' co 
	http://svn.ipd.uka.de/repos/hauma/haui/trunk/svg-import/

2. Check out svg2office:

svn --username anonymous --password '' co 
	http://svn.ipd.uka.de/repos/hauma/haui/trunk/svg2office/

3. Optionally check out rng2dom (see above):

svn --username anonymous --password '' co 
	http://svn.ipd.uka.de/repos/hauma/haui/trunk/rng2dom/

4. Check out a matching revision of xml-batik:

svn co -r321327
	http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk xml-batik

Afterwards, you have to apply the patches to batik. The patch file is provided in svg2office/patches. If your current working directory is your workspace, the following should do:

cd xml-batik
patch -p0 < ../svg2office/patches/xml-batik.patch
cd ..

All projects are prepared for the Eclipse IDE. After you have added them to your workspace, eclipse compiles all the sources for you.

You can also build things by hand. You need Apache Ant (http://ant.apache.org/) for executing the build scripts.

First, build Batik:

cd xml-batik
ant compile

Second, build the tranformation library svg2office:

cd svg2office
ant
cd ..

Now, you are ready, to create the UNO package and install it into your OpenOffice.org. The following assumes that you have an Apache Ant installed and your OpenOffice.org installation is located at /opt/openoffice.org1.9.122 (Note: you should use a more up-to-date release of OpenOffice.org now!).

Last but not least, build the filter and install it into your OpenOffice.org:

cd svg-import
ant -Dooo.home=/opt/openoffice.org1.9.122 install

If everything went fine, you now have a home-browen SVG import filter installed as package within your . The zip file of the created UNO package can be found in svg-import/build.

Haui 22:42, 18 April 2006 (CEST)

Personal tools