poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1647317 - in /poi/trunk: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java test-data/spreadsheet/57362.xlsx
Date Mon, 22 Dec 2014 14:16:24 GMT
Author: centic
Date: Mon Dec 22 14:16:23 2014
New Revision: 1647317

URL: http://svn.apache.org/r1647317
Log:
Bug 57362: Properly initialize chart axis when loading a workbook which already contains a
chart.

Added:
    poi/trunk/test-data/spreadsheet/57362.xlsx   (with props)
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java?rev=1647317&r1=1647316&r2=1647317&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java Mon Dec 22 14:16:23
2014
@@ -79,14 +79,13 @@ public final class XSSFChart extends POI
 	 */
 	private CTChart chart;
 
-	List<XSSFChartAxis> axis;
+	List<XSSFChartAxis> axis = new ArrayList<XSSFChartAxis>();
 
 	/**
 	 * Create a new SpreadsheetML chart
 	 */
 	protected XSSFChart() {
 		super();
-		axis = new ArrayList<XSSFChartAxis>();
 		createChart();
 	}
 
@@ -227,13 +226,13 @@ public final class XSSFChart extends POI
 		return categoryAxis;
 	}
 
-	public List<? extends XSSFChartAxis> getAxis() {
-		if (axis.isEmpty() && hasAxis()) {
-			parseAxis();
-		}
-		return axis;
-	}
-
+    public List<? extends XSSFChartAxis> getAxis() {
+        if (axis.isEmpty() && hasAxis()) {
+            parseAxis();
+        }
+        return axis;
+    }
+	
 	public XSSFManualLayout getManualLayout() {
 		return new XSSFManualLayout(this);
 	}

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java?rev=1647317&r1=1647316&r2=1647317&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java
Mon Dec 22 14:16:23 2014
@@ -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 ext
 		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<? extends XSSFChartAxis> axisList = chart.getAxis();
+
+        assertEquals(4, axisList.size());
+        assertNotNull(axisList.get(0));
+        assertNotNull(axisList.get(1));
+        assertNotNull(axisList.get(2));
+        assertNotNull(axisList.get(3));
+	}
 }

Added: poi/trunk/test-data/spreadsheet/57362.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/57362.xlsx?rev=1647317&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/57362.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message