Aspose::Words::Comment Class Referencefinal

Represents a container for text of a comment. More...

#include "Aspose.Words.Cpp/Model/Text/Comment.h"

Inherits Aspose::Words::InlineStory, INodeWithAnnotationId, and IMoveTrackableNode.

Public Member Functions

virtual Aspose::Words::NodeType get_NodeType () const
 Returns NodeType.Comment. More...
 
virtual Aspose::Words::StoryType get_StoryType ()
 Returns StoryType.Comments. More...
 
int32_t get_Id () const
 Gets the comment identifier. More...
 
int32_t get_IdInternal ()
 
void set_IdInternal (int32_t value)
 
int32_t get_ParentIdInternal ()
 
void set_ParentIdInternal (int32_t value)
 
System::String get_Initial () const
 Returns or sets the initials of the user associated with a specific comment. More...
 
void set_Initial (System::String value)
 Setter for Aspose::Words::Comment::get_Initial. More...
 
System::DateTime get_DateTime () const
 Gets the date and time that the comment was made. More...
 
void set_DateTime (System::DateTime value)
 Setter for Aspose::Words::Comment::get_DateTime. More...
 
System::String get_Author () const
 Returns or sets the author name for a comment. More...
 
void set_Author (System::String value)
 Setter for Aspose::Words::Comment::get_Author. More...
 
System::SharedPtr< Aspose::Words::Commentget_Ancestor ()
 Returns the parent Comment object. Returns null for top-level comments. More...
 
System::SharedPtr< Aspose::Words::CommentCollectionget_Replies ()
 Returns a collection of Aspose::Words::Comment objects that are immediate children of the specified comment. More...
 
bool get_Done () const
 Gets or sets flag indicating that the comment has been marked done. More...
 
void set_Done (bool value)
 Setter for Aspose::Words::Comment::get_Done. More...
 
System::SharedPtr< Aspose::Words::Revisions::MoveRevision > get_MoveFromRevision ()
 
void set_MoveFromRevision (System::SharedPtr< Aspose::Words::Revisions::MoveRevision > value)
 
System::SharedPtr< Aspose::Words::Revisions::MoveRevision > get_MoveToRevision ()
 
void set_MoveToRevision (System::SharedPtr< Aspose::Words::Revisions::MoveRevision > value)
 
 Comment (System::SharedPtr< Aspose::Words::DocumentBase > doc)
 Initializes a new instance of the Comment class. More...
 
 Comment (System::SharedPtr< Aspose::Words::DocumentBase > doc, System::String author, System::String initial, System::DateTime dateTime)
 Initializes a new instance of the Comment class. More...
 
virtual bool Accept (System::SharedPtr< Aspose::Words::DocumentVisitor > visitor)
 Accepts a visitor. More...
 
System::SharedPtr< Aspose::Words::CommentAddReply (System::String author, System::String initial, System::DateTime dateTime, System::String text)
 Adds a reply to this comment. More...
 
void RemoveReply (System::SharedPtr< Aspose::Words::Comment > reply)
 Removes the specified reply to this comment. More...
 
void RemoveAllReplies ()
 Removes all replies to this comment. More...
 
void SetText (System::String text)
 This is a convenience method that allows to easily set text of the comment. More...
 
- Public Member Functions inherited from Aspose::Words::InlineStory
System::SharedPtr< Aspose::Words::Paragraphget_ParentParagraph ()
 Retrieves the parent Aspose::Words::Paragraph of this node. More...
 
System::SharedPtr< Aspose::Words::Paragraphget_FirstParagraph ()
 Gets the first paragraph in the story. More...
 
System::SharedPtr< Aspose::Words::Paragraphget_LastParagraph ()
 Gets the last paragraph in the story. More...
 
System::SharedPtr< Aspose::Words::ParagraphCollectionget_Paragraphs ()
 Gets a collection of paragraphs that are immediate children of the story. More...
 
