Patch from Jon Scharff from bug #57826 - If a XSSF shape has a buFont but no bullet character, mirror Excel and treat as un-bulleted

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1676831 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2015-04-29 19:21:37 +00:00
parent c029154424
commit b2a1862f19
3 changed files with 38 additions and 4 deletions

View File

@ -713,9 +713,15 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
setValue(false);
return true;
}
if(props.isSetBuFont() || props.isSetBuChar() || props.isSetBuAutoNum()){
if (props.isSetBuFont()) {
if (props.isSetBuChar() || props.isSetBuAutoNum()) {
setValue(true);
return true;
} else {
// Excel treats text with buFont but no char/autonum
// as not bulleted
// Possibly the font is just used if bullets turned on again?
}
}
return false;
}

View File

@ -2369,6 +2369,34 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
checkStyle(styleBack);
}
/**
* Paragraph with property BuFont but none of the properties
* BuNone, BuChar, and BuAutoNum, used to trigger a NPE
* Excel treats this as not-bulleted, so now do we
*/
@Test
public void testBug57826() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("57826.xlsx");
assertTrue("no sheets in workbook", workbook.getNumberOfSheets() >= 1);
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFDrawing drawing = sheet.getDrawingPatriarch();
assertNotNull(drawing);
List<XSSFShape> shapes = drawing.getShapes();
assertEquals(1, shapes.size());
assertTrue(shapes.get(0) instanceof XSSFSimpleShape);
XSSFSimpleShape shape = (XSSFSimpleShape)shapes.get(0);
// Used to throw a NPE
String text = shape.getText();
// No bulleting info included
assertEquals("test ok", text);
}
private void checkStyle(XSSFCellStyle cellStyle) {
assertNotNull(cellStyle);
assertEquals(0, cellStyle.getFillForegroundColor());

Binary file not shown.