ASF Bugzilla – Attachment 24328 Details for
Bug 47924
cell.getCellComment may return wrong comment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
standalone quickfix for testing
quickfixhack_comment_problem.txt (text/plain), 2.94 KB, created by
Karl Eilebrecht
on 2009-10-01 04:31:08 UTC
(
hide
)
Description:
standalone quickfix for testing
Filename:
MIME Type:
Creator:
Karl Eilebrecht
Created:
2009-10-01 04:31:08 UTC
Size:
2.94 KB
patch
obsolete
> /** > * This method is a temporary fix for a problem with cell comment assignment.<br> > * The method cell.getCellComment() sucks when a comment has been inserted later (broken order).<br> > * @param wsheet current worksheet > * @param rowIdx current row index > * @param colIdx current column index > * @return > */ > public static HSSFComment findCorrectCellComment(HSSFSheet wsheet, int rowIdx, int colIdx) { > HSSFComment comment = null; > try { > Method m = HSSFSheet.class.getDeclaredMethod("getSheet"); > m.setAccessible(true); > Sheet sheet = (Sheet)m.invoke(wsheet); > Map<Integer, TextObjectRecord> noteTxo = new HashMap<Integer, TextObjectRecord>(); > int i = 0; > for (Iterator<RecordBase> it = sheet.getRecords().iterator(); it.hasNext();) { > RecordBase rec = it.next(); > if (rec instanceof NoteRecord) { > NoteRecord note = (NoteRecord) rec; > if (note.getRow() == rowIdx && note.getColumn() == colIdx) { > if(i < noteTxo.size()) { > TextObjectRecord txo = noteTxo.get(note.getShapeId()); > Constructor<HSSFComment> con = HSSFComment.class.getDeclaredConstructor(NoteRecord.class, TextObjectRecord.class); > con.setAccessible(true); > comment = con.newInstance(note, txo); //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 { > System.out.println("Failed to match NoteRecord and TextObjectRecord, row: " + rowIdx + ", column: " + colIdx); > } > break; > } > i++; > } else if (rec instanceof ObjRecord) { > ObjRecord obj = (ObjRecord) rec; > SubRecord sub = obj.getSubRecords().get(0); > if (sub instanceof CommonObjectDataSubRecord) { > CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord) sub; > if (cmo.getObjectType() == CommonObjectDataSubRecord.OBJECT_TYPE_COMMENT) { > while (it.hasNext()) { > rec = it.next(); > if (rec instanceof TextObjectRecord) { > noteTxo.put(cmo.getObjectId(), (TextObjectRecord) rec); > break; > } > } > } > } > } > } > } > catch (Exception ex) { > ex.printStackTrace(); > } > return comment; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 47924
: 24328