View | Details | Raw Unified | Return to bug 58365
Collapse All | Expand All

(-)src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (+27 lines)
Lines 19-26 Link Here
19
19
20
import java.io.PrintWriter;
20
import java.io.PrintWriter;
21
import java.util.ArrayList;
21
import java.util.ArrayList;
22
import java.util.HashSet;
22
import java.util.Iterator;
23
import java.util.Iterator;
23
import java.util.List;
24
import java.util.List;
25
import java.util.Set;
24
import java.util.TreeMap;
26
import java.util.TreeMap;
25
27
26
import org.apache.poi.ddf.EscherRecord;
28
import org.apache.poi.ddf.EscherRecord;
Lines 2194-2199 Link Here
2194
        return null;
2196
        return null;
2195
    }
2197
    }
2196
2198
2199
    public Set<String> getAllCellCommentRefs() {
2200
        HSSFPatriarch patriarch = getDrawingPatriarch();
2201
        if (null == patriarch) {
2202
            patriarch = createDrawingPatriarch();
2203
        }
2204
        Set<String> locations = new HashSet<String>();
2205
        findCellCommentLocations(patriarch, locations);
2206
        return locations;
2207
    }
2208
    private void findCellCommentLocations(HSSFShapeContainer container, Set<String> locations){
2209
        for (Object object : container.getChildren()) {
2210
            HSSFShape shape = (HSSFShape) object;
2211
            if (shape instanceof HSSFShapeGroup) {
2212
                findCellCommentLocations((HSSFShapeGroup) shape, locations);
2213
                continue;
2214
            }
2215
            if (shape instanceof HSSFComment) {
2216
                HSSFComment comment = (HSSFComment) shape;
2217
                if (comment.hasPosition()) {
2218
                    locations.add(org.apache.poi.hssf.util.CellReference.convertNumToColString(comment.getColumn())+comment.getRow());
2219
                }
2220
            }
2221
        }
2222
    }
2223
2197
2224
2198
    public CellRangeAddress getRepeatingRows() {
2225
    public CellRangeAddress getRepeatingRows() {
2199
        return getRepeatingRowsOrColums(true);
2226
        return getRepeatingRowsOrColums(true);
(-)src/java/org/apache/poi/ss/usermodel/Sheet.java (+9 lines)
Lines 19-24 Link Here
19
19
20
import java.util.Iterator;
20
import java.util.Iterator;
21
import java.util.List;
21
import java.util.List;
22
import java.util.Set;
22
23
23
import org.apache.poi.hssf.util.PaneInformation;
24
import org.apache.poi.hssf.util.PaneInformation;
24
import org.apache.poi.ss.util.CellRangeAddress;
25
import org.apache.poi.ss.util.CellRangeAddress;
Lines 1067-1070 Link Here
1067
     *  you take it out of them.
1068
     *  you take it out of them.
1068
     */
1069
     */
1069
    int getColumnOutlineLevel(int columnIndex);
1070
    int getColumnOutlineLevel(int columnIndex);
1071
1072
1073
    /**
1074
     * Returns all cell addresses of this sheet
1075
     * having one or more comments associated.
1076
     * @return A set of cell references (in no particular order).
1077
     */
1078
    Set<String> getAllCellCommentRefs();
1070
}
1079
}
(-)src/ooxml/java/org/apache/poi/xssf/model/CommentsTable.java (-3 / +19 lines)
Lines 19-26 Link Here
19
import java.io.IOException;
19
import java.io.IOException;
20
import java.io.InputStream;
20
import java.io.InputStream;
21
import java.io.OutputStream;
21
import java.io.OutputStream;
22
import java.util.Collections;
22
import java.util.HashMap;
23
import java.util.HashMap;
23
import java.util.Map;
24
import java.util.Map;
25
import java.util.Set;
24
26
25
import org.apache.poi.POIXMLDocumentPart;
27
import org.apache.poi.POIXMLDocumentPart;
26
import org.apache.poi.openxml4j.opc.PackagePart;
28
import org.apache.poi.openxml4j.opc.PackagePart;
Lines 40-45 Link Here
40
     *  map for fast lookup.
42
     *  map for fast lookup.
41
     */
43
     */
42
    private Map<String, CTComment> commentRefs;
44
    private Map<String, CTComment> commentRefs;
45
    private Set<String> commentRefsUnmodifiable;
43
46
44
    public CommentsTable() {
47
    public CommentsTable() {
45
        super();
48
        super();
Lines 117-131 Link Here
117
    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
120
    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
118
    public CTComment getCTComment(String cellRef) {
121
    public CTComment getCTComment(String cellRef) {
119
        // Create the cache if needed
122
        // Create the cache if needed
123
        prepareCTCommentCache();
124
125
        // Return the comment, or null if not known
126
        return commentRefs.get(cellRef);
127
    }
128
    
129
    public Set<String> getAllCommentRefs(){
130
        prepareCTCommentCache();
131
        
132
        return commentRefsUnmodifiable;
133
    }
134
135
    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
136
    private void prepareCTCommentCache() {
137
        // Create the cache if needed
120
        if(commentRefs == null) {
138
        if(commentRefs == null) {
121
           commentRefs = new HashMap<String, CTComment>();
139
           commentRefs = new HashMap<String, CTComment>();
122
           for (CTComment comment : comments.getCommentList().getCommentArray()) {
140
           for (CTComment comment : comments.getCommentList().getCommentArray()) {
123
              commentRefs.put(comment.getRef(), comment);
141
              commentRefs.put(comment.getRef(), comment);
124
           }
142
           }
143
           commentRefsUnmodifiable = Collections.unmodifiableSet(commentRefs.keySet());
125
        }
144
        }
126
127
        // Return the comment, or null if not known
128
        return commentRefs.get(cellRef);
129
    }
145
    }
130
146
131
    /**
147
    /**
(-)src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (+5 lines)
Lines 22-27 Link Here
22
import java.util.Iterator;
22
import java.util.Iterator;
23
import java.util.List;
23
import java.util.List;
24
import java.util.Map;
24
import java.util.Map;
25
import java.util.Set;
25
import java.util.TreeMap;
26
import java.util.TreeMap;
26
27
27
import org.apache.poi.hssf.util.PaneInformation;
28
import org.apache.poi.hssf.util.PaneInformation;
Lines 1539-1542 Link Here
1539
    public int getColumnOutlineLevel(int columnIndex) {
1540
    public int getColumnOutlineLevel(int columnIndex) {
1540
        return _sh.getColumnOutlineLevel(columnIndex);
1541
        return _sh.getColumnOutlineLevel(columnIndex);
1541
    }
1542
    }
1543
1544
    public Set<String> getAllCellCommentRefs() {
1545
        return _sh.getAllCellCommentRefs();
1546
    }
1542
}
1547
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (+4 lines)
Lines 3965-3968 Link Here
3965
        }
3965
        }
3966
        return col.getOutlineLevel();
3966
        return col.getOutlineLevel();
3967
    }
3967
    }
3968
3969
    public Set<String> getAllCellCommentRefs() {
3970
        return sheetComments.getAllCommentRefs();
3971
    }
3968
}
3972
}

Return to bug 58365