org.odftoolkit.odfdom.doc
Class OdfTextDocument

java.lang.Object
  extended by org.odftoolkit.odfdom.doc.OdfDocument
      extended by org.odftoolkit.odfdom.doc.OdfTextDocument

public class OdfTextDocument
extends OdfDocument

This class represents an empty ODF text document.


Nested Class Summary
static class OdfTextDocument.OdfMediaType
          This enum contains all possible media types of OdfSpreadsheetDocument documents.
 
Nested classes/interfaces inherited from class org.odftoolkit.odfdom.doc.OdfDocument
OdfDocument.OdfXMLFile, OdfDocument.Resource
 
Constructor Summary
protected OdfTextDocument()
           
 
Method Summary
 OdfTextParagraph addText(java.lang.String text)
          Append text to the end of a text document.
 void changeMode(OdfTextDocument.OdfMediaType type)
          Switches this instance to the given type.
 OdfOfficeText getContentRoot()
          Get the content root of a text document.
 OdfTextParagraph newParagraph()
          Creates a new paragraph
 OdfTextParagraph newParagraph(java.lang.String text)
          Creates a new paragraph and append text
static OdfTextDocument newTextDocument()
          Creates an empty text document.
static OdfTextDocument newTextMasterDocument()
          Creates an empty text master document.
static OdfTextDocument newTextTemplateDocument()
          Creates an empty text template.
static OdfTextDocument newTextWebDocument()
          Creates an empty text web.
 
Methods inherited from class org.odftoolkit.odfdom.doc.OdfDocument
close, embedDocument, getBaseURI, getContentDom, getContentStream, getDocumentPackagePath, getDocumentStyles, getEmbeddedDocument, getEmbeddedDocuments, getEmbeddedDocuments, getMediaType, getMetaDom, getMetaStream, getOfficeBody, getOfficeMasterStyles, getOfficeMetadata, getOrCreateDocumentStyles, getPackage, getRootDocument, getSettingsStream, getStylesDom, getStylesStream, getTableByName, getTableList, getXMLFilePath, getXPath, loadDocument, loadDocument, loadDocument, loadDocument, loadTemplate, newImage, RemoveEmbedDocument, save, save, save, setMediaType, setPackage, setRootDocument, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OdfTextDocument

protected OdfTextDocument()
Method Detail

newTextDocument

public static OdfTextDocument newTextDocument()
                                       throws java.lang.Exception
Creates an empty text document.

Returns:
ODF text document based on a default template
Throws:
java.lang.Exception - - if the document could not be created

newTextTemplateDocument

public static OdfTextDocument newTextTemplateDocument()
                                               throws java.lang.Exception
Creates an empty text template.

Returns:
ODF text template based on a default
Throws:
java.lang.Exception - - if the template could not be created

newTextMasterDocument

public static OdfTextDocument newTextMasterDocument()
                                             throws java.lang.Exception
Creates an empty text master document.

Returns:
ODF text master based on a default
Throws:
java.lang.Exception - - if the document could not be created

newTextWebDocument

public static OdfTextDocument newTextWebDocument()
                                          throws java.lang.Exception
Creates an empty text web.

Returns:
ODF text web based on a default
Throws:
java.lang.Exception - - if the document could not be created

getContentRoot

public OdfOfficeText getContentRoot()
                             throws java.lang.Exception
Get the content root of a text document. Start here to get or create new elements of a text document like paragraphs, headings, tables or lists.

Returns:
content root, representing the office:text tag
Throws:
java.lang.Exception - if the file DOM could not be created.

newParagraph

public OdfTextParagraph newParagraph(java.lang.String text)
                              throws java.lang.Exception
Creates a new paragraph and append text

Parameters:
text -
Returns:
the new paragraph
Throws:
java.lang.Exception - if the file DOM could not be created.

newParagraph

public OdfTextParagraph newParagraph()
                              throws java.lang.Exception
Creates a new paragraph

Returns:
The new paragraph
Throws:
java.lang.Exception - if the file DOM could not be created.

addText

public OdfTextParagraph addText(java.lang.String text)
                         throws java.lang.Exception
Append text to the end of a text document. If there is no paragraph at the end of a document, a new one will be created.

Parameters:
text - initial text for the paragraph.
Returns:
The paragraph at the end of the text document, where the text has been added to.
Throws:
java.lang.Exception - if the file DOM could not be created.

changeMode

public void changeMode(OdfTextDocument.OdfMediaType type)
Switches this instance to the given type. This method can be used to e.g. convert a document instance to a template and vice versa. *

Parameters:
type -


Copyright © 2008-2010 ODF Toolkit Project. All Rights Reserved.