incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r795293 - in /websites/production/odftoolkit: ./ content/odftoolkit/simple/demo/demo3.html
Date Mon, 05 Sep 2011 03:27:28 GMT
Author: devinhan
Date: Mon Sep  5 03:27:27 2011
New Revision: 795293

Log:
Publishing merge to odftoolkit site by devinhan

Modified:
    websites/production/odftoolkit/   (props changed)
    websites/production/odftoolkit/content/odftoolkit/simple/demo/demo3.html

Propchange: websites/production/odftoolkit/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep  5 03:27:27 2011
@@ -1 +1 @@
-/websites/staging/odftoolkit/trunk:794771-795289
+/websites/staging/odftoolkit/trunk:794771-795292

Modified: websites/production/odftoolkit/content/odftoolkit/simple/demo/demo3.html
==============================================================================
--- websites/production/odftoolkit/content/odftoolkit/simple/demo/demo3.html (original)
+++ websites/production/odftoolkit/content/odftoolkit/simple/demo/demo3.html Mon Sep  5 03:27:27
2011
@@ -78,301 +78,116 @@
   <div id="contenta">
   
     
-    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link rel="stylesheet" href="../images/style.css" type="text/css" />
-
-<link type="text/css" rel="stylesheet" href="styles/shCoreEclipse.css"/>
-
-<title>Demos - SimpleODF</title>
-<style type="text/css">
-<!--
-.STYLE1 {
-    color: #FFFFFF;
-    font-size: 24px;
-}
-.STYLE2 {font-size: 32px}
-.STYLE3 {font-size: 16px}
-.STYLE4 {font-size: 36px}
--->
-    </style>
-    <script type="text/javascript">
-
-var _gaq = _gaq || [];
-  _gaq.push(['_setAccount', 'UA-22366020-1']);
-  _gaq.push(['_trackPageview']);
-
-(function() {
-    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-  })();
-
-</script>
-</head>
-<body>
-<div id="page" align="center">
-  <div id="content" style="width:920px" class="contentpanel">
-    <div id="topheader">
-      <div class="topright"> </div>
-    </div>
-    <div id="menu">
-      <div align="left" class="smallwhitetext"> <a href="../index.html" class="home">
</a> <a href="../downloads.html" class="download"></a> <a href="../documents.html"
class="document"></a> <a href="../demo/index.html" class="sample"> </a>
</div>
-    </div>
-    <div id="subcontent" align ="left">
-        <div align="left" class="titletext"> <span >
-        <a href="index.html">Simple Demos<a> > 
-        <a href="demo3.html">Demo 2: Navigation API in Hotel Receipt<a>
-        </span> 
-        </div>
-
-<!---------------------------------------------------------------------------------------------------->

-<div class="contenttitle">
-
-<a name="overview">Overview</a>
-
-</div>
-
-<div class="bodytext">
-
-<p>
-
-This demo is a simple template application about hotel receipt. By loading the configuration
file "consume-data.properties" and navigating the hotel receipt template, this demo could
generate the ODF documents (ODT, ODP, and ODS format). In the generated ODF documents, you
can see the concrete information about hotel receipt, such as hotel name, customer name, consume
time, consume data, total expense, headcount, and consume item details including the price,
quantity, total expense of each item. Taking the ODT document as an example, the ODT document
template is shown in the following picture. Please notice the area surrounding by eight small
green square, it is a chart. Because this chart is generated by the column ConsumeItem and
the column Total Expense($) in the above table and the values of the column Total Expense($)
are not numeric type, the template chart might not display correctly in your ODF editor, but
it will display correctly after the template is expanded.
-
-<br><img src="image/ODT Templating.jpg">
-
-<br>And the generated ODT document is shown in the following picture.
-
-<br><img src="image/Generated ODT.jpg" >
-
+    <p><strong><a href="index.html">Demos</a></strong> &gt;
<strong>Navigation API in Hotel Receipt</strong>   <br />
 </p>
