org.odftoolkit.simple.text
Class Paragraph

java.lang.Object
  extended by org.odftoolkit.simple.Component
      extended by org.odftoolkit.simple.text.Paragraph
All Implemented Interfaces:
FrameContainer, TextboxContainer

public class Paragraph
extends Component
implements TextboxContainer

This class presents paragraph in ODF document. It provides methods to manipulate text content, and other child component under the paragraph.

Since:
0.5

Method Summary
 Textbox addTextbox()
          Add a text box
 Textbox addTextbox(FrameRectangle position)
          Add a text box with a specific size at a specific position
 void appendTextContent(String content)
          Append the text content at the end of this paragraph.
 void appendTextContentNotCollapsed(String content)
          Append the text content at the end of this paragraph.
 OdfElement getFrameContainerElement()
          Get the ODF element which can have as child element directly according to ODF specification.
static Paragraph getInstanceof(TextPElement pElement)
          Get a paragraph instance by an instance of TextPElement.
 TextPElement getOdfElement()
          Return the instance of "text:p" element
 Document getOwnerDocument()
          Get the owner document of this paragraph
 DefaultStyleHandler getStyleHandler()
          Get the style handler of this paragraph.
 String getStyleName()
          Get the style name of this paragraph
 Textbox getTextboxByName(String name)
          Return a text box whose name is a given value.
 List<Textbox> getTextboxByUsage(PresentationDocument.PresentationClass usage)
          This method is only useful in presentation slide.
 Iterator<Textbox> getTextboxIterator()
          Return an Iterator of the text objects in this container.
 String getTextContent()
          Return the text content of this paragraph.
static Paragraph newParagraph(ParagraphContainer container)
          Create an instance of paragraph
 boolean removeTextbox(Textbox box)
          Remove the text box
 void removeTextContent()
          Remove the text content of this paragraph.
 void setStyleName(String styleName)
          Set the style name of this paragraph
 void setTextContent(String content)
          Set the text content of this paragraph.
 void setTextContentNotCollapsed(String content)
          Set the text content of this paragraph.
 
Methods inherited from class org.odftoolkit.simple.Component
getComponentByElement, registerComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstanceof

public static Paragraph getInstanceof(TextPElement pElement)
Get a paragraph instance by an instance of TextPElement.

Parameters:
pElement - - the instance of TextPElement
Returns:
an instance of paragraph

newParagraph

public static Paragraph newParagraph(ParagraphContainer container)
Create an instance of paragraph

The paragrah will be added at the end of this container.

Parameters:
container - - the paragraph container that contains this paragraph.

setTextContent

public void setTextContent(String content)
Set the text content of this paragraph.

All the existing text content of this paragraph would be removed, and then new text content would be set.

The white space characters in the content would be collapsed by default. For example, tab character would be replaced with , break line character would be replaced with .

Parameters:
content - - the text content
See Also:
setTextContentNotCollapsed(String content)

removeTextContent

public void removeTextContent()
Remove the text content of this paragraph.

The other child elements except text content will not be removed.


getTextContent

public String getTextContent()
Return the text content of this paragraph.

The other child elements except text content will not be returned.

Returns:
- the text content of this paragraph

setTextContentNotCollapsed

public void setTextContentNotCollapsed(String content)
Set the text content of this paragraph.

All the existing text content of this paragraph would be removed, and then new text content would be set.

The white space characters in the content would not be collapsed.

Parameters:
content - - the text content
See Also:
setTextContent(String content)

appendTextContent

public void appendTextContent(String content)
Append the text content at the end of this paragraph.

The white space characters in the content would be collapsed by default. For example, tab character would be replaced with , break line character would be replaced with .

Parameters:
content - - the text content
See Also:
appendTextContentNotCollapsed(String content)

appendTextContentNotCollapsed

public void appendTextContentNotCollapsed(String content)
Append the text content at the end of this paragraph.

The white space characters in the content would not be collapsed.

Parameters:
content - - the text content
See Also:
appendTextContent(String content)

setStyleName

public void setStyleName(String styleName)
Set the style name of this paragraph

Parameters:
styleName - - the style name

getStyleName

public String getStyleName()
Get the style name of this paragraph

Returns:
- the style name

getOwnerDocument

public Document getOwnerDocument()
Get the owner document of this paragraph

Overrides:
getOwnerDocument in class Component
Returns:
the document who owns this paragraph

getStyleHandler

public DefaultStyleHandler getStyleHandler()
Get the style handler of this paragraph.

The style handler is an instance of DefaultStyleHandler

Returns:
an instance of DefaultStyleHandler
See Also:
DefaultStyleHandler

getOdfElement

public TextPElement getOdfElement()
Return the instance of "text:p" element

Specified by:
getOdfElement in class Component
Returns:
the instance of "text:p" element

addTextbox

public Textbox addTextbox()
Description copied from interface: TextboxContainer
Add a text box

Specified by:
addTextbox in interface TextboxContainer
Returns:
the object of text box

getTextboxIterator

public Iterator<Textbox> getTextboxIterator()
Description copied from interface: TextboxContainer
Return an Iterator of the text objects in this container.

Specified by:
getTextboxIterator in interface TextboxContainer
Returns:
an Iterator of the text objects in this container

removeTextbox

public boolean removeTextbox(Textbox box)
Description copied from interface: TextboxContainer
Remove the text box

Specified by:
removeTextbox in interface TextboxContainer
Parameters:
box - - the instance of text box
Returns:
true if success, false if fails

getFrameContainerElement

public OdfElement getFrameContainerElement()
Description copied from interface: FrameContainer
Get the ODF element which can have as child element directly according to ODF specification. This Element will help to find the position to insert a new draw:frame element.

Specified by:
getFrameContainerElement in interface FrameContainer
Returns:
the parent of draw:frame

addTextbox

public Textbox addTextbox(FrameRectangle position)
Description copied from interface: TextboxContainer
Add a text box with a specific size at a specific position

Specified by:
addTextbox in interface TextboxContainer
Parameters:
position - - the rectangle (position and size) of this text box
Returns:
the object of text box

getTextboxByName

public Textbox getTextboxByName(String name)
Description copied from interface: TextboxContainer
Return a text box whose name is a given value.

Specified by:
getTextboxByName in interface TextboxContainer
Parameters:
name - - the name of the text box
Returns:
a text box whose name is a given value

getTextboxByUsage

public List<Textbox> getTextboxByUsage(PresentationDocument.PresentationClass usage)
Description copied from interface: TextboxContainer
This method is only useful in presentation slide.

This method will return a list of text boxs by the usage in presentation slides.

Specified by:
getTextboxByUsage in interface TextboxContainer
Parameters:
usage - - the usage description
Returns:
a list of text box Null will be returned if the owner document is not a presentation


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