Class CommentUtil
java.lang.Object
pro.verron.officestamper.core.CommentUtil
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 TypeMethodDescriptionstatic Commentcomment(DocxPart docxPart, org.docx4j.wml.CommentRangeStart crs, org.docx4j.openpackaging.packages.WordprocessingMLPackage document, org.docx4j.wml.ContentAccessor contentAccessor) Creates aCommentobject.static voiddeleteComment(Comment comment) Returns the string value of the specified comment object.static org.docx4j.wml.CommentsextractContent(org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart commentsPart) Extracts the contents of a givenCommentsPart.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.
-
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 givenCommentsPart.- Parameters:
commentsPart- theCommentsPartfrom which content will be extracted- Returns:
- the
Commentsinstance containing the content of the provided comments part - Throws:
OfficeStamperException- if an error occurs while retrieving the content
-
deleteComment
-
comment
public static Comment comment(DocxPart docxPart, org.docx4j.wml.CommentRangeStart crs, org.docx4j.openpackaging.packages.WordprocessingMLPackage document, org.docx4j.wml.ContentAccessor contentAccessor) Creates aCommentobject.- Parameters:
docxPart- the document part.crs- the comment range start.document- the document.contentAccessor- the content accessor.- Returns:
- the comment.
-