incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r795442 - /websites/staging/odftoolkit/trunk/content/odftoolkit/odfdom/Layers.html
Date Wed, 07 Sep 2011 09:12:43 GMT
Author: buildbot
Date: Wed Sep  7 09:12:42 2011
New Revision: 795442

Log:
Staging update by buildbot

Modified:
    websites/staging/odftoolkit/trunk/content/odftoolkit/odfdom/Layers.html

Modified: websites/staging/odftoolkit/trunk/content/odftoolkit/odfdom/Layers.html
==============================================================================
--- websites/staging/odftoolkit/trunk/content/odftoolkit/odfdom/Layers.html (original)
+++ websites/staging/odftoolkit/trunk/content/odftoolkit/odfdom/Layers.html Wed Sep  7 09:12:42
2011
@@ -78,129 +78,140 @@
   <div id="contenta">
   
     
-    <p><strong>TOC</strong></p>
-<p>=The ODFDOM Layers=</p>
+    <h2 id="the-odfdom-layers">The ODFDOM Layers</h2>
 <p>The ODFDOM project's objective is to provide an easy API for reading, writing and
manipulating documents of the OpenDocument format (ODF). 
 To archive this, the ODFDOM API follows a layered approach to access documents, as layered
design is the robust foundation for a well-designed modular structure.</p>
-<p><center> [[image: ODFDOM-New-Layered-Model.png]]</center></p>
-<p>==The ODF Package Layer==
-The ODF Package Layer provides access to all resources stored within the ODF package, such
as XML streams, images or embedded objects. 
-===The ODF Package API===
-The ODF Package API covers all features from the [http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part3.html
third part of the ODF 1.2 specification] defining the ODF Package features. The ODF 1.2 package
features are build on top technologies as [http://www.pkware.com/documents/APPNOTE/APPNOTE_6.2.0.txt
ZIP package handling], [http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/ W3C encryption],
[http://www.w3.org/TR/2008/REC-xmldsig-core-20080610/ W3C signature] and [http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/
W3C metadata].</p>
+<p><center><img alt="alt text" src="ODFDOM-New-Layered-Model.png" /></center></p>
+<h2 id="the-odf-package-layer">The ODF Package Layer</h2>
+<p>The ODF Package Layer provides access to all resources stored within the ODF package,
such as XML streams, images or embedded objects. <br />
+</p>
+<p><strong>The ODF Package API</strong><br />
+The ODF Package API covers all features from <a href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part3.html">the
third part of the ODF 1.2 specification</a> defining the ODF Package features. The ODF
1.2 package features are build on top technologies as <a href="http://www.pkware.com/documents/APPNOTE/APPNOTE_6.2.0.txt">ZIP
package handling</a>, <a href="http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/">W3C
encryption</a>, <a href="http://www.w3.org/TR/2008/REC-xmldsig-core-20080610/">W3C
signature</a> and <a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">W3C
metadata</a>.</p>
 <p>At this layer a document is in general represented by a bundle of named resources
zipped to a package.
 For instance, an ODF text document like 'myVacation.odt' might contain the following files:</p>
