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 Comment object occurs on its own, the comment is anchored to the position of the Comment object.
To anchor a comment to a region of text three objects are required: Comment, CommentRangeStart and CommentRangeEnd. All three objects need to share the same Id value.
Comment is an inline-level node and can only be a child of Paragraph.
Comment can contain Paragraph and Table child nodes.
Shows how to add a comment to a document, and then reply to it.
Shows how to add a comment to a paragraph.
#include <Aspose.Words.Cpp/Comment.h>
Public Member Functions | |
Comment (SharedPtr< DocumentBase > doc) | |
Initializes a new instance of the Comment class. More... | |
Comment (SharedPtr< DocumentBase > doc, String author, String initial, DateTime dateTime) | |
Initializes a new instance of the Comment class. More... | |
bool | Accept (SharedPtr< DocumentVisitor > visitor) override |
Accepts a visitor. More... | |
SharedPtr< Comment > | AddReply (String author, String initial, DateTime dateTime, String text) |
Adds a reply to this comment. More... | |
SharedPtr< Comment > | get_Ancestor () |
Returns the parent Comment object. Returns null for top-level comments. More... | |
String | get_Author () const |
Returns or sets the author name for a comment. More... | |
DateTime | get_DateTime () const |
Gets the date and time that the comment was made. More... | |
bool | get_Done () const |
Gets or sets flag indicating that the comment has been marked done. More... | |
int32_t | get_Id () const |
Gets the comment identifier. More... | |
String | get_Initial () const |
Returns or sets the initials of the user associated with a specific comment. More... | |
NodeType | get_NodeType () const override |
Returns NodeType.Comment. More... | |
SharedPtr< CommentCollection > | get_Replies () |
Returns a collection of Comment objects that are immediate children of the specified comment. More... | |
StoryType | get_StoryType () override |
Returns StoryType.Comments. More... | |
virtual const TypeInfo & | GetType () const override |
virtual bool | Is (const TypeInfo &target) const override |
void | RemoveAllReplies () |
Removes all replies to this comment. More... | |
void | RemoveMoveRevisions () override |
void | RemoveReply (SharedPtr< Comment > reply) |
Removes the specified reply to this comment. More... | |
void | set_Author (String value) |
Setter for get_Author. More... | |
void | set_DateTime (DateTime value) |
Setter for get_DateTime. More... | |
void | set_Done (bool value) |
Setter for get_Done. More... | |
void | set_Initial (String value) |
Setter for get_Initial. More... | |
void | SetText (String text) |
This is a convenience method that allows to easily set text of the comment. More... | |
![]() | |
void | EnsureMinimum () |
If the last child is not a paragraph, creates and appends one empty paragraph. More... | |
SharedPtr< Paragraph > | get_FirstParagraph () |
Gets the first paragraph in the story. More... | |
SharedPtr< Font > | get_Font () |
Provides access to the font formatting of the anchor character of this object. More... | |
bool | get_IsDeleteRevision () |
Returns true if this object was deleted in Microsoft Word while change tracking was enabled. More... | |
bool | get_IsInsertRevision () |
Returns true if this object was inserted 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... | |
SharedPtr< Paragraph > | get_LastParagraph () |
Gets the last paragraph in the story. More... | |
SharedPtr< ParagraphCollection > | get_Paragraphs () |
Gets a collection of paragraphs that are immediate children of the story. More... | |
SharedPtr< Paragraph > | get_ParentParagraph () |
Retrieves the parent Paragraph of this node. More... | |
SharedPtr< TableCollection > | get_Tables () |
Gets a collection of tables that are immediate children of the story. More... | |
![]() | |
SharedPtr< Node > | AppendChild (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... | |
SharedPtr< CompositeNode > | get_Container () override |
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< Node > | GetCurrentNode () override |
SharedPtr< IEnumerator< SharedPtr< Node > > > | GetEnumerator () override |
Provides support for the for each style iteration over the child nodes of this node. More... | |
SharedPtr< Node > | GetNextMatchingNode (SharedPtr< Node > curNode) override |
String | GetText () override |
Gets the text of this node and of all its children. More... | |
int32_t | IndexOf (SharedPtr< Node > child) |
Returns the index of the specified child node in the child node array. More... | |
SharedPtr< Node > | InsertAfter (SharedPtr< Node > newChild, SharedPtr< Node > refChild) |
Inserts the specified node immediately after the specified reference node. More... | |
SharedPtr< Node > | InsertBefore (SharedPtr< Node > newChild, SharedPtr< Node > refChild) |
Inserts the specified node immediately before the specified reference node. More... | |
SharedPtr< Node > | PrependChild (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 (SharedPtr< Node > oldChild) |
Removes the specified child node. More... | |
void | RemoveSmartTags () |
Removes all SmartTag descendant nodes of the current node. More... | |
SharedPtr< NodeList > | SelectNodes (String xpath) |
Selects a list of nodes matching the XPath expression. More... | |
SharedPtr< Node > | SelectSingleNode (String xpath) |
Selects the first Node that matches the XPath expression. 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... | |
SharedPtr< Node > | get_NextSibling () |
Gets the node immediately following 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 () |
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 const TypeInfo & | Type () |
![]() | |
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::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 Author, Initial and DateTime properties.
doc | The owner document. |
Shows how print the contents of all comments and their comment ranges using a document visitor.
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.
doc | The owner document. |
author | The author name for the comment. Cannot be null. |
initial | The author initials for the comment. Cannot be null. |
dateTime | The date and time for the comment. |
Shows how to add a comment to a paragraph.
|
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 print the contents of all comments and their comment ranges using a document visitor.
Implements Aspose::Words::Node.
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.
author | The author name for the reply. |
initial | The author initials for the reply. |
dateTime | The date and time for the reply. |
text | The reply text. |
Shows how to add a comment to a document, and then reply to it.
System::SharedPtr<Aspose::Words::Comment> Aspose::Words::Comment::get_Ancestor | ( | ) |
Returns the parent Comment object. Returns null for top-level comments.
Shows how to print all of a document's comments and their replies.
System::String Aspose::Words::Comment::get_Author | ( | ) | const |
Returns or sets the author name for a comment.
Cannot be null.
Default is empty string.
Shows how to print all of a document's comments and their replies.
System::DateTime Aspose::Words::Comment::get_DateTime | ( | ) | const |
Gets the date and time that the comment was made.
Default is MinValue.
Shows how print the contents of all comments and their comment ranges using a document visitor.
bool Aspose::Words::Comment::get_Done | ( | ) | const |
Gets or sets flag indicating that the comment has been marked done.
Shows how to mark a comment as "done".
Shows how print the contents of all comments and their comment ranges using a document visitor.
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 CommentRangeStart and CommentRangeEnd object sharing the same identifier value as the Comment object.
You would use this value when looking for the CommentRangeStart and 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.
Shows how print the contents of all comments and their comment ranges using a document visitor.
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.
Shows how print the contents of all comments and their comment ranges using a document visitor.
|
overridevirtual |
Returns NodeType.Comment.
Shows how to traverse a composite node's tree of child nodes.
Implements Aspose::Words::Node.
System::SharedPtr<Aspose::Words::CommentCollection> Aspose::Words::Comment::get_Replies | ( | ) |
Returns a collection of Comment objects that are immediate children of the specified comment.
Shows how to print all of a document's comments and their replies.
|
overridevirtual |
Returns StoryType.Comments.
Shows how to insert InlineStory nodes.
Implements Aspose::Words::InlineStory.
|
overridevirtual |
Reimplemented from Aspose::Words::InlineStory.
|
overridevirtual |
Reimplemented from Aspose::Words::InlineStory.
void Aspose::Words::Comment::RemoveAllReplies | ( | ) |
Removes all replies to this comment.
Shows how to remove comment replies.
|
override |
void Aspose::Words::Comment::RemoveReply | ( | System::SharedPtr< Aspose::Words::Comment > | reply | ) |
Removes the specified reply to this comment.
reply | The comment node of the deleting reply. |
Shows how to remove comment replies.
void Aspose::Words::Comment::set_Author | ( | System::String | value | ) |
Setter for Aspose::Words::Comment::get_Author.
void Aspose::Words::Comment::set_DateTime | ( | System::DateTime | value | ) |
Setter for Aspose::Words::Comment::get_DateTime.
void Aspose::Words::Comment::set_Done | ( | bool | value | ) |
Setter for Aspose::Words::Comment::get_Done.
void Aspose::Words::Comment::set_Initial | ( | System::String | value | ) |
Setter for Aspose::Words::Comment::get_Initial.
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.
text | The new text of the comment. |
Shows how to add a comment to a document, and then reply to it.
|
static |