Difference between revisions of "SVG Import Source Code"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Updated.)
m (removed historical page from its category list)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{historical}}
 +
 
{{SVGTOC}}
 
{{SVGTOC}}
 
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.
 
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.
Line 4: Line 6:
 
<b>Be warned</b>: 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:
 
<b>Be warned</b>: 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":
+
The SVG import filter project currently consists of several sub-projects that are described below.
  
<ol>
+
=== OpenOffice.org Extension (svg-import) ===
<li>The  integration component <b>svg-import</b>. This provides a [[Main_XImportFilter|XImportFilter]]. This filter builds an annotated SVG DOM tree using Batik, transforms it into an [[OpenDocument]] DOM tree using <b>svg2office</b> and finally translates the resulting [[OpenDocument]] DOM into SAX events, which are fed into the [[Main_XDocumentHandler|XDocumentHandler]] that is provided by OpenOffice.org.</li>
+
  
<li>The <b>svg2office</b> 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/[[Main_DocumentBuilder|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 [[Main_RelaxNG|RelaxNG]] schema of the [[OpenDocument]] specification. This is accomplished by <b>rng2dom</b>.
+
This provides a [[Main_XImportFilter|XImportFilter]]. This filter builds an annotated SVG DOM tree using Batik, transforms it into an [[OpenDocument]] DOM tree using <b>svg2office</b> and finally translates the resulting [[OpenDocument]] DOM into SAX events, which are fed into the [[Main_XDocumentHandler|XDocumentHandler]] that is provided by OpenOffice.org.
  
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.</li>
+
=== SVG to ODG Transformation kernel (svg2office) ===
  
<li><b>rng2dom</b> is a set of transformations that distill information out of a [[Main_RelaxNG|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.
+
The <b>svg2office</b> 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/[[Main_DocumentBuilder|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 [[Main_RelaxNG|RelaxNG]] schema of the [[OpenDocument]] specification.  
  
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 <b>not</b> need this project to successfully compile your SVG import filter.</li>
+
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.
  
<li>A (minimally) hacked version of <b>xml-batik</b>. 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.</li>
+
=== Java OpenDocument Processing (haui.office) ===
</ol>
+
 
 +
<b>haui.office</b> is a library for manipulating OpenDocument documents in pure Java.
 +
 
 +
=== Various Utilities ===
 +
 
 +
* <b>haui.collections</b> is a rudimentary library for sequences.
 +
 
 +
* <b>net.sf.wtk.xml</b> is a library for visitor-based XML DOM processing.
 +
 
 +
* <b>net.sf.wtk.ant.namespaces</b> a tool for introducing namepaces into Apache Ant build files to describe dependencies among projects.
 +
 
 +
* <b>net.sf.wtk.ant.maven</b> a stub for the Apache Ant libraries for automatically downloading dependencies from Maven repositories.
 +
 
 +
=== Apache Batik SVG Engine (xml-batik) ===
 +
 
 +
A (minimally) hacked version of <b>xml-batik</b>. 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.
 +
 
 +
 
 +
== Checking out the sources ==
  
 
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:
 
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:
Line 24: Line 43:
 
1. Check out svg-import:
 
1. Check out svg-import:
 
<pre>
 
<pre>
svn --username anonymous --password '' co  
+
svn --username anonymous --password '' co \
http://svn.ipd.uka.de/repos/hauma/haui/trunk/svg-import/
+
    http://svn.ipd.uka.de/repos/hauma/haui/trunk/svg-import/
 
</pre>
 
</pre>
  
 
2. Check out svg2office:
 
2. Check out svg2office:
 
<pre>
 
<pre>
svn --username anonymous --password '' co  
+
svn --username anonymous --password '' co \
http://svn.ipd.uka.de/repos/hauma/haui/trunk/svg2office/
+
    http://svn.ipd.uka.de/repos/hauma/haui/trunk/svg2office/
 
</pre>
 
</pre>
  
3. Optionally check out rng2dom (see above):
+
3. Check out haui.office
 
<pre>
 
<pre>
svn --username anonymous --password '' co  
+
svn --username anonymous --password '' co \
http://svn.ipd.uka.de/repos/hauma/haui/trunk/rng2dom/
+
    http://svn.ipd.uka.de/repos/hauma/haui/trunk/haui.office/
 
</pre>
 
</pre>
  
4. Check out a matching revision of xml-batik:
+
4. Check out haui.collections:
 
<pre>
 
<pre>
svn co -r321327
+
svn --username anonymous --password '' co \
http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk xml-batik
+
    http://svn.ipd.uka.de/repos/hauma/haui/trunk/haui.collections/
 
</pre>
 
</pre>
  
Afterwards, you have to apply the patches to batik. The patch file is provided in <tt>svg2office/patches</tt>. If your current working directory is your workspace, the following should do:
+
5. Check out net.sf.wtk dependencies:
 +
<pre>
 +
svn co https://wtk.svn.sourceforge.net/svnroot/wtk/trunk/net.sf.wtk.ant.namespaces/
 +
svn co https://wtk.svn.sourceforge.net/svnroot/wtk/trunk/net.sf.wtk.ant.maven/
 +
svn co https://wtk.svn.sourceforge.net/svnroot/wtk/trunk/net.sf.wtk.xml/
 +
</pre>
  
 +
6. Check out a matching revision of xml-batik:
 
<pre>
 
<pre>
cd xml-batik
+
svn co -r571815 \
patch -p0 < ../svg2office/patches/xml-batik.patch
+
    http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk xml-batik
cd ..
+
 
</pre>
 
</pre>
  
All projects are prepared for the Eclipse IDE. After you have added them to your workspace, eclipse compiles all the sources for you.
+
== Building the sources ==
  
You can also build things by hand. You need Apache Ant (http://ant.apache.org/) for executing the build scripts.
+
Afterwards, you have to apply the patches to batik. The patch file is provided in <tt>svg2office/patches</tt>. If your current working directory is your workspace, the following should do:
  
First, build Batik:
 
 
<pre>
 
<pre>
 
cd xml-batik
 
cd xml-batik
ant compile
+
patch -p0 < ../svg2office/patches/xml-batik-r571815.patch
 +
cd ..
 
</pre>
 
</pre>
  
Second, build the tranformation library svg2office:
+
All projects are prepared for building with either Eclipse or Apache Ant (http://ant.apache.org/).
 +
 
 +
Ant build files have propper dependencies so that building the top-most project (svg-import) automatically builds all dependencies. The only dependency that has to be resolved manually is the dependency to your local OpenOffice.org installation for accessing the UNO runtime interface libraries. Therefore, the path to your local OpenOffice installation must be entered into the following properties file:
 +
 
 
<pre>
 
<pre>
cd svg2office
+
cd svg-import
ant
+
cp .local.properties.example .local.properties
 +
vi .local.properties
 
cd ..
 
cd ..
 
</pre>
 
</pre>
  
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 <tt>/opt/openoffice.org1.9.122</tt> (Note: you should use a more up-to-date release of OpenOffice.org now!).
+
Now, you are ready to build the OpenOffice.org extension:
  
Last but not least, build the filter and install it into your OpenOffice.org:
 
 
<pre>
 
<pre>
 
cd svg-import
 
cd svg-import
ant -Dooo.home=/opt/openoffice.org1.9.122 install
+
ant extension
 
</pre>
 
</pre>
  
If everything went fine, you now have a home-browen SVG import
+
If everything went fine, you find a home-browen SVG import
filter installed as package within your . The zip file of the created UNO package can be found in <tt>svg-import/build</tt>.
+
filter <tt>svg-import.oxt</tt> in the directory <tt>svg-import/build</tt>, which can be installed into OpenOffice.org using the integrated package manager.  
  
[[User:Haui|Haui]] 22:42, 18 April 2006 (CEST)
+
-----
 +
Last update: [[User:Haui|Haui]] 21:43, 5 September 2007 (CEST) for building version 1.2.2 of the import filter.

Latest revision as of 07:53, 22 June 2012

This page is archived for historical reasons only. It is no longer maintained and information may not be current.

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 several sub-projects that are described below.

OpenOffice.org Extension (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.

SVG to ODG Transformation kernel (svg2office)

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.

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.

Java OpenDocument Processing (haui.office)

haui.office is a library for manipulating OpenDocument documents in pure Java.

Various Utilities

  • haui.collections is a rudimentary library for sequences.
  • net.sf.wtk.xml is a library for visitor-based XML DOM processing.
  • net.sf.wtk.ant.namespaces a tool for introducing namepaces into Apache Ant build files to describe dependencies among projects.
  • net.sf.wtk.ant.maven a stub for the Apache Ant libraries for automatically downloading dependencies from Maven repositories.

Apache Batik SVG Engine (xml-batik)

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.


Checking out the sources

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. Check out haui.office

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

4. Check out haui.collections:

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

5. Check out net.sf.wtk dependencies:

svn co https://wtk.svn.sourceforge.net/svnroot/wtk/trunk/net.sf.wtk.ant.namespaces/
svn co https://wtk.svn.sourceforge.net/svnroot/wtk/trunk/net.sf.wtk.ant.maven/
svn co https://wtk.svn.sourceforge.net/svnroot/wtk/trunk/net.sf.wtk.xml/

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

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

Building the sources

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-r571815.patch
cd ..

All projects are prepared for building with either Eclipse or Apache Ant (http://ant.apache.org/).

Ant build files have propper dependencies so that building the top-most project (svg-import) automatically builds all dependencies. The only dependency that has to be resolved manually is the dependency to your local OpenOffice.org installation for accessing the UNO runtime interface libraries. Therefore, the path to your local OpenOffice installation must be entered into the following properties file:

cd svg-import
cp .local.properties.example .local.properties
vi .local.properties
cd ..

Now, you are ready to build the OpenOffice.org extension:

cd svg-import
ant extension

If everything went fine, you find a home-browen SVG import filter svg-import.oxt in the directory svg-import/build, which can be installed into OpenOffice.org using the integrated package manager.


Last update: Haui 21:43, 5 September 2007 (CEST) for building version 1.2.2 of the import filter.

Personal tools