You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2010/03/03 04:00:49 UTC
DO NOT REPLY [Bug 48846] New: TextObjectRecord sometimes become
null, so it must be checked before using.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48846
Summary: TextObjectRecord sometimes become null, so it must be
checked before using.
Product: POI
Version: 3.6
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: dev@poi.apache.org
ReportedBy: benbrand@mac.com
In findCellComment(Sheet, int, int) method of
org.apache.poi.hssf.usermodel.HSSFCell, TextObjectRecord sometimes become null.
-- original code --
for (Iterator<RecordBase> it = sheet.getRecords().iterator();
it.hasNext();) {
RecordBase rec = it.next();
if (rec instanceof NoteRecord) {
NoteRecord note = (NoteRecord) rec;
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());
} else {
log.log(POILogger.WARN, "Failed to match NoteRecord and
TextObjectRecord, row: " + row + ", column: " + column);
}
break;
}
i++;
} else if (rec instanceof ObjRecord) {
--- end ------------
With this code, my program crashed with NullPointerException on line of
'comment.setString(txo.getStr());', because a local variable 'txo' is null.
I changed the code like bellow, then the program works correctly.
--- changed code ---
for (Iterator<RecordBase> it = sheet.getRecords().iterator();
it.hasNext();) {
RecordBase rec = it.next();
if (rec instanceof NoteRecord) {
NoteRecord note = (NoteRecord) rec;
if (note.getRow() == row && note.getColumn() == column) {
if(i < noteTxo.size()) {
TextObjectRecord txo = noteTxo.get(note.getShapeId());
//NEXT LINE IS ADDED
if(txo != null) { // <-- MUST CHECK txo IS NOT NULL.
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());
} 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);
}
break;
}
i++;
} else if (rec instanceof ObjRecord) {
--- end ------------
Thanks.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 48846] TextObjectRecord sometimes become null, so
it must be checked before using.
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48846
Bug 48846 depends on bug 47624, which changed state.
Bug 47624 Summary: File Error Data May Have been Lost error while opening commented workbook(excel file)
https://issues.apache.org/bugzilla/show_bug.cgi?id=47624
What |Old Value |New Value
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 48846] TextObjectRecord sometimes become null, so
it must be checked before using.
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48846
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #3 from Yegor Kozlov <ye...@dinom.ru> 2010-05-22 12:24:47 EDT ---
Fixed in r947315
Thanks,
Yegor
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 48846] TextObjectRecord sometimes become null, so
it must be checked before using.
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48846
nothize <no...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |47624
--- Comment #2 from nothize <no...@gmail.com> 2010-03-18 07:57:16 UTC ---
This issue seems to be related with 47624.
The TextObjectRecord was not removed properly after an EscherAggregate record
has came into play. It was supposed to be part of a paired DrawingRecord and
TextObjectRecord for a cell comment.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 48846] TextObjectRecord sometimes become null, so
it must be checked before using.
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48846
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2010-03-15 06:35:09 UTC ---
The suggested fix looks OK, but can you upload a sample file that demonstrates
the "null TextObjectRecord" issue? I would like to have a junit test case for
this fix.
Yegor
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org