public class Paragraph extends CompositeNode
Paragraph is a block-level node and can be a child of classes derived from Story or InlineStory.
Paragraph can contain any number of inline-level nodes and bookmarks.
The complete list of child nodes that can occur inside a paragraph consists of BookmarkStart, BookmarkEnd, FieldStart, FieldSeparator, FieldEnd, FormField, Comment, Footnote, Run, SpecialChar, Shape, GroupShape, SmartTag.
A valid paragraph in Microsoft Word always ends with a paragraph break character and a minimal valid paragraph consists just of a paragraph break. The Paragraph class automatically appends the appropriate paragraph break character at the end and this character is not part of the child nodes of the Paragraph, therefore a Paragraph can be empty.
Do not include the end of paragraph ControlChar.PARAGRAPH_BREAK or end of cell ControlChar.CELL characters inside the text of the paragraph as it might make the paragraph invalid when the document is opened in Microsoft Word.
| Constructor and Description |
|---|
Paragraph(DocumentBase doc)
Initializes a new instance of the Paragraph class.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(DocumentVisitor visitor)
Accepts a visitor.
|
Field |
appendField(int fieldType,
boolean updateField) |
Field |
appendField(java.lang.String fieldCode)
|
Field |
appendField(java.lang.String fieldCode,
java.lang.String fieldValue)
|
void |
clearParaAttrs() |
void |
clearRunAttrs() |
java.lang.Object |
fetchInheritedParaAttr(int key) |
java.lang.Object |
fetchInheritedRunAttr(int key) |
java.lang.Object |
fetchParaAttr(int key) |
boolean |
getBreakIsStyleSeparator()
True if this paragraph break is a Style Separator.
|
java.lang.Object |
getDirectParaAttr(int key) |
java.lang.Object |
getDirectParaAttr(int key,
int revisionsView) |
java.lang.Object |
getDirectRunAttr(int key) |
TabStop[] |
getEffectiveTabStops()
Returns array of all tab stops applied to this paragraph, including applied indirectly by styles or lists.
|
FrameFormat |
getFrameFormat()
Provides access to the paragraph formatting properties.
|
ListFormat |
getListFormat()
Provides access to the list formatting properties of the paragraph.
|
ListLabel |
getListLabel()
Gets a
getListLabel() object that provides access to list numbering value and formatting for this paragraph. |
int |
getNodeType()
Returns NodeType.Paragraph.
|
Font |
getParagraphBreakFont()
Provides access to the font formatting of the paragraph break character.
|
ParagraphFormat |
getParagraphFormat()
Provides access to the paragraph formatting properties.
|
Section |
getParentSection()
Retrieves the parent
Section of the paragraph. |
Story |
getParentStory()
Retrieves the parent section-level story that can be
Body or HeaderFooter. |
RunCollection |
getRuns()
Provides access to the typed collection of pieces of text inside the paragraph.
|
java.lang.String |
getText()
Gets the text of this paragraph including the end of paragraph character.
|
Field |
insertField(int fieldType,
boolean updateField,
Node refNode,
boolean isAfter) |
Field |
insertField(java.lang.String fieldCode,
Node refNode,
boolean isAfter)
|
Field |
insertField(java.lang.String fieldCode,
java.lang.String fieldValue,
Node refNode,
boolean isAfter)
|
boolean |
isDeleteRevision()
Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
|
boolean |
isEndOfCell()
True if this paragraph is the last paragraph in a
Cell; false otherwise. |
boolean |
isEndOfDocument()
True if this paragraph is the last paragraph in the last section of the document.
|
boolean |
isEndOfHeaderFooter()
True if this paragraph is the last paragraph in the HeaderFooter (main text story) of a Section; false otherwise.
|
boolean |
isEndOfSection()
True if this paragraph is the last paragraph in the Body (main text story) of a Section; false otherwise.
|
boolean |
isFormatRevision()
Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled.
|
boolean |
isInCell()
True if this paragraph is an immediate child of
Cell; false otherwise. |
boolean |
isInsertRevision()
Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
|
boolean |
isListItem()
True when the paragraph is an item in a bulleted or numbered list in original revision.
|
boolean |
isMoveFromRevision()
Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
|
boolean |
isMoveToRevision()
Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
|
int |
joinRunsWithSameFormatting()
Joins runs with the same formatting in the paragraph.
|
void |
removeMoveRevisions() |
void |
removeParaAttr(int key) |
void |
removeRunAttr(int key) |
void |
setParaAttr(int key,
java.lang.Object value) |
void |
setRunAttr(int key,
java.lang.Object value) |
acceptChildren, acceptCore, appendChild, coreRemoveSelfOnly, getChild, getChildNodes, getChildNodes, getContainer, getCount, getCurrentNode, getFirstChild, getLastChild, getNextMatchingNode, hasChildNodes, indexOf, insertAfter, insertBefore, isComposite, iterator, prependChild, removeAllChildren, removeChild, removeSmartTags, selectNodes, selectSingleNodedd, deepClone, getAncestor, getAncestor, getCustomNodeId, getDocument, getNextSibling, getParentNode, getPreviousSibling, getRange, memberwiseClone, nextPreOrder, nodeTypeToString, previousPreOrder, remove, setCustomNodeId, toString, toString, toString, visitorActionToBoolpublic Paragraph(DocumentBase doc)
When Paragraph is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.
To append Paragraph to the document use InsertAfter or InsertBefore on the story where you want the paragraph inserted.
doc - The owner document.public int getNodeType()
getNodeType in class NodeNodeType constants.public Story getParentStory()
Body or HeaderFooter.Story value.public Section getParentSection()
Section of the paragraph.Section value.public boolean isInCell()
Cell; false otherwise.boolean value.public boolean isEndOfCell()
Cell; false otherwise.boolean value.public boolean getBreakIsStyleSeparator()
boolean value.public boolean isEndOfSection()
boolean value.public boolean isEndOfHeaderFooter()
boolean value.public boolean isEndOfDocument()
boolean value.public ParagraphFormat getParagraphFormat()
ParagraphFormat value.public ListFormat getListFormat()
ListFormat value.public FrameFormat getFrameFormat()
FrameFormat value.public ListLabel getListLabel()
getListLabel() object that provides access to list numbering value and formatting for this paragraph.getListLabel() object that provides access to list numbering value and formatting for this paragraph.public RunCollection getRuns()
RunCollection value.public Font getParagraphBreakFont()
Font value.public boolean isInsertRevision()
public boolean isDeleteRevision()
public boolean isMoveFromRevision()
public boolean isMoveToRevision()
public boolean isFormatRevision()
public boolean accept(DocumentVisitor visitor) throws java.lang.Exception
Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.
For more info see the Visitor design pattern.
public java.lang.String getText()
The text of all child nodes is concatenated and the end of paragraph character is appended as follows:
Body, then ControlChar.SECTION_BREAK (\x000c) is appended.
Cell, then ControlChar.CELL (\x0007) is appended.
ControlChar.PARAGRAPH_BREAK (\r) is appended.
The returned string includes all control and special characters as described in ControlChar.
getText in class CompositeNodepublic java.lang.Object getDirectParaAttr(int key)
public java.lang.Object getDirectParaAttr(int key,
int revisionsView)
public java.lang.Object fetchInheritedParaAttr(int key)
public java.lang.Object fetchParaAttr(int key)
public void setParaAttr(int key,
java.lang.Object value)
public void removeParaAttr(int key)
public void clearParaAttrs()
public java.lang.Object getDirectRunAttr(int key)
public java.lang.Object fetchInheritedRunAttr(int key)
public void setRunAttr(int key,
java.lang.Object value)
public void removeRunAttr(int key)
public void clearRunAttrs()
public void removeMoveRevisions()
public boolean isListItem()
boolean value.public TabStop[] getEffectiveTabStops()
public int joinRunsWithSameFormatting()
public Field appendField(int fieldType, boolean updateField) throws java.lang.Exception
java.lang.Exceptionpublic Field appendField(java.lang.String fieldCode) throws java.lang.Exception
fieldCode - The field code to append (without curly braces).Field object that represents the appended field.java.lang.Exceptionpublic Field appendField(java.lang.String fieldCode, java.lang.String fieldValue)
fieldCode - The field code to append (without curly braces).fieldValue - The field value to append. Pass null for fields that do not have a value.Field object that represents the appended field.public Field insertField(int fieldType, boolean updateField, Node refNode, boolean isAfter) throws java.lang.Exception
java.lang.Exceptionpublic Field insertField(java.lang.String fieldCode, Node refNode, boolean isAfter) throws java.lang.Exception
fieldCode - The field code to insert (without curly braces).refNode - Reference node inside this paragraph (if refNode is null, then appends to the end of the paragraph).isAfter - Whether to insert the field after or before reference node.Field object that represents the inserted field.java.lang.Exceptionpublic Field insertField(java.lang.String fieldCode, java.lang.String fieldValue, Node refNode, boolean isAfter)
fieldCode - The field code to insert (without curly braces).fieldValue - The field value to insert. Pass null for fields that do not have a value.refNode - Reference node inside this paragraph (if refNode is null, then appends to the end of the paragraph).isAfter - Whether to insert the field after or before reference node.Field object that represents the inserted field.