You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ab...@apache.org on 2017/11/26 14:03:03 UTC

svn commit: r1816383 [2/5] - in /poi/trunk: ./ src/examples/src/org/apache/poi/xslf/usermodel/ src/examples/src/org/apache/poi/xssf/usermodel/examples/ src/java/org/apache/poi/hssf/usermodel/ src/java/org/apache/poi/ss/usermodel/ src/java/org/apache/po...

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutMode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutMode.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutMode.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutMode.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,44 @@
+/* ====================================================================
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.HashMap;
+
+import org.openxmlformats.schemas.drawingml.x2006.chart.STLayoutMode;;
+
+public enum LayoutMode {
+    EDGE(STLayoutMode.EDGE),
+    FACTOR(STLayoutMode.FACTOR);
+
+    final STLayoutMode.Enum underlying;
+
+    LayoutMode(STLayoutMode.Enum layoutMode) {
+        this.underlying = layoutMode;
+    }
+
+    private final static HashMap<STLayoutMode.Enum, LayoutMode> reverse = new HashMap<STLayoutMode.Enum, LayoutMode>();
+    static {
+        for (LayoutMode value : values()) {
+            reverse.put(value.underlying, value);
+        }
+    }
+
+    static LayoutMode valueOf(STLayoutMode.Enum layoutMode) {
+        return reverse.get(layoutMode);
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutTarget.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutTarget.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutTarget.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LayoutTarget.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,44 @@
+/* ====================================================================
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.HashMap;
+
+import org.openxmlformats.schemas.drawingml.x2006.chart.STLayoutTarget;;
+
+public enum LayoutTarget {
+    INNER(STLayoutTarget.INNER),
+    OUTER(STLayoutTarget.OUTER);
+
+    final STLayoutTarget.Enum underlying;
+
+    LayoutTarget(STLayoutTarget.Enum layoutTarget) {
+        this.underlying = layoutTarget;
+    }
+
+    private final static HashMap<STLayoutTarget.Enum, LayoutTarget> reverse = new HashMap<STLayoutTarget.Enum, LayoutTarget>();
+    static {
+        for (LayoutTarget value : values()) {
+            reverse.put(value.underlying, value);
+        }
+    }
+
+    static LayoutTarget valueOf(STLayoutTarget.Enum layoutTarget) {
+        return reverse.get(layoutTarget);
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LegendPosition.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LegendPosition.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LegendPosition.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/LegendPosition.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,47 @@
+/* ====================================================================
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.HashMap;
+
+import org.openxmlformats.schemas.drawingml.x2006.chart.STLegendPos;
+
+public enum LegendPosition {
+    BOTTOM(STLegendPos.B),
+    LEFT(STLegendPos.L),
+    RIGHT(STLegendPos.R),
+    TOP(STLegendPos.T),
+    TOP_RIGHT(STLegendPos.TR);
+
+    final STLegendPos.Enum underlying;
+
+    LegendPosition(STLegendPos.Enum position) {
+        this.underlying = position;
+    }
+
+    private final static HashMap<STLegendPos.Enum, LegendPosition> reverse = new HashMap<STLegendPos.Enum, LegendPosition>();
+    static {
+        for (LegendPosition value : values()) {
+            reverse.put(value.underlying, value);
+        }
+    }
+
+    static LegendPosition valueOf(STLegendPos.Enum position) {
+        return reverse.get(position);
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/MarkerStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/MarkerStyle.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/MarkerStyle.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/MarkerStyle.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,53 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.HashMap;
+
+import org.openxmlformats.schemas.drawingml.x2006.chart.STMarkerStyle;
+
+public enum MarkerStyle {
+    CIRCLE(STMarkerStyle.CIRCLE),
+    DASH(STMarkerStyle.DASH),
+    DIAMOND(STMarkerStyle.DIAMOND),
+    DOT(STMarkerStyle.DOT),
+    NONE(STMarkerStyle.NONE),
+    PICTURE(STMarkerStyle.PICTURE),
+    PLUS(STMarkerStyle.PLUS),
+    SQUARE(STMarkerStyle.SQUARE),
+    STAR(STMarkerStyle.STAR),
+    TRIANGLE(STMarkerStyle.TRIANGLE),
+    X(STMarkerStyle.X);
+
+    final STMarkerStyle.Enum underlying;
+
+    MarkerStyle(STMarkerStyle.Enum style) {
+        this.underlying = style;
+    }
+
+    private final static HashMap<STMarkerStyle.Enum, MarkerStyle> reverse = new HashMap<STMarkerStyle.Enum, MarkerStyle>();
+    static {
+        for (MarkerStyle value : values()) {
+            reverse.put(value.underlying, value);
+        }
+    }
+
+    static MarkerStyle valueOf(STMarkerStyle.Enum style) {
+        return reverse.get(style);
+    }
+}

Copied: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/RadarStyle.java (from r1816205, poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/RadarStyle.java?p2=poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/RadarStyle.java&p1=poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java&r1=1816205&r2=1816383&rev=1816383&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/RadarStyle.java Sun Nov 26 14:03:01 2017
@@ -15,41 +15,31 @@
    limitations under the License.
 ==================================================================== */
 
-package org.apache.poi.ss.usermodel.charts;
+package org.apache.poi.xddf.usermodel.chart;
 
-import org.apache.poi.ss.util.CellReference;
+import java.util.HashMap;
 
