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/17 23:35:17 UTC

svn commit: r1895129 - in /poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf: model/CommentsTable.java usermodel/XSSFSheet.java

Author: fanningpj
Date: Wed Nov 17 23:35:16 2021
New Revision: 1895129

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

Modified:
    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/XSSFSheet.java

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=1895129&r1=1895128&r2=1895129&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 Wed Nov 17 23:35:16 2021
@@ -97,7 +97,7 @@ public class CommentsTable extends POIXM
     }
 
     /**
-     * @return iterator of comments
+     * @return iterator of comments (without their VML Shapes set)
      * @since POI 5.2.0
      */
     public Iterator<XSSFComment> commentIterator() {

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1895129&r1=1895128&r2=1895129&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Wed Nov 17 23:35:16 2021
@@ -3115,14 +3115,14 @@ public class XSSFSheet extends POIXMLDoc
 
                 // is there a change necessary for the current row?
                 if(newrownum != rownum) {
-                    CTCommentList lst = sheetComments.getCTComments().getCommentList();
-                    for (CTComment comment : lst.getCommentArray()) {
-                        String oldRef = comment.getRef();
-                        CellReference ref = new CellReference(oldRef);
+                    Iterator<XSSFComment> commentIterator = sheetComments.commentIterator();
+                    while (commentIterator.hasNext()) {
+                        XSSFComment oldComment = commentIterator.next();
+                        CellReference ref = new CellReference(oldComment.getRow(), oldComment.getColumn());
 
                         // is this comment part of the current row?
                         if(ref.getRow() == rownum) {
-                            XSSFComment xssfComment = new XSSFComment(sheetComments, comment,
+                            XSSFComment xssfComment = new XSSFComment(sheetComments, oldComment.getCTComment(),
                                     vml == null ? null : vml.findCommentShape(rownum, ref.getCol()));
 
                             // we should not perform the shifting right here as we would then find
@@ -3199,16 +3199,16 @@ public class XSSFSheet extends POIXMLDoc
         });
 
 
-        if(sheetComments != null){
-            CTCommentList lst = sheetComments.getCTComments().getCommentList();
-            for (CTComment comment : lst.getCommentArray()) {
-                String oldRef = comment.getRef();
-                CellReference ref = new CellReference(oldRef);
+        if (sheetComments != null) {
+            Iterator<XSSFComment> commentIterator = sheetComments.commentIterator();
+            while (commentIterator.hasNext()) {
+                XSSFComment oldComment = commentIterator.next();
+                CellReference ref = new CellReference(oldComment.getRow(), oldComment.getColumn());
 
                 int columnIndex =ref.getCol();
                 int newColumnIndex = shiftedRowNum(startColumnIndex, endColumnIndex, n, columnIndex);
                 if(newColumnIndex != columnIndex){
-                    XSSFComment xssfComment = new XSSFComment(sheetComments, comment,
+                    XSSFComment xssfComment = new XSSFComment(sheetComments, oldComment.getCTComment(),
                             vml == null ? null : vml.findCommentShape(ref.getRow(), columnIndex));
                     commentsToShift.put(xssfComment, newColumnIndex);
                 }



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