incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1165478 [2/3] - in /incubator/odf/site/trunk/content/odftoolkit/simple: ./ demo/scripts/ demo/styles/ document/ document/cookbook/ document/javadoc/ javadoc/
Date Tue, 06 Sep 2011 02:09:28 GMT
Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Presentation.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate%20Presentation.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Presentation.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Presentation.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,98 @@
+<!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" />
+<title>Manipulate Presentation</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+</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="../samples.html" class="sample"> </a> </div>
+</div>
+<div id="subcontent" align ="left">
+<div align="left" class="titletext"> <span >
+<a href="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Manipulate Presentation.html">Manipulate Presentation</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Text Document.html">previous</a></li>
+  <li><a href="Manipulate Slide.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Create Presentation Document">
+<br/>
+<a href="#Create Presentation Document" >Create Presentation Document</a>
+<hr/>
+</div>
+<div class="bodytext">
+Let's create an empty presentation document first. The following codes generates an empty presentation document with one slide:
+</div>
+<br/><pre class='code' id="code0">
+		    <span class='javaclass'>PresentationDocument</span> document=<span class='javaclass'>PresentationDocument</span>.newPresentationDocument();	 <br/>
+		    document.save(filePath);<br/>
+</pre>
+<br/><div class="bodytext">
+We can also create a presentation template document by using the following codes. The operation of the template document is the same with the normal presentation document.
+</div>
+<br/><pre class='code' id="code1">
+                    <span class='javaclass'>PresentationDocument</span> documentTmp=<span class='javaclass'>PresentationDocument</span>.newPresentationTemplateDocument();			    <br/>
+</pre>
+<br/><div class="contenttitle" id="Get Presentation Document">
+<br/>
+<a href="#Get Presentation Document" >Get Presentation Document</a>
+<hr/>
+</div>
+<div class="bodytext">
+We can get the existing presentation Document by using the loadDocument function like follows: 
+</div>
+<div class="bodytext">
+Here presentation.odp is the name of the existing presentation document.
+</div>
+<div class="bodytext">
+Also we can append all the slides of the specified presentation document to the current document by using the following codes:
+</div>
+<div class="bodytext">
+Here the slides of the documents "presentation.odp" will be appended to "document".
+</div>
+<br/><pre class='code' id="code2">
+		    <span class='javaclass'>PresentationDocument</span> presentationmodel;<br/>
+		    presentationmodel=(<span class='javaclass'>PresentationDocument</span>)<span class='javaclass'>PresentationDocument</span>.loadDocument("presentation.odp");<br/>
+	            document.appendPresentation(presentationmodel);	       <br/>
+</pre>
+<br/><div class="contenttitle" id="Change Presentation Mode">
+<br/>
+<a href="#Change Presentation Mode" >Change Presentation Mode</a>
+<hr/>
+</div>
+<div class="bodytext">
+We can switch the mode presentation documents by using the following codes. Here the first one convert the presentation document to a template, and the second one convert the template to a normal presentation document.
+</div>
+<br/><pre class='code' id="code3">
+		    document.changeMode(<span class='javaclass'>OdfMediaType</span>.PRESENTATION_TEMPLATE);	<br/>
+		    documentTmp.changeMode(<span class='javaclass'>OdfMediaType</span>.<span class='javaclass'>PRESENTATION</span>);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Text Document.html">previous</a></li>
+  <li><a href="Manipulate Slide.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="#">About Us</a> | <a href="#">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Slide.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate%20Slide.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Slide.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Slide.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,202 @@
+<!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" />
+<title>Manipulate Slide</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+</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="../samples.html" class="sample"> </a> </div>
+</div>
+<div id="subcontent" align ="left">
+<div align="left" class="titletext"> <span >
+<a href="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Manipulate Slide.html">Manipulate Slide</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Presentation.html">previous</a></li>
+  <li><a href="Manipulate Table.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Add Slide">
+<br/>
+<a href="#Add Slide" >Add Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+If you want to add new slide to the presentation document, you can use the following codes:
+</div>
+<div class="bodytext">
+Here the SlideLayout is the layout model of the added slide, the first parameter is the index of the added slide and the second parameter is the name of this slide.
+</div>
+<br/><pre class='code' id="code0">
+                <span class='javaclass'>PresentationDocument</span> document=<span class='javaclass'>PresentationDocument</span>.newPresentationDocument();	        			<br/>
+		document.newSlide(1, "new slide", <span class='javaclass'>SlideLayout</span>.TITLE_ONLY);<br/>
+</pre>
+<br/><div class="contenttitle" id="Get Slide">
+<br/>
+<a href="#Get Slide" >Get Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+You can get the slide through the index in the presentation document, like follows:
+</div>
+<br/><pre class='code' id="code1">
+		<span class='javaclass'>Slide</span> slide;<br/>
+		slide=document.getSlideByIndex(0);<br/>
+</pre>
+<br/><div class="bodytext">
+Or you can get the slide through the name of it by using the following code:
+</div>
+<br/><pre class='code' id="code2">
+		slide=document.getSlideByName("new slide");<br/>
+</pre>
+<br/><div class="bodytext">
+To get all the slides in the document,you can do like this:
+</div>
+<br/><pre class='code' id="code3">
+		<span class='javaclass'>Iterator</span>&lt;<span class='javaclass'>Slide</span>&gt; slideList=document.getSlides();<br/>
+</pre>
+<br/><div class="bodytext">
+Also you can get the number of the slides in the document by the following code:
+</div>
+<br/><pre class='code' id="code4">
+		<span class='basic'>int</span> numSlide=document.getSlideCount();<br/>
+</pre>
+<br/><div class="contenttitle" id="Set/Get Slide Name/Index">
+<br/>
+<a href="#Set/Get Slide Name/Index" >Set/Get Slide Name/Index</a>
+<hr/>
+</div>
+<div class="bodytext">
+If you want to set a new name for a slide, you can use the following two methods:
+</div>
+<br/><pre class='code' id="code5">
+		slide.setSlideName("second slide");	<br/>
+		document.getSlideByIndex(2).setSlideName("third slide");<br/>
+</pre>
+<br/><div class="bodytext">
+If you want to know the index and the name of one slide which is being operated, you can use the following codes:
+</div>
+<br/><pre class='code' id="code6">
+		<span class='basic'>int</span> slideIndex=slide.getSlideIndex();<br/>
+		<span class='javaclass'>String</span> slideName=slide.getSlideName();<br/>
+</pre>
+<br/><div class="contenttitle" id="Copy Slide">
+<br/>
+<a href="#Copy Slide" >Copy Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+You can copy a slide in the presentation document from one position to another by using the following codes:
+</div>
+<div class="bodytext">
+Here the first parameter is the source position of the slide need to be copied, the second parameter is the destination position of the slide need to be copied, and the last parameter is the new name of the copied slide. 
+</div>
+<br/><pre class='code' id="code7">
+		document.copySlide(1, 2, "copied slide");<br/>
+</pre>
+<br/><div class="bodytext">
+And also you can copy a slide from another document by using the following codes:
+</div>
+<div class="bodytext">
+Here the first parameter of copyForeignSlide is the new position of the copied slide in the current document, the second parameter is the source document of the copied slide, and the last one is the slide index of the source document that need to be copied.
+</div>
+<br/><pre class='code' id="code8">
+		 <span class='javaclass'>PresentationDocument</span> documentmodel;<br/>
+		 documentmodel=(<span class='javaclass'>PresentationDocument</span>)<span class='javaclass'>PresentationDocument</span>.loadDocument("presentation.odp");<br/>
+		 document.copyForeignSlide(1, documentmodel, 2);<br/>
+</pre>
+<br/><div class="contenttitle" id="Move/Delete Slide">
+<br/>
+<a href="#Move/Delete Slide" >Move/Delete Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+To move one slide to another position of this presentation position, you can use the following codes:
+</div>
+<div class="bodytext">
+Here the first parameter is the current index of the slide that need to be moved, and the second parameter is the index of the destination position before the move action.
+</div>
+<br/><pre class='code' id="code9">
+		document.moveSlide(2, 1);		<br/>
+</pre>
+<br/><div class="bodytext">
+You can delete the slide either by through the index or through the name of the specified slide, like follows:
+</div>
+<br/><pre class='code' id="code10">
+		document.deleteSlideByIndex(1);<br/>
+		document.deleteSlideByName("third slide");<br/>
+</pre>
+<br/><div class="contenttitle" id="Add Text to Slide">
+<br/>
+<a href="#Add Text to Slide" >Add Text to Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+	  You can set the text content of a slide with text box API since version 0.5.	  Below codes will get the title text box of a slide, set the text content,	  and then get the outline text box, set the list content.
+</div>
+<br/><pre class='code' id="code11">
+	    <span class='javaclass'>Textbox</span> titleBox = slide.getTextboxByUsage(<span class='javaclass'>PresentationClass</span>.<span class='javaclass'>TITLE</span>).get(0);<br/>
+	    titleBox.setTextContent("<span class='javaclass'>This</span> is the title");<br/>
+	    <span class='javaclass'>Textbox</span> outline = slide.getTextboxByUsage(<span class='javaclass'>PresentationClass</span>.<span class='javaclass'>OUTLINE</span>).get(0);<br/>
+	    <span class='javaclass'>List</span> txtList = outline.addList();<br/>
+	    txtList.addItem("<span class='javaclass'>List</span> Item1");<br/>
+	    txtList.addItem("<span class='javaclass'>List</span> Item2");<br/>
+</pre>
+<br/><div class="bodytext">
+To add some text, you can first get the notes of one slide and then add text to this corresponding notes. The following codes shows this process:
+</div>
+<br/><pre class='code' id="code12">
+		<span class='javaclass'>Notes</span> note=slide.getNotesPage();<br/>
+		note.addText("text notes");<br/>
+</pre>
+<br/><div class="contenttitle" id="Add Image to Slide">
+<br/>
+<a href="#Add Image to Slide" >Add Image to Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+To add an image to slide, you can use below codes to simply add the image to the last slide of the presentation document.
+</div>
+<br/><pre class='code' id="code13">
+		<span class='javaclass'>URI</span> imageuri=<span class='modifier'>new</span> <span class='javaclass'>URI</span>("namdaemun.jpg");<br/>
+		document.newImage(imageuri);<br/>
+</pre>
+<br/><div class="bodytext">
+Or you can use following code to add an image to a specific position you want
+</div>
+<br/><pre class='code' id="code14">
+		<span class='javaclass'>Slide</span> slide1 = document.getSlideByIndex(1);<br/>
+		<span class='javaclass'>Image</span> image = <span class='javaclass'>Image</span>.newImage(slide1, <span class='modifier'>new</span> <span class='javaclass'>URI</span>("http://www.xxx.com/a.jpg"));<br/>
+		<span class='javaclass'>FrameRectangle</span> rect = image.getRectangle();<br/>
+		rect.setX(4);<br/>
+		rect.setY(5.7);<br/>
+		image.setRectangle(rect);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Presentation.html">previous</a></li>
+  <li><a href="Manipulate Table.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="#">About Us</a> | <a href="#">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Table.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate%20Table.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Table.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Table.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,154 @@
+<!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" />
+<title>Manipulate Table</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+</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="../samples.html" class="sample"> </a> </div>
+</div>
+<div id="subcontent" align ="left">
+<div align="left" class="titletext"> <span >
+<a href="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Manipulate Table.html">Manipulate Table</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Slide.html">previous</a></li>
+  <li><a href="Manipulate Columns and Rows.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Overview">
+<br/>
+<a href="#Overview" >Overview</a>
+<hr/>
+</div>
+<div class="bodytext">
+ This <a href="">Table</a> API supports to manipulate tables in text and spreadsheet documents. It covers the table definition in <a href="http:docs.oasis-open.org/office/v1.2/cd05/OpenDocument-v1.2-cd05-part1.html#a_9_Tables">ODF Specification 1.2 Committee Draft05</a>
+</div>
+<div class="contenttitle" id="Create Table">
+<br/>
+<a href="#Create Table" >Create Table</a>
+<hr/>
+</div>
+<div class="bodytext">
+Let's create an empty table first.By default,the code below create a table with 5 columns and 2 rows.
+</div>
+<br/><pre class='code' id="code0">
+            <span class='javaclass'>TextDocument</span> document = <span class='javaclass'>TextDocument</span>.newTextDocument();<br/>
+            <span class='javaclass'>Table</span> table1 = <span class='javaclass'>Table</span>.newTable(document);<br/>
+            table1.setTableName("table1");<br/>
+            document.save(filePath);<br/>
+</pre>
+<br/><div class="bodytext">
+If you want to create table with specified column and row,you can do like this:
+</div>
+<br/><pre class='code' id="code1">
+            <span class='basic'>int</span> row=4;<br/>
+            <span class='basic'>int</span> column=3;<br/>
+            <span class='javaclass'>Table</span> table2=<span class='javaclass'>Table</span>.newTable(document, row, column);<br/>
+            table2.setTableName("table2");<br/>
+</pre>
+<br/><div class="bodytext">
+       If you want to put some numbers into a table while creating it, you can use the constructor Table.newTable(document,rowlabels,columnlabels, data)       which you should specify a 2 dimension array as the data and 2 String arrays as table labels,one for row and the other for column. 
+</div>
+<br/><pre class='code' id="code2">
+        <span class='basic'>int</span> rowcount = 10, columncount = 4;<br/>
+     	<span class='basic'>double</span>[][] data = <span class='modifier'>new</span> <span class='basic'>double</span>[rowcount][columncount];	<br/>
+     	<span class='javaclass'>String</span>[] rowlabels = <span class='modifier'>new</span> <span class='javaclass'>String</span>[rowcount];<br/>
+     	<span class='javaclass'>String</span>[] columnlabels = <span class='modifier'>new</span> <span class='javaclass'>String</span>[columncount];<br/>
+     	<span class='javaclass'>Table</span> table3=<span class='javaclass'>Table</span>.newTable(document,rowlabels,columnlabels, data);<br/>
+     	table3.setTableName("dataTable");<br/>
+</pre>
+<br/><div class="bodytext">
+You can also fill table with string values while creating it, to do this you should provide a 2 dimension string array instead of double array.
+</div>
+<br/><pre class='code' id="code3">
+     	<span class='javaclass'>String</span>[][] stringData = <span class='modifier'>new</span> <span class='javaclass'>String</span>[rowcount][columncount];<br/>
+     	<span class='javaclass'>Table</span> table4 = <span class='javaclass'>Table</span>.newTable(document, rowlabels, columnlabels, stringData);<br/>
+     	table4.setTableName("stringTable");<br/>
+</pre>
+<br/><div class="contenttitle" id="Find Table">
+<br/>
+<a href="#Find Table" >Find Table</a>
+<hr/>
+</div>
+<div class="bodytext">
+To get all the tables in the document,you can do like this:
+</div>
+<br/><pre class='code' id="code4">
+        <span class='javaclass'>List</span>&lt;<span class='javaclass'>Table</span>&gt; tableList=document.getTableList();<br/>
+</pre>
+<br/><div class="bodytext">
+If you want to get a single table,you can use the table name to find it.If it's not found,the method returns null.
+</div>
+<br/><pre class='code' id="code5">
+        <span class='javaclass'>Table</span> emptyTable=document.getTableByName("table1");<br/>
+</pre>
+<br/><div class="contenttitle" id="Delete Table">
+<br/>
+<a href="#Delete Table" >Delete Table</a>
+<hr/>
+</div>
+<br/><pre class='code' id="code6">
+        <span class='javaclass'>Table</span> table = document.getTableByName("<span class='javaclass'>DeletedTable</span>");<br/>
+        <span class='control'>if</span> (table != <span class='basic'>null</span>) {<br/>
+     	table.remove();<br/>
+        }<br/>
+</pre>
+<br/><div class="contenttitle" id="Set Table">
+<br/>
+<a href="#Set Table" >Set Table</a>
+<hr/>
+</div>
+<div class="bodytext">
+You can set or update table name,which can be regarded as table identifier in a document.
+</div>
+<br/><pre class='code' id="code7">
+           table1.getTableName();<br/>
+           table1.setTableName("<span class='javaclass'>EnglishScore</span>");<br/>
+</pre>
+<br/><div class="bodytext">
+If you want to change table width,you can do like this:
+</div>
+<br/><pre class='code' id="code8">
+        <span class='javaclass'>Table</span> tableWidth=document.getTableByName("table1");<br/>
+        <span class='control'>if</span>(tableWidth!=<span class='basic'>null</span>) {<br/>
+            <span class='basic'>long</span> width=500;<br/>
+            tableWidth.setWidth(width);<br/>
+            tableWidth.getWidth();<br/>
+        }<br/>
+</pre>
+<br/><div class="bodytext">
+Each table in the document has a protect attribute to show whether it is protected or not.
+</div>
+<br/><pre class='code' id="code9">
+           <span class='basic'>boolean</span> isProtected=table1.isProtected();<br/>
+           table1.setProtected(<span class='basic'>true</span>);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Slide.html">previous</a></li>
+  <li><a href="Manipulate Columns and Rows.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="#">About Us</a> | <a href="#">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Text Document.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate%20Text%20Document.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Text Document.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate Text Document.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,433 @@
+<!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" />
+<title>Manipulate Text Document</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+</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="../samples.html" class="sample"> </a> </div>
+</div>
+<div id="subcontent" align ="left">
+<div align="left" class="titletext"> <span >
+<a href="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Manipulate Text Document.html">Manipulate Text Document</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Metadata.html">previous</a></li>
+  <li><a href="Manipulate Presentation.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Overview">
+<br/>
+<a href="#Overview" >Overview</a>
+<hr/>
+</div>
+<div class="bodytext">
+Till now, we support high level APIs to manipulate text document, paragraph, section and list.
+</div>
+<div class="contenttitle" id="Generate TextDocument">
+<br/>
+<a href="#Generate TextDocument" >Generate TextDocument</a>
+<hr/>
+</div>
+<div class="bodytext">
+		There are typically four kinds of Text Documents with different modes can be generated: text document,		master document, template document and web document.
+</div>
+<div class="bodytext">
+The following codes generates an empty text document.
+</div>
+<br/><pre class='code' id="code0">
+            <span class='javaclass'>TextDocument</span> document1=<span class='javaclass'>TextDocument</span>.newTextDocument();	 <br/>
+	    document1.save(filePath);<br/>
+</pre>
+<br/><div class="bodytext">
+	    There are two methods to generate a new document, one with a parameter of	    OdfMediaType, and the other one just use the corresponding new function.
+</div>
+<div class="bodytext">
+	    The following two lines of codes generate the same kinds of document(Master document). 	    The other three kinds of document are similar.
+</div>
+<br/><pre class='code' id="code1">
+	    <span class='javaclass'>TextDocument</span> documentMedia1=<span class='javaclass'>TextDocument</span>.newTextDocument(<span class='javaclass'>OdfMediaType</span>.TEXT_MASTER);<br/>
+	    <span class='javaclass'>TextDocument</span> documentMedia2=<span class='javaclass'>TextDocument</span>.newTextMasterDocument();<br/>
+</pre>
+<br/><div class="contenttitle" id="Get TextDocument">
+<br/>
+<a href="#Get TextDocument" >Get TextDocument</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    We can get the existing Text Document by using the loadDocument function like follows.	    The loadDocument function has four kinds of parameters: File, InputStream, OdfPackageDocument and	    String. Here the one with string parameter is used as an example.
+</div>
+<br/><pre class='code' id="code2">
+	    <span class='javaclass'>TextDocument</span> document2=(<span class='javaclass'>TextDocument</span>)<span class='javaclass'>TextDocument</span>.loadDocument("textdocument.odt");<br/>
+</pre>
+<br/><div class="bodytext">
+Also we can change the mode of one text document by using the following codes:
+</div>
+<br/><pre class='code' id="code3">
+	    document2.changeMode(<span class='javaclass'>OdfMediaType</span>.TEXT_WEB);<br/>
+</pre>
+<br/><div class="contenttitle" id="Manipulate Paragraph">
+<br/>
+<a href="#Manipulate Paragraph" >Manipulate Paragraph</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    To add a new paragraph to a text document, the following codes can be used,	    the first one add an empty paragraph to the end of the document, and the second one	    add a new paragraph with the corresponding texts to the document.
+</div>
+<br/><pre class='code' id="code4">
+	    document1.addParagraph(<span class='basic'>null</span>);<br/>
+	    document1.addParagraph("test newParagraph function in textDocument");<br/>
+</pre>
+<br/><div class="bodytext">
+	    The first one will get the second paragraph of this document. The second statement will get the last paragraph with text content. 	    The paragraph without text content will be ignored if the second parameter is true.
+</div>
+<div class="bodytext">
+The following codes can be used to append text to the end of a paragrah.
+</div>
+<br/><pre class='code' id="code5">
+	    para1.appendTextContent("test addText function in textDocument");<br/>
+</pre>
+<br/><div class="bodytext">
+The following code is to set the horizontal alignment of a paragraph.
+</div>
+<br/><pre class='code' id="code6">
+	    para1.getStyleHandler().getParagraphPropertiesForWrite().setHorizontalAlignment(<span class='javaclass'>HorizontalAlignmentType</span>.<span class='javaclass'>CENTER</span>);<br/>
+</pre>
+<br/><div class="contenttitle" id="Manipulate Section">
+<br/>
+<a href="#Manipulate Section" >Manipulate Section</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    From version 0.4, we support high level APIs for section. 	    You can use the following code to get a section by name:
+</div>
+<br/><pre class='code' id="code7">
+		<span class='javaclass'>Section</span> aSection = document1.getSectionByName("<span class='javaclass'>ImageSection</span>");<br/>
+</pre>
+<br/><div class="bodytext">
+		or use the following code to get an iterator of sections. 		All sections in the document would be returned, including sections in footer and header.
+</div>
+<br/><pre class='code' id="code8">
+		<span class='javaclass'>Iterator</span>&lt;<span class='javaclass'>Section</span>&gt; sections = document1.getSectionIterator();<br/>
+		<span class='control'>while</span> (sections.hasNext()) {<br/>
+			<span class='javaclass'>Section</span> theSection = sections.next();<br/>
+		}<br/>
+</pre>
+<br/><div class="bodytext">
+		After you get the object of section, 		you can use the following codes to set and get the name of the section.
+</div>
+<br/><pre class='code' id="code9">
+		<span class='javaclass'>String</span> name = aSection.getName();<br/>
+		aSection.setName("<span class='javaclass'>NewName</span>");<br/>
+</pre>
+<br/><div class="bodytext">
+		You can use the following code to copy and append a section at the end of a document.		Copying from a foreign document is supported. 		You don't need to care whether or not the document is the owner of the source section.
+</div>
+<br/><pre class='code' id="code10">
+		document1.appendSection(aSection, <span class='basic'>true</span>);<br/>
+</pre>
+<br/><div class="bodytext">
+		If you want to copy and append a section within a same document,		you can specify with the second parameter of "copyAppendSection(Section section, boolean isResourceCopied)"		whether the linked resources to this section are copied or not.		The following code means to copy a section and append it at the end, but the linked resources are shared between the source section and the copied section.
+</div>
+<br/><pre class='code' id="code11">
+		document1.appendSection(aSection, <span class='basic'>false</span>);<br/>
+</pre>
+<br/><div class="bodytext">
+		You can remove this Section from the document content, 		all the resources that are only linked with this section would be removed too.
+</div>
+<br/><pre class='code' id="code12">
+		aSection.remove();<br/>
+</pre>
+<br/><div class="contenttitle" id="Manipulate List">
+<br/>
+<a href="#Manipulate List" >Manipulate List</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    From version 0.4, we support high level APIs for list.		You can use the following code to create a list. The two methods are same.
+</div>
+<br/><pre class='code' id="code13">
+		<span class='javaclass'>List</span> newList1 = document1.addList();<br/>
+		<span class='javaclass'>List</span> newList2 = <span class='modifier'>new</span> <span class='javaclass'>List</span>(document1);<br/>
+</pre>
+<br/><div class="bodytext">
+	    Actually, you can append list to table cell, list item, presentation slide and notes. They all have the same ability with text document for list.		We call them ListContainer, which can append, remove and get the iterator of list.
+</div>
+<br/><pre class='code' id="code14">
+		<span class='javaclass'>Iterator</span>&lt;<span class='javaclass'>List</span>&gt; lists = document1.getListIterator();<br/>
+		<span class='javaclass'>List</span> list =<span class='basic'>null</span>;<br/>
+		<span class='control'>while</span> (lists.hasNext()) {<br/>
+			list = lists.next();<br/>
+		}<br/>
+</pre>
+<br/><div class="bodytext">
+		After you get the object of list, 		you can use the following methods to set and get the header of the list.
+</div>
+<br/><pre class='code' id="code15">
+		<span class='javaclass'>String</span> header = list.getHeader();<br/>
+		list.setHeader("<span class='javaclass'>NewHeader</span>");<br/>
+</pre>
+<br/><div class="bodytext">
+		You can get all of the existing items in this list. They are returned as java.util.List.
+</div>
+<br/><pre class='code' id="code16">
+		java.util.<span class='javaclass'>List</span>&lt;<span class='javaclass'>ListItem</span>&gt; items = list.getItems();<br/>
+</pre>
+<br/><div class="bodytext">
+		If you only want to get the item at a specific location, you can use the following code:
+</div>
+<br/><pre class='code' id="code17">
+		<span class='basic'>int</span> location = 2;<br/>
+		<span class='javaclass'>ListItem</span> item = list.getItem(location);<br/>
+</pre>
+<br/><div class="bodytext">
+		There are several ways to help you append item(s) to the list. Please reference the following code:
+</div>
+<br/><pre class='code' id="code18">
+<span class='comments'>		// add single item</span>
+		<span class='javaclass'>ListItem</span> newItem1 = list.addItem(item);<br/>
+		<span class='javaclass'>ListItem</span> newItem2 = list.addItem("itemContent");<br/>
+<span class='comments'>		// add clone items</span>
+		<span class='javaclass'>ListItem</span>[] newItems = <span class='modifier'>new</span> <span class='javaclass'>ListItem</span>[]{newItem1, newItem2};<br/>
+		list.addItems(newItems);<br/>
+<span class='comments'>		// add string items</span>
+		<span class='javaclass'>String</span>[] newItemContents = <span class='modifier'>new</span> <span class='javaclass'>String</span>[]{"itemContent1", "itemContent2"};<br/>
+		list.addItems(newItemContents);<br/>
+</pre>
+<br/><div class="bodytext">
+		You can specify a location to insert new item(s).
+</div>
+<br/><pre class='code' id="code19">
+		newItem1 = list.addItem(location, item);<br/>
+		newItem2 = list.addItem(location, "itemContent");<br/>
+		list.addItems(location, newItems);<br/>
+		list.addItems(location, newItemContents);<br/>
+</pre>
+<br/><div class="bodytext">
+		If you want to replace a list item with a new one, you can use the following code.
+</div>
+<br/><pre class='code' id="code20">
+		item = list.set(location, newItem1);<br/>
+		item = list.set(location, "itemContent");<br/>
+</pre>
+<br/><div class="bodytext">
+		You can use the following methods to remove item(s).
+</div>
+<br/><pre class='code' id="code21">
+		list.removeItem(item);<br/>
+<span class='comments'>		//item in specific location.</span>
+		list.removeItem(location);<br/>
+<span class='comments'>		//item in specific collection.</span>
+		list.removeItems(items);<br/>
+</pre>
+<br/><div class="bodytext">
+		You can specify with the following methods whether the numbering of the previous list is continued by this list:
+</div>
+<br/><pre class='code' id="code22">
+<span class='comments'>		// the numbering of the proximate list is continued</span>
+		newList1.setContinueNumbering(<span class='basic'>true</span>);<br/>
+<span class='comments'>		// the numbering of the specified list is continued by this list</span>
+		newList2.setContinueList(list);<br/>
+</pre>
+<br/><div class="bodytext">
+		You can use the following method to know whether the list is a number list.
+</div>
+<br/><pre class='code' id="code23">
+		<span class='javaclass'>ListType</span> type = list.getType();<br/>
+</pre>
+<br/><div class="bodytext">
+		Now, List API support 3 types of lists, ListType.BULLET, ListType.NUMBER and ListType.IMAGE. The default created 		list is ListType.BULLET, bullet list.		How to create a number list or a image list then?		ListDecorator has powerful functions that can help you. ListDecorator is an interface 		which decides how to decorate a list and its list items. We supply 4 implementations of this interface, 		BulletDecorator, NumberDecorator, ImageDecorator and OutlineDecorator.
+</div>
+<br/><pre class='code' id="code24">
+<span class='comments'>		// create a number list.</span>
+		<span class='javaclass'>ListDecorator</span> numberDecorator = <span class='modifier'>new</span> <span class='javaclass'>NumberDecorator</span>(document1);<br/>
+		<span class='javaclass'>List</span> numberList1 = document1.addList(numberDecorator);<br/>
+		<span class='javaclass'>List</span> numberList2 = <span class='modifier'>new</span> <span class='javaclass'>List</span>(document1, numberDecorator);<br/>
+</pre>
+<br/><div class="bodytext">
+		You can implement your own ListDecorator as need, or extend the default four implementations.
+</div>
+<div class="bodytext">
+		You can remove a list from the document, the following two methods are same.
+</div>
+<br/><pre class='code' id="code25">
+		list.remove();<br/>
+		document1.removeList(list);<br/>
+</pre>
+<br/><div class="bodytext">
+		We also provide funtions to manipulate list items.		You can use the following methods to get and set the text content of a item.
+</div>
+<br/><pre class='code' id="code26">
+		<span class='javaclass'>String</span> itemContent = item.getTextContent();<br/>
+		item.setTextContent("new item content");<br/>
+</pre>
+<br/><div class="bodytext">
+		You can get the item index and its owner list.
+</div>
+<br/><pre class='code' id="code27">
+		<span class='basic'>int</span> index = item.getIndex();<br/>
+		<span class='javaclass'>List</span> ownerList = item.getOwnerList();<br/>
+</pre>
+<br/><div class="bodytext">
+		When you want to remove an item, besides List.removeItem(ListItem), you can use the following method directly.
+</div>
+<br/><pre class='code' id="code28">
+		item.remove();<br/>
+</pre>
+<br/><div class="bodytext">
+		With the help of the following code, the start number of list item can be set.
+</div>
+<br/><pre class='code' id="code29">
+		item.setStartNumber(3);<br/>
+</pre>
+<br/><div class="bodytext">
+		Since list item is also a ListContainer, you can add sub list to an item.
+</div>
+<br/><pre class='code' id="code30">
+		item.addList();<br/>
+</pre>
+<br/><div class="contenttitle" id="Footer and header">
+<br/>
+<a href="#Footer and header" >Footer and header</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    From version 0.4.5, we support high level APIs for footer and header.		You can use the following code to get the header and footer. 
+</div>
+<br/><pre class='code' id="code31">
+		<span class='javaclass'>Header</span> docHeader = doc.getHeader();<br/>
+		<span class='javaclass'>Footer</span> footer = doc.getFooter();<br/>
+</pre>
+<br/><div class="bodytext">
+	    In order to add contents to header and arrange these contents in a good layout,		I suggest you to use table.		It's easy to add a none-border table to header.		Below codes show how to add a table with 2 columns and 1 row to header, and then 		add some text content to the left cell, and add an image to the right cell.
+</div>
+<br/><pre class='code' id="code32">
+		<span class='javaclass'>Table</span> table = docHeader.addTable(1,2);<br/>
+		table.getCellByPosition(0, 0).setStringValue("header table cell");<br/>
+		<span class='javaclass'>Cell</span> cell = table.getCellByPosition(1, 0);<br/>
+		<span class='javaclass'>Image</span> image1 = cell.setImage(<span class='modifier'>new</span> <span class='javaclass'>URI</span>("file:/c:/image.jpg"));<br/>
+</pre>
+<br/><div class="bodytext">
+	    Below codes show how to add a table with 1 column and 1 row to footer, and then 		add some text content to the cell.		You can easily set the style of these text content. The codes describe how to put		the text content in the center, set the font of the text content, 		and set the background of the cell.
+</div>
+<br/><pre class='code' id="code33">
+		table = footer.addTable(1, 1);<br/>
+		<span class='javaclass'>Cell</span> cellByPosition = table.getCellByPosition(0, 0);<br/>
+		cellByPosition.setStringValue("footer table cell");<br/>
+		cellByPosition.setHorizontalAlignment(<span class='javaclass'>HorizontalAlignmentType</span>.<span class='javaclass'>CENTER</span>);<br/>
+		<span class='javaclass'>Font</span> myFont = <span class='modifier'>new</span> <span class='javaclass'>Font</span>("<span class='javaclass'>Arial</span>", <span class='javaclass'>StyleTypeDefinitions</span>.<span class='javaclass'>FontStyle</span>.<span class='javaclass'>ITALIC</span>, 12, <span class='javaclass'>Color</span>.<span class='javaclass'>BLUE</span>);<br/>
+		cellByPosition.setFont(myFont);<br/>
+		cellByPosition.setCellBackgroundColor(<span class='javaclass'>Color</span>.<span class='javaclass'>YELLOW</span>);<br/>
+</pre>
+<br/><div class="contenttitle" id="Textbox">
+<br/>
+<a href="#Textbox" >Textbox</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    From version 0.5, we support high level APIs for text box.		Below codes will create a text box and add it to the text 		document with a paragraph as the anchor position.		The FrameRectangle specifies an area and the position of this text box.
+</div>
+<br/><pre class='code' id="code34">
+		<span class='javaclass'>Paragraph</span> paragraph = doc.getParagraphByIndex(0, <span class='basic'>false</span>);<br/>
+		<span class='javaclass'>Textbox</span> box = paragraph.addTextbox(<span class='modifier'>new</span> <span class='javaclass'>FrameRectangle</span>(1,1,2,1,<span class='javaclass'>SupportedLinearMeasure</span>.<span class='javaclass'>IN</span>));<br/>
+</pre>
+<br/><div class="bodytext">
+		Below codes is to set the text content and name of this text box; 
+</div>
+<br/><pre class='code' id="code35">
+		box.setTextContent("this is a text box");<br/>
+		box.setName("<span class='javaclass'>MyTextbox</span>");<br/>
+</pre>
+<br/><div class="bodytext">
+		Below codes is to get a text box by name or get an iterator of text box contained by a paragraph. 
+</div>
+<br/><pre class='code' id="code36">
+		<span class='javaclass'>Textbox</span> myBox=paragraph.getTextboxByName("<span class='javaclass'>MyTextbox</span>");<br/>
+		<span class='javaclass'>Iterator</span>&lt;<span class='javaclass'>Textbox</span>&gt; boxIter = paragraph.getTextboxIterator();<br/>
+</pre>
+<br/><div class="bodytext">
+		Below code is to set the background color of a text box. 
+</div>
+<br/><pre class='code' id="code37">
+		myBox.setBackgroundColor(<span class='javaclass'>Color</span>.<span class='javaclass'>BLUE</span>);<br/>
+</pre>
+<br/><div class="bodytext">
+		Below code is to remove a text box; 
+</div>
+<br/><pre class='code' id="code38">
+		paragraph.removeTextbox(myBox);<br/>
+</pre>
+<br/><div class="contenttitle" id="Image">
+<br/>
+<a href="#Image" >Image</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    From version 0.5.5, we support high level APIs for images.		Below codes will create a image and add it to a document with a paragraph as the anchor position.
+</div>
+<br/><pre class='code' id="code39">
+		<span class='javaclass'>Paragraph</span> para = doc.getParagraphByIndex(1, <span class='basic'>false</span>);<br/>
+		<span class='javaclass'>Image</span> image = <span class='javaclass'>Image</span>.newImage(para, <span class='modifier'>new</span> <span class='javaclass'>URI</span>("file:/c:/image.jpg"));<br/>
+</pre>
+<br/><div class="bodytext">
+		Below codes can set the properties of image, and even the vertical (or horizontal) alignment.
+</div>
+<br/><pre class='code' id="code40">
+		image.setTitle("<span class='javaclass'>Image</span> title");<br/>
+		image.setDescription("<span class='javaclass'>This</span> is a sample image");<br/>
+		image.setVerticalPosition(<span class='javaclass'>FrameVerticalPosition</span>.<span class='javaclass'>TOP</span>);<br/>
+		image.setHorizontalPosition(<span class='javaclass'>FrameHorizontalPosition</span>.<span class='javaclass'>RIGHT</span>);<br/>
+</pre>
+<br/><div class="bodytext">
+		If you want to handle more style settings of image, you can try FrameStyleHandler.
+</div>
+<br/><pre class='code' id="code41">
+		<span class='javaclass'>FrameStyleHandler</span> handler = image.getStyleHandler();<br/>
+		handler.setAchorType(<span class='javaclass'>AnchorType</span>.AS_CHARACTER);<br/>
+		handler.setHorizontalRelative(<span class='javaclass'>HorizontalRelative</span>.<span class='javaclass'>PAGE</span>);<br/>
+		handler.setVerticalRelative(<span class='javaclass'>VerticalRelative</span>.<span class='javaclass'>PAGE</span>);<br/>
+</pre>
+<br/><div class="contenttitle" id="Span">
+<br/>
+<a href="#Span" >Span</a>
+<hr/>
+</div>
+<div class="bodytext">
+	    From version 0.5.5, we support high level APIs for span.		You can create a span based on a text selection.		With span, you can set a different style to this small unit.
+</div>
+<br/><pre class='code' id="code42">
+		<span class='javaclass'>TextNavigation</span> navigation = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("test", doc);<br/>
+		<span class='javaclass'>TextSelection</span> sel = (<span class='javaclass'>TextSelection</span>) navigation.nextSelection();<br/>
+		<span class='javaclass'>Span</span> span = <span class='javaclass'>Span</span>.newSpan(sel);<br/>
+		<span class='javaclass'>DefaultStyleHandler</span> styleHandler = span.getStyleHandler();<br/>
+		<span class='javaclass'>Font</span> font1Base = <span class='modifier'>new</span> <span class='javaclass'>Font</span>("<span class='javaclass'>Arial</span>", <span class='javaclass'>FontStyle</span>.<span class='javaclass'>ITALIC</span>, 10, <span class='javaclass'>Color</span>.<span class='javaclass'>BLACK</span>, <span class='javaclass'>TextLinePosition</span>.<span class='javaclass'>THROUGH</span>);<br/>
+		styleHandler.getTextPropertiesForWrite().setFont(font1Base);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Manipulate Metadata.html">previous</a></li>
+  <li><a href="Manipulate Presentation.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="#">About Us</a> | <a href="#">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate TextSearch.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate%20TextSearch.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate TextSearch.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Manipulate TextSearch.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,252 @@
+<!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" />
+<title>Manipulate TextSearch</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+<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="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Manipulate TextSearch.html">Manipulate TextSearch</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Style Handling.html">previous</a></li>
+  <li><a href="TextExtractor.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="TextNavigation">
+<br/>
+<a href="#TextNavigation" >TextNavigation</a>
+<hr/>
+</div>
+<div class="bodytext">
+		First an ODF text document is needed to test the navigation operation. The following codes shows two main functions of TextNavigation		:hasNext() and getCurrentItem(). The first parameter of the TextNavigation constructor is the matched pattern String, and the second is		the navigation scope.
+</div>
+<div class="bodytext">
+		The result of function getCurrentItem is a Selection object, so a TextSelection object is used here to check out 		the result.Finally the informations of all the String "What" in the text document will be printed out.
+</div>
+<br/><pre class='code' id="code0">
+		<span class='javaclass'>TextDocument</span> textdoc=(<span class='javaclass'>TextDocument</span>)<span class='javaclass'>TextDocument</span>.loadDocument("textsearch.odt");<br/>
+		<span class='javaclass'>TextNavigation</span> search1;<br/>
+		search1=<span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("<span class='javaclass'>What</span>",textdoc);<br/>
+		<span class='control'>while</span> (search1.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> item1 = (<span class='javaclass'>TextSelection</span>) search1.nextSelection();<br/>
+			<span class='javaclass'>System</span>.out.println(item1);<br/>
+		}		<br/>
+</pre>
+<br/><div class="contenttitle" id="TextSelection">
+<br/>
+<a href="#TextSelection" >TextSelection</a>
+<hr/>
+</div>
+<div class="contenttitle2" id="Get Index/Text of TextSelection">
+<br/>
+<a href="#Get Index/Text of TextSelection" >Get Index/Text of TextSelection</a>
+<hr/>
+</div>
+<div class="bodytext">
+		Run the following codes will get the text content of the searched String "good" and the corresponding index in 		the text document.
+</div>
+<br/><pre class='code' id="code1">
+		<span class='javaclass'>TextNavigation</span> search2=<span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("good",textdoc);<br/>
+		<span class='control'>while</span>(search2.hasNext()){<br/>
+			<span class='javaclass'>TextSelection</span> item2=(<span class='javaclass'>TextSelection</span>) search2.nextSelection();<br/>
+			<span class='javaclass'>String</span> searchedText=item2.getText();<br/>
+			<span class='basic'>int</span> searchedIndex=item2.getIndex();	<br/>
+			<span class='javaclass'>System</span>.out.println(searchedText);<br/>
+			<span class='javaclass'>System</span>.out.println(searchedIndex);<br/>
+		}		<br/>
+</pre>
+<br/><div class="contenttitle2" id="Cut String">
+<br/>
+<a href="#Cut String" >Cut String</a>
+<hr/>
+</div>
+<div class="bodytext">
+		To cut some specified string in a text document, you can do like the following codes which		cut off all the String "day" in the document.
+</div>
+<br/><pre class='code' id="code2">
+	        search2=<span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("day",textdoc);<br/>
+		<span class='control'>while</span>(search2.hasNext()){<br/>
+			<span class='javaclass'>TextSelection</span> item=(<span class='javaclass'>TextSelection</span>) search2.nextSelection();<br/>
+			item.cut();	<br/>
+		}		<br/>
+</pre>
+<br/><div class="contenttitle2" id="Paste String">
+<br/>
+<a href="#Paste String" >Paste String</a>
+<hr/>
+</div>
+<div class="bodytext">
+		The following codes paste the string "change" both at the front and at the end of the string "good",		by using the function pasteAtFrontOf() and pasteAtEndOf().
+</div>
+<br/><pre class='code' id="code3">
+		search2 = <span class='basic'>null</span>;<br/>
+		search2 = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("good", textdoc);<br/>
+		<span class='javaclass'>TextSelection</span> pastesource = <span class='basic'>null</span>;<br/>
+		<span class='javaclass'>TextNavigation</span> search3 = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("change", textdoc);<br/>
+		<span class='control'>if</span> (search3.hasNext()) {<br/>
+			pastesource = (<span class='javaclass'>TextSelection</span>) search3.nextSelection();<br/>
+		}		<br/>
+		<span class='control'>while</span> (search2.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> item = (<span class='javaclass'>TextSelection</span>) search2.nextSelection();	<br/>
+<span class='comments'>			//paste "change" at the front of "good"</span>
+			pastesource.pasteAtFrontOf(item);<br/>
+<span class='comments'>			//paste "change" at the end of "good"</span>
+			pastesource.pasteAtEndOf(item);<br/>
+		}<br/>
+</pre>
+<br/><div class="contenttitle2" id="Replace String">
+<br/>
+<a href="#Replace String" >Replace String</a>
+<hr/>
+</div>
+<div class="bodytext">
+The following codes replace all the string "replacesource" with the string "replacedest" in the text document.
+</div>
+<br/><pre class='code' id="code4">
+		search2 = <span class='basic'>null</span>;<br/>
+		search2 = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("replacesource", textdoc);<br/>
+		<span class='control'>if</span> (search3.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> item= (<span class='javaclass'>TextSelection</span>) search3.nextSelection();<br/>
+			item.replaceWith("replacedest");<br/>
+		}		<br/>
+</pre>
+<br/><div class="contenttitle2" id="Add Reference to String">
+<br/>
+<a href="#Add Reference to String" >Add Reference to String</a>
+<hr/>
+</div>
+<div class="bodytext">
+		To add reference for a string, you can do like the following codes. Here 		function addHref is used, the parameter of it is an URL object. The codes add network address		"http:www.ibm.com" to the string "network".
+</div>
+<br/><pre class='code' id="code5">
+		search2 = <span class='basic'>null</span>;<br/>
+		search2 = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("network", textdoc);<br/>
+		<span class='control'>while</span> (search2.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> item = (<span class='javaclass'>TextSelection</span>) search2.nextSelection();<br/>
+			item.addHref(<span class='modifier'>new</span> <span class='javaclass'>URL</span>("http://www.ibm.com"));<br/>
+		}<br/>
+</pre>
+<br/><div class="contenttitle2" id="Add Comment">
+<br/>
+<a href="#Add Comment" >Add Comment</a>
+<hr/>
+</div>
+<div class="bodytext">
+		Adding comment is a useful function when review document, such as spell check and security check. 		You can do it like the following codes. Here, function addComment is used, the first parameter is 		the comment content, the second parameter is the comment author. The codes add a spell suggestion 		before the string "natwork".
+</div>
+<br/><pre class='code' id="code6">
+		<span class='javaclass'>TextNavigation</span> search4 = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("natwork", textdoc);<br/>
+		<span class='control'>while</span> (search4.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> selection = (<span class='javaclass'>TextSelection</span>) search4.nextSelection();<br/>
+			selection.addComment("<span class='javaclass'>Please</span> change 'natwork' with 'network'.",	"<span class='javaclass'>SpellChecker</span>");<br/>
+		}<br/>
+</pre>
+<br/><div class="contenttitle" id="FieldSelection">
+<br/>
+<a href="#FieldSelection" >FieldSelection</a>
+<hr/>
+</div>
+<div class="bodytext">
+		Field Selection is a decorator class of TextSelection, which help user replace a text content with field.		Following code can be used to search the document content, and replace with a simple field.
+</div>
+<br/><pre class='code' id="code7">
+		<span class='javaclass'>TextDocument</span> doc = <span class='javaclass'>TextDocument</span>.loadDocument("fieldSample.odt");<br/>
+		<span class='javaclass'>TextNavigation</span> search = <span class='modifier'>new</span> <span class='javaclass'>TextNavigation</span>("<span class='javaclass'>ReplaceDateTarget</span>", doc);<br/>
+		<span class='control'>while</span> (search.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> item = (<span class='javaclass'>TextSelection</span>) search.nextSelection();<br/>
+			<span class='javaclass'>FieldSelection</span> fieldSelection = <span class='modifier'>new</span> <span class='javaclass'>FieldSelection</span>(item);<br/>
+			fieldSelection.replaceWithSimpleField(<span class='javaclass'>Field</span>.<span class='javaclass'>FieldType</span>.FIXED_DATE_FIELD);<br/>
+		}<br/>
+</pre>
+<br/><div class="bodytext">
+		Following code can be used to search the document content, and replace with a condition field.
+</div>
+<br/><pre class='code' id="code8">
+		<span class='javaclass'>TextSelection</span> item = (<span class='javaclass'>TextSelection</span>) search.nextSelection();<br/>
+		<span class='javaclass'>FieldSelection</span> fieldSelection = <span class='modifier'>new</span> <span class='javaclass'>FieldSelection</span>(item);<br/>
+		fieldSelection.replaceWithConditionField("test_con_variable == \"true\"", "trueText", "falseText");<br/>
+</pre>
+<br/><div class="bodytext">
+		Following code can be used to replace with a hidden field.
+</div>
+<br/><pre class='code' id="code9">
+		fieldSelection.replaceWithHiddenTextField("test_con_variable == \"true\"", "hiddenText");<br/>
+</pre>
+<br/><div class="bodytext">
+		Following code can be used to replace with a reference field.
+</div>
+<br/><pre class='code' id="code10">
+		<span class='javaclass'>ReferenceField</span> referenceField = <span class='javaclass'>Fields</span>.createReferenceField(doc.addParagraph("span").getOdfElement(), "selection-test-ref");<br/>
+		fieldSelection.replaceWithReferenceField(referenceField, <span class='javaclass'>ReferenceField</span>.<span class='javaclass'>DisplayType</span>.<span class='javaclass'>TEXT</span>);<br/>
+</pre>
+<br/><div class="bodytext">
+		Following code can be used to replace with a variable field.
+</div>
+<br/><pre class='code' id="code11">
+		<span class='javaclass'>VariableField</span> userVariableField = <span class='javaclass'>Fields</span>.createUserVariableField(doc, "selection_user_variable", "test");<br/>
+		fieldSelection.replaceWithVariableField(userVariableField);<br/>
+</pre>
+<br/><div class="contenttitle" id="TextStyleNavigation">
+<br/>
+<a href="#TextStyleNavigation" >TextStyleNavigation</a>
+<hr/>
+</div>
+<div class="bodytext">
+		Similar with TextNavigation, TextStyleNavigation has two main functions: getCurrentItem() and		hasNext() which is shown in the following codes. The input parameter of TextStyleNavigation constructor		is a map of OdfStyleProperty, so here a TreeMap "searchProps" which contains the Style properties is used		to construct the TextStyleNavigation object.
+</div>
+<br/><pre class='code' id="code12">
+		<span class='javaclass'>TextStyleNavigation</span> searchStyle1;<br/>
+		<span class='javaclass'>TreeMap</span>&lt;<span class='javaclass'>OdfStyleProperty</span>, <span class='javaclass'>String</span>&gt; searchProps = <span class='modifier'>new</span> <span class='javaclass'>TreeMap</span>&lt;<span class='javaclass'>OdfStyleProperty</span>, <span class='javaclass'>String</span>&gt;();<br/>
+		searchProps.put(<span class='javaclass'>StyleTextPropertiesElement</span>.<span class='javaclass'>FontName</span>, "<span class='javaclass'>Times</span> <span class='javaclass'>New</span> Roman1");<br/>
+		searchProps.put(<span class='javaclass'>StyleTextPropertiesElement</span>.<span class='javaclass'>FontSize</span>, "16pt");<br/>
+		searchStyle1 = <span class='modifier'>new</span> <span class='javaclass'>TextStyleNavigation</span>(searchProps, textdoc);<br/>
+		<span class='control'>if</span> (searchStyle1.hasNext()) {<br/>
+			<span class='javaclass'>TextSelection</span> itemstyle = (<span class='javaclass'>TextSelection</span>) searchStyle1.nextSelection();<br/>
+			<span class='javaclass'>System</span>.out.print((itemstyle.toString()));<br/>
+		}<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Style Handling.html">previous</a></li>
+  <li><a href="TextExtractor.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="../index.html">About Us</a> | <a href="mailto:Daisy@odftoolkit.org">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Presentation Document.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Presentation%20Document.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Presentation Document.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Presentation Document.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,111 @@
+<!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" />
+<title>Presentation Document</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+<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="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Presentation Document.html">Presentation Document</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Text Document.html">previous</a></li>
+  <li><a href="Slide.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Create Presentation Document">
+<br/>
+<a href="#Create Presentation Document" >Create Presentation Document</a>
+<hr/>
+</div>
+<div class="bodytext">
+Let's create an empty presentation document first. The following codes generates an empty presentation document with one slide:
+</div>
+<br/><pre class='code' id="code0">
+		    <span class='javaclass'>PresentationDocument</span> document=<span class='javaclass'>PresentationDocument</span>.newPresentationDocument();	 <br/>
+		    document.save(filePath);<br/>
+</pre>
+<br/><div class="bodytext">
+We can also create a presentation template document by using the following codes. The operation of the template document is the same with the normal presentation document.
+</div>
+<br/><pre class='code' id="code1">
+                    <span class='javaclass'>PresentationDocument</span> documentTmp=<span class='javaclass'>PresentationDocument</span>.newPresentationTemplateDocument();			    <br/>
+</pre>
+<br/><div class="contenttitle" id="Get Presentation Document">
+<br/>
+<a href="#Get Presentation Document" >Get Presentation Document</a>
+<hr/>
+</div>
+<div class="bodytext">
+We can get the existing presentation Document by using the loadDocument function like follows: 
+</div>
+<div class="bodytext">
+Here presentation.odp is the name of the existing presentation document.
+</div>
+<div class="bodytext">
+Also we can append all the slides of the specified presentation document to the current document by using the following codes:
+</div>
+<div class="bodytext">
+Here the slides of the documents "presentation.odp" will be appended to "document".
+</div>
+<br/><pre class='code' id="code2">
+		    <span class='javaclass'>PresentationDocument</span> presentationmodel;<br/>
+		    presentationmodel=(<span class='javaclass'>PresentationDocument</span>)<span class='javaclass'>PresentationDocument</span>.loadDocument("presentation.odp");<br/>
+	            document.appendPresentation(presentationmodel);	       <br/>
+</pre>
+<br/><div class="contenttitle" id="Change Presentation Mode">
+<br/>
+<a href="#Change Presentation Mode" >Change Presentation Mode</a>
+<hr/>
+</div>
+<div class="bodytext">
+We can switch the mode presentation documents by using the following codes. Here the first one convert the presentation document to a template, and the second one convert the template to a normal presentation document.
+</div>
+<br/><pre class='code' id="code3">
+		    document.changeMode(<span class='javaclass'>OdfMediaType</span>.PRESENTATION_TEMPLATE);	<br/>
+		    documentTmp.changeMode(<span class='javaclass'>OdfMediaType</span>.<span class='javaclass'>PRESENTATION</span>);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Text Document.html">previous</a></li>
+  <li><a href="Slide.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="../index.html">About Us</a> | <a href="mailto:Daisy@odftoolkit.org">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Slide.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Slide.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Slide.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Slide.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,215 @@
+<!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" />
+<title>Slide</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+<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="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Slide.html">Slide</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Presentation Document.html">previous</a></li>
+  <li><a href="Table.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Add Slide">
+<br/>
+<a href="#Add Slide" >Add Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+If you want to add new slide to the presentation document, you can use the following codes:
+</div>
+<div class="bodytext">
+Here the SlideLayout is the layout model of the added slide, the first parameter is the index of the added slide and the second parameter is the name of this slide.
+</div>
+<br/><pre class='code' id="code0">
+                <span class='javaclass'>PresentationDocument</span> document=<span class='javaclass'>PresentationDocument</span>.newPresentationDocument();	        			<br/>
+		document.newSlide(1, "new slide", <span class='javaclass'>SlideLayout</span>.TITLE_ONLY);<br/>
+</pre>
+<br/><div class="contenttitle" id="Get Slide">
+<br/>
+<a href="#Get Slide" >Get Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+You can get the slide through the index in the presentation document, like follows:
+</div>
+<br/><pre class='code' id="code1">
+		<span class='javaclass'>Slide</span> slide;<br/>
+		slide=document.getSlideByIndex(0);<br/>
+</pre>
+<br/><div class="bodytext">
+Or you can get the slide through the name of it by using the following code:
+</div>
+<br/><pre class='code' id="code2">
+		slide=document.getSlideByName("new slide");<br/>
+</pre>
+<br/><div class="bodytext">
+To get all the slides in the document,you can do like this:
+</div>
+<br/><pre class='code' id="code3">
+		<span class='javaclass'>Iterator</span>&lt;<span class='javaclass'>Slide</span>&gt; slideList=document.getSlides();<br/>
+</pre>
+<br/><div class="bodytext">
+Also you can get the number of the slides in the document by the following code:
+</div>
+<br/><pre class='code' id="code4">
+		<span class='basic'>int</span> numSlide=document.getSlideCount();<br/>
+</pre>
+<br/><div class="contenttitle" id="Set/Get Slide Name/Index">
+<br/>
+<a href="#Set/Get Slide Name/Index" >Set/Get Slide Name/Index</a>
+<hr/>
+</div>
+<div class="bodytext">
+If you want to set a new name for a slide, you can use the following two methods:
+</div>
+<br/><pre class='code' id="code5">
+		slide.setSlideName("second slide");	<br/>
+		document.getSlideByIndex(2).setSlideName("third slide");<br/>
+</pre>
+<br/><div class="bodytext">
+If you want to know the index and the name of one slide which is being operated, you can use the following codes:
+</div>
+<br/><pre class='code' id="code6">
+		<span class='basic'>int</span> slideIndex=slide.getSlideIndex();<br/>
+		<span class='javaclass'>String</span> slideName=slide.getSlideName();<br/>
+</pre>
+<br/><div class="contenttitle" id="Copy Slide">
+<br/>
+<a href="#Copy Slide" >Copy Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+You can copy a slide in the presentation document from one position to another by using the following codes:
+</div>
+<div class="bodytext">
+Here the first parameter is the source position of the slide need to be copied, the second parameter is the destination position of the slide need to be copied, and the last parameter is the new name of the copied slide. 
+</div>
+<br/><pre class='code' id="code7">
+		document.copySlide(1, 2, "copied slide");<br/>
+</pre>
+<br/><div class="bodytext">
+And also you can copy a slide from another document by using the following codes:
+</div>
+<div class="bodytext">
+Here the first parameter of copyForeignSlide is the new position of the copied slide in the current document, the second parameter is the source document of the copied slide, and the last one is the slide index of the source document that need to be copied.
+</div>
+<br/><pre class='code' id="code8">
+		 <span class='javaclass'>PresentationDocument</span> documentmodel;<br/>
+		 documentmodel=(<span class='javaclass'>PresentationDocument</span>)<span class='javaclass'>PresentationDocument</span>.loadDocument("presentation.odp");<br/>
+		 document.copyForeignSlide(1, documentmodel, 2);<br/>
+</pre>
+<br/><div class="contenttitle" id="Move/Delete Slide">
+<br/>
+<a href="#Move/Delete Slide" >Move/Delete Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+To move one slide to another position of this presentation position, you can use the following codes:
+</div>
+<div class="bodytext">
+Here the first parameter is the current index of the slide that need to be moved, and the second parameter is the index of the destination position before the move action.
+</div>
+<br/><pre class='code' id="code9">
+		document.moveSlide(2, 1);		<br/>
+</pre>
+<br/><div class="bodytext">
+You can delete the slide either by through the index or through the name of the specified slide, like follows:
+</div>
+<br/><pre class='code' id="code10">
+		document.deleteSlideByIndex(1);<br/>
+		document.deleteSlideByName("third slide");<br/>
+</pre>
+<br/><div class="contenttitle" id="Add Text to Slide">
+<br/>
+<a href="#Add Text to Slide" >Add Text to Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+	  You can set the text content of a slide with text box API since version 0.5.	  Below codes will get the title text box of a slide, set the text content,	  and then get the outline text box, set the list content.
+</div>
+<br/><pre class='code' id="code11">
+	    <span class='javaclass'>Textbox</span> titleBox = slide.getTextboxByUsage(<span class='javaclass'>PresentationClass</span>.<span class='javaclass'>TITLE</span>).get(0);<br/>
+	    titleBox.setTextContent("<span class='javaclass'>This</span> is the title");<br/>
+	    <span class='javaclass'>Textbox</span> outline = slide.getTextboxByUsage(<span class='javaclass'>PresentationClass</span>.<span class='javaclass'>OUTLINE</span>).get(0);<br/>
+	    <span class='javaclass'>List</span> txtList = outline.addList();<br/>
+	    txtList.addItem("<span class='javaclass'>List</span> Item1");<br/>
+	    txtList.addItem("<span class='javaclass'>List</span> Item2");<br/>
+</pre>
+<br/><div class="bodytext">
+To add some text, you can first get the notes of one slide and then add text to this corresponding notes. The following codes shows this process:
+</div>
+<br/><pre class='code' id="code12">
+		<span class='javaclass'>Notes</span> note=slide.getNotesPage();<br/>
+		note.addText("text notes");<br/>
+</pre>
+<br/><div class="contenttitle" id="Add Image to Slide">
+<br/>
+<a href="#Add Image to Slide" >Add Image to Slide</a>
+<hr/>
+</div>
+<div class="bodytext">
+To add an image to slide, you can use below codes to simply add the image to the last slide of the presentation document.
+</div>
+<br/><pre class='code' id="code13">
+		<span class='javaclass'>URI</span> imageuri=<span class='modifier'>new</span> <span class='javaclass'>URI</span>("namdaemun.jpg");<br/>
+		document.newImage(imageuri);<br/>
+</pre>
+<br/><div class="bodytext">
+Or you can use following code to add an image to a specific position you want
+</div>
+<br/><pre class='code' id="code14">
+		<span class='javaclass'>Slide</span> slide1 = document.getSlideByIndex(1);<br/>
+		<span class='javaclass'>Image</span> image = <span class='javaclass'>Image</span>.newImage(slide1, <span class='modifier'>new</span> <span class='javaclass'>URI</span>("http://www.xxx.com/a.jpg"));<br/>
+		<span class='javaclass'>FrameRectangle</span> rect = image.getRectangle();<br/>
+		rect.setX(4);<br/>
+		rect.setY(5.7);<br/>
+		image.setRectangle(rect);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Presentation Document.html">previous</a></li>
+  <li><a href="Table.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="../index.html">About Us</a> | <a href="mailto:Daisy@odftoolkit.org">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>

