Base class for all nodes of a Word document.
A document is represented as a tree of nodes, similar to DOM or XmlDocument.
For more info see the Composite design pattern.
The Node class:
Shows how to clone a composite node.
Shows how to traverse through a composite node's collection of child nodes.
Shows how to remove all child nodes of a specific type from a composite node.
#include <Aspose.Words.Cpp/Node.h>
Public Member Functions | |
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 (SharedPtr< Node > rootNode) |
Gets next node according to the pre-order tree traversal algorithm. More... | |
SharedPtr< Node > | PreviousPreOrder (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 (SharedPtr< SaveOptions > saveOptions) |
Exports the content of the node into a string using the specified save options. More... | |
Static Public Member Functions | |
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 () |
|
pure virtual |
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.
Implemented in Aspose::Words::Tables::Table, Aspose::Words::Tables::Row, Aspose::Words::Tables::Cell, Aspose::Words::SubDocument, Aspose::Words::SpecialChar, Aspose::Words::Section, Aspose::Words::Run, Aspose::Words::Paragraph, Aspose::Words::Notes::Footnote, Aspose::Words::Math::OfficeMath, Aspose::Words::Markup::StructuredDocumentTagRangeStart, Aspose::Words::Markup::StructuredDocumentTagRangeEnd, Aspose::Words::Markup::StructuredDocumentTag, Aspose::Words::Markup::SmartTag, Aspose::Words::HeaderFooter, Aspose::Words::Fields::FormField, Aspose::Words::Fields::FieldStart, Aspose::Words::Fields::FieldSeparator, Aspose::Words::Fields::FieldEnd, Aspose::Words::EditableRangeStart, Aspose::Words::EditableRangeEnd, Aspose::Words::Drawing::Shape, Aspose::Words::Drawing::GroupShape, Aspose::Words::Document, Aspose::Words::CommentRangeStart, Aspose::Words::CommentRangeEnd, Aspose::Words::Comment, Aspose::Words::BuildingBlocks::GlossaryDocument, Aspose::Words::BuildingBlocks::BuildingBlock, Aspose::Words::BookmarkStart, Aspose::Words::BookmarkEnd, Aspose::Words::Body, and Aspose::Words::AbsolutePositionTab.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::Clone | ( | bool | isCloneChildren | ) |
Creates a duplicate of the node.
This method serves as a copy constructor for nodes. The cloned node has no parent, but belongs to the same document as the original node.
This method always performs a deep copy of the node. The isCloneChildren parameter specifies whether to perform copy all child nodes as well.
isCloneChildren | True to recursively clone the subtree under the specified node; false to clone only the node itself. |
Shows how to clone a composite node.
int32_t Aspose::Words::Node::get_CustomNodeId | ( | ) | const |
Specifies custom node identifier.
Default is zero.
This identifier can be set and used arbitrarily. For example, as a key to get external data.
Important note, specified value is not saved to an output file and exists only during the node lifetime.
Shows how to traverse through a composite node's collection of child nodes.
|
virtual |
Gets the document to which this node belongs.
The node always belongs to a document even if it has just been created and not yet added to the tree, or if it has been removed from the tree.
Shows how to create a node and set its owning document.
Reimplemented in Aspose::Words::DocumentBase.
|
virtual |
Returns true if this node can contain other nodes.
Shows how to traverse a composite node's tree of child nodes.
Reimplemented in Aspose::Words::CompositeNode.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::get_NextSibling | ( | ) |
Gets the node immediately following this node.
Shows how to traverse a composite node's tree of child nodes.
Shows how to use a node's NextSibling property to enumerate through its immediate children.
|
pure virtual |
Gets the type of this node.
Shows how to traverse a composite node's tree of child nodes.
Shows how to remove all child nodes of a specific type from a composite node.
Shows how to use a node's NextSibling property to enumerate through its immediate children.
Implemented in Aspose::Words::Tables::Table, Aspose::Words::Tables::Row, Aspose::Words::Tables::Cell, Aspose::Words::SubDocument, Aspose::Words::SpecialChar, Aspose::Words::Section, Aspose::Words::Run, Aspose::Words::Paragraph, Aspose::Words::Notes::Footnote, Aspose::Words::Math::OfficeMath, Aspose::Words::Markup::StructuredDocumentTagRangeStart, Aspose::Words::Markup::StructuredDocumentTagRangeEnd, Aspose::Words::Markup::StructuredDocumentTag, Aspose::Words::Markup::SmartTag, Aspose::Words::HeaderFooter, Aspose::Words::Fields::FormField, Aspose::Words::Fields::FieldStart, Aspose::Words::Fields::FieldSeparator, Aspose::Words::Fields::FieldEnd, Aspose::Words::EditableRangeStart, Aspose::Words::EditableRangeEnd, Aspose::Words::Drawing::Shape, Aspose::Words::Drawing::GroupShape, Aspose::Words::Document, Aspose::Words::CommentRangeStart, Aspose::Words::CommentRangeEnd, Aspose::Words::Comment, Aspose::Words::BuildingBlocks::GlossaryDocument, Aspose::Words::BuildingBlocks::BuildingBlock, Aspose::Words::BookmarkStart, Aspose::Words::BookmarkEnd, and Aspose::Words::Body.
System::SharedPtr<Aspose::Words::CompositeNode> Aspose::Words::Node::get_ParentNode | ( | ) |
Gets the immediate parent of this node.
If a node has just been created and not yet added to the tree, or if it has been removed from the tree, the parent is null.
Shows how to access a node's parent node.
Shows how to create a node and set its owning document.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::get_PreviousSibling | ( | ) |
Gets the node immediately preceding this node.
Shows how to use of methods of Node and CompositeNode to remove a section before the last section in the document.
System::SharedPtr<Aspose::Words::Range> Aspose::Words::Node::get_Range | ( | ) |
Returns a Range object that represents the portion of a document that is contained in this node.
Shows how to delete all the nodes from a range.
System::SharedPtr<Aspose::Words::CompositeNode> Aspose::Words::Node::GetAncestor | ( | Aspose::Words::NodeType | ancestorType | ) |
Gets the first ancestor of the specified NodeType.
ancestorType | The node type of the ancestor to retrieve. |
Shows how to find out if a tables are nested.
|
inline |
|
virtual |
Gets the text of this node and of all its children.
The returned string includes all control and special characters as described in ControlChar.
Shows how to use control characters.
Shows how to construct an Aspose.Words document by hand.
Reimplemented in Aspose::Words::Tables::Row, Aspose::Words::SpecialChar, Aspose::Words::Run, Aspose::Words::Paragraph, Aspose::Words::CompositeNode, and Aspose::Words::BookmarkStart.
|
overridevirtual |
Reimplemented from System::Object.
Reimplemented in Aspose::Words::Tables::Table, Aspose::Words::Tables::Row, Aspose::Words::Tables::Cell, Aspose::Words::SubDocument, Aspose::Words::Story, Aspose::Words::SpecialChar, Aspose::Words::Section, Aspose::Words::Run, Aspose::Words::Paragraph, Aspose::Words::Notes::Footnote, Aspose::Words::Math::OfficeMath, Aspose::Words::Markup::StructuredDocumentTagRangeStart, Aspose::Words::Markup::StructuredDocumentTagRangeEnd, Aspose::Words::Markup::StructuredDocumentTag, Aspose::Words::Markup::SmartTag, Aspose::Words::InlineStory, Aspose::Words::Inline, Aspose::Words::HeaderFooter, Aspose::Words::Fields::FormField, Aspose::Words::Fields::FieldStart, Aspose::Words::Fields::FieldSeparator, Aspose::Words::Fields::FieldEnd, Aspose::Words::Fields::FieldChar, Aspose::Words::EditableRangeStart, Aspose::Words::EditableRangeEnd, Aspose::Words::Drawing::ShapeBase, Aspose::Words::Drawing::Shape, Aspose::Words::Drawing::GroupShape, Aspose::Words::DocumentBase, Aspose::Words::Document, Aspose::Words::CompositeNode, Aspose::Words::CommentRangeStart, Aspose::Words::CommentRangeEnd, Aspose::Words::Comment, Aspose::Words::BuildingBlocks::GlossaryDocument, Aspose::Words::BuildingBlocks::BuildingBlock, Aspose::Words::BookmarkStart, Aspose::Words::BookmarkEnd, Aspose::Words::Body, and Aspose::Words::AbsolutePositionTab.
|
overridevirtual |
Reimplemented from System::Object.
Reimplemented in Aspose::Words::Tables::Table, Aspose::Words::Tables::Row, Aspose::Words::Tables::Cell, Aspose::Words::SubDocument, Aspose::Words::Story, Aspose::Words::SpecialChar, Aspose::Words::Section, Aspose::Words::Run, Aspose::Words::Paragraph, Aspose::Words::Notes::Footnote, Aspose::Words::Math::OfficeMath, Aspose::Words::Markup::StructuredDocumentTagRangeStart, Aspose::Words::Markup::StructuredDocumentTagRangeEnd, Aspose::Words::Markup::StructuredDocumentTag, Aspose::Words::Markup::SmartTag, Aspose::Words::InlineStory, Aspose::Words::Inline, Aspose::Words::HeaderFooter, Aspose::Words::Fields::FormField, Aspose::Words::Fields::FieldStart, Aspose::Words::Fields::FieldSeparator, Aspose::Words::Fields::FieldEnd, Aspose::Words::Fields::FieldChar, Aspose::Words::EditableRangeStart, Aspose::Words::EditableRangeEnd, Aspose::Words::Drawing::ShapeBase, Aspose::Words::Drawing::Shape, Aspose::Words::Drawing::GroupShape, Aspose::Words::DocumentBase, Aspose::Words::Document, Aspose::Words::CompositeNode, Aspose::Words::CommentRangeStart, Aspose::Words::CommentRangeEnd, Aspose::Words::Comment, Aspose::Words::BuildingBlocks::GlossaryDocument, Aspose::Words::BuildingBlocks::BuildingBlock, Aspose::Words::BookmarkStart, Aspose::Words::BookmarkEnd, Aspose::Words::Body, and Aspose::Words::AbsolutePositionTab.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::NextPreOrder | ( | System::SharedPtr< Aspose::Words::Node > | rootNode | ) |
Gets next node according to the pre-order tree traversal algorithm.
rootNode | The top node (limit) of traversal. |
Shows how to traverse the document's node tree using the pre-order traversal algorithm, and delete any encountered shape with an image.
|
static |
A utility method that converts a node type enum value into a user friendly string.
Shows how to traverse a composite node's tree of child nodes.
Shows how to use a node's NextSibling property to enumerate through its immediate children.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::PreviousPreOrder | ( | System::SharedPtr< Aspose::Words::Node > | rootNode | ) |
Gets the previous node according to the pre-order tree traversal algorithm.
rootNode | The top node (limit) of traversal. |
Shows how to traverse the document's node tree using the pre-order traversal algorithm, and delete any encountered shape with an image.
void Aspose::Words::Node::Remove | ( | ) |
Removes itself from the parent.
Shows how to delete all shapes with images from a document.
Shows how to remove all child nodes of a specific type from a composite node.
void Aspose::Words::Node::set_CustomNodeId | ( | int32_t | value | ) |
Setter for Aspose::Words::Node::get_CustomNodeId.
System::String Aspose::Words::Node::ToString | ( | Aspose::Words::SaveFormat | saveFormat | ) |
Exports the content of the node into a string in the specified format.
Shows the difference between calling the GetText and ToString methods on a node.
Shows how to extract the list labels of all paragraphs that are list items.
Exports the content of a node to String in HTML format.
System::String Aspose::Words::Node::ToString | ( | System::SharedPtr< Aspose::Words::Saving::SaveOptions > | saveOptions | ) |
Exports the content of the node into a string using the specified save options.
saveOptions | Specifies the options that control how the node is saved. |
Exports the content of a node to String in HTML format.
|
static |