-<p>[[image: ODF_Package.jpg]]</p>
-<p>'''Note:''' 
-All file streams aside of the '/Pictures' directory and its content are specified by the
ODF standard. 
-Furthermore, the file streams are similar for all types of ODF documents.</p>
-<p>The main requirements for this layer in regard of ZIP are: 
-<em> Zip/unzip the file streams of the package
-</em> Enlist all file streams in the /META-INF/manifest.xml (similar to an inventory)
-* Begin the package with an unzipped 'mimetype' file stream (allowing others to easily identify
the package)</p>
+<p><img alt="alt text" src="ODF_Package.jpg" /></p>
+<p><strong><em>Note:</em></strong> All file streams aside of
the '/Pictures' directory and its content are specified by the ODF standard. 
+Furthermore, the file streams are similar for all types of ODF documents.<br />
+</p>
+<p>The main requirements for this layer in regard of ZIP are: <br />
+</p>
+<ul>
+<li>Zip/unzip the file streams of the package</li>
+<li>Enlist all file streams in the /META-INF/manifest.xml (similar to an
+    inventory)</li>
+<li>Begin the package with an unzipped 'mimetype' file stream (allowing
+    others to easily identify the package)</li>
+</ul>
 <p>All sources of the Package layer are organized in ODFDOM beyond <code>org.odftoolkit.odfdom.pkg.*</code></p>
 <p>The following example illustrates how to add a graphic to the package level
 (although not shown by an ODF application (like OpenOffice.org), as not used by the shown
content):</p>
-<pre>
+<div class="codehilite"><pre><span class="nb">import</span> <span
class="n">org</span><span class="o">.</span><span class="n">odftoolkit</span><span
class="o">.</span><span class="n">odfdom</span><span class="o">.</span><span
class="n">pkg</span><span class="o">.</span><span class="n">OdfPackage</span><span
class="p">;</span>
+<span class="p">[</span><span class="o">...</span><span class="p">]</span>
 
-import org.odftoolkit.odfdom.pkg.OdfPackage;
-[...]
+<span class="sr">//</span> <span class="n">loads</span> <span
class="n">the</span> <span class="n">ODF</span> <span class="n">document</span>
<span class="nb">package</span> <span class="n">from</span> <span
class="n">the</span> <span class="n">path</span>
+<span class="n">OdfPackage</span> <span class="n">pkg</span> <span
class="o">=</span> <span class="n">OdfPackage</span><span class="o">.</span><span
class="n">loadPackage</span><span class="p">(</span><span class="s">&quot;/home/myDocuments/myVacation.odt&quot;</span><span
class="p">);</span>
 
