poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47924] New: cell.getCellComment may return wrong comment
Date Thu, 01 Oct 2009 11:31:13 GMT
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


Mime
View raw message