incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r795153 - in /websites/production/odftoolkit: ./ content/odftoolkit/simple/demo/demo10.html
Date Fri, 02 Sep 2011 08:40:37 GMT
Author: devinhan
Date: Fri Sep  2 08:40:36 2011
New Revision: 795153

Log:
Publishing merge to odftoolkit site by devinhan

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

Propchange: websites/production/odftoolkit/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  2 08:40:36 2011
@@ -1 +1 @@
-/websites/staging/odftoolkit/trunk:794771-795148
+/websites/staging/odftoolkit/trunk:794771-795152

Modified: websites/production/odftoolkit/content/odftoolkit/simple/demo/demo10.html
==============================================================================
--- websites/production/odftoolkit/content/odftoolkit/simple/demo/demo10.html (original)
+++ websites/production/odftoolkit/content/odftoolkit/simple/demo/demo10.html Fri Sep  2 08:40:36
2011
@@ -78,176 +78,86 @@
   <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">
-  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="demo10.html">Demo 9: Automatically Formatting a Document<a>
-    </span> 
-</div>
-<!---------------------------------------------------------------------------------------------------->

-<div class="contenttitle">
-    <a name="overview">Overview</a>
-</div>
-<div class="bodytext">
-    <p>
-    The Simple Java API for ODF has enhanced features to support document formatting in version
0.6.5. It supplies methods for manipulating headings, page breaks, hyperlinks, comments, font
and alignment. This demo shows how to use these features to help document formatting.<br/><br/>
-    It's a common scenario that we need apply some  styles to plain text to improve its appearance.
In this demo, a text document is created using plain text from a text file. While reading
content, paragraphs whose  length  is less than 20 characters are changed to headings with
a new font style. "Version" and "date" information is  set as right alignment and gray text.
Each line which matches an URL  will be applied as a hyperlink. Each heading and its following
paragraphs are considered as a chapter. There will be a page break after page line count larger
than a predefined value. Then verify word spelling and add comments as tip to those which
may have a spelling mistake. The last one is a security check. After these processes, the
plain text has been changed into a formatted document.<br/><br/>
-    This picture shows part of the generated document. The new document looks orderly and
beautiful than before.<br/><br/>
-    <img src="image/demo10.png"></img><br/><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 clear. Firstly, we open the data source and create a
text document. Secondly, we create paragraph for each line. Thirdly, we set different style
for different content. Then we do spell and security check with the help of Navigation API.
Comments are given if suspicious words are found.  Finally, the new created document is saved.
<br/><br/>
-    <!--java code-->
-    <pre class="brush:java;">
-        BufferedReader reader = new BufferedReader(new InputStreamReader(FormatParagraphDemo.class.getResourceAsStream("text.txt")));
-        String in = reader.readLine();
-        TextDocument doc = TextDocument.newTextDocument();
-        int lineCount = 0;
-        int pageLineCount = 0;
-        Paragraph refParagraph = null;
-        while (in != null) {
-            in = in.trim();
-            Paragraph paragraph = doc.addParagraph(in);
-            lineCount++;
-            pageLineCount++;
-            switch (lineCount) {
-            case 1:
-                paragraph
-                        .setHorizontalAlignment(HorizontalAlignmentType.CENTER);
-                paragraph.setFont(new Font("Arial", FontStyle.BOLD, 16));
-                paragraph.applyHeading();
-                break;
-            case 2:
-            case 3:
-                paragraph.setHorizontalAlignment(HorizontalAlignmentType.RIGHT);
-                paragraph.setFont(new Font("Tahoma", FontStyle.ITALIC, 10,
-                        Color.GRAY));
-                break;
-            default:
-                if (in.startsWith("http://")) {
-                    paragraph.applyHyperlink(new URI(in));
-                }
-                if (in.length() < 20) {
-                    paragraph.applyHeading();
-                    paragraph.setFont(new Font("Arial", FontStyle.BOLD, 12));
-                    if (pageLineCount > 16) {
-                        doc.addPageBreak(refParagraph);
-                        pageLineCount = 0;
-                    }
-                }
-            }
-            refParagraph = paragraph;
-            in = reader.readLine();
-
-<div class="codehilite"><pre>    <span class="p">}</span>
-    <span class="sr">//</span> <span class="n">spell</span> <span
class="n">check</span>
-    <span class="n">TextNavigation</span> <span class="n">navigation1</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">TextNavigation</span><span
class="p">(</span><span class="s">&quot;lower-level&quot;</span><span
class="p">,</span> <span class="n">doc</span><span class="p">);</span>
-    <span class="k">while</span> <span class="p">(</span><span
class="n">navigation1</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">selection</span>
<span class="o">=</span> <span class="p">(</span><span class="n">TextSelection</span><span
class="p">)</span> <span class="n">navigation1</span>
-                <span class="o">.</span><span class="n">nextSelection</span><span
class="p">();</span>
-        <span class="n">selection</span><span class="o">.</span><span
class="n">addComment</span><span class="p">(</span>
-                <span class="s">&quot;Please change &#39;lower-level&#39;
with &#39;lower level&#39;.&quot;</span><span class="p">,</span>
-                <span class="s">&quot;SpellChecker&quot;</span><span
class="p">);</span>
-    <span class="p">}</span>
-    <span class="sr">//</span> <span class="n">security</span> <span
class="n">check</span>
-    <span class="n">TextNavigation</span> <span class="n">navigation2</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">TextNavigation</span><span
class="p">(</span><span class="s">&quot;confidential&quot;</span><span
class="p">,</span> <span class="n">doc</span><span class="p">);</span>
-    <span class="k">if</span> <span class="p">(</span><span class="n">navigation2</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">selection</span>
<span class="o">=</span> <span class="p">(</span><span class="n">TextSelection</span><span
class="p">)</span> <span class="n">navigation2</span>
-                <span class="o">.</span><span class="n">nextSelection</span><span
class="p">();</span>
-        <span class="n">selection</span>
-                <span class="o">.</span><span class="n">addComment</span><span
class="p">(</span>
-                        <span class="s">&quot;This is a confidential document,
please don&#39;t redistribute.&quot;</span><span class="p">,</span>
-                        <span class="s">&quot;SecurityChecker&quot;</span><span
class="p">);</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;format_text.odt&quot;</span><span
class="p">);</span>
-<span class="sr">&lt;/pre&gt;</span>
+    <p><strong><a href="index.html">Demos</a> &gt; Automatically
Formatting a Document</strong><br />
+</p>
+<p><strong>Overview</strong><br />
+</p>
+<p>Simple API enhanced features to support document formatting in version 0.6.5. It
supplies methods for manipulating headings, page breaks, hyperlinks, comments, font and alignment.
This demo shows how to use these features to help document formatting.<br />
+</p>
+<p>It's a common scenario that we need apply some  styles to plain text to improve
its appearance. In this demo, a text document is created using plain text from a text file.
While reading content, paragraphs whose  length  is less than 20 characters are changed to
headings with a new font style. "Version" and "date" information is  set as right alignment
and gray text. Each line which matches an URL  will be applied as a hyperlink. Each heading
and its following paragraphs are considered as a chapter. There will be a page break after
page line count larger than a predefined value. Then verify word spelling and add comments
as tip to those which may have a spelling mistake. The last one is a security check. After
these processes, the plain text has been changed into a formatted document.<br />
+</p>
+<p>This picture shows part of the generated document. The new document looks orderly
and beautiful than before.</p>
+<p><img alt="alt text" src="image/demo10.png" /></p>
+<p><strong>Code Introduction</strong></p>
+<p>There code of this demo is very clear. Firstly, we open the data source and create
a text document. Secondly, we create paragraph for each line. Thirdly, we set different style
for different content. Then we do spell and security check with the help of Navigation API.
Comments are given if suspicious words are found.  Finally, the new created document is saved.<br
/>
+</p>
+<div class="codehilite"><pre>        <span class="n">BufferedReader</span>
<span class="n">reader</span> <span class="o">=</span> <span class="k">new</span>
<span class="n">BufferedReader</span><span class="p">(</span><span
class="k">new</span> <span class="n">InputStreamReader</span><span
class="p">(</span><span class="n">this</span><span class="o">.</span><span
class="n">class</span><span class="o">.</span><span class="n">getResourceAsStream</span><span
class="p">(</span><span class="s">&quot;text.txt&quot;</span><span
class="p">)));</span>
+        <span class="n">String</span> <span class="n">in</span> <span
class="o">=</span> <span class="n">reader</span><span class="o">.</span><span
class="n">readLine</span><span class="p">();</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">newTextDocument</span><span class="p">();</span>
+        <span class="nb">int</span> <span class="n">lineCount</span>
<span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+        <span class="nb">int</span> <span class="n">pageLineCount</span>
<span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+        <span class="n">Paragraph</span> <span class="n">refParagraph</span>
<span class="o">=</span> <span class="n">null</span><span class="p">;</span>
+        <span class="k">while</span> <span class="p">(</span><span
class="n">in</span> <span class="o">!=</span> <span class="n">null</span><span
class="p">)</span> <span class="p">{</span>
+            <span class="n">in</span> <span class="o">=</span> <span
class="n">in</span><span class="o">.</span><span class="n">trim</span><span
class="p">();</span>
+            <span class="n">Paragraph</span> <span class="n">paragraph</span>
<span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span
class="n">addParagraph</span><span class="p">(</span><span class="n">in</span><span
class="p">);</span>
+            <span class="n">lineCount</span><span class="o">++</span><span
class="p">;</span>
+            <span class="n">pageLineCount</span><span class="o">++</span><span
class="p">;</span>
+            <span class="n">switch</span> <span class="p">(</span><span
class="n">lineCount</span><span class="p">)</span> <span class="p">{</span>
+            <span class="k">case</span> <span class="mi">1</span><span
class="p">:</span>
+                <span class="n">paragraph</span>
+                        <span class="o">.</span><span class="n">setHorizontalAlignment</span><span
class="p">(</span><span class="n">HorizontalAlignmentType</span><span
class="o">.</span><span class="n">CENTER</span><span class="p">);</span>
+                <span class="n">paragraph</span><span class="o">.</span><span
class="n">setFont</span><span class="p">(</span><span class="k">new</span>
<span class="n">Font</span><span class="p">(</span><span class="s">&quot;Arial&quot;</span><span
class="p">,</span> <span class="n">FontStyle</span><span class="o">.</span><span
class="n">BOLD</span><span class="p">,</span> <span class="mi">16</span><span
class="p">));</span>
+                <span class="n">paragraph</span><span class="o">.</span><span
class="n">applyHeading</span><span class="p">();</span>
+                <span class="n">break</span><span class="p">;</span>
+            <span class="k">case</span> <span class="mi">2</span><span
class="p">:</span>
+            <span class="k">case</span> <span class="mi">3</span><span
class="p">:</span>
+                <span class="n">paragraph</span><span class="o">.</span><span
class="n">setHorizontalAlignment</span><span class="p">(</span><span
class="n">HorizontalAlignmentType</span><span class="o">.</span><span
class="n">RIGHT</span><span class="p">);</span>
+                <span class="n">paragraph</span><span class="o">.</span><span
class="n">setFont</span><span class="p">(</span><span class="k">new</span>
<span class="n">Font</span><span class="p">(</span><span class="s">&quot;Tahoma&quot;</span><span
class="p">,</span> <span class="n">FontStyle</span><span class="o">.</span><span
class="n">ITALIC</span><span class="p">,</span> <span class="mi">10</span><span
class="p">,</span>
+                        <span class="n">Color</span><span class="o">.</span><span
class="n">GRAY</span><span class="p">));</span>
+                <span class="n">break</span><span class="p">;</span>
+            <span class="n">default:</span>
+                <span class="k">if</span> <span class="p">(</span><span
class="n">in</span><span class="o">.</span><span class="n">startsWith</span><span
class="p">(</span><span class="s">&quot;http://&quot;</span><span
class="p">))</span> <span class="p">{</span>
+                    <span class="n">paragraph</span><span class="o">.</span><span
class="n">applyHyperlink</span><span class="p">(</span><span class="k">new</span>
<span class="n">URI</span><span class="p">(</span><span class="n">in</span><span
class="p">));</span>
+                <span class="p">}</span>
+                <span class="k">if</span> <span class="p">(</span><span
class="n">in</span><span class="o">.</span><span class="nb">length</span><span
class="p">()</span> <span class="o">&lt;</span> <span class="mi">20</span><span
class="p">)</span> <span class="p">{</span>
+                    <span class="n">paragraph</span><span class="o">.</span><span
class="n">applyHeading</span><span class="p">();</span>
+                    <span class="n">paragraph</span><span class="o">.</span><span
class="n">setFont</span><span class="p">(</span><span class="k">new</span>
<span class="n">Font</span><span class="p">(</span><span class="s">&quot;Arial&quot;</span><span
class="p">,</span> <span class="n">FontStyle</span><span class="o">.</span><span
class="n">BOLD</span><span class="p">,</span> <span class="mi">12</span><span
class="p">));</span>
+                    <span class="k">if</span> <span class="p">(</span><span
class="n">pageLineCount</span> <span class="o">&gt;</span> <span
class="mi">16</span><span class="p">)</span> <span class="p">{</span>
+                        <span class="n">doc</span><span class="o">.</span><span
class="n">addPageBreak</span><span class="p">(</span><span class="n">refParagraph</span><span
class="p">);</span>
+                        <span class="n">pageLineCount</span> <span class="o">=</span>
<span class="mi">0</span><span class="p">;</span>
+                    <span class="p">}</span>
+                <span class="p">}</span>
+            <span class="p">}</span>
+            <span class="n">refParagraph</span> <span class="o">=</span>
<span class="n">paragraph</span><span class="p">;</span>
+            <span class="n">in</span> <span class="o">=</span> <span
class="n">reader</span><span class="o">.</span><span class="n">readLine</span><span
class="p">();</span>
+
+        <span class="p">}</span>
+        <span class="sr">//</span> <span class="n">spell</span> <span
class="n">check</span>
+        <span class="n">TextNavigation</span> <span class="n">navigation1</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">TextNavigation</span><span
class="p">(</span><span class="s">&quot;lower-level&quot;</span><span
class="p">,</span> <span class="n">doc</span><span class="p">);</span>
+        <span class="k">while</span> <span class="p">(</span><span
class="n">navigation1</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">selection</span>
<span class="o">=</span> <span class="p">(</span><span class="n">TextSelection</span><span
class="p">)</span> <span class="n">navigation1</span>
+                    <span class="o">.</span><span class="n">nextSelection</span><span
class="p">();</span>
+            <span class="n">selection</span><span class="o">.</span><span
class="n">addComment</span><span class="p">(</span>
+                    <span class="s">&quot;Please change &#39;lower-level&#39;
with &#39;lower level&#39;.&quot;</span><span class="p">,</span>
+                    <span class="s">&quot;SpellChecker&quot;</span><span
class="p">);</span>
+        <span class="p">}</span>
+        <span class="sr">//</span> <span class="n">security</span>
<span class="n">check</span>
+        <span class="n">TextNavigation</span> <span class="n">navigation2</span>
<span class="o">=</span> <span class="k">new</span> <span class="n">TextNavigation</span><span
class="p">(</span><span class="s">&quot;confidential&quot;</span><span
class="p">,</span> <span class="n">doc</span><span class="p">);</span>
+        <span class="k">if</span> <span class="p">(</span><span
class="n">navigation2</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">selection</span>
<span class="o">=</span> <span class="p">(</span><span class="n">TextSelection</span><span
class="p">)</span> <span class="n">navigation2</span>
+                    <span class="o">.</span><span class="n">nextSelection</span><span
class="p">();</span>
+            <span class="n">selection</span>
+                    <span class="o">.</span><span class="n">addComment</span><span
class="p">(</span>
+                            <span class="s">&quot;This is a confidential document,
please don&#39;t redistribute.&quot;</span><span class="p">,</span>
+                            <span class="s">&quot;SecurityChecker&quot;</span><span
class="p">);</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;format_text.odt&quot;</span><span
class="p">);</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.6.5</a>.
-  </p>
-  <p>
-    You can download the code of this demo from <a href="demo10.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></p>
+<p>Powered by the Simple Java API for ODF version <a href="../downloads.html">0.6.5</a>.<br
/>
+You can download the code of this demo from <a href="demo10.zip">here</a>.</p>
   </div>
 
   <div id="footera">



Mime
View raw message