Represents a paragraph of text.
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.ParagraphBreak 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.
Shows how to construct an Aspose.Words document by hand.
#include <Aspose.Words.Cpp/Paragraph.h>
Public Member Functions | |
Paragraph (const SharedPtr< DocumentBase > &doc) | |
Initializes a new instance of the Paragraph class. More... | |
bool | Accept (SharedPtr< DocumentVisitor > visitor) override |
Accepts a visitor. More... | |
SharedPtr< Field > | AppendField (FieldType fieldType, bool updateField) |
Appends a field to this paragraph. More... | |
SharedPtr< Field > | AppendField (const String &fieldCode) |
Appends a field to this paragraph. More... | |
SharedPtr< Field > | AppendField (const String &fieldCode, const String &fieldValue) |
Appends a field to this paragraph. More... | |
bool | get_BreakIsStyleSeparator () |
True if this paragraph break is a Style Separator. A style separator allows one paragraph to consist of parts that have different paragraph styles. More... | |
SharedPtr< FrameFormat > | get_FrameFormat () |
Provides access to the paragraph formatting properties. More... | |
bool | get_IsDeleteRevision () |
Returns true if this object was deleted in Microsoft Word while change tracking was enabled. More... | |
bool | get_IsEndOfCell () |
True if this paragraph is the last paragraph in a Cell; false otherwise. More... | |
bool | get_IsEndOfDocument () |
True if this paragraph is the last paragraph in the last section of the document. More... | |
bool | get_IsEndOfHeaderFooter () |
True if this paragraph is the last paragraph in the HeaderFooter (main text story) of a Section; false otherwise. More... | |
bool | get_IsEndOfSection () |
True if this paragraph is the last paragraph in the Body (main text story) of a Section; false otherwise. More... | |
bool | get_IsFormatRevision () |
Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled. More... | |
bool | get_IsInCell () |
True if this paragraph is an immediate child of Cell; false otherwise. More... | |
bool | get_IsInsertRevision () |
Returns true if this object was inserted in Microsoft Word while change tracking was enabled. More... | |
bool | get_IsListItem () |
True when the paragraph is an item in a bulleted or numbered list in original revision. More... | |
bool | get_IsMoveFromRevision () |
Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled. More... | |
bool | get_IsMoveToRevision () |
Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled. More... | |
SharedPtr< ListFormat > | get_ListFormat () |
Provides access to the list formatting properties of the paragraph. More... | |
SharedPtr< ListLabel > | get_ListLabel () |
Gets a ListLabel object that provides access to list numbering value and formatting for this paragraph. More... | |
NodeType | get_NodeType () const override |
Returns NodeType.Paragraph. More... | |
SharedPtr< Font > | get_ParagraphBreakFont () |
Provides access to the font formatting of the paragraph break character. More... | |
SharedPtr< ParagraphFormat > | get_ParagraphFormat () |
Provides access to the paragraph formatting properties. More... | |
SharedPtr< Section > | get_ParentSection () |
Retrieves the parent Section of the paragraph. More... | |
SharedPtr< Story > | get_ParentStory () |
Retrieves the parent section-level story that can be Body or HeaderFooter. More... | |
SharedPtr< RunCollection > | get_Runs () |
Provides access to the typed collection of pieces of text inside the paragraph. More... | |
ArrayPtr< SharedPtr< TabStop > > | GetEffectiveTabStops () |
Returns array of all tab stops applied to this paragraph, including applied indirectly by styles or lists. More... | |
String | GetText () override |
Gets the text of this paragraph including the end of paragraph character. More... | |
virtual const TypeInfo & | GetType () const override |
SharedPtr< Field > | InsertField (FieldType fieldType, bool updateField, const SharedPtr< Node > &refNode, bool isAfter) |
Inserts a field into this paragraph. More... | |
SharedPtr< Field > | InsertField (const String &fieldCode, const SharedPtr< Node > &refNode, bool isAfter) |
Inserts a field into this paragraph. More... | |
SharedPtr< Field > | InsertField (const String &fieldCode, const String &fieldValue, const SharedPtr< Node > &refNode, bool isAfter) |
Inserts a field into this paragraph. More... | |
virtual bool | Is (const TypeInfo &target) const override |
int32_t | JoinRunsWithSameFormatting () |
Joins runs with the same formatting in the paragraph. More... | |
![]() | |
SharedPtr< Node > | AppendChild (const SharedPtr< Node > &newChild) |
Adds the specified node to the end of the list of child nodes for this node. More... | |
SharedPtr< NodeCollection > | get_ChildNodes () |
Gets all immediate child nodes of this node. More... | |
int32_t | get_Count () |
Gets the number of immediate children of this node. More... | |
SharedPtr< Node > | get_FirstChild () const |
Gets the first child of the node. More... | |
bool | get_HasChildNodes () |
Returns true if this node has any child nodes. More... | |
bool | get_IsComposite () override |
Returns true as this node can have child nodes. More... | |
SharedPtr< Node > | get_LastChild () const |
Gets the last child of the node. More... | |
SharedPtr< Node > | GetChild (NodeType nodeType, int32_t index, bool isDeep) |
Returns an Nth child node that matches the specified type. More... | |
SharedPtr< NodeCollection > | GetChildNodes (NodeType nodeType, bool isDeep) |
Returns a live collection of child nodes that match the specified type. More... | |
SharedPtr< IEnumerator< SharedPtr< Node > > > | GetEnumerator () override |
Provides support for the for each style iteration over the child nodes of this node. More... | |
String | GetText () override |
Gets the text of this node and of all its children. More... | |
virtual const TypeInfo & | GetType () const override |
int32_t | IndexOf (const SharedPtr< Node > &child) |
Returns the index of the specified child node in the child node array. More... | |
SharedPtr< Node > | InsertAfter (const SharedPtr< Node > &newChild, const SharedPtr< Node > &refChild) |
Inserts the specified node immediately after the specified reference node. More... | |
SharedPtr< Node > | InsertBefore (const SharedPtr< Node > &newChild, const SharedPtr< Node > &refChild) |
Inserts the specified node immediately before the specified reference node. More... | |
virtual bool | Is (const TypeInfo &target) const override |
SharedPtr< Node > | PrependChild (const SharedPtr< Node > &newChild) |
Adds the specified node to the beginning of the list of child nodes for this node. More... | |
void | RemoveAllChildren () |
Removes all the child nodes of the current node. More... | |
SharedPtr< Node > | RemoveChild (const SharedPtr< Node > &oldChild) |
Removes the specified child node. More... | |
void | RemoveSmartTags () |
Removes all SmartTag descendant nodes of the current node. More... | |
SharedPtr< NodeList > | SelectNodes (const String &xpath) |
Selects a list of nodes matching the XPath expression. More... | |
SharedPtr< Node > | SelectSingleNode (const String &xpath) |
Selects the first Node that matches the XPath expression. More... | |
void | SetTemplateWeakPtr (uint32_t argument) override |
![]() | |
virtual bool | Accept (SharedPtr< DocumentVisitor > visitor)=0 |
Accepts a visitor. More... | |
SharedPtr< Node > | Clone (bool isCloneChildren) |
Creates a duplicate of the node. More... | |
int32_t | get_CustomNodeId () const |
Specifies custom node identifier. More... | |
virtual SharedPtr< DocumentBase > | get_Document () const |
Gets the document to which this node belongs. More... | |
virtual bool | get_IsComposite () |
Returns true if this node can contain other nodes. More... | |
SharedPtr< Node > | get_NextSibling () |
Gets the node immediately following this node. More... | |
virtual NodeType | get_NodeType () const =0 |
Gets the type of this node. More... | |
SharedPtr< CompositeNode > | get_ParentNode () |
Gets the immediate parent of this node. More... | |
SharedPtr< Node > | get_PreviousSibling () |
Gets the node immediately preceding this node. More... | |
SharedPtr< Range > | get_Range () |
Returns a Range object that represents the portion of a document that is contained in this node. More... | |
SharedPtr< CompositeNode > | GetAncestor (NodeType ancestorType) |
Gets the first ancestor of the specified NodeType. More... | |
template<typename T > | |
T | GetAncestorOf () |
virtual String | GetText () |
Gets the text of this node and of all its children. More... | |
virtual const TypeInfo & | GetType () const override |
virtual bool | Is (const TypeInfo &target) const override |
SharedPtr< Node > | NextPreOrder (const SharedPtr< Node > &rootNode) |
Gets next node according to the pre-order tree traversal algorithm. More... | |
SharedPtr< Node > | PreviousPreOrder (const SharedPtr< Node > &rootNode) |
Gets the previous node according to the pre-order tree traversal algorithm. More... | |
void | Remove () |
Removes itself from the parent. More... | |
void | set_CustomNodeId (int32_t value) |
Setter for get_CustomNodeId. More... | |
String | ToString (SaveFormat saveFormat) |
Exports the content of the node into a string in the specified format. More... | |
String | ToString (const SharedPtr< SaveOptions > &saveOptions) |
Exports the content of the node into a string using the specified save options. More... | |
Static Public Member Functions | |
static const TypeInfo & | Type () |
![]() | |
static const TypeInfo & | Type () |
![]() | |
static String | NodeTypeToString (NodeType nodeType) |
A utility method that converts a node type enum value into a user friendly string. More... | |
static const TypeInfo & | Type () |
Aspose::Words::Paragraph::Paragraph | ( | const System::SharedPtr< Aspose::Words::DocumentBase > & | doc | ) |
Initializes a new instance of the Paragraph class.
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. |
Shows how to construct an Aspose.Words document by hand.
|
overridevirtual |
Accepts a visitor.
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.
visitor | The visitor that will visit the nodes. |
Shows how to use a DocumentVisitor implementation to remove all hidden content from a document.
Implements Aspose::Words::Node.
System::SharedPtr< Aspose::Words::Fields::Field > Aspose::Words::Paragraph::AppendField | ( | Aspose::Words::Fields::FieldType | fieldType, |
bool | updateField | ||
) |
Appends a field to this paragraph.
fieldType | The type of the field to append. |
updateField | Specifies whether to update the field immediately. |
Shows various ways of appending fields to a paragraph.
System::SharedPtr< Aspose::Words::Fields::Field > Aspose::Words::Paragraph::AppendField | ( | const System::String & | fieldCode | ) |
Appends a field to this paragraph.
fieldCode | The field code to append (without curly braces). |
Shows various ways of appending fields to a paragraph.
System::SharedPtr< Aspose::Words::Fields::Field > Aspose::Words::Paragraph::AppendField | ( | const System::String & | fieldCode, |
const System::String & | fieldValue | ||
) |
Appends a field to this paragraph.
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. |
Shows various ways of appending fields to a paragraph.
bool Aspose::Words::Paragraph::get_BreakIsStyleSeparator | ( | ) |
True if this paragraph break is a Style Separator. A style separator allows one paragraph to consist of parts that have different paragraph styles.
Shows how to write text to the same line as a TOC heading and have it not show up in the TOC.
System::SharedPtr< Aspose::Words::FrameFormat > Aspose::Words::Paragraph::get_FrameFormat | ( | ) |
Provides access to the paragraph formatting properties.
Shows how to get information about formatting properties of paragraphs that are frames.
bool Aspose::Words::Paragraph::get_IsDeleteRevision | ( | ) |
Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
Shows how to work with revision paragraphs.
bool Aspose::Words::Paragraph::get_IsEndOfCell | ( | ) |
True if this paragraph is the last paragraph in a Cell; false otherwise.
Shows how to set a table to stay together on the same page.
bool Aspose::Words::Paragraph::get_IsEndOfDocument | ( | ) |
True if this paragraph is the last paragraph in the last section of the document.
Shows how to insert a paragraph into the document.
bool Aspose::Words::Paragraph::get_IsEndOfHeaderFooter | ( | ) |
True if this paragraph is the last paragraph in the HeaderFooter (main text story) of a Section; false otherwise.
Shows how to create a header and a footer.
bool Aspose::Words::Paragraph::get_IsEndOfSection | ( | ) |
True if this paragraph is the last paragraph in the Body (main text story) of a Section; false otherwise.
Shows how to insert the contents of one document to a bookmark in another document.
bool Aspose::Words::Paragraph::get_IsFormatRevision | ( | ) |
Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled.
Shows how to check whether a paragraph is a format revision.
bool Aspose::Words::Paragraph::get_IsInCell | ( | ) |
True if this paragraph is an immediate child of Cell; false otherwise.
Shows how to set a table to stay together on the same page.
bool Aspose::Words::Paragraph::get_IsInsertRevision | ( | ) |
Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
Shows how to work with revision paragraphs.
bool Aspose::Words::Paragraph::get_IsListItem | ( | ) |
True when the paragraph is an item in a bulleted or numbered list in original revision.
Shows how to nest a list inside another list.
bool Aspose::Words::Paragraph::get_IsMoveFromRevision | ( | ) |
Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
Shows how to check whether a paragraph is a move revision.
bool Aspose::Words::Paragraph::get_IsMoveToRevision | ( | ) |
Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
Shows how to check whether a paragraph is a move revision.
System::SharedPtr< Aspose::Words::Lists::ListFormat > Aspose::Words::Paragraph::get_ListFormat | ( | ) |
Provides access to the list formatting properties of the paragraph.
Shows how to output all paragraphs in a document that are list items.
System::SharedPtr< Aspose::Words::Lists::ListLabel > Aspose::Words::Paragraph::get_ListLabel | ( | ) |
Gets a ListLabel object that provides access to list numbering value and formatting for this paragraph.
Shows how to extract the list labels of all paragraphs that are list items.
|
overridevirtual |
Returns NodeType.Paragraph.
Shows how to traverse a composite node's tree of child nodes.
Implements Aspose::Words::Node.
System::SharedPtr< Aspose::Words::Font > Aspose::Words::Paragraph::get_ParagraphBreakFont | ( | ) |
Provides access to the font formatting of the paragraph break character.
Shows how to use a DocumentVisitor implementation to remove all hidden content from a document.
System::SharedPtr< Aspose::Words::ParagraphFormat > Aspose::Words::Paragraph::get_ParagraphFormat | ( | ) |
Provides access to the paragraph formatting properties.
Shows how to construct an Aspose.Words document by hand.
System::SharedPtr< Aspose::Words::Section > Aspose::Words::Paragraph::get_ParentSection | ( | ) |
Retrieves the parent Section of the paragraph.
Shows how to create a header and a footer.
System::SharedPtr< Aspose::Words::Story > Aspose::Words::Paragraph::get_ParentStory | ( | ) |
Retrieves the parent section-level story that can be Body or HeaderFooter.
Shows how to create a header and a footer.
System::SharedPtr< Aspose::Words::RunCollection > Aspose::Words::Paragraph::get_Runs | ( | ) |
Provides access to the typed collection of pieces of text inside the paragraph.
Shows how to determine the revision type of an inline node.
System::ArrayPtr< System::SharedPtr< Aspose::Words::TabStop > > Aspose::Words::Paragraph::GetEffectiveTabStops | ( | ) |
Returns array of all tab stops applied to this paragraph, including applied indirectly by styles or lists.
Shows how to set custom tab stops for a paragraph.
|
overridevirtual |
Gets the text of this paragraph including the end of paragraph character.
The text of all child nodes is concatenated and the end of paragraph character is appended as follows:
The returned string includes all control and special characters as described in ControlChar.
Shows how to add, update and delete child nodes in a CompositeNode's collection of children.
Reimplemented from Aspose::Words::CompositeNode.
|
overridevirtual |
Reimplemented from Aspose::Words::CompositeNode.
System::SharedPtr< Aspose::Words::Fields::Field > Aspose::Words::Paragraph::InsertField | ( | Aspose::Words::Fields::FieldType | fieldType, |
bool | updateField, | ||
const System::SharedPtr< Aspose::Words::Node > & | refNode, | ||
bool | isAfter | ||
) |
Inserts a field into this paragraph.
fieldType | The type of the field to insert. |
updateField | Specifies whether to update the field immediately. |
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. |
Shows various ways of adding fields to a paragraph.
System::SharedPtr< Aspose::Words::Fields::Field > Aspose::Words::Paragraph::InsertField | ( | const System::String & | fieldCode, |
const System::SharedPtr< Aspose::Words::Node > & | refNode, | ||
bool | isAfter | ||
) |
Inserts a field into this paragraph.
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. |
Shows various ways of adding fields to a paragraph.
System::SharedPtr< Aspose::Words::Fields::Field > Aspose::Words::Paragraph::InsertField | ( | const System::String & | fieldCode, |
const System::String & | fieldValue, | ||
const System::SharedPtr< Aspose::Words::Node > & | refNode, | ||
bool | isAfter | ||
) |
Inserts a field into this paragraph.
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. |
Shows various ways of adding fields to a paragraph.
|
overridevirtual |
Reimplemented from Aspose::Words::CompositeNode.
int32_t Aspose::Words::Paragraph::JoinRunsWithSameFormatting | ( | ) |
Joins runs with the same formatting in the paragraph.
Shows how to simplify paragraphs by merging superfluous runs.
|
static |