From e224d82fe5927d95e96b30544f271d3e2b5a9871 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 22 Dec 2014 14:16:23 +0000 Subject: [PATCH] Bug 57362: Properly initialize chart axis when loading a workbook which already contains a chart. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647317 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/xssf/usermodel/XSSFChart.java | 17 +++++++------- .../usermodel/charts/TestXSSFChartAxis.java | 22 ++++++++++++++++++ test-data/spreadsheet/57362.xlsx | Bin 0 -> 13283 bytes 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 test-data/spreadsheet/57362.xlsx diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java index 41038114f6..0f2179a9dc 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java @@ -79,14 +79,13 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA */ private CTChart chart; - List axis; + List axis = new ArrayList(); /** * Create a new SpreadsheetML chart */ protected XSSFChart() { super(); - axis = new ArrayList(); createChart(); } @@ -227,13 +226,13 @@ public final class XSSFChart extends POIXMLDocumentPart implements Chart, ChartA return categoryAxis; } - public List getAxis() { - if (axis.isEmpty() && hasAxis()) { - parseAxis(); - } - return axis; - } - + public List getAxis() { + if (axis.isEmpty() && hasAxis()) { + parseAxis(); + } + return axis; + } + public XSSFManualLayout getManualLayout() { return new XSSFManualLayout(this); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java index 0188c71555..f1351f1862 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java @@ -17,9 +17,14 @@ package org.apache.poi.xssf.usermodel.charts; +import java.util.List; + import junit.framework.TestCase; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.charts.*; +import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.usermodel.*; public final class TestXSSFChartAxis extends TestCase { @@ -111,4 +116,21 @@ public final class TestXSSFChartAxis extends TestCase { axis.setMinorTickMark(AxisTickMark.CROSS); assertEquals(AxisTickMark.CROSS, axis.getMinorTickMark()); } + + public void testGetChartAxisBug57362() { + //Load existing excel with some chart on it having primary and secondary axis. + final Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("57362.xlsx"); + final Sheet sh = workbook.getSheetAt(0); + final XSSFSheet xsh = (XSSFSheet) sh; + final XSSFDrawing drawing = xsh.createDrawingPatriarch(); + final XSSFChart chart = drawing.getCharts().get(0); + + final List axisList = chart.getAxis(); + + assertEquals(4, axisList.size()); + assertNotNull(axisList.get(0)); + assertNotNull(axisList.get(1)); + assertNotNull(axisList.get(2)); + assertNotNull(axisList.get(3)); + } } diff --git a/test-data/spreadsheet/57362.xlsx b/test-data/spreadsheet/57362.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..ec2be38234f922651c9b441048481a7077c9dc88 GIT binary patch literal 13283 zcmeIYg;!k5(mo8q-QC^YC3tYR5D4z>8r&_oLvVL@3GVI=!GZ^O_)T)oy~)YR_x%I! z-D}P4+0)a{n(D6Vs(PyAr9ePYfxv+vfq;OBfb3q=@FoBQ0m*{{0iggvzS0o3wsJ7E za?n$aR z?;lRQg-uHn#9`ofmg8@<>nwnCBU*G8?`uHq?t;d)xPdb|KgYmVrfE>{CZe(Sje>-{ zD!uuTK;W34yxJ>&bz|ERGlk@~QOjq2%*Epuv7y&%)p!aK^x32796!JlWbxVLB zWIv!D6DM~0xgn%e=Qx9`*YUVhGR%DhTU&ddexq9GM>D7|fFHD$hClQ@K6RAQ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