-// loads the ODF document package from the path
-OdfPackage pkg = OdfPackage.loadPackage("/home/myDocuments/myVacation.odt");
-
-// loads the image from the URL and inserts the image in the package, 
-// adapting the manifest
-pkg.insert(new URI("./myHoliday.png"), "Pictures/myHoliday.png", "image/png");
-pkg.save("/home/myDocuments/myVacation.odt");
-
-</pre>
-
-<br/>
-
-<p>==The ODF XML Layer==
-The ODF XML Layer provides all the features of an office format, such as tables, images,
numbering etc. All features are defined in [http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part1.html
the first part of the ODF 1.2 specification] describing the ODF XML schema. This layer consists
of two APIs representing two different views on the features.</p>
-<p>===The ODF DOM API===
-The ODF DOM API gives access to the XML, the elemental parts of the ODF schema features.
With this API it is easy to manipulate all specified XML nodes extending the platform and
language independent DOM API [http://www.w3.org/DOM/ DOM API standardized by the W3C] - best-known
by its implementation through the browsers. It extends the DOM API using a typed DOM. For
every ODF XML element and ODF XML attribute defined by the ODF grammar (the RelaxNG schema)
a unique class exists, providing methods for their allowed children. The purpose is to provide
the user a corset to easily write valid ODF without consulting the spec constantly. This API
is very consistent as instead of laboriously writing all these classes, the sources were generated
directly from the ODF schema. This generation guarantees complete coverage of the ODF specification
on one side and an easy and accurate upgrade to future ODF specifications on the other. </p>
-<p>At this level, all XML file streams of the document are accessible via the [http://www.w3.org/DOM/
W3C DOM API], but only the ODF standardized XML file streams of the document (e.g. content.xml,
meta.xml) have their own classes representing their ODF XML elements. Foreign XML within a
specified ODF XML file will remain in the document model in general and won't be neglected
unless desired ( which still might be a future option).</p>
+<span class="sr">//</span> <span class="n">loads</span> <span
class="n">the</span> <span class="n">image</span> <span class="n">from</span>
<span class="n">the</span> <span class="n">URL</span> <span class="ow">and</span>
<span class="n">inserts</span> <span class="n">the</span> <span
class="n">image</span> <span class="n">in</span> <span class="n">the</span>
<span class="nb">package</span><span class="p">,</span> 
+<span class="sr">//</span> <span class="n">adapting</span> <span
class="n">the</span> <span class="n">manifest</span>
+<span class="n">pkg</span><span class="o">.</span><span class="n">insert</span><span
class="p">(</span><span class="k">new</span> <span class="n">URI</span><span
class="p">(</span><span class="s">&quot;./myHoliday.png&quot;</span><span
class="p">),</span> <span class="s">&quot;Pictures/myHoliday.png&quot;</span><span
class="p">,</span> <span class="s">&quot;image/png&quot;</span><span
class="p">);</span>
+<span class="n">pkg</span><span class="o">.</span><span class="n">save</span><span
class="p">(</span><span class="s">&quot;/home/myDocuments/myVacation.odt&quot;</span><span
class="p">);</span>
+</pre></div>
+
+
+<h2 id="the-odf-xml-layer">The ODF XML Layer</h2>
+<p>The ODF XML Layer provides all the features of an office format, such as tables,
images, numbering etc. All features are defined in <a href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part1.html">the
first part of the ODF 1.2 specification</a> describing the ODF XML schema. This layer
consists of two APIs representing two different views on the features. <br />
+</p>
+<p><strong>The ODF DOM API</strong><br />
+</p>
+<p>The ODF DOM API gives access to the XML, the elemental parts of the ODF schema features.
With this API it is easy to manipulate all specified XML nodes extending the platform and
language independent DOM API <a href="http://www.w3.org/DOM/">DOM API standardized by
the W3C</a> - best-known by its implementation through the browsers. It extends the
DOM API using a typed DOM. For every ODF XML element and ODF XML attribute defined by the
ODF grammar (the RelaxNG schema) a unique class exists, providing methods for their allowed
children. The purpose is to provide the user a corset to easily write valid ODF without consulting
the spec constantly. This API is very consistent as instead of laboriously writing all these
classes, the sources were generated directly from the ODF schema. This generation guarantees
complete coverage of the ODF specification on one side and an easy and accurate upgrade to
future ODF specifications on the other. </p>
+<p>At this level, all XML file streams of the document are accessible via the <a
href="http://www.w3.org/DOM/">W3C DOM API</a>, but only the ODF standardized XML
file streams of the document (e.g. content.xml, meta.xml) have their own classes representing
their ODF XML elements. Foreign XML within a specified ODF XML file will remain in the document
model in general and won't be neglected unless desired ( which still might be a future option).</p>
 <p>Example of the ODF XML representing a table in ODF:</p>
-<p>[[image: FruitTable_code.jpg]]</p>
-<p>'''Note:''' In the OpenDocument standard the ODF elements are reused among all document
types. The above XML of a table is for instance equally usable in Text and Spreadsheet documents.</p>
+<p><img alt="alt text" src="FruitTable_code.jpg" /></p>
+<p><strong><em>Note:</em></strong> In the OpenDocument standard
the ODF elements are reused among all document types. The above XML of a table is for instance
equally usable in Text and Spreadsheet documents.</p>
 <p>This XML would be mapped to a W3C derived ODF DOM class structure:</p>
-<p>[[image: Table_fruits_diagramm.jpg | 670x346px]]</p>
+<p><img alt="alt text" src="Table_fruits_diagramm.jpg" /></p>
 <p>All sources of the typed DOM API are organized beyond <code>org.odftoolkit.odfdom.dom.*</code></p>
-<p>The sources for the ODF elements are all generated from the ODF grammar (RelaxNG
schema) using the following naming conventions in the Java reference implementation:
-<em> The class name is equal to the element local name using the Namespace as prefix
and 'Element' as suffix (e.g. the 'draw:frame' element has the <code>DrawFrameElement</code>
class). 
-</em> Elements are stored beyond a sub-package equal to their Namespace used by the
OOo. Therefore the frame element 'draw:frame' would be generated in Java as class <code>org.odftoolkit.odfdom.dom.draw.DrawFrameElement</code>.</p>
-<p>'''Note:''' The element local names 'h' and 'p' have been renamed to the classes
'Heading' and 'Paragraph' for usability reasons.</p>
-<p>The following example illustrates how to add a graphic to the ODF document, that
it is viewable:
-<pre></p>
-<p>import java.net.URI;
-import org.odftoolkit.odfdom.OdfElement;
-import org.odftoolkit.odfdom.doc.OdfDocument;
-import org.odftoolkit.odfdom.doc.OdfTextDocument;
-import org.odftoolkit.odfdom.doc.draw.OdfDrawImage;
-import org.odftoolkit.odfdom.dom.element.draw.DrawFrameElement;
-import org.odftoolkit.odfdom.dom.element.office.OfficeTextElement;
-import org.odftoolkit.odfdom.dom.element.text.TextPElement;</p>
-<p>[...]</p>
-<p>// Load file
-OdfTextDocument odt = (OdfTextDocument) OdfDocument.loadDocument("ImageIn.odt");</p>
-<p>// get root of all content of a text document
-OfficeTextElement officeText = odt.getContentRoot();</p>
-<p>// get first paragraph
-TextPElement firstParagraph = 
-  OdfElement.findFirstChildNode(TextPElement.class, officeText);</p>
-<p>// XPath alternative to get the first paragraph
-/<em>
-  XPath xpath = XPathFactory.newInstance().newXPath();
-  xpath.setNamespaceContext(new OdfNamespace());
-  OdfFileDom dom = odt.getContentDom();
-  firstParagraph = (TextPElement) xpath.evaluate("//text:p[1]", dom, XPathConstants.NODE);
-</em>/</p>
-<p>// insert a frame
-DrawFrameElement frame = firstParagraph.newDrawFrameElement();</p>
-<p>// insert an image: This is a class from the Document API
-OdfDrawImage image = (OdfDrawImage) frame.newDrawImageElement();
-image.newImage(new URI("./MySampleImage.png"));</p>
-<p>// Save file
-odt.save("ImageOut.odt");
-</pre>
-<br/>
-Even in this example we had to refer to a class from the Document API. Otherwise our implementation
had gotten quite long and complex. </p>
-<br/>
+<p>The sources for the ODF elements are all generated from the ODF grammar (RelaxNG
schema) using the following naming conventions in the Java reference implementation: <br
/>
+</p>
+<ul>
+<li>The class name is equal to the element local name using the Namespace as prefix
and 'Element' as suffix (e.g. the 'draw:frame' element has the <code>DrawFrameElement</code>
class).<br />
+</li>
+<li>Elements are stored beyond a sub-package equal to their Namespace used by the OOo.
Therefore the frame element 'draw:frame' would be generated in Java as class <code>org.odftoolkit.odfdom.dom.draw.DrawFrameElement</code>.</li>
+</ul>
+<p><strong><em>Note:</em></strong> The element local names
'h' and 'p' have been renamed to the classes 'Heading' and 'Paragraph' for usability reasons.</p>
+<p>The following example illustrates how to add a graphic to the ODF document, that
it is viewable:</p>
+<div class="codehilite"><pre><span class="nb">import</span> <span
class="n">java</span><span class="o">.</span><span class="n">net</span><span
class="o">.</span><span class="n">URI</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">OdfElement</span><span
class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">doc</span><span
class="o">.</span><span class="n">OdfDocument</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">doc</span><span
class="o">.</span><span class="n">OdfTextDocument</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">doc</span><span
class="o">.</span><span class="n">draw</span><span class="o">.</span><span
class="n">OdfDrawImage</span><span class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">dom</span><span
class="o">.</span><span class="n">element</span><span class="o">.</span><span
class="n">draw</span><span class="o">.</span><span class="n">DrawFrameElement</span><span
class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">dom</span><span
class="o">.</span><span class="n">element</span><span class="o">.</span><span
class="n">office</span><span class="o">.</span><span class="n">OfficeTextElement</span><span
class="p">;</span>
+<span class="nb">import</span> <span class="n">org</span><span
class="o">.</span><span class="n">odftoolkit</span><span class="o">.</span><span
class="n">odfdom</span><span class="o">.</span><span class="n">dom</span><span
class="o">.</span><span class="n">element</span><span class="o">.</span><span
class="n">text</span><span class="o">.</span><span class="n">TextPElement</span><span
class="p">;</span>
+
+<span class="p">[</span><span class="o">...</span><span class="p">]</span>
+
+<span class="sr">//</span> <span class="n">Load</span> <span class="n">file</span>
+<span class="n">OdfTextDocument</span> <span class="n">odt</span>
<span class="o">=</span> <span class="p">(</span><span class="n">OdfTextDocument</span><span
class="p">)</span> <span class="n">OdfDocument</span><span class="o">.</span><span
class="n">loadDocument</span><span class="p">(</span><span class="s">&quot;ImageIn.odt&quot;</span><span
class="p">);</span>
+
+<span class="sr">//</span> <span class="n">get</span> <span class="n">root</span>
<span class="n">of</span> <span class="n">all</span> <span class="n">content</span>
<span class="n">of</span> <span class="n">a</span> <span class="n">text</span>
<span class="n">document</span>
+<span class="n">OfficeTextElement</span> <span class="n">officeText</span>
<span class="o">=</span> <span class="n">odt</span><span class="o">.</span><span
class="n">getContentRoot</span><span class="p">();</span>
+
+<span class="sr">//</span> <span class="n">get</span> <span class="n">first</span>
<span class="n">paragraph</span>
+<span class="n">TextPElement</span> <span class="n">firstParagraph</span>
<span class="o">=</span> 
+  <span class="n">OdfElement</span><span class="o">.</span><span
class="n">findFirstChildNode</span><span class="p">(</span><span class="n">TextPElement</span><span
class="o">.</span><span class="n">class</span><span class="p">,</span>
<span class="n">officeText</span><span class="p">);</span>
+
+<span class="sr">//</span> <span class="n">XPath</span> <span
class="n">alternative</span> <span class="n">to</span> <span class="n">get</span>
<span class="n">the</span> <span class="n">first</span> <span class="n">paragraph</span>
+<span class="o">/*</span>
+  <span class="n">XPath</span> <span class="n">xpath</span> <span
class="o">=</span> <span class="n">XPathFactory</span><span class="o">.</span><span
class="n">newInstance</span><span class="p">()</span><span class="o">.</span><span
class="n">newXPath</span><span class="p">();</span>
+  <span class="n">xpath</span><span class="o">.</span><span class="n">setNamespaceContext</span><span
class="p">(</span><span class="k">new</span> <span class="n">OdfNamespace</span><span
class="p">());</span>
+  <span class="n">OdfFileDom</span> <span class="n">dom</span> <span
class="o">=</span> <span class="n">odt</span><span class="o">.</span><span
class="n">getContentDom</span><span class="p">();</span>
+  <span class="n">firstParagraph</span> <span class="o">=</span>
<span class="p">(</span><span class="n">TextPElement</span><span
class="p">)</span> <span class="n">xpath</span><span class="o">.</span><span
class="n">evaluate</span><span class="p">(</span><span class="s">&quot;//text:p[1]&quot;</span><span
class="p">,</span> <span class="n">dom</span><span class="p">,</span>
<span class="n">XPathConstants</span><span class="o">.</span><span
class="n">NODE</span><span class="p">);</span>
+<span class="o">*/</span>
+
+<span class="sr">//</span> <span class="n">insert</span> <span
class="n">a</span> <span class="n">frame</span>
+<span class="n">DrawFrameElement</span> <span class="n">frame</span>
<span class="o">=</span> <span class="n">firstParagraph</span><span
class="o">.</span><span class="n">newDrawFrameElement</span><span
class="p">();</span>
+
+<span class="sr">//</span> <span class="n">insert</span> <span
class="n">an</span> <span class="n">image:</span> <span class="n">This</span>
<span class="n">is</span> <span class="n">a</span> <span class="n">class</span>
<span class="n">from</span> <span class="n">the</span> <span class="n">Document</span>
<span class="n">API</span>
+<span class="n">OdfDrawImage</span> <span class="n">image</span>
<span class="o">=</span> <span class="p">(</span><span class="n">OdfDrawImage</span><span
class="p">)</span> <span class="n">frame</span><span class="o">.</span><span
class="n">newDrawImageElement</span><span class="p">();</span>
+<span class="n">image</span><span class="o">.</span><span class="n">newImage</span><span
class="p">(</span><span class="k">new</span> <span class="n">URI</span><span
class="p">(</span><span class="s">&quot;./MySampleImage.png&quot;</span><span
class="p">));</span>
+
+<span class="sr">//</span> <span class="n">Save</span> <span class="n">file</span>
+<span class="n">odt</span><span class="o">.</span><span class="n">save</span><span
class="p">(</span><span class="s">&quot;ImageOut.odt&quot;</span><span
class="p">);</span>
+</pre></div>
+
 
-<p>===The ODF Document API===</p>
+<p>Even in this example we had to refer to a class from the Document API. Otherwise
our implementation had gotten quite long and complex. </p>
+<p><strong>The ODF Document API</strong></p>
 <p>The ODF Document API provides a different much more high level view on the ODF schema
features. This API is concerned about usability, hiding all ODF XML implementation details
from the user, covering frequent user scenarios. For example, changing the content of a certain
spreadsheet cell (e.g. Add 'Hello World' to a spreadsheet cell positioned at 'B2'). While
in the ODF DOM API in general each class represents an ODF XML node, here a class covers multiple
underlying ODF XML elements (&amp; their attributes). Think of puzzle piece consisting
of multiple smaller pieces. Therefore the typed DOM tree is being mapped to feature tree.</p>
 <p>As naming convention all sources of the ODF document functionality layer are organized
beyond <code>org.odftoolkit.odfdom.doc.*</code>
 The name of a document class is in general similar as the root element from the XML layer
feature, only there is the new prefix 'Odf' and the suffix 'Element' has been neglected.</p>
 <p>For example, the document class for a 'draw:frame' element would be represented
in the ODFDOM Java reference implemenation as <code>org.odftoolkit.odfdom.doc.draw.OdfDrawFrame</code>
class. Some classes of the Document API differ from this naming convention, e.g. OdfTextParagraph
is the subclass of TextPElement. However by browsing the packages you will easily find the
classes your looking for.</p>
-<p>'''Note:''' The Document API will change. The current inheritance between DOM and
DOC elements does not fit any longer in the multiple elements to a single document feature
(1:n) pattern. The first Document Object is the table <code>rg.odftoolkit.odfdom.doc.table.OdfTable</code>,
others will follow soon.</p>
+<p><strong><em>Note:</em></strong> The Document API will change.
The current inheritance between DOM and DOC elements does not fit any longer in the multiple
elements to a single document feature (1:n) pattern. The first Document Object is the table
<code>rg.odftoolkit.odfdom.doc.table.OdfTable</code>, others will follow soon.</p>
 <p>Again let's look at the previous code example for the DOM API: Remember all DOM
element classes are abstract and we're really getting objects from the Document API: Even
if <code>frame.newDrawFrameElement()</code> is defined to return the DOM class
DrawFrameElement, it really returns the DOC subclass OdfDrawFrame. So it's always save to
use explicit casting <code>OdfDrawFrame frame = (OdfDrawFrame) firstParagraph.newDrawFrameElement();</code>.</p>
 <p>However reworking the previous example would just make the code larger, since we're
not using any of the document methods provided by the DOC subclasses. </p>
 <p>Here's an example for working with DOC classes, completely avoiding handling the
DOM manually:</p>
-<pre>
-[...]
-// Load Image
-OdfTextDocument odt = (OdfTextDocument) OdfDocument.loadDocument("ImageIn.odt");
+<div class="codehilite"><pre><span class="k">[...]</span>
+<span class="err">//</span> <span class="err">Load</span> <span
class="err">Image</span>
+<span class="na">OdfTextDocument odt</span> <span class="o">=</span>
<span class="s">(OdfTextDocument) OdfDocument.loadDocument(&quot;ImageIn.odt&quot;);</span>
 
-// Play around with text
-odt.addText("When there is no paragraph, the text will be embedded in a new paragraph");
-odt.newParagraph("Create new paragraph");
-odt.addText("\nThis is a new line");
+<span class="err">//</span> <span class="err">Play</span> <span
class="err">around</span> <span class="err">with</span> <span class="err">text</span>
+<span class="err">odt.addText(&quot;When</span> <span class="err">there</span>
<span class="err">is</span> <span class="err">no</span> <span class="err">paragraph,</span>
<span class="err">the</span> <span class="err">text</span> <span
class="err">will</span> <span class="err">be</span> <span class="err">embedded</span>
<span class="err">in</span> <span class="err">a</span> <span class="err">new</span>
<span class="err">paragraph&quot;)</span><span class="c">;</span>
+<span class="err">odt.newParagraph(&quot;Create</span> <span class="err">new</span>
<span class="err">paragraph&quot;)</span><span class="c">;</span>
+<span class="err">odt.addText(&quot;\nThis</span> <span class="err">is</span>
<span class="err">a</span> <span class="err">new</span> <span class="err">line&quot;)</span><span
class="c">;</span>
 
-// Insert Image and make last paragraph its anchor
-odt.newImage(new URI("./MySampleImage.png"));
+<span class="err">//</span> <span class="err">Insert</span> <span
class="err">Image</span> <span class="err">and</span> <span class="err">make</span>
<span class="err">last</span> <span class="err">paragraph</span> <span
class="err">its</span> <span class="err">anchor</span>
+<span class="err">odt.newImage(new</span> <span class="err">URI(&quot;./MySampleImage.png&quot;))</span><span
class="c">;</span>
 
-// Insert new spreadsheet as sub document into the package within directory  "myOdsDirectoryPath/"
-odt.insertDocument(OdfSpreadsheetDocument.newSpreadsheetDocument(), "myOdsDirectoryPath");
+<span class="err">//</span> <span class="err">Insert</span> <span
class="err">new</span> <span class="err">spreadsheet</span> <span
class="err">as</span> <span class="err">sub</span> <span class="err">document</span>
<span class="err">into</span> <span class="err">the</span> <span
class="err">package</span> <span class="err">within</span> <span class="err">directory</span>
 <span class="err">&quot;myOdsDirectoryPath/&quot;</span>
+<span class="err">odt.insertDocument(OdfSpreadsheetDocument.newSpreadsheetDocument(),</span>
<span class="err">&quot;myOdsDirectoryPath&quot;)</span><span class="c">;</span>
 
-// Save file
-odt.save("ImageOut.odt");
-</pre>
+<span class="err">//</span> <span class="err">Save</span> <span
class="err">file</span>
+<span class="err">odt.save(&quot;ImageOut.odt&quot;)</span><span class="c">;</span>
+</pre></div>
 
-<br/>
 
-<p style="margin: 15px 0px; text-align:center">Go on reading about [[Development|how
to set up a building environment and where to get the source code]].</p>
+<p>Go on reading about <a href="Development.html">how to set up a building environment
and where to get the source code</a>.</p>
   </div>
 
   <div id="footera">



Mime
View raw message