-
-<p>
-
-Use the Simple Java API for ODF to complete this simple template application. This demo mainly
uses the API of package navigation. In the root directory of this demo project, there are
three defined ODF template documents, "Navigation-ODT-Templating.odt", "Navigation-ODP-Templating.odp"
and "Navigation-ODS-Templating.ods", and one configuration file, "consume-data.properties".
Run NavigationForODF.java, and then in the root directory of this demo project you can find
three generated ODF documents, "Navigation-ODT-Generated.odt", "Navigation-ODP-Generated.odp"
and "Navigation-ODS-Generated.ods", which contain the information of "consume-data.properties".
In these ODF documents, the consume item details are shown as table and chart.
-
+<p><strong>Overview</strong>  <br />
 </p>
-
-<p>
-
-Please notice the differences of ODT, ODP, ODS template document. In ODT and ODS template
documents, the chart could be automatically generated by the ODF editor according to the data
of table, and in this demo the data of chart comes from the column of ConsumeItem and Total
Expense($). But in ODP template documents, the chart can not be automatically generated by
the table, in fact, the chart in ODP template document is created manually through the function
"insert chart" of openoffice, and the type of second column must be numeric. In addition,
please notice the cell value of ODS document, the cell value has character type and numeric
type, for example, ‘5,000 represents character type and 5,000 represents numeric type,
and we could see that the different point is the single quotation marks before 5,000.
-
+<p>This demo is a simple template application about hotel receipt. By loading the configuration
file "consume-data.properties" and navigating the hotel receipt template, this demo could
generate the ODF documents (ODT, ODP, and ODS format).  <br />
 </p>
-
-</div>
-
-<hr/>
-
-<div class="contenttitle">
-
-<a name="codeintroduction">Code Introduction</a>
-
-</div>
-
-<div class="bodytext">
-
-<p>
-
-First, load the key-value in the file "consume-data.properties" into the instance of Properties,
and put ConsumeItem as key and TotalExpenseOfItem as value to the instance of HashMap for
navigating ODP document template.
-
+<p>In the generated ODF documents, you can see the concrete information about hotel
receipt, such as hotel name, customer name, consume time, consume data, total expense, headcount,
and consume item details including the price, quantity, total expense of each item. Taking
the ODT document as an example, the ODT document template is shown in the following picture.
Please notice the area surrounding by eight small green square, it is a chart. Because this
chart is generated by the column ConsumeItem and the column Total Expense($) in the above
table and the values of the column Total Expense($) are not numeric type, the template chart
might not display correctly in your ODF editor, but it will display correctly after the template
is expanded. <br />
 </p>
