incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r795165 - /websites/staging/odftoolkit/trunk/content/odftoolkit/simple/demo/demo6.html
Date Fri, 02 Sep 2011 09:41:23 GMT
Author: buildbot
Date: Fri Sep  2 09:41:23 2011
New Revision: 795165

Log:
Staging update by buildbot

Modified:
    websites/staging/odftoolkit/trunk/content/odftoolkit/simple/demo/demo6.html

Modified: websites/staging/odftoolkit/trunk/content/odftoolkit/simple/demo/demo6.html
==============================================================================
--- websites/staging/odftoolkit/trunk/content/odftoolkit/simple/demo/demo6.html (original)
+++ websites/staging/odftoolkit/trunk/content/odftoolkit/simple/demo/demo6.html Fri Sep  2
09:41:23 2011
@@ -78,144 +78,67 @@
   <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" src="scripts/shCore.js"></script>  
-<script type="text/javascript" src="scripts/shBrushJava.js"></script>  
-<script type="text/javascript"> SyntaxHighlighter.all();</script>
-<script type="text/javascript">
-
-<p>var _gaq = _gaq || [];
-  _gaq.push(['_setAccount', 'UA-22366020-1']);
-  _gaq.push(['_trackPageview']);</p>
-<p>(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);
-  })();</p>
-<p></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> &gt; 
-        <a href="demo6.html">Demo 5: Booking Sheet with Text Box<a>
-        </span> 
-        </div></p>
-<div class="codehilite"><pre>    <span class="sr">&lt;!----------------------------------------------------------------------------------------------------&gt;</span>
-</pre></div>
-
-
-<p><div class="contenttitle">
-    <a name="overview">Overview</a>
-</div>
-<div class="bodytext">
-    <p>This demo shows the power of text box and paragraph support in Simple ODF.<br/>
-    The background of this demo is that a travel agency has to help customers book hotel.
They have a spreadsheet file in hand, which records all of the visitors' information. They
need to generate an order form with the requirements of hotel reservation using these data.
A order form template has been supplied. This program generates order forms for all the visitors
based on records of passengers in spreadsheet and the given template.<br/><br/>
-<img src="image/demo6.png" ><br/><br/> 
+    <p><strong><a href="index.html">Demos</a></strong> &gt;
<strong>Booking Sheet with Text Box</strong> <br />
 </p>
