Package org.apache.poi.xwpf.usermodel
Class XWPFComments
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xwpf.usermodel.XWPFComments
-
public class XWPFComments extends POIXMLDocumentPart
specifies all of the comments defined in the current document
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Constructor Summary
Constructors Constructor Description XWPFComments()Construct XWPFComments from scratch for a new document.XWPFComments(POIXMLDocumentPart parent, PackagePart part)Construct XWPFComments from a package part
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringaddPictureData(byte[] pictureData, int format)Adds a picture to the comments.java.lang.StringaddPictureData(byte[] pictureData, PictureType pictureType)Adds a picture to the comments.java.lang.StringaddPictureData(java.io.InputStream is, int format)Adds a picture to the comments.java.lang.StringaddPictureData(java.io.InputStream is, PictureType pictureType)Adds a picture to the comments.XWPFCommentcreateComment(java.math.BigInteger cid)Create a new comment and add it to the document.java.util.List<XWPFPictureData>getAllPictures()XWPFCommentgetComment(int pos)Get the specified comment by positionXWPFCommentgetComment(CTComment ctComment)Get the specified comment by ctCommentXWPFCommentgetCommentByID(java.lang.String id)Get the specified comment by comment idjava.util.List<XWPFComment>getComments()Get the list ofXWPFCommentin the Comments part.CTCommentsgetCtComments()Gets the underlying CTComments object for the comments.XWPFDocumentgetXWPFDocument()voidonDocumentRead()read comments form an existing packagebooleanremoveComment(int pos)Remove the specified comment if present.voidsetCtComments(CTComments ctComments)set a new commentsvoidsetXWPFDocument(XWPFDocument document)-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, isCommitted, setCommitted, toString
-
-
-
-
Constructor Detail
-
XWPFComments
public XWPFComments(POIXMLDocumentPart parent, PackagePart part)
Construct XWPFComments from a package part- Parameters:
part- the package part holding the data of the footnotes,
-
XWPFComments
public XWPFComments()
Construct XWPFComments from scratch for a new document.
-
-
Method Detail
-
onDocumentRead
public void onDocumentRead() throws java.io.IOExceptionread comments form an existing package- Throws:
java.io.IOException
-
addPictureData
public java.lang.String addPictureData(java.io.InputStream is, int format) throws InvalidFormatException, java.io.IOExceptionAdds a picture to the comments.- Parameters:
is- The stream to read image fromformat- The format of the picture, seeDocument- Returns:
- the index to this picture (0 based), the added picture can be
obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the format of the picture is not known.java.io.IOException- If reading the picture-data from the stream fails.- See Also:
addPictureData(InputStream, PictureType)
-
addPictureData
public java.lang.String addPictureData(java.io.InputStream is, PictureType pictureType) throws InvalidFormatException, java.io.IOExceptionAdds a picture to the comments.- Parameters:
is- The stream to read image frompictureType- ThePictureTypeof the picture- Returns:
- the index to this picture (0 based), the added picture can be
obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the pictureType of the picture is not known.java.io.IOException- If reading the picture-data from the stream fails.- Since:
- POI 5.2.3
-
addPictureData
public java.lang.String addPictureData(byte[] pictureData, int format) throws InvalidFormatExceptionAdds a picture to the comments.- Parameters:
pictureData- The picture dataformat- The format of the picture, seeDocument- Returns:
- the index to this picture (0 based), the added picture can be
obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the format of the picture is not known.
-
addPictureData
public java.lang.String addPictureData(byte[] pictureData, PictureType pictureType) throws InvalidFormatExceptionAdds a picture to the comments.- Parameters:
pictureData- The picture datapictureType- ThePictureTypeof the picture.- Returns:
- the index to this picture (0 based), the added picture can be
obtained from
getAllPictures(). - Throws:
InvalidFormatException- If the pictureType of the picture is not known.- Since:
- POI 5.2.3
-
getAllPictures
public java.util.List<XWPFPictureData> getAllPictures()
-
getCtComments
public CTComments getCtComments()
Gets the underlying CTComments object for the comments.- Returns:
- CTComments object
-
setCtComments
@Internal public void setCtComments(CTComments ctComments)
set a new comments
-
getComments
public java.util.List<XWPFComment> getComments()
Get the list ofXWPFCommentin the Comments part.
-
getComment
public XWPFComment getComment(int pos)
Get the specified comment by position- Parameters:
pos- Array position of the comment
-
getCommentByID
public XWPFComment getCommentByID(java.lang.String id)
Get the specified comment by comment id- Parameters:
id- comment id- Returns:
- the specified comment
-
getComment
public XWPFComment getComment(CTComment ctComment)
Get the specified comment by ctComment
-
createComment
public XWPFComment createComment(java.math.BigInteger cid)
Create a new comment and add it to the document.- Parameters:
cid- comment Id
-
removeComment
public boolean removeComment(int pos)
Remove the specified comment if present.- Parameters:
pos- Array position of the comment to be removed- Returns:
- True if the comment was removed.
-
getXWPFDocument
public XWPFDocument getXWPFDocument()
-
setXWPFDocument
public void setXWPFDocument(XWPFDocument document)
-
-