+<p><img src="image/ODT Templating.jpg" ></img><br />
+</p>
+<p>And the generated ODT document is shown in the following picture. <br />
+</p>
+<p><img src="image/Generated ODT.jpg" ></img></p>
+<p>Use Simple API to complete this simple template application. This demo mainly uses
the API of package navigation.  <br />
+</p>
+<p>In the root directory of this demo project, there are three defined ODF template
documents, "Navigation-ODT-Templating.odt", "Navigation-ODP-Templating.odp" and "Navigation-ODS-Templating.ods",
and one configuration file, "consume-data.properties". Run NavigationForODF.java, and then
in the root directory of this demo project you can find three generated ODF documents, "Navigation-ODT-Generated.odt",
"Navigation-ODP-Generated.odp" and "Navigation-ODS-Generated.ods", which contain the information
of "consume-data.properties". In these ODF documents, the consume item details are shown as
table and chart.  <br />
+</p>
+<p>Please notice the differences of ODT, ODP, ODS template document. In ODT and ODS
template documents, the chart could be automatically generated by the ODF editor according
to the data of table, and in this demo the data of chart comes from the column of ConsumeItem
and Total Expense($). But in ODP template documents, the chart can not be automatically generated
by the table, in fact, the chart in ODP template document is created manually through the
function "insert chart" of openoffice, and the type of second column must be numeric. In addition,
please notice the cell value of ODS document, the cell value has character type and numeric
type, for example, ‘5,000 represents character type and 5,000 represents numeric type,
and we could see that the different point is the single quotation marks before 5,000. <br
/>
+</p>
+<p><strong>Code Introduction</strong></p>
+<p>First, load the key-value in the file "consume-data.properties" into the instance
of Properties, and put ConsumeItem as key and TotalExpenseOfItem as value to the instance
of HashMap for navigating ODP document template. <br />
+</p>
+<div class="codehilite"><pre><span class="n">public</span> <span
class="n">void</span> <span class="n">loadConsumeData</span><span
class="p">(</span><span class="n">String</span> <span class="n">filepath</span><span
class="p">)</span> <span class="n">throws</span> <span class="n">Exception</span>
<span class="p">{</span>
+    <span class="n">InputStream</span> <span class="n">is</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">FileInputStream</span><span
class="p">(</span><span class="n">filepath</span><span class="p">);</span>
+    <span class="n">properties</span><span class="o">.</span><span
class="n">load</span><span class="p">(</span><span class="n">is</span><span
class="p">);</span>
+    <span class="n">is</span><span class="o">.</span><span class="nb">close</span><span
class="p">();</span>
+    <span class="sr">//</span> <span class="n">put</span> <span
class="n">ConsumeItem</span> <span class="n">as</span> <span class="n">key</span>
<span class="ow">and</span> <span class="n">TotalExpenseOfItem</span>
<span class="n">as</span> <span class="n">value</span> <span class="n">to</span>
<span class="nb">map</span>
+    <span class="n">Enumeration</span><span class="sr">&lt;String&gt;</span>
<span class="n">enu</span> <span class="o">=</span> <span class="p">(</span><span
class="n">Enumeration</span><span class="sr">&lt;String&gt;</span><span
class="p">)</span> <span class="n">properties</span><span class="o">.</span><span
class="n">propertyNames</span><span class="p">();</span>
+    <span class="k">while</span> <span class="p">(</span><span
class="n">enu</span><span class="o">.</span><span class="n">hasMoreElements</span><span
class="p">())</span> <span class="p">{</span>
+        <span class="n">String</span> <span class="n">key</span>
<span class="o">=</span> <span class="p">(</span><span class="n">String</span><span
class="p">)</span> <span class="n">enu</span><span class="o">.</span><span
class="n">nextElement</span><span class="p">();</span>
+        <span class="k">if</span> <span class="p">(</span><span
class="n">key</span><span class="o">.</span><span class="n">contains</span><span
class="p">(</span><span class="s">&quot;ConsumeItem&quot;</span><span
class="p">))</span> <span class="p">{</span>
+            <span class="n">String</span> <span class="n">consumeItem</span>
<span class="o">=</span> <span class="n">properties</span><span
class="o">.</span><span class="n">getProperty</span><span class="p">(</span><span
class="n">key</span><span class="p">);</span>
+            <span class="n">String</span> <span class="n">totalExpenseOfItem</span>
<span class="o">=</span> <span class="n">properties</span><span
class="o">.</span><span class="n">getProperty</span><span class="p">(</span><span
class="s">&quot;TotalExpenseOfItem&quot;</span>
+                                        <span class="o">+</span> <span class="n">key</span><span
class="o">.</span><span class="n">charAt</span><span class="p">(</span><span
class="n">key</span><span class="o">.</span><span class="nb">length</span><span
class="p">()</span> <span class="o">-</span> <span class="mi">1</span><span
class="p">));</span>
+            <span class="nb">map</span><span class="o">.</span><span
class="n">put</span><span class="p">(</span><span class="n">consumeItem</span><span
class="p">,</span> <span class="n">totalExpenseOfItem</span><span
class="p">);</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p>Then, introduce how to navigate the template documents and generate the ODF documents.
 <br />
+</p>
+<p><strong><em>Navigate ODT document template</em></strong><br
/>
+</p>
+<p>Load "Navigation-ODT-Templating.odt" and get the instance of TextDocument. Then
traverse the instance of Properties, use the API of TextNavigation and TextSelection to complete
the replacement of template document as the line 10-14. Please notice the line 17 and 18,
make sure that the chart is shown rightly when open the generated document, so is navigating
ODP and ODS document template. At last, generate "Navigation-ODT-Generated.odt" as the line
19.  <br />
+</p>
+<div class="codehilite"><pre><span class="n">public</span> <span
class="n">void</span> <span class="n">navigateODT</span><span class="p">()</span>
<span class="n">throws</span> <span class="n">Exception</span> <span
class="p">{</span>
+    <span class="n">Iterator</span> <span class="n">it</span> <span
class="o">=</span> <span class="n">properties</span><span class="o">.</span><span
class="n">entrySet</span><span class="p">()</span><span class="o">.</span><span
class="n">iterator</span><span class="p">();</span>
+    <span class="n">System</span><span class="o">.</span><span
class="n">out</span><span class="o">.</span><span class="n">println</span><span
class="p">(</span><span class="s">&quot;Navigate ODT document: Navigation-ODT-Templating.odt&quot;</span><span
class="p">);</span>
+    <span class="n">TextDocument</span> <span class="n">textdoc</span>
<span class="o">=</span> <span class="p">(</span><span class="n">TextDocument</span><span
class="p">)</span> <span class="n">TextDocument</span><span class="o">.</span><span
class="n">loadDocument</span><span class="p">(</span><span class="s">&quot;Navigation-ODT-Templating.odt&quot;</span><span
class="p">);</span>
+    <span class="n">TextNavigation</span> <span class="n">search</span><span
class="p">;</span>
+    <span class="k">while</span> <span class="p">(</span><span
class="n">it</span><span class="o">.</span><span class="n">hasNext</span><span
class="p">())</span> <span class="p">{</span>
+        <span class="n">Map</span><span class="o">.</span><span
class="n">Entry</span> <span class="n">entry</span> <span class="o">=</span>
<span class="p">(</span><span class="n">Map</span><span class="o">.</span><span
class="n">Entry</span><span class="p">)</span> <span class="n">it</span><span
class="o">.</span><span class="k">next</span><span class="p">();</span>
+        <span class="n">String</span> <span class="n">key</span>
<span class="o">=</span> <span class="p">(</span><span class="n">String</span><span
class="p">)</span> <span class="n">entry</span><span class="o">.</span><span
class="n">getKey</span><span class="p">();</span>
+        <span class="n">String</span> <span class="n">value</span>
<span class="o">=</span> <span class="p">(</span><span class="n">String</span><span
class="p">)</span> <span class="n">entry</span><span class="o">.</span><span
class="n">getValue</span><span class="p">();</span>
+        <span class="n">search</span> <span class="o">=</span> <span
class="k">new</span> <span class="n">TextNavigation</span><span class="p">(</span><span
class="n">key</span><span class="p">,</span> <span class="n">textdoc</span><span
class="p">);</span>
+        <span class="k">while</span> <span class="p">(</span><span
class="n">search</span><span class="o">.</span><span class="n">hasNext</span><span
class="p">())</span> <span class="p">{</span>
+            <span class="n">TextSelection</span> <span class="n">item</span>
<span class="o">=</span> <span class="p">(</span><span class="n">TextSelection</span><span
class="p">)</span> <span class="n">search</span><span class="o">.</span><span
class="n">nextSelection</span><span class="p">();</span>
+            <span class="n">item</span><span class="o">.</span><span
class="n">replaceWith</span><span class="p">(</span><span class="n">value</span><span
class="p">);</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+    <span class="sr">//</span> <span class="n">remove</span> <span
class="n">ObjectReplacements</span><span class="sr">/ and Thumbnails/</span>
+    <span class="n">textdoc</span><span class="o">.</span><span
class="n">getPackage</span><span class="p">()</span><span class="o">.</span><span
class="n">removePackageDocument</span><span class="p">(</span><span
class="s">&quot;ObjectReplacements/&quot;</span><span class="p">);</span>
+    <span class="n">textdoc</span><span class="o">.</span><span
class="n">getPackage</span><span class="p">()</span><span class="o">.</span><span
class="n">removePackageDocument</span><span class="p">(</span><span
class="s">&quot;Thumbnails/&quot;</span><span class="p">);</span>
+    <span class="n">textdoc</span><span class="o">.</span><span
class="n">save</span><span class="p">(</span><span class="s">&quot;Navigation-ODT-Generated.odt&quot;</span><span
class="p">);</span>
+    <span class="n">System</span><span class="o">.</span><span
class="n">out</span><span class="o">.</span><span class="n">println</span><span
class="p">(</span><span class="s">&quot;...\nNavigation is over, and Navigation-ODT-Generated.odt
is generated&quot;</span><span class="p">);</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<p><strong><em>Navigate ODP document template</em></strong>
<br />
+</p>
+<p>Unlike the ODT document, the chart of ODP document is an embedded document. Before
navigate the chart, get the embedded document as the line 2 and 3. The chart comes from a
table, and we could change the chart by setting the cell value of the table as the line 13-15.
The line 15 uses the Class DefaultCellValueAdapter to update the cell value and value type.
 <br />
+</p>
+<div class="codehilite"><pre>    <span class="sr">//</span> <span
class="n">set</span> <span class="n">the</span> <span class="n">cell</span>
<span class="n">value</span> <span class="n">in</span> <span class="n">the</span>
<span class="n">table</span> <span class="n">of</span> <span class="n">embedderdocument</span>
+    <span class="n">List</span><span class="sr">&lt;Document&gt;</span>
<span class="n">embeddedDocuments</span> <span class="o">=</span>
<span class="n">pdoc</span><span class="o">.</span><span class="n">getEmbeddedDocuments</span><span
class="p">();</span>
+    <span class="n">Document</span> <span class="n">embeddedDocument</span>
<span class="o">=</span> <span class="n">embeddedDocuments</span><span
class="o">.</span><span class="n">get</span><span class="p">(</span><span
class="mi">0</span><span class="p">);</span>
+    <span class="n">Table</span> <span class="n">table</span> <span
class="o">=</span> <span class="n">embeddedDocument</span><span class="o">.</span><span
class="n">getTableList</span><span class="p">()</span><span class="o">.</span><span
class="n">get</span><span class="p">(</span><span class="mi">0</span><span
class="p">);</span>
+    <span class="n">String</span> <span class="n">consumeItem</span><span
class="p">;</span>
+    <span class="n">String</span> <span class="n">totalExpenseOfItem</span><span
class="p">;</span>
+    <span class="nb">int</span> <span class="nb">index</span> <span
class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+    <span class="n">Iterator</span><span class="sr">&lt;String&gt;</span>
<span class="n">it</span> <span class="o">=</span> <span class="nb">map</span><span
class="o">.</span><span class="n">keySet</span><span class="p">()</span><span
class="o">.</span><span class="n">iterator</span><span class="p">();</span>
+    <span class="k">while</span> <span class="p">(</span><span
class="n">it</span><span class="o">.</span><span class="n">hasNext</span><span
class="p">())</span> <span class="p">{</span>
+        <span class="nb">index</span><span class="o">++</span><span
class="p">;</span>
+        <span class="n">consumeItem</span> <span class="o">=</span>
<span class="p">(</span><span class="n">String</span><span class="p">)</span>
<span class="n">it</span><span class="o">.</span><span class="k">next</span><span
class="p">();</span>
+        <span class="n">totalExpenseOfItem</span> <span class="o">=</span>
<span class="p">(</span><span class="n">String</span><span class="p">)</span>
<span class="nb">map</span><span class="o">.</span><span class="n">get</span><span
class="p">(</span><span class="n">consumeItem</span><span class="p">);</span>
+        <span class="n">table</span><span class="o">.</span><span
class="n">getColumnByIndex</span><span class="p">(</span><span class="mi">0</span><span
class="p">)</span><span class="o">.</span><span class="n">getCellByIndex</span><span
class="p">(</span><span class="nb">index</span><span class="p">)</span><span
class="o">.</span><span class="n">setDisplayText</span><span class="p">(</span><span
class="n">consumeItem</span><span class="p">);</span>
+        <span class="n">table</span><span class="o">.</span><span
class="n">getColumnByIndex</span><span class="p">(</span><span class="mi">1</span><span
class="p">)</span><span class="o">.</span><span class="n">getCellByIndex</span><span
class="p">(</span><span class="nb">index</span><span class="p">)</span><span
class="o">.</span><span class="n">setDisplayText</span><span class="p">(</span><span
class="n">totalExpenseOfItem</span><span class="p">,</span> <span
class="k">new</span> <span class="n">DefaultCellValueAdapter</span><span
class="p">());</span>
+    <span class="p">}</span>
+</pre></div>
+
+
+<p><strong><em>Navigate ODS document template</em></strong>
<br />
+</p>
+<p>Unlike the ODT document, use the Class CellSelection to complete the replacement.
Class CellSelection is the subclass of Class TextSelection. Use the method "advancedReplaceWith"
to update the cell value and value type.  <br />
+</p>
+<div class="codehilite"><pre>    <span class="n">search</span> <span
class="o">=</span> <span class="k">new</span> <span class="n">TextNavigation</span><span
class="p">(</span><span class="n">key</span><span class="p">,</span>
<span class="n">ssdoc</span><span class="p">);</span>
+    <span class="k">while</span> <span class="p">(</span><span
class="n">search</span><span class="o">.</span><span class="n">hasNext</span><span
class="p">())</span> <span class="p">{</span>
+        <span class="n">CellSelection</span> <span class="n">item</span>
<span class="o">=</span> <span class="p">(</span><span class="n">CellSelection</span><span
class="p">)</span> <span class="n">search</span><span class="o">.</span><span
class="n">nextSelection</span><span class="p">();</span>
+        <span class="n">item</span><span class="o">.</span><span
class="n">advancedReplaceWith</span><span class="p">(</span><span
class="n">value</span><span class="p">,</span> <span class="k">new</span>
<span class="n">DefaultCellValueAdapter</span><span class="p">());</span>
+    <span class="p">}</span>
+</pre></div>
 
-<!--java code-->
-
-<pre class="brush:java;">
-
-public void loadConsumeData(String filepath) throws Exception {
-
-InputStream is = new FileInputStream(filepath);
-
-properties.load(is);
-
-is.close();
-
-// put ConsumeItem as key and TotalExpenseOfItem as value to map
-
-Enumeration<String> enu = (Enumeration<String>) properties.propertyNames();
-
-while (enu.hasMoreElements()) {
-
-String key = (String) enu.nextElement();
-
-if (key.contains("ConsumeItem")) {
-
-String consumeItem = properties.getProperty(key);
-
-String totalExpenseOfItem = properties.getProperty("TotalExpenseOfItem"
-                                            + key.charAt(key.length() - 1));
-
-map.put(consumeItem, totalExpenseOfItem);
-
-}
-
-}
-
-}
-
-</pre>
 
+<p><strong>Download</strong> <br />
 </p>
-
-<p>
-
-Then, introduce how to navigate the template documents and generate the ODF documents.
-
-<br><b>Ⅰ. Navigate ODT document template</b>
-
-<br>Load "Navigation-ODT-Templating.odt" and get the instance of TextDocument. Then
traverse the instance of Properties, use the API of TextNavigation and TextSelection to complete
the replacement of template document as the line 10-14. Please notice the line 17 and 18,
make sure that the chart is shown rightly when open the generated document, so is navigating
ODP and ODS document template. At last, generate "Navigation-ODT-Generated.odt" as the line
19.
-
-<!--java code-->
-
-<pre class="brush:java;">
-
-public void navigateODT() throws Exception {
-
-Iterator it = properties.entrySet().iterator();
-
-System.out.println("Navigate ODT document: Navigation-ODT-Templating.odt");
-
-TextDocument textdoc = (TextDocument) TextDocument.loadDocument("Navigation-ODT-Templating.odt");
-
-TextNavigation search;
-
-while (it.hasNext()) {
-
-Map.Entry entry = (Map.Entry) it.next();
-
-String key = (String) entry.getKey();
-
-String value = (String) entry.getValue();
-
-search = new TextNavigation(key, textdoc);
-
-while (search.hasNext()) {
-
-TextSelection item = (TextSelection) search.nextSelection();
-
-item.replaceWith(value);
-
-}
-
-}
-
-// remove ObjectReplacements/ and Thumbnails/
-
-textdoc.getPackage().removePackageDocument("ObjectReplacements/");
-
-textdoc.getPackage().removePackageDocument("Thumbnails/");
-
-textdoc.save("Navigation-ODT-Generated.odt");
-
-System.out.println("...\nNavigation is over, and Navigation-ODT-Generated.odt is generated");
-
-}
-
-</pre>
-
-</p>
-
-<p>
-
-<b>Ⅱ. Navigate ODP document template</b>
-
-<br>Unlike the ODT document, the chart of ODP document is an embedded document. Before
navigate the chart, get the embedded document as the line 2 and 3. The chart comes from a
table, and we could change the chart by setting the cell value of the table as the line 13-15.
The line 15 uses the Class DefaultCellValueAdapter to update the cell value and value type.
-
-<!--java code-->
-
-<pre class="brush:java;">
-
-// set the cell value in the table of embedderdocument
-
-List<Document> embeddedDocuments = pdoc.getEmbeddedDocuments();
-
-Document embeddedDocument = embeddedDocuments.get(0);
-
-Table table = embeddedDocument.getTableList().get(0);
-
-String consumeItem;
-
-String totalExpenseOfItem;
-
-int index = 0;
-
-Iterator<String> it = map.keySet().iterator();
-
-while (it.hasNext()) {
-
-index++;
-
-consumeItem = (String) it.next();
-
-totalExpenseOfItem = (String) map.get(consumeItem);
-
-table.getColumnByIndex(0).getCellByIndex(index).setDisplayText(consumeItem);
-
-table.getColumnByIndex(1).getCellByIndex(index).setDisplayText(
-
-totalExpenseOfItem, new DefaultCellValueAdapter());
-
-}
-
-</pre>
-
-</p>
-
-<p>
-
-<b>Ⅲ. Navigate ODS document template</b>
-
-<br>Unlike the ODT document, use the Class CellSelection to complete the replacement.
Class CellSelection is the subclass of Class TextSelection. Use the method "advancedReplaceWith"
to update the cell value and value type.
-
-<!--java code-->
-
-<pre class="brush:java;">
-
-search = new TextNavigation(key, ssdoc);
-
-while (search.hasNext()) {
-
-CellSelection item = (CellSelection) search.nextSelection();
-
-item.advancedReplaceWith(value, new DefaultCellValueAdapter());
-
-}
-
-</pre>
-
+<p>Powered by Simple API version <a href="../downloads.html">0.3.5</a>.<br
/>
+You can download the code of this demo from <a href="Navigation-for-ODF.zip">here</a>.<br
/>
 </p>
-
-</div>
-
-<hr/>
-
-<div class="contenttitle"><a name="download">Download</a></div>
-
-<div class="bodytext">
-
-<p> Powered by Simple API version <a target="_new" href="../downloads.html"><img
src="../images/link.png"></img>0.3.5</a>.</p>
-
-<p> You can download the code of this demo from <a Href="Navigation-for-ODF.zip"><img
src="../images/link.png"></img>here</a>.</p>
-
-</div>
-<!---------------------------------------------------------------------------------------------------->
-
-</div>
-    <div id="footer" class="smallgraytext"> <a href="../index.html">Home</a>
| <a href="#">About Us</a> | <a href="mailto:Daisy@odftoolkit.org">Contact
Us</a> </div>
-  </div>
-</div>
-</body>
-</html>
-
-<script type="text/javascript" src="scripts/shCore.js"></script>
-
-<script type="text/javascript" src="scripts/shBrushJava.js"></script>
-
-<script type="text/javascript"> SyntaxHighlighter.all();</script>
   </div>
 
   <div id="footera">



Mime
View raw message