Added: incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Style Handling.html
URL: http://svn.apache.org/viewvc/incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Style%20Handling.html?rev=1165478&view=auto
==============================================================================
--- incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Style Handling.html (added)
+++ incubator/odf/site/trunk/content/odftoolkit/simple/document/cookbook/Style Handling.html Tue Sep  6 02:09:27 2011
@@ -0,0 +1,150 @@
+<!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" />
+<title>Style Handling</title>
+ <link type="text/css" rel="stylesheet" href="cookbook.css"/>
+<link rel="stylesheet" href="../images/style.css" type="text/css" />
+<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="../documents.html">Documents</a> > 
+<a href="index.html">Cookbook</a> ><a href="Style Handling.html">Style Handling</a>
+</span>
+</div>
+<div class="navigation">
+ <ul>
+  <li><a href="Charts.html">previous</a></li>
+  <li><a href="Manipulate TextSearch.html">next</a></li>
+ </ul>
+</div>
+<br/>
+<div class="contenttitle" id="Overview">
+<br/>
+<a href="#Overview" >Overview</a>
+<hr/>
+</div>
+<div class="bodytext">
+Style handling methods provide convenient methods to set font and borders.
+</div>
+<div class="contenttitle" id="Font handling">
+<br/>
+<a href="#Font handling" >Font handling</a>
+<hr/>
+</div>
+<div class="bodytext">
+		The most simple method to define font settings is to create a font		object, and set it to a cell object.		The below code snippet defines a font object to describe "Arial"		italic font with size "12pt" and black color,		and then set it to a cell. The font will work for western characters		by default.
+</div>
+<br/><pre class='code' id="code0">
+		<span class='javaclass'>SpreadsheetDocument</span> document = <span class='javaclass'>SpreadsheetDocument</span>.newSpreadsheetDocument();<br/>
+		<span class='javaclass'>Table</span> table = document.getTableByName("Sheet1");<br/>
+		<span class='javaclass'>Font</span> font = <span class='modifier'>new</span> <span class='javaclass'>Font</span>("<span class='javaclass'>Arial</span>", <span class='javaclass'>StyleTypeDefinitions</span>.<span class='javaclass'>FontStyle</span>.<span class='javaclass'>ITALIC</span>, 12, <span class='javaclass'>Color</span>.<span class='javaclass'>BLACK</span>);<br/>
+		<span class='javaclass'>Cell</span> cell = table.getCellByPosition("A1");<br/>
+		cell.setFont(font);<br/>
+</pre>
+<br/><div class="bodytext">
+		The most simple method to get font settings of western characters is:
+</div>
+<br/><pre class='code' id="code1">
+		<span class='javaclass'>Font</span> theFont = cell.getFont();<br/>
+		<span class='basic'>double</span> size = theFont.getSize();<br/>
+		<span class='javaclass'>String</span> fontName = theFont.getFamilyName();<br/>
+		<span class='javaclass'>StyleTypeDefinitions</span>.<span class='javaclass'>FontStyle</span> fontStyle = theFont.getFontStyle();<br/>
+		<span class='javaclass'>Color</span> fontColor = theFont.getColor();<br/>
+</pre>
+<br/><div class="contenttitle" id="Advanced font handling">
+<br/>
+<a href="#Advanced font handling" >Advanced font handling</a>
+<hr/>
+</div>
+<div class="bodytext">
+		<i>CellStyleHandler</i> can help you to achieve advanced functions.		In Open Document Format, there can be different font settings for		different script types. 		For example, a font setting for English characters and another font		setting for Chinese characters.		If you want to define the font setting for other script types, you		can reference to below codes.		The below code snippet defines a font for Chinese characters.
+</div>
+<br/><pre class='code' id="code2">
+		cell.getStyleHandler().setFont(font, <span class='modifier'>new</span> <span class='javaclass'>Locale</span>(<span class='javaclass'>Locale</span>.<span class='javaclass'>CHINESE</span>.getLanguage(), <span class='javaclass'>Locale</span>.<span class='javaclass'>CHINA</span>.getCountry()));<br/>
+</pre>
+<br/><div class="bodytext">
+		The below code snippet shows how to get the font setting for other kinds of scripts.
+</div>
+<br/><pre class='code' id="code3">
+		<span class='javaclass'>CellStyleHandler</span> styleHandler = cell.getStyleHandler();<br/>
+		<span class='javaclass'>Font</span> westernFont = styleHandler.getFont(<span class='javaclass'>Document</span>.<span class='javaclass'>ScriptType</span>.<span class='javaclass'>WESTERN</span>);<br/>
+		<span class='javaclass'>Font</span> chineseFont = styleHandler.getFont(<span class='javaclass'>Document</span>.<span class='javaclass'>ScriptType</span>.<span class='javaclass'>CJK</span>);<br/>
+		<span class='javaclass'>Font</span> complexFont = styleHandler.getFont(<span class='javaclass'>Document</span>.<span class='javaclass'>ScriptType</span>.<span class='javaclass'>CTL</span>);<br/>
+</pre>
+<br/><div class="contenttitle" id="Border handling">
+<br/>
+<a href="#Border handling" >Border handling</a>
+<hr/>
+</div>
+<div class="bodytext">
+		The most simple way to set border is to create a border object and		then set it to a cell object.		Below code snippet illustrates how to set a cell object with four		borders.
+</div>
+<br/><pre class='code' id="code4">
+		cell = table.getCellByPosition("A1");<br/>
+		cell.setStringValue("four border");<br/>
+		<span class='javaclass'>Border</span> border = <span class='modifier'>new</span> <span class='javaclass'>Border</span>(<span class='javaclass'>Color</span>.<span class='javaclass'>RED</span>, 1, <span class='javaclass'>StyleTypeDefinitions</span>.<span class='javaclass'>SupportedLinearMeasure</span>.<span class='javaclass'>PT</span>);<br/>
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.ALL_FOUR, border);<br/>
+</pre>
+<br/><div class="bodytext">
+		Below code snippet illustrates how to set a cell object with left and		right borders, top and bottom borders and diagonal lines.
+</div>
+<br/><pre class='code' id="code5">
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.LEFT_RIGHT, border);<br/>
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.TOP_BOTTOM, border);<br/>
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.DIAGONAL_LINES, border);<br/>
+</pre>
+<br/><div class="bodytext">
+		Below code snippet illustrates how to set a cell object with left		border, top border and diagonal from bottom left to top right.
+</div>
+<br/><pre class='code' id="code6">
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.<span class='javaclass'>LEFT</span>, border);<br/>
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.<span class='javaclass'>TOP</span>, border);<br/>
+		cell.setBorders(<span class='javaclass'>CellBordersType</span>.<span class='javaclass'>DIAGONALBLTR</span>, border);<br/>
+</pre>
+<br/><div class="bodytext">
+		Below code snippet illustrates how to get a border definition.
+</div>
+<br/><pre class='code' id="code7">
+		<span class='javaclass'>Border</span> thisBorder = cell.getBorder(<span class='javaclass'>CellBordersType</span>.<span class='javaclass'>LEFT</span>);<br/>
+		thisBorder = cell.getBorder(<span class='javaclass'>CellBordersType</span>.<span class='javaclass'>TOP</span>);<br/>
+		thisBorder = cell.getBorder(<span class='javaclass'>CellBordersType</span>.<span class='javaclass'>DIAGONALBLTR</span>);<br/>
+</pre>
+<br/><br/> 
+<div class="navigation">
+ <ul>
+  <li><a href="Charts.html">previous</a></li>
+  <li><a href="Manipulate TextSearch.html">next</a></li>
+  <li><a href="#">top</a></li>
+ </ul>
+</div>
+<br/>
+</div>
+<div id="footer" class="smallgraytext"> <a href="../index.html">Home</a> | <a href="../index.html">About Us</a> | <a href="mailto:Daisy@odftoolkit.org">Contact Us</a> </div>
+</div>
+</div>
+</body>
+</html>



Mime
View raw message