Package org.apache.poi.xwpf.usermodel
Class XWPFComments
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFComments
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
ConstructorsConstructorDescriptionConstruct XWPFComments from scratch for a new document.XWPFComments(POIXMLDocumentPart parent, PackagePart part) Construct XWPFComments from a package part -
Method Summary
Modifier and TypeMethodDescriptionaddPictureData(byte[] pictureData, int format) Deprecated.addPictureData(byte[] pictureData, PictureType pictureType) Adds a picture to the comments.addPictureData(InputStream is, int format) Adds a picture to the comments.addPictureData(InputStream is, PictureType pictureType) Adds a picture to the comments.protected voidcommit()save and commit commentscreateComment(BigInteger cid) Create a new comment and add it to the document.getComment(int pos) Get the specified comment by positiongetComment(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComment ctComment) Get the specified comment by ctCommentgetCommentByID(String id) Get the specified comment by comment idGet the list ofXWPFCommentin the Comments part.org.openxmlformats.schemas.wordprocessingml.x2006.main.CTCommentsGets the underlying CTComments object for the comments.voidread comments form an existing packagebooleanremoveComment(int pos) Remove the specified comment if present.voidsetCtComments(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComments ctComments) set a new commentsvoidsetXWPFDocument(XWPFDocument document) Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createHyperlink, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getReferenceRelationship, getReferenceRelationships, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeReferenceRelationship, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
Constructor Details
-
XWPFComments
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 Details
-
onDocumentRead
read comments form an existing package- Overrides:
onDocumentReadin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException when a document is read
-
addPictureData
Adds 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.IOException- If reading the picture-data from the stream fails.- See Also:
-
addPictureData
public String addPictureData(InputStream is, PictureType pictureType) throws InvalidFormatException, IOException Adds 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.IOException- If reading the picture-data from the stream fails.- Since:
- 5.2.3
-
addPictureData
@Deprecated @Removal(version="7.0.0") public String addPictureData(byte[] pictureData, int format) throws InvalidFormatException Deprecated.useaddPictureData(byte[], PictureType)instead.Adds 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 String addPictureData(byte[] pictureData, PictureType pictureType) throws InvalidFormatException Adds 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:
- 5.2.3
-
commit
save and commit comments- Overrides:
commitin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException if the changes can't be committed
-
getAllPictures
-
getCtComments
public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComments getCtComments()Gets the underlying CTComments object for the comments.- Returns:
- CTComments object
-
setCtComments
@Internal public void setCtComments(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComments ctComments) set a new comments -
getComments
Get the list ofXWPFCommentin the Comments part. -
getComment
Get the specified comment by position- Parameters:
pos- Array position of the comment
-
getCommentByID
Get the specified comment by comment id- Parameters:
id- comment id- Returns:
- the specified comment
-
getComment
public XWPFComment getComment(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComment ctComment) Get the specified comment by ctComment -
createComment
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
-
setXWPFDocument
-
addPictureData(byte[], PictureType)instead.