incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r795013 - /websites/staging/odftoolkit/trunk/content/odftoolkit/simple/gettingstartguide.html
Date Tue, 30 Aug 2011 08:45:43 GMT
Author: buildbot
Date: Tue Aug 30 08:45:42 2011
New Revision: 795013

Log:
Staging update by buildbot

Added:
    websites/staging/odftoolkit/trunk/content/odftoolkit/simple/gettingstartguide.html

Added: websites/staging/odftoolkit/trunk/content/odftoolkit/simple/gettingstartguide.html
==============================================================================
--- websites/staging/odftoolkit/trunk/content/odftoolkit/simple/gettingstartguide.html (added)
+++ websites/staging/odftoolkit/trunk/content/odftoolkit/simple/gettingstartguide.html Tue
Aug 30 08:45:42 2011
@@ -0,0 +1,198 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE- 2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<link href="/odftoolkit/css/odf.css" rel="stylesheet" type="text/css">
+
+<title></title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+</head>
+
+<body>
+  <div id="banner">
+   <!-- <div id="bannerleft"><a alt="Apache ODF Toolkit (incubating)" href="http://incubator.apache.org/odftoolkit/">
+      <img id="logo" alt="Apache ODF Toolkit (Incubating)" src="/odftoolkit/images/ooo-logo.png"/></a></div>
-->
+    <div id="bannerright"><a alt="Apache Incubator" href="http://incubator.apache.org">
+      <img id="asf-logo" alt="Apache Incubator" src="/odftoolkit/images/apache-incubator-logo.png"/></a></div>
+   <div id="bannercenter"><br/>&nbsp;&nbsp;&nbsp;&nbsp;Apache
ODF Toolkit (incubating)</div>
+  </div>
+  <div id="clear"></div>
+  
+  <div id="sidenav">
+    <h1 id="general">General</h1>
+<ul>
+<li><a href="/odftoolkit/index.html">About</a></li>
+<li><a href="http://incubator.apache.org/projects/odftoolkit.html">Incubator
page</a></li>
+<li><a href="/odftoolkit/license.html">License</a></li>
+</ul>
+<h1 id="components">Components</h1>
+<ul>
+<li><a href="/odftoolkit/odfdom/index.html">ODFDOM</a></li>
+<li><a href="/odftoolkit/simple/index.html">Simple API</a></li>
+<li><a href="/odftoolkit/conformance/ODFValidator.html">Conformance Tools</a></li>
+<li><a href="/odftoolkit/xsltrunner/ODFXSLTRunner.html">XSLT Runner</a></li>
+</ul>
+<h1 id="community">Community</h1>
+<ul>
+<li><a href="/odftoolkit/get-involved.html">Get Involved</a></li>
+<li><a href="/odftoolkit/mailing-lists.html">Mailing Lists</a></li>
+<li><a href="/odftoolkit/people.html">People</a></li>
+<li><a href="/odftoolkit/community-faqs.html">Community FAQs</a></li>
+</ul>
+<h1 id="development">Development</h1>
+<ul>
+<li><a href="/odftoolkit/source.html">Source Code</a></li>
+<li><a href="/odftoolkit/website-local.html">Website</a></li>
+<li><a href="/odftoolkit/developer-faqs.html">Developer FAQs</a></li>
+</ul>
+<h1 id="ppmc">PPMC</h1>
+<ul>
+<li><a href="/odftoolkit/ppmc-faqs.html">PPMC FAQs</a><br />
+</li>
+</ul>
+<h1 id="asf">ASF</h1>
+<ul>
+<li><a href="http://www.apache.org">Apache Software Foundation</a></li>
+<li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+<li><a href="http://www.apache.org/foundation/sponsorship.html">Become a Sponsor</a></li>
+</ul>
+  </div>
+  <div id="contenta">
+  
+    
+    <p>Title:Getting Start Guide
+Notice:    Licensed to the Apache Software Foundation (ASF) under one
+           or more contributor license agreements.  See the NOTICE file
+           distributed with this work for additional information
+           regarding copyright ownership.  The ASF licenses this file
+           to you under the Apache License, Version 2.0 (the
+           "License"); you may not use this file except in compliance
+           with the License.  You may obtain a copy of the License at
+           .
+             http://www.apache.org/licenses/LICENSE-2.0
+           .
+           Unless required by applicable law or agreed to in writing,
+           software distributed under the License is distributed on an
+           "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+           KIND, either express or implied.  See the License for the
+           specific language governing permissions and limitations
+           under the License.</p>
+<p>This start guide shows how to use the Simple ODF API to create a text document with
image, paragraph, list and table in OpenDocument format (ODF). In about 40 lines of code,
you will be able to produce an OpenDocument Format text document named HelloWorld.odt that
looks like this:</p>
+<p><img alt="demo file" src="images/helloworld.png" /></p>
+<p><strong>Prerequisites</strong></p>
+<p>Simple ODF is written in Java, so you will need to have Java 1.5 or above installed
on your system. Make sure you download the SDK (software development kit), not just the runtime
version of Java.</p>
+<p>In this tutorial, you can build and run the application from the command line or
IDE, such as Eclipse. Anyway, you need to download the following three jars, store them in
the "lib" directory and add them into the classpatch.</p>
+<ol>
+<li><a href="http://odftoolkit.org/projects/simple/downloads/download/0.6.6/simple-odf-0.6.6.jar">Simple
ODF 0.6.6</a>.</li>
+<li><a href="http://repo1.maven.org/maven2/org/odftoolkit/odfdom-java/0.8.7/odfdom-java-0.8.7.jar">ODFDOM
0.8.7</a>.</li>
+<li>The Apache Xerces 2.9.1 or higher version (download from <a href="http://xerces.apache.org/mirrors.cgi">Apache
+    Xerces</a> web site).</li>
+</ol>
+<p>In addition, you need to download <a href="http://simple.odftoolkit.org/helloworld.zip">the
resource file</a> of this demo.</p>
+<p><strong>Code</strong></p>
+<p>We write all of the code needed to create the document in the HelloWorld class.
For simplicity, the code is wrapped in main method directly, package declaration is omitted
and hard code is also included in this program. </p>
+<p>import java.net.URI;</p>
+<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">simple</span><span class="o">.</span><span
class="n">TextDocument</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">simple</span><span class="o">.</span><span class="n">table</span><span
class="o">.</span><span class="n">Cell</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">simple</span><span class="o">.</span><span class="n">table</span><span
class="o">.</span><span class="n">Table</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">simple</span><span class="o">.</span><span class="n">text</span><span
class="o">.</span><span class="n">list</span><span class="o">.</span><span
class="n">List</span><span class="p">;</span>
+
+<span class="n">public</span> <span class="n">class</span> <span
class="n">HelloWorld</span> <span class="p">{</span>
+    <span class="n">public</span> <span class="n">static</span> <span
class="n">void</span> <span class="n">main</span><span class="p">(</span><span
class="n">String</span><span class="o">[]</span> <span class="n">args</span><span
class="p">)</span> <span class="p">{</span>
+        <span class="n">TextDocument</span> <span class="n">outputOdt</span><span
class="p">;</span>
+        <span class="n">try</span> <span class="p">{</span>
+            <span class="n">outputOdt</span> <span class="o">=</span>
<span class="n">TextDocument</span><span class="o">.</span><span
class="n">newTextDocument</span><span class="p">();</span>
+
+            <span class="sr">//</span> <span class="n">add</span>
<span class="n">image</span>
+            <span class="n">outputOdt</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;odf-logo.png&quot;</span><span
class="p">));</span>
+
+            <span class="sr">//</span> <span class="n">add</span>
<span class="n">paragraph</span>
+            <span class="n">outputOdt</span><span class="o">.</span><span
class="n">addParagraph</span><span class="p">(</span><span class="s">&quot;Hello
World, Hello Simple ODF!&quot;</span><span class="p">);</span>
+
+            <span class="sr">//</span> <span class="n">add</span>
<span class="n">list</span>
+            <span class="n">outputOdt</span><span class="o">.</span><span
class="n">addParagraph</span><span class="p">(</span><span class="s">&quot;The
following is a list.&quot;</span><span class="p">);</span>
+            <span class="n">List</span> <span class="n">list</span>
<span class="o">=</span> <span class="n">outputOdt</span><span
class="o">.</span><span class="n">addList</span><span class="p">();</span>
+            <span class="n">String</span><span class="o">[]</span>
<span class="n">items</span> <span class="o">=</span> <span class="p">{</span><span
class="s">&quot;item1&quot;</span><span class="p">,</span> <span
class="s">&quot;item2&quot;</span><span class="p">,</span> <span
class="s">&quot;item3&quot;</span><span class="p">};</span>
+            <span class="n">list</span><span class="o">.</span><span
class="n">addItems</span><span class="p">(</span><span class="n">items</span><span
class="p">);</span>
+
+            <span class="sr">//</span> <span class="n">add</span>
<span class="n">table</span>
+            <span class="n">Table</span> <span class="n">table</span>
<span class="o">=</span> <span class="n">outputOdt</span><span
class="o">.</span><span class="n">addTable</span><span class="p">(</span><span
class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span
class="p">);</span>
+            <span class="n">Cell</span> <span class="n">cell</span>
<span class="o">=</span> <span class="n">table</span><span class="o">.</span><span
class="n">getCellByPosition</span><span class="p">(</span><span class="mi">0</span><span
class="p">,</span> <span class="mi">0</span><span class="p">);</span>
+            <span class="n">cell</span><span class="o">.</span><span
class="n">setStringValue</span><span class="p">(</span><span class="s">&quot;Hello
World!&quot;</span><span class="p">);</span>
+
+            <span class="n">outputOdt</span><span class="o">.</span><span
class="n">save</span><span class="p">(</span><span class="s">&quot;HelloWorld.odt&quot;</span><span
class="p">);</span>
+        <span class="p">}</span> <span class="n">catch</span> <span
class="p">(</span><span class="n">Exception</span> <span class="n">e</span><span
class="p">)</span> <span class="p">{</span>
+            <span class="n">System</span><span class="o">.</span><span
class="n">err</span><span class="o">.</span><span class="n">println</span><span
class="p">(</span><span class="s">&quot;ERROR: unable to create output
file.&quot;</span><span class="p">);</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>The TextDocument class has these convenient methods: </p>
+<div class="codehilite"><pre><span class="sr">//</span> <span
class="n">Creates</span> <span class="n">a</span> <span class="k">new</span>
<span class="n">text</span> <span class="n">document</span> <span
class="n">that</span> <span class="n">contains</span> <span class="n">an</span>
<span class="n">empty</span> <span class="n">paragraph</span><span
class="o">.</span>
+    <span class="n">TextDocument</span><span class="o">.</span><span
class="n">newTextDocument</span><span class="p">();</span>
+    <span class="sr">//</span> <span class="n">Puts</span> <span
class="n">the</span> <span class="n">image</span> <span class="n">at</span>
<span class="n">the</span> <span class="n">given</span> <span class="n">location</span>
<span class="n">at</span> <span class="n">the</span> <span class="n">end</span>
<span class="n">of</span> <span class="n">the</span> <span class="n">document</span><span
class="o">.</span>
+    <span class="n">TextDocument</span><span class="o">.</span><span
class="n">newImage</span><span class="p">(</span><span class="n">URI</span>
<span class="n">location</span><span class="p">)</span>
+    <span class="sr">//</span> <span class="n">Creates</span> <span
class="n">a</span> <span class="k">new</span> <span class="n">paragraph</span>
<span class="n">with</span> <span class="n">the</span> <span class="n">given</span>
<span class="n">content</span> <span class="ow">and</span> <span
class="n">appends</span> <span class="n">it</span> <span class="n">to</span>
<span class="n">the</span> <span class="n">end</span> <span class="n">of</span>
<span class="n">the</span> <span class="n">document</span><span
class="o">.</span>
+    <span class="n">TextDocument</span><span class="o">.</span><span
class="n">addParagraph</span><span class="p">(</span><span class="n">String</span>
<span class="n">content</span><span class="p">)</span>
+    <span class="sr">//</span> <span class="n">Creates</span> <span
class="n">a</span> <span class="k">new</span><span class="p">,</span>
<span class="n">empty</span> <span class="n">list</span> <span
class="ow">and</span> <span class="n">appends</span> <span class="n">it</span>
<span class="n">to</span> <span class="n">the</span> <span class="n">end</span>
<span class="n">of</span> <span class="n">the</span> <span class="n">document</span>
<span class="n">you</span><span class="err">&#39;</span><span
class="n">re</span> <span class="n">building</span><span class="o">.</span>
<span class="n">You</span> <span class="n">can</span> <span class="n">add</span>
<span class="n">items</span> <span class="k">for</span> <span class="n">this</span>
<span class="n">list</span><span class="o">.</span>
+    <span class="n">TextDocument</span><span class="o">.</span><span
class="n">addList</span><span class="p">()</span>
+    <span class="sr">//</span> <span class="n">Creates</span> <span
class="n">a</span> <span class="k">new</span> <span class="n">table</span>
<span class="n">with</span> <span class="n">columnCount</span> <span
class="n">columns</span> <span class="ow">and</span> <span class="n">rowCount</span>
<span class="n">rows</span><span class="o">.</span> <span class="n">You</span>
<span class="n">can</span> <span class="n">get</span> <span class="n">the</span>
<span class="n">cell</span> <span class="n">at</span> <span class="n">given</span>
<span class="n">position</span> <span class="ow">and</span> <span
class="n">set</span> <span class="n">its</span> <span class="n">content</span><span
class="o">.</span>
+    <span class="n">TextDocument</span><span class="o">.</span><span
class="n">addTable</span><span class="p">(</span><span class="nb">int</span>
<span class="n">columnCount</span><span class="p">,</span> <span
class="nb">int</span> <span class="n">rowCount</span><span class="p">);</span>
+    <span class="sr">//</span> <span class="n">Saves</span> <span
class="n">the</span> <span class="n">document</span> <span class="n">at</span>
<span class="n">the</span> <span class="n">given</span> <span class="n">path</span><span
class="o">.</span> 
+    <span class="n">TextDocument</span><span class="o">.</span><span
class="n">save</span><span class="p">(</span><span class="n">String</span>
<span class="n">path</span><span class="p">)</span>
+</pre></div>
+
+
+<p><strong>Building and Running</strong></p>
+<p>If you use Eclipse, you can just run this class as a Java Application. If you use
command line, please complie code and run it with the following commands:</p>
+<div class="codehilite"><pre><span class="n">javac</span> <span
class="o">-</span><span class="n">cp</span> <span class="n">lib</span><span
class="sr">/odfdom-java-0.8.7.jar:lib/sim</span><span class="n">ple</span><span
class="o">-</span><span class="n">odf</span><span class="o">-</span><span
class="mf">0.6.6</span><span class="o">.</span><span class="n">jar</span>
<span class="n">HelloWorld</span><span class="o">.</span><span
class="n">java</span>
+<span class="n">java</span> <span class="o">-</span><span class="n">cp</span>
<span class="n">lib</span><span class="sr">/odfdom-java-0.8.7.jar:lib/sim</span><span
class="n">ple</span><span class="o">-</span><span class="n">odf</span><span
class="o">-</span><span class="mf">0.6.6</span><span class="o">.</span><span
class="n">jar:lib</span><span class="o">/</span><span class="n">xercesImpl</span><span
class="o">.</span><span class="n">jar:</span><span class="o">.</span>
<span class="n">HelloWorld</span>
+</pre></div>
+
+
+<p><strong>Getting the Files</strong></p>
+<p>You can download the code and resources of this demo from <a href="http://simple.odftoolkit.org/helloworld.zip">here</a>.</p>
+  </div>
+
+  <div id="footera">
+    <div id="poweredby">
+      <p><img src="/odftoolkit/images/feather-small.gif"/><br/>Powered
by the Apache CMS.</p>
+    </div>
+    <div id="copyrighta">
+      <p>
+	Apache "ODF Toolkit" is an effort undergoing incubation at The Apache Software Foundation
(ASF), sponsored by the Apache Incubator.
+	Incubation is required of all newly accepted projects until a further review indicates that
the infrastructure, communications, and
+	decision making process	have stabilized in a manner consistent with other successful ASF
projects. While incubation status is
+	not necessarily a reflection of the completeness or stability of the code, it does indicate
that the project has
+	yet to be fully endorsed by the ASF.</p>
+      <p>
+	Copyright &copy; 2011 The Apache Software Foundation Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache
License, Version 2.0</a>.
+	<a href="/openofficeorg/contact.html">Contact Us</a>
+	<br />Apache and the Apache feather logos are trademarks of The Apache Software Foundation.
+	<br />Other names appearing on the site may be trademarks of their respective owners.
+      </p>
+    </div>
+  </div>
+
+</body>
+</html>



Mime
View raw message