System::SharedPtr< Aspose::Words::Tables::TableCollectionget_Tables ()
 Gets a collection of tables that are immediate children of the story. More...
 
bool get_IsInsertRevision ()
 Returns true if this object was inserted in Microsoft Word while change tracking was enabled. More...
 
bool get_IsDeleteRevision ()
 Returns true if this object was deleted in Microsoft Word while change tracking was enabled. 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...
 
System::SharedPtr< Aspose::Words::Fontget_Font ()
 Provides access to the font formatting of the anchor character of this object. More...
 
System::SharedPtr< Aspose::Words::RunPr > get_RunPr_IInline ()
 
void set_RunPr_IInline (System::SharedPtr< Aspose::Words::RunPr > value)
 
System::SharedPtr< Aspose::Words::Paragraphget_ParentParagraph_IInline ()
 
System::SharedPtr< Aspose::Words::DocumentBaseget_Document_IInline ()
 
void EnsureMinimum ()
 If the last child is not a paragraph, creates and appends one empty paragraph. More...
 
System::SharedPtr< Aspose::Words::RunPr > GetExpandedRunPr_IInline (Aspose::Words::RunPrExpandFlags flags)
 
System::SharedPtr< System::ObjectGetDirectRunAttr (int32_t fontAttr)
 
System::SharedPtr< System::ObjectFetchInheritedRunAttr (int32_t fontAttr)
 
void SetRunAttr (int32_t fontAttr, System::SharedPtr< System::Object > value)
 
void RemoveRunAttr (int32_t key)
 
void ClearRunAttrs ()
 
- Public Member Functions inherited from Aspose::Words::CompositeNode
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::NodeCollectionget_ChildNodes ()
 Gets all immediate child nodes of this node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_FirstChild () const
 Gets the first child of the node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_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::CompositeNodeget_Container ()
 
virtual System::String GetText ()
 Gets the text of this node and of all its children. More...
 
System::SharedPtr< Aspose::Words::NodeCollectionGetChildNodes (Aspose::Words::NodeType nodeType, bool isDeep)
 Returns a live collection of child nodes that match the specified type. More...
 
System::SharedPtr< Aspose::Words::NodeGetChild (Aspose::Words::NodeType nodeType, int32_t index, bool isDeep)
 Returns an Nth child node that matches the specified type. More...
 
System::SharedPtr< Aspose::Words::NodeListSelectNodes (System::String xpath)
 Selects a list of nodes matching the XPath expression. More...
 
