]> source.dussan.org Git - poi.git/commitdiff
avoid NPE when finding cell comments, Bugzilla 48846
authorYegor Kozlov <yegor@apache.org>
Sat, 22 May 2010 16:24:22 +0000 (16:24 +0000)
committerYegor Kozlov <yegor@apache.org>
Sat, 22 May 2010 16:24:22 +0000 (16:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@947315 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
test-data/spreadsheet/49325.xlsx [new file with mode: 0755]

index ea298f929831f35ee5f5c4741be8f52ccba8552c..bb66430073d56969cba62af3b056db0086b95f6a 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-SNAPSHOT" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">48846 - Avoid NPE when finding cell comments</action>
            <action dev="POI-DEVELOPERS" type="fix">49325 - Ensure that CTPhoneticPr is included in poi-ooxml jar</action>
            <action dev="POI-DEVELOPERS" type="fix">49191 - Fixed tests failing in non-english locales</action>
            <action dev="POI-DEVELOPERS" type="add">48432 - Support for XSSF themes</action>
index ac7ab6f911a6fe33bac1862d3608cea87bc7b195..a490d44dfdeaf6529c79d467b51cddf086fe1560 100644 (file)
@@ -1079,12 +1079,16 @@ public class HSSFCell implements Cell {
                 if (note.getRow() == row && note.getColumn() == column) {
                     if(i < noteTxo.size()) {
                         TextObjectRecord txo = noteTxo.get(note.getShapeId());
-                        comment = new HSSFComment(note, txo);
-                        comment.setRow(note.getRow());
-                        comment.setColumn((short) note.getColumn());
-                        comment.setAuthor(note.getAuthor());
-                        comment.setVisible(note.getFlags() == NoteRecord.NOTE_VISIBLE);
-                        comment.setString(txo.getStr());
+                        if(txo != null){
+                            comment = new HSSFComment(note, txo);
+                            comment.setRow(note.getRow());
+                            comment.setColumn(note.getColumn());
+                            comment.setAuthor(note.getAuthor());
+                            comment.setVisible(note.getFlags() == NoteRecord.NOTE_VISIBLE);
+                            comment.setString(txo.getStr());     
+                        } else{
+                            log.log(POILogger.WARN, "Failed to match NoteRecord and TextObjectRecord, row: " + row + ", column: " + column);
+                         }
                     } else {
                         log.log(POILogger.WARN, "Failed to match NoteRecord and TextObjectRecord, row: " + row + ", column: " + column);
                     }
diff --git a/test-data/spreadsheet/49325.xlsx b/test-data/spreadsheet/49325.xlsx
new file mode 100755 (executable)
index 0000000..adcba90
Binary files /dev/null and b/test-data/spreadsheet/49325.xlsx differ