Comment

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IComment, com.aspose.slides.IDOMObject

public class Comment implements IComment, IDOMObject

Represents a comment on a slide.


This example shows you how to add a comment to a slide in a PowerPoint presentation.
 
 // Instantiates the Presentation class
 Presentation presentation = new Presentation();
 try {
    // Adds an empty slide
     presentation.getSlides().addEmptySlide(presentation.getLayoutSlides().get_Item(0));
     // Adds an author
     ICommentAuthor author = presentation.getCommentAuthors().addAuthor("Jawad", "MF");
     // Sets the position for comments
     android.graphics.PointF point = new android.graphics.PointF();
     point.x = 0.2f;
     point.y = 0.2f;
     // Adds slide comment for an author on slide 1
     author.getComments().addComment("Hello Jawad, this is slide comment", presentation.getSlides().get_Item(0), point, new Date());
     // Adds slide comment for an author on slide 2
     author.getComments().addComment("Hello Jawad, this is second slide comment", presentation.getSlides().get_Item(1), point, new Date());
 	// Save the PowerPoint Presentation file
     presentation.save("Comments_out.pptx", SaveFormat.Pptx);
 } finally {
     if (presentation != null) presentation.dispose();
 }
 
 This example shows you how to access an existing comment on a slide in a PowerPoint presentation.
 
 // Instantiates the Presentation class
 Presentation presentation = new Presentation("Comments1.pptx");
 try {
     // Iterate CommentAuthors
     for (ICommentAuthor commentAuthor : presentation.getCommentAuthors())
     {
         CommentAuthor author = (CommentAuthor) commentAuthor;
         // Iterate Comments
         for (IComment comment1 : author.getComments())
         {
             Comment comment = (Comment) comment1;
             System.out.println("ISlide :" + comment.getSlide().getSlideNumber() + " has comment: " + comment.getText() + " with Author: " + comment.getAuthor().getName() + " posted on time :" + comment.getCreatedTime().toString() + "\n");
         }
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }
 
 This example shows you how to add comments and get replies to them.
 
 // Instantiates the Presentation class
 Presentation pres = new Presentation();
 try {
    // Adds a comment
     ICommentAuthor author1 = pres.getCommentAuthors().addAuthor("Author_1", "A.A.");
     IComment comment1 = author1.getComments().addComment("comment1", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     // Adds a reply to comment1
     ICommentAuthor author2 = pres.getCommentAuthors().addAuthor("Autror_2", "B.B.");
     IComment reply1 = author2.getComments().addComment("reply 1 for comment 1", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     reply1.setParentComment(comment1);
     // Adds another reply to comment1
     IComment reply2 = author2.getComments().addComment("reply 2 for comment 1", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     reply2.setParentComment(comment1);
     // Adds a reply to existing reply
     IComment subReply = author1.getComments().addComment("subreply 3 for reply 2", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     subReply.setParentComment(reply2);
     IComment comment2 = author2.getComments().addComment("comment 2", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     IComment comment3 = author2.getComments().addComment("comment 3", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     IComment reply3 = author1.getComments().addComment("reply 4 for comment 3", pres.getSlides().get_Item(0), new android.graphics.PointF(10, 10), new Date());
     reply3.setParentComment(comment3);
     // Displays the comments hierarchy on console
     ISlide slide = pres.getSlides().get_Item(0);
     IComment[] comments = slide.getSlideComments(null);
     for (int i = 0; i < comments.length; i++)
     {
         IComment comment = comments[i];
         while (comment.getParentComment() != null)
         {
             System.out.println("\t");
             comment = comment.getParentComment();
         }
         System.out.println(comments[i].getAuthor().getName() + " : " + comments[i].getText());
     }
     pres.save("parent_comment.pptx",SaveFormat.Pptx);
     // Removes comment1 and all replies to it
     comment1.remove();
     pres.save("remove_comment.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Methods

MethodDescription
getText()Returns or sets the plain text of a slide comment.
setText(String value)Returns or sets the plain text of a slide comment.
getCreatedTime()Returns or sets the time of a comment creation.
setCreatedTime(Date value)Returns or sets the time of a comment creation.
getSlide()Returns or sets the parent slide of a comment.
getAuthor()Returns the author of a comment.
getPosition()Returns or sets the position of a comment on a slide.
setPosition(PointF value)Returns or sets the position of a comment on a slide.
remove()Removes comment and all its replies from the parent collection.
getParentComment()Gets or sets parent comment.
setParentComment(IComment value)Gets or sets parent comment.
getParent_Immediate()

getText()

public final String getText()

Returns or sets the plain text of a slide comment. Read/write String.

Returns: java.lang.String

setText(String value)

public final void setText(String value)

Returns or sets the plain text of a slide comment. Read/write String.

Parameters:

ParameterTypeDescription
valuejava.lang.String

getCreatedTime()

public final Date getCreatedTime()

Returns or sets the time of a comment creation. Setting this property to java.util.Date(Long.MIN_VALUE) means no comment time is set. Read/write java.util.Date.


Comment time is an optional parameter.

Returns: java.util.Date

setCreatedTime(Date value)

public final void setCreatedTime(Date value)

Returns or sets the time of a comment creation. Setting this property to java.util.Date(Long.MIN_VALUE) means no comment time is set. Read/write java.util.Date.


Comment time is an optional parameter.

Parameters:

ParameterTypeDescription
valuejava.util.Date

getSlide()

public final ISlide getSlide()

Returns or sets the parent slide of a comment. Read-only ISlide.

Returns: ISlide

getAuthor()

public final ICommentAuthor getAuthor()

Returns the author of a comment. Read-only ICommentAuthor.

Returns: ICommentAuthor

getPosition()

public final PointF getPosition()

Returns or sets the position of a comment on a slide. Read/write android.graphics.PointF.

Returns: android.graphics.PointF

setPosition(PointF value)

public final void setPosition(PointF value)

Returns or sets the position of a comment on a slide. Read/write android.graphics.PointF.

Parameters:

ParameterTypeDescription
valueandroid.graphics.PointF

remove()

public final void remove()

Removes comment and all its replies from the parent collection.

getParentComment()

public final IComment getParentComment()

Gets or sets parent comment. Read/write IComment.

Returns: IComment

setParentComment(IComment value)

public final void setParentComment(IComment value)

Gets or sets parent comment. Read/write IComment.

Parameters:

ParameterTypeDescription
valueIComment

getParent_Immediate()

public IDOMObject getParent_Immediate()

Returns Parent_Immediate object. Read-only IDOMObject.

Returns: com.aspose.slides.IDOMObject