Aspose::Words::Comment::Comment constructor
Contents
[
Hide
]Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase>&) constructor
Initializes a new instance of the Comment class.
Aspose::Words::Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase> &doc)
Parameter | Type | Description |
---|---|---|
doc | const System::SharedPtr<Aspose::Words::DocumentBase>& | The owner document. |
Remarks
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 InsertAfter1() or
After creating a comment, don’t forget to set its Author, Initial and DateTime properties.
See Also
- Class DocumentBase
- Class Comment
- Namespace Aspose::Words
- Library Aspose.Words for C++
Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase>&, const System::String&, const System::String&, System::DateTime) constructor
Initializes a new instance of the Comment class.
Aspose::Words::Comment::Comment(const System::SharedPtr<Aspose::Words::DocumentBase> &doc, const System::String &author, const System::String &initial, System::DateTime dateTime)
Parameter | Type | Description |
---|---|---|
doc | const System::SharedPtr<Aspose::Words::DocumentBase>& | The owner document. |
author | const System::String& | The author name for the comment. Cannot be null. |
initial | const System::String& | The author initials for the comment. Cannot be null. |
dateTime | System::DateTime | The date and time for the comment. |
Examples
Shows how to add a comment to a paragraph.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
builder->Write(u"Hello world!");
auto comment = System::MakeObject<Aspose::Words::Comment>(doc, u"John Doe", u"JD", System::DateTime::get_Today());
builder->get_CurrentParagraph()->AppendChild<System::SharedPtr<Aspose::Words::Comment>>(comment);
builder->MoveTo(comment->AppendChild<System::SharedPtr<Aspose::Words::Paragraph>>(System::MakeObject<Aspose::Words::Paragraph>(doc)));
builder->Write(u"Comment text.");
ASSERT_EQ(System::DateTime::get_Today(), comment->get_DateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc->Save(get_ArtifactsDir() + u"InlineStory.AddComment.docx");
See Also
- Class DocumentBase
- Class Comment
- Namespace Aspose::Words
- Library Aspose.Words for C++