Base class for nodes that can contain other nodes. More...
#include "Aspose.Words.Cpp/Model/Nodes/CompositeNode.h"
Inherits Aspose::Words::Node, System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >, and INodeCollection.
Inherited by Aspose::Words::BuildingBlocks::BuildingBlock, Aspose::Words::DocumentBase, Aspose::Words::Drawing::ShapeBase, Aspose::Words::InlineStory, Aspose::Words::Markup::SmartTag, Aspose::Words::Markup::StructuredDocumentTag, Aspose::Words::Math::OfficeMath, Aspose::Words::Paragraph, Aspose::Words::Section, Aspose::Words::Story, Aspose::Words::Tables::Cell, Aspose::Words::Tables::Row, and Aspose::Words::Tables::Table.
Public Member Functions | |
virtual bool | get_IsComposite () |
Returns true as this node can have child nodes. More... | |
bool | get_HasChildNodes () |
Returns true if this node has any child nodes. More... | |
System::SharedPtr< Aspose::Words::NodeCollection > | get_ChildNodes () |
Gets all immediate child nodes of this node. More... | |
System::SharedPtr< Aspose::Words::Node > | get_FirstChild () const |
Gets the first child of the node. More... | |
System::SharedPtr< Aspose::Words::Node > | get_LastChild () const |
Gets the last child of the node. More... | |
int32_t | get_Count () |
Gets the number of immediate children of this node. More... | |
System::SharedPtr< Aspose::Words::CompositeNode > | get_Container () |
virtual | ~CompositeNode () |
virtual System::String | GetText () |
Gets the text of this node and of all its children. More... | |
System::SharedPtr< Aspose::Words::NodeCollection > | GetChildNodes (Aspose::Words::NodeType nodeType, bool isDeep) |
Returns a live collection of child nodes that match the specified type. More... | |
System::SharedPtr< Aspose::Words::Node > | GetChild (Aspose::Words::NodeType nodeType, int32_t index, bool isDeep) |
Returns an Nth child node that matches the specified type. More... | |
System::SharedPtr< Aspose::Words::NodeList > | SelectNodes (System::String xpath) |
Selects a list of nodes matching the XPath expression. More... | |
System::SharedPtr< Aspose::Words::Node > | SelectSingleNode (System::String xpath) |
Selects the first Node that matches the XPath expression. More... | |
System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< Aspose::Words::Node > > > | GetEnumerator () |
Provides support for the for each style iteration over the child nodes of this node. More... | |
System::SharedPtr< Aspose::Words::Node > | AppendChild (System::SharedPtr< Aspose::Words::Node > newChild) |
Adds the specified node to the end of the list of child nodes for this node. More... | |
System::SharedPtr< Aspose::Words::Node > | PrependChild (System::SharedPtr< Aspose::Words::Node > newChild) |
Adds the specified node to the beginning of the list of child nodes for this node. More... | |
System::SharedPtr< Aspose::Words::Node > | InsertAfter (System::SharedPtr< Aspose::Words::Node > newChild, System::SharedPtr< Aspose::Words::Node > refChild) |
Inserts the specified node immediately after the specified reference node. More... | |
System::SharedPtr< Aspose::Words::Node > | InsertBefore (System::SharedPtr< Aspose::Words::Node > newChild, System::SharedPtr< Aspose::Words::Node > refChild) |
Inserts the specified node immediately before the specified reference node. More... | |
System::SharedPtr< Aspose::Words::Node > | RemoveChild (System::SharedPtr< Aspose::Words::Node > oldChild) |
Removes the specified child node. More... | |
void | RemoveAllChildren () |
Removes all the child nodes of the current node. More... | |
void | RemoveSmartTags () |
Removes all Aspose::Words::Markup::SmartTag descendant nodes of the current node. More... | |
int32_t | IndexOf (System::SharedPtr< Aspose::Words::Node > child) |
Returns the index of the specified child node in the child node array. More... | |
System::SharedPtr< Aspose::Words::Node > | GetNextMatchingNode (System::SharedPtr< Aspose::Words::Node > &curNode) |
![]() | |
virtual Aspose::Words::NodeType | get_NodeType () const =0 |
Gets the type of this node. More... | |
System::SharedPtr< Aspose::Words::CompositeNode > | get_ParentNode () |
Gets the immediate parent of this node. More... | |
virtual System::SharedPtr< Aspose::Words::DocumentBase > | get_Document () |
Gets the document to which this node belongs. More... | |
System::SharedPtr< Aspose::Words::Node > | get_PreviousSibling () |
Gets the node immediately preceding this node. More... | |
System::SharedPtr< Aspose::Words::Node > | get_NextSibling () |
Gets the node immediately following this node. More... | |
System::SharedPtr< Aspose::Words::Range > | get_Range () |
Returns a Range object that represents the portion of a document that is contained in this node. More... | |
System::SharedPtr< Aspose::Words::Node > | Clone (bool isCloneChildren) |
virtual bool | Accept (System::SharedPtr< Aspose::Words::DocumentVisitor > visitor)=0 |
Accepts a visitor. More... | |
template<typename T > | |
T | GetAncestorOf () |
System::SharedPtr< Aspose::Words::CompositeNode > | GetAncestor (Aspose::Words::NodeType ancestorType) |
Gets the first ancestor of the specified Aspose::Words::NodeType. More... | |
void | Remove () |
Removes itself from the parent. More... | |
System::SharedPtr< Aspose::Words::Node > | NextPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode) |
Gets next node according to the pre-order tree traversal algorithm. More... | |
System::SharedPtr< Aspose::Words::Node > | PreviousPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode) |
Gets the previous node according to the pre-order tree traversal algorithm. More... | |
System::String | ToString (Aspose::Words::SaveFormat saveFormat) |
Exports the content of the node into a string in the specified format. More... | |
System::String | ToString (System::SharedPtr< Aspose::Words::Saving::SaveOptions > saveOptions) |
Exports the content of the node into a string using the specified save options. More... | |
![]() | |
Object () | |
Creates object. Initializes all internal data structures. More... | |
virtual | ~Object () |
Destroys object. Frees all internal data structures. More... | |
Object (Object const &x) | |
Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More... | |
Object & | operator= (Object const &x) |
Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More... | |
Object * | SharedRefAdded () |
Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More... | |
int | SharedRefRemovedSafe () |
Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More... | |
int | RemovedSharedRefs (int count) |
Decreases shared reference count by specified value. More... | |
Detail::SmartPtrCounter * | WeakRefAdded () |
Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More... | |
void | WeakRefRemoved () |
Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More... | |
Detail::SmartPtrCounter * | GetCounter () |
Gets reference counter data structure associated with the object. More... | |
int | SharedCount () const |
Gets current value of shared refernce counter. More... | |
void | Lock () |
Implements C# lock() statement locking. Call directly or use LockContext sentry object. More... | |
void | Unlock () |
Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More... | |
virtual bool | Equals (ptr obj) |
Compares objects using C# Object.Equals semantics. More... | |
virtual int | GetHashCode () const |
Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More... | |
virtual String | ToString () ASPOSE_CONST |
Analog of C# Object.ToString() method. Enables converting custom objects to string. More... | |
virtual ptr | MemberwiseClone () const |
Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More... | |
virtual const TypeInfo & | GetType () const |
Gets actual type of object. Analog of C# System.Object.GetType() call. More... | |
virtual bool | Is (const TypeInfo &targetType) const |
Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More... | |
virtual void | SetTemplateWeakPtr (unsigned int argument) |
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More... | |
Additional Inherited Members | |
![]() | |
typedef SmartPtr< Object > | ptr |
Alias for smart pointer type. More... | |
typedef System::Details::SharedMembersType | shared_members_type |
structure to keep list of shared pointers contained in object. More... | |
![]() | |
typedef IEnumerator< System::SharedPtr< Aspose::Words::Node > > | IEnumeratorType |
Enumerator type. More... | |
![]() | |
static System::String | NodeTypeToString (Aspose::Words::NodeType nodeType) |
A utility method that converts a node type enum value into a user friendly string. More... | |
![]() | |
static bool | ReferenceEquals (ptr const &objA, ptr const &objB) |
Compares objects by reference. More... | |
template<typename T > | |
static std::enable_if<!IsSmartPtr< T >::value, bool >::type | ReferenceEquals (T const &objA, T const &objB) |
Compares objects by reference. More... | |
template<typename T > | |
static std::enable_if<!IsSmartPtr< T >::value, bool >::type | ReferenceEquals (T const &objA, std::nullptr_t) |
Reference-compares value type object with nullptr. More... | |
template<typename T1 , typename T2 > | |
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type | Equals (T1 const &objA, T2 const &objB) |
Compares reference type objects in C# style. More... | |
template<typename T1 , typename T2 > | |
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type | Equals (T1 const &objA, T2 const &objB) |
Compares value type objects in C# style. More... | |
static const TypeInfo & | Type () |
Impleemnts C# typeof(System.Object) construct. More... | |
template<> | |
bool | Equals (float const &objA, float const &objB) |
template<> | |
bool | Equals (double const &objA, double const &objB) |
template<> | |
bool | ReferenceEquals (String const &str, std::nullptr_t) |
template<> | |
bool | ReferenceEquals (String const &str1, String const &str2) |
Base class for nodes that can contain other nodes.
A document is represented as a tree of nodes, similar to DOM or XmlDocument.
For more info see the Composite design pattern.
The Aspose::Words::CompositeNode class:
|
virtual |
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::AppendChild | ( | System::SharedPtr< Aspose::Words::Node > | newChild | ) |
Adds the specified node to the end of the list of child nodes for this node.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use Aspose::Words::DocumentBase::ImportNode(System::SharedPtr<Aspose::Words::Node>, bool, Aspose::Words::ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild | The node to add. |
System::SharedPtr<Aspose::Words::NodeCollection> Aspose::Words::CompositeNode::get_ChildNodes | ( | ) |
Gets all immediate child nodes of this node.
Note, Aspose::Words::CompositeNode::get_ChildNodes is equivalent to calling GetChildNodes(NodeType.Any, false)
and creates and returns a new collection every time it is accessed.
If there are no child nodes, this property returns an empty collection.
System::SharedPtr<Aspose::Words::CompositeNode> Aspose::Words::CompositeNode::get_Container | ( | ) |
int32_t Aspose::Words::CompositeNode::get_Count | ( | ) |
Gets the number of immediate children of this node.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::get_FirstChild | ( | ) | const |
Gets the first child of the node.
If there is no first child node, a null is returned.
bool Aspose::Words::CompositeNode::get_HasChildNodes | ( | ) |
Returns true if this node has any child nodes.
|
virtual |
Returns true as this node can have child nodes.
Reimplemented from Aspose::Words::Node.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::get_LastChild | ( | ) | const |
Gets the last child of the node.
If there is no last child node, a null is returned.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::GetChild | ( | Aspose::Words::NodeType | nodeType, |
int32_t | index, | ||
bool | isDeep | ||
) |
Returns an Nth child node that matches the specified type.
If index is out of range, a null is returned.
nodeType | Specifies the type of the child node. |
index | Zero based index of the child node to select. Negative indexes are also allowed and indicate access from the end, that is -1 means the last node. |
isDeep | True to select from all child nodes recursively. False to select only among immediate children. See remarks for more info. |
Note that markup nodes (Aspose::Words::NodeType::StructuredDocumentTag and Aspose::Words::NodeType::SmartTag) are traversed even when isDeep = false and GetChild is invoked for non-markup node type. For example if the first run in a para is wrapped in a StructuredDocumentTag, it will still be returned by GetChild(NodeType.Run, 0, false).
System::SharedPtr<Aspose::Words::NodeCollection> Aspose::Words::CompositeNode::GetChildNodes | ( | Aspose::Words::NodeType | nodeType, |
bool | isDeep | ||
) |
Returns a live collection of child nodes that match the specified type.
The collection of nodes returned by this method is always live.
A live collection is always in sync with the document. For example, if you selected all sections in a document and enumerate through the collection deleting the sections, the section is removed from the collection immediately when it is removed from the document.
nodeType | Specifies the type of nodes to select. |
isDeep | True to select from all child nodes recursively. False to select only among immediate children. |
|
virtual |
Provides support for the for each style iteration over the child nodes of this node.
Implements System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::GetNextMatchingNode | ( | System::SharedPtr< Aspose::Words::Node > & | curNode | ) |
|
virtual |
Gets the text of this node and of all its children.
The returned string includes all control and special characters as described in Aspose::Words::ControlChar.
Reimplemented from Aspose::Words::Node.
Reimplemented in Aspose::Words::Paragraph, and Aspose::Words::Tables::Row.
int32_t Aspose::Words::CompositeNode::IndexOf | ( | System::SharedPtr< Aspose::Words::Node > | child | ) |
Returns the index of the specified child node in the child node array.
Returns -1 if the node is not found in the child nodes.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::InsertAfter | ( | System::SharedPtr< Aspose::Words::Node > | newChild, |
System::SharedPtr< Aspose::Words::Node > | refChild | ||
) |
Inserts the specified node immediately after the specified reference node.
If refChild is null, inserts newChild at the beginning of the list of child nodes.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use Aspose::Words::DocumentBase::ImportNode(System::SharedPtr<Aspose::Words::Node>, bool, Aspose::Words::ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild | The Node to insert. |
refChild | The Node that is the reference node. The newNode is placed after the refNode. |
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::InsertBefore | ( | System::SharedPtr< Aspose::Words::Node > | newChild, |
System::SharedPtr< Aspose::Words::Node > | refChild | ||
) |
Inserts the specified node immediately before the specified reference node.
If refChild is null, inserts newChild at the end of the list of child nodes.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use Aspose::Words::DocumentBase::ImportNode(System::SharedPtr<Aspose::Words::Node>, bool, Aspose::Words::ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild | The Node to insert. |
refChild | The Node that is the reference node. The newChild is placed before this node. |
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::PrependChild | ( | System::SharedPtr< Aspose::Words::Node > | newChild | ) |
Adds the specified node to the beginning of the list of child nodes for this node.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use Aspose::Words::DocumentBase::ImportNode(System::SharedPtr<Aspose::Words::Node>, bool, Aspose::Words::ImportFormatMode) to import the node to the current document. The imported node can then be inserted into the current document.
newChild | The node to add. |
void Aspose::Words::CompositeNode::RemoveAllChildren | ( | ) |
Removes all the child nodes of the current node.
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::RemoveChild | ( | System::SharedPtr< Aspose::Words::Node > | oldChild | ) |
Removes the specified child node.
The parent of oldChild is set to null after the node is removed.
oldChild | The node to remove. |
void Aspose::Words::CompositeNode::RemoveSmartTags | ( | ) |
Removes all Aspose::Words::Markup::SmartTag descendant nodes of the current node.
This method does not remove the content of the smart tags.
System::SharedPtr<Aspose::Words::NodeList> Aspose::Words::CompositeNode::SelectNodes | ( | System::String | xpath | ) |
Selects a list of nodes matching the XPath expression.
Only expressions with element names are supported at the moment. Expressions that use attribute names are not supported.
xpath | The XPath expression. |
System::SharedPtr<Aspose::Words::Node> Aspose::Words::CompositeNode::SelectSingleNode | ( | System::String | xpath | ) |
Selects the first Node that matches the XPath expression.
Only expressions with element names are supported at the moment. Expressions that use attribute names are not supported.
xpath | The XPath expression. |