aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2010-05-22 16:24:22 +0000
committerYegor Kozlov <yegor@apache.org>2010-05-22 16:24:22 +0000
commite79cc21802e5204a508d177aa3ff5d1331101b46 (patch)
tree4add01c3b6634ca3c270fb1e23c298f42d5161ea
parent267082051485df62e56d54486d20e1eb1660fcb1 (diff)
downloadpoi-e79cc21802e5204a508d177aa3ff5d1331101b46.tar.gz
poi-e79cc21802e5204a508d177aa3ff5d1331101b46.zip
avoid NPE when finding cell comments, Bugzilla 48846
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@947315 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/documentation/content/xdocs/status.xml1
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFCell.java16
-rwxr-xr-xtest-data/spreadsheet/49325.xlsxbin0 -> 7429 bytes
3 files changed, 11 insertions, 6 deletions
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index ea298f9298..bb66430073 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -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>
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
index ac7ab6f911..a490d44dfd 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
@@ -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
index 0000000000..adcba90b77
--- /dev/null
+++ b/test-data/spreadsheet/49325.xlsx
Binary files differ