Bug 58315 - NullPointerException by XSSFRichTextString.getFontAtIndex
Summary: NullPointerException by XSSFRichTextString.getFontAtIndex
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.12-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 59098 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-09-02 12:46 UTC by Florian Lindermaier
Modified: 2016-03-11 22:24 UTC (History)
1 user (show)



Attachments
Sample Project To Show the bug (25.19 KB, application/forced-download)
2015-09-02 12:46 UTC, Florian Lindermaier
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Lindermaier 2015-09-02 12:46:01 UTC
Created attachment 33058 [details]
Sample Project To Show the bug

Hello,

i need to find striked out Characters in a Cell. In my Cell is a String containing "320 338 350". " 388" is striked out and has a blue color.

My code breaks when trying to retriev the Font(richText.getFontAtIndex(i)) with i==2. At i==2 the Font changes from a the rich text font(getFontAtIndex is returning a Font) to the cell font(getFontAtIndex should return null).

for (int i = richText.length() - 1; i >= 0; i--) {
    Font f = richText.getFontAtIndex(i);
    if (f != null && f.getStrikeout()) {
        tmpCellContent.deleteCharAt(i);
    }
}

I attached a sample project. Run the unit test
Comment 1 Dominik Stadler 2015-09-05 13:06:57 UTC
I put in a simple fix via r1701382, you can verify the changes with a recent nightly build or the upcoming 3.13-beta2.
Comment 2 Dominik Stadler 2016-03-11 22:24:47 UTC
*** Bug 59098 has been marked as a duplicate of this bug. ***