-/**
- * Basic settings for all chart series.
- */
-public interface ChartSeries {
-
-    /**
-     * Sets the title of the series as a string literal.
-     *
-     * @param title
-     */
-    void setTitle(String title);
-
-    /**
-     * Sets the title of the series as a cell reference.
-     *
-     * @param titleReference
-     */
-    void setTitle(CellReference titleReference);
-
-    /**
-     * @return title as string literal.
-     */
-    String getTitleString();
-
-    /**
-     * @return title as cell reference.
-     */
-    CellReference getTitleCellReference();
-
-    /**
-     * @return title type.
-     */
-    TitleType getTitleType();
+import org.openxmlformats.schemas.drawingml.x2006.chart.STRadarStyle;
+
+public enum RadarStyle {
+    FILLED(STRadarStyle.FILLED),
+    MARKER(STRadarStyle.MARKER),
+    STANDARD(STRadarStyle.STANDARD);
+
+    final STRadarStyle.Enum underlying;
+
+    RadarStyle(STRadarStyle.Enum style) {
+        this.underlying = style;
+    }
+
+    private final static HashMap<STRadarStyle.Enum, RadarStyle> reverse = new HashMap<STRadarStyle.Enum, RadarStyle>();
+    static {
+        for (RadarStyle value : values()) {
+            reverse.put(value.underlying, value);
+        }
+    }
+
+    static RadarStyle valueOf(STRadarStyle.Enum style) {
+        return reverse.get(style);
+    }
 }

Copied: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/ScatterStyle.java (from r1816205, poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/ScatterStyle.java?p2=poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/ScatterStyle.java&p1=poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java&r1=1816205&r2=1816383&rev=1816383&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSeries.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/ScatterStyle.java Sun Nov 26 14:03:01 2017
@@ -15,41 +15,34 @@
    limitations under the License.
 ==================================================================== */
 
-package org.apache.poi.ss.usermodel.charts;
+package org.apache.poi.xddf.usermodel.chart;
 
-import org.apache.poi.ss.util.CellReference;
+import java.util.HashMap;
 
-/**
- * Basic settings for all chart series.
- */
-public interface ChartSeries {
-
-    /**
-     * Sets the title of the series as a string literal.
-     *
-     * @param title
-     */
-    void setTitle(String title);
-
-    /**
-     * Sets the title of the series as a cell reference.
-     *
-     * @param titleReference
-     */
-    void setTitle(CellReference titleReference);
-
-    /**
-     * @return title as string literal.
-     */
-    String getTitleString();
-
-    /**
-     * @return title as cell reference.
-     */
-    CellReference getTitleCellReference();
-
-    /**
-     * @return title type.
-     */
-    TitleType getTitleType();
+import org.openxmlformats.schemas.drawingml.x2006.chart.STScatterStyle;
+
+public enum ScatterStyle {
+    LINE(STScatterStyle.LINE),
+    LINE_MARKER(STScatterStyle.LINE_MARKER),
+    MARKER(STScatterStyle.MARKER),
+    NONE(STScatterStyle.NONE),
+    SMOOTH(STScatterStyle.SMOOTH),
+    SMOOTH_MARKER(STScatterStyle.SMOOTH_MARKER);
+
+    final STScatterStyle.Enum underlying;
+
+    ScatterStyle(STScatterStyle.Enum style) {
+        this.underlying = style;
+    }
+
+    private final static HashMap<STScatterStyle.Enum, ScatterStyle> reverse = new HashMap<STScatterStyle.Enum, ScatterStyle>();
+    static {
+        for (ScatterStyle value : values()) {
+            reverse.put(value.underlying, value);
+        }
+    }
+
+    static ScatterStyle valueOf(STScatterStyle.Enum style) {
+        return reverse.get(style);
+    }
 }

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,146 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.Map;
+
+import org.apache.poi.util.Beta;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFBarChartData extends XDDFChartData {
+    private CTBarChart chart;
+
+    public XDDFBarChartData(CTBarChart chart, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        this.chart = chart;
+        for (CTBarSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(chart.getAxIdArray(), categories, values);
+    }
+
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        if (chart.isSetVaryColors()) {
+            chart.getVaryColors().setVal(varyColors);
+        } else {
+            chart.addNewVaryColors().setVal(varyColors);
+        }
+    }
+
+    public BarDirection getBarDirection() {
+        return BarDirection.valueOf(chart.getBarDir().getVal());
+    }
+
+    public void setBarDirection(BarDirection direction) {
+        chart.getBarDir().setVal(direction.underlying);
+    }
+
+    public BarGrouping getBarGrouping() {
+        if (chart.isSetGrouping()) {
+            return BarGrouping.valueOf(chart.getGrouping().getVal());
+        } else {
+            return BarGrouping.STANDARD;
+        }
+    }
+
+    public void setBarGrouping(BarGrouping grouping) {
+        if (chart.isSetGrouping()) {
+            chart.getGrouping().setVal(grouping.underlying);
+        } else {
+            chart.addNewGrouping().setVal(grouping.underlying);
+        }
+    }
+
+    public int getGapWidth() {
+        if (chart.isSetGapWidth()) {
+            return chart.getGapWidth().getVal();
+        } else {
+            return 0;
+        }
+    }
+
+    public void setGapWidth(int width) {
+        if (chart.isSetGapWidth()) {
+            chart.getGapWidth().setVal(width);
+        } else {
+            chart.addNewGapWidth().setVal(width);
+        }
+    }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTBarSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTBarSer series;
+
+        protected Series(CTBarSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTBarSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            return series.getTx();
+        }
+
+        @Override
+        public void setShowLeaderLines(boolean showLeaderLines) {
+            if (!series.isSetDLbls()) {
+                series.addNewDLbls();
+            }
+            if (series.getDLbls().isSetShowLeaderLines()) {
+                series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+            } else {
+                series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,151 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTickMark;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTUnsignedInt;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+
+@Beta
+public class XDDFCategoryAxis extends XDDFChartAxis {
+
+    private CTCatAx ctCatAx;
+
+    public XDDFCategoryAxis(CTPlotArea plotArea, AxisPosition position) {
+        initializeAxis(plotArea, position);
+    }
+
+    public XDDFCategoryAxis(CTCatAx ctCatAx) {
+        this.ctCatAx = ctCatAx;
+    }
+
+    @Override
+    @Internal
+    public CTShapeProperties getMajorGridLines() {
+        if (!ctCatAx.isSetMajorGridlines()) {
+            ctCatAx.addNewMajorGridlines();
+        }
+        if (!ctCatAx.getMajorGridlines().isSetSpPr()) {
+            ctCatAx.getMajorGridlines().addNewSpPr();
+        }
+        return ctCatAx.getMajorGridlines().getSpPr();
+    }
+
+    @Override
+    @Internal
+    public CTShapeProperties getLine() {
+        return ctCatAx.getSpPr();
+    }
+
+    @Override
+    public void crossAxis(XDDFChartAxis axis) {
+        ctCatAx.getCrossAx().setVal(axis.getId());
+    }
+
+    @Override
+    protected CTUnsignedInt getCTAxId() {
+        return ctCatAx.getAxId();
+    }
+
+    @Override
+    protected CTAxPos getCTAxPos() {
+        return ctCatAx.getAxPos();
+    }
+
+    @Override
+    public boolean hasNumberFormat() {
+        return ctCatAx.isSetNumFmt();
+    }
+
+    @Override
+    protected CTNumFmt getCTNumFmt() {
+        if (ctCatAx.isSetNumFmt()) {
+            return ctCatAx.getNumFmt();
+        }
+        return ctCatAx.addNewNumFmt();
+    }
+
+    @Override
+    protected CTScaling getCTScaling() {
+        return ctCatAx.getScaling();
+    }
+
+    @Override
+    protected CTCrosses getCTCrosses() {
+        CTCrosses crosses = ctCatAx.getCrosses();
+        if (crosses == null) {
+            return ctCatAx.addNewCrosses();
+        } else {
+            return crosses;
+        }
+    }
+
+    @Override
+    protected CTBoolean getDelete() {
+        return ctCatAx.getDelete();
+    }
+
+    @Override
+    protected CTTickMark getMajorCTTickMark() {
+        return ctCatAx.getMajorTickMark();
+    }
+
+    @Override
+    protected CTTickMark getMinorCTTickMark() {
+        return ctCatAx.getMinorTickMark();
+    }
+
+    public AxisLabelAlignment getLabelAlignment() {
+        return AxisLabelAlignment.valueOf(ctCatAx.getLblAlgn().getVal());
+    }
+
+    public void setLabelAlignment(AxisLabelAlignment labelAlignment) {
+        ctCatAx.getLblAlgn().setVal(labelAlignment.underlying);
+    }
+
+    private void initializeAxis(CTPlotArea plotArea, AxisPosition position) {
+        final long id = getNextAxId(plotArea);
+        ctCatAx = plotArea.addNewCatAx();
+        ctCatAx.addNewAxId().setVal(id);
+        ctCatAx.addNewAxPos();
+        ctCatAx.addNewScaling();
+        ctCatAx.addNewCrosses();
+        ctCatAx.addNewCrossAx();
+        ctCatAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
+        ctCatAx.addNewDelete();
+        ctCatAx.addNewMajorTickMark();
+        ctCatAx.addNewMinorTickMark();
+
+        setPosition(position);
+        setOrientation(AxisOrientation.MIN_MAX);
+        setCrosses(AxisCrosses.AUTO_ZERO);
+        setVisible(true);
+        setMajorTickMark(AxisTickMark.CROSS);
+        setMinorTickMark(AxisTickMark.NONE);
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,26 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.util.Beta;
+
+@Beta
+public interface XDDFCategoryDataSource extends XDDFDataSource<String> {
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,331 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import static org.apache.poi.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.apache.xmlbeans.XmlException;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTDateAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTRadarChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
+
+@Beta
+public abstract class XDDFChart extends POIXMLDocumentPart {
+
+    protected List<XDDFChartAxis> axes = new ArrayList<>();
+
+    /**
+     * Root element of the Chart part
+     */
+    protected final CTChartSpace chartSpace;
+
+    /**
+     * Chart element in the chart space
+     */
+    protected final CTChart chart;
+
+    /**
+     * Construct a chart.
+     */
+    protected XDDFChart() {
+        super();
+
+        chartSpace = CTChartSpace.Factory.newInstance();
+        chart = chartSpace.addNewChart();
+        chart.addNewPlotArea();
+    }
+
+    /**
+     * Construct a DrawingML chart from a package part.
+     *
+     * @param part the package part holding the chart data,
+     * the content type must be <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
+     *
+     * @since POI 3.14-Beta1
+     */
+    protected XDDFChart(PackagePart part) throws IOException, XmlException {
+        super(part);
+
+        chartSpace = ChartSpaceDocument.Factory.parse(part.getInputStream(), DEFAULT_XML_OPTIONS).getChartSpace();
+        chart = chartSpace.getChart();
+    }
+
+    /**
+     * Return the underlying CTChartSpace bean, the root element of the Chart part.
+     *
+     * @return the underlying CTChartSpace bean
+     */
+    @Internal
+    public CTChartSpace getCTChartSpace() {
+        return chartSpace;
+    }
+
+    /**
+     * Return the underlying CTChart bean, within the Chart Space
+     *
+     * @return the underlying CTChart bean
+     */
+    @Internal
+    public CTChart getCTChart() {
+        return chart;
+
+    }
+
+    /**
+     * Return the underlying CTPlotArea bean, within the Chart
+     *
+     * @return the underlying CTPlotArea bean
+     */
+    @Internal
+    protected CTPlotArea getCTPlotArea() {
+        return chart.getPlotArea();
+    }
+
+    /**
+     * @return true if only visible cells will be present on the chart,
+     *         false otherwise
+     */
+    public boolean isPlotOnlyVisibleCells() {
+        if (chart.isSetPlotVisOnly()) {
+            return chart.getPlotVisOnly().getVal();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * @param only a flag specifying if only visible cells should be
+     *        present on the chart
+     */
+    public void setPlotOnlyVisibleCells(boolean only) {
+        if (!chart.isSetPlotVisOnly()) {
+            chart.setPlotVisOnly(CTBoolean.Factory.newInstance());
+        }
+        chart.getPlotVisOnly().setVal(only);
+    }
+
+    public void setFloor(int thickness) {
+        if (!chart.isSetFloor()) {
+            chart.setFloor(CTSurface.Factory.newInstance());
+        }
+        chart.getFloor().getThickness().setVal(thickness);
+    }
+
+    public void setBackWall(int thickness) {
+        if (!chart.isSetBackWall()) {
+            chart.setBackWall(CTSurface.Factory.newInstance());
+        }
+        chart.getBackWall().getThickness().setVal(thickness);
+    }
+
+    public void setSideWall(int thickness) {
+        if (!chart.isSetSideWall()) {
+            chart.setSideWall(CTSurface.Factory.newInstance());
+        }
+        chart.getSideWall().getThickness().setVal(thickness);
+    }
+
+    public void setAutoTitleDeleted(boolean deleted) {
+        if (!chart.isSetAutoTitleDeleted()) {
+            chart.setAutoTitleDeleted(CTBoolean.Factory.newInstance());
+        }
+        chart.getAutoTitleDeleted().setVal(deleted);
+    }
+
+    public XDDFChartLegend getOrAddLegend() {
+        return new XDDFChartLegend(chart);
+    }
+
+    public void deleteLegend() {
+        if (chart.isSetLegend()) {
+            chart.unsetLegend();
+        }
+    }
+
+    public XDDFManualLayout getOrAddManualLayout() {
+        return new XDDFManualLayout(chart.getPlotArea());
+    }
+
+    public void plot(XDDFChartData data) {
+        for (XDDFChartData.Series series : data.getSeries()) {
+            series.plot();
+        }
+    }
+
+    public List<XDDFChartData> getChartSeries() {
+        List<XDDFChartData> series = new LinkedList<>();
+        CTPlotArea plotArea = getCTPlotArea();
+        Map<Long, XDDFChartAxis> categories = getCategoryAxes();
+        Map<Long, XDDFValueAxis> values = getValueAxes();
+
+        for (int i = 0; i < plotArea.sizeOfBarChartArray(); i++) {
+            CTBarChart barChart = plotArea.getBarChartArray(i);
+            series.add(new XDDFBarChartData(barChart, categories, values));
+        }
+
+        for (int i = 0; i < plotArea.sizeOfLineChartArray(); i++) {
+            CTLineChart lineChart = plotArea.getLineChartArray(i);
+            series.add(new XDDFLineChartData(lineChart, categories, values));
+        }
+
+        for (int i = 0; i < plotArea.sizeOfPieChartArray(); i++) {
+            CTPieChart pieChart = plotArea.getPieChartArray(i);
+            series.add(new XDDFPieChartData(pieChart));
+        }
+
+        for (int i = 0; i < plotArea.sizeOfRadarChartArray(); i++) {
+            CTRadarChart radarChart = plotArea.getRadarChartArray(i);
+            series.add(new XDDFRadarChartData(radarChart, categories, values));
+        }
+
+        for (int i = 0; i < plotArea.sizeOfScatterChartArray(); i++) {
+            CTScatterChart scatterChart = plotArea.getScatterChartArray(i);
+            series.add(new XDDFScatterChartData(scatterChart, categories, values));
+        }
+
+        // TODO repeat above code for all kind of charts
+        return series;
+    }
+
+    private Map<Long, XDDFChartAxis> getCategoryAxes() {
+        CTPlotArea plotArea = getCTPlotArea();
+        int sizeOfArray = plotArea.sizeOfCatAxArray();
+        Map<Long, XDDFChartAxis> axes = new HashMap<Long, XDDFChartAxis>(sizeOfArray);
+        for (int i = 0; i < sizeOfArray; i++) {
+            CTCatAx category = plotArea.getCatAxArray(i);
+            axes.put(category.getAxId().getVal(), new XDDFCategoryAxis(category));
+        }
+        return axes;
+    }
+
+    private Map<Long, XDDFValueAxis> getValueAxes() {
+        CTPlotArea plotArea = getCTPlotArea();
+        int sizeOfArray = plotArea.sizeOfValAxArray();
+        Map<Long, XDDFValueAxis> axes = new HashMap<>(sizeOfArray);
+        for (int i = 0; i < sizeOfArray; i++) {
+            CTValAx values = plotArea.getValAxArray(i);
+            axes.put(values.getAxId().getVal(), new XDDFValueAxis(values));
+        }
+        return axes;
+    }
+
+    public XDDFValueAxis createValueAxis(AxisPosition pos) {
+        XDDFValueAxis valueAxis = new XDDFValueAxis(chart.getPlotArea(), pos);
+        if (axes.size() == 1) {
+            XDDFChartAxis axis = axes.get(0);
+            axis.crossAxis(valueAxis);
+            valueAxis.crossAxis(axis);
+        }
+        axes.add(valueAxis);
+        return valueAxis;
+    }
+
+    public XDDFCategoryAxis createCategoryAxis(AxisPosition pos) {
+        XDDFCategoryAxis categoryAxis = new XDDFCategoryAxis(chart.getPlotArea(), pos);
+        if (axes.size() == 1) {
+            XDDFChartAxis axis = axes.get(0);
+            axis.crossAxis(categoryAxis);
+            categoryAxis.crossAxis(axis);
+        }
+        axes.add(categoryAxis);
+        return categoryAxis;
+    }
+
+    public XDDFDateAxis createDateAxis(AxisPosition pos) {
+        XDDFDateAxis dateAxis = new XDDFDateAxis(chart.getPlotArea(), pos);
+        if (axes.size() == 1) {
+            XDDFChartAxis axis = axes.get(0);
+            axis.crossAxis(dateAxis);
+            dateAxis.crossAxis(axis);
+        }
+        axes.add(dateAxis);
+        return dateAxis;
+    }
+
+    public XDDFChartData createData(ChartTypes type, XDDFChartAxis category, XDDFValueAxis values) {
+        Map<Long, XDDFChartAxis> categories = Collections.singletonMap(category.getId(), category);
+        Map<Long, XDDFValueAxis> mapValues = Collections.singletonMap(values.getId(), values);
+        final CTPlotArea plotArea = getCTPlotArea();
+        switch (type) {
+        case BAR:
+            return new XDDFBarChartData(plotArea.addNewBarChart(), categories, mapValues);
+        case LINE:
+            return new XDDFLineChartData(plotArea.addNewLineChart(), categories, mapValues);
+        case PIE:
+            return new XDDFPieChartData(plotArea.addNewPieChart());
+        case RADAR:
+            return new XDDFRadarChartData(plotArea.addNewRadarChart(), categories, mapValues);
+        case SCATTER:
+            return new XDDFScatterChartData(plotArea.addNewScatterChart(), categories, mapValues);
+        default:
+            return null;
+        }
+    }
+
+    public List<? extends XDDFChartAxis> getAxes() {
+        if (axes.isEmpty() && hasAxes()) {
+            parseAxes();
+        }
+        return axes;
+    }
+
+    private boolean hasAxes() {
+        CTPlotArea ctPlotArea = chart.getPlotArea();
+        int totalAxisCount = ctPlotArea.sizeOfValAxArray() + ctPlotArea.sizeOfCatAxArray() + ctPlotArea.sizeOfDateAxArray() + ctPlotArea.sizeOfSerAxArray();
+        return totalAxisCount > 0;
+    }
+
+    private void parseAxes() {
+        // TODO: add other axis types
+        for (CTCatAx catAx : chart.getPlotArea().getCatAxArray()) {
+            axes.add(new XDDFCategoryAxis(catAx));
+        }
+        for (CTDateAx dateAx : chart.getPlotArea().getDateAxArray()) {
+            axes.add(new XDDFDateAxis(dateAx));
+        }
+        for (CTValAx valAx : chart.getPlotArea().getValAxArray()) {
+            axes.add(new XDDFValueAxis(valAx));
+        }
+    }
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,302 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLogBase;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTickMark;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTUnsignedInt;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+
+/**
+ * Base class for all axis types.
+ */
+@Beta
+public abstract class XDDFChartAxis {
+    protected abstract CTUnsignedInt getCTAxId();
+
+    protected abstract CTAxPos getCTAxPos();
+
+    protected abstract CTNumFmt getCTNumFmt();
+
+    protected abstract CTScaling getCTScaling();
+
+    protected abstract CTCrosses getCTCrosses();
+
+    protected abstract CTBoolean getDelete();
+
+    protected abstract CTTickMark getMajorCTTickMark();
+
+    protected abstract CTTickMark getMinorCTTickMark();
+
+    @Internal
+    public abstract CTShapeProperties getMajorGridLines();
+
+    @Internal
+    public abstract CTShapeProperties getLine();
+
+    /**
+     * @return axis id
+     */
+    public long getId() {
+        return getCTAxId().getVal();
+    }
+
+    /**
+     * @return axis position
+     */
+    public AxisPosition getPosition() {
+        return AxisPosition.valueOf(getCTAxPos().getVal());
+    }
+
+    /**
+     * @param position
+     *            new axis position
+     */
+    public void setPosition(AxisPosition position) {
+        getCTAxPos().setVal(position.underlying);
+    }
+
+    /**
+     * Use this to check before retrieving a number format, as calling {@link #getNumberFormat()} may create a default
+     * one if none exists.
+     *
+     * @return true if a number format element is defined, false if not
+     */
+    public abstract boolean hasNumberFormat();
+
+    /**
+     * @param format
+     *            axis number format
+     */
+    public void setNumberFormat(String format) {
+        getCTNumFmt().setFormatCode(format);
+        getCTNumFmt().setSourceLinked(true);
+    }
+
+    /**
+     * @return axis number format
+     */
+    public String getNumberFormat() {
+        return getCTNumFmt().getFormatCode();
+    }
+
+    /**
+     * @return true if log base is defined, false otherwise
+     */
+    public boolean isSetLogBase() {
+        return getCTScaling().isSetLogBase();
+    }
+
+    private static final double MIN_LOG_BASE = 2.0;
+    private static final double MAX_LOG_BASE = 1000.0;
+
+    /**
+     * @param logBase
+     *            a number between 2 and 1000 (inclusive)
+     * @throws IllegalArgumentException
+     *             if log base not within allowed range
+     */
+    public void setLogBase(double logBase) {
+        if (logBase < MIN_LOG_BASE || MAX_LOG_BASE < logBase) {
+            throw new IllegalArgumentException("Axis log base must be between 2 and 1000 (inclusive), got: " + logBase);
+        }
+        CTScaling scaling = getCTScaling();
+        if (scaling.isSetLogBase()) {
+            scaling.getLogBase().setVal(logBase);
+        } else {
+            scaling.addNewLogBase().setVal(logBase);
+        }
+    }
+
+    /**
+     * @return axis log base or 0.0 if not set
+     */
+    public double getLogBase() {
+        CTLogBase logBase = getCTScaling().getLogBase();
+        if (logBase != null) {
+            return logBase.getVal();
+        }
+        return 0.0;
+    }
+
+    /**
+     * @return true if minimum value is defined, false otherwise
+     */
+    public boolean isSetMinimum() {
+        return getCTScaling().isSetMin();
+    }
+
+    /**
+     * @param min
+     *            axis minimum
+     */
+    public void setMinimum(double min) {
+        CTScaling scaling = getCTScaling();
+        if (scaling.isSetMin()) {
+            scaling.getMin().setVal(min);
+        } else {
+            scaling.addNewMin().setVal(min);
+        }
+    }
+
+    /**
+     * @return axis minimum or 0.0 if not set
+     */
+    public double getMinimum() {
+        CTScaling scaling = getCTScaling();
+        if (scaling.isSetMin()) {
+            return scaling.getMin().getVal();
+        } else {
+            return 0.0;
+        }
+    }
+
+    /**
+     * @return true if maximum value is defined, false otherwise
+     */
+    public boolean isSetMaximum() {
+        return getCTScaling().isSetMax();
+    }
+
+    /**
+     * @param max
+     *            axis maximum
+     */
+    public void setMaximum(double max) {
+        CTScaling scaling = getCTScaling();
+        if (scaling.isSetMax()) {
+            scaling.getMax().setVal(max);
+        } else {
+            scaling.addNewMax().setVal(max);
+        }
+    }
+
+    /**
+     * @return axis maximum or 0.0 if not set
+     */
+    public double getMaximum() {
+        CTScaling scaling = getCTScaling();
+        if (scaling.isSetMax()) {
+            return scaling.getMax().getVal();
+        } else {
+            return 0.0;
+        }
+    }
+
+    /**
+     * @return axis orientation
+     */
+    public AxisOrientation getOrientation() {
+        return AxisOrientation.valueOf(getCTScaling().getOrientation().getVal());
+    }
+
+    /**
+     * @param orientation
+     *            axis orientation
+     */
+    public void setOrientation(AxisOrientation orientation) {
+        CTScaling scaling = getCTScaling();
+        if (scaling.isSetOrientation()) {
+            scaling.getOrientation().setVal(orientation.underlying);
+        } else {
+            scaling.addNewOrientation().setVal(orientation.underlying);
+        }
+    }
+
+    /**
+     * @return axis cross type
+     */
+    public AxisCrosses getCrosses() {
+        return AxisCrosses.valueOf(getCTCrosses().getVal());
+    }
+
+    /**
+     * @param crosses
+     *            axis cross type
+     */
+    public void setCrosses(AxisCrosses crosses) {
+        getCTCrosses().setVal(crosses.underlying);
+    }
+
+    /**
+     * Declare this axis cross another axis.
+     *
+     * @param axis
+     *            that this axis should cross
+     */
+    public abstract void crossAxis(XDDFChartAxis axis);
+
+    /**
+     * @return visibility of the axis.
+     */
+    public boolean isVisible() {
+        return !getDelete().getVal();
+    }
+
+    /**
+     * @param value
+     *            visibility of the axis.
+     */
+    public void setVisible(boolean value) {
+        getDelete().setVal(!value);
+    }
+
+    /**
+     * @return major tick mark.
+     */
+    public AxisTickMark getMajorTickMark() {
+        return AxisTickMark.valueOf(getMajorCTTickMark().getVal());
+    }
+
+    /**
+     * @param tickMark
+     *            major tick mark type.
+     */
+    public void setMajorTickMark(AxisTickMark tickMark) {
+        getMajorCTTickMark().setVal(tickMark.underlying);
+    }
+
+    /**
+     * @return minor tick mark.
+     */
+    public AxisTickMark getMinorTickMark() {
+        return AxisTickMark.valueOf(getMinorCTTickMark().getVal());
+    }
+
+    /**
+     * @param tickMark
+     *            minor tick mark type.
+     */
+    public void setMinorTickMark(AxisTickMark tickMark) {
+        getMinorCTTickMark().setVal(tickMark.underlying);
+    }
+
+    protected long getNextAxId(CTPlotArea plotArea) {
+        long totalAxisCount = plotArea.sizeOfValAxArray() + plotArea.sizeOfCatAxArray() + plotArea.sizeOfDateAxArray()
+                + plotArea.sizeOfSerAxArray();
+        return totalAxisCount;
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,291 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.util.Beta;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumData;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumRef;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumVal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrData;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrRef;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrVal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTUnsignedInt;
+
+/**
+ * Base of all XDDF Chart Data
+ */
+@Beta
+public abstract class XDDFChartData {
+    protected List<Series> series;
+    private XDDFCategoryAxis categoryAxis;
+    private List<XDDFValueAxis> valueAxes;
+
+    protected XDDFChartData() {
+        this.series = new ArrayList<Series>();
+    }
+
+    protected void defineAxes(CTUnsignedInt[] axes, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        List<XDDFValueAxis> list = new ArrayList<XDDFValueAxis>(axes.length);
+        for (CTUnsignedInt axe : axes) {
+            Long axisId = axe.getVal();
+            XDDFChartAxis category = categories.get(axisId);
+            if (category == null) {
+                XDDFValueAxis axis = values.get(axisId);
+                if (axis != null) {
+                    list.add(axis);
+                }
+            } else if (category instanceof XDDFCategoryAxis) {
+                this.categoryAxis = (XDDFCategoryAxis) category;
+            }
+        }
+        this.valueAxes = Collections.unmodifiableList(list);
+    }
+
+    public XDDFCategoryAxis getCategoryAxis() {
+        return categoryAxis;
+    }
+
+    public List<XDDFValueAxis> getValueAxes() {
+        return valueAxes;
+    }
+
+    public List<Series> getSeries() {
+        return series;
+    }
+
+    public abstract void setVaryColors(boolean varyColors);
+
+    public abstract XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values);
+
+    public abstract class Series {
+        protected abstract CTSerTx getSeriesText();
+
+        public abstract void setShowLeaderLines(boolean showLeaderLines);
+
+        protected XDDFDataSource<?> categoryData;
+        protected XDDFNumericalDataSource<? extends Number> valuesData;
+
+        protected abstract CTAxDataSource getAxDS();
+
+        protected abstract CTNumDataSource getNumDS();
+
+        protected Series(XDDFDataSource<?> category, XDDFNumericalDataSource<? extends Number> values) {
+            replaceData(category, values);
+        }
+
+        public void replaceData(XDDFDataSource<?> category, XDDFNumericalDataSource<? extends Number> values) {
+            if (category == null || values == null) {
+                throw new IllegalStateException("Category and values must be defined before filling chart data.");
+            }
+            int numOfPoints = category.getPointCount();
+            if (numOfPoints != values.getPointCount()) {
+                throw new IllegalStateException("Category and values must have the same point count.");
+            }
+            this.categoryData = category;
+            this.valuesData = values;
+        }
+
+        public void setTitle(String title, CellReference titleRef) {
+            if (titleRef == null) {
+                getSeriesText().setV(title);
+            } else {
+                CTStrRef ref;
+                if (getSeriesText().isSetStrRef()) {
+                    ref = getSeriesText().getStrRef();
+                } else {
+                    ref = getSeriesText().addNewStrRef();
+                }
+                CTStrData cache;
+                if (ref.isSetStrCache()) {
+                    cache = ref.getStrCache();
+                } else {
+                    cache = ref.addNewStrCache();
+                }
+                cache.getPtArray(0).setV(title);
+                ref.setF(titleRef.formatAsString());
+            }
+        }
+
+        public XDDFDataSource<?> getCategoryData() {
+            return categoryData;
+        }
+
+        public XDDFNumericalDataSource<? extends Number> getValuesData() {
+            return valuesData;
+        }
+
+        public void plot() {
+            int numOfPoints = categoryData.getPointCount();
+            if (categoryData.isNumeric()) {
+                CTNumData cache = retrieveNumCache(getAxDS(), categoryData);
+                fillNumCache(cache, numOfPoints, (XDDFNumericalDataSource<?>) categoryData);
+            } else {
+                CTStrData cache = retrieveStrCache(getAxDS(), categoryData);
+                fillStringCache(cache, numOfPoints, categoryData);
+            }
+            CTNumData cache = retrieveNumCache(getNumDS(), valuesData);
+            fillNumCache(cache, numOfPoints, valuesData);
+        }
+
+        private CTNumData retrieveNumCache(final CTAxDataSource axDataSource, XDDFDataSource<?> data) {
+            CTNumData numCache;
+            if (data.isReference()) {
+                CTNumRef numRef;
+                if (axDataSource.isSetNumRef()) {
+                    numRef = axDataSource.getNumRef();
+                } else {
+                    numRef = axDataSource.addNewNumRef();
+                }
+                if (numRef.isSetNumCache()) {
+                    numCache = numRef.getNumCache();
+                } else {
+                    numCache = numRef.addNewNumCache();
+                }
+                numRef.setF(data.getDataRangeReference());
+                if (axDataSource.isSetNumLit()) {
+                    axDataSource.unsetNumLit();
+                }
+            } else {
+                if (axDataSource.isSetNumLit()) {
+                    numCache = axDataSource.getNumLit();
+                } else {
+                    numCache = axDataSource.addNewNumLit();
+                }
+                if (axDataSource.isSetNumRef()) {
+                    axDataSource.unsetNumRef();
+                }
+            }
+            return numCache;
+        }
+
+        private CTStrData retrieveStrCache(final CTAxDataSource axDataSource, XDDFDataSource<?> data) {
+            CTStrData strCache;
+            if (data.isReference()) {
+                CTStrRef strRef;
+                if (axDataSource.isSetStrRef()) {
+                    strRef = axDataSource.getStrRef();
+                } else {
+                    strRef = axDataSource.addNewStrRef();
+                }
+                if (strRef.isSetStrCache()) {
+                    strCache = strRef.getStrCache();
+                } else {
+                    strCache = strRef.addNewStrCache();
+                }
+                strRef.setF(data.getDataRangeReference());
+                if (axDataSource.isSetStrLit()) {
+                    axDataSource.unsetStrLit();
+                }
+            } else {
+                if (axDataSource.isSetStrLit()) {
+                    strCache = axDataSource.getStrLit();
+                } else {
+                    strCache = axDataSource.addNewStrLit();
+                }
+                if (axDataSource.isSetStrRef()) {
+                    axDataSource.unsetStrRef();
+                }
+            }
+            return strCache;
+        }
+
+        private CTNumData retrieveNumCache(final CTNumDataSource numDataSource, XDDFDataSource<?> data) {
+            CTNumData numCache;
+            if (data.isReference()) {
+                CTNumRef numRef;
+                if (numDataSource.isSetNumRef()) {
+                    numRef = numDataSource.getNumRef();
+                } else {
+                    numRef = numDataSource.addNewNumRef();
+                }
+                if (numRef.isSetNumCache()) {
+                    numCache = numRef.getNumCache();
+                } else {
+                    numCache = numRef.addNewNumCache();
+                }
+                numRef.setF(data.getDataRangeReference());
+                if (numDataSource.isSetNumLit()) {
+                    numDataSource.unsetNumLit();
+                }
+            } else {
+                if (numDataSource.isSetNumLit()) {
+                    numCache = numDataSource.getNumLit();
+                } else {
+                    numCache = numDataSource.addNewNumLit();
+                }
+                if (numDataSource.isSetNumRef()) {
+                    numDataSource.unsetNumRef();
+                }
+            }
+            return numCache;
+        }
+
+        private void fillStringCache(CTStrData cache, int numOfPoints, XDDFDataSource<?> data) {
+            cache.setPtArray(null); // unset old values
+            if (cache.isSetPtCount()) {
+                cache.getPtCount().setVal(numOfPoints);
+            } else {
+                cache.addNewPtCount().setVal(numOfPoints);
+            }
+            for (int i = 0; i < numOfPoints; ++i) {
+                String value = data.getPointAt(i).toString();
+                if (value != null) {
+                    CTStrVal ctStrVal = cache.addNewPt();
+                    ctStrVal.setIdx(i);
+                    ctStrVal.setV(value);
+                }
+            }
+        }
+
+        private void fillNumCache(CTNumData cache, int numOfPoints, XDDFNumericalDataSource<?> data) {
+            String formatCode = data.getFormatCode();
+            if (formatCode == null) {
+                if (cache.isSetFormatCode()) {
+                    cache.unsetFormatCode();
+                }
+            } else {
+                cache.setFormatCode(formatCode);
+            }
+            cache.setPtArray(null); // unset old values
+            if (cache.isSetPtCount()) {
+                cache.getPtCount().setVal(numOfPoints);
+            } else {
+                cache.addNewPtCount().setVal(numOfPoints);
+            }
+            for (int i = 0; i < numOfPoints; ++i) {
+                Object value = data.getPointAt(i);
+                if (value != null) {
+                    CTNumVal ctNumVal = cache.addNewPt();
+                    ctNumVal.setIdx(i);
+                    ctNumVal.setV(value.toString());
+                }
+            }
+        }
+    }
+}

Copied: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartExtensionList.java (from r1816205, poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSeries.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartExtensionList.java?p2=poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartExtensionList.java&p1=poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSeries.java&r1=1816205&r2=1816383&rev=1816383&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSeries.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartExtensionList.java Sun Nov 26 14:03:01 2017
@@ -15,24 +15,27 @@
    limitations under the License.
 ==================================================================== */
 
-package org.apache.poi.ss.usermodel.charts;
+package org.apache.poi.xddf.usermodel.chart;
 
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTExtensionList;
 
-/**
- * Represents a line chart series.
- */
 @Beta
-public interface LineChartSeries extends ChartSeries {
-
-    /**
-     * @return data source used for category axis data.
-     */
-    ChartDataSource<?> getCategoryAxisData();
-
-    /**
-     * @return data source used for value axis.
-     */
-    ChartDataSource<? extends Number> getValues();
+public class XDDFChartExtensionList {
+    private CTExtensionList list;
 
+    public XDDFChartExtensionList() {
+        this(CTExtensionList.Factory.newInstance());
+    }
+
+    @Internal
+    protected XDDFChartExtensionList(CTExtensionList list) {
+        this.list = list;
+    }
+
+    @Internal
+    public CTExtensionList getXmlObject() {
+        return list;
+    }
 }

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,184 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.apache.poi.xddf.usermodel.text.XDDFTextBody;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLegend;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+
+/**
+ * Represents a DrawingML chart legend
+ */
+@Beta
+public final class XDDFChartLegend {
+
+    /**
+     * Underlying CTLegend bean
+     */
+    private CTLegend legend;
+
+    /**
+     * Create a new DrawingML chart legend
+     */
+    public XDDFChartLegend(CTChart ctChart) {
+        this.legend = (ctChart.isSetLegend()) ? ctChart.getLegend() : ctChart.addNewLegend();
+
+        setDefaults();
+    }
+
+    /**
+     * Set sensible default styling.
+     */
+    private void setDefaults() {
+        if (!legend.isSetOverlay()) {
+            legend.addNewOverlay();
+        }
+        legend.getOverlay().setVal(false);
+    }
+
+    /**
+     * Return the underlying CTLegend bean.
+     *
+     * @return the underlying CTLegend bean
+     */
+    @Internal
+    protected CTLegend getXmlObject() {
+        return legend;
+    }
+
+    @Internal  // will later replace with XDDFShapeProperties
+    public CTShapeProperties getShapeProperties() {
+        if (legend.isSetSpPr()) {
+            return legend.getSpPr();
+        } else {
+            return null;
+        }
+    }
+
+    @Internal  // will later replace with XDDFShapeProperties
+    public void setShapeProperties(CTShapeProperties properties) {
+        if (properties == null) {
+            legend.unsetSpPr();
+        } else {
+            legend.setSpPr(properties);
+        }
+    }
+
+    public XDDFTextBody getTextBody() {
+        if (legend.isSetTxPr()) {
+            return new XDDFTextBody(legend.getTxPr());
+        } else {
+            return null;
+        }
+    }
+
+    public void setTextBody(XDDFTextBody body) {
+        if (body == null) {
+            legend.unsetTxPr();
+        } else {
+            legend.setTxPr(body.getXmlObject());
+        }
+    }
+
+    public XDDFLegendEntry addEntry() {
+        return new XDDFLegendEntry(legend.addNewLegendEntry());
+    }
+
+    public XDDFLegendEntry getEntry(int index) {
+        return new XDDFLegendEntry(legend.getLegendEntryArray(index));
+    }
+
+    public List<XDDFLegendEntry> getEntries() {
+        return legend
+            .getLegendEntryList()
+            .stream()
+            .map(entry -> new XDDFLegendEntry(entry))
+            .collect(Collectors.toList());
+    }
+
+    public void setExtensionList(XDDFChartExtensionList list) {
+        if (list == null) {
+            legend.unsetExtLst();
+        } else {
+            legend.setExtLst(list.getXmlObject());
+        }
+    }
+
+    public XDDFChartExtensionList getExtensionList() {
+        if (legend.isSetExtLst()) {
+            return new XDDFChartExtensionList(legend.getExtLst());
+        } else {
+            return null;
+        }
+    }
+
+    public void setLayout(XDDFLayout layout) {
+        if (layout == null) {
+            legend.unsetLayout();
+        } else {
+            legend.setLayout(layout.getXmlObject());
+        }
+    }
+
+    public XDDFLayout getLayout() {
+        if (legend.isSetLayout()) {
+            return new XDDFLayout(legend.getLayout());
+        } else {
+            return null;
+        }
+    }
+
+    public void setPosition(LegendPosition position) {
+        if (!legend.isSetLegendPos()) {
+            legend.addNewLegendPos();
+        }
+        legend.getLegendPos().setVal(position.underlying);
+    }
+
+    /*
+     * According to ECMA-376 default position is RIGHT.
+     */
+    public LegendPosition getPosition() {
+        if (legend.isSetLegendPos()) {
+            return LegendPosition.valueOf(legend.getLegendPos().getVal());
+        } else {
+            return LegendPosition.RIGHT;
+        }
+    }
+
+    public XDDFManualLayout getOrAddManualLayout() {
+        if (!legend.isSetLayout()) {
+            legend.addNewLayout();
+        }
+        return new XDDFManualLayout(legend.getLayout());
+    }
+
+    public boolean isOverlay() {
+        return legend.getOverlay().getVal();
+    }
+
+    public void setOverlay(boolean value) {
+        legend.getOverlay().setVal(value);
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,35 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.util.Beta;
+
+@Beta
+public interface XDDFDataSource<T> {
+    int getPointCount();
+
+    T getPointAt(int index);
+
+    boolean isReference();
+
+    boolean isNumeric();
+
+    String getDataRangeReference();
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,299 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.Beta;
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumData;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrData;
+
+/**
+ * Class {@code XDDFDataSourcesFactory} is a factory for {@link XDDFDataSource} instances.
+ */
+@Beta
+public class XDDFDataSourcesFactory {
+
+    private XDDFDataSourcesFactory() {
+    }
+
+    public static XDDFCategoryDataSource fromDataSource(final CTAxDataSource categoryDS) {
+        return new XDDFCategoryDataSource() {
+            private CTStrData category = (CTStrData) categoryDS.getStrRef().getStrCache().copy();
+
+            @Override
+            public boolean isNumeric() {
+                return false;
+            }
+
+            @Override
+            public boolean isReference() {
+                return true;
+            }
+
+            @Override
+            public int getPointCount() {
+                return (int) category.getPtCount().getVal();
+            }
+
+            @Override
+            public String getPointAt(int index) {
+                return category.getPtArray(index).getV();
+            }
+
+            @Override
+            public String getDataRangeReference() {
+                return categoryDS.getStrRef().getF();
+            }
+        };
+    }
+
+    public static XDDFNumericalDataSource<Double> fromDataSource(final CTNumDataSource valuesDS) {
+        return new XDDFNumericalDataSource<Double>() {
+            private CTNumData values = (CTNumData) valuesDS.getNumRef().getNumCache().copy();
+            private String formatCode = values.isSetFormatCode() ? values.getFormatCode() : null;
+
+            @Override
+            public String getFormatCode() {
+                return formatCode;
+            }
+
+            @Override
+            public void setFormatCode(String formatCode) {
+                this.formatCode = formatCode;
+            }
+
+            @Override
+            public boolean isNumeric() {
+                return true;
+            }
+
+            @Override
+            public boolean isReference() {
+                return true;
+            }
+
+            @Override
+            public int getPointCount() {
+                return (int) values.getPtCount().getVal();
+            }
+
+            @Override
+            public Double getPointAt(int index) {
+                return Double.valueOf(values.getPtArray(index).getV());
+            }
+
+            @Override
+            public String getDataRangeReference() {
+                return valuesDS.getNumRef().getF();
+            }
+        };
+    }
+
+    public static <T extends Number> XDDFNumericalDataSource<T> fromArray(T[] elements, String dataRange) {
+        return new NumericalArrayDataSource<T>(elements, dataRange);
+    }
+
+    public static XDDFCategoryDataSource fromArray(String[] elements, String dataRange) {
+        return new StringArrayDataSource(elements, dataRange);
+    }
+
+    public static XDDFNumericalDataSource<Double> fromNumericCellRange(XSSFSheet sheet,
+            CellRangeAddress cellRangeAddress) {
+        return new NumericalCellRangeDataSource(sheet, cellRangeAddress);
+    }
+
+    public static XDDFCategoryDataSource fromStringCellRange(XSSFSheet sheet, CellRangeAddress cellRangeAddress) {
+        return new StringCellRangeDataSource(sheet, cellRangeAddress);
+    }
+
+    private abstract static class AbstractArrayDataSource<T> implements XDDFDataSource<T> {
+        private final T[] elements;
+        private final String dataRange;
+
+        public AbstractArrayDataSource(T[] elements, String dataRange) {
+            this.elements = elements.clone();
+            this.dataRange = dataRange;
+        }
+
+        @Override
+        public int getPointCount() {
+            return elements.length;
+        }
+
+        @Override
+        public T getPointAt(int index) {
+            return elements[index];
+        }
+
+        @Override
+        public boolean isReference() {
+            return dataRange != null;
+        }
+
+        @Override
+        public boolean isNumeric() {
+            Class<?> arrayComponentType = elements.getClass().getComponentType();
+            return (Number.class.isAssignableFrom(arrayComponentType));
+        }
+
+        @Override
+        public String getDataRangeReference() {
+            if (dataRange == null) {
+                throw new UnsupportedOperationException("Literal data source can not be expressed by reference.");
+            } else {
+                return dataRange;
+            }
+        }
+    }
+
+    private static class NumericalArrayDataSource<T extends Number> extends AbstractArrayDataSource<T>
+            implements XDDFNumericalDataSource<T> {
+        private String formatCode;
+
+        public NumericalArrayDataSource(T[] elements, String dataRange) {
+            super(elements, dataRange);
+        }
+
+        @Override
+        public String getFormatCode() {
+            return formatCode;
+        }
+
+        @Override
+        public void setFormatCode(String formatCode) {
+            this.formatCode = formatCode;
+        }
+    }
+
+    private static class StringArrayDataSource extends AbstractArrayDataSource<String>
+            implements XDDFCategoryDataSource {
+        public StringArrayDataSource(String[] elements, String dataRange) {
+            super(elements, dataRange);
+        }
+    }
+
+    private abstract static class AbstractCellRangeDataSource<T> implements XDDFDataSource<T> {
+        private final XSSFSheet sheet;
+        private final CellRangeAddress cellRangeAddress;
+        private final int numOfCells;
+        private XSSFFormulaEvaluator evaluator;
+
+        protected AbstractCellRangeDataSource(XSSFSheet sheet, CellRangeAddress cellRangeAddress) {
+            this.sheet = sheet;
+            // Make copy since CellRangeAddress is mutable.
+            this.cellRangeAddress = cellRangeAddress.copy();
+            this.numOfCells = this.cellRangeAddress.getNumberOfCells();
+            this.evaluator = sheet.getWorkbook().getCreationHelper().createFormulaEvaluator();
+        }
+
+        @Override
+        public int getPointCount() {
+            return numOfCells;
+        }
+
+        @Override
+        public boolean isReference() {
+            return true;
+        }
+
+        @Override
+        public String getDataRangeReference() {
+            return cellRangeAddress.formatAsString(sheet.getSheetName(), true);
+        }
+
+        protected CellValue getCellValueAt(int index) {
+            if (index < 0 || index >= numOfCells) {
+                throw new IndexOutOfBoundsException(
+                        "Index must be between 0 and " + (numOfCells - 1) + " (inclusive), given: " + index);
+            }
+            int firstRow = cellRangeAddress.getFirstRow();
+            int firstCol = cellRangeAddress.getFirstColumn();
+            int lastCol = cellRangeAddress.getLastColumn();
+            int width = lastCol - firstCol + 1;
+            int rowIndex = firstRow + index / width;
+            int cellIndex = firstCol + index % width;
+            XSSFRow row = sheet.getRow(rowIndex);
+            return (row == null) ? null : evaluator.evaluate(row.getCell(cellIndex));
+        }
+    }
+
+    private static class NumericalCellRangeDataSource extends AbstractCellRangeDataSource<Double>
+            implements XDDFNumericalDataSource<Double> {
+        protected NumericalCellRangeDataSource(XSSFSheet sheet, CellRangeAddress cellRangeAddress) {
+            super(sheet, cellRangeAddress);
+        }
+
+        private String formatCode;
+
+        @Override
+        public String getFormatCode() {
+            return formatCode;
+        }
+
+        @Override
+        public void setFormatCode(String formatCode) {
+            this.formatCode = formatCode;
+        }
+
+        @Override
+        public Double getPointAt(int index) {
+            CellValue cellValue = getCellValueAt(index);
+            if (cellValue != null && cellValue.getCellTypeEnum() == CellType.NUMERIC) {
+                return Double.valueOf(cellValue.getNumberValue());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public boolean isNumeric() {
+            return true;
+        }
+    }
+
+    private static class StringCellRangeDataSource extends AbstractCellRangeDataSource<String>
+            implements XDDFCategoryDataSource {
+        protected StringCellRangeDataSource(XSSFSheet sheet, CellRangeAddress cellRangeAddress) {
+            super(sheet, cellRangeAddress);
+        }
+
+        @Override
+        public String getPointAt(int index) {
+            CellValue cellValue = getCellValueAt(index);
+            if (cellValue != null && cellValue.getCellTypeEnum() == CellType.STRING) {
+                return cellValue.getStringValue();
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public boolean isNumeric() {
+            return false;
+        }
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java?rev=1816383&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java Sun Nov 26 14:03:01 2017
@@ -0,0 +1,147 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.xddf.usermodel.chart;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTDateAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTickMark;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTUnsignedInt;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+
+/**
+ * Date axis type. Currently only implements the same values as {@link XDDFCategoryAxis}, since the two are nearly
+ * identical.
+ */
+@Beta
+public class XDDFDateAxis extends XDDFChartAxis {
+
+    private CTDateAx ctDateAx;
+
+    public XDDFDateAxis(CTPlotArea plotArea, AxisPosition position) {
+        initializeAxis(plotArea, position);
+    }
+
+    public XDDFDateAxis(CTDateAx ctDateAx) {
+        this.ctDateAx = ctDateAx;
+    }
+
+    @Override
+    @Internal
+    public CTShapeProperties getMajorGridLines() {
+        if (!ctDateAx.isSetMajorGridlines()) {
+            ctDateAx.addNewMajorGridlines();
+        }
+        if (!ctDateAx.getMajorGridlines().isSetSpPr()) {
+            ctDateAx.getMajorGridlines().addNewSpPr();
+        }
+        return ctDateAx.getMajorGridlines().getSpPr();
+    }
+
+    @Override
+    @Internal
+    public CTShapeProperties getLine() {
+        return ctDateAx.getSpPr();
+    }
+
+    @Override
+    public void crossAxis(XDDFChartAxis axis) {
+        ctDateAx.getCrossAx().setVal(axis.getId());
+    }
+
+    @Override
+    protected CTUnsignedInt getCTAxId() {
+        return ctDateAx.getAxId();
+    }
+
+    @Override
+    protected CTAxPos getCTAxPos() {
+        return ctDateAx.getAxPos();
+    }
+
+    @Override
+    public boolean hasNumberFormat() {
+        return ctDateAx.isSetNumFmt();
+    }
+
+    @Override
+    protected CTNumFmt getCTNumFmt() {
+        if (ctDateAx.isSetNumFmt()) {
+            return ctDateAx.getNumFmt();
+        }
+        return ctDateAx.addNewNumFmt();
+    }
+
+    @Override
+    protected CTScaling getCTScaling() {
+        return ctDateAx.getScaling();
+    }
+
+    @Override
+    protected CTCrosses getCTCrosses() {
+        CTCrosses crosses = ctDateAx.getCrosses();
+        if (crosses == null) {
+            return ctDateAx.addNewCrosses();
+        } else {
+            return crosses;
+        }
+    }
+
+    @Override
+    protected CTBoolean getDelete() {
+        return ctDateAx.getDelete();
+    }
+
+    @Override
+    protected CTTickMark getMajorCTTickMark() {
+        return ctDateAx.getMajorTickMark();
+    }
+
+    @Override
+    protected CTTickMark getMinorCTTickMark() {
+        return ctDateAx.getMinorTickMark();
+    }
+
+    private void initializeAxis(CTPlotArea plotArea, AxisPosition position) {
+        final long id = getNextAxId(plotArea);
+        ctDateAx = plotArea.addNewDateAx();
+        ctDateAx.addNewAxId().setVal(id);
+        ctDateAx.addNewAxPos();
+        ctDateAx.addNewScaling();
+        ctDateAx.addNewCrosses();
+        ctDateAx.addNewCrossAx();
+        ctDateAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
+        ctDateAx.addNewDelete();
+        ctDateAx.addNewMajorTickMark();
+        ctDateAx.addNewMinorTickMark();
+
+        setPosition(position);
+        setOrientation(AxisOrientation.MIN_MAX);
+        setCrosses(AxisCrosses.AUTO_ZERO);
+        setVisible(true);
+        setMajorTickMark(AxisTickMark.CROSS);
+        setMinorTickMark(AxisTickMark.NONE);
+    }
+}



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