From b342bc5d8b3021d61aacaed91e2bae567bcd221d Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Fri, 16 May 2014 07:09:55 +0000 Subject: [PATCH] Fix Bug 56514, add missing null-check if simple shape does not have any text git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1595127 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/XSSFSimpleShape.java | 29 +++------------- .../poi/xssf/usermodel/TestXSSFDrawing.java | 31 ++++++++++++++++-- test-data/spreadsheet/56514.xlsx | Bin 0 -> 10525 bytes 3 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 test-data/spreadsheet/56514.xlsx diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java index 44fc91bbf9..7ce8c4e0df 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java @@ -25,28 +25,7 @@ import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.util.Internal; import org.apache.poi.util.Units; -import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D; -import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun; -import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor; -import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph; -import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D; -import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextHorzOverflowType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextVertOverflowType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextVerticalType; -import org.openxmlformats.schemas.drawingml.x2006.main.STTextWrappingType; +import org.openxmlformats.schemas.drawingml.x2006.main.*; import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape; import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRElt; @@ -81,8 +60,10 @@ public class XSSFSimpleShape extends XSSFShape implements Iterable shapes = drawing.getShapes(); + assertEquals(4, shapes.size()); + + wb = XSSFTestDataSamples.writeOutAndReadBack(wb); + + shapes = drawing.getShapes(); + assertEquals(4, shapes.size()); + +/* OutputStream stream = new FileOutputStream(new File("C:\\temp\\56514.xlsx")); + try { + wb.write(stream); + } finally { + stream.close(); + }*/ + } } diff --git a/test-data/spreadsheet/56514.xlsx b/test-data/spreadsheet/56514.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..29163a5febe535294233460d2d78844998387ecb GIT binary patch literal 10525 zcmeHNWmr^e*QUD}Q0Wk)K>-2jE~$|QX(Xh(yCejL0fnJkB&0@=?r!OpmKdZZztMBv z&vQ7w-}U`}-+f)P_v~wC-80XA?zPsvp7p3IBBKBh&=4>X5D;h)GP+u2tPv3q;!qI~ zh!HT5^d#-=T+HoU4Angy%$=Wec-Y#|WTPN4Wg;NKzyIIkKll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