From 5f0072983bf8ffc8b2b6de27037da7df1cb8c801 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alain=20B=C3=A9arez?= Date: Sat, 6 Jan 2018 02:51:53 +0000 Subject: [PATCH] introduce XDDFShapeProperties as user model API (closes #72 from GitHub) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1820369 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xslf/usermodel/BarChartDemo.java | 31 +- .../poi/xslf/usermodel/PieChartDemo.java | 13 +- .../poi/xssf/usermodel/examples/BarChart.java | 104 ++++++ .../poi/xddf/usermodel/BlackWhiteMode.java | 46 +++ .../poi/xddf/usermodel/CompoundLine.java | 47 +++ .../xddf/usermodel/HasShapeProperties.java | 22 ++ .../apache/poi/xddf/usermodel/LineCap.java | 45 +++ .../poi/xddf/usermodel/LineEndLength.java | 45 +++ .../poi/xddf/usermodel/LineEndType.java | 48 +++ .../poi/xddf/usermodel/LineEndWidth.java | 45 +++ .../poi/xddf/usermodel/PathShadeType.java | 45 +++ .../poi/xddf/usermodel/PenAlignment.java | 44 +++ .../poi/xddf/usermodel/PresetColor.java | 180 ++++++++++ .../poi/xddf/usermodel/PresetGeometry.java | 230 +++++++++++++ .../poi/xddf/usermodel/PresetLineDash.java | 53 +++ .../poi/xddf/usermodel/PresetPattern.java | 96 ++++++ .../xddf/usermodel/RectangleAlignment.java | 51 +++ .../poi/xddf/usermodel/SchemeColor.java | 59 ++++ .../poi/xddf/usermodel/SystemColor.java | 72 ++++ .../poi/xddf/usermodel/TileFlipMode.java | 46 +++ .../xddf/usermodel/XDDFAdjustHandlePolar.java | 39 +++ .../xddf/usermodel/XDDFAdjustHandleXY.java | 39 +++ .../apache/poi/xddf/usermodel/XDDFColor.java | 79 +++++ .../poi/xddf/usermodel/XDDFColorHsl.java | 77 +++++ .../poi/xddf/usermodel/XDDFColorPreset.java | 69 ++++ .../xddf/usermodel/XDDFColorRgbBinary.java | 69 ++++ .../xddf/usermodel/XDDFColorRgbPercent.java | 102 ++++++ .../xddf/usermodel/XDDFColorSchemeBased.java | 59 ++++ .../usermodel/XDDFColorSystemDefined.java | 77 +++++ .../xddf/usermodel/XDDFConnectionSite.java | 39 +++ .../xddf/usermodel/XDDFCustomGeometry2D.java | 288 ++++++++++++++++ .../poi/xddf/usermodel/XDDFDashStop.java | 53 +++ .../xddf/usermodel/XDDFEffectContainer.java | 37 +++ .../poi/xddf/usermodel/XDDFEffectList.java | 37 +++ .../poi/xddf/usermodel/XDDFExtensionList.java | 37 +++ .../xddf/usermodel/XDDFFillProperties.java | 24 ++ .../poi/xddf/usermodel/XDDFGeometryGuide.java | 53 +++ .../xddf/usermodel/XDDFGeometryRectangle.java | 39 +++ .../usermodel/XDDFGradientFillProperties.java | 182 ++++++++++ .../poi/xddf/usermodel/XDDFGradientStop.java | 105 ++++++ .../usermodel/XDDFGroupFillProperties.java | 40 +++ .../xddf/usermodel/XDDFLineEndProperties.java | 60 ++++ .../XDDFLineJoinBevelProperties.java | 39 +++ .../XDDFLineJoinMiterProperties.java | 58 ++++ .../usermodel/XDDFLineJoinProperties.java | 24 ++ .../XDDFLineJoinRoundProperties.java | 40 +++ .../xddf/usermodel/XDDFLineProperties.java | 313 ++++++++++++++++++ .../usermodel/XDDFLinearShadeProperties.java | 72 ++++ .../xddf/usermodel/XDDFNoFillProperties.java | 40 +++ .../apache/poi/xddf/usermodel/XDDFPath.java | 39 +++ .../usermodel/XDDFPathShadeProperties.java | 76 +++++ .../usermodel/XDDFPatternFillProperties.java | 94 ++++++ .../usermodel/XDDFPictureFillProperties.java | 151 +++++++++ .../poi/xddf/usermodel/XDDFPoint2D.java | 53 +++ .../xddf/usermodel/XDDFPositiveSize2D.java | 56 ++++ .../xddf/usermodel/XDDFPresetGeometry2D.java | 89 +++++ .../xddf/usermodel/XDDFPresetLineDash.java | 59 ++++ .../xddf/usermodel/XDDFRelativeRectangle.java | 112 +++++++ .../poi/xddf/usermodel/XDDFScene3D.java | 36 ++ .../poi/xddf/usermodel/XDDFShape3D.java | 36 ++ .../xddf/usermodel/XDDFShapeProperties.java | 276 +++++++++++++++ .../usermodel/XDDFSolidFillProperties.java | 105 ++++++ .../usermodel/XDDFStretchInfoProperties.java | 54 +++ .../usermodel/XDDFTileInfoProperties.java | 136 ++++++++ .../poi/xddf/usermodel/XDDFTransform2D.java | 140 ++++++++ .../usermodel/chart/XDDFBarChartData.java | 25 ++ .../usermodel/chart/XDDFCategoryAxis.java | 39 ++- .../poi/xddf/usermodel/chart/XDDFChart.java | 19 ++ .../xddf/usermodel/chart/XDDFChartAxis.java | 26 +- .../xddf/usermodel/chart/XDDFChartData.java | 3 + .../xddf/usermodel/chart/XDDFChartLegend.java | 16 +- .../xddf/usermodel/chart/XDDFDateAxis.java | 42 ++- .../poi/xddf/usermodel/chart/XDDFLayout.java | 8 +- .../xddf/usermodel/chart/XDDFLegendEntry.java | 12 +- .../usermodel/chart/XDDFLineChartData.java | 25 ++ .../usermodel/chart/XDDFManualLayout.java | 4 +- .../usermodel/chart/XDDFPieChartData.java | 25 ++ .../usermodel/chart/XDDFRadarChartData.java | 25 ++ .../usermodel/chart/XDDFScatterChartData.java | 25 ++ .../xddf/usermodel/chart/XDDFValueAxis.java | 38 ++- .../apache/poi/xslf/usermodel/XSLFTheme.java | 16 +- .../poi/xddf/usermodel/TestXDDFColor.java | 119 +++++++ 82 files changed, 5406 insertions(+), 85 deletions(-) create mode 100644 src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/BlackWhiteMode.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/CompoundLine.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/HasShapeProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/LineCap.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndLength.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndType.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndWidth.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/PathShadeType.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/PenAlignment.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/PresetColor.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/PresetGeometry.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/PresetLineDash.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/PresetPattern.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/RectangleAlignment.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/SchemeColor.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/SystemColor.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/TileFlipMode.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandlePolar.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandleXY.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColor.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorHsl.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorPreset.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbBinary.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbPercent.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSchemeBased.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSystemDefined.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFConnectionSite.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFDashStop.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectContainer.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectList.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFExtensionList.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryGuide.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryRectangle.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientStop.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGroupFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineEndProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinBevelProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinMiterProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinRoundProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLinearShadeProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFNoFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPath.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPathShadeProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPatternFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPictureFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPoint2D.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPositiveSize2D.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetGeometry2D.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetLineDash.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFRelativeRectangle.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFScene3D.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShape3D.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShapeProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFSolidFillProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFStretchInfoProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTileInfoProperties.java create mode 100644 src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTransform2D.java create mode 100644 src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java b/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java index c66b9e00ed..2912087c26 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java @@ -55,9 +55,9 @@ public class BarChartDemo { return; } - BufferedReader modelReader = new BufferedReader(new FileReader(args[1])); - XMLSlideShow pptx = null; - try { + try (FileInputStream argIS = new FileInputStream(args[0]); + BufferedReader modelReader = new BufferedReader(new FileReader(args[1]))) { + String chartTitle = modelReader.readLine(); // first line is chart title // Category Axis Data @@ -76,25 +76,18 @@ public class BarChartDemo { String[] categories = listCategories.toArray(new String[listCategories.size()]); Double[] values = listValues.toArray(new Double[listValues.size()]); - pptx = new XMLSlideShow(new FileInputStream(args[0])); - XSLFSlide slide = pptx.getSlides().get(0); - setBarData(findChart(slide), chartTitle, categories, values); + try (XMLSlideShow pptx = new XMLSlideShow(argIS)) { + XSLFSlide slide = pptx.getSlides().get(0); + setBarData(findChart(slide), chartTitle, categories, values); - XSLFChart chart = findChart(pptx.createSlide().importContent(slide)); - setColumnData(chart, "Column variant"); + XSLFChart chart = findChart(pptx.createSlide().importContent(slide)); + setColumnData(chart, "Column variant"); - // save the result - OutputStream out = new FileOutputStream("bar-chart-demo-output.pptx"); - try { - pptx.write(out); - } finally { - out.close(); - } - } finally { - if (pptx != null) { - pptx.close(); + // save the result + try (OutputStream out = new FileOutputStream("bar-chart-demo-output.pptx")) { + pptx.write(out); + } } - modelReader.close(); } } diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java b/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java index 45122f7b2f..1d613f54d9 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java +++ b/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java @@ -52,10 +52,11 @@ public class PieChartDemo { return; } - try (BufferedReader modelReader = new BufferedReader(new FileReader(args[1]))) { + try (FileInputStream argIS = new FileInputStream(args[0]); + BufferedReader modelReader = new BufferedReader(new FileReader(args[1]))) { String chartTitle = modelReader.readLine(); // first line is chart title - try (XMLSlideShow pptx = new XMLSlideShow(new FileInputStream(args[0]))) { + try (XMLSlideShow pptx = new XMLSlideShow(argIS)) { XSLFSlide slide = pptx.getSlides().get(0); // find chart in the slide @@ -70,17 +71,17 @@ public class PieChartDemo { if(chart == null) { throw new IllegalStateException("chart not found in the template"); } - + // Series Text List series = chart.getChartSeries(); XDDFPieChartData pie = (XDDFPieChartData) series.get(0); - + // Category Axis Data List listCategories = new ArrayList(3); - + // Values List listValues = new ArrayList(3); - + // set model String ln; while((ln = modelReader.readLine()) != null){ diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java new file mode 100644 index 0000000000..e05599f9fb --- /dev/null +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java @@ -0,0 +1,104 @@ +/* ==================================================================== + 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.xssf.usermodel.examples; + +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xddf.usermodel.PresetColor; +import org.apache.poi.xddf.usermodel.XDDFColor; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; +import org.apache.poi.xddf.usermodel.XDDFSolidFillProperties; +import org.apache.poi.xddf.usermodel.chart.AxisCrosses; +import org.apache.poi.xddf.usermodel.chart.AxisPosition; +import org.apache.poi.xddf.usermodel.chart.ChartTypes; +import org.apache.poi.xddf.usermodel.chart.LegendPosition; +import org.apache.poi.xddf.usermodel.chart.XDDFCategoryAxis; +import org.apache.poi.xddf.usermodel.chart.XDDFChartData; +import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend; +import org.apache.poi.xddf.usermodel.chart.XDDFDataSource; +import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory; +import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; +import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis; +import org.apache.poi.xssf.usermodel.XSSFChart; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +/** + * Line chart example. + */ +public class BarChart { + + public static void main(String[] args) throws IOException { + try (XSSFWorkbook wb = new XSSFWorkbook()) { + XSSFSheet sheet = wb.createSheet("barchart"); + final int NUM_OF_ROWS = 3; + final int NUM_OF_COLUMNS = 10; + + // Create a row and put some cells in it. Rows are 0 based. + Row row; + Cell cell; + for (int rowIndex = 0; rowIndex < NUM_OF_ROWS; rowIndex++) { + row = sheet.createRow((short) rowIndex); + for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) { + cell = row.createCell((short) colIndex); + cell.setCellValue(colIndex * (rowIndex + 1)); + } + } + + XSSFDrawing drawing = sheet.createDrawingPatriarch(); + XSSFClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15); + + XSSFChart chart = drawing.createChart(anchor); + XDDFChartLegend legend = chart.getOrAddLegend(); + legend.setPosition(LegendPosition.TOP_RIGHT); + + // Use a category axis for the bottom axis. + XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM); + XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT); + leftAxis.setCrosses(AxisCrosses.AUTO_ZERO); + + XDDFDataSource xs = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1)); + XDDFNumericalDataSource ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1)); + XDDFNumericalDataSource ys2 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1)); + + XDDFChartData data = chart.createData(ChartTypes.BAR, bottomAxis, leftAxis); + data.addSeries(xs, ys1); + data.addSeries(xs, ys2); + chart.plot(data); + + XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(PresetColor.CHARTREUSE)); + XDDFChartData.Series firstSeries = data.getSeries().get(0); + XDDFShapeProperties properties = firstSeries.getShapeProperties(); + if (properties == null) { + properties = new XDDFShapeProperties(); + } + properties.setFillProperties(fill); + firstSeries.setShapeProperties(properties); + + // Write the output to a file + try (FileOutputStream fileOut = new FileOutputStream("ooxml-bar-chart.xlsx")) { + wb.write(fileOut); + } + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/BlackWhiteMode.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/BlackWhiteMode.java new file mode 100644 index 0000000000..847fad3f3d --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/BlackWhiteMode.java @@ -0,0 +1,46 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STBlackWhiteMode; + +public enum BlackWhiteMode { + AUTO(STBlackWhiteMode.AUTO), + BLACK(STBlackWhiteMode.BLACK), + BLACK_GRAY(STBlackWhiteMode.BLACK_GRAY), + BLACK_WHITE(STBlackWhiteMode.BLACK_WHITE); + + final STBlackWhiteMode.Enum underlying; + + BlackWhiteMode(STBlackWhiteMode.Enum mode) { + this.underlying = mode; + } + + private final static HashMap reverse = new HashMap(); + static { + for (BlackWhiteMode value : values()) { + reverse.put(value.underlying, value); + } + } + + static BlackWhiteMode valueOf(STBlackWhiteMode.Enum mode) { + return reverse.get(mode); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/CompoundLine.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/CompoundLine.java new file mode 100644 index 0000000000..f696ac6db6 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/CompoundLine.java @@ -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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine; + +public enum CompoundLine { + DOUBLE(STCompoundLine.DBL), + SINGLE(STCompoundLine.SNG), + THICK_THIN(STCompoundLine.THICK_THIN), + THIN_THICK(STCompoundLine.THIN_THICK), + TRIPLE(STCompoundLine.TRI); + + final STCompoundLine.Enum underlying; + + CompoundLine(STCompoundLine.Enum line) { + this.underlying = line; + } + + private final static HashMap reverse = new HashMap(); + static { + for (CompoundLine value : values()) { + reverse.put(value.underlying, value); + } + } + + static CompoundLine valueOf(STCompoundLine.Enum LineEndWidth) { + return reverse.get(LineEndWidth); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/HasShapeProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/HasShapeProperties.java new file mode 100644 index 0000000000..8a664b6054 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/HasShapeProperties.java @@ -0,0 +1,22 @@ +/* ==================================================================== + 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; + +public interface HasShapeProperties { + XDDFShapeProperties getOrAddShapeProperties(); +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/LineCap.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineCap.java new file mode 100644 index 0000000000..a658ccb8b2 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineCap.java @@ -0,0 +1,45 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap; + +public enum LineCap { + FLAT(STLineCap.FLAT), + ROUND(STLineCap.RND), + SQUARE(STLineCap.SQ); + + final STLineCap.Enum underlying; + + LineCap(STLineCap.Enum line) { + this.underlying = line; + } + + private final static HashMap reverse = new HashMap(); + static { + for (LineCap value : values()) { + reverse.put(value.underlying, value); + } + } + + static LineCap valueOf(STLineCap.Enum LineEndWidth) { + return reverse.get(LineEndWidth); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndLength.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndLength.java new file mode 100644 index 0000000000..31f4414c67 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndLength.java @@ -0,0 +1,45 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength; + +public enum LineEndLength { + LARGE(STLineEndLength.LG), + MEDIUM(STLineEndLength.MED), + SMALL(STLineEndLength.SM); + + final STLineEndLength.Enum underlying; + + LineEndLength(STLineEndLength.Enum lineEnd) { + this.underlying = lineEnd; + } + + private final static HashMap reverse = new HashMap(); + static { + for (LineEndLength value : values()) { + reverse.put(value.underlying, value); + } + } + + static LineEndLength valueOf(STLineEndLength.Enum LineEndWidth) { + return reverse.get(LineEndWidth); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndType.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndType.java new file mode 100644 index 0000000000..8ef50ba543 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndType.java @@ -0,0 +1,48 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType; + +public enum LineEndType { + ARROW(STLineEndType.ARROW), + DIAMOND(STLineEndType.DIAMOND), + NONE(STLineEndType.NONE), + OVAL(STLineEndType.OVAL), + STEALTH(STLineEndType.STEALTH), + TRIANGLE(STLineEndType.TRIANGLE); + + final STLineEndType.Enum underlying; + + LineEndType(STLineEndType.Enum lineEnd) { + this.underlying = lineEnd; + } + + private final static HashMap reverse = new HashMap(); + static { + for (LineEndType value : values()) { + reverse.put(value.underlying, value); + } + } + + static LineEndType valueOf(STLineEndType.Enum LineEndWidth) { + return reverse.get(LineEndWidth); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndWidth.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndWidth.java new file mode 100644 index 0000000000..d93f7067a6 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/LineEndWidth.java @@ -0,0 +1,45 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth; + +public enum LineEndWidth { + LARGE(STLineEndWidth.LG), + MEDIUM(STLineEndWidth.MED), + SMALL(STLineEndWidth.SM); + + final STLineEndWidth.Enum underlying; + + LineEndWidth(STLineEndWidth.Enum lineEnd) { + this.underlying = lineEnd; + } + + private final static HashMap reverse = new HashMap(); + static { + for (LineEndWidth value : values()) { + reverse.put(value.underlying, value); + } + } + + static LineEndWidth valueOf(STLineEndWidth.Enum LineEndWidth) { + return reverse.get(LineEndWidth); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/PathShadeType.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/PathShadeType.java new file mode 100644 index 0000000000..913e7cb73a --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/PathShadeType.java @@ -0,0 +1,45 @@ +/* ==================================================================== +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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STPathShadeType; + +public enum PathShadeType { + CIRCLE(STPathShadeType.CIRCLE), + RECTANGLE(STPathShadeType.RECT), + SHAPE(STPathShadeType.SHAPE); + + final STPathShadeType.Enum underlying; + + PathShadeType(STPathShadeType.Enum pathShadeType) { + this.underlying = pathShadeType; + } + + private final static HashMap reverse = new HashMap(); + static { + for (PathShadeType value : values()) { + reverse.put(value.underlying, value); + } + } + + static PathShadeType valueOf(STPathShadeType.Enum pathShadeType) { + return reverse.get(pathShadeType); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/PenAlignment.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/PenAlignment.java new file mode 100644 index 0000000000..cbb4732fb2 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/PenAlignment.java @@ -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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STPenAlignment; + +public enum PenAlignment { + CENTER(STPenAlignment.CTR), + IN(STPenAlignment.IN); + + final STPenAlignment.Enum underlying; + + PenAlignment(STPenAlignment.Enum alignment) { + this.underlying = alignment; + } + + private final static HashMap reverse = new HashMap(); + static { + for (PenAlignment value : values()) { + reverse.put(value.underlying, value); + } + } + + static PenAlignment valueOf(STPenAlignment.Enum LineEndWidth) { + return reverse.get(LineEndWidth); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetColor.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetColor.java new file mode 100644 index 0000000000..ce723ebff9 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetColor.java @@ -0,0 +1,180 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STPresetColorVal; + +public enum PresetColor { + ALICE_BLUE(STPresetColorVal.ALICE_BLUE), + ANTIQUE_WHITE(STPresetColorVal.ANTIQUE_WHITE), + AQUA(STPresetColorVal.AQUA), + AQUAMARINE(STPresetColorVal.AQUAMARINE), + AZURE(STPresetColorVal.AZURE), + BEIGE(STPresetColorVal.BEIGE), + BISQUE(STPresetColorVal.BISQUE), + BLACK(STPresetColorVal.BLACK), + BLANCHED_ALMOND(STPresetColorVal.BLANCHED_ALMOND), + BLUE(STPresetColorVal.BLUE), + BLUE_VIOLET(STPresetColorVal.BLUE_VIOLET), + CADET_BLUE(STPresetColorVal.CADET_BLUE), + CHARTREUSE(STPresetColorVal.CHARTREUSE), + CHOCOLATE(STPresetColorVal.CHOCOLATE), + CORAL(STPresetColorVal.CORAL), + CORNFLOWER_BLUE(STPresetColorVal.CORNFLOWER_BLUE), + CORNSILK(STPresetColorVal.CORNSILK), + CRIMSON(STPresetColorVal.CRIMSON), + CYAN(STPresetColorVal.CYAN), + DEEP_PINK(STPresetColorVal.DEEP_PINK), + DEEP_SKY_BLUE(STPresetColorVal.DEEP_SKY_BLUE), + DIM_GRAY(STPresetColorVal.DIM_GRAY), + DARK_BLUE(STPresetColorVal.DK_BLUE), + DARK_CYAN(STPresetColorVal.DK_CYAN), + DARK_GOLDENROD(STPresetColorVal.DK_GOLDENROD), + DARK_GRAY(STPresetColorVal.DK_GRAY), + DARK_GREEN(STPresetColorVal.DK_GREEN), + DARK_KHAKI(STPresetColorVal.DK_KHAKI), + DARK_MAGENTA(STPresetColorVal.DK_MAGENTA), + DARK_OLIVE_GREEN(STPresetColorVal.DK_OLIVE_GREEN), + DARK_ORANGE(STPresetColorVal.DK_ORANGE), + DARK_ORCHID(STPresetColorVal.DK_ORCHID), + DARK_RED(STPresetColorVal.DK_RED), + DARK_SALMON(STPresetColorVal.DK_SALMON), + DARK_SEA_GREEN(STPresetColorVal.DK_SEA_GREEN), + DARK_SLATE_BLUE(STPresetColorVal.DK_SLATE_BLUE), + DARK_SLATE_GRAY(STPresetColorVal.DK_SLATE_GRAY), + DARK_TURQUOISE(STPresetColorVal.DK_TURQUOISE), + DARK_VIOLET(STPresetColorVal.DK_VIOLET), + DODGER_BLUE(STPresetColorVal.DODGER_BLUE), + FIREBRICK(STPresetColorVal.FIREBRICK), + FLORAL_WHITE(STPresetColorVal.FLORAL_WHITE), + FOREST_GREEN(STPresetColorVal.FOREST_GREEN), + FUCHSIA(STPresetColorVal.FUCHSIA), + GAINSBORO(STPresetColorVal.GAINSBORO), + GHOST_WHITE(STPresetColorVal.GHOST_WHITE), + GOLD(STPresetColorVal.GOLD), + GOLDENROD(STPresetColorVal.GOLDENROD), + GRAY(STPresetColorVal.GRAY), + GREEN(STPresetColorVal.GREEN), + GREEN_YELLOW(STPresetColorVal.GREEN_YELLOW), + HONEYDEW(STPresetColorVal.HONEYDEW), + HOT_PINK(STPresetColorVal.HOT_PINK), + INDIAN_RED(STPresetColorVal.INDIAN_RED), + INDIGO(STPresetColorVal.INDIGO), + IVORY(STPresetColorVal.IVORY), + KHAKI(STPresetColorVal.KHAKI), + LAVENDER(STPresetColorVal.LAVENDER), + LAVENDER_BLUSH(STPresetColorVal.LAVENDER_BLUSH), + LAWN_GREEN(STPresetColorVal.LAWN_GREEN), + LEMON_CHIFFON(STPresetColorVal.LEMON_CHIFFON), + LIME(STPresetColorVal.LIME), + LIME_GREEN(STPresetColorVal.LIME_GREEN), + LINEN(STPresetColorVal.LINEN), + LIGHT_BLUE(STPresetColorVal.LT_BLUE), + LIGHT_CORAL(STPresetColorVal.LT_CORAL), + LIGHT_CYAN(STPresetColorVal.LT_CYAN), + LIGHT_GOLDENROD_YELLOW(STPresetColorVal.LT_GOLDENROD_YELLOW), + LIGHT_GRAY(STPresetColorVal.LT_GRAY), + LIGHT_GREEN(STPresetColorVal.LT_GREEN), + LIGHT_PINK(STPresetColorVal.LT_PINK), + LIGHT_SALMON(STPresetColorVal.LT_SALMON), + LIGHT_SEA_GREEN(STPresetColorVal.LT_SEA_GREEN), + LIGHT_SKY_BLUE(STPresetColorVal.LT_SKY_BLUE), + LIGHT_SLATE_GRAY(STPresetColorVal.LT_SLATE_GRAY), + LIGHT_STEEL_BLUE(STPresetColorVal.LT_STEEL_BLUE), + LIGHT_YELLOW(STPresetColorVal.LT_YELLOW), + MAGENTA(STPresetColorVal.MAGENTA), + MAROON(STPresetColorVal.MAROON), + MEDIUM_AQUAMARINE(STPresetColorVal.MED_AQUAMARINE), + MEDIUM_BLUE(STPresetColorVal.MED_BLUE), + MEDIUM_ORCHID(STPresetColorVal.MED_ORCHID), + MEDIUM_PURPLE(STPresetColorVal.MED_PURPLE), + MEDIUM_SEA_GREEN(STPresetColorVal.MED_SEA_GREEN), + MEDIUM_SLATE_BLUE(STPresetColorVal.MED_SLATE_BLUE), + MEDIUM_SPRING_GREEN(STPresetColorVal.MED_SPRING_GREEN), + MEDIUM_TURQUOISE(STPresetColorVal.MED_TURQUOISE), + MEDIUM_VIOLET_RED(STPresetColorVal.MED_VIOLET_RED), + MIDNIGHT_BLUE(STPresetColorVal.MIDNIGHT_BLUE), + MINT_CREAM(STPresetColorVal.MINT_CREAM), + MISTY_ROSE(STPresetColorVal.MISTY_ROSE), + MOCCASIN(STPresetColorVal.MOCCASIN), + NAVAJO_WHITE(STPresetColorVal.NAVAJO_WHITE), + NAVY(STPresetColorVal.NAVY), + OLD_LACE(STPresetColorVal.OLD_LACE), + OLIVE(STPresetColorVal.OLIVE), + OLIVE_DRAB(STPresetColorVal.OLIVE_DRAB), + ORANGE(STPresetColorVal.ORANGE), + ORANGE_RED(STPresetColorVal.ORANGE_RED), + ORCHID(STPresetColorVal.ORCHID), + PALE_GOLDENROD(STPresetColorVal.PALE_GOLDENROD), + PALE_GREEN(STPresetColorVal.PALE_GREEN), + PALE_TURQUOISE(STPresetColorVal.PALE_TURQUOISE), + PALE_VIOLET_RED(STPresetColorVal.PALE_VIOLET_RED), + PAPAYA_WHIP(STPresetColorVal.PAPAYA_WHIP), + PEACH_PUFF(STPresetColorVal.PEACH_PUFF), + PERU(STPresetColorVal.PERU), + PINK(STPresetColorVal.PINK), + PLUM(STPresetColorVal.PLUM), + POWDER_BLUE(STPresetColorVal.POWDER_BLUE), + PURPLE(STPresetColorVal.PURPLE), + RED(STPresetColorVal.RED), + ROSY_BROWN(STPresetColorVal.ROSY_BROWN), + ROYAL_BLUE(STPresetColorVal.ROYAL_BLUE), + SADDLE_BROWN(STPresetColorVal.SADDLE_BROWN), + SALMON(STPresetColorVal.SALMON), + SANDY_BROWN(STPresetColorVal.SANDY_BROWN), + SEA_GREEN(STPresetColorVal.SEA_GREEN), + SEA_SHELL(STPresetColorVal.SEA_SHELL), + SIENNA(STPresetColorVal.SIENNA), + SILVER(STPresetColorVal.SILVER), + SKY_BLUE(STPresetColorVal.SKY_BLUE), + SLATE_BLUE(STPresetColorVal.SLATE_BLUE), + SLATE_GRAY(STPresetColorVal.SLATE_GRAY), + SNOW(STPresetColorVal.SNOW), + SPRING_GREEN(STPresetColorVal.SPRING_GREEN), + STEEL_BLUE(STPresetColorVal.STEEL_BLUE), + TAN(STPresetColorVal.TAN), + TEAL(STPresetColorVal.TEAL), + THISTLE(STPresetColorVal.THISTLE), + TOMATO(STPresetColorVal.TOMATO), + TURQUOISE(STPresetColorVal.TURQUOISE), + VIOLET(STPresetColorVal.VIOLET), + WHEAT(STPresetColorVal.WHEAT), + WHITE(STPresetColorVal.WHITE), + WHITE_SMOKE(STPresetColorVal.WHITE_SMOKE), + YELLOW(STPresetColorVal.YELLOW), + YELLOW_GREEN(STPresetColorVal.YELLOW_GREEN); + + final STPresetColorVal.Enum underlying; + + PresetColor(STPresetColorVal.Enum color) { + this.underlying = color; + } + + private final static HashMap reverse = new HashMap(); + static { + for (PresetColor value : values()) { + reverse.put(value.underlying, value); + } + } + + static PresetColor valueOf(STPresetColorVal.Enum color) { + return reverse.get(color); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetGeometry.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetGeometry.java new file mode 100644 index 0000000000..85afa8387e --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetGeometry.java @@ -0,0 +1,230 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType; + +public enum PresetGeometry { + ACCENT_BORDER_CALLOUT_1(STShapeType.ACCENT_BORDER_CALLOUT_1), + ACCENT_BORDER_CALLOUT_2(STShapeType.ACCENT_BORDER_CALLOUT_2), + ACCENT_BORDER_CALLOUT_3(STShapeType.ACCENT_BORDER_CALLOUT_3), + ACCENT_CALLOUT_1(STShapeType.ACCENT_CALLOUT_1), + ACCENT_CALLOUT_2(STShapeType.ACCENT_CALLOUT_2), + ACCENT_CALLOUT_3(STShapeType.ACCENT_CALLOUT_3), + ACTION_BUTTON_BACK_PREVIOUS(STShapeType.ACTION_BUTTON_BACK_PREVIOUS), + ACTION_BUTTON_BEGINNING(STShapeType.ACTION_BUTTON_BEGINNING), + ACTION_BUTTON_BLANK(STShapeType.ACTION_BUTTON_BLANK), + ACTION_BUTTON_DOCUMENT(STShapeType.ACTION_BUTTON_DOCUMENT), + ACTION_BUTTON_END(STShapeType.ACTION_BUTTON_END), + ACTION_BUTTON_FORWARD_NEXT(STShapeType.ACTION_BUTTON_FORWARD_NEXT), + ACTION_BUTTON_HELP(STShapeType.ACTION_BUTTON_HELP), + ACTION_BUTTON_HOME(STShapeType.ACTION_BUTTON_HOME), + ACTION_BUTTON_INFORMATION(STShapeType.ACTION_BUTTON_INFORMATION), + ACTION_BUTTON_MOVIE(STShapeType.ACTION_BUTTON_MOVIE), + ACTION_BUTTON_RETURN(STShapeType.ACTION_BUTTON_RETURN), + ACTION_BUTTON_SOUND(STShapeType.ACTION_BUTTON_SOUND), + ARC(STShapeType.ARC), + BENT_ARROW(STShapeType.BENT_ARROW), + BENT_CONNECTOR_2(STShapeType.BENT_CONNECTOR_2), + BENT_CONNECTOR_3(STShapeType.BENT_CONNECTOR_3), + DARK_BLUE(STShapeType.BENT_CONNECTOR_4), + BENT_CONNECTOR_4(STShapeType.BENT_CONNECTOR_4), + BENT_CONNECTOR_5(STShapeType.BENT_CONNECTOR_5), + BENT_UP_ARROW(STShapeType.BENT_UP_ARROW), + BEVEL(STShapeType.BEVEL), + BLOCK_ARC(STShapeType.BLOCK_ARC), + BORDER_CALLOUT_1(STShapeType.BORDER_CALLOUT_1), + BORDER_CALLOUT_2(STShapeType.BORDER_CALLOUT_2), + BORDER_CALLOUT_3(STShapeType.BORDER_CALLOUT_3), + BRACE_PAIR(STShapeType.BRACE_PAIR), + BRACKET_PAIR(STShapeType.BRACKET_PAIR), + CALLOUT_1(STShapeType.CALLOUT_1), + CALLOUT_2(STShapeType.CALLOUT_2), + CALLOUT_3(STShapeType.CALLOUT_3), + CAN(STShapeType.CAN), + CHART_PLUS(STShapeType.CHART_PLUS), + CHART_STAR(STShapeType.CHART_STAR), + CHART_X(STShapeType.CHART_X), + CHEVRON(STShapeType.CHEVRON), + CHORD(STShapeType.CHORD), + CIRCULAR_ARROW(STShapeType.CIRCULAR_ARROW), + CLOUD(STShapeType.CLOUD), + CLOUD_CALLOUT(STShapeType.CLOUD_CALLOUT), + CORNER(STShapeType.CORNER), + CORNER_TABS(STShapeType.CORNER_TABS), + CUBE(STShapeType.CUBE), + CURVED_CONNECTOR_2(STShapeType.CURVED_CONNECTOR_2), + CURVED_CONNECTOR_3(STShapeType.CURVED_CONNECTOR_3), + CURVED_CONNECTOR_4(STShapeType.CURVED_CONNECTOR_4), + CURVED_CONNECTOR_5(STShapeType.CURVED_CONNECTOR_5), + CURVED_DOWN_ARROW(STShapeType.CURVED_DOWN_ARROW), + CURVED_LEFT_ARROW(STShapeType.CURVED_LEFT_ARROW), + CURVED_RIGHT_ARROW(STShapeType.CURVED_RIGHT_ARROW), + CURVED_UP_ARROW(STShapeType.CURVED_UP_ARROW), + DECAGON(STShapeType.DECAGON), + DIAGONAL_STRIPE(STShapeType.DIAG_STRIPE), + DIAMOND(STShapeType.DIAMOND), + DODECAGON(STShapeType.DODECAGON), + DONUT(STShapeType.DONUT), + DOUBLE_WAVE(STShapeType.DOUBLE_WAVE), + DOWN_ARROW(STShapeType.DOWN_ARROW), + DOWN_ARROW_CALLOUT(STShapeType.DOWN_ARROW_CALLOUT), + ELLIPSE(STShapeType.ELLIPSE), + ELLIPSE_RIBBON(STShapeType.ELLIPSE_RIBBON), + ELLIPSE_RIBBON_2(STShapeType.ELLIPSE_RIBBON_2), + FLOW_CHART_ALTERNATE_PROCESS(STShapeType.FLOW_CHART_ALTERNATE_PROCESS), + FLOW_CHART_COLLATE(STShapeType.FLOW_CHART_COLLATE), + FLOW_CHART_CONNECTOR(STShapeType.FLOW_CHART_CONNECTOR), + FLOW_CHART_DECISION(STShapeType.FLOW_CHART_DECISION), + FLOW_CHART_DELAY(STShapeType.FLOW_CHART_DELAY), + FLOW_CHART_DISPLAY(STShapeType.FLOW_CHART_DISPLAY), + FLOW_CHART_DOCUMENT(STShapeType.FLOW_CHART_DOCUMENT), + FLOW_CHART_EXTRACT(STShapeType.FLOW_CHART_EXTRACT), + FLOW_CHART_INPUT_OUTPUT(STShapeType.FLOW_CHART_INPUT_OUTPUT), + FLOW_CHART_INTERNAL_STORAGE(STShapeType.FLOW_CHART_INTERNAL_STORAGE), + FLOW_CHART_MAGNETIC_DISK(STShapeType.FLOW_CHART_MAGNETIC_DISK), + FLOW_CHART_MAGNETIC_DRUM(STShapeType.FLOW_CHART_MAGNETIC_DRUM), + FLOW_CHART_MAGNETIC_TAPE(STShapeType.FLOW_CHART_MAGNETIC_TAPE), + FLOW_CHART_MANUAL_INPUT(STShapeType.FLOW_CHART_MANUAL_INPUT), + FLOW_CHART_MANUAL_OPERATION(STShapeType.FLOW_CHART_MANUAL_OPERATION), + FLOW_CHART_MERGE(STShapeType.FLOW_CHART_MERGE), + FLOW_CHART_MULTIDOCUMENT(STShapeType.FLOW_CHART_MULTIDOCUMENT), + FLOW_CHART_OFFLINE_STORAGE(STShapeType.FLOW_CHART_OFFLINE_STORAGE), + FLOW_CHART_OFFPAGE_CONNECTOR(STShapeType.FLOW_CHART_OFFPAGE_CONNECTOR), + FLOW_CHART_ONLINE_STORAGE(STShapeType.FLOW_CHART_ONLINE_STORAGE), + FLOW_CHART_OR(STShapeType.FLOW_CHART_OR), + FLOW_CHART_PREDEFINED_PROCESS(STShapeType.FLOW_CHART_PREDEFINED_PROCESS), + FLOW_CHART_PREPARATION(STShapeType.FLOW_CHART_PREPARATION), + FLOW_CHART_PROCESS(STShapeType.FLOW_CHART_PROCESS), + FLOW_CHART_PUNCHED_CARD(STShapeType.FLOW_CHART_PUNCHED_CARD), + FLOW_CHART_PUNCHED_TAPE(STShapeType.FLOW_CHART_PUNCHED_TAPE), + FLOW_CHART_SORT(STShapeType.FLOW_CHART_SORT), + FLOW_CHART_SUMMING_JUNCTION(STShapeType.FLOW_CHART_SUMMING_JUNCTION), + FLOW_CHART_TERMINATOR(STShapeType.FLOW_CHART_TERMINATOR), + FOLDED_CORNER(STShapeType.FOLDED_CORNER), + FRAME(STShapeType.FRAME), + FUNNEL(STShapeType.FUNNEL), + GEAR_6(STShapeType.GEAR_6), + GEAR_9(STShapeType.GEAR_9), + HALF_FRAME(STShapeType.HALF_FRAME), + HEART(STShapeType.HEART), + HEPTAGON(STShapeType.HEPTAGON), + HEXAGON(STShapeType.HEXAGON), + HOME_PLATE(STShapeType.HOME_PLATE), + HORIZONTAL_SCROLL(STShapeType.HORIZONTAL_SCROLL), + IRREGULAR_SEAL_1(STShapeType.IRREGULAR_SEAL_1), + IRREGULAR_SEAL_2(STShapeType.IRREGULAR_SEAL_2), + LEFT_ARROW(STShapeType.LEFT_ARROW), + LEFT_ARROW_CALLOUT(STShapeType.LEFT_ARROW_CALLOUT), + LEFT_BRACE(STShapeType.LEFT_BRACE), + LEFT_BRACKET(STShapeType.LEFT_BRACKET), + LEFT_CIRCULAR_ARROW(STShapeType.LEFT_CIRCULAR_ARROW), + LEFT_RIGHT_ARROW(STShapeType.LEFT_RIGHT_ARROW), + LEFT_RIGHT_ARROW_CALLOUT(STShapeType.LEFT_RIGHT_ARROW_CALLOUT), + LEFT_RIGHT_CIRCULAR_ARROW(STShapeType.LEFT_RIGHT_CIRCULAR_ARROW), + LEFT_RIGHT_RIBBON(STShapeType.LEFT_RIGHT_RIBBON), + LEFT_RIGHT_UP_ARROW(STShapeType.LEFT_RIGHT_UP_ARROW), + LEFT_UP_ARROW(STShapeType.LEFT_UP_ARROW), + LIGHTNING_BOLT(STShapeType.LIGHTNING_BOLT), + LINE(STShapeType.LINE), + LINE_INVERTED(STShapeType.LINE_INV), + MATH_DIVIDE(STShapeType.MATH_DIVIDE), + MATH_EQUAL(STShapeType.MATH_EQUAL), + MATH_MINUS(STShapeType.MATH_MINUS), + MATH_MULTIPLY(STShapeType.MATH_MULTIPLY), + MATH_NOT_EQUAL(STShapeType.MATH_NOT_EQUAL), + MATH_PLUS(STShapeType.MATH_PLUS), + MOON(STShapeType.MOON), + NO_SMOKING(STShapeType.NO_SMOKING), + NON_ISOSCELES_TRAPEZOID(STShapeType.NON_ISOSCELES_TRAPEZOID), + NOTCHED_RIGHT_ARROW(STShapeType.NOTCHED_RIGHT_ARROW), + OCTAGON(STShapeType.OCTAGON), + PARALLELOGRAM(STShapeType.PARALLELOGRAM), + PENTAGON(STShapeType.PENTAGON), + PIE(STShapeType.PIE), + PIE_WEDGE(STShapeType.PIE_WEDGE), + PLAQUE(STShapeType.PLAQUE), + PLAQUE_TABS(STShapeType.PLAQUE_TABS), + PLUS(STShapeType.PLUS), + QUAD_ARROW(STShapeType.QUAD_ARROW), + QUAD_ARROW_CALLOUT(STShapeType.QUAD_ARROW_CALLOUT), + RECTANGLE(STShapeType.RECT), + RIBBON(STShapeType.RIBBON), + RIBBON_2(STShapeType.RIBBON_2), + RIGHT_ARROW(STShapeType.RIGHT_ARROW), + RIGHT_ARROW_CALLOUT(STShapeType.RIGHT_ARROW_CALLOUT), + RIGHT_BRACE(STShapeType.RIGHT_BRACE), + RIGHT_BRACKET(STShapeType.RIGHT_BRACKET), + ROUND_RECTANGLE_1_CORNER(STShapeType.ROUND_1_RECT), + ROUND_RECTANGLE_2_DIAGONAL_CORNERS(STShapeType.ROUND_2_DIAG_RECT), + ROUND_RECTANGLE_2_SAME_SIDE_CORNERS(STShapeType.ROUND_2_SAME_RECT), + ROUND_RECTANGLE(STShapeType.ROUND_RECT), + RIGHT_TRIANGLE(STShapeType.RT_TRIANGLE), + SMILEY_FACE(STShapeType.SMILEY_FACE), + SNIP_RECTANGLE_1_CORNER(STShapeType.SNIP_1_RECT), + SNIP_RECTANGLE_2_DIAGONAL_CORNERS(STShapeType.SNIP_2_DIAG_RECT), + SNIP_RECTANGLE_2_SAME_SIDE_CORNERS(STShapeType.SNIP_2_SAME_RECT), + SNIP_ROUND_RECTANGLE(STShapeType.SNIP_ROUND_RECT), + SQUARE_TABS(STShapeType.SQUARE_TABS), + STAR_10(STShapeType.STAR_10), + STAR_12(STShapeType.STAR_12), + STAR_16(STShapeType.STAR_16), + STAR_24(STShapeType.STAR_24), + STAR_32(STShapeType.STAR_32), + STAR_4(STShapeType.STAR_4), + STAR_5(STShapeType.STAR_5), + STAR_6(STShapeType.STAR_6), + STAR_7(STShapeType.STAR_7), + STAR_8(STShapeType.STAR_8), + STRAIGHT_CONNECTOR(STShapeType.STRAIGHT_CONNECTOR_1), + STRIPED_RIGHT_ARROW(STShapeType.STRIPED_RIGHT_ARROW), + SUN(STShapeType.SUN), + SWOOSH_ARROW(STShapeType.SWOOSH_ARROW), + TEARDROP(STShapeType.TEARDROP), + TRAPEZOID(STShapeType.TRAPEZOID), + TRIANGLE(STShapeType.TRIANGLE), + UP_ARROW(STShapeType.UP_ARROW), + UP_ARROW_CALLOUT(STShapeType.UP_ARROW_CALLOUT), + UP_DOWN_ARROW(STShapeType.UP_DOWN_ARROW), + UP_DOWN_ARROW_CALLOUT(STShapeType.UP_DOWN_ARROW_CALLOUT), + UTURN_ARROW(STShapeType.UTURN_ARROW), + VERTICAL_SCROLL(STShapeType.VERTICAL_SCROLL), + WAVE(STShapeType.WAVE), + WEDGE_ELLIPSE_CALLOUT(STShapeType.WEDGE_ELLIPSE_CALLOUT), + WEDGE_RECTANGLE_CALLOUT(STShapeType.WEDGE_RECT_CALLOUT), + WEDGE_ROUND_RECTANGLE_CALLOUT(STShapeType.WEDGE_ROUND_RECT_CALLOUT); + + final STShapeType.Enum underlying; + + PresetGeometry(STShapeType.Enum shape) { + this.underlying = shape; + } + + private final static HashMap reverse = new HashMap(); + static { + for (PresetGeometry value : values()) { + reverse.put(value.underlying, value); + } + } + + static PresetGeometry valueOf(STShapeType.Enum shape) { + return reverse.get(shape); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetLineDash.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetLineDash.java new file mode 100644 index 0000000000..0b512eaa62 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetLineDash.java @@ -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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal; + +public enum PresetLineDash { + DASH(STPresetLineDashVal.DASH), + DASH_DOT(STPresetLineDashVal.DASH_DOT), + DOT(STPresetLineDashVal.DOT), + LARGE_DASH(STPresetLineDashVal.LG_DASH), + LARGE_DASH_DOT(STPresetLineDashVal.LG_DASH_DOT), + LARGE_DASH_DOT_DOT(STPresetLineDashVal.LG_DASH_DOT_DOT), + SOLID(STPresetLineDashVal.SOLID), + SYSTEM_DASH(STPresetLineDashVal.SYS_DASH), + SYSTEM_DASH_DOT(STPresetLineDashVal.SYS_DASH_DOT), + SYSTEM_DASH_DOT_DOT(STPresetLineDashVal.SYS_DASH_DOT_DOT), + SYSTEM_DOT(STPresetLineDashVal.SYS_DOT); + + final STPresetLineDashVal.Enum underlying; + + PresetLineDash(STPresetLineDashVal.Enum dash) { + this.underlying = dash; + } + + private final static HashMap reverse = new HashMap(); + static { + for (PresetLineDash value : values()) { + reverse.put(value.underlying, value); + } + } + + static PresetLineDash valueOf(STPresetLineDashVal.Enum dash) { + return reverse.get(dash); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetPattern.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetPattern.java new file mode 100644 index 0000000000..8be7b2d673 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/PresetPattern.java @@ -0,0 +1,96 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STPresetPatternVal; + +public enum PresetPattern { + CROSS(STPresetPatternVal.CROSS), + DASH_DOWNWARD_DIAGONAL(STPresetPatternVal.DASH_DN_DIAG), + DASH_HORIZONTAL(STPresetPatternVal.DASH_HORZ), + DASH_UPWARD_DIAGONAL(STPresetPatternVal.DASH_UP_DIAG), + DASH_VERTICAL(STPresetPatternVal.DASH_VERT), + DIAGONAL_BRICK(STPresetPatternVal.DIAG_BRICK), + DIAGONAL_CROSS(STPresetPatternVal.DIAG_CROSS), + DIVOT(STPresetPatternVal.DIVOT), + DARK_DOWNWARD_DIAGONAL(STPresetPatternVal.DK_DN_DIAG), + DARK_HORIZONTAL(STPresetPatternVal.DK_HORZ), + DARK_UPWARD_DIAGONAL(STPresetPatternVal.DK_UP_DIAG), + DARK_VERTICAL(STPresetPatternVal.DK_VERT), + DOWNWARD_DIAGONAL(STPresetPatternVal.DN_DIAG), + DOTTED_DIAMOND(STPresetPatternVal.DOT_DMND), + DOTTED_GRID(STPresetPatternVal.DOT_GRID), + HORIZONTAL(STPresetPatternVal.HORZ), + HORIZONTAL_BRICK(STPresetPatternVal.HORZ_BRICK), + LARGE_CHECKER_BOARD(STPresetPatternVal.LG_CHECK), + LARGE_CONFETTI(STPresetPatternVal.LG_CONFETTI), + LARGE_GRID(STPresetPatternVal.LG_GRID), + LIGHT_DOWNWARD_DIAGONAL(STPresetPatternVal.LT_DN_DIAG), + LIGHT_HORIZONTAL(STPresetPatternVal.LT_HORZ), + LIGHT_UPWARD_DIAGONAL(STPresetPatternVal.LT_UP_DIAG), + LIGHT_VERTICAL(STPresetPatternVal.LT_VERT), + NARROW_HORIZONTAL(STPresetPatternVal.NAR_HORZ), + NARROW_VERTICAL(STPresetPatternVal.NAR_VERT), + OPEN_DIAMOND(STPresetPatternVal.OPEN_DMND), + PERCENT_5(STPresetPatternVal.PCT_5), + PERCENT_10(STPresetPatternVal.PCT_10), + PERCENT_20(STPresetPatternVal.PCT_20), + PERCENT_25(STPresetPatternVal.PCT_25), + PERCENT_30(STPresetPatternVal.PCT_30), + PERCENT_40(STPresetPatternVal.PCT_40), + PERCENT_50(STPresetPatternVal.PCT_50), + PERCENT_60(STPresetPatternVal.PCT_60), + PERCENT_70(STPresetPatternVal.PCT_70), + PERCENT_75(STPresetPatternVal.PCT_75), + PERCENT_80(STPresetPatternVal.PCT_80), + PERCENT_90(STPresetPatternVal.PCT_90), + PLAID(STPresetPatternVal.PLAID), + SHINGLE(STPresetPatternVal.SHINGLE), + SMALL_CHECKER_BOARD(STPresetPatternVal.SM_CHECK), + SMALL_CONFETTI(STPresetPatternVal.SM_CONFETTI), + SMALL_GRID(STPresetPatternVal.SM_GRID), + SOLID_DIAMOND(STPresetPatternVal.SOLID_DMND), + SPHERE(STPresetPatternVal.SPHERE), + TRELLIS(STPresetPatternVal.TRELLIS), + UPWARD_DIAGONAL(STPresetPatternVal.UP_DIAG), + VERTICAL(STPresetPatternVal.VERT), + WAVE(STPresetPatternVal.WAVE), + WEAVE(STPresetPatternVal.WEAVE), + WIDE_DOWNWARD_DIAGONAL(STPresetPatternVal.WD_DN_DIAG), + WIDE_UPWARD_DIAGONAL(STPresetPatternVal.WD_UP_DIAG), + ZIG_ZAG(STPresetPatternVal.ZIG_ZAG); + + final STPresetPatternVal.Enum underlying; + + PresetPattern(STPresetPatternVal.Enum pattern) { + this.underlying = pattern; + } + + private final static HashMap reverse = new HashMap(); + static { + for (PresetPattern value : values()) { + reverse.put(value.underlying, value); + } + } + + static PresetPattern valueOf(STPresetPatternVal.Enum pattern) { + return reverse.get(pattern); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/RectangleAlignment.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/RectangleAlignment.java new file mode 100644 index 0000000000..ba116e01ac --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/RectangleAlignment.java @@ -0,0 +1,51 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STRectAlignment; + +public enum RectangleAlignment { + BOTTOM(STRectAlignment.B), + BOTTOM_LEFT(STRectAlignment.BL), + BOTTOM_RIGHT(STRectAlignment.BR), + CENTER(STRectAlignment.CTR), + LEFT(STRectAlignment.L), + RIGHT(STRectAlignment.R), + TOP(STRectAlignment.T), + TOP_LEFT(STRectAlignment.TL), + TOP_RIGHT(STRectAlignment.TR); + + final STRectAlignment.Enum underlying; + + RectangleAlignment(STRectAlignment.Enum alignment) { + this.underlying = alignment; + } + + private final static HashMap reverse = new HashMap(); + static { + for (RectangleAlignment value : values()) { + reverse.put(value.underlying, value); + } + } + + static RectangleAlignment valueOf(STRectAlignment.Enum alignment) { + return reverse.get(alignment); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/SchemeColor.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/SchemeColor.java new file mode 100644 index 0000000000..896c5d1fc8 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/SchemeColor.java @@ -0,0 +1,59 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal; + +public enum SchemeColor { + ACCENT_1(STSchemeColorVal.ACCENT_1), + ACCENT_2(STSchemeColorVal.ACCENT_2), + ACCENT_3(STSchemeColorVal.ACCENT_3), + ACCENT_4(STSchemeColorVal.ACCENT_4), + ACCENT_5(STSchemeColorVal.ACCENT_5), + ACCENT_6(STSchemeColorVal.ACCENT_6), + BACKGROUND_1(STSchemeColorVal.BG_1), + BACKGROUND_2(STSchemeColorVal.BG_2), + DARK_1(STSchemeColorVal.DK_1), + DARK_2(STSchemeColorVal.DK_2), + FOLLOWED_LINK(STSchemeColorVal.FOL_HLINK), + LINK(STSchemeColorVal.HLINK), + LIGHT_1(STSchemeColorVal.LT_1), + LIGHT_2(STSchemeColorVal.LT_2), + PLACEHOLDER(STSchemeColorVal.PH_CLR), + TEXT_1(STSchemeColorVal.TX_1), + TEXT_2(STSchemeColorVal.TX_2); + + final STSchemeColorVal.Enum underlying; + + SchemeColor(STSchemeColorVal.Enum color) { + this.underlying = color; + } + + private final static HashMap reverse = new HashMap(); + static { + for (SchemeColor value : values()) { + reverse.put(value.underlying, value); + } + } + + static SchemeColor valueOf(STSchemeColorVal.Enum color) { + return reverse.get(color); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/SystemColor.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/SystemColor.java new file mode 100644 index 0000000000..7521a15c8d --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/SystemColor.java @@ -0,0 +1,72 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STSystemColorVal; + +public enum SystemColor { + ACTIVE_BORDER(STSystemColorVal.ACTIVE_BORDER), + ACTIVE_CAPTION(STSystemColorVal.ACTIVE_CAPTION), + APPLICATION_WORKSPACE(STSystemColorVal.APP_WORKSPACE), + BACKGROUND(STSystemColorVal.BACKGROUND), + BUTTON_FACE(STSystemColorVal.BTN_FACE), + BUTTON_HIGHLIGHT(STSystemColorVal.BTN_HIGHLIGHT), + BUTTON_SHADOW(STSystemColorVal.BTN_SHADOW), + BUTTON_TEXT(STSystemColorVal.BTN_TEXT), + CAPTION_TEXT(STSystemColorVal.CAPTION_TEXT), + GRADIENT_ACTIVE_CAPTION(STSystemColorVal.GRADIENT_ACTIVE_CAPTION), + GRADIENT_INACTIVE_CAPTION(STSystemColorVal.GRADIENT_INACTIVE_CAPTION), + GRAY_TEXT(STSystemColorVal.GRAY_TEXT), + HIGHLIGHT(STSystemColorVal.HIGHLIGHT), + HIGHLIGHT_TEXT(STSystemColorVal.HIGHLIGHT_TEXT), + HOT_LIGHT(STSystemColorVal.HOT_LIGHT), + INACTIVE_BORDER(STSystemColorVal.INACTIVE_BORDER), + INACTIVE_CAPTION(STSystemColorVal.INACTIVE_CAPTION), + INACTIVE_CAPTION_TEXT(STSystemColorVal.INACTIVE_CAPTION_TEXT), + INFO_BACKGROUND(STSystemColorVal.INFO_BK), + INFO_TEXT(STSystemColorVal.INFO_TEXT), + MENU(STSystemColorVal.MENU), + MENU_BAR(STSystemColorVal.MENU_BAR), + MENU_HIGHLIGHT(STSystemColorVal.MENU_HIGHLIGHT), + MENU_TEXT(STSystemColorVal.MENU_TEXT), + SCROLL_BAR(STSystemColorVal.SCROLL_BAR), + WINDOW(STSystemColorVal.WINDOW), + WINDOW_FRAME(STSystemColorVal.WINDOW_FRAME), + WINDOW_TEXT(STSystemColorVal.WINDOW_TEXT), + X_3D_DARK_SHADOW(STSystemColorVal.X_3_D_DK_SHADOW), + X_3D_LIGHT(STSystemColorVal.X_3_D_LIGHT); + + final STSystemColorVal.Enum underlying; + + SystemColor(STSystemColorVal.Enum color) { + this.underlying = color; + } + + private final static HashMap reverse = new HashMap(); + static { + for (SystemColor value : values()) { + reverse.put(value.underlying, value); + } + } + + static SystemColor valueOf(STSystemColorVal.Enum color) { + return reverse.get(color); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/TileFlipMode.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/TileFlipMode.java new file mode 100644 index 0000000000..a63a2ac878 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/TileFlipMode.java @@ -0,0 +1,46 @@ +/* ==================================================================== + 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; + +import java.util.HashMap; + +import org.openxmlformats.schemas.drawingml.x2006.main.STTileFlipMode; + +public enum TileFlipMode { + NONE(STTileFlipMode.NONE), + X(STTileFlipMode.X), + XY(STTileFlipMode.XY), + Y(STTileFlipMode.Y); + + final STTileFlipMode.Enum underlying; + + TileFlipMode(STTileFlipMode.Enum mode) { + this.underlying = mode; + } + + private final static HashMap reverse = new HashMap(); + static { + for (TileFlipMode value : values()) { + reverse.put(value.underlying, value); + } + } + + static TileFlipMode valueOf(STTileFlipMode.Enum mode) { + return reverse.get(mode); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandlePolar.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandlePolar.java new file mode 100644 index 0000000000..c9ebc717f0 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandlePolar.java @@ -0,0 +1,39 @@ +/* + * ==================================================================== + * 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPolarAdjustHandle; + +@Beta +public class XDDFAdjustHandlePolar { + private CTPolarAdjustHandle handle; + + @Internal + public XDDFAdjustHandlePolar(CTPolarAdjustHandle handle) { + this.handle = handle; + } + + @Internal + public CTPolarAdjustHandle getXmlObject() { + return handle; + } + } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandleXY.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandleXY.java new file mode 100644 index 0000000000..608af4ba0e --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFAdjustHandleXY.java @@ -0,0 +1,39 @@ +/* + * ==================================================================== + * 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTXYAdjustHandle; + +@Beta +public class XDDFAdjustHandleXY { + private CTXYAdjustHandle handle; + + @Internal + public XDDFAdjustHandleXY(CTXYAdjustHandle handle) { + this.handle = handle; + } + + @Internal + public CTXYAdjustHandle getXmlObject() { + return handle; + } + } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColor.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColor.java new file mode 100644 index 0000000000..4e07f46c7a --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColor.java @@ -0,0 +1,79 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; + +@Beta +public abstract class XDDFColor { + protected CTColor container; + + @Internal + protected XDDFColor(CTColor container) { + this.container = container; + } + + public static XDDFColor from(byte[] color) { + return new XDDFColorRgbBinary(color); + } + + public static XDDFColor from(int red, int green, int blue) { + return new XDDFColorRgbPercent(red, green, blue); + } + + public static XDDFColor from(PresetColor color) { + return new XDDFColorPreset(color); + } + + public static XDDFColor from(SchemeColor color) { + return new XDDFColorSchemeBased(color); + } + + public static XDDFColor from(SystemColor color) { + return new XDDFColorSystemDefined(color); + } + + @Internal + protected static XDDFColor forColorContainer(CTColor container) { + if (container.isSetHslClr()) { + return new XDDFColorHsl(container.getHslClr(), container); + } else if (container.isSetPrstClr()) { + return new XDDFColorPreset(container.getPrstClr(), container); + } else if (container.isSetSchemeClr()) { + return new XDDFColorSchemeBased(container.getSchemeClr(), container); + } else if (container.isSetScrgbClr()) { + return new XDDFColorRgbPercent(container.getScrgbClr(), container); + } else if (container.isSetSrgbClr()) { + return new XDDFColorRgbBinary(container.getSrgbClr(), container); + } else if (container.isSetSysClr()) { + return new XDDFColorSystemDefined(container.getSysClr(), container); + } + return null; + } + + @Internal + protected CTColor getColorContainer() { + return container; + } + + @Internal + protected abstract XmlObject getXmlObject(); +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorHsl.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorHsl.java new file mode 100644 index 0000000000..a25296de83 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorHsl.java @@ -0,0 +1,77 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor; + +@Beta +public class XDDFColorHsl extends XDDFColor { + private CTHslColor color; + + public XDDFColorHsl(int hue, int saturation, int luminance) { + this(CTHslColor.Factory.newInstance(), CTColor.Factory.newInstance()); + setHue(hue); + setSaturation(saturation); + setLuminance(luminance); + } + + @Internal + protected XDDFColorHsl(CTHslColor color) { + this(color, null); + } + + @Internal + protected XDDFColorHsl(CTHslColor color, CTColor container) { + super(container); + this.color = color; + } + + @Override + @Internal + protected XmlObject getXmlObject() { + return color; + } + + public int getHue() { + return color.getHue2(); + } + + public void setHue(int hue) { + color.setHue2(hue); + } + + public int getSaturation() { + return color.getSat2(); + } + + public void setSaturation(int saturation) { + color.setSat2(saturation); + } + + public int getLuminance() { + return color.getLum2(); + } + + public void setLuminance(int lightness) { + color.setLum2(lightness); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorPreset.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorPreset.java new file mode 100644 index 0000000000..9b477f8ba0 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorPreset.java @@ -0,0 +1,69 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor; + +@Beta +public class XDDFColorPreset extends XDDFColor { + private CTPresetColor color; + + public XDDFColorPreset(PresetColor color) { + this(CTPresetColor.Factory.newInstance(), CTColor.Factory.newInstance()); + setValue(color); + } + + @Internal + protected XDDFColorPreset(CTPresetColor color) { + this(color, null); + } + + @Internal + protected XDDFColorPreset(CTPresetColor color, CTColor container) { + super(container); + this.color = color; + } + + @Override + @Internal + protected XmlObject getXmlObject() { + return color; + } + + public PresetColor getValue() { + if (color.isSetVal()) { + return PresetColor.valueOf(color.getVal()); + } else { + return null; + } + } + + public void setValue(PresetColor value) { + if (value == null) { + if (color.isSetVal()) { + color.unsetVal(); + } + } else { + color.setVal(value.underlying); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbBinary.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbBinary.java new file mode 100644 index 0000000000..01cb6f2c07 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbBinary.java @@ -0,0 +1,69 @@ +/* ==================================================================== + 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; + +import java.util.Locale; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor; + +@Beta +public class XDDFColorRgbBinary extends XDDFColor { + private CTSRgbColor color; + + public XDDFColorRgbBinary(byte[] color) { + this(CTSRgbColor.Factory.newInstance(), CTColor.Factory.newInstance()); + setValue(color); + } + + @Internal + protected XDDFColorRgbBinary(CTSRgbColor color) { + this(color, null); + } + + @Internal + protected XDDFColorRgbBinary(CTSRgbColor color, CTColor container) { + super(container); + this.color = color; + } + + @Override + @Internal + protected XmlObject getXmlObject() { + return color; + } + + public byte[] getValue() { + return color.getVal(); + } + + public void setValue(byte[] value) { + color.setVal(value); + } + + public String toRGBHex() { + StringBuilder sb = new StringBuilder(6); + for (byte b: color.getVal()) { + sb.append(String.format(Locale.ROOT, "%02X", b)); + } + return sb.toString().toUpperCase(Locale.ROOT); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbPercent.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbPercent.java new file mode 100644 index 0000000000..a7eefebfc1 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorRgbPercent.java @@ -0,0 +1,102 @@ +/* ==================================================================== + 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; + +import java.util.Locale; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor; + +@Beta +public class XDDFColorRgbPercent extends XDDFColor { + private CTScRgbColor color; + + public XDDFColorRgbPercent(int red, int green, int blue) { + this(CTScRgbColor.Factory.newInstance(), CTColor.Factory.newInstance()); + setRed(red); + setGreen(green); + setBlue(blue); + } + + @Internal + protected XDDFColorRgbPercent(CTScRgbColor color) { + this(color, null); + } + + @Internal + protected XDDFColorRgbPercent(CTScRgbColor color, CTColor container) { + super(container); + this.color = color; + } + + @Override + @Internal + protected XmlObject getXmlObject() { + return color; + } + + public int getRed() { + return color.getR(); + } + + public void setRed(int red) { + color.setR(normalize(red)); + } + + public int getGreen() { + return color.getG(); + } + + public void setGreen(int green) { + color.setG(normalize(green)); + } + + public int getBlue() { + return color.getB(); + } + + public void setBlue(int blue) { + color.setB(normalize(blue)); + } + + private int normalize(int value) { + if (value < 0) { + return 0; + } + if (100_000 < value) { + return 100_000; + } + return value; + } + + public String toRGBHex() { + StringBuilder sb = new StringBuilder(6); + appendHex(sb, color.getR()); + appendHex(sb, color.getG()); + appendHex(sb, color.getB()); + return sb.toString().toUpperCase(Locale.ROOT); + } + + private void appendHex(StringBuilder sb, int value) { + int b = value * 255 / 100_000; + sb.append(String.format(Locale.ROOT, "%02X", b)); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSchemeBased.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSchemeBased.java new file mode 100644 index 0000000000..46c379c445 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSchemeBased.java @@ -0,0 +1,59 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor; + +@Beta +public class XDDFColorSchemeBased extends XDDFColor { + private CTSchemeColor color; + + public XDDFColorSchemeBased(SchemeColor color) { + this(CTSchemeColor.Factory.newInstance(), CTColor.Factory.newInstance()); + setValue(color); + } + + @Internal + protected XDDFColorSchemeBased(CTSchemeColor color) { + this(color, null); + } + + @Internal + protected XDDFColorSchemeBased(CTSchemeColor color, CTColor container) { + super(container); + this.color = color; + } + + @Override + @Internal + protected XmlObject getXmlObject() { + return color; + } + + public SchemeColor getValue() { + return SchemeColor.valueOf(color.getVal()); + } + + public void setValue(SchemeColor scheme) { + color.setVal(scheme.underlying); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSystemDefined.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSystemDefined.java new file mode 100644 index 0000000000..202e7db076 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFColorSystemDefined.java @@ -0,0 +1,77 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.apache.xmlbeans.XmlObject; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor; + +@Beta +public class XDDFColorSystemDefined extends XDDFColor { + private CTSystemColor color; + + public XDDFColorSystemDefined(SystemColor color) { + this(CTSystemColor.Factory.newInstance(), CTColor.Factory.newInstance()); + setValue(color); + } + + @Internal + protected XDDFColorSystemDefined(CTSystemColor color) { + this(color, null); + } + + @Internal + protected XDDFColorSystemDefined(CTSystemColor color, CTColor container) { + super(container); + this.color = color; + } + + @Override + @Internal + protected XmlObject getXmlObject() { + return color; + } + + public SystemColor getValue() { + return SystemColor.valueOf(color.getVal()); + } + + public void setValue(SystemColor value) { + color.setVal(value.underlying); + } + + public byte[] getLastColor() { + if (color.isSetLastClr()) { + return color.getLastClr(); + } else { + return null; + } + } + + public void setLastColor(byte[] last) { + if (last == null) { + if (color.isSetLastClr()) { + color.unsetLastClr(); + } + } else { + color.setLastClr(last); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFConnectionSite.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFConnectionSite.java new file mode 100644 index 0000000000..0f7a4a29fd --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFConnectionSite.java @@ -0,0 +1,39 @@ +/* + * ==================================================================== + * 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTConnectionSite; + +@Beta +public class XDDFConnectionSite { + private CTConnectionSite site; + + @Internal + protected XDDFConnectionSite(CTConnectionSite site) { + this.site = site; + } + + @Internal + public CTConnectionSite getXmlObject() { + return site; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.java new file mode 100644 index 0000000000..8da645b5fc --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.java @@ -0,0 +1,288 @@ +/* ==================================================================== + 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; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D; + +@Beta +public class XDDFCustomGeometry2D { + private CTCustomGeometry2D geometry; + + protected XDDFCustomGeometry2D(CTCustomGeometry2D geometry) { + this.geometry = geometry; + } + + @Internal + protected CTCustomGeometry2D getXmlObject() { + return geometry; + } + + public XDDFGeometryRectangle getRectangle() { + if (geometry.isSetRect()) { + return new XDDFGeometryRectangle(geometry.getRect()); + } else { + return null; + } + } + + public void setRectangle(XDDFGeometryRectangle rectangle) { + if (rectangle == null) { + if (geometry.isSetRect()) { + geometry.unsetRect(); + } + } else { + geometry.setRect(rectangle.getXmlObject()); + } + } + + public XDDFAdjustHandlePolar addPolarAdjustHandle() { + if (!geometry.isSetAhLst()) { + geometry.addNewAhLst(); + } + return new XDDFAdjustHandlePolar(geometry.getAhLst().addNewAhPolar()); + } + + public XDDFAdjustHandlePolar insertPolarAdjustHandle(int index) { + if (!geometry.isSetAhLst()) { + geometry.addNewAhLst(); + } + return new XDDFAdjustHandlePolar(geometry.getAhLst().insertNewAhPolar(index)); + } + + public void removePolarAdjustHandle(int index) { + if (geometry.isSetAhLst()) { + geometry.getAhLst().removeAhPolar(index); + } + } + + public XDDFAdjustHandlePolar getPolarAdjustHandle(int index) { + if (geometry.isSetAhLst()) { + return new XDDFAdjustHandlePolar(geometry.getAhLst().getAhPolarArray(index)); + } else { + return null; + } + } + + public List getPolarAdjustHandles() { + if (geometry.isSetAhLst()) { + return Collections.unmodifiableList(geometry + .getAhLst() + .getAhPolarList() + .stream() + .map(guide -> new XDDFAdjustHandlePolar(guide)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public XDDFAdjustHandleXY addXYAdjustHandle() { + if (!geometry.isSetAhLst()) { + geometry.addNewAhLst(); + } + return new XDDFAdjustHandleXY(geometry.getAhLst().addNewAhXY()); + } + + public XDDFAdjustHandleXY insertXYAdjustHandle(int index) { + if (!geometry.isSetAhLst()) { + geometry.addNewAhLst(); + } + return new XDDFAdjustHandleXY(geometry.getAhLst().insertNewAhXY(index)); + } + + public void removeXYAdjustHandle(int index) { + if (geometry.isSetAhLst()) { + geometry.getAhLst().removeAhXY(index); + } + } + + public XDDFAdjustHandleXY getXYAdjustHandle(int index) { + if (geometry.isSetAhLst()) { + return new XDDFAdjustHandleXY(geometry.getAhLst().getAhXYArray(index)); + } else { + return null; + } + } + + public List getXYAdjustHandles() { + if (geometry.isSetAhLst()) { + return Collections.unmodifiableList(geometry + .getAhLst() + .getAhXYList() + .stream() + .map(guide -> new XDDFAdjustHandleXY(guide)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public XDDFGeometryGuide addAdjustValue() { + if (!geometry.isSetAvLst()) { + geometry.addNewAvLst(); + } + return new XDDFGeometryGuide(geometry.getAvLst().addNewGd()); + } + + public XDDFGeometryGuide insertAdjustValue(int index) { + if (!geometry.isSetAvLst()) { + geometry.addNewAvLst(); + } + return new XDDFGeometryGuide(geometry.getAvLst().insertNewGd(index)); + } + + public void removeAdjustValue(int index) { + if (geometry.isSetAvLst()) { + geometry.getAvLst().removeGd(index); + } + } + + public XDDFGeometryGuide getAdjustValue(int index) { + if (geometry.isSetAvLst()) { + return new XDDFGeometryGuide(geometry.getAvLst().getGdArray(index)); + } else { + return null; + } + } + + public List getAdjustValues() { + if (geometry.isSetAvLst()) { + return Collections.unmodifiableList(geometry + .getAvLst() + .getGdList() + .stream() + .map(guide -> new XDDFGeometryGuide(guide)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public XDDFConnectionSite addConnectionSite() { + if (!geometry.isSetCxnLst()) { + geometry.addNewCxnLst(); + } + return new XDDFConnectionSite(geometry.getCxnLst().addNewCxn()); + } + + public XDDFConnectionSite insertConnectionSite(int index) { + if (!geometry.isSetCxnLst()) { + geometry.addNewCxnLst(); + } + return new XDDFConnectionSite(geometry.getCxnLst().insertNewCxn(index)); + } + + public void removeConnectionSite(int index) { + if (geometry.isSetCxnLst()) { + geometry.getCxnLst().removeCxn(index); + } + } + + public XDDFConnectionSite getConnectionSite(int index) { + if (geometry.isSetCxnLst()) { + return new XDDFConnectionSite(geometry.getCxnLst().getCxnArray(index)); + } else { + return null; + } + } + + public List getConnectionSites() { + if (geometry.isSetCxnLst()) { + return Collections.unmodifiableList(geometry + .getCxnLst() + .getCxnList() + .stream() + .map(guide -> new XDDFConnectionSite(guide)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public XDDFGeometryGuide addGuide() { + if (!geometry.isSetGdLst()) { + geometry.addNewGdLst(); + } + return new XDDFGeometryGuide(geometry.getGdLst().addNewGd()); + } + + public XDDFGeometryGuide insertGuide(int index) { + if (!geometry.isSetGdLst()) { + geometry.addNewGdLst(); + } + return new XDDFGeometryGuide(geometry.getGdLst().insertNewGd(index)); + } + + public void removeGuide(int index) { + if (geometry.isSetGdLst()) { + geometry.getGdLst().removeGd(index); + } + } + + public XDDFGeometryGuide getGuide(int index) { + if (geometry.isSetGdLst()) { + return new XDDFGeometryGuide(geometry.getGdLst().getGdArray(index)); + } else { + return null; + } + } + + public List getGuides() { + if (geometry.isSetGdLst()) { + return Collections.unmodifiableList(geometry + .getGdLst() + .getGdList() + .stream() + .map(guide -> new XDDFGeometryGuide(guide)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public XDDFPath addNewPath() { + return new XDDFPath(geometry.getPathLst().addNewPath()); + } + + public XDDFPath insertNewPath(int index) { + return new XDDFPath(geometry.getPathLst().insertNewPath(index)); + } + + public void removePath(int index) { + geometry.getPathLst().removePath(index); + } + + public XDDFPath getPath(int index) { + return new XDDFPath(geometry.getPathLst().getPathArray(index)); + } + + public List getPaths() { + return Collections.unmodifiableList(geometry + .getPathLst() + .getPathList() + .stream() + .map(ds -> new XDDFPath(ds)) + .collect(Collectors.toList())); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFDashStop.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFDashStop.java new file mode 100644 index 0000000000..7735665eaf --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFDashStop.java @@ -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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTDashStop; + +@Beta +public class XDDFDashStop { + private CTDashStop stop; + + @Internal + protected XDDFDashStop(CTDashStop stop) { + this.stop = stop; + } + + @Internal + protected CTDashStop getXmlObject() { + return stop; + } + + public int getDashLength() { + return stop.getD(); + } + + public void setDashLength(int length) { + stop.setD(length); + } + + public int getSpaceLength() { + return stop.getSp(); + } + + public void setSpaceLength(int length) { + stop.setSp(length); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectContainer.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectContainer.java new file mode 100644 index 0000000000..16fb0415f5 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectContainer.java @@ -0,0 +1,37 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectContainer; + +@Beta +public class XDDFEffectContainer { + private CTEffectContainer container; + + @Internal + protected XDDFEffectContainer(CTEffectContainer container) { + this.container = container; + } + + @Internal + public CTEffectContainer getXmlObject() { + return container; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectList.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectList.java new file mode 100644 index 0000000000..46e72002d0 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFEffectList.java @@ -0,0 +1,37 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectList; + +@Beta +public class XDDFEffectList { + private CTEffectList list; + + @Internal + protected XDDFEffectList(CTEffectList list) { + this.list = list; + } + + @Internal + public CTEffectList getXmlObject() { + return list; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFExtensionList.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFExtensionList.java new file mode 100644 index 0000000000..973dab6e20 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFExtensionList.java @@ -0,0 +1,37 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList; + +@Beta +public class XDDFExtensionList { + private CTOfficeArtExtensionList list; + + @Internal + protected XDDFExtensionList(CTOfficeArtExtensionList list) { + this.list = list; + } + + @Internal + public CTOfficeArtExtensionList getXmlObject() { + return list; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFFillProperties.java new file mode 100644 index 0000000000..f880e276fc --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFFillProperties.java @@ -0,0 +1,24 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; + +@Beta +public interface XDDFFillProperties { +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryGuide.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryGuide.java new file mode 100644 index 0000000000..04cc94c8f7 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryGuide.java @@ -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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuide; + +@Beta +public class XDDFGeometryGuide { + private CTGeomGuide guide; + + @Internal + protected XDDFGeometryGuide(CTGeomGuide guide) { + this.guide = guide; + } + + @Internal + protected CTGeomGuide getXmlObject() { + return guide; + } + + public String getFormula() { + return guide.getFmla(); + } + + public void setFormula(String formula) { + guide.setFmla(formula); + } + + public String getName() { + return guide.getName(); + } + + public void setName(String name) { + guide.setName(name); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryRectangle.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryRectangle.java new file mode 100644 index 0000000000..e696314c67 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGeometryRectangle.java @@ -0,0 +1,39 @@ +/* + * ==================================================================== + * 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomRect; + +@Beta +public class XDDFGeometryRectangle { + private CTGeomRect rectangle; + + @Internal + protected XDDFGeometryRectangle(CTGeomRect rectangle) { + this.rectangle = rectangle; + } + + @Internal + public CTGeomRect getXmlObject() { + return rectangle; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientFillProperties.java new file mode 100644 index 0000000000..fd97f3d373 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientFillProperties.java @@ -0,0 +1,182 @@ +/* ==================================================================== + 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; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties; + +@Beta +public class XDDFGradientFillProperties implements XDDFFillProperties { + private CTGradientFillProperties props; + + public XDDFGradientFillProperties() { + this(CTGradientFillProperties.Factory.newInstance()); + } + + protected XDDFGradientFillProperties(CTGradientFillProperties properties) { + this.props = properties; + } + + @Internal + protected CTGradientFillProperties getXmlObject() { + return props; + } + + public Boolean isRotatingWithShape() { + if (props.isSetRotWithShape()) { + return props.getRotWithShape(); + } else { + return null; + } + } + + public void setRotatingWithShape(Boolean rotating) { + if (rotating == null) { + if (props.isSetRotWithShape()) { + props.unsetRotWithShape(); + } + } else { + props.setRotWithShape(rotating); + } + } + + public TileFlipMode getTileFlipMode() { + if (props.isSetFlip()) { + return TileFlipMode.valueOf(props.getFlip()); + } else { + return null; + } + } + + public void setTileFlipMode(TileFlipMode mode) { + if (mode == null) { + if (props.isSetFlip()) { + props.unsetFlip(); + } + } else { + props.setFlip(mode.underlying); + } + } + + public XDDFGradientStop addGradientStop() { + if (!props.isSetGsLst()) { + props.addNewGsLst(); + } + return new XDDFGradientStop(props.getGsLst().addNewGs()); + } + + public XDDFGradientStop insertGradientStop(int index) { + if (!props.isSetGsLst()) { + props.addNewGsLst(); + } + return new XDDFGradientStop(props.getGsLst().insertNewGs(index)); + } + + public void removeGradientStop(int index) { + if (props.isSetGsLst()) { + props.getGsLst().removeGs(index); + } + } + + public XDDFGradientStop getGradientStop(int index) { + if (props.isSetGsLst()) { + return new XDDFGradientStop(props.getGsLst().getGsArray(index)); + } else { + return null; + } + } + + public List getGradientStops() { + if (props.isSetGsLst()) { + return Collections.unmodifiableList(props + .getGsLst() + .getGsList() + .stream() + .map(gs -> new XDDFGradientStop(gs)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public int countGradientStops() { + if (props.isSetGsLst()) { + return props.getGsLst().sizeOfGsArray(); + } else { + return 0; + } + } + + public XDDFLinearShadeProperties getLinearShadeProperties() { + if (props.isSetLin()) { + return new XDDFLinearShadeProperties(props.getLin()); + } else { + return null; + } + } + + public void setLinearShadeProperties(XDDFLinearShadeProperties properties) { + if (properties == null) { + if (props.isSetLin()) { + props.unsetLin(); + } + } else { + props.setLin(properties.getXmlObject()); + } + } + + public XDDFPathShadeProperties getPathShadeProperties() { + if (props.isSetPath()) { + return new XDDFPathShadeProperties(props.getPath()); + } else { + return null; + } + } + + public void setPathShadeProperties(XDDFPathShadeProperties properties) { + if (properties == null) { + if (props.isSetPath()) { + props.unsetPath(); + } + } else { + props.setPath(properties.getXmlObject()); + } + } + + public XDDFRelativeRectangle getTileRectangle() { + if (props.isSetTileRect()) { + return new XDDFRelativeRectangle(props.getTileRect()); + } else { + return null; + } + } + public void setTileRectangle(XDDFRelativeRectangle rectangle) { + if (rectangle == null) { + if (props.isSetTileRect()) { + props.unsetTileRect(); + } + } else { + props.setTileRect(rectangle.getXmlObject()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientStop.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientStop.java new file mode 100644 index 0000000000..7d647dc043 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGradientStop.java @@ -0,0 +1,105 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGradientStop; +import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor; + +@Beta +public class XDDFGradientStop { + private CTGradientStop stop; + + @Internal + protected XDDFGradientStop(CTGradientStop stop) { + this.stop = stop; + } + + @Internal + protected CTGradientStop getXmlObject() { + return stop; + } + + public int getPosition() { + return stop.getPos(); + } + + public void setPosition(int position) { + stop.setPos(position); + } + + public XDDFColor getColor() { + if (stop.isSetHslClr()) { + return new XDDFColorHsl(stop.getHslClr()); + } else if (stop.isSetPrstClr()) { + return new XDDFColorPreset(stop.getPrstClr()); + } else if (stop.isSetSchemeClr()) { + return new XDDFColorSchemeBased(stop.getSchemeClr()); + } else if (stop.isSetScrgbClr()) { + return new XDDFColorRgbPercent(stop.getScrgbClr()); + } else if (stop.isSetSrgbClr()) { + return new XDDFColorRgbBinary(stop.getSrgbClr()); + } else if (stop.isSetSysClr()) { + return new XDDFColorSystemDefined(stop.getSysClr()); + } + return null; + } + + public void setColor(XDDFColor color) { + if (stop.isSetHslClr()) { + stop.unsetHslClr(); + } + if (stop.isSetPrstClr()) { + stop.unsetPrstClr(); + } + if (stop.isSetSchemeClr()) { + stop.unsetSchemeClr(); + } + if (stop.isSetScrgbClr()) { + stop.unsetScrgbClr(); + } + if (stop.isSetSrgbClr()) { + stop.unsetSrgbClr(); + } + if (stop.isSetSysClr()) { + stop.unsetSysClr(); + } + if (color == null) { + return; + } + if (color instanceof XDDFColorHsl) { + stop.setHslClr((CTHslColor) color.getXmlObject()); + } else if (color instanceof XDDFColorPreset) { + stop.setPrstClr((CTPresetColor) color.getXmlObject()); + } else if (color instanceof XDDFColorSchemeBased) { + stop.setSchemeClr((CTSchemeColor) color.getXmlObject()); + } else if (color instanceof XDDFColorRgbPercent) { + stop.setScrgbClr((CTScRgbColor) color.getXmlObject()); + } else if (color instanceof XDDFColorRgbBinary) { + stop.setSrgbClr((CTSRgbColor) color.getXmlObject()); + } else if (color instanceof XDDFColorSystemDefined) { + stop.setSysClr((CTSystemColor) color.getXmlObject()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGroupFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGroupFillProperties.java new file mode 100644 index 0000000000..0a1f558057 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFGroupFillProperties.java @@ -0,0 +1,40 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupFillProperties; + +@Beta +public class XDDFGroupFillProperties implements XDDFFillProperties { + private CTGroupFillProperties props; + + public XDDFGroupFillProperties() { + this(CTGroupFillProperties.Factory.newInstance()); + } + + protected XDDFGroupFillProperties(CTGroupFillProperties properties) { + this.props = properties; + } + + @Internal + protected CTGroupFillProperties getXmlObject() { + return props; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineEndProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineEndProperties.java new file mode 100644 index 0000000000..deedaf4929 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineEndProperties.java @@ -0,0 +1,60 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties; + +@Beta +public class XDDFLineEndProperties { + private CTLineEndProperties props; + + protected XDDFLineEndProperties(CTLineEndProperties properties) { + this.props = properties; + } + + @Internal + protected CTLineEndProperties getXmlObject() { + return props; + } + + public LineEndLength getLength() { + return LineEndLength.valueOf(props.getLen()); + } + + public void setLength(LineEndLength length) { + props.setLen(length.underlying); + } + + public LineEndType getType() { + return LineEndType.valueOf(props.getType()); + } + + public void setType(LineEndType type) { + props.setType(type.underlying); + } + + public LineEndWidth getWidth() { + return LineEndWidth.valueOf(props.getW()); + } + + public void setWidth(LineEndWidth width) { + props.setW(width.underlying); + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinBevelProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinBevelProperties.java new file mode 100644 index 0000000000..a6c9a9e097 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinBevelProperties.java @@ -0,0 +1,39 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTLineJoinBevel; + +@Beta +public class XDDFLineJoinBevelProperties implements XDDFLineJoinProperties { + private CTLineJoinBevel join; + + public XDDFLineJoinBevelProperties() { + this(CTLineJoinBevel.Factory.newInstance()); + } + protected XDDFLineJoinBevelProperties(CTLineJoinBevel join) { + this.join = join; + } + + @Internal + protected CTLineJoinBevel getXmlObject() { + return join; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinMiterProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinMiterProperties.java new file mode 100644 index 0000000000..3abddeaa75 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinMiterProperties.java @@ -0,0 +1,58 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTLineJoinMiterProperties; + +@Beta +public class XDDFLineJoinMiterProperties implements XDDFLineJoinProperties { + private CTLineJoinMiterProperties join; + + public XDDFLineJoinMiterProperties() { + this(CTLineJoinMiterProperties.Factory.newInstance()); + } + + protected XDDFLineJoinMiterProperties(CTLineJoinMiterProperties join) { + this.join = join; + } + + @Internal + protected CTLineJoinMiterProperties getXmlObject() { + return join; + } + + public Integer getLimit() { + if (join.isSetLim()) { + return join.getLim(); + } else { + return null; + } + } + + public void setLimit(Integer limit) { + if (limit == null) { + if (join.isSetLim()) { + join.unsetLim(); + } + } else { + join.setLim(limit); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinProperties.java new file mode 100644 index 0000000000..e1b53ca21f --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinProperties.java @@ -0,0 +1,24 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; + +@Beta +public interface XDDFLineJoinProperties { +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinRoundProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinRoundProperties.java new file mode 100644 index 0000000000..6de28cf361 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineJoinRoundProperties.java @@ -0,0 +1,40 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTLineJoinRound; + +@Beta +public class XDDFLineJoinRoundProperties implements XDDFLineJoinProperties { + private CTLineJoinRound join; + + public XDDFLineJoinRoundProperties() { + this(CTLineJoinRound.Factory.newInstance()); + } + + protected XDDFLineJoinRoundProperties(CTLineJoinRound join) { + this.join = join; + } + + @Internal + protected CTLineJoinRound getXmlObject() { + return join; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineProperties.java new file mode 100644 index 0000000000..794a751cbc --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLineProperties.java @@ -0,0 +1,313 @@ +/* ==================================================================== + 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; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties; + +@Beta +public class XDDFLineProperties { + private CTLineProperties props; + + public XDDFLineProperties() { + this(CTLineProperties.Factory.newInstance()); + } + + @Internal + protected XDDFLineProperties(CTLineProperties properties) { + this.props = properties; + } + + @Internal + protected CTLineProperties getXmlObject() { + return props; + } + + public PenAlignment getPenAlignment() { + if (props.isSetAlgn()) { + return PenAlignment.valueOf(props.getAlgn()); + } else { + return null; + } + } + + public void setPenAlignment(PenAlignment alignment) { + if (alignment == null) { + if (props.isSetAlgn()) { + props.unsetAlgn(); + } + } else { + props.setAlgn(alignment.underlying); + } + } + + public LineCap getLineCap() { + if (props.isSetCap()) { + return LineCap.valueOf(props.getCap()); + } else { + return null; + } + } + + public void setLineCap(LineCap cap) { + if (cap == null) { + if (props.isSetCap()) { + props.unsetCap(); + } + } else { + props.setCap(cap.underlying); + } + } + + public CompoundLine getCompoundLine() { + if (props.isSetCmpd()) { + return CompoundLine.valueOf(props.getCmpd()); + } else { + return null; + } + } + + public void setCompoundLine(CompoundLine compound) { + if (compound == null) { + if (props.isSetCmpd()) { + props.unsetCmpd(); + } + } else { + props.setCmpd(compound.underlying); + } + } + + public XDDFDashStop addDashStop() { + if (!props.isSetCustDash()) { + props.addNewCustDash(); + } + return new XDDFDashStop(props.getCustDash().addNewDs()); + } + + public XDDFDashStop insertDashStop(int index) { + if (!props.isSetCustDash()) { + props.addNewCustDash(); + } + return new XDDFDashStop(props.getCustDash().insertNewDs(index)); + } + + public void removeDashStop(int index) { + if (props.isSetCustDash()) { + props.getCustDash().removeDs(index); + } + } + + public XDDFDashStop getDashStop(int index) { + if (props.isSetCustDash()) { + return new XDDFDashStop(props.getCustDash().getDsArray(index)); + } else { + return null; + } + } + + public List getDashStops() { + if (props.isSetCustDash()) { + return Collections.unmodifiableList(props + .getCustDash() + .getDsList() + .stream() + .map(ds -> new XDDFDashStop(ds)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public int countDashStops() { + if (props.isSetCustDash()) { + return props.getCustDash().sizeOfDsArray(); + } else { + return 0; + } + } + + public XDDFPresetLineDash getPresetDash() { + if (props.isSetPrstDash()) { + return new XDDFPresetLineDash(props.getPrstDash()); + } else { + return null; + } + } + + public void setPresetDash(XDDFPresetLineDash properties) { + if (properties == null) { + if (props.isSetPrstDash()) { + props.unsetPrstDash(); + } + } else { + props.setPrstDash(properties.getXmlObject()); + } + } + + public XDDFExtensionList getExtensionList() { + if (props.isSetExtLst()) { + return new XDDFExtensionList(props.getExtLst()); + } else { + return null; + } + } + + public void setExtensionList(XDDFExtensionList list) { + if (list == null) { + if (props.isSetExtLst()) { + props.unsetExtLst(); + } + } else { + props.setExtLst(list.getXmlObject()); + } + } + + public XDDFFillProperties getFillProperties() { + if (props.isSetGradFill()) { + return new XDDFGradientFillProperties(props.getGradFill()); + } else if (props.isSetNoFill()) { + return new XDDFNoFillProperties(props.getNoFill()); + } else if (props.isSetPattFill()) { + return new XDDFPatternFillProperties(props.getPattFill()); + } else if (props.isSetSolidFill()) { + return new XDDFSolidFillProperties(props.getSolidFill()); + } else { + return null; + } + } + + public void setFillProperties(XDDFFillProperties properties) { + if (props.isSetGradFill()) { + props.unsetGradFill(); + } + if (props.isSetNoFill()) { + props.unsetNoFill(); + } + if (props.isSetPattFill()) { + props.unsetPattFill(); + } + if (props.isSetSolidFill()) { + props.unsetSolidFill(); + } + if (properties == null) { + return; + } + if (properties instanceof XDDFGradientFillProperties) { + props.setGradFill(((XDDFGradientFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFNoFillProperties) { + props.setNoFill(((XDDFNoFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFPatternFillProperties) { + props.setPattFill(((XDDFPatternFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFSolidFillProperties) { + props.setSolidFill(((XDDFSolidFillProperties) properties).getXmlObject()); + } + } + + public XDDFLineJoinProperties getLineJoinProperties() { + if (props.isSetBevel()) { + return new XDDFLineJoinBevelProperties(props.getBevel()); + } else if (props.isSetMiter()) { + return new XDDFLineJoinMiterProperties(props.getMiter()); + } else if (props.isSetRound()) { + return new XDDFLineJoinRoundProperties(props.getRound()); + } else { + return null; + } + } + + public void setLineJoinProperties(XDDFLineJoinProperties properties) { + if (props.isSetBevel()) { + props.unsetBevel(); + } + if (props.isSetMiter()) { + props.unsetMiter(); + } + if (props.isSetRound()) { + props.unsetRound(); + } + if (properties == null) { + return; + } + if (properties instanceof XDDFLineJoinBevelProperties) { + props.setBevel(((XDDFLineJoinBevelProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFLineJoinMiterProperties) { + props.setMiter(((XDDFLineJoinMiterProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFLineJoinRoundProperties) { + props.setRound(((XDDFLineJoinRoundProperties) properties).getXmlObject()); + } + } + + public XDDFLineEndProperties getHeadEnd() { + if (props.isSetHeadEnd()) { + return new XDDFLineEndProperties(props.getHeadEnd()); + } else { + return null; + } + } + + public void setHeadEnd(XDDFLineEndProperties properties) { + if (properties == null) { + if (props.isSetHeadEnd()) { + props.unsetHeadEnd(); + } + } else { + props.setHeadEnd(properties.getXmlObject()); + } + } + + public XDDFLineEndProperties getTailEnd() { + if (props.isSetTailEnd()) { + return new XDDFLineEndProperties(props.getTailEnd()); + } else { + return null; + } + } + + public void setTailEnd(XDDFLineEndProperties properties) { + if (properties == null) { + if (props.isSetTailEnd()) { + props.unsetTailEnd(); + } + } else { + props.setTailEnd(properties.getXmlObject()); + } + } + + public Integer getWidth() { + if (props.isSetW()) { + return props.getW(); + } else { + return null; + } + } + + public void setWidth(Integer width) { + if (width == null) { + if (props.isSetW()) { + props.unsetW(); + } + } else { + props.setW(width); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLinearShadeProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLinearShadeProperties.java new file mode 100644 index 0000000000..c3d4566dc3 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFLinearShadeProperties.java @@ -0,0 +1,72 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTLinearShadeProperties; + +@Beta +public class XDDFLinearShadeProperties { + private CTLinearShadeProperties props; + + protected XDDFLinearShadeProperties(CTLinearShadeProperties properties) { + this.props = properties; + } + + @Internal + protected CTLinearShadeProperties getXmlObject() { + return props; + } + + public Integer getAngle() { + if (props.isSetAng()) { + return props.getAng(); + } else { + return null; + } + } + + public void setAngle(Integer angle) { + if (angle == null) { + if (props.isSetAng()) { + props.unsetAng(); + } + } else { + props.setAng(angle); + } + } + + public Boolean getScaled() { + if (props.isSetScaled()) { + return props.getScaled(); + } else { + return null; + } + } + + public void setScaled(Boolean scaled) { + if (scaled == null) { + if (props.isSetScaled()) { + props.unsetScaled(); + } + } else { + props.setScaled(scaled); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFNoFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFNoFillProperties.java new file mode 100644 index 0000000000..ae15aa8c9a --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFNoFillProperties.java @@ -0,0 +1,40 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTNoFillProperties; + +@Beta +public class XDDFNoFillProperties implements XDDFFillProperties { + private CTNoFillProperties props; + + public XDDFNoFillProperties() { + this(CTNoFillProperties.Factory.newInstance()); + } + + protected XDDFNoFillProperties(CTNoFillProperties properties) { + this.props = properties; + } + + @Internal + protected CTNoFillProperties getXmlObject() { + return props; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPath.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPath.java new file mode 100644 index 0000000000..67c760e87a --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPath.java @@ -0,0 +1,39 @@ +/* + * ==================================================================== + * 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPath2D; + +@Beta +public class XDDFPath { + private CTPath2D path; + + @Internal + protected XDDFPath(CTPath2D path) { + this.path = path; + } + + @Internal + public CTPath2D getXmlObject() { + return path; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPathShadeProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPathShadeProperties.java new file mode 100644 index 0000000000..8d5892fda6 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPathShadeProperties.java @@ -0,0 +1,76 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPathShadeProperties; + +@Beta +public class XDDFPathShadeProperties { + private CTPathShadeProperties props; + + public XDDFPathShadeProperties() { + this(CTPathShadeProperties.Factory.newInstance()); + } + + protected XDDFPathShadeProperties(CTPathShadeProperties properties) { + this.props = properties; + } + + @Internal + protected CTPathShadeProperties getXmlObject() { + return props; + } + + public XDDFRelativeRectangle getFillToRectangle() { + if (props.isSetFillToRect()) { + return new XDDFRelativeRectangle(props.getFillToRect()); + } else { + return null; + } + } + + public void setFillToRectangle(XDDFRelativeRectangle rectangle) { + if (rectangle == null) { + if (props.isSetFillToRect()) { + props.unsetFillToRect(); + } + } else { + props.setFillToRect(rectangle.getXmlObject()); + } + } + + public PathShadeType getPathShadeType() { + if (props.isSetPath()) { + return PathShadeType.valueOf(props.getPath()); + } else { + return null; + } + } + + public void setPathShadeType(PathShadeType path) { + if (path == null) { + if (props.isSetPath()) { + props.unsetPath(); + } + } else { + props.setPath(path.underlying); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPatternFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPatternFillProperties.java new file mode 100644 index 0000000000..b0daca96b8 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPatternFillProperties.java @@ -0,0 +1,94 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPatternFillProperties; + +@Beta +public class XDDFPatternFillProperties implements XDDFFillProperties { + private CTPatternFillProperties props; + + public XDDFPatternFillProperties() { + this(CTPatternFillProperties.Factory.newInstance()); + } + + protected XDDFPatternFillProperties(CTPatternFillProperties properties) { + this.props = properties; + } + + @Internal + protected CTPatternFillProperties getXmlObject() { + return props; + } + + public PresetPattern getPresetPattern() { + if (props.isSetPrst()) { + return PresetPattern.valueOf(props.getPrst()); + } else { + return null; + } + } + + public void setPresetPattern(PresetPattern pattern) { + if (pattern == null) { + if (props.isSetPrst()) { + props.unsetPrst(); + } + } else { + props.setPrst(pattern.underlying); + } + } + + public XDDFColor getBackgroundColor() { + if (props.isSetBgClr()) { + return XDDFColor.forColorContainer(props.getBgClr()); + } else { + return null; + } + } + + public void setBackgroundColor(XDDFColor color) { + if (color == null) { + if (props.isSetBgClr()) { + props.unsetBgClr(); + } + } else { + props.setBgClr(color.getColorContainer()); + } + } + + public XDDFColor getForegroundColor() { + if (props.isSetFgClr()) { + return XDDFColor.forColorContainer(props.getFgClr()); + } else { + return null; + } + } + + public void setForegroundColor(XDDFColor color) { + if (color == null) { + if (props.isSetFgClr()) { + props.unsetFgClr(); + } + } else { + props.setFgClr(color.getColorContainer()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPictureFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPictureFillProperties.java new file mode 100644 index 0000000000..0064f14c8f --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPictureFillProperties.java @@ -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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip; +import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties; + +@Beta +public class XDDFPictureFillProperties implements XDDFFillProperties { + private CTBlipFillProperties props; + + public XDDFPictureFillProperties() { + this(CTBlipFillProperties.Factory.newInstance()); + } + + protected XDDFPictureFillProperties(CTBlipFillProperties properties) { + this.props = properties; + } + + @Internal + protected CTBlipFillProperties getXmlObject() { + return props; + } + + @Internal + public CTBlip getCTBlip() { + if (props.isSetBlip()) { + return props.getBlip(); + } else { + return null; + } + } + + @Internal + public void setBlip(CTBlip blip) { + if (blip == null) { + if (props.isSetBlip()) { + props.unsetBlip(); + } + } else { + props.setBlip(blip); + } + } + + public Boolean isRotatingWithShape() { + if (props.isSetRotWithShape()) { + return props.getRotWithShape(); + } else { + return null; + } + } + + public void setRotatingWithShape(Boolean rotating) { + if (rotating == null) { + if (props.isSetRotWithShape()) { + props.unsetRotWithShape(); + } + } else { + props.setRotWithShape(rotating); + } + } + + public Long getDpi() { + if (props.isSetDpi()) { + return props.getDpi(); + } else { + return null; + } + } + + public void setDpi(Long dpi) { + if (dpi == null) { + if (props.isSetDpi()) { + props.unsetDpi(); + } + } else { + props.setDpi(dpi); + } + } + + public XDDFRelativeRectangle getSourceRectangle() { + if (props.isSetSrcRect()) { + return new XDDFRelativeRectangle(props.getSrcRect()); + } else { + return null; + } + } + + public void setSourceRectangle(XDDFRelativeRectangle rectangle) { + if (rectangle == null) { + if (props.isSetSrcRect()) { + props.unsetSrcRect(); + } + } else { + props.setSrcRect(rectangle.getXmlObject()); + } + } + + public XDDFStretchInfoProperties getStetchInfoProperties() { + if (props.isSetStretch()) { + return new XDDFStretchInfoProperties(props.getStretch()); + } else { + return null; + } + } + + public void setStretchInfoProperties(XDDFStretchInfoProperties properties) { + if (properties == null) { + if (props.isSetStretch()) { + props.unsetStretch(); + } + } else { + props.setStretch(properties.getXmlObject()); + } + } + + public XDDFTileInfoProperties getTileInfoProperties() { + if (props.isSetTile()) { + return new XDDFTileInfoProperties(props.getTile()); + } else { + return null; + } + } + + public void setTileInfoProperties(XDDFTileInfoProperties properties) { + if (properties == null) { + if (props.isSetTile()) { + props.unsetTile(); + } + } else { + props.setTile(properties.getXmlObject()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPoint2D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPoint2D.java new file mode 100644 index 0000000000..e01aec9064 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPoint2D.java @@ -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; + +import org.apache.poi.util.Beta; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; + +@Beta +public class XDDFPoint2D { + private CTPoint2D point; + private long x; + private long y; + + protected XDDFPoint2D(CTPoint2D point) { + this.point = point; + } + + public XDDFPoint2D(long x, long y) { + this.x = x; + this.y = y; + } + + public long getX() { + if (point == null) { + return x; + } else { + return point.getX(); + } + } + + public long getY() { + if (point == null) { + return y; + } else { + return point.getY(); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPositiveSize2D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPositiveSize2D.java new file mode 100644 index 0000000000..a8989311b9 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPositiveSize2D.java @@ -0,0 +1,56 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; + +@Beta +public class XDDFPositiveSize2D { + private CTPositiveSize2D size; + private long x; + private long y; + + protected XDDFPositiveSize2D(CTPositiveSize2D size) { + this.size = size; + } + + public XDDFPositiveSize2D(long x, long y) { + if (x <0 || y < 0) { + throw new IllegalArgumentException("x and y must be positive"); + } + this.x = x; + this.y = y; + } + + public long getX() { + if (size == null) { + return x; + } else { + return size.getCx(); + } + } + + public long getY() { + if (size == null) { + return y; + } else { + return size.getCy(); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetGeometry2D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetGeometry2D.java new file mode 100644 index 0000000000..f60e314e86 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetGeometry2D.java @@ -0,0 +1,89 @@ +/* ==================================================================== + 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; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D; + +@Beta +public class XDDFPresetGeometry2D { + private CTPresetGeometry2D geometry; + + protected XDDFPresetGeometry2D(CTPresetGeometry2D geometry) { + this.geometry = geometry; + } + + @Internal + protected CTPresetGeometry2D getXmlObject() { + return geometry; + } + + public PresetGeometry getGeometry() { + return PresetGeometry.valueOf(geometry.getPrst()); + } + + public void setGeometry(PresetGeometry preset) { + geometry.setPrst(preset.underlying); + } + + public XDDFGeometryGuide addAdjustValue() { + if (!geometry.isSetAvLst()) { + geometry.addNewAvLst(); + } + return new XDDFGeometryGuide(geometry.getAvLst().addNewGd()); + } + + public XDDFGeometryGuide insertAdjustValue(int index) { + if (!geometry.isSetAvLst()) { + geometry.addNewAvLst(); + } + return new XDDFGeometryGuide(geometry.getAvLst().insertNewGd(index)); + } + + public void removeAdjustValue(int index) { + if (geometry.isSetAvLst()) { + geometry.getAvLst().removeGd(index); + } + } + + public XDDFGeometryGuide getAdjustValue(int index) { + if (geometry.isSetAvLst()) { + return new XDDFGeometryGuide(geometry.getAvLst().getGdArray(index)); + } else { + return null; + } + } + + public List getAdjustValues() { + if (geometry.isSetAvLst()) { + return Collections.unmodifiableList(geometry + .getAvLst() + .getGdList() + .stream() + .map(guide -> new XDDFGeometryGuide(guide)) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetLineDash.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetLineDash.java new file mode 100644 index 0000000000..81a9942de2 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFPresetLineDash.java @@ -0,0 +1,59 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetLineDashProperties; + +@Beta +public class XDDFPresetLineDash { + private CTPresetLineDashProperties props; + + public XDDFPresetLineDash(PresetLineDash dash) { + this(CTPresetLineDashProperties.Factory.newInstance()); + setValue(dash); + } + + protected XDDFPresetLineDash(CTPresetLineDashProperties properties) { + this.props = properties; + } + + @Internal + protected CTPresetLineDashProperties getXmlObject() { + return props; + } + + public PresetLineDash getValue() { + if (props.isSetVal()) { + return PresetLineDash.valueOf(props.getVal()); + } else { + return null; + } + } + + public void setValue(PresetLineDash dash) { + if (dash == null) { + if (props.isSetVal()) { + props.unsetVal(); + } + } else { + props.setVal(dash.underlying); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFRelativeRectangle.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFRelativeRectangle.java new file mode 100644 index 0000000000..582b9623fa --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFRelativeRectangle.java @@ -0,0 +1,112 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTRelativeRect; + +@Beta +public class XDDFRelativeRectangle { + private CTRelativeRect rect; + + public XDDFRelativeRectangle() { + this(CTRelativeRect.Factory.newInstance()); + } + + protected XDDFRelativeRectangle(CTRelativeRect rectangle) { + this.rect = rectangle; + } + + @Internal + protected CTRelativeRect getXmlObject() { + return rect; + } + + public Integer getBottom() { + if (rect.isSetB()) { + return rect.getB(); + } else { + return null; + } + } + + public void setBottom(Integer bottom) { + if (bottom == null) { + if (rect.isSetB()) { + rect.unsetB(); + } + } else { + rect.setB(bottom); + } + } + + public Integer getLeft() { + if (rect.isSetL()) { + return rect.getL(); + } else { + return null; + } + } + + public void setLeft(Integer left) { + if (left == null) { + if (rect.isSetL()) { + rect.unsetL(); + } + } else { + rect.setL(left); + } + } + + public Integer getRight() { + if (rect.isSetR()) { + return rect.getR(); + } else { + return null; + } + } + + public void setRight(Integer right) { + if (right == null) { + if (rect.isSetR()) { + rect.unsetR(); + } + } else { + rect.setR(right); + } + } + + public Integer getTop() { + if (rect.isSetT()) { + return rect.getT(); + } else { + return null; + } + } + + public void setTop(Integer top) { + if (top == null) { + if (rect.isSetT()) { + rect.unsetT(); + } + } else { + rect.setT(top); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFScene3D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFScene3D.java new file mode 100644 index 0000000000..48f61cd643 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFScene3D.java @@ -0,0 +1,36 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTScene3D; + +@Beta +public class XDDFScene3D { + private CTScene3D scene; + + protected XDDFScene3D(CTScene3D scene) { + this.scene = scene; + } + + @Internal + public CTScene3D getXmlObject() { + return scene; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShape3D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShape3D.java new file mode 100644 index 0000000000..eb0e80ce17 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShape3D.java @@ -0,0 +1,36 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTShape3D; + +@Beta +public class XDDFShape3D { + private CTShape3D shape; + + protected XDDFShape3D(CTShape3D shape) { + this.shape = shape; + } + + @Internal + public CTShape3D getXmlObject() { + return shape; + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShapeProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShapeProperties.java new file mode 100644 index 0000000000..9182f26ba8 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFShapeProperties.java @@ -0,0 +1,276 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; + +@Beta +public class XDDFShapeProperties { + private CTShapeProperties props; + + public XDDFShapeProperties() { + this(CTShapeProperties.Factory.newInstance()); + } + + @Internal + public XDDFShapeProperties(CTShapeProperties properties) { + this.props = properties; + } + + @Internal + public CTShapeProperties getXmlObject() { + return props; + } + + public BlackWhiteMode getBlackWhiteMode() { + if (props.isSetBwMode()) { + return BlackWhiteMode.valueOf(props.getBwMode()); + } else { + return null; + } + } + + public void setBlackWhiteMode(BlackWhiteMode mode) { + if (mode == null) { + if (props.isSetBwMode()) { + props.unsetBwMode(); + } + } else { + props.setBwMode(mode.underlying); + } + } + + public XDDFFillProperties getFillProperties() { + if (props.isSetGradFill()) { + return new XDDFGradientFillProperties(props.getGradFill()); + } else if (props.isSetGrpFill()) { + return new XDDFGroupFillProperties(props.getGrpFill()); + } else if (props.isSetNoFill()) { + return new XDDFNoFillProperties(props.getNoFill()); + } else if (props.isSetPattFill()) { + return new XDDFPatternFillProperties(props.getPattFill()); + } else if (props.isSetBlipFill()) { + return new XDDFPictureFillProperties(props.getBlipFill()); + } else if (props.isSetSolidFill()) { + return new XDDFSolidFillProperties(props.getSolidFill()); + } else { + return null; + } + } + + public void setFillProperties(XDDFFillProperties properties) { + if (props.isSetBlipFill()) { + props.unsetBlipFill(); + } + if (props.isSetGradFill()) { + props.unsetGradFill(); + } + if (props.isSetGrpFill()) { + props.unsetGrpFill(); + } + if (props.isSetNoFill()) { + props.unsetNoFill(); + } + if (props.isSetPattFill()) { + props.unsetPattFill(); + } + if (props.isSetSolidFill()) { + props.unsetSolidFill(); + } + if (properties == null) { + return; + } + if (properties instanceof XDDFGradientFillProperties) { + props.setGradFill(((XDDFGradientFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFGroupFillProperties) { + props.setGrpFill(((XDDFGroupFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFNoFillProperties) { + props.setNoFill(((XDDFNoFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFPatternFillProperties) { + props.setPattFill(((XDDFPatternFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFPictureFillProperties) { + props.setBlipFill(((XDDFPictureFillProperties) properties).getXmlObject()); + } else if (properties instanceof XDDFSolidFillProperties) { + props.setSolidFill(((XDDFSolidFillProperties) properties).getXmlObject()); + } + } + + public XDDFLineProperties getLineProperties() { + if (props.isSetLn()) { + return new XDDFLineProperties(props.getLn()); + } else { + return null; + } + } + + public void setLineProperties(XDDFLineProperties properties) { + if (properties == null) { + if (props.isSetLn()) { + props.unsetLn(); + } + } else { + props.setLn(properties.getXmlObject()); + } + } + + public XDDFCustomGeometry2D getCustomGeometry2D() { + if (props.isSetCustGeom()) { + return new XDDFCustomGeometry2D(props.getCustGeom()); + } else { + return null; + } + } + + public void setCustomGeometry2D(XDDFCustomGeometry2D geometry) { + if (geometry == null) { + if (props.isSetCustGeom()) { + props.unsetCustGeom(); + } + } else { + props.setCustGeom(geometry.getXmlObject()); + } + } + + public XDDFPresetGeometry2D getPresetGeometry2D() { + if (props.isSetPrstGeom()) { + return new XDDFPresetGeometry2D(props.getPrstGeom()); + } else { + return null; + } + } + + public void setPresetGeometry2D(XDDFPresetGeometry2D geometry) { + if (geometry == null) { + if (props.isSetPrstGeom()) { + props.unsetPrstGeom(); + } + } else { + props.setPrstGeom(geometry.getXmlObject()); + } + } + + public XDDFEffectContainer getEffectContainer() { + if (props.isSetEffectDag()) { + return new XDDFEffectContainer(props.getEffectDag()); + } else { + return null; + } + } + + public void setEffectContainer(XDDFEffectContainer container) { + if (container == null) { + if (props.isSetEffectDag()) { + props.unsetEffectDag(); + } + } else { + props.setEffectDag(container.getXmlObject()); + } + } + + public XDDFEffectList getEffectList() { + if (props.isSetEffectLst()) { + return new XDDFEffectList(props.getEffectLst()); + } else { + return null; + } + } + + public void setEffectList(XDDFEffectList list) { + if (list == null) { + if (props.isSetEffectLst()) { + props.unsetEffectLst(); + } + } else { + props.setEffectLst(list.getXmlObject()); + } + } + + public XDDFExtensionList getExtensionList() { + if (props.isSetExtLst()) { + return new XDDFExtensionList(props.getExtLst()); + } else { + return null; + } + } + + public void setExtensionList(XDDFExtensionList list) { + if (list == null) { + if (props.isSetExtLst()) { + props.unsetExtLst(); + } + } else { + props.setExtLst(list.getXmlObject()); + } + } + + public XDDFScene3D getScene3D() { + if (props.isSetScene3D()) { + return new XDDFScene3D(props.getScene3D()); + } else { + return null; + } + } + + public void setScene3D(XDDFScene3D scene) { + if (scene == null) { + if (props.isSetScene3D()) { + props.unsetScene3D(); + } + } else { + props.setScene3D(scene.getXmlObject()); + } + } + + public XDDFShape3D getShape3D() { + if (props.isSetSp3D()) { + return new XDDFShape3D(props.getSp3D()); + } else { + return null; + } + } + + public void setShape3D(XDDFShape3D shape) { + if (shape == null) { + if (props.isSetSp3D()) { + props.unsetSp3D(); + } + } else { + props.setSp3D(shape.getXmlObject()); + } + } + + public XDDFTransform2D getTransform2D() { + if (props.isSetXfrm()) { + return new XDDFTransform2D(props.getXfrm()); + } else { + return null; + } + } + + public void setTransform2D(XDDFTransform2D transform) { + if (transform == null) { + if (props.isSetXfrm()) { + props.unsetXfrm(); + } + } else { + props.setXfrm(transform.getXmlObject()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFSolidFillProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFSolidFillProperties.java new file mode 100644 index 0000000000..22b8d19802 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFSolidFillProperties.java @@ -0,0 +1,105 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor; + +@Beta +public class XDDFSolidFillProperties implements XDDFFillProperties { + private CTSolidColorFillProperties props; + + public XDDFSolidFillProperties() { + this(CTSolidColorFillProperties.Factory.newInstance()); + } + + public XDDFSolidFillProperties(XDDFColor color) { + this(CTSolidColorFillProperties.Factory.newInstance()); + setColor(color); + } + + protected XDDFSolidFillProperties(CTSolidColorFillProperties properties) { + this.props = properties; + } + + @Internal + protected CTSolidColorFillProperties getXmlObject() { + return props; + } + + public XDDFColor getColor() { + if (props.isSetHslClr()) { + return new XDDFColorHsl(props.getHslClr()); + } else if (props.isSetPrstClr()) { + return new XDDFColorPreset(props.getPrstClr()); + } else if (props.isSetSchemeClr()) { + return new XDDFColorSchemeBased(props.getSchemeClr()); + } else if (props.isSetScrgbClr()) { + return new XDDFColorRgbPercent(props.getScrgbClr()); + } else if (props.isSetSrgbClr()) { + return new XDDFColorRgbBinary(props.getSrgbClr()); + } else if (props.isSetSysClr()) { + return new XDDFColorSystemDefined(props.getSysClr()); + } + return null; + } + + public void setColor(XDDFColor color) { + if (props.isSetHslClr()) { + props.unsetHslClr(); + } + if (props.isSetPrstClr()) { + props.unsetPrstClr(); + } + if (props.isSetSchemeClr()) { + props.unsetSchemeClr(); + } + if (props.isSetScrgbClr()) { + props.unsetScrgbClr(); + } + if (props.isSetSrgbClr()) { + props.unsetSrgbClr(); + } + if (props.isSetSysClr()) { + props.unsetSysClr(); + } + if (color == null) { + return; + } + if (color instanceof XDDFColorHsl) { + props.setHslClr((CTHslColor) color.getXmlObject()); + } else if (color instanceof XDDFColorPreset) { + props.setPrstClr((CTPresetColor) color.getXmlObject()); + } else if (color instanceof XDDFColorSchemeBased) { + props.setSchemeClr((CTSchemeColor) color.getXmlObject()); + } else if (color instanceof XDDFColorRgbPercent) { + props.setScrgbClr((CTScRgbColor) color.getXmlObject()); + } else if (color instanceof XDDFColorRgbBinary) { + props.setSrgbClr((CTSRgbColor) color.getXmlObject()); + } else if (color instanceof XDDFColorSystemDefined) { + props.setSysClr((CTSystemColor) color.getXmlObject()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFStretchInfoProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFStretchInfoProperties.java new file mode 100644 index 0000000000..0630200942 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFStretchInfoProperties.java @@ -0,0 +1,54 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTStretchInfoProperties; + +@Beta +public class XDDFStretchInfoProperties { + private CTStretchInfoProperties props; + + protected XDDFStretchInfoProperties(CTStretchInfoProperties properties) { + this.props = properties; + } + + @Internal + protected CTStretchInfoProperties getXmlObject() { + return props; + } + + public XDDFRelativeRectangle getFillRectangle() { + if (props.isSetFillRect()) { + return new XDDFRelativeRectangle(props.getFillRect()); + } else { + return null; + } + } + + public void setFillRectangle(XDDFRelativeRectangle rectangle) { + if (rectangle == null) { + if (props.isSetFillRect()) { + props.unsetFillRect(); + } + } else { + props.setFillRect(rectangle.getXmlObject()); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTileInfoProperties.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTileInfoProperties.java new file mode 100644 index 0000000000..63bb9f2b65 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTileInfoProperties.java @@ -0,0 +1,136 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTileInfoProperties; + +@Beta +public class XDDFTileInfoProperties { + private CTTileInfoProperties props; + + protected XDDFTileInfoProperties(CTTileInfoProperties properties) { + this.props = properties; + } + + @Internal + protected CTTileInfoProperties getXmlObject() { + return props; + } + + public void setAlignment(RectangleAlignment alignment) { + if (alignment == null) { + if (props.isSetAlgn()) { + props.unsetAlgn(); + } + } else { + props.setAlgn(alignment.underlying); + } + } + + public TileFlipMode getFlipMode() { + if (props.isSetFlip()) { + return TileFlipMode.valueOf(props.getFlip()); + } else { + return null; + } + } + + public void setFlipMode(TileFlipMode mode) { + if (mode == null) { + if (props.isSetFlip()) { + props.unsetFlip(); + } + } else { + props.setFlip(mode.underlying); + } + } + + public Integer getSx() { + if (props.isSetSx()) { + return props.getSx(); + } else { + return null; + } + } + + public void setSx(Integer value) { + if (value == null) { + if (props.isSetSx()) { + props.unsetSx(); + } + } else { + props.setSx(value); + } + } + + public Integer getSy() { + if (props.isSetSy()) { + return props.getSy(); + } else { + return null; + } + } + + public void setSy(Integer value) { + if (value == null) { + if (props.isSetSy()) { + props.unsetSy(); + } + } else { + props.setSy(value); + } + } + + public Long getTx() { + if (props.isSetTx()) { + return props.getTx(); + } else { + return null; + } + } + + public void setTx(Long value) { + if (value == null) { + if (props.isSetTx()) { + props.unsetTx(); + } + } else { + props.setTx(value); + } + } + + public Long getTy() { + if (props.isSetTy()) { + return props.getTy(); + } else { + return null; + } + } + + public void setTy(Long value) { + if (value == null) { + if (props.isSetTy()) { + props.unsetTy(); + } + } else { + props.setTy(value); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTransform2D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTransform2D.java new file mode 100644 index 0000000000..78785134f1 --- /dev/null +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/XDDFTransform2D.java @@ -0,0 +1,140 @@ +/* ==================================================================== + 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; + +import org.apache.poi.util.Beta; +import org.apache.poi.util.Internal; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D; +import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D; + +@Beta +public class XDDFTransform2D { + private CTTransform2D transform; + + protected XDDFTransform2D(CTTransform2D transform) { + this.transform = transform; + } + + @Internal + protected CTTransform2D getXmlObject() { + return transform; + } + + public Boolean getFlipHorizontal() { + if (transform.isSetFlipH()) { + return transform.getFlipH(); + } else { + return null; + } + } + + public void setFlipHorizontal(Boolean flip) { + if (flip == null) { + if (transform.isSetFlipH()) { + transform.unsetFlipH(); + } + } else { + transform.setFlipH(flip); + } + } + + public Boolean getFlipVertical() { + if (transform.isSetFlipV()) { + return transform.getFlipV(); + } else { + return null; + } + } + + public void setFlipVertical(Boolean flip) { + if (flip == null) { + if (transform.isSetFlipV()) { + transform.unsetFlipV(); + } + } else { + transform.setFlipV(flip); + } + } + + public XDDFPositiveSize2D getExtension() { + if (transform.isSetExt()) { + return new XDDFPositiveSize2D(transform.getExt()); + } else { + return null; + } + } + + public void setExtension(XDDFPositiveSize2D extension) { + CTPositiveSize2D xformExt; + if (extension == null) { + if (transform.isSetExt()) { + transform.unsetExt(); + } + return; + } else if (transform.isSetExt()) { + xformExt = transform.getExt(); + } else { + xformExt = transform.addNewExt(); + } + xformExt.setCx(extension.getX()); + xformExt.setCy(extension.getY()); + } + + public XDDFPoint2D getOffset() { + if (transform.isSetOff()) { + return new XDDFPoint2D(transform.getOff()); + } else { + return null; + } + } + + public void setOffset(XDDFPoint2D offset) { + CTPoint2D xformOff; + if (offset == null) { + if (transform.isSetOff()) { + transform.unsetOff(); + } + return; + } else if (transform.isSetOff()) { + xformOff = transform.getOff(); + } else { + xformOff = transform.addNewOff(); + } + xformOff.setX(offset.getX()); + xformOff.setY(offset.getY()); + } + + public Integer getRotation() { + if (transform.isSetRot()) { + return transform.getRot(); + } else { + return null; + } + } + + public void setRotation(Integer rotation) { + if (rotation == null) { + if (transform.isSetRot()) { + transform.unsetRot(); + } + } else { + transform.setRot(rotation); + } + } +} diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java index e89ec321d0..a696a3b8f4 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java @@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart; import java.util.Map; import org.apache.poi.util.Beta; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer; @@ -133,6 +134,30 @@ public class XDDFBarChartData extends XDDFChartData { } } + @Override + public XDDFShapeProperties getShapeProperties() { + if (series.isSetSpPr()) { + return new XDDFShapeProperties(series.getSpPr()); + } else { + return null; + } + } + + @Override + public void setShapeProperties(XDDFShapeProperties properties) { + if (properties == null) { + if (series.isSetSpPr()) { + series.unsetSpPr(); + } + } else { + if (series.isSetSpPr()) { + series.setSpPr(properties.getXmlObject()); + } else { + series.addNewSpPr().set(properties.getXmlObject()); + } + } + } + @Override protected CTAxDataSource getAxDS() { return series.getCat(); diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java index 2744d8b203..4a673f7d33 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java @@ -18,10 +18,11 @@ package org.apache.poi.xddf.usermodel.chart; import org.apache.poi.util.Beta; -import org.apache.poi.util.Internal; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; 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.CTChartLines; import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; @@ -45,21 +46,37 @@ public class XDDFCategoryAxis extends XDDFChartAxis { } @Override - @Internal - public CTShapeProperties getMajorGridLines() { - if (!ctCatAx.isSetMajorGridlines()) { - ctCatAx.addNewMajorGridlines(); + public XDDFShapeProperties getOrAddMajorGridProperties() { + CTChartLines majorGridlines; + if (ctCatAx.isSetMajorGridlines()) { + majorGridlines = ctCatAx.getMajorGridlines(); + } else { + majorGridlines = ctCatAx.addNewMajorGridlines(); } - if (!ctCatAx.getMajorGridlines().isSetSpPr()) { - ctCatAx.getMajorGridlines().addNewSpPr(); + return new XDDFShapeProperties(getOrAddLinesProperties(majorGridlines)); + } + + @Override + public XDDFShapeProperties getOrAddMinorGridProperties() { + CTChartLines minorGridlines; + if (ctCatAx.isSetMinorGridlines()) { + minorGridlines = ctCatAx.getMinorGridlines(); + } else { + minorGridlines = ctCatAx.addNewMinorGridlines(); } - return ctCatAx.getMajorGridlines().getSpPr(); + return new XDDFShapeProperties(getOrAddLinesProperties(minorGridlines)); } @Override - @Internal - public CTShapeProperties getLine() { - return ctCatAx.getSpPr(); + public XDDFShapeProperties getOrAddShapeProperties() { + CTShapeProperties properties; + if (ctCatAx.isSetSpPr()) { + properties = ctCatAx.getSpPr(); + } else { + properties = ctCatAx.addNewSpPr(); + } + + return new XDDFShapeProperties(properties); } @Override diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java index 92f146e2b2..0f6bad2a09 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java @@ -33,6 +33,7 @@ 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.poi.xddf.usermodel.XDDFShapeProperties; import org.apache.xmlbeans.XmlException; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean; @@ -48,6 +49,7 @@ 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; +import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; @Beta public abstract class XDDFChart extends POIXMLDocumentPart { @@ -172,6 +174,23 @@ public abstract class XDDFChart extends POIXMLDocumentPart { chart.getAutoTitleDeleted().setVal(deleted); } + public XDDFShapeProperties getOrAddShapeProperties() { + CTPlotArea plotArea = getCTPlotArea(); + CTShapeProperties properties; + if (plotArea.isSetSpPr()) { + properties = plotArea.getSpPr(); + } else { + properties = plotArea.addNewSpPr(); + } + return new XDDFShapeProperties(properties); + } + + public void deleteShapeProperties() { + if (getCTPlotArea().isSetSpPr()) { + getCTPlotArea().unsetSpPr(); + } + } + public XDDFChartLegend getOrAddLegend() { return new XDDFChartLegend(chart); } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java index 3279d2b3c2..cd1c6f01ab 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java @@ -18,9 +18,11 @@ package org.apache.poi.xddf.usermodel.chart; import org.apache.poi.util.Beta; -import org.apache.poi.util.Internal; +import org.apache.poi.xddf.usermodel.HasShapeProperties; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartLines; import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses; import org.openxmlformats.schemas.drawingml.x2006.chart.CTLogBase; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt; @@ -34,7 +36,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties; * Base class for all axis types. */ @Beta -public abstract class XDDFChartAxis { +public abstract class XDDFChartAxis implements HasShapeProperties { protected abstract CTUnsignedInt getCTAxId(); protected abstract CTAxPos getCTAxPos(); @@ -51,11 +53,9 @@ public abstract class XDDFChartAxis { protected abstract CTTickMark getMinorCTTickMark(); - @Internal - public abstract CTShapeProperties getMajorGridLines(); + public abstract XDDFShapeProperties getOrAddMajorGridProperties(); - @Internal - public abstract CTShapeProperties getLine(); + public abstract XDDFShapeProperties getOrAddMinorGridProperties(); /** * @return axis id @@ -80,8 +80,8 @@ public abstract class XDDFChartAxis { } /** - * Use this to check before retrieving a number format, as calling {@link #getNumberFormat()} may create a default - * one if none exists. + * 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 */ @@ -294,6 +294,16 @@ public abstract class XDDFChartAxis { getMinorCTTickMark().setVal(tickMark.underlying); } + protected CTShapeProperties getOrAddLinesProperties(CTChartLines gridlines) { + CTShapeProperties properties; + if (gridlines.isSetSpPr()) { + properties = gridlines.getSpPr(); + } else { + properties = gridlines.addNewSpPr(); + } + return properties; + } + protected long getNextAxId(CTPlotArea plotArea) { long totalAxisCount = plotArea.sizeOfValAxArray() + plotArea.sizeOfCatAxArray() + plotArea.sizeOfDateAxArray() + plotArea.sizeOfSerAxArray(); diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java index 66f4c9b555..f5ad1f1706 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.Beta; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumData; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; @@ -87,6 +88,8 @@ public abstract class XDDFChartData { protected abstract CTSerTx getSeriesText(); public abstract void setShowLeaderLines(boolean showLeaderLines); + public abstract XDDFShapeProperties getShapeProperties(); + public abstract void setShapeProperties(XDDFShapeProperties properties); protected XDDFDataSource categoryData; protected XDDFNumericalDataSource valuesData; diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java index 75db5ebbd4..2c5794e6f1 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartLegend.java @@ -79,7 +79,9 @@ public final class XDDFChartLegend { @Internal // will later replace with XDDFShapeProperties public void setShapeProperties(CTShapeProperties properties) { if (properties == null) { - legend.unsetSpPr(); + if (legend.isSetSpPr()) { + legend.unsetSpPr(); + } } else { legend.setSpPr(properties); } @@ -95,7 +97,9 @@ public final class XDDFChartLegend { public void setTextBody(XDDFTextBody body) { if (body == null) { - legend.unsetTxPr(); + if (legend.isSetTxPr()) { + legend.unsetTxPr(); + } } else { legend.setTxPr(body.getXmlObject()); } @@ -119,7 +123,9 @@ public final class XDDFChartLegend { public void setExtensionList(XDDFChartExtensionList list) { if (list == null) { - legend.unsetExtLst(); + if (legend.isSetExtLst()) { + legend.unsetExtLst(); + } } else { legend.setExtLst(list.getXmlObject()); } @@ -135,7 +141,9 @@ public final class XDDFChartLegend { public void setLayout(XDDFLayout layout) { if (layout == null) { - legend.unsetLayout(); + if (legend.isSetLayout()) { + legend.unsetLayout(); + } } else { legend.setLayout(layout.getXmlObject()); } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java index bc72a2162e..95f7d74f4c 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java @@ -18,9 +18,10 @@ package org.apache.poi.xddf.usermodel.chart; import org.apache.poi.util.Beta; -import org.apache.poi.util.Internal; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartLines; import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses; import org.openxmlformats.schemas.drawingml.x2006.chart.CTDateAx; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt; @@ -32,8 +33,8 @@ 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. + * Date axis type. Currently only implements the same values as + * {@link XDDFCategoryAxis}, since the two are nearly identical. */ @Beta public class XDDFDateAxis extends XDDFChartAxis { @@ -49,21 +50,36 @@ public class XDDFDateAxis extends XDDFChartAxis { } @Override - @Internal - public CTShapeProperties getMajorGridLines() { - if (!ctDateAx.isSetMajorGridlines()) { - ctDateAx.addNewMajorGridlines(); + public XDDFShapeProperties getOrAddMajorGridProperties() { + CTChartLines majorGridlines; + if (ctDateAx.isSetMajorGridlines()) { + majorGridlines = ctDateAx.getMajorGridlines(); + } else { + majorGridlines = ctDateAx.addNewMajorGridlines(); } - if (!ctDateAx.getMajorGridlines().isSetSpPr()) { - ctDateAx.getMajorGridlines().addNewSpPr(); + return new XDDFShapeProperties(getOrAddLinesProperties(majorGridlines)); + } + + @Override + public XDDFShapeProperties getOrAddMinorGridProperties() { + CTChartLines minorGridlines; + if (ctDateAx.isSetMinorGridlines()) { + minorGridlines = ctDateAx.getMinorGridlines(); + } else { + minorGridlines = ctDateAx.addNewMinorGridlines(); } - return ctDateAx.getMajorGridlines().getSpPr(); + return new XDDFShapeProperties(getOrAddLinesProperties(minorGridlines)); } @Override - @Internal - public CTShapeProperties getLine() { - return ctDateAx.getSpPr(); + public XDDFShapeProperties getOrAddShapeProperties() { + CTShapeProperties properties; + if (ctDateAx.isSetSpPr()) { + properties = ctDateAx.getSpPr(); + } else { + properties = ctDateAx.addNewSpPr(); + } + return new XDDFShapeProperties(properties); } @Override diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLayout.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLayout.java index b3bacdd649..257931a5d4 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLayout.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLayout.java @@ -41,7 +41,9 @@ public class XDDFLayout { public void setExtensionList(XDDFChartExtensionList list) { if (list == null) { - layout.unsetExtLst(); + if (layout.isSetExtLst()) { + layout.unsetExtLst(); + } } else { layout.setExtLst(list.getXmlObject()); } @@ -57,7 +59,9 @@ public class XDDFLayout { public void setManualLayout(XDDFManualLayout manual) { if (manual == null) { - layout.unsetManualLayout(); + if (layout.isSetManualLayout()) { + layout.unsetManualLayout(); + } } else { layout.setManualLayout(manual.getXmlObject()); } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLegendEntry.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLegendEntry.java index da8fa22c85..bedc954662 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLegendEntry.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLegendEntry.java @@ -46,7 +46,9 @@ public class XDDFLegendEntry { public void setTextBody(XDDFTextBody body) { if (body == null) { - entry.unsetTxPr(); + if (entry.isSetTxPr()) { + entry.unsetTxPr(); + } } else { entry.setTxPr(body.getXmlObject()); } @@ -62,7 +64,9 @@ public class XDDFLegendEntry { public void setDelete(Boolean delete) { if (delete == null) { - entry.unsetDelete(); + if (entry.isSetDelete()) { + entry.unsetDelete(); + } } else { if (entry.isSetDelete()) { entry.getDelete().setVal(delete); @@ -82,7 +86,9 @@ public class XDDFLegendEntry { public void setExtensionList(XDDFChartExtensionList list) { if (list == null) { - entry.unsetExtLst(); + if (entry.isSetExtLst()) { + entry.unsetExtLst(); + } } else { entry.setExtLst(list.getXmlObject()); } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java index ff4c648b61..03ee375e93 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java @@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart; import java.util.Map; import org.apache.poi.util.Beta; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart; import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer; @@ -102,6 +103,30 @@ public class XDDFLineChartData extends XDDFChartData { } } + @Override + public XDDFShapeProperties getShapeProperties() { + if (series.isSetSpPr()) { + return new XDDFShapeProperties(series.getSpPr()); + } else { + return null; + } + } + + @Override + public void setShapeProperties(XDDFShapeProperties properties) { + if (properties == null) { + if (series.isSetSpPr()) { + series.unsetSpPr(); + } + } else { + if (series.isSetSpPr()) { + series.setSpPr(properties.getXmlObject()); + } else { + series.addNewSpPr().set(properties.getXmlObject()); + } + } + } + public void setMarkerSize(short size) { CTMarker marker = getMarker(); if (marker.isSetSize()) { diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFManualLayout.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFManualLayout.java index 766fb95507..856a530fbc 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFManualLayout.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFManualLayout.java @@ -71,7 +71,9 @@ public final class XDDFManualLayout { public void setExtensionList(XDDFChartExtensionList list) { if (list == null) { - layout.unsetExtLst(); + if (layout.isSetExtLst()) { + layout.unsetExtLst(); + } } else { layout.setExtLst(list.getXmlObject()); } diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java index 5c773c272d..3d7cac6740 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java @@ -18,6 +18,7 @@ package org.apache.poi.xddf.usermodel.chart; import org.apache.poi.util.Beta; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart; @@ -89,6 +90,30 @@ public class XDDFPieChartData extends XDDFChartData { } } + @Override + public XDDFShapeProperties getShapeProperties() { + if (series.isSetSpPr()) { + return new XDDFShapeProperties(series.getSpPr()); + } else { + return null; + } + } + + @Override + public void setShapeProperties(XDDFShapeProperties properties) { + if (properties == null) { + if (series.isSetSpPr()) { + series.unsetSpPr(); + } + } else { + if (series.isSetSpPr()) { + series.setSpPr(properties.getXmlObject()); + } else { + series.addNewSpPr().set(properties.getXmlObject()); + } + } + } + public long getExplosion() { if (series.isSetExplosion()) { return series.getExplosion().getVal(); diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java index 15891ce58b..a189391346 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java @@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart; import java.util.Map; import org.apache.poi.util.Beta; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTRadarChart; @@ -106,6 +107,30 @@ public class XDDFRadarChartData extends XDDFChartData { } } + @Override + public XDDFShapeProperties getShapeProperties() { + if (series.isSetSpPr()) { + return new XDDFShapeProperties(series.getSpPr()); + } else { + return null; + } + } + + @Override + public void setShapeProperties(XDDFShapeProperties properties) { + if (properties == null) { + if (series.isSetSpPr()) { + series.unsetSpPr(); + } + } else { + if (series.isSetSpPr()) { + series.setSpPr(properties.getXmlObject()); + } else { + series.addNewSpPr().set(properties.getXmlObject()); + } + } + } + @Override protected CTAxDataSource getAxDS() { return series.getCat(); diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java index f025273a24..bd6c69b21c 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java @@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart; import java.util.Map; import org.apache.poi.util.Beta; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart; @@ -110,6 +111,30 @@ public class XDDFScatterChartData extends XDDFChartData { } } + @Override + public XDDFShapeProperties getShapeProperties() { + if (series.isSetSpPr()) { + return new XDDFShapeProperties(series.getSpPr()); + } else { + return null; + } + } + + @Override + public void setShapeProperties(XDDFShapeProperties properties) { + if (properties == null) { + if (series.isSetSpPr()) { + series.unsetSpPr(); + } + } else { + if (series.isSetSpPr()) { + series.setSpPr(properties.getXmlObject()); + } else { + series.addNewSpPr().set(properties.getXmlObject()); + } + } + } + @Override protected CTAxDataSource getAxDS() { return series.getXVal(); diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java index 08fe0dea15..9720000d16 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java @@ -18,9 +18,10 @@ package org.apache.poi.xddf.usermodel.chart; import org.apache.poi.util.Beta; -import org.apache.poi.util.Internal; +import org.apache.poi.xddf.usermodel.XDDFShapeProperties; import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos; import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartLines; import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses; import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt; import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; @@ -45,21 +46,36 @@ public class XDDFValueAxis extends XDDFChartAxis { } @Override - @Internal - public CTShapeProperties getMajorGridLines() { - if (!ctValAx.isSetMajorGridlines()) { - ctValAx.addNewMajorGridlines(); + public XDDFShapeProperties getOrAddMajorGridProperties() { + CTChartLines majorGridlines; + if (ctValAx.isSetMajorGridlines()) { + majorGridlines = ctValAx.getMajorGridlines(); + } else { + majorGridlines = ctValAx.addNewMajorGridlines(); } - if (!ctValAx.getMajorGridlines().isSetSpPr()) { - ctValAx.getMajorGridlines().addNewSpPr(); + return new XDDFShapeProperties(getOrAddLinesProperties(majorGridlines)); + } + + @Override + public XDDFShapeProperties getOrAddMinorGridProperties() { + CTChartLines minorGridlines; + if (ctValAx.isSetMinorGridlines()) { + minorGridlines = ctValAx.getMinorGridlines(); + } else { + minorGridlines = ctValAx.addNewMinorGridlines(); } - return ctValAx.getMajorGridlines().getSpPr(); + return new XDDFShapeProperties(getOrAddLinesProperties(minorGridlines)); } @Override - @Internal - public CTShapeProperties getLine() { - return ctValAx.getSpPr(); + public XDDFShapeProperties getOrAddShapeProperties() { + CTShapeProperties properties; + if (ctValAx.isSetSpPr()) { + properties = ctValAx.getSpPr(); + } else { + properties = ctValAx.addNewSpPr(); + } + return new XDDFShapeProperties(properties); } @Override diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java index dce8a2a026..faf46f192a 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java @@ -49,12 +49,12 @@ import org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument; public class XSLFTheme extends POIXMLDocumentPart { private CTOfficeStyleSheet _theme; private Map _schemeColors; - + XSLFTheme() { super(); _theme = CTOfficeStyleSheet.Factory.newInstance(); } - + /** * @since POI 3.14-Beta1 */ @@ -65,7 +65,7 @@ public class XSLFTheme extends POIXMLDocumentPart { _theme = doc.getTheme(); initialize(); } - + public void importTheme(XSLFTheme theme) { _theme = theme.getXmlObject(); _schemeColors = theme._schemeColors; @@ -74,7 +74,7 @@ public class XSLFTheme extends POIXMLDocumentPart { private void initialize(){ CTBaseStyles elems = _theme.getThemeElements(); CTColorScheme scheme = elems.getClrScheme(); - // The color scheme is responsible for defining a list of twelve colors. + // The color scheme is responsible for defining a list of twelve colors. _schemeColors = new HashMap<>(12); for(XmlObject o : scheme.selectPath("*")){ CTColor c = (CTColor)o; @@ -114,13 +114,14 @@ public class XSLFTheme extends POIXMLDocumentPart { /** * Get a color from the theme's color scheme by name - * + * * @return a theme color or null if not found */ - CTColor getCTColor(String name){ + @Internal + public CTColor getCTColor(String name){ return _schemeColors.get(name); } - + /** * While developing only! */ @@ -129,6 +130,7 @@ public class XSLFTheme extends POIXMLDocumentPart { return _theme; } + @Override protected final void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( diff --git a/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java b/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java new file mode 100644 index 0000000000..989313ae19 --- /dev/null +++ b/src/ooxml/testcases/org/apache/poi/xddf/usermodel/TestXDDFColor.java @@ -0,0 +1,119 @@ +/* ==================================================================== + 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; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFTheme; +import org.junit.Test; +import org.openxmlformats.schemas.drawingml.x2006.main.CTColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor; +import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor; +import org.openxmlformats.schemas.drawingml.x2006.main.STPresetColorVal; +import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal; +import org.openxmlformats.schemas.drawingml.x2006.main.STSystemColorVal; + +public class TestXDDFColor { + private static final String XMLNS = "xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"/>"; + + @Test + public void testSchemeColor() throws IOException { + XMLSlideShow ppt = new XMLSlideShow(); + XSLFTheme theme = ppt.createSlide().getTheme(); + + XDDFColor color = XDDFColor.forColorContainer(getThemeColor(theme, STSchemeColorVal.ACCENT_2)); + // accent2 in theme1.xml is + assertEquals("