Bug 57826

Summary: [PATCH] XSSFSimpleShape.getText throws NullPointerException
Product: POI Reporter: Jon Scharff <jon_s>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: jon_s
Priority: P2 Keywords: PatchAvailable
Version: 3.11-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: An xlsx file that exhibits the issue
[patch] testcase for the bug (made with ant -f patch.xml).

Description Jon Scharff 2015-04-17 07:34:53 UTC
Created attachment 32657 [details]
An xlsx file that exhibits the issue

A NullPointerException occurs when running extractor.XSSFExcelExtractor on the attached xlsx file.

It is possible have a shape containing a paragraph with property BuFont but none of the properties BuNone, BuChar, and BuAutoNum. This is the case with the text box containing text "test fail" in the attached file. *

In this case, usermodel.XSSFTextParagraph.isBullet() returns true.

usermodel.XSSFSimpleShape.getText() expects that if p.isBullet() is true then either p.isBulletAutoNumber() is true or p.getBulletCharacter() returns a non-null string. However, with the attached file, this is not the case.

Excel 2010 treats the textbox as not being bulleted, so perhaps XSSFTextParagraph.isBullet() should return false in this case. Otherwise, XSSFSimpleShape.getText() should perform a null check before using the result of p.getBulletCharacter() (or both?).

* I have no idea how the text box got in this state, but it was mostly likely done with Microsoft products...
Comment 1 Jon Scharff 2015-04-20 06:14:41 UTC
Created attachment 32663 [details]
[patch] testcase for the bug (made with ant -f patch.xml).

includes an xlsx that exhibits the issue and a junit test added to usermodel.TestUnfixedBugs in ooxml/testcases.
Comment 2 Dominik Stadler 2015-04-20 20:45:26 UTC
Comment on attachment 32663 [details]
[patch] testcase for the bug (made with ant -f patch.xml).

.
Comment 3 Nick Burch 2015-04-29 19:22:06 UTC
Thanks! Fixed in r1676831, using your test to verify it's all working