Class CommentUtil

java.lang.Object
pro.verron.officestamper.core.CommentUtil

public class CommentUtil extends Object
Utility class for working with comments in a DOCX document.
Since:
1.0.0
Version:
${version}
Author:
Joseph Verron, Tom Hombergs
  • Method Summary

    Modifier and Type
    Method
    Description
    static Comment
    comment(DocxPart docxPart, org.docx4j.wml.CommentRangeStart crs, org.docx4j.openpackaging.packages.WordprocessingMLPackage document, org.docx4j.wml.ContentAccessor contentAccessor)
    Creates a Comment object.
    static void
    Returns the string value of the specified comment object.
    static org.docx4j.wml.Comments
    extractContent(org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart commentsPart)
    Extracts the contents of a given CommentsPart.
    static Collection<org.docx4j.wml.Comments.Comment>
    getCommentFor(org.docx4j.wml.ContentAccessor contentAccessor, org.docx4j.openpackaging.packages.OpcPackage document)
    Retrieves the comment associated with a given paragraph content within a WordprocessingMLPackage document.
    static Optional<org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart>
    getCommentsPart(org.docx4j.openpackaging.parts.Parts parts)
    Retrieves the CommentsPart from the given Parts object.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getCommentFor

      public static Collection<org.docx4j.wml.Comments.Comment> getCommentFor(org.docx4j.wml.ContentAccessor contentAccessor, org.docx4j.openpackaging.packages.OpcPackage document)
      Retrieves the comment associated with a given paragraph content within a WordprocessingMLPackage document.
      Parameters:
      contentAccessor - the content accessor to search for comments.
      document - the WordprocessingMLPackage document containing the paragraph and its comments.
      Returns:
      a collection of found comments.
    • getCommentsPart

      public static Optional<org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart> getCommentsPart(org.docx4j.openpackaging.parts.Parts parts)
      Retrieves the CommentsPart from the given Parts object.
      Parameters:
      parts - the Parts object containing the various parts of the document.
      Returns:
      an Optional containing the CommentsPart if found, or an empty Optional if not found.
    • extractContent

      public static org.docx4j.wml.Comments extractContent(org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart commentsPart)
      Extracts the contents of a given CommentsPart.
      Parameters:
      commentsPart - the CommentsPart from which content will be extracted
      Returns:
      the Comments instance containing the content of the provided comments part
      Throws:
      OfficeStamperException - if an error occurs while retrieving the content
    • deleteComment

      public static void deleteComment(Comment comment)
      Returns the string value of the specified comment object.
      Parameters:
      comment - a Comment object
    • comment

      public static Comment comment(DocxPart docxPart, org.docx4j.wml.CommentRangeStart crs, org.docx4j.openpackaging.packages.WordprocessingMLPackage document, org.docx4j.wml.ContentAccessor contentAccessor)
      Creates a Comment object.
      Parameters:
      docxPart - the document part.
      crs - the comment range start.
      document - the document.
      contentAccessor - the content accessor.
      Returns:
      the comment.