Bug 58315

Summary: NullPointerException by XSSFRichTextString.getFontAtIndex
Product: POI Reporter: Florian Lindermaier <florian.lindermaier>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: jmarkmurph
Priority: P2    
Version: 3.12-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Sample Project To Show the 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. ***