Aspose::Words::Comment Class Referencefinal

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 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.

See also
Aspose::Words::CommentRangeStart
Aspose::Words::CommentRangeEnd
Examples

Shows how to add a comment with a reply to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create new comment
auto newComment = MakeObject<Comment>(doc, u"John Doe", u"J.D.", System::DateTime::get_Now());
newComment->SetText(u"My comment.");
// Add this comment to a document node
builder->get_CurrentParagraph()->AppendChild(newComment);
// Add comment reply
newComment->AddReply(u"John Doe", u"JD", System::DateTime(2017, 9, 25, 12, 15, 0), u"New reply");

Shows how to add a comment to a paragraph in the document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Some text is added.");
auto comment = MakeObject<Comment>(doc, u"Amy Lee", u"AL", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild(comment);
comment->get_Paragraphs()->Add(MakeObject<Paragraph>(doc));
comment->get_FirstParagraph()->get_Runs()->Add(MakeObject<Run>(doc, u"Comment text."));
doc->Save(ArtifactsDir + u"InlineStory.AddComment.docx");

#include <Aspose.Words.Cpp/Model/Text/Comment.h>

+ Inheritance diagram for Aspose::Words::Comment:

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< CommentAddReply (String author, String initial, DateTime dateTime, String text)
 Adds a reply to this comment. More...
 
SharedPtr< Commentget_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< CommentCollectionget_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 TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void RemoveAllReplies ()
 Removes all replies to this comment. More...
 
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)
 Gets the date and time that the comment was made. 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...
 
- Public Member Functions inherited from InlineStory
void EnsureMinimum ()
 If the last child is not a paragraph, creates and appends one empty paragraph. More...
 
SharedPtr< Paragraphget_FirstParagraph ()
 Gets the first paragraph in the story. More...
 
SharedPtr< Fontget_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< Paragraphget_LastParagraph ()
 Gets the last paragraph in the story. More...
 
SharedPtr< ParagraphCollectionget_Paragraphs ()
 Gets a collection of paragraphs that are immediate children of the story. More...
 
SharedPtr< Paragraphget_ParentParagraph ()
 Retrieves the parent Paragraph of this node. More...
 
SharedPtr< TableCollectionget_Tables ()
 Gets a collection of tables that are immediate children of the story. More...
 
- Public Member Functions inherited from CompositeNode
SharedPtr< NodeAppendChild (SharedPtr< Node > newChild)
 Adds the specified node to the end of the list of child nodes for this node. More...
 
SharedPtr< NodeCollectionget_ChildNodes ()
 Gets all immediate child nodes of this node. More...
 
SharedPtr< CompositeNodeget_Container () override
 
int32_t get_Count ()
 Gets the number of immediate children of this node. More...
 
SharedPtr< Nodeget_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< Nodeget_LastChild () const
 Gets the last child of the node. More...
 
SharedPtr< NodeGetChild (NodeType nodeType, int32_t index, bool isDeep)
 Returns an Nth child node that matches the specified type. More...
 
SharedPtr< NodeCollectionGetChildNodes (NodeType nodeType, bool isDeep)
 Returns a live collection of child nodes that match the specified type. More...
 
SharedPtr< NodeGetCurrentNode () override
 
SharedPtr< IEnumerator< SharedPtr< Node > > > GetEnumerator () override
 Provides support for the for each style iteration over the child nodes of this node. More...
 
