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 2009/10/01 13:31:13 UTC
DO NOT REPLY [Bug 47924] New: cell.getCellComment may return wrong
comment
https://issues.apache.org/bugzilla/show_bug.cgi?id=47924
Summary: cell.getCellComment may return wrong comment
Product: POI
Version: 3.5-FINAL
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: HSSF
AssignedTo: dev@poi.apache.org
ReportedBy: Karl.Eilebrecht@freenet.de
Created an attachment (id=24328)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=24328)
standalone quickfix for testing
The method getCellComment() located at HSSFCell may return a wrong comment if
more comments have been added later.
Problem: The method HSSFCell.findCellComment() makes an assumption about
the ordering of text records that is probably wrong.
Line 1084
" //find the next TextObjectRecord which holds the comment's text
//the order of TXO matches the order of NoteRecords: i-th TXO record
corresponds to the i-th NoteRecord"
Steps to reproduce:
- create an excel sheet with some cell comments
- close and re-open it
- add a new comment to a cell above(!) the existing comments
- go through existing cells and output the result of cell.getCellComment()
Some comments will not match these you typed in in excel.
Solution proposal:
==================
Match objectId of text record with note's shape Id for
a correct assignment.
Replace list by a map in line 1057
Map<Integer, TextObjectRecord> noteTxo =
new HashMap<Integer, TextObjectRecord>();
Change line 1089
noteTxo.put(cmo.getObjectId(), (TextObjectRecord) rec);
Change line 1065
TextObjectRecord txo = noteTxo.get(note.getShapeId());
WARNING: This is a new assumption. I did not verify this under all
circumstances or against documentation. But in my environment it runs fine.
For those being in a hurry I attach a standalone quick fix hack (works without
patching the jar).
--
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 47924] cell.getCellComment may return wrong
comment
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47924
Karl Eilebrecht <Ka...@freenet.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Karl.Eilebrecht@freenet.de
--
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 47924] cell.getCellComment may return wrong
comment
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47924
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2009-10-29 09:56:05 UTC ---
Karl,
A very good catch, thanks!
The logic to match NoteRecord and TextObjectRecord should not rely on the order
of records, instead it should match them by objectId, as you suggested. I
easily reproduced the bug in Excel 2003 and Excel 2007.
P.S. I wrote this code some years ago when the Excel spec was closed. Most of
it was derived by trial and error and hence can be not optimal.
Regards,
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