Aspose::Words::Node Class Referenceabstract

Detailed Description

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:

  • Defines the child node interface.
  • Defines the interface for visiting nodes.
  • Provides default cloning capability.
  • Implements parent node and owner document mechanisms.
  • Implements access to sibling nodes.

#include <Aspose.Words.Cpp/Model/Nodes/Node.h>

+ Inheritance diagram for Aspose::Words::Node:

Public Member Functions

virtual bool Accept (SharedPtr< DocumentVisitor > visitor)=0
 Accepts a visitor. More...
 
SharedPtr< NodeClone (bool isCloneChildren)
 
virtual SharedPtr< DocumentBaseget_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< Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
virtual NodeType get_NodeType () const =0
 Gets the type of this node. More...
 
SharedPtr< CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
SharedPtr< Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
SharedPtr< Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
SharedPtr< CompositeNodeGetAncestor (NodeType ancestorType)
 Gets the first ancestor of the specified NodeType. More...
 
template<typename T >
GetAncestorOf ()
 
virtual String GetText ()
 Gets the text of this node and of all its children. More...
 
SharedPtr< NodeNextPreOrder (SharedPtr< Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
SharedPtr< NodePreviousPreOrder (SharedPtr< Node > rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
void Remove ()
 Removes itself from the parent. 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...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
virtual ASPOSECPP_SHARED_API const TypeInfoGetType () const
 
virtual ASPOSECPP_SHARED_API bool Is (const TypeInfo &targetType) const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

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 Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 

Member Function Documentation

◆ Accept()

virtual bool Aspose::Words::Node::Accept ( System::SharedPtr< Aspose::Words::DocumentVisitor visitor)
pure virtual

◆ Clone()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::Clone ( bool  isCloneChildren)

◆ get_Document()

virtual System::SharedPtr<Aspose::Words::DocumentBase> Aspose::Words::Node::get_Document ( ) const
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.

Reimplemented in Aspose::Words::DocumentBase.

◆ get_IsComposite()

virtual bool Aspose::Words::Node::get_IsComposite ( )
virtual

Returns true if this node can contain other nodes.

This method returns false as Node cannot have child nodes.

Reimplemented in Aspose::Words::CompositeNode.

◆ get_NextSibling()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::get_NextSibling ( )

Gets the node immediately following this node.

If there is no next node, a null is returned.

◆ get_NodeType()

◆ get_ParentNode()

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.

◆ get_PreviousSibling()

System::SharedPtr<Aspose::Words::Node> Aspose::Words::Node::get_PreviousSibling ( )

Gets the node immediately preceding this node.

If there is no preceding node, a null is returned.

◆ get_Range()

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.

◆ GetAncestor()

System::SharedPtr<Aspose::Words::CompositeNode> Aspose::Words::Node::GetAncestor ( Aspose::Words::NodeType  ancestorType)

Gets the first ancestor of the specified NodeType.

Parameters
ancestorTypeThe node type of the ancestor to retrieve.
Returns
The ancestor of the specified type or null if no ancestor of this type was found.

◆ GetAncestorOf()

template<typename T >
T Aspose::Words::Node::GetAncestorOf ( )
inline

◆ GetText()

virtual System::String Aspose::Words::Node::GetText ( )
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.

Reimplemented in Aspose::Words::Paragraph, Aspose::Words::CompositeNode, Aspose::Words::Tables::Row, Aspose::Words::Run, Aspose::Words::BookmarkStart, and Aspose::Words::SpecialChar.

◆ NextPreOrder()

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.

Parameters
rootNodeThe top node (limit) of traversal.
Returns
Next node in pre-order order. Null if reached the rootNode.

◆ NodeTypeToString()

static System::String Aspose::Words::Node::NodeTypeToString ( Aspose::Words::NodeType  nodeType)
static

A utility method that converts a node type enum value into a user friendly string.

◆ PreviousPreOrder()

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.

Parameters
rootNodeThe top node (limit) of traversal.
Returns
Previous node in pre-order order. Null if reached the rootNode.

◆ Remove()

void Aspose::Words::Node::Remove ( )

Removes itself from the parent.

◆ ToString() [1/2]

System::String Aspose::Words::Node::ToString ( Aspose::Words::SaveFormat  saveFormat)

Exports the content of the node into a string in the specified format.

Returns
The content of the node in the specified format.

◆ ToString() [2/2]

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.

Parameters
saveOptionsSpecifies the options that control how the node is saved.
Returns
The content of the node in the specified format.