SharedPtr< NodeGetNextMatchingNode (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< NodeInsertAfter (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
SharedPtr< NodeInsertBefore (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
SharedPtr< NodePrependChild (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< NodeRemoveChild (SharedPtr< Node > oldChild)
 Removes the specified child node. More...
 
void RemoveSmartTags ()
 Removes all SmartTag descendant nodes of the current node. More...
 
SharedPtr< NodeListSelectNodes (String xpath)
 Selects a list of nodes matching the XPath expression. More...
 
SharedPtr< NodeSelectSingleNode (String xpath)
 Selects the first Node that matches the XPath expression. More...
 
- Public Member Functions inherited from Node
SharedPtr< NodeClone (bool isCloneChildren)
 Creates a duplicate of the node. More...
 
virtual SharedPtr< DocumentBaseget_Document () const
 Gets the document to which this node belongs. More...
 
SharedPtr< Nodeget_NextSibling ()
 Gets the node immediately following 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 ()
 
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
 
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 ()
 
- Public Member Functions inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
EnumeratorBasedIterator< T, IEnumerator< T > > begin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cbegin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cend () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > end () noexcept
 
bool LINQ_All (std::function< bool(T)> predicate)
 
bool LINQ_Any ()
 
bool LINQ_Any (std::function< bool(T)> predicate)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Cast ()
 
SharedPtr< IEnumerable< Result > > LINQ_Cast ()
 
bool LINQ_Contains (T value)
 
int LINQ_Count ()
 
int LINQ_Count (const Func< T, bool > &predicate)
 
LINQ_ElementAt (int index)
 
LINQ_First ()
 
LINQ_First (const Func< T, bool > &predicate)
 
LINQ_FirstOrDefault ()
 
LINQ_FirstOrDefault (std::function< bool(T)> predicate)
 
LINQ_Last ()
 
LINQ_LastOrDefault ()
 
SharedPtr< IEnumerable< ResultType > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Result > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Source > > LINQ_OrderBy (const Func< Source, Key > &keySelector)
 
SharedPtr< IEnumerable< T > > LINQ_OrderBy (const Func< T, Key > &keySelector)
 
SharedPtr< IEnumerable< Result > > LINQ_Select (const Func< Source, Result > &selector)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Select (const Func< T, ResultType > &selector)
 
ArrayPtr< T > LINQ_ToArray ()
 
SharedPtr< List< T > > LINQ_ToList ()
 
SharedPtr< IEnumerable< T > > LINQ_Where (std::function< bool(T)> predicate)
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from InlineStory
static const TypeInfoType ()
 
- Static Public Member Functions inherited from CompositeNode
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Node
static String NodeTypeToString (NodeType nodeType)
 A utility method that converts a node type enum value into a user friendly string. More...
 
static const TypeInfoType ()
 
- 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
 
- Public Types inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
typedef IEnumerator< T > IEnumeratorType
 
typedef T ValueType
 

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 Author, Initial and 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.
Examples

Shows how to add a comment to a paragraph in the document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Write(u"Some text is added.");
auto comment = MakeObject<Comment>(doc, u"Amy Lee", u"AL", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild(comment);
comment->get_Paragraphs()->Add(MakeObject<Paragraph>(doc));
comment->get_FirstParagraph()->get_Runs()->Add(MakeObject<Run>(doc, u"Comment text."));
doc->Save(ArtifactsDir + u"InlineStory.AddComment.docx");

Member Function Documentation

◆ Accept()

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

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.

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 Comment node for the reply.
Examples

Shows how to add a comment with a reply to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create new comment
auto newComment = MakeObject<Comment>(doc, u"John Doe", u"J.D.", System::DateTime::get_Now());
newComment->SetText(u"My comment.");
// Add this comment to a document node
builder->get_CurrentParagraph()->AppendChild(newComment);
// Add comment reply
newComment->AddReply(u"John Doe", u"JD", System::DateTime(2017, 9, 25, 12, 15, 0), u"New reply");

◆ get_Ancestor()

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

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

Examples

Shows how to get all comments with all replies.

auto doc = MakeObject<Document>(MyDir + u"Comments.docx");
// Get all comment from the document
SharedPtr<NodeCollection> comments = doc->GetChildNodes(Aspose::Words::NodeType::Comment, true);
// For all comments and replies we identify comment level and info about it
for (auto comment : System::IterateOver(comments->LINQ_OfType<SharedPtr<Comment> >()))
{
if (comment->get_Ancestor() == nullptr)
{
System::Console::WriteLine(u"\nThis is a top-level comment");
System::Console::WriteLine(String(u"Comment author: ") + comment->get_Author());
System::Console::WriteLine(String(u"Comment text: ") + comment->GetText());
for (auto commentReply : System::IterateOver(comment->get_Replies()->LINQ_OfType<SharedPtr<Comment> >()))
{
System::Console::WriteLine(u"\n\tThis is a comment reply");
System::Console::WriteLine(String(u"\tReply author: ") + commentReply->get_Author());
System::Console::WriteLine(String(u"\tReply text: ") + commentReply->GetText());
}
}
}

◆ 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.

Examples

Shows how to get all comments with all replies.

auto doc = MakeObject<Document>(MyDir + u"Comments.docx");
// Get all comment from the document
SharedPtr<NodeCollection> comments = doc->GetChildNodes(Aspose::Words::NodeType::Comment, true);
// For all comments and replies we identify comment level and info about it
for (auto comment : System::IterateOver(comments->LINQ_OfType<SharedPtr<Comment> >()))
{
if (comment->get_Ancestor() == nullptr)
{
System::Console::WriteLine(u"\nThis is a top-level comment");
System::Console::WriteLine(String(u"Comment author: ") + comment->get_Author());
System::Console::WriteLine(String(u"Comment text: ") + comment->GetText());
for (auto commentReply : System::IterateOver(comment->get_Replies()->LINQ_OfType<SharedPtr<Comment> >()))
{
System::Console::WriteLine(u"\n\tThis is a comment reply");
System::Console::WriteLine(String(u"\tReply author: ") + commentReply->get_Author());
System::Console::WriteLine(String(u"\tReply text: ") + commentReply->GetText());
}
}
}

◆ get_DateTime()

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

Gets the date and time that the comment was made.

Default is MinValue.

◆ get_Done()

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

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

Examples

Shows how to mark comment as Done.

auto doc = MakeObject<Document>(MyDir + u"Comments.docx");
SharedPtr<NodeCollection> comments = doc->GetChildNodes(Aspose::Words::NodeType::Comment, true);
auto comment = System::DynamicCast<Aspose::Words::Comment>(comments->idx_get(0));
SharedPtr<CommentCollection> repliesCollection = comment->get_Replies();
for (auto childComment : System::IterateOver<Comment>(repliesCollection))
{
if (!childComment->get_Done())
{
// Update comment reply Done mark
childComment->set_Done(true);
}
}

◆ 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 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.

◆ 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_NodeType()

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

Returns NodeType.Comment.

Implements Aspose::Words::Node.

◆ get_Replies()

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

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

Examples

Shows how to get all comments with all replies.

auto doc = MakeObject<Document>(MyDir + u"Comments.docx");
// Get all comment from the document
SharedPtr<NodeCollection> comments = doc->GetChildNodes(Aspose::Words::NodeType::Comment, true);
// For all comments and replies we identify comment level and info about it
for (auto comment : System::IterateOver(comments->LINQ_OfType<SharedPtr<Comment> >()))
{
if (comment->get_Ancestor() == nullptr)
{
System::Console::WriteLine(u"\nThis is a top-level comment");
System::Console::WriteLine(String(u"Comment author: ") + comment->get_Author());
System::Console::WriteLine(String(u"Comment text: ") + comment->GetText());
for (auto commentReply : System::IterateOver(comment->get_Replies()->LINQ_OfType<SharedPtr<Comment> >()))
{
System::Console::WriteLine(u"\n\tThis is a comment reply");
System::Console::WriteLine(String(u"\tReply author: ") + commentReply->get_Author());
System::Console::WriteLine(String(u"\tReply text: ") + commentReply->GetText());
}
}
}

◆ get_StoryType()

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

Returns StoryType.Comments.

Examples

Shows how to insert InlineStory nodes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Footnote> footnote = builder->InsertFootnote(Aspose::Words::FootnoteType::Footnote, nullptr);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell
auto table = MakeObject<Table>(doc);
table->EnsureMinimum();
// We can place a table inside a footnote, which will make it appear at the footer of the referencing page
ASSERT_TRUE(footnote->get_Tables()->get_Count() == 0);
footnote->AppendChild(table);
ASSERT_EQ(1, footnote->get_Tables()->get_Count());
ASSERT_EQ(Aspose::Words::NodeType::Table, footnote->get_LastChild()->get_NodeType());
// An InlineStory has an "EnsureMinimum()" method as well, but in this case it makes sure the last child of the node is a paragraph,
// so we can click and write text easily in Microsoft Word
footnote->EnsureMinimum();
ASSERT_EQ(Aspose::Words::NodeType::Paragraph, footnote->get_LastChild()->get_NodeType());
// Edit the appearance of the anchor, which is the small superscript number in the main text that points to the footnote
footnote->get_Font()->set_Name(u"Arial");
footnote->get_Font()->set_Color(System::Drawing::Color::get_Green());
// All inline story nodes have their own respective story types
ASSERT_EQ(Aspose::Words::StoryType::Footnotes, footnote->get_StoryType());
// A comment is another type of inline story
auto comment = System::DynamicCast<Aspose::Words::Comment>(builder->get_CurrentParagraph()->AppendChild(MakeObject<Comment>(doc, u"John Doe", u"J. D.", System::DateTime::get_Now())));
// The parent paragraph of an inline story node will be the one from the main document body
ASPOSE_ASSERT_EQ(doc->get_FirstSection()->get_Body()->get_FirstParagraph(), comment->get_ParentParagraph());
// However, the last paragraph is the one from the comment text contents, which will be outside the main document body in a speech bubble
// A comment won't have any child nodes by default, so we can apply the EnsureMinimum() method to place a paragraph here as well
ASSERT_TRUE(comment->get_LastParagraph() == nullptr);
comment->EnsureMinimum();
ASSERT_EQ(Aspose::Words::NodeType::Paragraph, comment->get_LastChild()->get_NodeType());
// Once we have a paragraph, we can move the builder do it and write our comment
builder->MoveTo(comment->get_LastParagraph());
builder->Write(u"My comment.");
ASSERT_EQ(Aspose::Words::StoryType::Comments, comment->get_StoryType());
doc->Save(ArtifactsDir + u"InlineStory.InsertInlineStoryNodes.docx");

Implements Aspose::Words::InlineStory.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Comment::GetType ( ) const
overridevirtual

Reimplemented from Aspose::Words::InlineStory.

◆ Is()

virtual bool Aspose::Words::Comment::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from Aspose::Words::InlineStory.

◆ RemoveAllReplies()

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

Removes all replies to this comment.

Examples

Shows how to remove comment replies.

auto doc = MakeObject<Document>(MyDir + u"Comments.docx");
SharedPtr<NodeCollection> comments = doc->GetChildNodes(Aspose::Words::NodeType::Comment, true);
auto comment = System::DynamicCast<Aspose::Words::Comment>(comments->idx_get(0));
comment->RemoveAllReplies();

◆ RemoveReply()

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

Removes the specified reply to this comment.

Parameters
replyThe comment node of the deleting reply.
Examples

Shows how to remove specific comment reply.

auto doc = MakeObject<Document>(MyDir + u"Comments.docx");
SharedPtr<NodeCollection> comments = doc->GetChildNodes(Aspose::Words::NodeType::Comment, true);
auto parentComment = System::DynamicCast<Aspose::Words::Comment>(comments->idx_get(0));
SharedPtr<CommentCollection> repliesCollection = parentComment->get_Replies();
// Remove the first reply to comment
parentComment->RemoveReply(repliesCollection->idx_get(0));

◆ set_Author()

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

◆ set_DateTime()

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

Gets the date and time that the comment was made.

Default is MinValue.

◆ set_Done()

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

◆ set_Initial()

void Aspose::Words::Comment::set_Initial ( System::String  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.
Examples

Shows how to add a comment with a reply to a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Create new comment
auto newComment = MakeObject<Comment>(doc, u"John Doe", u"J.D.", System::DateTime::get_Now());
newComment->SetText(u"My comment.");
// Add this comment to a document node
builder->get_CurrentParagraph()->AppendChild(newComment);
// Add comment reply
newComment->AddReply(u"John Doe", u"JD", System::DateTime(2017, 9, 25, 12, 15, 0), u"New reply");

◆ Type()

static const System::TypeInfo& Aspose::Words::Comment::Type ( )
static
@ Comment
A comment in a Word document. A Comment node can have Paragraph and Table nodes.
String
static ASPOSECPP_SHARED_API DateTime get_Now()
static ASPOSECPP_SHARED_API void WriteLine()
std::enable_if_t<!Details::IsIterable< Enumerable >::value, Details::EnumeratorAdapter< Enumerable, T > > IterateOver(System::SmartPtr< Enumerable > enumerable)
@ Comments
Contains document comments (annotations), represented by Comment.
static ASPOSECPP_SHARED_API Color get_Green()
@ Footnotes
Contains footnote text, represented by Footnote.
static ASPOSECPP_SHARED_API DateTime get_Today()
@ Footnote
The object is a footnote.
@ Paragraph
A paragraph of text. A Paragraph node is a container for inline level elements Run,...
@ Table
A Table object that represents a table in a Word document. A Table node can have Row nodes.