-</div>
-<hr/>
-<div class="contenttitle">
-    <a name="codeintroduction">Code Introduction</a>
-</div>
-<div class="bodytext">
-    <p>
-    There code of this demo is very simple. First, load template document and spreadsheet
separately. Secondly, iterate data table and create new section and paragraph. The Text Boxes
in the paragraph are also cloned. All of them are iterated and filled information from data
table.<br/>
-    Data items counts are also computed. These counts are wrote to the bottom table of the
sheet.<br/>
-    <!--java code-->
-    <pre class="brush:java;">
-    public static void main(String[] args) {
-        try {
-            // load template document
-            TextDocument doc = TextDocument.loadDocument("DemoTemplate.odt");
-            Table roomtable = doc.getTableByName("RoomTable");
-            roomtable.remove();
-            Section templateSection = doc.getSectionByName("SectionForm");
-            // load passenger data document
-            SpreadsheetDocument data = SpreadsheetDocument.loadDocument("Passengers.ods");
-            Table table = data.getTableByName("passenger");
-            int count = table.getRowCount();
-            int type1Count = 0, type2Count = 0, type3Count = 0;
-            for (int i = 1; i &lt; count; i++) {
-                Row row = table.getRowByIndex(i);
-                for (int j = 0; j &lt; 6; j++) {
-                    Paragraph para = templateSection.getParagraphByIndex(j, false);
-                    Textbox nameBox = para.getTextboxIterator().next();
-                    String content = row.getCellByIndex(j).getDisplayText();
-                    nameBox.setTextContent(content);
-                    if (j == 5) {
-                        if (content.equals("Deluxe Room"))
-                            type1Count++;
-                        else if (content.equals("Studio/Junior Suite"))
-                            type2Count++;
-                        else if (content.equals("Executive Suite"))
-                            type3Count++;
-                    }
-                }
-                doc.appendSection(templateSection, false);
-                doc.addParagraph(null);
-            }
-            templateSection.remove();
-            roomtable.getCellByPosition(2, 1).setStringValue(type1Count + "");
-            roomtable.getCellByPosition(2, 2).setStringValue(type2Count + "");
-            roomtable.getCellByPosition(2, 3).setStringValue(type3Count + "");</p>
-<div class="codehilite"><pre>        <span class="n">doc</span><span
class="o">.</span><span class="n">getContentRoot</span><span class="p">()</span><span
class="o">.</span><span class="n">appendChild</span><span class="p">(</span><span
class="n">roomtable</span><span class="o">.</span><span class="n">getOdfElement</span><span
class="p">());</span>
+<p><strong>Overview</strong> <br />
+</p>
+<p>This demo shows the power of text box and paragraph support in Simple ODF. <br
/>
+</p>
+<p>The background of this demo is that a travel agency has to help customers book hotel.
They have a spreadsheet file in hand, which records all of the visitors' information. They
need to generate an order form with the requirements of hotel reservation using these data.
A order form template has been supplied. This program generates order forms for all the visitors
based on records of passengers in spreadsheet and the given template.  <br />
+</p>
+<p><img src="image/demo6.png" ><br/><br/> 
+<strong>Code Introduction</strong></p>
+<p>There code of this demo is very simple. First, load template document and spreadsheet
separately. Secondly, iterate data table and create new section and paragraph. The Text Boxes
in the paragraph are also cloned. All of them are iterated and filled information from data
table.<br/>
+Data items counts are also computed. These counts are wrote to the bottom table of the sheet.<br/></p>
+<div class="codehilite"><pre><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">try</span> <span class="p">{</span>
+        <span class="sr">//</span> <span class="n">load</span> <span
class="n">template</span> <span class="n">document</span>
+        <span class="n">TextDocument</span> <span class="n">doc</span>
<span class="o">=</span> <span class="n">TextDocument</span><span
class="o">.</span><span class="n">loadDocument</span><span class="p">(</span><span
class="s">&quot;DemoTemplate.odt&quot;</span><span class="p">);</span>
+        <span class="n">Table</span> <span class="n">roomtable</span>
<span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span
class="n">getTableByName</span><span class="p">(</span><span class="s">&quot;RoomTable&quot;</span><span
class="p">);</span>
+        <span class="n">roomtable</span><span class="o">.</span><span
class="n">remove</span><span class="p">();</span>
+        <span class="n">Section</span> <span class="n">templateSection</span>
<span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span
class="n">getSectionByName</span><span class="p">(</span><span class="s">&quot;SectionForm&quot;</span><span
class="p">);</span>
+        <span class="sr">//</span> <span class="n">load</span> <span
class="n">passenger</span> <span class="n">data</span> <span class="n">document</span>
+        <span class="n">SpreadsheetDocument</span> <span class="n">data</span>
<span class="o">=</span> <span class="n">SpreadsheetDocument</span><span
class="o">.</span><span class="n">loadDocument</span><span class="p">(</span><span
class="s">&quot;Passengers.ods&quot;</span><span class="p">);</span>
+        <span class="n">Table</span> <span class="n">table</span>
<span class="o">=</span> <span class="n">data</span><span class="o">.</span><span
class="n">getTableByName</span><span class="p">(</span><span class="s">&quot;passenger&quot;</span><span
class="p">);</span>
+        <span class="nb">int</span> <span class="n">count</span>
<span class="o">=</span> <span class="n">table</span><span class="o">.</span><span
class="n">getRowCount</span><span class="p">();</span>
+        <span class="nb">int</span> <span class="n">type1Count</span>
<span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
<span class="n">type2Count</span> <span class="o">=</span> <span
class="mi">0</span><span class="p">,</span> <span class="n">type3Count</span>
<span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+        <span class="k">for</span> <span class="p">(</span><span
class="nb">int</span> <span class="n">i</span> <span class="o">=</span>
<span class="mi">1</span><span class="p">;</span> <span class="n">i</span>
<span class="o">&lt;</span> <span class="n">count</span><span
class="p">;</span> <span class="n">i</span><span class="o">++</span><span
class="p">)</span> <span class="p">{</span>
+            <span class="n">Row</span> <span class="n">row</span>
<span class="o">=</span> <span class="n">table</span><span class="o">.</span><span
class="n">getRowByIndex</span><span class="p">(</span><span class="n">i</span><span
class="p">);</span>
+            <span class="k">for</span> <span class="p">(</span><span
class="nb">int</span> <span class="n">j</span> <span class="o">=</span>
<span class="mi">0</span><span class="p">;</span> <span class="n">j</span>
<span class="o">&lt;</span> <span class="mi">6</span><span
class="p">;</span> <span class="n">j</span><span class="o">++</span><span
class="p">)</span> <span class="p">{</span>
+                <span class="n">Paragraph</span> <span class="n">para</span>
<span class="o">=</span> <span class="n">templateSection</span><span
class="o">.</span><span class="n">getParagraphByIndex</span><span
class="p">(</span><span class="n">j</span><span class="p">,</span>
<span class="n">false</span><span class="p">);</span>
+                <span class="n">Textbox</span> <span class="n">nameBox</span>
<span class="o">=</span> <span class="n">para</span><span class="o">.</span><span
class="n">getTextboxIterator</span><span class="p">()</span><span
class="o">.</span><span class="k">next</span><span class="p">();</span>
+                <span class="n">String</span> <span class="n">content</span>
<span class="o">=</span> <span class="n">row</span><span class="o">.</span><span
class="n">getCellByIndex</span><span class="p">(</span><span class="n">j</span><span
class="p">)</span><span class="o">.</span><span class="n">getDisplayText</span><span
class="p">();</span>
+                <span class="n">nameBox</span><span class="o">.</span><span
class="n">setTextContent</span><span class="p">(</span><span class="n">content</span><span
class="p">);</span>
+                <span class="k">if</span> <span class="p">(</span><span
class="n">j</span> <span class="o">==</span> <span class="mi">5</span><span
class="p">)</span> <span class="p">{</span>
+                    <span class="k">if</span> <span class="p">(</span><span
class="n">content</span><span class="o">.</span><span class="n">equals</span><span
class="p">(</span><span class="s">&quot;Deluxe Room&quot;</span><span
class="p">))</span>
+                        <span class="n">type1Count</span><span class="o">++</span><span
class="p">;</span>
+                    <span class="k">else</span> <span class="k">if</span>
<span class="p">(</span><span class="n">content</span><span class="o">.</span><span
class="n">equals</span><span class="p">(</span><span class="s">&quot;Studio/Junior
Suite&quot;</span><span class="p">))</span>
+                        <span class="n">type2Count</span><span class="o">++</span><span
class="p">;</span>
+                    <span class="k">else</span> <span class="k">if</span>
<span class="p">(</span><span class="n">content</span><span class="o">.</span><span
class="n">equals</span><span class="p">(</span><span class="s">&quot;Executive
Suite&quot;</span><span class="p">))</span>
+                        <span class="n">type3Count</span><span class="o">++</span><span
class="p">;</span>
+                <span class="p">}</span>
+            <span class="p">}</span>
+            <span class="n">doc</span><span class="o">.</span><span
class="n">appendSection</span><span class="p">(</span><span class="n">templateSection</span><span
class="p">,</span> <span class="n">false</span><span class="p">);</span>
+            <span class="n">doc</span><span class="o">.</span><span
class="n">addParagraph</span><span class="p">(</span><span class="n">null</span><span
class="p">);</span>
+        <span class="p">}</span>
+        <span class="n">templateSection</span><span class="o">.</span><span
class="n">remove</span><span class="p">();</span>
+        <span class="n">roomtable</span><span class="o">.</span><span
class="n">getCellByPosition</span><span class="p">(</span><span class="mi">2</span><span
class="p">,</span> <span class="mi">1</span><span class="p">)</span><span
class="o">.</span><span class="n">setStringValue</span><span class="p">(</span><span
class="n">type1Count</span> <span class="o">+</span> <span class="s">&quot;&quot;</span><span
class="p">);</span>
+        <span class="n">roomtable</span><span class="o">.</span><span
class="n">getCellByPosition</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="o">.</span><span class="n">setStringValue</span><span class="p">(</span><span
class="n">type2Count</span> <span class="o">+</span> <span class="s">&quot;&quot;</span><span
class="p">);</span>
+        <span class="n">roomtable</span><span class="o">.</span><span
class="n">getCellByPosition</span><span class="p">(</span><span class="mi">2</span><span
class="p">,</span> <span class="mi">3</span><span class="p">)</span><span
class="o">.</span><span class="n">setStringValue</span><span class="p">(</span><span
class="n">type3Count</span> <span class="o">+</span> <span class="s">&quot;&quot;</span><span
class="p">);</span>
+
+        <span class="n">doc</span><span class="o">.</span><span
class="n">getContentRoot</span><span class="p">()</span><span class="o">.</span><span
class="n">appendChild</span><span class="p">(</span><span class="n">roomtable</span><span
class="o">.</span><span class="n">getOdfElement</span><span class="p">());</span>
         <span class="n">doc</span><span class="o">.</span><span
class="n">save</span><span class="p">(</span><span class="s">&quot;output.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">e</span><span class="o">.</span><span
class="n">printStackTrace</span><span class="p">();</span>
     <span class="p">}</span>
 
 <span class="p">}</span>
-<span class="sr">&lt;/pre&gt;</span>
 </pre></div>
 
 
-<p></p>
-</div>
-<hr/>
-<div class="contenttitle">
-    <a name="download">Download</a>
-</div>
-<div class="bodytext">
-  <p>
-    Powered by the Simple Java API for ODF version  <a target="_new" href="../downloads.html"><img
src="../images/link.png"></img>0.5</a>.
-  </p>
-  <p>
-    You can download the code of this demo from <a href="TextboxDemo.zip"><img src="../images/link.png"></img>here</a>.
-  </p>
-</div>
-<!---------------------------------------------------------------------------------------------------->
  <br />
-</div>
-<div id="footer" class="smallgraytext"> <a href="#">Home</a> | <a href="#">About
Us</a> | <a href="#">Contact Us</a> </div>
-</div>
-</div>
-</body>
-</html> </p>
+<p><strong>Download</strong> <br />
+Powered by the Simple Java API for ODF version  <a target="_new" href="../downloads.html">0.5</a>.<br
/>
+You can download the code of this demo from <a href="TextboxDemo.zip">here</a>.</p>
   </div>
 
   <div id="footera">



Mime
View raw message