You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2018/10/06 19:33:28 UTC
svn commit: r1843032 [2/3] - in /poi/branches/hemf: ./ jenkins/ maven/
sonar/ooxml/ src/examples/src/org/apache/poi/hssf/view/
src/examples/src/org/apache/poi/ss/examples/
src/examples/src/org/apache/poi/ss/examples/html/
src/examples/src/org/apache/po...
Modified: poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java (original)
+++ poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java Sat Oct 6 19:33:27 2018
@@ -22,15 +22,22 @@ 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.XDDFLineProperties;
+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.MarkerStyle;
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.XDDFLineChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
import org.apache.poi.xssf.usermodel.XSSFChart;
@@ -57,35 +64,64 @@ public class LineChart {
row = sheet.createRow((short) rowIndex);
for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) {
cell = row.createCell((short) colIndex);
- cell.setCellValue(colIndex * (rowIndex + 1));
+ cell.setCellValue(colIndex * (rowIndex + 1.0));
}
}
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);
+ bottomAxis.setTitle("x"); // https://stackoverflow.com/questions/32010765
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
+ leftAxis.setTitle("f(x)");
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
-
+
XDDFDataSource<Double> xs = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
XDDFNumericalDataSource<Double> ys2 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1));
-
- XDDFChartData data = chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
- data.addSeries(xs, ys1);
- data.addSeries(xs, ys2);
+
+ XDDFLineChartData data = (XDDFLineChartData) chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
+ XDDFLineChartData.Series series1 = (XDDFLineChartData.Series) data.addSeries(xs, ys1);
+ series1.setTitle("2x", null); // https://stackoverflow.com/questions/21855842
+ series1.setSmooth(false); // https://stackoverflow.com/questions/29014848
+ series1.setMarkerStyle(MarkerStyle.STAR); // https://stackoverflow.com/questions/39636138
+ XDDFLineChartData.Series series2 = (XDDFLineChartData.Series) data.addSeries(xs, ys2);
+ series2.setTitle("3x", null);
+ series2.setSmooth(true);
+ series2.setMarkerSize((short) 6);
+ series2.setMarkerStyle(MarkerStyle.TRIANGLE); // https://stackoverflow.com/questions/39636138
chart.plot(data);
+ // if your series have missing values like https://stackoverflow.com/questions/29014848
+ // chart.displayBlanksAs(DisplayBlanks.GAP);
+
+ // https://stackoverflow.com/questions/24676460
+ solidLineSeries(data, 0, PresetColor.CHARTREUSE);
+ solidLineSeries(data, 1, PresetColor.TURQUOISE);
+
// Write the output to a file
try (FileOutputStream fileOut = new FileOutputStream("ooxml-line-chart.xlsx")) {
wb.write(fileOut);
}
}
}
+
+ private static void solidLineSeries(XDDFChartData data, int index, PresetColor color) {
+ XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color));
+ XDDFLineProperties line = new XDDFLineProperties();
+ line.setFillProperties(fill);
+ XDDFChartData.Series series = data.getSeries().get(index);
+ XDDFShapeProperties properties = series.getShapeProperties();
+ if (properties == null) {
+ properties = new XDDFShapeProperties();
+ }
+ properties.setLineProperties(line);
+ series.setShapeProperties(properties);
+ }
}
Modified: poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java (original)
+++ poi/branches/hemf/src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java Sat Oct 6 19:33:27 2018
@@ -25,6 +25,11 @@ 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.XDDFLineProperties;
+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;
@@ -34,6 +39,7 @@ import org.apache.poi.xddf.usermodel.cha
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.XDDFScatterChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
import org.apache.poi.xssf.usermodel.XSSFChart;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
@@ -59,36 +65,56 @@ public class ScatterChart {
row = sheet.createRow((short) rowIndex);
for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) {
cell = row.createCell((short) colIndex);
- cell.setCellValue(colIndex * (rowIndex + 1));
+ cell.setCellValue(colIndex * (rowIndex + 1.0));
}
}
-
+
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);
-
+
XDDFValueAxis bottomAxis = chart.createValueAxis(AxisPosition.BOTTOM);
+ bottomAxis.setTitle("x"); // https://stackoverflow.com/questions/32010765
XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);
+ leftAxis.setTitle("f(x)");
leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
-
+
XDDFDataSource<Double> xs = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
XDDFNumericalDataSource<Double> ys2 = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1));
-
-
- XDDFChartData data = chart.createData(ChartTypes.SCATTER, bottomAxis, leftAxis);
-
- data.addSeries(xs, ys1);
- data.addSeries(xs, ys2);
+
+
+ XDDFScatterChartData data = (XDDFScatterChartData) chart.createData(ChartTypes.SCATTER, bottomAxis, leftAxis);
+ XDDFScatterChartData.Series series1 = (XDDFScatterChartData.Series) data.addSeries(xs, ys1);
+ series1.setTitle("2x", null); // https://stackoverflow.com/questions/21855842
+ series1.setSmooth(false); // https://stackoverflow.com/questions/39636138
+ XDDFScatterChartData.Series series2 = (XDDFScatterChartData.Series) data.addSeries(xs, ys2);
+ series2.setTitle("3x", null);
chart.plot(data);
+ solidLineSeries(data, 0, PresetColor.CHARTREUSE);
+ solidLineSeries(data, 1, PresetColor.TURQUOISE);
+
// Write the output to a file
try (FileOutputStream fileOut = new FileOutputStream("ooxml-scatter-chart.xlsx")) {
wb.write(fileOut);
}
}
}
+
+ private static void solidLineSeries(XDDFChartData data, int index, PresetColor color) {
+ XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color));
+ XDDFLineProperties line = new XDDFLineProperties();
+ line.setFillProperties(fill);
+ XDDFChartData.Series series = data.getSeries().get(index);
+ XDDFShapeProperties properties = series.getShapeProperties();
+ if (properties == null) {
+ properties = new XDDFShapeProperties();
+ }
+ properties.setLineProperties(line);
+ series.setShapeProperties(properties);
+ }
}
Modified: poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java (original)
+++ poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java Sat Oct 6 19:33:27 2018
@@ -111,16 +111,16 @@ public class SimpleDocument {
r5.setTextPosition(-10);
r5.setText("For in that sleep of death what dreams may come");
r5.addCarriageReturn();
- r5.setText("When we have shuffled off this mortal coil,"
- + "Must give us pause: there's the respect"
+ r5.setText("When we have shuffled off this mortal coil, "
+ + "Must give us pause: there's the respect "
+ "That makes calamity of so long life;");
r5.addBreak();
- r5.setText("For who would bear the whips and scorns of time,"
+ r5.setText("For who would bear the whips and scorns of time, "
+ "The oppressor's wrong, the proud man's contumely,");
r5.addBreak(BreakClear.ALL);
- r5.setText("The pangs of despised love, the law's delay,"
- + "The insolence of office and the spurns" + ".......");
+ r5.setText("The pangs of despised love, the law's delay, "
+ + "The insolence of office and the spurns " + ".......");
try (FileOutputStream out = new FileOutputStream("simple.docx")) {
doc.write(out);
Modified: poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java (original)
+++ poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java Sat Oct 6 19:33:27 2018
@@ -43,18 +43,29 @@ public class SimpleImages {
for (String imgFile : args) {
int format;
- if (imgFile.endsWith(".emf")) format = XWPFDocument.PICTURE_TYPE_EMF;
- else if (imgFile.endsWith(".wmf")) format = XWPFDocument.PICTURE_TYPE_WMF;
- else if (imgFile.endsWith(".pict")) format = XWPFDocument.PICTURE_TYPE_PICT;
- else if (imgFile.endsWith(".jpeg") || imgFile.endsWith(".jpg")) format = XWPFDocument.PICTURE_TYPE_JPEG;
- else if (imgFile.endsWith(".png")) format = XWPFDocument.PICTURE_TYPE_PNG;
- else if (imgFile.endsWith(".dib")) format = XWPFDocument.PICTURE_TYPE_DIB;
- else if (imgFile.endsWith(".gif")) format = XWPFDocument.PICTURE_TYPE_GIF;
- else if (imgFile.endsWith(".tiff")) format = XWPFDocument.PICTURE_TYPE_TIFF;
- else if (imgFile.endsWith(".eps")) format = XWPFDocument.PICTURE_TYPE_EPS;
- else if (imgFile.endsWith(".bmp")) format = XWPFDocument.PICTURE_TYPE_BMP;
- else if (imgFile.endsWith(".wpg")) format = XWPFDocument.PICTURE_TYPE_WPG;
- else {
+ if (imgFile.endsWith(".emf")) {
+ format = XWPFDocument.PICTURE_TYPE_EMF;
+ } else if (imgFile.endsWith(".wmf")) {
+ format = XWPFDocument.PICTURE_TYPE_WMF;
+ } else if (imgFile.endsWith(".pict")) {
+ format = XWPFDocument.PICTURE_TYPE_PICT;
+ } else if (imgFile.endsWith(".jpeg") || imgFile.endsWith(".jpg")) {
+ format = XWPFDocument.PICTURE_TYPE_JPEG;
+ } else if (imgFile.endsWith(".png")) {
+ format = XWPFDocument.PICTURE_TYPE_PNG;
+ } else if (imgFile.endsWith(".dib")) {
+ format = XWPFDocument.PICTURE_TYPE_DIB;
+ } else if (imgFile.endsWith(".gif")) {
+ format = XWPFDocument.PICTURE_TYPE_GIF;
+ } else if (imgFile.endsWith(".tiff")) {
+ format = XWPFDocument.PICTURE_TYPE_TIFF;
+ } else if (imgFile.endsWith(".eps")) {
+ format = XWPFDocument.PICTURE_TYPE_EPS;
+ } else if (imgFile.endsWith(".bmp")) {
+ format = XWPFDocument.PICTURE_TYPE_BMP;
+ } else if (imgFile.endsWith(".wpg")) {
+ format = XWPFDocument.PICTURE_TYPE_WPG;
+ } else {
System.err.println("Unsupported picture: " + imgFile +
". Expected emf|wmf|pict|jpeg|png|dib|gif|tiff|eps|bmp|wpg");
continue;
@@ -62,7 +73,9 @@ public class SimpleImages {
r.setText(imgFile);
r.addBreak();
- r.addPicture(new FileInputStream(imgFile), format, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 pixels
+ try (FileInputStream is = new FileInputStream(imgFile)) {
+ r.addPicture(is, format, imgFile, Units.toEMU(200), Units.toEMU(200)); // 200x200 pixels
+ }
r.addBreak(BreakType.PAGE);
}
Modified: poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt (original)
+++ poi/branches/hemf/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt Sat Oct 6 19:33:27 2018
@@ -1,4 +1,12 @@
-My Bar or Column Chart
-First 1.0
-Second 3.0
-Third 4.0
\ No newline at end of file
+10 languages with most speakers as first language
+countries,speakers,language
+58,315,Ø§ÙØ¹Ø±Ø¨ÙØ©
+4,243,বাà¦à¦²à¦¾
+38,1299,䏿
+118,378,English
+4,260,हिनà¥à¤¦à¥
+2,128,æ¥æ¬èª
+15,223,português
+6,119,ਪੰà¨à¨¾à¨¬à©
+18,154,Ð ÑÑÑкий ÑзÑк
+31,442,español
Modified: poi/branches/hemf/src/java/org/apache/poi/ddf/EscherRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/ddf/EscherRecord.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/java/org/apache/poi/ddf/EscherRecord.java (original)
+++ poi/branches/hemf/src/java/org/apache/poi/ddf/EscherRecord.java Sat Oct 6 19:33:27 2018
@@ -336,7 +336,7 @@ public abstract class EscherRecord imple
String tagName = capitalizeAndTrim((String)attrs[0]);
boolean hasValue = false;
boolean lastChildComplex = false;
- for (int i=0; i<attrs.length; i+=2) {
+ for (int i=0; i<attrs.length-1; i+=2) {
Object value = attrs[i+1];
if (value == null) {
// ignore null values
@@ -384,7 +384,7 @@ public abstract class EscherRecord imple
if (attrList != null && attrList.length > 0) {
String childTab = " ";
for (Object[] attrs : attrList) {
- for (int i=0; i<attrs.length; i+=2) {
+ for (int i=0; i<attrs.length-1; i+=2) {
Object value = attrs[i+1];
if (value == null) {
// ignore null values
Modified: poi/branches/hemf/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java (original)
+++ poi/branches/hemf/src/java/org/apache/poi/ss/formula/EvaluationConditionalFormatRule.java Sat Oct 6 19:33:27 2018
@@ -21,15 +21,7 @@ import java.text.CollationKey;
import java.text.Collator;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import org.apache.poi.ss.formula.eval.BlankEval;
import org.apache.poi.ss.formula.eval.BoolEval;
@@ -900,9 +892,9 @@ public class EvaluationConditionalFormat
return false;
}
ValueAndFormat o = (ValueAndFormat) obj;
- return ( value == o.value || value.equals(o.value))
- && ( format == o.format || format.equals(o.format))
- && (string == o.string || string.equals(o.string));
+ return (Objects.equals(value, o.value)
+ && Objects.equals(format, o.format)
+ && Objects.equals(string, o.string));
}
/**
Modified: poi/branches/hemf/src/java/org/apache/poi/ss/formula/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/ss/formula/FormulaParser.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/java/org/apache/poi/ss/formula/FormulaParser.java (original)
+++ poi/branches/hemf/src/java/org/apache/poi/ss/formula/FormulaParser.java Sat Oct 6 19:33:27 2018
@@ -382,9 +382,6 @@ public final class FormulaParser {
if (token instanceof OperandPtg) {
return false;
}
- if (token instanceof OperationPtg) {
- return true;
- }
return false;
}
Modified: poi/branches/hemf/src/java/org/apache/poi/ss/formula/atp/RandBetween.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/ss/formula/atp/RandBetween.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/java/org/apache/poi/ss/formula/atp/RandBetween.java (original)
+++ poi/branches/hemf/src/java/org/apache/poi/ss/formula/atp/RandBetween.java Sat Oct 6 19:33:27 2018
@@ -77,7 +77,7 @@ final class RandBetween implements FreeR
top = bottom;
}
- return new NumberEval((bottom + (int)(Math.random() * ((top - bottom) + 1))));
+ return new NumberEval((bottom + (long)(Math.random() * ((top - bottom) + 1))));
}
Modified: poi/branches/hemf/src/java/org/apache/poi/util/StaxHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/java/org/apache/poi/util/StaxHelper.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/java/org/apache/poi/util/StaxHelper.java (original)
+++ poi/branches/hemf/src/java/org/apache/poi/util/StaxHelper.java Sat Oct 6 19:33:27 2018
@@ -34,7 +34,7 @@ public final class StaxHelper {
* Creates a new StAX XMLInputFactory, with sensible defaults
*/
public static XMLInputFactory newXMLInputFactory() {
- XMLInputFactory factory = XMLInputFactory.newFactory();
+ XMLInputFactory factory = XMLInputFactory.newInstance();
trySetProperty(factory, XMLInputFactory.IS_NAMESPACE_AWARE, true);
trySetProperty(factory, XMLInputFactory.IS_VALIDATING, false);
trySetProperty(factory, XMLInputFactory.SUPPORT_DTD, false);
@@ -46,7 +46,7 @@ public final class StaxHelper {
* Creates a new StAX XMLOutputFactory, with sensible defaults
*/
public static XMLOutputFactory newXMLOutputFactory() {
- XMLOutputFactory factory = XMLOutputFactory.newFactory();
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
trySetProperty(factory, XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
return factory;
}
@@ -55,7 +55,8 @@ public final class StaxHelper {
* Creates a new StAX XMLEventFactory, with sensible defaults
*/
public static XMLEventFactory newXMLEventFactory() {
- return XMLEventFactory.newFactory();
+ // this method seems safer on Android than getFactory()
+ return XMLEventFactory.newInstance();
}
private static void trySetProperty(XMLInputFactory factory, String feature, boolean flag) {
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/ooxml/POIXMLProperties.java Sat Oct 6 19:33:27 2018
@@ -223,7 +223,7 @@ public class POIXMLProperties {
throw new POIXMLException(e);
}
}
- if(extPart != null){
+ if(extPart != null && ext != null && ext.props != null){
try (OutputStream out = extPart.getOutputStream()) {
if (extPart.getSize() > 0) {
extPart.clear();
@@ -231,7 +231,7 @@ public class POIXMLProperties {
ext.props.save(out, DEFAULT_XML_OPTIONS);
}
}
- if(custPart != null){
+ if(custPart != null && cust != null && cust.props != null){
try (OutputStream out = custPart.getOutputStream()) {
cust.props.save(out, DEFAULT_XML_OPTIONS);
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java Sat Oct 6 19:33:27 2018
@@ -28,7 +28,6 @@ import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -416,6 +415,8 @@ public abstract class OPCPackage impleme
* If your package is open read only, then you should call {@link #revert()}
* when finished with the package.
*
+ * This method is not thread-safe.
+ *
* @throws IOException
* If an IO exception occur during the saving process.
*/
@@ -434,27 +435,20 @@ public abstract class OPCPackage impleme
return;
}
- // Save the content
- ReentrantReadWriteLock l = new ReentrantReadWriteLock();
- try {
- l.writeLock().lock();
- if (this.originalPackagePath != null
- && !this.originalPackagePath.trim().isEmpty()) {
- File targetFile = new File(this.originalPackagePath);
- if (!targetFile.exists()
- || !(this.originalPackagePath
- .equalsIgnoreCase(targetFile.getAbsolutePath()))) {
- // Case of a package created from scratch
- save(targetFile);
- } else {
- closeImpl();
- }
- } else if (this.output != null) {
- save(this.output);
- output.close();
+ if (this.originalPackagePath != null
+ && !this.originalPackagePath.trim().isEmpty()) {
+ File targetFile = new File(this.originalPackagePath);
+ if (!targetFile.exists()
+ || !(this.originalPackagePath
+ .equalsIgnoreCase(targetFile.getAbsolutePath()))) {
+ // Case of a package created from scratch
+ save(targetFile);
+ } else {
+ closeImpl();
}
- } finally {
- l.writeLock().unlock();
+ } else if (this.output != null) {
+ save(this.output);
+ output.close();
}
// Clear
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/marshallers/PackagePropertiesMarshaller.java Sat Oct 6 19:33:27 2018
@@ -21,8 +21,6 @@ import java.io.OutputStream;
import java.util.Optional;
import javax.xml.XMLConstants;
-import javax.xml.stream.XMLEventFactory;
-import javax.xml.stream.events.Namespace;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackagePart;
@@ -36,105 +34,109 @@ import org.w3c.dom.Element;
* Package properties marshaller.
*/
public class PackagePropertiesMarshaller implements PartMarshaller {
- private final static Namespace namespaceDC, namespaceCoreProperties, namespaceDcTerms, namespaceXSI;
- static {
- final XMLEventFactory f = XMLEventFactory.newInstance();
- namespaceDC = f.createNamespace("dc", PackagePropertiesPart.NAMESPACE_DC_URI);
- namespaceCoreProperties = f.createNamespace("cp", PackagePropertiesPart.NAMESPACE_CP_URI);
- namespaceDcTerms = f.createNamespace("dcterms", PackagePropertiesPart.NAMESPACE_DCTERMS_URI);
- namespaceXSI = f.createNamespace("xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
- }
+ private final static NamespaceImpl namespaceDC =
+ new NamespaceImpl("dc", PackagePropertiesPart.NAMESPACE_DC_URI);
+ private final static NamespaceImpl namespaceCoreProperties =
+ new NamespaceImpl("cp", PackagePropertiesPart.NAMESPACE_CP_URI);;
+ private final static NamespaceImpl namespaceDcTerms =
+ new NamespaceImpl("dcterms", PackagePropertiesPart.NAMESPACE_DCTERMS_URI);
+ private final static NamespaceImpl namespaceXSI =
+ new NamespaceImpl("xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);;
- protected static final String KEYWORD_CATEGORY = "category";
+ protected static final String KEYWORD_CATEGORY = "category";
- protected static final String KEYWORD_CONTENT_STATUS = "contentStatus";
+ protected static final String KEYWORD_CONTENT_STATUS = "contentStatus";
- protected static final String KEYWORD_CONTENT_TYPE = "contentType";
+ protected static final String KEYWORD_CONTENT_TYPE = "contentType";
- protected static final String KEYWORD_CREATED = "created";
+ protected static final String KEYWORD_CREATED = "created";
- protected static final String KEYWORD_CREATOR = "creator";
+ protected static final String KEYWORD_CREATOR = "creator";
- protected static final String KEYWORD_DESCRIPTION = "description";
+ protected static final String KEYWORD_DESCRIPTION = "description";
- protected static final String KEYWORD_IDENTIFIER = "identifier";
+ protected static final String KEYWORD_IDENTIFIER = "identifier";
- protected static final String KEYWORD_KEYWORDS = "keywords";
+ protected static final String KEYWORD_KEYWORDS = "keywords";
- protected static final String KEYWORD_LANGUAGE = "language";
+ protected static final String KEYWORD_LANGUAGE = "language";
- protected static final String KEYWORD_LAST_MODIFIED_BY = "lastModifiedBy";
+ protected static final String KEYWORD_LAST_MODIFIED_BY = "lastModifiedBy";
- protected static final String KEYWORD_LAST_PRINTED = "lastPrinted";
+ protected static final String KEYWORD_LAST_PRINTED = "lastPrinted";
- protected static final String KEYWORD_MODIFIED = "modified";
+ protected static final String KEYWORD_MODIFIED = "modified";
- protected static final String KEYWORD_REVISION = "revision";
+ protected static final String KEYWORD_REVISION = "revision";
- protected static final String KEYWORD_SUBJECT = "subject";
+ protected static final String KEYWORD_SUBJECT = "subject";
- protected static final String KEYWORD_TITLE = "title";
+ protected static final String KEYWORD_TITLE = "title";
- protected static final String KEYWORD_VERSION = "version";
+ protected static final String KEYWORD_VERSION = "version";
- PackagePropertiesPart propsPart;
+ PackagePropertiesPart propsPart;
- // The document
- Document xmlDoc;
+ // The document
+ Document xmlDoc;
- /**
- * Marshall package core properties to an XML document. Always return
- * <code>true</code>.
- */
- @Override
- public boolean marshall(PackagePart part, OutputStream out)
- throws OpenXML4JException {
- if (!(part instanceof PackagePropertiesPart))
- throw new IllegalArgumentException(
- "'part' must be a PackagePropertiesPart instance.");
- propsPart = (PackagePropertiesPart) part;
+ /**
+ * Marshall package core properties to an XML document. Always return
+ * <code>true</code>.
+ */
+ @Override
+ public boolean marshall(PackagePart part, OutputStream out)
+ throws OpenXML4JException {
+ if (!(part instanceof PackagePropertiesPart))
+ throw new IllegalArgumentException(
+ "'part' must be a PackagePropertiesPart instance.");
+ propsPart = (PackagePropertiesPart) part;
- // Configure the document
- xmlDoc = DocumentHelper.createDocument();
+ // Configure the document
+ xmlDoc = DocumentHelper.createDocument();
Element rootElem = xmlDoc.createElementNS(namespaceCoreProperties.getNamespaceURI(),
getQName("coreProperties", namespaceCoreProperties));
- DocumentHelper.addNamespaceDeclaration(rootElem, namespaceCoreProperties);
- DocumentHelper.addNamespaceDeclaration(rootElem, namespaceDC);
- DocumentHelper.addNamespaceDeclaration(rootElem, namespaceDcTerms);
- DocumentHelper.addNamespaceDeclaration(rootElem, namespaceXSI);
+ DocumentHelper.addNamespaceDeclaration(rootElem,
+ namespaceCoreProperties.getPrefix(), namespaceCoreProperties.getNamespaceURI());
+ DocumentHelper.addNamespaceDeclaration(rootElem,
+ namespaceDC.getPrefix(), namespaceDC.getNamespaceURI());
+ DocumentHelper.addNamespaceDeclaration(rootElem,
+ namespaceDcTerms.getPrefix(), namespaceDcTerms.getNamespaceURI());
+ DocumentHelper.addNamespaceDeclaration(rootElem,
+ namespaceXSI.getPrefix(), namespaceXSI.getNamespaceURI());
xmlDoc.appendChild(rootElem);
- addCategory();
- addContentStatus();
- addContentType();
- addCreated();
- addCreator();
- addDescription();
- addIdentifier();
- addKeywords();
- addLanguage();
- addLastModifiedBy();
- addLastPrinted();
- addModified();
- addRevision();
- addSubject();
- addTitle();
- addVersion();
- return true;
- }
+ addCategory();
+ addContentStatus();
+ addContentType();
+ addCreated();
+ addCreator();
+ addDescription();
+ addIdentifier();
+ addKeywords();
+ addLanguage();
+ addLastModifiedBy();
+ addLastPrinted();
+ addModified();
+ addRevision();
+ addSubject();
+ addTitle();
+ addVersion();
+ return true;
+ }
/**
* Sets the given element's text content, creating it if necessary.
*/
- private Element setElementTextContent(String localName, Namespace namespace, Optional<String> property) {
+ private Element setElementTextContent(String localName, NamespaceImpl namespace, Optional<String> property) {
return setElementTextContent(localName, namespace, property, property.orElse(null));
}
-
- private String getQName(String localName, Namespace namespace) {
+
+ private String getQName(String localName, NamespaceImpl namespace) {
return namespace.getPrefix().isEmpty() ? localName : namespace.getPrefix() + ':' + localName;
}
- private Element setElementTextContent(String localName, Namespace namespace, Optional<?> property, String propertyValue) {
+ private Element setElementTextContent(String localName, NamespaceImpl namespace, Optional<?> property, String propertyValue) {
if (!property.isPresent())
return null;
@@ -149,7 +151,7 @@ public class PackagePropertiesMarshaller
return elem;
}
- private Element setElementTextContent(String localName, Namespace namespace, Optional<?> property, String propertyValue, String xsiType) {
+ private Element setElementTextContent(String localName, NamespaceImpl namespace, Optional<?> property, String propertyValue, String xsiType) {
Element element = setElementTextContent(localName, namespace, property, propertyValue);
if (element != null) {
element.setAttributeNS(namespaceXSI.getNamespaceURI(), getQName("type", namespaceXSI), xsiType);
@@ -159,114 +161,129 @@ public class PackagePropertiesMarshaller
/**
- * Add category property element if needed.
- */
- private void addCategory() {
+ * Add category property element if needed.
+ */
+ private void addCategory() {
setElementTextContent(KEYWORD_CATEGORY, namespaceCoreProperties, propsPart.getCategoryProperty());
- }
+ }
- /**
- * Add content status property element if needed.
- */
- private void addContentStatus() {
+ /**
+ * Add content status property element if needed.
+ */
+ private void addContentStatus() {
setElementTextContent(KEYWORD_CONTENT_STATUS, namespaceCoreProperties, propsPart.getContentStatusProperty());
- }
+ }
- /**
- * Add content type property element if needed.
- */
- private void addContentType() {
+ /**
+ * Add content type property element if needed.
+ */
+ private void addContentType() {
setElementTextContent(KEYWORD_CONTENT_TYPE, namespaceCoreProperties, propsPart.getContentTypeProperty());
- }
+ }
- /**
- * Add created property element if needed.
- */
- private void addCreated() {
+ /**
+ * Add created property element if needed.
+ */
+ private void addCreated() {
setElementTextContent(KEYWORD_CREATED, namespaceDcTerms, propsPart.getCreatedProperty(),
propsPart.getCreatedPropertyString(), "dcterms:W3CDTF");
- }
+ }
- /**
- * Add creator property element if needed.
- */
- private void addCreator() {
+ /**
+ * Add creator property element if needed.
+ */
+ private void addCreator() {
setElementTextContent(KEYWORD_CREATOR, namespaceDC, propsPart.getCreatorProperty());
- }
+ }
- /**
- * Add description property element if needed.
- */
- private void addDescription() {
+ /**
+ * Add description property element if needed.
+ */
+ private void addDescription() {
setElementTextContent(KEYWORD_DESCRIPTION, namespaceDC, propsPart.getDescriptionProperty());
- }
+ }
- /**
- * Add identifier property element if needed.
- */
- private void addIdentifier() {
+ /**
+ * Add identifier property element if needed.
+ */
+ private void addIdentifier() {
setElementTextContent(KEYWORD_IDENTIFIER, namespaceDC, propsPart.getIdentifierProperty());
- }
+ }
/**
- * Add keywords property element if needed.
- */
- private void addKeywords() {
+ * Add keywords property element if needed.
+ */
+ private void addKeywords() {
setElementTextContent(KEYWORD_KEYWORDS, namespaceCoreProperties, propsPart.getKeywordsProperty());
- }
+ }
- /**
- * Add language property element if needed.
- */
- private void addLanguage() {
+ /**
+ * Add language property element if needed.
+ */
+ private void addLanguage() {
setElementTextContent(KEYWORD_LANGUAGE, namespaceDC, propsPart.getLanguageProperty());
- }
+ }
- /**
- * Add 'last modified by' property if needed.
- */
- private void addLastModifiedBy() {
+ /**
+ * Add 'last modified by' property if needed.
+ */
+ private void addLastModifiedBy() {
setElementTextContent(KEYWORD_LAST_MODIFIED_BY, namespaceCoreProperties, propsPart.getLastModifiedByProperty());
- }
+ }
- /**
- * Add 'last printed' property if needed.
- *
- */
- private void addLastPrinted() {
+ /**
+ * Add 'last printed' property if needed.
+ */
+ private void addLastPrinted() {
setElementTextContent(KEYWORD_LAST_PRINTED, namespaceCoreProperties, propsPart.getLastPrintedProperty(), propsPart.getLastPrintedPropertyString());
- }
+ }
- /**
- * Add modified property element if needed.
- */
- private void addModified() {
+ /**
+ * Add modified property element if needed.
+ */
+ private void addModified() {
setElementTextContent(KEYWORD_MODIFIED, namespaceDcTerms, propsPart.getModifiedProperty(),
propsPart.getModifiedPropertyString(), "dcterms:W3CDTF");
}
- /**
- * Add revision property if needed.
- */
- private void addRevision() {
+ /**
+ * Add revision property if needed.
+ */
+ private void addRevision() {
setElementTextContent(KEYWORD_REVISION, namespaceCoreProperties, propsPart.getRevisionProperty());
- }
+ }
- /**
- * Add subject property if needed.
- */
- private void addSubject() {
+ /**
+ * Add subject property if needed.
+ */
+ private void addSubject() {
setElementTextContent(KEYWORD_SUBJECT, namespaceDC, propsPart.getSubjectProperty());
- }
+ }
- /**
- * Add title property if needed.
- */
- private void addTitle() {
+ /**
+ * Add title property if needed.
+ */
+ private void addTitle() {
setElementTextContent(KEYWORD_TITLE, namespaceDC, propsPart.getTitleProperty());
- }
+ }
- private void addVersion() {
+ private void addVersion() {
setElementTextContent(KEYWORD_VERSION, namespaceCoreProperties, propsPart.getVersionProperty());
- }
-}
+ }
+
+ private static class NamespaceImpl {
+ private final String prefix;
+ private final String namespaceURI;
+
+ NamespaceImpl(String prefix, String namespaceURI) {
+ this.prefix = prefix;
+ this.namespaceURI = namespaceURI;
+ }
+
+ public String getPrefix() { return prefix; }
+
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+ }
+}
\ No newline at end of file
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/openxml4j/util/Nullable.java Sat Oct 6 19:33:27 2018
@@ -17,12 +17,17 @@
package org.apache.poi.openxml4j.util;
+import org.apache.poi.util.Removal;
+
/**
* An immutable object that could be defined as null.
*
* @author Julien Chable
* @version 0.9
+ * @deprecated No longer used in POI code base, use {@link java.util.Optional} instead
*/
+@Removal(version = "4.2")
+@Deprecated
public final class Nullable<E> {
private E value;
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java Sat Oct 6 19:33:27 2018
@@ -150,7 +150,7 @@ import org.w3c.dom.events.EventTarget;
* <p>To use SignatureInfo and its sibling classes, you'll need to have the following libs
* in the classpath:</p>
* <ul>
- * <li>BouncyCastle bcpkix and bcprov (tested against 1.59)</li>
+ * <li>BouncyCastle bcpkix and bcprov (tested against 1.60)</li>
* <li>Apache Santuario "xmlsec" (tested against 2.1.0)</li>
* <li>and slf4j-api (tested against 1.7.25)</li>
* </ul>
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java Sat Oct 6 19:33:27 2018
@@ -34,9 +34,24 @@ public class XDDFBarChartData extends XD
public XDDFBarChartData(CTBarChart chart, Map<Long, XDDFChartAxis> categories,
Map<Long, XDDFValueAxis> values) {
this.chart = chart;
+ if (chart.getBarDir() == null) {
+ chart.addNewBarDir().setVal(BarDirection.BAR.underlying);
+ }
for (CTBarSer series : chart.getSerList()) {
this.series.add(new Series(series, series.getCat(), series.getVal()));
}
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
defineAxes(chart.getAxIdArray(), categories, values);
}
@@ -94,6 +109,7 @@ public class XDDFBarChartData extends XD
XDDFNumericalDataSource<? extends Number> values) {
final int index = this.series.size();
final CTBarSer ctSer = this.chart.addNewSer();
+ ctSer.addNewTx();
ctSer.addNewCat();
ctSer.addNewVal();
ctSer.addNewIdx().setVal(index);
@@ -119,7 +135,11 @@ public class XDDFBarChartData extends XD
@Override
protected CTSerTx getSeriesText() {
- return series.getTx();
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
}
@Override
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryAxis.java Sat Oct 6 19:33:27 2018
@@ -79,6 +79,19 @@ public class XDDFCategoryAxis extends XD
return new XDDFShapeProperties(properties);
}
+ /**
+ * @since 4.0.1
+ */
+ @Override
+ public void setTitle(String text) {
+ if (!ctCatAx.isSetTitle()) {
+ ctCatAx.addNewTitle();
+ }
+ XDDFTitle title = new XDDFTitle(null, ctCatAx.getTitle());
+ title.setOverlay(false);
+ title.setText(text);
+ }
+
@Override
public boolean isSetMinorUnit() {
return false;
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFCategoryDataSource.java Sat Oct 6 19:33:27 2018
@@ -23,4 +23,23 @@ import org.apache.poi.util.Beta;
@Beta
public interface XDDFCategoryDataSource extends XDDFDataSource<String> {
+ @Override
+ default int getColIndex() {
+ return 0;
+ }
+
+ @Override
+ default boolean isNumeric() {
+ return false;
+ }
+
+ @Override
+ default boolean isReference() {
+ return true;
+ }
+
+ @Override
+ default String getDataRangeReference() {
+ return getFormula();
+ }
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java Sat Oct 6 19:33:27 2018
@@ -70,7 +70,6 @@ import org.openxmlformats.schemas.drawin
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTTx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
@@ -215,6 +214,72 @@ public abstract class XDDFChart extends
}
/**
+ * @since 4.0.1
+ *
+ */
+ public void displayBlanksAs(DisplayBlanks as) {
+ if (as == null){
+ if (chart.isSetDispBlanksAs()) {
+ chart.unsetDispBlanksAs();
+ }
+ } else {
+ if (chart.isSetDispBlanksAs()) {
+ chart.getDispBlanksAs().setVal(as.underlying);
+ } else {
+ chart.addNewDispBlanksAs().setVal(as.underlying);
+ }
+ }
+ }
+
+ /**
+ * @since 4.0.1
+ */
+ public Boolean getTitleOverlay() {
+ if (chart.isSetTitle()) {
+ CTTitle title = chart.getTitle();
+ if (title.isSetOverlay()) {
+ return title.getOverlay().getVal();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @since 4.0.1
+ */
+ public void setTitleOverlay(boolean overlay) {
+ if (!chart.isSetTitle()) {
+ chart.addNewTitle();
+ }
+ new XDDFTitle(this, chart.getTitle()).setOverlay(overlay);
+ }
+
+ /**
+ * Sets the title text as a static string.
+ *
+ * @param text
+ * to use as new title
+ * @since 4.0.1
+ */
+ public void setTitleText(String text) {
+ if (!chart.isSetTitle()) {
+ chart.addNewTitle();
+ }
+ new XDDFTitle(this, chart.getTitle()).setText(text);
+ }
+
+ /**
+ * @since 4.0.1
+ */
+ public XDDFTitle getTitle() {
+ if (chart.isSetTitle()) {
+ return new XDDFTitle(this, chart.getTitle());
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Get the chart title body if there is one, i.e. title is set and is not a
* formula.
*
@@ -225,15 +290,7 @@ public abstract class XDDFChart extends
if (!chart.isSetTitle()) {
return null;
}
- CTTitle title = chart.getTitle();
- if (!title.isSetTx()) {
- return null;
- }
- CTTx tx = title.getTx();
- if (!tx.isSetRich()) {
- return null;
- }
- return new XDDFTextBody(this, tx.getRich());
+ return new XDDFTitle(this, chart.getTitle()).getBody();
}
@Override
@@ -327,7 +384,7 @@ public abstract class XDDFChart extends
private Map<Long, XDDFChartAxis> getCategoryAxes() {
CTPlotArea plotArea = getCTPlotArea();
int sizeOfArray = plotArea.sizeOfCatAxArray();
- Map<Long, XDDFChartAxis> axes = new HashMap<Long, XDDFChartAxis>(sizeOfArray);
+ Map<Long, XDDFChartAxis> axes = new HashMap<>(sizeOfArray);
for (int i = 0; i < sizeOfArray; i++) {
CTCatAx category = plotArea.getCatAxArray(i);
axes.put(category.getAxId().getVal(), new XDDFCategoryAxis(category));
@@ -641,20 +698,22 @@ public abstract class XDDFChart extends
}
/**
- * set sheet time in excel file
+ * set sheet title in excel file
*
* @param title
* title of sheet
+ * @param column
+ * column index
* @return return cell reference
* @since POI 4.0.0
*/
- public CellReference setSheetTitle(String title) {
+ public CellReference setSheetTitle(String title, int column) {
XSSFSheet sheet = getSheet();
XSSFRow row = this.getRow(sheet, 0);
- XSSFCell cell = this.getCell(row, 1);
+ XSSFCell cell = this.getCell(row, column);
cell.setCellValue(title);
- this.updateSheetTable(sheet.getTables().get(0).getCTTable(), title, 1);
- return new CellReference(sheet.getSheetName(), 0, 1, true, true);
+ this.updateSheetTable(sheet.getTables().get(0).getCTTable(), title, column);
+ return new CellReference(sheet.getSheetName(), 0, column, true, true);
}
/**
@@ -670,12 +729,11 @@ public abstract class XDDFChart extends
private void updateSheetTable(CTTable ctTable, String title, int index) {
CTTableColumns tableColumnList = ctTable.getTableColumns();
CTTableColumn column = null;
- if (tableColumnList.getCount() >= index) {
- column = tableColumnList.getTableColumnArray(index);
- } else {
+ for( int i = 0; tableColumnList.getCount() < index; i++) {
column = tableColumnList.addNewTableColumn();
- column.setId(index);
+ column.setId(i);
}
+ column = tableColumnList.getTableColumnArray(index);
column.setName(title);
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartAxis.java Sat Oct 6 19:33:27 2018
@@ -57,6 +57,11 @@ public abstract class XDDFChartAxis impl
public abstract XDDFShapeProperties getOrAddMinorGridProperties();
/**
+ * @since 4.0.1
+ */
+ public abstract void setTitle(String text);
+
+ /**
* @return true if minor unit value is defined, false otherwise
*/
public abstract boolean isSetMinorUnit();
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java Sat Oct 6 19:33:27 2018
@@ -130,6 +130,10 @@ public abstract class XDDFChartData {
} else {
cache = ref.addNewStrCache();
}
+ if (cache.sizeOfPtArray() < 1) {
+ cache.addNewPtCount().setVal(1);
+ cache.addNewPt().setIdx(0);;
+ }
cache.getPtArray(0).setV(title);
ref.setF(titleRef.formatAsString());
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSource.java Sat Oct 6 19:33:27 2018
@@ -34,4 +34,6 @@ public interface XDDFDataSource<T> {
int getColIndex();
String getDataRangeReference();
+
+ String getFormula();
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDataSourcesFactory.java Sat Oct 6 19:33:27 2018
@@ -41,39 +41,50 @@ public class XDDFDataSourcesFactory {
}
public static XDDFCategoryDataSource fromDataSource(final CTAxDataSource categoryDS) {
- return new XDDFCategoryDataSource() {
- private CTStrData category = (CTStrData) categoryDS.getStrRef().getStrCache().copy();
-
- @Override
- public boolean isNumeric() {
- return false;
- }
-
- @Override
- public boolean isReference() {
- return true;
- }
-
- @Override
- public int getPointCount() {
- return (int) category.getPtCount().getVal();
- }
-
- @Override
- public String getPointAt(int index) {
- return category.getPtArray(index).getV();
- }
-
- @Override
- public String getDataRangeReference() {
- return categoryDS.getStrRef().getF();
- }
-
- @Override
- public int getColIndex() {
- return 0;
- }
- };
+ if (categoryDS.getStrRef() == null) {
+ return new XDDFCategoryDataSource() {
+ private CTNumData category = (CTNumData) categoryDS.getNumRef().getNumCache().copy();
+
+ @Override
+ public boolean isNumeric() {
+ return true;
+ }
+
+ @Override
+ public String getFormula() {
+ return categoryDS.getNumRef().getF();
+ }
+
+ @Override
+ public int getPointCount() {
+ return (int) category.getPtCount().getVal();
+ }
+
+ @Override
+ public String getPointAt(int index) {
+ return category.getPtArray(index).getV();
+ }
+ };
+ } else {
+ return new XDDFCategoryDataSource() {
+ private CTStrData category = (CTStrData) categoryDS.getStrRef().getStrCache().copy();
+
+ @Override
+ public String getFormula() {
+ return categoryDS.getStrRef().getF();
+ }
+
+ @Override
+ public int getPointCount() {
+ return (int) category.getPtCount().getVal();
+ }
+
+ @Override
+ public String getPointAt(int index) {
+ return category.getPtArray(index).getV();
+ }
+ };
+ }
}
public static XDDFNumericalDataSource<Double> fromDataSource(final CTNumDataSource valuesDS) {
@@ -82,6 +93,11 @@ public class XDDFDataSourcesFactory {
private String formatCode = values.isSetFormatCode() ? values.getFormatCode() : null;
@Override
+ public String getFormula() {
+ return valuesDS.getNumRef().getF();
+ }
+
+ @Override
public String getFormatCode() {
return formatCode;
}
@@ -124,7 +140,7 @@ public class XDDFDataSourcesFactory {
}
public static <T extends Number> XDDFNumericalDataSource<T> fromArray(T[] elements, String dataRange) {
- return new NumericalArrayDataSource<T>(elements, dataRange);
+ return new NumericalArrayDataSource<>(elements, dataRange);
}
public static XDDFCategoryDataSource fromArray(String[] elements, String dataRange) {
@@ -132,7 +148,7 @@ public class XDDFDataSourcesFactory {
}
public static <T extends Number> XDDFNumericalDataSource<T> fromArray(T[] elements, String dataRange, int col) {
- return new NumericalArrayDataSource<T>(elements, dataRange, col);
+ return new NumericalArrayDataSource<>(elements, dataRange, col);
}
public static XDDFCategoryDataSource fromArray(String[] elements, String dataRange, int col) {
@@ -213,6 +229,11 @@ public class XDDFDataSourcesFactory {
}
@Override
+ public String getFormula() {
+ return getDataRangeReference();
+ }
+
+ @Override
public String getFormatCode() {
return formatCode;
}
@@ -232,6 +253,11 @@ public class XDDFDataSourcesFactory {
public StringArrayDataSource(String[] elements, String dataRange, int col) {
super(elements, dataRange, col);
}
+
+ @Override
+ public String getFormula() {
+ return getDataRangeReference();
+ }
}
private abstract static class AbstractCellRangeDataSource<T> implements XDDFDataSource<T> {
@@ -290,6 +316,11 @@ public class XDDFDataSourcesFactory {
super(sheet, cellRangeAddress);
}
+ @Override
+ public String getFormula() {
+ return getDataRangeReference();
+ }
+
private String formatCode;
@Override
@@ -325,6 +356,11 @@ public class XDDFDataSourcesFactory {
}
@Override
+ public String getFormula() {
+ return getDataRangeReference();
+ }
+
+ @Override
public String getPointAt(int index) {
CellValue cellValue = getCellValueAt(index);
if (cellValue != null && cellValue.getCellType() == CellType.STRING) {
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFDateAxis.java Sat Oct 6 19:33:27 2018
@@ -82,6 +82,19 @@ public class XDDFDateAxis extends XDDFCh
return new XDDFShapeProperties(properties);
}
+ /**
+ * @since 4.0.1
+ */
+ @Override
+ public void setTitle(String text) {
+ if (!ctDateAx.isSetTitle()) {
+ ctDateAx.addNewTitle();
+ }
+ XDDFTitle title = new XDDFTitle(null, ctDateAx.getTitle());
+ title.setOverlay(false);
+ title.setText(text);
+ }
+
@Override
public boolean isSetMinorUnit() {
return ctDateAx.isSetMinorUnit();
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java Sat Oct 6 19:33:27 2018
@@ -38,6 +38,18 @@ public class XDDFLineChartData extends X
for (CTLineSer series : chart.getSerList()) {
this.series.add(new Series(series, series.getCat(), series.getVal()));
}
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
defineAxes(chart.getAxIdArray(), categories, values);
}
@@ -88,7 +100,11 @@ public class XDDFLineChartData extends X
@Override
protected CTSerTx getSeriesText() {
- return series.getTx();
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
}
@Override
@@ -127,7 +143,44 @@ public class XDDFLineChartData extends X
}
}
+ /**
+ * @since 4.0.1
+ */
+ public Boolean getSmooth() {
+ if (series.isSetSmooth()) {
+ return series.getSmooth().getVal();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @param smooth
+ * whether or not to smooth lines, if <code>null</code> then reverts to default.
+ * @since 4.0.1
+ */
+ public void setSmooth(Boolean smooth) {
+ if (smooth == null) {
+ if (series.isSetSmooth()) {
+ series.unsetSmooth();
+ }
+ } else {
+ if (series.isSetSmooth()) {
+ series.getSmooth().setVal(smooth);
+ } else {
+ series.addNewSmooth().setVal(smooth);
+ }
+ }
+ }
+
+ /**
+ * @param size
+ * <dl><dt>Minimum inclusive:</dt><dd>2</dd><dt>Maximum inclusive:</dt><dd>72</dd></dl>
+ */
public void setMarkerSize(short size) {
+ if (size < 2 || 72 < size) {
+ throw new IllegalArgumentException("Minimum inclusive: 2; Maximum inclusive: 72");
+ }
CTMarker marker = getMarker();
if (marker.isSetSize()) {
marker.getSize().setVal(size);
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java Sat Oct 6 19:33:27 2018
@@ -75,7 +75,11 @@ public class XDDFPieChartData extends XD
@Override
protected CTSerTx getSeriesText() {
- return series.getTx();
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
}
@Override
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java Sat Oct 6 19:33:27 2018
@@ -38,6 +38,18 @@ public class XDDFRadarChartData extends
for (CTRadarSer series : chart.getSerList()) {
this.series.add(new Series(series, series.getCat(), series.getVal()));
}
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
defineAxes(chart.getAxIdArray(), categories, values);
}
@@ -92,7 +104,11 @@ public class XDDFRadarChartData extends
@Override
protected CTSerTx getSeriesText() {
- return series.getTx();
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
}
@Override
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java Sat Oct 6 19:33:27 2018
@@ -22,6 +22,7 @@ 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.CTMarker;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer;
@@ -38,6 +39,18 @@ public class XDDFScatterChartData extend
for (CTScatterSer series : chart.getSerList()) {
this.series.add(new Series(series, series.getXVal(), series.getYVal()));
}
+ defineAxes(categories, values);
+ }
+
+ private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+ if (chart.sizeOfAxIdArray() == 0) {
+ for (Long id : categories.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ for (Long id : values.keySet()) {
+ chart.addNewAxId().setVal(id);
+ }
+ }
defineAxes(chart.getAxIdArray(), categories, values);
}
@@ -96,7 +109,78 @@ public class XDDFScatterChartData extend
@Override
protected CTSerTx getSeriesText() {
- return series.getTx();
+ if (series.isSetTx()) {
+ return series.getTx();
+ } else {
+ return series.addNewTx();
+ }
+ }
+
+ /**
+ * @since 4.0.1
+ */
+ public Boolean getSmooth() {
+ if (series.isSetSmooth()) {
+ return series.getSmooth().getVal();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @param smooth
+ * whether or not to smooth lines, if <code>null</code> then reverts to default.
+ * @since 4.0.1
+ */
+ public void setSmooth(Boolean smooth) {
+ if (smooth == null) {
+ if (series.isSetSmooth()) {
+ series.unsetSmooth();
+ }
+ } else {
+ if (series.isSetSmooth()) {
+ series.getSmooth().setVal(smooth);
+ } else {
+ series.addNewSmooth().setVal(smooth);
+ }
+ }
+ }
+
+ /**
+ * @param size
+ * <dl><dt>Minimum inclusive:</dt><dd>2</dd><dt>Maximum inclusive:</dt><dd>72</dd></dl>
+ * @since 4.0.1
+ */
+ public void setMarkerSize(short size) {
+ if (size < 2 || 72 < size) {
+ throw new IllegalArgumentException("Minimum inclusive: 2; Maximum inclusive: 72");
+ }
+ CTMarker marker = getMarker();
+ if (marker.isSetSize()) {
+ marker.getSize().setVal(size);
+ } else {
+ marker.addNewSize().setVal(size);
+ }
+ }
+
+ /**
+ * @since 4.0.1
+ */
+ public void setMarkerStyle(MarkerStyle style) {
+ CTMarker marker = getMarker();
+ if (marker.isSetSymbol()) {
+ marker.getSymbol().setVal(style.underlying);
+ } else {
+ marker.addNewSymbol().setVal(style.underlying);
+ }
+ }
+
+ private CTMarker getMarker() {
+ if (series.isSetMarker()) {
+ return series.getMarker();
+ } else {
+ return series.addNewMarker();
+ }
}
@Override
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSeriesAxis.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSeriesAxis.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSeriesAxis.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSeriesAxis.java Sat Oct 6 19:33:27 2018
@@ -79,6 +79,19 @@ public class XDDFSeriesAxis extends XDDF
return new XDDFShapeProperties(properties);
}
+ /**
+ * @since 4.0.1
+ */
+ @Override
+ public void setTitle(String text) {
+ if (!ctSerAx.isSetTitle()) {
+ ctSerAx.addNewTitle();
+ }
+ XDDFTitle title = new XDDFTitle(null, ctSerAx.getTitle());
+ title.setOverlay(false);
+ title.setText(text);
+ }
+
@Override
public boolean isSetMinorUnit() {
return false;
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFValueAxis.java Sat Oct 6 19:33:27 2018
@@ -78,6 +78,19 @@ public class XDDFValueAxis extends XDDFC
return new XDDFShapeProperties(properties);
}
+ /**
+ * @since 4.0.1
+ */
+ @Override
+ public void setTitle(String text) {
+ if (!ctValAx.isSetTitle()) {
+ ctValAx.addNewTitle();
+ }
+ XDDFTitle title = new XDDFTitle(null, ctValAx.getTitle());
+ title.setOverlay(false);
+ title.setText(text);
+ }
+
@Override
public boolean isSetMinorUnit() {
return ctValAx.isSetMinorUnit();
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java Sat Oct 6 19:33:27 2018
@@ -67,6 +67,16 @@ public class XDDFParagraphProperties {
}
}
+ /**
+ * @since 4.0.1
+ */
+ public XDDFRunProperties addDefaultRunProperties() {
+ if (!props.isSetDefRPr()) {
+ props.addNewDefRPr();
+ }
+ return getDefaultRunProperties();
+ }
+
public XDDFRunProperties getDefaultRunProperties() {
if (props.isSetDefRPr()) {
return new XDDFRunProperties(props.getDefRPr());
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java Sat Oct 6 19:33:27 2018
@@ -70,6 +70,19 @@ public class XDDFTextBody {
return p;
}
+ public void setText(String text) {
+ if (_body.sizeOfPArray() > 0) {
+ // remove all but first paragraph
+ for (int i = _body.sizeOfPArray() - 1; i > 0; i--) {
+ _body.removeP(i);
+ }
+ getParagraph(0).setText(text);
+ } else {
+ // as there were no paragraphs yet, initialize the text body
+ initialize().setText(text);
+ }
+ }
+
public XDDFTextParagraph addNewParagraph() {
return new XDDFTextParagraph(_body.addNewP(), this);
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java Sat Oct 6 19:33:27 2018
@@ -69,6 +69,24 @@ public class XDDFTextParagraph {
_runs.add(new XDDFTextRun((CTRegularTextRun) xo, this));
}
}
+
+ addDefaultRunProperties();
+ addAfterLastRunProperties();
+ }
+
+ public void setText(String text) {
+ // remove all runs
+ for (int i = _p.sizeOfBrArray() - 1; i >= 0; i--) {
+ _p.removeBr(i);
+ }
+ for (int i = _p.sizeOfFldArray() - 1; i >= 0; i--) {
+ _p.removeFld(i);
+ }
+ for (int i = _p.sizeOfRArray() - 1; i >= 0; i--) {
+ _p.removeR(i);
+ }
+ _runs.clear();
+ appendRegularRun(text);
}
public String getText() {
@@ -662,6 +680,13 @@ public class XDDFTextParagraph {
}
}
+ /**
+ * @since 4.0.1
+ */
+ public XDDFRunProperties addDefaultRunProperties() {
+ return getOrCreateProperties().addDefaultRunProperties();
+ }
+
public XDDFRunProperties getDefaultRunProperties() {
if (_p.isSetPPr()) {
return getProperties().getDefaultRunProperties();
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java Sat Oct 6 19:33:27 2018
@@ -372,8 +372,8 @@ public class XMLSlideShow extends POIXML
}
if (!themeIndexList.isEmpty()) {
- Boolean found = false;
- for (Integer i = 1; i <= themeIndexList.size(); i++) {
+ boolean found = false;
+ for (int i = 1; i <= themeIndexList.size(); i++) {
if (!themeIndexList.contains(i)) {
found = true;
themeIndex = i;
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java Sat Oct 6 19:33:27 2018
@@ -77,7 +77,20 @@ public class XSLFBackground extends XSLF
public void setFillColor(Color color) {
CTBackgroundProperties bgPr = getBgPr(true);
-
+
+ if (bgPr.isSetBlipFill()) {
+ bgPr.unsetBlipFill();
+ }
+ if (bgPr.isSetGradFill()) {
+ bgPr.unsetGradFill();
+ }
+ if (bgPr.isSetGrpFill()) {
+ bgPr.unsetGrpFill();
+ }
+ if (bgPr.isSetPattFill()) {
+ bgPr.unsetPattFill();
+ }
+
if (color == null) {
if (bgPr.isSetSolidFill()) {
bgPr.unsetSolidFill();
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFChart.java Sat Oct 6 19:33:27 2018
@@ -69,7 +69,7 @@ public final class XSLFChart extends XDD
return XSLFFactory.getInstance();
}
- public XSLFTextShape getTitle() {
+ public XSLFTextShape getTitleShape() {
if (!chart.isSetTitle()) {
chart.addNewTitle();
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java Sat Oct 6 19:33:27 2018
@@ -153,7 +153,7 @@ public class XSLFColor {
colorRef = _phClr.getVal().toString();
}
// find referenced CTColor in the theme and convert it to java.awt.Color via a recursive call
- CTColor ctColor = theme.getCTColor(colorRef);
+ CTColor ctColor = theme == null ? null : theme.getCTColor(colorRef);
if(ctColor != null) {
color = toColor(ctColor, null);
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Sat Oct 6 19:33:27 2018
@@ -692,10 +692,24 @@ implements XSLFShapeContainer, Sheet<XSL
/**
* Helper method for sheet and group shapes
*
- * @param pictureShape the picture shapes whose relation is to be removed
+ * @param pictureShape the picture shapes whose relation is to be removed,
+ * only if there are no more relations on its sheet to that picture
*/
void removePictureRelation(XSLFPictureShape pictureShape) {
- removeRelation(pictureShape.getBlipId());
+ int numberOfRelations = 0;
+ String targetBlipId = pictureShape.getBlipId();
+ for (XSLFShape shape : pictureShape.getSheet().getShapes()) {
+ if (shape instanceof XSLFPictureShape) {
+ XSLFPictureShape currentPictureShape = ((XSLFPictureShape) shape);
+ String currentBlipId = currentPictureShape.getBlipId();
+ if (currentBlipId != null && currentBlipId.equals(targetBlipId)) {
+ numberOfRelations++;
+ }
+ }
+ }
+ if (numberOfRelations <= 1) {
+ removeRelation(pictureShape.getBlipId());
+ }
}
Modified: poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
URL: http://svn.apache.org/viewvc/poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java?rev=1843032&r1=1843031&r2=1843032&view=diff
==============================================================================
--- poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java (original)
+++ poi/branches/hemf/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java Sat Oct 6 19:33:27 2018
@@ -98,7 +98,7 @@ public class StylesTable extends POIXMLD
if (num < 0) {
throw new IllegalArgumentException("Maximum Number of Data Formats must be greater than or equal to 0");
} else {
- throw new IllegalStateException("Cannot set the maximum number of data formats less than the current quantity." +
+ throw new IllegalStateException("Cannot set the maximum number of data formats less than the current quantity. " +
"Data formats must be explicitly removed (via StylesTable.removeNumberFormat) before the limit can be decreased.");
}
}
@@ -316,7 +316,7 @@ public class StylesTable extends POIXMLD
short nextKey = (short) (numberFormats.lastKey() + 1);
if (nextKey < 0) {
throw new IllegalStateException(
- "Cowardly avoiding creating a number format with a negative id." +
+ "Cowardly avoiding creating a number format with a negative id. " +
"This is probably due to arithmetic overflow.");
}
formatIndex = (short) Math.max(nextKey, FIRST_USER_DEFINED_NUMBER_FORMAT_ID);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org