System::SharedPtr< Aspose::Words::NodeSelectSingleNode (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::NodeAppendChild (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::NodePrependChild (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::NodeInsertAfter (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::NodeInsertBefore (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::NodeRemoveChild (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::NodeGetNextMatchingNode (System::SharedPtr< Aspose::Words::Node > &curNode)
 
- Public Member Functions inherited from Aspose::Words::Node
System::SharedPtr< Aspose::Words::CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
virtual System::SharedPtr< Aspose::Words::DocumentBaseget_Document ()
 Gets the document to which this node belongs. More...
 
System::SharedPtr< Aspose::Words::Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
System::SharedPtr< Aspose::Words::Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
System::SharedPtr< Aspose::Words::Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
System::SharedPtr< Aspose::Words::NodeClone (bool isCloneChildren)
 
template<typename T >
GetAncestorOf ()
 
System::SharedPtr< Aspose::Words::CompositeNodeGetAncestor (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::NodeNextPreOrder (System::SharedPtr< Aspose::Words::Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
System::SharedPtr< Aspose::Words::NodePreviousPreOrder (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...
 
- Public Member Functions inherited from System::Object
 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...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 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 TypeInfoGetType () 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...
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Public Types inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
typedef IEnumerator< System::SharedPtr< Aspose::Words::Node > > IEnumeratorType
 Enumerator type. More...
 
- Static Public Member Functions inherited from Aspose::Words::Node
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 Public Member Functions inherited from System::Object
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 TypeInfoType ()
 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)
 

Detailed Description

Represents a container for text of a comment.

A comment is an annotation which is anchored to a region of text or to a position in text. A comment can contain an arbitrary amount of block-level content.

If a Aspose::Words::Comment object occurs on its own, the comment is anchored to the position of the Aspose::Words::Comment object.

To anchor a comment to a region of text three objects are required: Aspose::Words::Comment, Aspose::Words::CommentRangeStart and Aspose::Words::CommentRangeEnd. All three objects need to share the same Aspose::Words::Comment::get_Id value.

Aspose::Words::Comment is an inline-level node and can only be a child of Aspose::Words::Paragraph.

Aspose::Words::Comment can contain Aspose::Words::Paragraph and Aspose::Words::Tables::Table child nodes.

See also
Aspose::Words::CommentRangeStart, Aspose::Words::CommentRangeEnd

Constructor & Destructor Documentation

◆ Comment() [1/2]

Aspose::Words::Comment::Comment ( System::SharedPtr< Aspose::Words::DocumentBase doc)

Initializes a new instance of the Comment class.

When Comment is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.

To append Comment to the document use InsertAfter or InsertBefore on the paragraph where you want the comment inserted.

After creating a comment, don't forget to set its Aspose::Words::Comment::get_Author, Aspose::Words::Comment::get_Initial and Aspose::Words::Comment::get_DateTime properties.

Parameters
docThe owner document.

◆ Comment() [2/2]

Aspose::Words::Comment::Comment ( System::SharedPtr< Aspose::Words::DocumentBase doc,
System::String  author,
System::String  initial,
System::DateTime  dateTime 
)

Initializes a new instance of the Comment class.

Parameters
docThe owner document.
authorThe author name for the comment. Cannot be null.
initialThe author initials for the comment. Cannot be null.
dateTimeThe date and time for the comment.

Member Function Documentation

◆ Accept()

virtual bool Aspose::Words::Comment::Accept ( System::SharedPtr< Aspose::Words::DocumentVisitor visitor)
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.

Parameters
visitorThe visitor that will visit the nodes.
Returns
True if all nodes were visited; false if DocumentVisitor stopped the operation before visiting all nodes.

Calls Aspose::Words::DocumentVisitor::VisitCommentStart(System::SharedPtr<Aspose::Words::Comment>), then calls Aspose::Words::Node::Accept(System::SharedPtr<Aspose::Words::DocumentVisitor>) for all child nodes of the comment and calls Aspose::Words::DocumentVisitor::VisitCommentEnd(System::SharedPtr<Aspose::Words::Comment>) at the end.

Implements Aspose::Words::Node.

◆ AddReply()

System::SharedPtr<Aspose::Words::Comment> Aspose::Words::Comment::AddReply ( System::String  author,
System::String  initial,
System::DateTime  dateTime,
System::String  text 
)

Adds a reply to this comment.

Parameters
authorThe author name for the reply.
initialThe author initials for the reply.
dateTimeThe date and time for the reply.
textThe reply text.
Returns
The created Aspose::Words::Comment node for the reply.

Due to the existing MS Office limitations only 1 level of replies is allowed in the document. An exception of type System::InvalidOperationException will be raised if this method is called on the existing Reply comment.

◆ get_Ancestor()

System::SharedPtr<Aspose::Words::Comment> Aspose::Words::Comment::get_Ancestor ( )

Returns the parent Comment object. Returns null for top-level comments.

◆ get_Author()

System::String Aspose::Words::Comment::get_Author ( ) const

Returns or sets the author name for a comment.

Cannot be null.

Default is empty string.

◆ get_DateTime()

System::DateTime Aspose::Words::Comment::get_DateTime ( ) const

Gets the date and time that the comment was made.

Default is System::DateTime::MinValue.

◆ get_Done()

bool Aspose::Words::Comment::get_Done ( ) const

Gets or sets flag indicating that the comment has been marked done.

◆ get_Id()

int32_t Aspose::Words::Comment::get_Id ( ) const

Gets the comment identifier.

The comment identifier allows to anchor a comment to a region of text in the document. The region must be demarcated using the Aspose::Words::CommentRangeStart and Aspose::Words::CommentRangeEnd object sharing the same identifier value as the Aspose::Words::Comment object.

You would use this value when looking for the Aspose::Words::CommentRangeStart and Aspose::Words::CommentRangeEnd nodes that are linked to this comment.

Comment identifiers are supposed to be unique across a document and Aspose.Words automatically maintains comment identifiers when loading, saving and combining documents.

◆ get_IdInternal()

int32_t Aspose::Words::Comment::get_IdInternal ( )

◆ get_Initial()

System::String Aspose::Words::Comment::get_Initial ( ) const

Returns or sets the initials of the user associated with a specific comment.

Cannot be null.

Default is empty string.

◆ get_MoveFromRevision()

System::SharedPtr<Aspose::Words::Revisions::MoveRevision> Aspose::Words::Comment::get_MoveFromRevision ( )

◆ get_MoveToRevision()

System::SharedPtr<Aspose::Words::Revisions::MoveRevision> Aspose::Words::Comment::get_MoveToRevision ( )

◆ get_NodeType()

virtual Aspose::Words::NodeType Aspose::Words::Comment::get_NodeType ( ) const
virtual

Returns NodeType.Comment.

Implements Aspose::Words::Node.

◆ get_ParentIdInternal()

int32_t Aspose::Words::Comment::get_ParentIdInternal ( )

◆ get_Replies()

System::SharedPtr<Aspose::Words::CommentCollection> Aspose::Words::Comment::get_Replies ( )

Returns a collection of Aspose::Words::Comment objects that are immediate children of the specified comment.

◆ get_StoryType()

virtual Aspose::Words::StoryType Aspose::Words::Comment::get_StoryType ( )
virtual

◆ RemoveAllReplies()

void Aspose::Words::Comment::RemoveAllReplies ( )

Removes all replies to this comment.

All constituent nodes of the replies will be deleted from the document.

◆ RemoveReply()

void Aspose::Words::Comment::RemoveReply ( System::SharedPtr< Aspose::Words::Comment reply)

Removes the specified reply to this comment.

All constituent nodes of the reply will be deleted from the document.

Parameters
replyThe comment node of the deleting reply.

◆ set_Author()

void Aspose::Words::Comment::set_Author ( System::String  value)

◆ set_DateTime()

void Aspose::Words::Comment::set_DateTime ( System::DateTime  value)

◆ set_Done()

void Aspose::Words::Comment::set_Done ( bool  value)

◆ set_IdInternal()

void Aspose::Words::Comment::set_IdInternal ( int32_t  value)

◆ set_Initial()

void Aspose::Words::Comment::set_Initial ( System::String  value)

◆ set_MoveFromRevision()

void Aspose::Words::Comment::set_MoveFromRevision ( System::SharedPtr< Aspose::Words::Revisions::MoveRevision >  value)

◆ set_MoveToRevision()

void Aspose::Words::Comment::set_MoveToRevision ( System::SharedPtr< Aspose::Words::Revisions::MoveRevision >  value)

◆ set_ParentIdInternal()

void Aspose::Words::Comment::set_ParentIdInternal ( int32_t  value)

◆ SetText()

void Aspose::Words::Comment::SetText ( System::String  text)

This is a convenience method that allows to easily set text of the comment.

This method allows to quickly set text of a comment from a string. The string can contain paragraph breaks, this will create paragraphs of text in the comment accordingly. If you want to insert more complex elements into the comment, for example bookmarks or tables or apply rich formatting, then you need to use the appropriate node classes to build up the comment text.

Parameters
textThe new text of the comment.