package org.apache.poi.xssf.model;
import org.apache.poi.ss.util.CellAddress;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFComment;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
import java.util.Iterator;
* @since 4.0.0
*/
Iterator<CellAddress> getCellAddresses();
+
+ /**
+ * @return iterator of comments (without their VML Shapes set)
+ * @since POI 5.2.0
+ */
+ Iterator<XSSFComment> commentIterator();
+
+ /**
+ * Create a new comment and add to the CommentTable.
+ * @param sheet sheet to add comment to
+ * @param clientAnchor the anchor for this comment
+ * @return new XSSFComment
+ * @since POI 5.2.0
+ */
+ XSSFComment createNewComment(XSSFSheet sheet, XSSFClientAnchor clientAnchor);
+
+ /**
+ * Called after the reference is updated, so that
+ * we can reflect that in our cache
+ * @param oldReference the comment to remove from the commentRefs map
+ * @param comment the comment to replace in the commentRefs map
+ * @since POI 5.2.0
+ */
+ void referenceUpdated(CellAddress oldReference, XSSFComment comment);
}
* @return iterator of comments (without their VML Shapes set)
* @since POI 5.2.0
*/
+ @Override
public Iterator<XSSFComment> commentIterator() {
final CommentsTable table = this;
return new Iterator<XSSFComment>() {
* @param comment the comment to replace in the commentRefs map
* @since POI 5.2.0
*/
+ @Override
public void referenceUpdated(CellAddress oldReference, XSSFComment comment) {
if(commentRefs != null) {
commentRefs.remove(oldReference);
* @return new XSSFComment
* @since POI 5.2.0
*/
+ @Override
public XSSFComment createNewComment(XSSFSheet sheet, XSSFClientAnchor clientAnchor) {
XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
com.microsoft.schemas.vml.CTShape vmlShape = vml.newCommentShape();
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.model.Comments;
import org.apache.poi.xssf.model.CommentsTable;
import org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STTrueFalseBlank;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
public class XSSFComment implements Comment {
private final CTComment _comment;
- private final CommentsTable _comments;
+ private final Comments _comments;
private final CTShape _vmlShape;
/**
* low level comment object.
*/
public XSSFComment(CommentsTable comments, CTComment comment, CTShape vmlShape) {
+ this((Comments)comments, comment, vmlShape);
+ }
+
+ /**
+ * Creates a new XSSFComment, associated with a given
+ * low level comment object.
+ * @since POI 5.2.0
+ */
+ public XSSFComment(Comments comments, CTComment comment, CTShape vmlShape) {
_comment = comment;
_comments = comments;
_vmlShape = vmlShape;
CTClientData clientData = vmlShape.getClientDataArray(0);
clientData.setRowArray(0, new BigInteger(String.valueOf(ref.getRow())));
clientData.setColumnArray(0, new BigInteger(String.valueOf(ref.getCol())));
-
+
avoidXmlbeansCorruptPointer(vmlShape);
}
}