You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/11/18 11:38:56 UTC

svn commit: r1895146 - in /poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf: model/Comments.java model/CommentsTable.java usermodel/XSSFComment.java

Author: fanningpj
Date: Thu Nov 18 11:38:56 2021
New Revision: 1895146

URL: http://svn.apache.org/viewvc?rev=1895146&view=rev
Log:
try to make CommentsTable more extensible

Modified:
    poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
    poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
    poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java?rev=1895146&r1=1895145&r2=1895146&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/Comments.java Thu Nov 18 11:38:56 2021
@@ -17,7 +17,9 @@
 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;
 
@@ -58,4 +60,28 @@ public interface Comments {
      * @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);
 }

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java?rev=1895146&r1=1895145&r2=1895146&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/model/CommentsTable.java Thu Nov 18 11:38:56 2021
@@ -100,6 +100,7 @@ public class CommentsTable extends POIXM
      * @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>() {
@@ -142,6 +143,7 @@ public class CommentsTable extends POIXM
      * @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);
@@ -239,6 +241,7 @@ public class CommentsTable extends POIXM
      * @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();

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java?rev=1895146&r1=1895145&r2=1895146&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFComment.java Thu Nov 18 11:38:56 2021
@@ -25,6 +25,7 @@ import org.apache.poi.ss.usermodel.Comme
 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;
@@ -36,7 +37,7 @@ import com.microsoft.schemas.vml.CTShape
 public class XSSFComment implements Comment {
     
     private final CTComment _comment;
-    private final CommentsTable _comments;
+    private final Comments _comments;
     private final CTShape _vmlShape;
 
     /**
@@ -49,6 +50,15 @@ public class XSSFComment implements Comm
      *  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;
@@ -60,7 +70,7 @@ public class XSSFComment implements Comm
             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);
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org