poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1837082 - in /poi/trunk/src/ooxml/java/org/apache/poi/xssf: eventusermodel/XSSFSheetXMLHandler.java extractor/XSSFEventBasedExcelExtractor.java model/Comments.java model/CommentsTable.java usermodel/XSSFSheet.java
Date Mon, 30 Jul 2018 18:44:58 GMT
Author: fanningpj
Date: Mon Jul 30 18:44:58 2018
New Revision: 1837082

URL: http://svn.apache.org/viewvc?rev=1837082&view=rev
Log:
add new public method to expose cell addresses that have comments

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/Comments.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java?rev=1837082&r1=1837081&r2=1837082&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java Mon
Jul 30 18:44:58 2018
@@ -18,6 +18,7 @@ package org.apache.poi.xssf.eventusermod
 
 import static org.apache.poi.xssf.usermodel.XSSFRelation.NS_SPREADSHEETML;
 
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Queue;
 
@@ -115,7 +116,7 @@ public class XSSFSheetXMLHandler extends
     */
    public XSSFSheetXMLHandler(
            Styles styles,
-           CommentsTable comments,
+           Comments comments,
            SharedStrings strings,
            SheetContentsHandler sheetContentsHandler,
            DataFormatter dataFormatter,
@@ -159,11 +160,11 @@ public class XSSFSheetXMLHandler extends
        this(styles, strings, sheetContentsHandler, new DataFormatter(), formulasNotResults);
    }
    
-   private void init(CommentsTable commentsTable) {
+   private void init(Comments commentsTable) {
        if (commentsTable != null) {
            commentCellRefs = new LinkedList<>();
-           for (CellAddress cellAddress : commentsTable.getCellComments().keySet()) {
-               commentCellRefs.add(cellAddress);
+           for (Iterator<CellAddress> iter = commentsTable.getCellAddresses(); iter.hasNext();
) {
+               commentCellRefs.add(iter.next());
            }
        }
    }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java?rev=1837082&r1=1837081&r2=1837082&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java
Mon Jul 30 18:44:58 2018
@@ -230,7 +230,7 @@ public class XSSFEventBasedExcelExtracto
     public void processSheet(
             SheetContentsHandler sheetContentsExtractor,
             Styles styles,
-            CommentsTable comments,
+            Comments comments,
             SharedStrings strings,
             InputStream sheetInputStream)
             throws IOException, SAXException {
@@ -277,7 +277,7 @@ public class XSSFEventBasedExcelExtracto
                     text.append(iter.getSheetName());
                     text.append('\n');
                 }
-                CommentsTable comments = includeCellComments ? iter.getSheetComments() :
null;
+                Comments comments = includeCellComments ? iter.getSheetComments() : null;
                 processSheet(sheetExtractor, styles, comments, strings, stream);
                 if (includeHeadersFooters) {
                     sheetExtractor.appendHeaderText(text);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/Comments.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/Comments.java?rev=1837082&r1=1837081&r2=1837082&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/Comments.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/Comments.java Mon Jul 30 18:44:58 2018
@@ -19,6 +19,8 @@ package org.apache.poi.xssf.model;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 
+import java.util.Iterator;
+
 /**
  * An interface exposing useful functions for dealing with Excel Workbook Comments.
  * It is intended that this interface should support low level access and not expose
@@ -49,4 +51,11 @@ public interface Comments {
      * @return returns true if a comment was removed
      */
     boolean removeComment(CellAddress cellRef);
+
+    /**
+     * Returns all cell addresses that have comments.
+     * @return An iterator to traverse all cell addresses that have comments.
+     * @since 4.0.0
+     */
+    Iterator<CellAddress> getCellAddresses();
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java?rev=1837082&r1=1837081&r2=1837082&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java Mon Jul 30 18:44:58
2018
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
@@ -30,6 +31,7 @@ import org.apache.poi.ooxml.POIXMLDocume
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.ss.util.CellAddress;
 import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
 import org.apache.poi.xssf.usermodel.XSSFComment;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
@@ -157,17 +159,31 @@ public class CommentsTable extends POIXM
         // Return the comment, or null if not known
         return commentRefs.get(cellRef);
     }
-    
+
+    /**
+     * Returns all cell addresses that have comments.
+     * @return An iterator to traverse all cell addresses that have comments.
+     * @since 4.0.0
+     */
+    @Override
+    public Iterator<CellAddress> getCellAddresses() {
+        prepareCTCommentCache();
+        return commentRefs.keySet().iterator();
+    }
+
     /**
      * Returns all cell comments on this sheet.
      * @return A map of each Comment in this sheet, keyed on the cell address where
      * the comment is located.
+     * @deprecated use <code>getCellAddresses</code> instead
      */
+    @Removal(version = "4.2")
+    @Deprecated
     public Map<CellAddress, XSSFComment> getCellComments() {
         prepareCTCommentCache();
         final TreeMap<CellAddress, XSSFComment> map = new TreeMap<>();
         
-        for (final Entry<CellAddress, CTComment> e: commentRefs.entrySet()) {
+        for (final Entry<CellAddress, CTComment> e : commentRefs.entrySet()) {
             map.put(e.getKey(), new XSSFComment(this, e.getValue(), null));
         }
         

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1837082&r1=1837081&r2=1837082&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Mon Jul 30 18:44:58
2018
@@ -845,7 +845,8 @@ public class XSSFSheet extends POIXMLDoc
         }
         // the cell comments in sheetComments.getCellComments() do not have the client anchors
set
         Map<CellAddress, XSSFComment> map = new HashMap<>();
-        for(CellAddress address : sheetComments.getCellComments().keySet()) {
+        for(Iterator<CellAddress> iter = sheetComments.getCellAddresses(); iter.hasNext();
) {
+            CellAddress address = iter.next();
             map.put(address, getCellComment(address));
         }
         return map;



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


Mime
View raw message