import java.util.Map.Entry;
import java.util.TreeMap;
+import org.apache.poi.ooxml.util.DocumentHelper;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
-import org.apache.poi.openxml4j.opc.*;
-import org.apache.poi.ooxml.util.DocumentHelper;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageNamespaces;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackagePartName;
+import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
boolean defaultCTExists = this.defaultContentType.containsValue(contentType);
String extension = partName.getExtension().toLowerCase(Locale.ROOT);
if ((extension.length() == 0)
- || (this.defaultContentType.containsKey(extension) && !defaultCTExists))
+ || (this.defaultContentType.containsKey(extension) && !defaultCTExists)) {
this.addOverrideContentType(partName, contentType);
- else if (!defaultCTExists)
+ } else if (!defaultCTExists) {
this.addDefaultContentType(extension, contentType);
+ }
}
/**
*/
private void addOverrideContentType(PackagePartName partName,
String contentType) {
- if (overrideContentType == null)
+ if (overrideContentType == null) {
overrideContentType = new TreeMap<>();
+ }
overrideContentType.put(partName, contentType);
}
*/
public void removeContentType(PackagePartName partName)
throws InvalidOperationException {
- if (partName == null)
+ if (partName == null) {
throw new IllegalArgumentException("partName");
+ }
/* Override content type */
if (this.overrideContentType != null
try {
for (PackagePart part : this.container.getParts()) {
if (!part.getPartName().equals(partName)
- && this.getContentType(part.getPartName()) == null)
+ && this.getContentType(part.getPartName()) == null) {
throw new InvalidOperationException(
"Rule M2.4 is not respected: Nor a default element or override element is associated with the part: "
+ part.getPartName().getName());
+ }
}
} catch (InvalidFormatException e) {
throw new InvalidOperationException(e.getMessage());
* register, then <code>false</code>.
*/
public boolean isContentTypeRegister(String contentType) {
- if (contentType == null)
+ if (contentType == null) {
throw new IllegalArgumentException("contentType");
+ }
return (this.defaultContentType.values().contains(contentType) || (this.overrideContentType != null && this.overrideContentType
.values().contains(contentType)));
* content from an existing part.
*/
public String getContentType(PackagePartName partName) {
- if (partName == null)
+ if (partName == null) {
throw new IllegalArgumentException("partName");
+ }
if ((this.overrideContentType != null)
- && this.overrideContentType.containsKey(partName))
+ && this.overrideContentType.containsKey(partName)) {
return this.overrideContentType.get(partName);
+ }
String extension = partName.getExtension().toLowerCase(Locale.ROOT);
- if (this.defaultContentType.containsKey(extension))
+ if (this.defaultContentType.containsKey(extension)) {
return this.defaultContentType.get(extension);
+ }
/*
* [M2.4] : The package implementer shall require that the Content Types
*/
if (this.container != null && this.container.getPart(partName) != null) {
throw new OpenXML4JRuntimeException(
- "Rule M2.4 exception : this error should NEVER happen!\n"
- + "Check that your code is closing the open resources in the correct order prior to filing a bug report.\n"
- + "If you can provide the triggering file, then please raise a bug at https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach the file that triggers it, thanks!");
+ "Rule M2.4 exception : Part \'"
+ + partName
+ + "\' not found - this error should NEVER happen!\n"
+ + "Check that your code is closing the open resources in the correct order prior to filing a bug report.\n"
+ + "If you can provide the triggering file, then please raise a bug at https://bz.apache.org/bugzilla/enter_bug.cgi?product=POI and attach the file that triggers it, thanks!");
}
return null;
}
*/
public void clearAll() {
this.defaultContentType.clear();
- if (this.overrideContentType != null)
+ if (this.overrideContentType != null) {
this.overrideContentType.clear();
+ }
}
/**
*
*/
public void clearOverrideContentTypes() {
- if (this.overrideContentType != null)
+ if (this.overrideContentType != null) {
this.overrideContentType.clear();
+ }
}
/**
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
import javax.xml.namespace.QName;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.apache.poi.xddf.usermodel.text.TextContainer;
+import org.apache.poi.xddf.usermodel.text.XDDFTextBody;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
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;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumns;
@Beta
-public abstract class XDDFChart extends POIXMLDocumentPart {
+public abstract class XDDFChart extends POIXMLDocumentPart implements TextContainer {
/**
* Underlying workbook
*/
/**
* Construct a DrawingML chart from a package part.
*
- * @param part the package part holding the chart data,
- * the content type must be <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
+ * @param part
+ * the package part holding the chart data, the content type must
+ * be
+ * <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
* @since POI 3.14-Beta1
*/
protected XDDFChart(PackagePart part) throws IOException, XmlException {
}
/**
- * Return the underlying CTChartSpace bean, the root element of the Chart part.
+ * Return the underlying CTChartSpace bean, the root element of the Chart
+ * part.
*
* @return the underlying CTChartSpace bean
*/
}
/**
- * @return true if only visible cells will be present on the chart,
- * false otherwise
+ * @return true if only visible cells will be present on the chart, false
+ * otherwise
*/
public boolean isPlotOnlyVisibleCells() {
if (chart.isSetPlotVisOnly()) {
}
/**
- * @param only a flag specifying if only visible cells should be
- * present on the chart
+ * @param only
+ * a flag specifying if only visible cells should be present on
+ * the chart
*/
public void setPlotOnlyVisibleCells(boolean only) {
if (!chart.isSetPlotVisOnly()) {
chart.getAutoTitleDeleted().setVal(deleted);
}
+ /**
+ * Get the chart title body if there is one, i.e. title is set and is not a
+ * formula.
+ *
+ * @return text body or null, if title is a formula or no title is set.
+ */
+ @Beta
+ public XDDFTextBody getFormattedTitle() {
+ 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());
+ }
+
+ @Override
+ public <R> Optional<R> findDefinedParagraphProperty(Function<CTTextParagraphProperties, Boolean> isSet,
+ Function<CTTextParagraphProperties, R> getter) {
+ // TODO Auto-generated method stub
+ return Optional.empty();
+ }
+
+ @Override
+ public <R> Optional<R> findDefinedRunProperty(Function<CTTextCharacterProperties, Boolean> isSet,
+ Function<CTTextCharacterProperties, R> getter) {
+ // TODO Auto-generated method stub
+ return Optional.empty();
+ }
+
public XDDFShapeProperties getOrAddShapeProperties() {
CTPlotArea plotArea = getCTPlotArea();
CTShapeProperties properties;
Map<Long, XDDFValueAxis> mapValues = Collections.singletonMap(values.getId(), values);
final CTPlotArea plotArea = getCTPlotArea();
switch (type) {
- case BAR:
- return new XDDFBarChartData(plotArea.addNewBarChart(), categories, mapValues);
- case LINE:
- return new XDDFLineChartData(plotArea.addNewLineChart(), categories, mapValues);
- case PIE:
- return new XDDFPieChartData(plotArea.addNewPieChart());
- case RADAR:
- return new XDDFRadarChartData(plotArea.addNewRadarChart(), categories, mapValues);
- case SCATTER:
- return new XDDFScatterChartData(plotArea.addNewScatterChart(), categories, mapValues);
- default:
- return null;
+ case BAR:
+ return new XDDFBarChartData(plotArea.addNewBarChart(), categories, mapValues);
+ case LINE:
+ return new XDDFLineChartData(plotArea.addNewLineChart(), categories, mapValues);
+ case PIE:
+ return new XDDFPieChartData(plotArea.addNewPieChart());
+ case RADAR:
+ return new XDDFRadarChartData(plotArea.addNewRadarChart(), categories, mapValues);
+ case SCATTER:
+ return new XDDFScatterChartData(plotArea.addNewScatterChart(), categories, mapValues);
+ default:
+ return null;
}
}
private boolean hasAxes() {
CTPlotArea ctPlotArea = chart.getPlotArea();
- int totalAxisCount = ctPlotArea.sizeOfValAxArray() + ctPlotArea.sizeOfCatAxArray() + ctPlotArea.sizeOfDateAxArray() + ctPlotArea.sizeOfSerAxArray();
+ int totalAxisCount = ctPlotArea.sizeOfValAxArray() + ctPlotArea.sizeOfCatAxArray() + ctPlotArea
+ .sizeOfDateAxArray() + ctPlotArea.sizeOfSerAxArray();
return totalAxisCount > 0;
}
/**
* Set value range (basic Axis Options)
- * @param axisIndex 0 - primary axis, 1 - secondary axis
- * @param minimum minimum value; Double.NaN - automatic; null - no change
- * @param maximum maximum value; Double.NaN - automatic; null - no change
- * @param majorUnit major unit value; Double.NaN - automatic; null - no change
- * @param minorUnit minor unit value; Double.NaN - automatic; null - no change
+ *
+ * @param axisIndex
+ * 0 - primary axis, 1 - secondary axis
+ * @param minimum
+ * minimum value; Double.NaN - automatic; null - no change
+ * @param maximum
+ * maximum value; Double.NaN - automatic; null - no change
+ * @param majorUnit
+ * major unit value; Double.NaN - automatic; null - no change
+ * @param minorUnit
+ * minor unit value; Double.NaN - automatic; null - no change
*/
public void setValueRange(int axisIndex, Double minimum, Double maximum, Double majorUnit, Double minorUnit) {
XDDFChartAxis axis = getAxes().get(axisIndex);
}
/**
- * method to create relationship with embedded part
- * for example writing xlsx file stream into output stream
+ * method to create relationship with embedded part for example writing xlsx
+ * file stream into output stream
*
- * @param chartRelation relationship object
- * @param chartFactory ChartFactory object
- * @param chartIndex index used to suffix on file
- * @return return relation part which used to write relation in .rels file and get relation id
+ * @param chartRelation
+ * relationship object
+ * @param chartFactory
+ * ChartFactory object
+ * @param chartIndex
+ * index used to suffix on file
+ * @return return relation part which used to write relation in .rels file
+ * and get relation id
* @since POI 4.0.0
*/
- public PackageRelationship createRelationshipInChart(POIXMLRelation chartRelation, POIXMLFactory chartFactory, int chartIndex) {
+ public PackageRelationship createRelationshipInChart(POIXMLRelation chartRelation, POIXMLFactory chartFactory,
+ int chartIndex) {
documentPart = createRelationship(chartRelation, chartFactory, chartIndex, true).getDocumentPart();
return this.addRelation(null, chartRelation, documentPart).getRelationship();
}
/**
* if embedded part was null then create new part
*
- * @param chartRelation chart relation object
- * @param chartWorkbookRelation chart workbook relation object
- * @param chartFactory factory object of POIXMLFactory (XWPFFactory/XSLFFactory)
+ * @param chartRelation
+ * chart relation object
+ * @param chartWorkbookRelation
+ * chart workbook relation object
+ * @param chartFactory
+ * factory object of POIXMLFactory (XWPFFactory/XSLFFactory)
* @return return the new package part
* @throws InvalidFormatException
* @since POI 4.0.0
*/
- private PackagePart createWorksheetPart(POIXMLRelation chartRelation, POIXMLRelation chartWorkbookRelation, POIXMLFactory chartFactory) throws InvalidFormatException {
+ private PackagePart createWorksheetPart(POIXMLRelation chartRelation, POIXMLRelation chartWorkbookRelation,
+ POIXMLFactory chartFactory) throws InvalidFormatException {
PackageRelationship xlsx = createRelationshipInChart(chartWorkbookRelation, chartFactory, chartIndex);
this.setExternalId(xlsx.getId());
return getTargetPart(xlsx);
/**
* this method write the XSSFWorkbook object data into embedded excel file
*
- * @param workbook XSSFworkbook object
+ * @param workbook
+ * XSSFworkbook object
* @throws IOException
* @throws InvalidFormatException
* @since POI 4.0.0
POIXMLRelation chartRelation = getChartRelation();
POIXMLRelation chartWorkbookRelation = getChartWorkbookRelation();
POIXMLFactory chartFactory = getChartFactory();
- if (chartRelation != null
- && chartWorkbookRelation != null
- && chartFactory != null) {
+ if (chartRelation != null && chartWorkbookRelation != null && chartFactory != null) {
worksheetPart = createWorksheetPart(chartRelation, chartWorkbookRelation, chartFactory);
} else {
throw new InvalidFormatException("unable to determine chart relations");
/**
* this method writes the data into sheet
*
- * @param sheet sheet of embedded excel
- * @param categoryData category values
- * @param valuesData data values
+ * @param sheet
+ * sheet of embedded excel
+ * @param categoryData
+ * category values
+ * @param valuesData
+ * data values
* @since POI 4.0.0
*/
protected void fillSheet(XSSFSheet sheet, XDDFDataSource<?> categoryData, XDDFNumericalDataSource<?> valuesData) {
}
/**
- * this method return row on given index
- * if row is null then create new row
+ * this method return row on given index if row is null then create new row
*
- * @param sheet current sheet object
- * @param index index of current row
+ * @param sheet
+ * current sheet object
+ * @param index
+ * index of current row
* @return this method return sheet row on given index
* @since POI 4.0.0
*/
- private XSSFRow getRow(XSSFSheet sheet,int index){
+ private XSSFRow getRow(XSSFSheet sheet, int index) {
if (sheet.getRow(index) != null) {
return sheet.getRow(index);
} else {
}
/**
- * this method return cell on given index
- * if cell is null then create new cell
+ * this method return cell on given index if cell is null then create new
+ * cell
*
- * @param row current row object
- * @param index index of current cell
+ * @param row
+ * current row object
+ * @param index
+ * index of current cell
* @return this method return sheet cell on given index
* @since POI 4.0.0
*/
- private XSSFCell getCell(XSSFRow row,int index){
+ private XSSFCell getCell(XSSFRow row, int index) {
if (row.getCell(index) != null) {
return row.getCell(index);
} else {
/**
* import content from other chart to created chart
*
- * @param other chart object
+ * @param other
+ * chart object
* @since POI 4.0.0
*/
public void importContent(XDDFChart other) {
@Override
protected void commit() throws IOException {
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
- xmlOptions.setSaveSyntheticDocumentElement(new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c"));
+ xmlOptions.setSaveSyntheticDocumentElement(
+ new QName(CTChartSpace.type.getName().getNamespaceURI(), "chartSpace", "c"));
if (workbook != null) {
try {
/**
* set sheet time in excel file
*
- * @param title title of sheet
+ * @param title
+ * title of sheet
* @return return cell reference
* @since POI 4.0.0
*/
/**
* this method update column header of sheet into table
*
- * @param ctTable xssf table object
- * @param title title of column
- * @param index index of column
+ * @param ctTable
+ * xssf table object
+ * @param title
+ * title of column
+ * @param index
+ * index of column
*/
private void updateSheetTable(CTTable ctTable, String title, int index) {
CTTableColumns tableColumnList = ctTable.getTableColumns();
CTTableColumn column = null;
- if(tableColumnList.getCount() >= index) {
+ if (tableColumnList.getCount() >= index) {
column = tableColumnList.getTableColumnArray(index);
- }
- else {
- column = tableColumnList.addNewTableColumn();
+ } else {
+ column = tableColumnList.addNewTableColumn();
column.setId(index);
}
column.setName(title);
}
/**
- * this method is used to get worksheet part
- * if call is from saveworkbook method then check isCommitted
- * isCommitted variable shows that we are writing xssfworkbook object into output stream of embedded part
+ * this method is used to get worksheet part if call is from saveworkbook
+ * method then check isCommitted isCommitted variable shows that we are
+ * writing xssfworkbook object into output stream of embedded part
*
* @return returns the packagepart of embedded file
* @throws InvalidFormatException
}
/**
- * while reading chart from template file then we need to parse and store embedded excel
- * file in chart object show that we can modify value according to use
+ * while reading chart from template file then we need to parse and store
+ * embedded excel file in chart object show that we can modify value
+ * according to use
*
- * @param workbook workbook object which we read from chart embedded part
+ * @param workbook
+ * workbook object which we read from chart embedded part
* @since POI 4.0.0
*/
public void setWorkbook(XSSFWorkbook workbook) {
}
/**
- * set the relation id of embedded excel relation id into external data relation tag
+ * set the relation id of embedded excel relation id into external data
+ * relation tag
*
- * @param id relation id of embedded excel relation id into external data relation tag
+ * @param id
+ * relation id of embedded excel relation id into external data
+ * relation tag
* @since POI 4.0.0
*/
public void setExternalId(String id) {
/**
* set chart index which can be use for relation part
*
- * @param chartIndex chart index which can be use for relation part
+ * @param chartIndex
+ * chart index which can be use for relation part
*/
public void setChartIndex(int chartIndex) {
this.chartIndex = chartIndex;
--- /dev/null
+/* ====================================================================
+ 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.text;
+
+import java.util.HashMap;
+
+import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;
+
+public enum AnchorType {
+ BOTTOM(STTextAnchoringType.B),
+ CENTER(STTextAnchoringType.CTR),
+ DISTRIBUTED(STTextAnchoringType.DIST),
+ JUSTIFIED(STTextAnchoringType.JUST),
+ TOP(STTextAnchoringType.T);
+
+ final STTextAnchoringType.Enum underlying;
+
+ AnchorType(STTextAnchoringType.Enum caps) {
+ this.underlying = caps;
+ }
+
+ private final static HashMap<STTextAnchoringType.Enum, AnchorType> reverse = new HashMap<STTextAnchoringType.Enum, AnchorType>();
+ static {
+ for (AnchorType value : values()) {
+ reverse.put(value.underlying, value);
+ }
+ }
+
+ static AnchorType valueOf(STTextAnchoringType.Enum caps) {
+ return reverse.get(caps);
+ }
+}
return props;
}
+ public AnchorType getAnchoring() {
+ if (props.isSetAnchor()) {
+ return AnchorType.valueOf(props.getAnchor());
+ } else {
+ return null;
+ }
+ }
+
+ public void setAnchoring(AnchorType anchor) {
+ if (anchor == null) {
+ if (props.isSetAnchor()) {
+ props.unsetAnchor();
+ }
+ } else {
+ props.setAnchor(anchor.underlying);
+ }
+ }
+
+ public Boolean isAnchorCentered() {
+ if (props.isSetAnchorCtr()) {
+ return props.getAnchorCtr();
+ } else {
+ return null;
+ }
+ }
+
+ public void setAnchorCentered(Boolean centered) {
+ if (centered == null) {
+ if (props.isSetAnchorCtr()) {
+ props.unsetAnchorCtr();
+ }
+ } else {
+ props.setAnchorCtr(centered);
+ }
+ }
+
public XDDFAutoFit getAutoFit() {
if (props.isSetNoAutofit()) {
return new XDDFNoAutoFit(props.getNoAutofit());
} else if (props.isSetSpAutoFit()) {
return new XDDFShapeAutoFit(props.getSpAutoFit());
}
- return new XDDFNoAutoFit();
+ return new XDDFNormalAutoFit();
}
public void setAutoFit(XDDFAutoFit autofit) {
- props.unsetNoAutofit();
- props.unsetNormAutofit();
- props.unsetSpAutoFit();
+ if (props.isSetNoAutofit()) {
+ props.unsetNoAutofit();
+ }
+ if (props.isSetNormAutofit()) {
+ props.unsetNormAutofit();
+ }
+ if (props.isSetSpAutoFit()) {
+ props.unsetSpAutoFit();
+ }
if (autofit instanceof XDDFNoAutoFit) {
props.setNoAutofit(((XDDFNoAutoFit) autofit).getXmlObject());
} else if (autofit instanceof XDDFNormalAutoFit) {
public void setExtensionList(XDDFExtensionList list) {
if (list == null) {
- props.unsetExtLst();
+ if (props.isSetExtLst()) {
+ props.unsetExtLst();
+ }
} else {
props.setExtLst(list.getXmlObject());
}
public void setBottomInset(Double points) {
if (points == null || Double.isNaN(points)) {
- props.unsetBIns();
+ if (props.isSetBIns()) {
+ props.unsetBIns();
+ }
} else {
props.setBIns(Units.toEMU(points));
}
public void setLeftInset(Double points) {
if (points == null || Double.isNaN(points)) {
- props.unsetLIns();
+ if (props.isSetLIns()) {
+ props.unsetLIns();
+ }
} else {
props.setLIns(Units.toEMU(points));
}
public void setRightInset(Double points) {
if (points == null || Double.isNaN(points)) {
- props.unsetRIns();
+ if (props.isSetRIns()) {
+ props.unsetRIns();
+ }
} else {
props.setRIns(Units.toEMU(points));
}
public void setTopInset(Double points) {
if (points == null || Double.isNaN(points)) {
- props.unsetTIns();
+ if (props.isSetTIns()) {
+ props.unsetTIns();
+ }
} else {
props.setTIns(Units.toEMU(points));
}
}
+
+ public Boolean hasParagraphSpacing() {
+ if (props.isSetSpcFirstLastPara()) {
+ return props.getSpcFirstLastPara();
+ } else {
+ return null;
+ }
+ }
+
+ public void setParagraphSpacing(Boolean spacing) {
+ if (spacing == null) {
+ if (props.isSetSpcFirstLastPara()) {
+ props.unsetSpcFirstLastPara();
+ }
+ } else {
+ props.setSpcFirstLastPara(spacing);
+ }
+ }
+
+ public Boolean isRightToLeft() {
+ if (props.isSetRtlCol()) {
+ return props.getRtlCol();
+ } else {
+ return null;
+ }
+ }
+
+ public void setRightToLeft(Boolean rightToLeft) {
+ if (rightToLeft == null) {
+ if (props.isSetRtlCol()) {
+ props.unsetRtlCol();
+ }
+ } else {
+ props.setRtlCol(rightToLeft);
+ }
+ }
}
package org.apache.poi.xddf.usermodel.text;
import org.apache.poi.util.Beta;
-import org.apache.poi.util.Internal;
@Beta
-public abstract class XDDFBulletSize {
- public static enum Kind {
- PERCENT,
- POINTS,
- TEXT;
- }
-
- @Internal
- protected XDDFBulletSize() {
- }
-
- public abstract Kind getType();
+public interface XDDFBulletSize {
}
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizeFollowText;
@Beta
-public class XDDFBulletSizeFollowText extends XDDFBulletSize {
+public class XDDFBulletSizeFollowText implements XDDFBulletSize {
private CTTextBulletSizeFollowText follow;
public XDDFBulletSizeFollowText() {
protected CTTextBulletSizeFollowText getXmlObject() {
return follow;
}
-
- @Override
- public Kind getType() {
- return Kind.TEXT;
- }
}
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePercent;
@Beta
-public class XDDFBulletSizePercent extends XDDFBulletSize {
+public class XDDFBulletSizePercent implements XDDFBulletSize {
private CTTextBulletSizePercent percent;
private Double scale;
return percent;
}
- @Override
- public Kind getType() {
- return Kind.PERCENT;
- }
-
public double getPercent() {
return percent.getVal() * scale;
}
public void setPercent(double value) {
- percent.setVal((int)(1000 * value));
+ percent.setVal((int) (1000 * value));
}
}
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint;
@Beta
-public class XDDFBulletSizePoints extends XDDFBulletSize {
+public class XDDFBulletSizePoints implements XDDFBulletSize {
private CTTextBulletSizePoint points;
public XDDFBulletSizePoints(double value) {
return points;
}
- @Override
- public Kind getType() {
- return Kind.POINTS;
- }
-
public double getPoints() {
return points.getVal() * 0.01;
}
public void setPoints(double value) {
- points.setVal((int)(100 * value));
+ points.setVal((int) (100 * value));
}
}
import org.apache.poi.util.Beta;
@Beta
-public abstract class XDDFBulletStyle {
-
+public interface XDDFBulletStyle {
}
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextAutonumberBullet;
@Beta
-public class XDDFBulletStyleAutoNumbered extends XDDFBulletStyle {
+public class XDDFBulletStyleAutoNumbered implements XDDFBulletStyle {
private CTTextAutonumberBullet style;
@Internal
protected XDDFBulletStyleAutoNumbered(CTTextAutonumberBullet style) {
- this.style =style;
+ this.style = style;
}
@Internal
public void setStartAt(Integer value) {
if (value == null) {
- style.unsetStartAt();
+ if (style.isSetStartAt()) {
+ style.unsetStartAt();
+ }
} else {
style.setStartAt(value);
}
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharBullet;
@Beta
-public class XDDFBulletStyleCharacter extends XDDFBulletStyle {
+public class XDDFBulletStyleCharacter implements XDDFBulletStyle {
private CTTextCharBullet style;
@Internal
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNoBullet;
@Beta
-public class XDDFBulletStyleNone extends XDDFBulletStyle {
+public class XDDFBulletStyleNone implements XDDFBulletStyle {
private CTTextNoBullet style;
@Internal
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBlipBullet;
@Beta
-public class XDDFBulletStylePicture extends XDDFBulletStyle {
+public class XDDFBulletStylePicture implements XDDFBulletStyle {
private CTTextBlipBullet style;
@Internal
public XDDFFont(FontGroup group, String typeface, Byte charset, Byte pitch, byte[] panose) {
this(group, CTTextFont.Factory.newInstance());
if (typeface == null) {
- font.unsetTypeface();
+ if (font.isSetTypeface()) {
+ font.unsetTypeface();
+ }
} else {
font.setTypeface(typeface);
}
if (charset == null) {
- font.unsetCharset();
+ if (font.isSetCharset()) {
+ font.unsetCharset();
+ }
} else {
font.setCharset(charset);
}
if (pitch == null) {
- font.unsetPitchFamily();
+ if (font.isSetPitchFamily()) {
+ font.unsetPitchFamily();
+ }
} else {
font.setPitchFamily(pitch);
}
if (panose == null || panose.length == 0) {
- font.unsetPanose();
+ if (font.isSetPanose()) {
+ font.unsetPanose();
+ }
} else {
font.setPanose(panose);
}
public XDDFHyperlink(String id) {
this(CTHyperlink.Factory.newInstance());
- this.link.setId(id);;
+ this.link.setId(id);
}
public XDDFHyperlink(String id, String action) {
public void setEndSound(Boolean ends) {
if (ends == null) {
- link.unsetEndSnd();
+ if (link.isSetEndSnd()) {
+ link.unsetEndSnd();
+ }
} else {
link.setEndSnd(ends);
}
public void setHighlightClick(Boolean highlights) {
if (highlights == null) {
- link.unsetHighlightClick();
+ if (link.isSetHighlightClick()) {
+ link.unsetHighlightClick();
+ }
} else {
link.setHighlightClick(highlights);
}
}
+
public Boolean getHistory() {
if (link.isSetHistory()) {
return link.getHistory();
public void setHistory(Boolean history) {
if (history == null) {
- link.unsetHistory();
+ if (link.isSetHistory()) {
+ link.unsetHistory();
+ }
} else {
link.setHistory(history);
}
}
-
public String getInvalidURL() {
if (link.isSetInvalidUrl()) {
return link.getInvalidUrl();
public void setInvalidURL(String invalid) {
if (invalid == null) {
- link.unsetInvalidUrl();
+ if (link.isSetInvalidUrl()) {
+ link.unsetInvalidUrl();
+ }
} else {
link.setInvalidUrl(invalid);
}
public void setTargetFrame(String frame) {
if (frame == null) {
- link.unsetTgtFrame();
+ if (link.isSetTgtFrame()) {
+ link.unsetTgtFrame();
+ }
} else {
link.setTgtFrame(frame);
}
public void setTooltip(String tooltip) {
if (tooltip == null) {
- link.unsetTooltip();
+ if (link.isSetTooltip()) {
+ link.unsetTooltip();
+ }
} else {
link.setTooltip(tooltip);
}
public void setExtensionList(XDDFExtensionList list) {
if (list == null) {
- link.unsetExtLst();
+ if (link.isSetExtLst()) {
+ link.unsetExtLst();
+ }
} else {
link.setExtLst(list.getXmlObject());
}
public void setFontScale(Integer value) {
if (value == null) {
- autofit.unsetFontScale();
+ if (autofit.isSetFontScale()) {
+ autofit.unsetFontScale();
+ }
} else {
autofit.setFontScale(value);
}
public void setLineSpaceReduction(Integer value) {
if (value == null) {
- autofit.unsetLnSpcReduction();
+ if (autofit.isSetLnSpcReduction()) {
+ autofit.unsetLnSpcReduction();
+ }
} else {
autofit.setLnSpcReduction(value);
}
}
public void setBulletStyle(XDDFBulletStyle style) {
- props.unsetBuAutoNum();
- props.unsetBuBlip();
- props.unsetBuChar();
- props.unsetBuNone();
+ if (props.isSetBuAutoNum()) {
+ props.unsetBuAutoNum();
+ }
+ if (props.isSetBuBlip()) {
+ props.unsetBuBlip();
+ }
+ if (props.isSetBuChar()) {
+ props.unsetBuChar();
+ }
+ if (props.isSetBuNone()) {
+ props.unsetBuNone();
+ }
if (style != null) {
if (style instanceof XDDFBulletStyleAutoNumbered) {
props.setBuAutoNum(((XDDFBulletStyleAutoNumbered) style).getXmlObject());
}
public void setBulletColor(XDDFColor color) {
- props.unsetBuClrTx();
+ if (props.isSetBuClrTx()) {
+ props.unsetBuClrTx();
+ }
if (color == null) {
- props.unsetBuClr();
+ if (props.isSetBuClr()) {
+ props.unsetBuClr();
+ }
} else {
props.setBuClr(color.getColorContainer());
}
}
public void setBulletColorFollowText() {
- props.unsetBuClr();
+ if (props.isSetBuClr()) {
+ props.unsetBuClr();
+ }
if (props.isSetBuClrTx()) {
// nothing to do: already set
} else {
}
public void setBulletFont(XDDFFont font) {
- props.unsetBuFontTx();
+ if (props.isSetBuFontTx()) {
+ props.unsetBuFontTx();
+ }
if (font == null) {
- props.unsetBuFont();
+ if (props.isSetBuFont()) {
+ props.unsetBuFont();
+ }
} else {
props.setBuFont(font.getXmlObject());
}
}
public void setBulletFontFollowText() {
- props.unsetBuFont();
+ if (props.isSetBuFont()) {
+ props.unsetBuFont();
+ }
if (props.isSetBuFontTx()) {
// nothing to do: already set
} else {
}
public void setBulletSize(XDDFBulletSize size) {
- props.unsetBuSzPct();
- props.unsetBuSzPts();
- props.unsetBuSzTx();
+ if (props.isSetBuSzPct()) {
+ props.unsetBuSzPct();
+ }
+ if (props.isSetBuSzPts()) {
+ props.unsetBuSzPts();
+ }
+ if (props.isSetBuSzTx()) {
+ props.unsetBuSzTx();
+ }
if (size != null) {
if (size instanceof XDDFBulletSizeFollowText) {
props.setBuSzTx(((XDDFBulletSizeFollowText) size).getXmlObject());
}
public void clearAll() {
- props.unsetBuAutoNum();
- props.unsetBuBlip();
- props.unsetBuChar();
- props.unsetBuNone();
- props.unsetBuClr();
- props.unsetBuClrTx();
- props.unsetBuFont();
- props.unsetBuFontTx();
- props.unsetBuSzPct();
- props.unsetBuSzPts();
- props.unsetBuSzTx();
+ if (props.isSetBuAutoNum()) {
+ props.unsetBuAutoNum();
+ }
+ if (props.isSetBuBlip()) {
+ props.unsetBuBlip();
+ }
+ if (props.isSetBuChar()) {
+ props.unsetBuChar();
+ }
+ if (props.isSetBuNone()) {
+ props.unsetBuNone();
+ }
+ if (props.isSetBuClr()) {
+ props.unsetBuClr();
+ }
+ if (props.isSetBuClrTx()) {
+ props.unsetBuClrTx();
+ }
+ if (props.isSetBuFont()) {
+ props.unsetBuFont();
+ }
+ if (props.isSetBuFontTx()) {
+ props.unsetBuFontTx();
+ }
+ if (props.isSetBuSzPct()) {
+ props.unsetBuSzPct();
+ }
+ if (props.isSetBuSzPts()) {
+ props.unsetBuSzPts();
+ }
+ if (props.isSetBuSzTx()) {
+ props.unsetBuSzTx();
+ }
}
}
public void setLevel(Integer level) {
if (level == null) {
- props.unsetLvl();
+ if (props.isSetLvl()) {
+ props.unsetLvl();
+ }
} else if (level < 1 || 9 < level) {
throw new IllegalArgumentException("Minimum inclusive: 1. Maximum inclusive: 9.");
} else {
public void setDefaultRunProperties(XDDFRunProperties properties) {
if (properties == null) {
- props.unsetDefRPr();
+ if (props.isSetDefRPr()) {
+ props.unsetDefRPr();
+ }
} else {
props.setDefRPr(properties.getXmlObject());
}
public void setEastAsianLineBreak(Boolean value) {
if (value == null) {
- props.unsetEaLnBrk();
+ if (props.isSetEaLnBrk()) {
+ props.unsetEaLnBrk();
+ }
} else {
props.setEaLnBrk(value);
}
public void setLatinLineBreak(Boolean value) {
if (value == null) {
- props.unsetLatinLnBrk();
+ if (props.isSetLatinLnBrk()) {
+ props.unsetLatinLnBrk();
+ }
} else {
props.setLatinLnBrk(value);
}
public void setHangingPunctuation(Boolean value) {
if (value == null) {
- props.unsetHangingPunct();
+ if (props.isSetHangingPunct()) {
+ props.unsetHangingPunct();
+ }
} else {
props.setHangingPunct(value);
}
public void setRightToLeft(Boolean value) {
if (value == null) {
- props.unsetRtl();
+ if (props.isSetRtl()) {
+ props.unsetRtl();
+ }
} else {
props.setRtl(value);
}
public void setFontAlignment(FontAlignment align) {
if (align == null) {
- props.unsetFontAlgn();
+ if (props.isSetFontAlgn()) {
+ props.unsetFontAlgn();
+ }
} else {
props.setFontAlgn(align.underlying);
}
public void setTextAlignment(TextAlignment align) {
if (align == null) {
- props.unsetAlgn();
+ if (props.isSetAlgn()) {
+ props.unsetAlgn();
+ }
} else {
props.setAlgn(align.underlying);
}
public void setDefaultTabSize(Double points) {
if (points == null) {
- props.unsetDefTabSz();
+ if (props.isSetDefTabSz()) {
+ props.unsetDefTabSz();
+ }
} else {
props.setDefTabSz(Units.toEMU(points));
}
public void setIndentation(Double points) {
if (points == null) {
- props.unsetIndent();
+ if (props.isSetIndent()) {
+ props.unsetIndent();
+ }
} else if (points < -4032 || 4032 < points) {
throw new IllegalArgumentException("Minimum inclusive = -4032. Maximum inclusive = 4032.");
} else {
public void setMarginLeft(Double points) {
if (points == null) {
- props.unsetMarL();
+ if (props.isSetMarL()) {
+ props.unsetMarL();
+ }
} else if (points < 0 || 4032 < points) {
throw new IllegalArgumentException("Minimum inclusive = 0. Maximum inclusive = 4032.");
} else {
public void setMarginRight(Double points) {
if (points == null) {
- props.unsetMarR();
+ if (props.isSetMarR()) {
+ props.unsetMarR();
+ }
} else if (points < 0 || 4032 < points) {
throw new IllegalArgumentException("Minimum inclusive = 0. Maximum inclusive = 4032.");
} else {
public void setLineSpacing(XDDFSpacing spacing) {
if (spacing == null) {
- props.unsetLnSpc();
+ if (props.isSetLnSpc()) {
+ props.unsetLnSpc();
+ }
} else {
props.setLnSpc(spacing.getXmlObject());
}
public void setSpaceAfter(XDDFSpacing spacing) {
if (spacing == null) {
- props.unsetSpcAft();
+ if (props.isSetSpcAft()) {
+ props.unsetSpcAft();
+ }
} else {
props.setSpcAft(spacing.getXmlObject());
}
public void setSpaceBefore(XDDFSpacing spacing) {
if (spacing == null) {
- props.unsetSpcBef();
+ if (props.isSetSpcBef()) {
+ props.unsetSpcBef();
+ }
} else {
props.setSpcBef(spacing.getXmlObject());
}
public void setExtensionList(XDDFExtensionList list) {
if (list == null) {
- props.unsetExtLst();
+ if (props.isSetExtLst()) {
+ props.unsetExtLst();
+ }
} else {
props.setExtLst(list.getXmlObject());
}
public void setBaseline(Integer value) {
if (value == null) {
- props.unsetBaseline();
+ if (props.isSetBaseline()) {
+ props.unsetBaseline();
+ }
} else {
props.setBaseline(value);
}
public void setDirty(Boolean dirty) {
if (dirty == null) {
- props.unsetDirty();
+ if (props.isSetDirty()) {
+ props.unsetDirty();
+ }
} else {
props.setDirty(dirty);
}
public void setSpellError(Boolean error) {
if (error == null) {
- props.unsetErr();
+ if (props.isSetErr()) {
+ props.unsetErr();
+ }
} else {
props.setErr(error);
}
public void setNoProof(Boolean noproof) {
if (noproof == null) {
- props.unsetNoProof();
+ if (props.isSetNoProof()) {
+ props.unsetNoProof();
+ }
} else {
props.setNoProof(noproof);
}
public void setNormalizeHeights(Boolean normalize) {
if (normalize == null) {
- props.unsetNormalizeH();
+ if (props.isSetNormalizeH()) {
+ props.unsetNormalizeH();
+ }
} else {
props.setNormalizeH(normalize);
}
public void setKumimoji(Boolean kumimoji) {
if (kumimoji == null) {
- props.unsetKumimoji();
+ if (props.isSetKumimoji()) {
+ props.unsetKumimoji();
+ }
} else {
props.setKumimoji(kumimoji);
}
public void setBold(Boolean bold) {
if (bold == null) {
- props.unsetB();
+ if (props.isSetB()) {
+ props.unsetB();
+ }
} else {
props.setB(bold);
}
public void setItalic(Boolean italic) {
if (italic == null) {
- props.unsetI();
+ if (props.isSetI()) {
+ props.unsetI();
+ }
} else {
props.setI(italic);
}
public void setFontSize(Double size) {
if (size == null) {
- props.unsetSz();
+ if (props.isSetSz()) {
+ props.unsetSz();
+ }
} else if (size < 1 || 400 < size) {
throw new IllegalArgumentException("Minimum inclusive = 1. Maximum inclusive = 400.");
} else {
- props.setSz((int)(100 * size));
+ props.setSz((int) (100 * size));
}
}
public void setFillProperties(XDDFFillProperties properties) {
- props.unsetBlipFill();
- props.unsetGradFill();
- props.unsetGrpFill();
- props.unsetNoFill();
- props.unsetPattFill();
- props.unsetSolidFill();
+ 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;
}
public void setCharacterKerning(Double kerning) {
if (kerning == null) {
- props.unsetKern();
+ if (props.isSetKern()) {
+ props.unsetKern();
+ }
} else if (kerning < 0 || 4000 < kerning) {
throw new IllegalArgumentException("Minimum inclusive = 0. Maximum inclusive = 4000.");
} else {
- props.setKern((int)(100*kerning));
+ props.setKern((int) (100 * kerning));
}
}
public void setCharacterSpacing(Double spacing) {
if (spacing == null) {
- props.unsetSpc();
+ if (props.isSetSpc()) {
+ props.unsetSpc();
+ }
} else if (spacing < -4000 || 4000 < spacing) {
throw new IllegalArgumentException("Minimum inclusive = -4000. Maximum inclusive = 4000.");
} else {
- props.setSpc((int)(100*spacing));
+ props.setSpc((int) (100 * spacing));
}
}
public void setFonts(XDDFFont[] fonts) {
- for (XDDFFont font: fonts) {
+ for (XDDFFont font : fonts) {
CTTextFont xml = font.getXmlObject();
switch (font.getGroup()) {
case COMPLEX_SCRIPT:
if (xml == null) {
- props.unsetCs();
+ if (props.isSetCs()) {
+ props.unsetCs();
+ }
} else {
props.setCs(xml);
}
case EAST_ASIAN:
if (xml == null) {
- props.unsetEa();
+ if (props.isSetEa()) {
+ props.unsetEa();
+ }
} else {
props.setEa(xml);
}
case LATIN:
if (xml == null) {
- props.unsetLatin();
+ if (props.isSetLatin()) {
+ props.unsetLatin();
+ }
} else {
props.setLatin(xml);
}
case SYMBOL:
if (xml == null) {
- props.unsetSym();
+ if (props.isSetSym()) {
+ props.unsetSym();
+ }
} else {
props.setSym(xml);
}
public void setUnderline(UnderlineType underline) {
if (underline == null) {
- props.unsetU();
+ if (props.isSetU()) {
+ props.unsetU();
+ }
} else {
props.setU(underline.underlying);
}
public void setStrikeThrough(StrikeType strike) {
if (strike == null) {
- props.unsetStrike();
+ if (props.isSetStrike()) {
+ props.unsetStrike();
+ }
} else {
props.setStrike(strike.underlying);
}
public void setCapitals(CapsType caps) {
if (caps == null) {
- props.unsetCap();
+ if (props.isSetCap()) {
+ props.unsetCap();
+ }
} else {
props.setCap(caps.underlying);
}
public void setHyperlink(XDDFHyperlink link) {
if (link == null) {
- props.unsetHlinkClick();
+ if (props.isSetHlinkClick()) {
+ props.unsetHlinkClick();
+ }
} else {
props.setHlinkClick(link.getXmlObject());
}
public void setMouseOver(XDDFHyperlink link) {
if (link == null) {
- props.unsetHlinkMouseOver();
+ if (props.isSetHlinkMouseOver()) {
+ props.unsetHlinkMouseOver();
+ }
} else {
props.setHlinkMouseOver(link.getXmlObject());
}
public void setLanguage(Locale lang) {
if (lang == null) {
- props.unsetLang();
+ if (props.isSetLang()) {
+ props.unsetLang();
+ }
} else {
props.setLang(lang.toLanguageTag());
}
public void setAlternativeLanguage(Locale lang) {
if (lang == null) {
- props.unsetAltLang();
+ if (props.isSetAltLang()) {
+ props.unsetAltLang();
+ }
} else {
props.setAltLang(lang.toLanguageTag());
}
public void setHighlight(XDDFColor color) {
if (color == null) {
- props.unsetHighlight();
+ if (props.isSetHighlight()) {
+ props.unsetHighlight();
+ }
} else {
props.setHighlight(color.getColorContainer());
}
public void setLineProperties(XDDFLineProperties properties) {
if (properties == null) {
- props.unsetLn();
+ if (props.isSetLn()) {
+ props.unsetLn();
+ }
} else {
props.setLn(properties.getXmlObject());
}
public void setBookmark(String bookmark) {
if (bookmark == null) {
- props.unsetBmk();
+ if (props.isSetBmk()) {
+ props.unsetBmk();
+ }
} else {
props.setBmk(bookmark);
}
public void setExtensionList(XDDFExtensionList list) {
if (list == null) {
- props.unsetExtLst();
+ if (props.isSetExtLst()) {
+ props.unsetExtLst();
+ }
} else {
props.setExtLst(list.getXmlObject());
}
public void setEffectContainer(XDDFEffectContainer container) {
if (container == null) {
- props.unsetEffectDag();
+ if (props.isSetEffectDag()) {
+ props.unsetEffectDag();
+ }
} else {
props.setEffectDag(container.getXmlObject());
}
public void setEffectList(XDDFEffectList list) {
if (list == null) {
- props.unsetEffectLst();
+ if (props.isSetEffectLst()) {
+ props.unsetEffectLst();
+ }
} else {
props.setEffectLst(list.getXmlObject());
}
public XDDFSpacingPercent(double value) {
this(CTTextSpacing.Factory.newInstance(), CTTextSpacingPercent.Factory.newInstance(), null);
- spacing.unsetSpcPts();
+ if (spacing.isSetSpcPts()) {
+ spacing.unsetSpcPts();
+ }
spacing.setSpcPct(percent);
setPercent(value);
}
public XDDFSpacingPoints(double value) {
this(CTTextSpacing.Factory.newInstance(), CTTextSpacingPoint.Factory.newInstance());
- spacing.unsetSpcPct();
+ if (spacing.isSetSpcPct()) {
+ spacing.unsetSpcPct();
+ }
spacing.setSpcPts(points);
setPoints(value);
}
public void setAlignment(TabAlignment align) {
if (align == null) {
- stop.unsetAlgn();
+ if (stop.isSetAlgn()) {
+ stop.unsetAlgn();
+ }
} else {
stop.setAlgn(align.underlying);
}
public void setPosition(Double position) {
if (position == null) {
- stop.unsetPos();
+ if (stop.isSetPos()) {
+ stop.unsetPos();
+ }
} else {
stop.setPos(Units.toEMU(position));
}
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
public XDDFTextBody(TextContainer parent) {
this(parent, CTTextBody.Factory.newInstance());
- this._body.addNewBodyPr();
+ initialize();
}
@Internal
return _parent;
}
+ public XDDFTextParagraph initialize() {
+ _body.addNewLstStyle();
+ _body.addNewBodyPr();
+ XDDFBodyProperties bp = getBodyProperties();
+ bp.setAnchoring(AnchorType.TOP);
+ bp.setRightToLeft(false);
+ XDDFTextParagraph p = addNewParagraph();
+ p.setTextAlignment(TextAlignment.LEFT);
+ XDDFRunProperties end = p.addAfterLastRunProperties();
+ end.setLanguage(Locale.US);
+ end.setFontSize(11.0);
+ return p;
+ }
+
public XDDFTextParagraph addNewParagraph() {
return new XDDFTextParagraph(_body.addNewP(), this);
}
}
public List<XDDFTextParagraph> getParagraphs() {
- return Collections.unmodifiableList(_body
- .getPList()
- .stream()
- .map(ds -> new XDDFTextParagraph(ds, this))
- .collect(Collectors.toList()));
+ return Collections.unmodifiableList(
+ _body.getPList().stream().map(ds -> new XDDFTextParagraph(ds, this)).collect(Collectors.toList()));
}
public XDDFBodyProperties getBodyProperties() {
public void setDefaultProperties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetDefPPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetDefPPr()) {
+ style.unsetDefPPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel1Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl1PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl1PPr()) {
+ style.unsetLvl1PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel2Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl2PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl2PPr()) {
+ style.unsetLvl2PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel3Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl3PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl3PPr()) {
+ style.unsetLvl3PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel4Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl4PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl4PPr()) {
+ style.unsetLvl4PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel5Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl5PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl5PPr()) {
+ style.unsetLvl5PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel6Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl6PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl6PPr()) {
+ style.unsetLvl6PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel7Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl7PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl7PPr()) {
+ style.unsetLvl7PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel8Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl8PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl8PPr()) {
+ style.unsetLvl8PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
public void setLevel9Properties(XDDFParagraphProperties properties) {
if (properties == null) {
if (_body.isSetLstStyle()) {
- _body.getLstStyle().unsetLvl9PPr();
+ CTTextListStyle style = _body.getLstStyle();
+ if (style.isSetLvl9PPr()) {
+ style.unsetLvl9PPr();
+ }
}
} else {
CTTextListStyle style = _body.isSetLstStyle() ? _body.getLstStyle() : _body.addNewLstStyle();
} else {
return findDefinedParagraphProperty(isSet, getter, level - 1);
}
- } else {
+ } else if (_parent != null) {
return _parent.findDefinedParagraphProperty(isSet, getter);
+ } else {
+ return Optional.empty();
}
}
} else {
return findDefinedRunProperty(isSet, getter, level - 1);
}
- } else {
+ } else if (_parent != null) {
return _parent.findDefinedRunProperty(isSet, getter);
+ } else {
+ return Optional.empty();
}
}
private CTTextParagraphProperties retrieveProperties(CTTextListStyle list, int level) {
- switch(level) {
- case 1: if (list.isSetLvl1PPr()) {
- return list.getLvl1PPr();
- } else {
- return null;
- }
- case 2: if (list.isSetLvl2PPr()) {
- return list.getLvl2PPr();
- } else {
- return null;
- }
- case 3: if (list.isSetLvl3PPr()) {
- return list.getLvl3PPr();
- } else {
- return null;
- }
- case 4: if (list.isSetLvl4PPr()) {
- return list.getLvl4PPr();
- } else {
- return null;
- }
- case 5: if (list.isSetLvl5PPr()) {
- return list.getLvl5PPr();
- } else {
- return null;
- }
- case 6: if (list.isSetLvl6PPr()) {
- return list.getLvl6PPr();
- } else {
- return null;
- }
- case 7: if (list.isSetLvl7PPr()) {
- return list.getLvl7PPr();
- } else {
- return null;
- }
- case 8: if (list.isSetLvl8PPr()) {
- return list.getLvl8PPr();
- } else {
- return null;
- }
- case 9: if (list.isSetLvl9PPr()) {
- return list.getLvl9PPr();
- } else {
+ switch (level) {
+ case 1:
+ if (list.isSetLvl1PPr()) {
+ return list.getLvl1PPr();
+ } else {
+ return null;
+ }
+ case 2:
+ if (list.isSetLvl2PPr()) {
+ return list.getLvl2PPr();
+ } else {
+ return null;
+ }
+ case 3:
+ if (list.isSetLvl3PPr()) {
+ return list.getLvl3PPr();
+ } else {
+ return null;
+ }
+ case 4:
+ if (list.isSetLvl4PPr()) {
+ return list.getLvl4PPr();
+ } else {
+ return null;
+ }
+ case 5:
+ if (list.isSetLvl5PPr()) {
+ return list.getLvl5PPr();
+ } else {
+ return null;
+ }
+ case 6:
+ if (list.isSetLvl6PPr()) {
+ return list.getLvl6PPr();
+ } else {
+ return null;
+ }
+ case 7:
+ if (list.isSetLvl7PPr()) {
+ return list.getLvl7PPr();
+ } else {
+ return null;
+ }
+ case 8:
+ if (list.isSetLvl8PPr()) {
+ return list.getLvl8PPr();
+ } else {
+ return null;
+ }
+ case 9:
+ if (list.isSetLvl9PPr()) {
+ return list.getLvl9PPr();
+ } else {
+ return null;
+ }
+ default:
return null;
}
- default: return null;
- }
}
}
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing;
/**
- * Represents a paragraph of text within the containing text body.
- * The paragraph is the highest level text separation mechanism.
+ * Represents a paragraph of text within the containing text body. The paragraph
+ * is the highest level text separation mechanism.
*/
@Beta
public class XDDFTextParagraph {
this._p = paragraph;
this._parent = parent;
- final int count = paragraph.sizeOfBrArray()
- + paragraph.sizeOfFldArray()
- + paragraph.sizeOfRArray();
+ final int count = paragraph.sizeOfBrArray() + paragraph.sizeOfFldArray() + paragraph.sizeOfRArray();
this._runs = new ArrayList<>(count);
for (XmlObject xo : _p.selectChildren(QNameSet.ALL)) {
return _parent;
}
- public List<XDDFTextRun> getTextRuns(){
+ public List<XDDFTextRun> getTextRuns() {
return _runs;
}
- public Iterator<XDDFTextRun> iterator(){
+ public Iterator<XDDFTextRun> iterator() {
return _runs.iterator();
}
*
* @return text run representing this line break ('\n').
*/
- public XDDFTextRun appendLineBreak(){
+ public XDDFTextRun appendLineBreak() {
CTTextLineBreak br = _p.addNewBr();
// by default, line break has the font properties of the last text run
- for (int i = _runs.size() - 1; i <= 0; i--){
+ for (int i = _runs.size() - 1; i <= 0; i--) {
CTTextCharacterProperties prevProps = _runs.get(i).getProperties();
// let's find one that is not undefined
if (prevProps != null) {
*
* @return the new text field.
*/
- public XDDFTextRun appendField(String id, String type, String text){
+ public XDDFTextRun appendField(String id, String type, String text) {
CTTextField f = _p.addNewFld();
f.setId(id);
f.setType(type);
*
* @return the new run of text.
*/
- public XDDFTextRun appendRegularRun(String text){
+ public XDDFTextRun appendRegularRun(String text) {
CTRegularTextRun r = _p.addNewR();
r.setT(text);
CTTextCharacterProperties rPr = r.addNewRPr();
* Returns the alignment that is applied to the paragraph.
*
* If this attribute is omitted, then a value of left is implied.
+ *
* @return alignment that is applied to the paragraph
*/
public TextAlignment getTextAlignment() {
return findDefinedParagraphProperty(props -> props.isSetAlgn(), props -> props.getAlgn())
- .map(align -> TextAlignment.valueOf(align))
- .orElse(null);
+ .map(align -> TextAlignment.valueOf(align)).orElse(null);
}
/**
- * Specifies the alignment that is to be applied to the paragraph.
- * Possible values for this include left, right, centered, justified and distributed,
+ * Specifies the alignment that is to be applied to the paragraph. Possible
+ * values for this include left, right, centered, justified and distributed,
*
- * @param align text alignment
+ * @param align
+ * text alignment
*/
public void setTextAlignment(TextAlignment align) {
if (align != null || _p.isSetPPr()) {
}
/**
- * Returns where vertically on a line of text the actual words are positioned. This deals
- * with vertical placement of the characters with respect to the baselines.
+ * Returns where vertically on a line of text the actual words are
+ * positioned. This deals with vertical placement of the characters with
+ * respect to the baselines.
*
* If this attribute is omitted, then a value of baseline is implied.
+ *
* @return alignment that is applied to the paragraph
*/
public FontAlignment getFontAlignment() {
return findDefinedParagraphProperty(props -> props.isSetFontAlgn(), props -> props.getFontAlgn())
- .map(align -> FontAlignment.valueOf(align))
- .orElse(null);
+ .map(align -> FontAlignment.valueOf(align)).orElse(null);
}
/**
- * Determines where vertically on a line of text the actual words are positioned. This deals
- * with vertical placement of the characters with respect to the baselines. For instance
- * having text anchored to the top baseline, anchored to the bottom baseline, centered in
- * between, etc.
+ * Determines where vertically on a line of text the actual words are
+ * positioned. This deals with vertical placement of the characters with
+ * respect to the baselines. For instance having text anchored to the top
+ * baseline, anchored to the bottom baseline, centered in between, etc.
*
- * @param align text font alignment
+ * @param align
+ * text font alignment
*/
public void setFontAlignment(FontAlignment align) {
if (align != null || _p.isSetPPr()) {
/**
*
- * @return the indentation, in points, applied to the first line of text in the paragraph.
+ * @return the indentation, in points, applied to the first line of text in
+ * the paragraph.
*/
public Double getIndentation() {
return findDefinedParagraphProperty(props -> props.isSetIndent(), props -> props.getIndent())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
- * Specifies the indentation size that will be applied to the first line of text in the paragraph.
- *
- * @param points the indentation in points.
- * The value <code>null</code> unsets the indentation for this paragraph.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>-4032</dd>
- * <dt>Maximum inclusive =</dt><dd>4032</dd>
- * </dt>
+ * Specifies the indentation size that will be applied to the first line of
+ * text in the paragraph.
+ *
+ * @param points
+ * the indentation in points. The value <code>null</code> unsets
+ * the indentation for this paragraph.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>-4032</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4032</dd></dt>
*/
public void setIndentation(Double points) {
if (points != null || _p.isSetPPr()) {
- getOrCreateProperties().setIndentation(points);;
+ getOrCreateProperties().setIndentation(points);
+ ;
}
}
*/
public Double getMarginLeft() {
return findDefinedParagraphProperty(props -> props.isSetMarL(), props -> props.getMarL())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
- * Specifies the left margin of the paragraph. This is specified in addition to the text body
- * inset and applies only to this text paragraph. That is the text body inset and the LeftMargin
- * attributes are additive with respect to the text position.
- *
- * @param points the margin in points.
- * The value <code>null</code> unsets the left margin for this paragraph.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>0</dd>
- * <dt>Maximum inclusive =</dt><dd>4032</dd>
- * </dt>
+ * Specifies the left margin of the paragraph. This is specified in addition
+ * to the text body inset and applies only to this text paragraph. That is
+ * the text body inset and the LeftMargin attributes are additive with
+ * respect to the text position.
+ *
+ * @param points
+ * the margin in points. The value <code>null</code> unsets the
+ * left margin for this paragraph.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>0</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4032</dd></dt>
*/
public void setMarginLeft(Double points) {
if (points != null || _p.isSetPPr()) {
*/
public Double getMarginRight() {
return findDefinedParagraphProperty(props -> props.isSetMarR(), props -> props.getMarR())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
- * Specifies the right margin of the paragraph. This is specified in addition to the text body
- * inset and applies only to this text paragraph. That is the text body inset and the RightMargin
- * attributes are additive with respect to the text position.
- *
- * @param points the margin in points.
- * The value <code>null</code> unsets the right margin for this paragraph.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>0</dd>
- * <dt>Maximum inclusive =</dt><dd>4032</dd>
- * </dt>
+ * Specifies the right margin of the paragraph. This is specified in
+ * addition to the text body inset and applies only to this text paragraph.
+ * That is the text body inset and the RightMargin attributes are additive
+ * with respect to the text position.
+ *
+ * @param points
+ * the margin in points. The value <code>null</code> unsets the
+ * right margin for this paragraph.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>0</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4032</dd></dt>
*/
public void setMarginRight(Double points) {
if (points != null || _p.isSetPPr()) {
/**
*
- * @return the default size for a tab character within this paragraph in points.
+ * @return the default size for a tab character within this paragraph in
+ * points.
*/
public Double getDefaultTabSize() {
return findDefinedParagraphProperty(props -> props.isSetDefTabSz(), props -> props.getDefTabSz())
- .map(emu -> Units.toPoints(emu))
- .orElse(null);
+ .map(emu -> Units.toPoints(emu)).orElse(null);
}
/**
* Specifies the default size for a tab character within this paragraph.
*
- * @param points the default tab size in points.
- * The value <code>null</code> unsets the default tab size for this paragraph.
+ * @param points
+ * the default tab size in points. The value <code>null</code>
+ * unsets the default tab size for this paragraph.
*/
public void setDefaultTabSize(Double points) {
if (points != null || _p.isSetPPr()) {
/**
* Returns the vertical line spacing that is to be used within a paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * This may be specified in two different ways, percentage spacing or font
+ * points spacing:
* <p>
- * If line spacing is a percentage of normal line height, result is instance of XDDFSpacingPercent.
- * If line spacing is expressed in points, result is instance of XDDFSpacingPoints.
+ * If line spacing is a percentage of normal line height, result is instance
+ * of XDDFSpacingPercent. If line spacing is expressed in points, result is
+ * instance of XDDFSpacingPoints.
* </p>
*
* @return the vertical line spacing.
*/
public XDDFSpacing getLineSpacing() {
return findDefinedParagraphProperty(props -> props.isSetLnSpc(), props -> props.getLnSpc())
- .map(spacing -> extractSpacing(spacing))
- .orElse(null);
+ .map(spacing -> extractSpacing(spacing)).orElse(null);
}
/**
- * This element specifies the vertical line spacing that is to be used within a paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * This element specifies the vertical line spacing that is to be used
+ * within a paragraph. This may be specified in two different ways,
+ * percentage spacing or font points spacing:
* <p>
- * If spacing is instance of XDDFSpacingPercent, then line spacing is a percentage of normal line height.
- * If spacing is instance of XDDFSpacingPoints, then line spacing is expressed in points.
+ * If spacing is instance of XDDFSpacingPercent, then line spacing is a
+ * percentage of normal line height. If spacing is instance of
+ * XDDFSpacingPoints, then line spacing is expressed in points.
* </p>
* Examples:
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* // spacing will be 120% of the size of the largest text on each line
* paragraph.setLineSpacing(new XDDFSpacingPercent(120));
*
*
* // spacing will be 48 points
* paragraph.setLineSpacing(new XDDFSpacingPoints(48.0));
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param linespacing the vertical line spacing
+ * @param linespacing
+ * the vertical line spacing
*/
public void setLineSpacing(XDDFSpacing linespacing) {
if (linespacing != null || _p.isSetPPr()) {
}
/**
- * The amount of vertical white space before the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * The amount of vertical white space before the paragraph. This may be
+ * specified in two different ways, percentage spacing or font points
+ * spacing:
* <p>
- * If spacing is a percentage of normal line height, result is instance of XDDFSpacingPercent.
- * If spacing is expressed in points, result is instance of XDDFSpacingPoints.
+ * If spacing is a percentage of normal line height, result is instance of
+ * XDDFSpacingPercent. If spacing is expressed in points, result is instance
+ * of XDDFSpacingPoints.
* </p>
*
* @return the vertical white space before the paragraph.
*/
public XDDFSpacing getSpaceBefore() {
return findDefinedParagraphProperty(props -> props.isSetSpcBef(), props -> props.getSpcBef())
- .map(spacing -> extractSpacing(spacing))
- .orElse(null);
+ .map(spacing -> extractSpacing(spacing)).orElse(null);
}
/**
- * Set the amount of vertical white space that will be present before the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * Set the amount of vertical white space that will be present before the
+ * paragraph. This may be specified in two different ways, percentage
+ * spacing or font points spacing:
* <p>
- * If spacing is instance of XDDFSpacingPercent, then spacing is a percentage of normal line height.
- * If spacing is instance of XDDFSpacingPoints, then spacing is expressed in points.
+ * If spacing is instance of XDDFSpacingPercent, then spacing is a
+ * percentage of normal line height. If spacing is instance of
+ * XDDFSpacingPoints, then spacing is expressed in points.
* </p>
* Examples:
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* // The paragraph will be formatted to have a spacing before the paragraph text.
* // The spacing will be 200% of the size of the largest text on each line
* paragraph.setSpaceBefore(new XDDFSpacingPercent(200));
*
* // The spacing will be a size of 48 points
* paragraph.setSpaceBefore(new XDDFSpacingPoints(48.0));
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param spaceBefore the vertical white space before the paragraph.
+ * @param spaceBefore
+ * the vertical white space before the paragraph.
*/
public void setSpaceBefore(XDDFSpacing spaceBefore) {
if (spaceBefore != null || _p.isSetPPr()) {
}
/**
- * The amount of vertical white space after the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * The amount of vertical white space after the paragraph. This may be
+ * specified in two different ways, percentage spacing or font points
+ * spacing:
* <p>
- * If spacing is a percentage of normal line height, result is instance of XDDFSpacingPercent.
- * If spacing is expressed in points, result is instance of XDDFSpacingPoints.
+ * If spacing is a percentage of normal line height, result is instance of
+ * XDDFSpacingPercent. If spacing is expressed in points, result is instance
+ * of XDDFSpacingPoints.
* </p>
*
* @return the vertical white space after the paragraph.
*/
public XDDFSpacing getSpaceAfter() {
return findDefinedParagraphProperty(props -> props.isSetSpcAft(), props -> props.getSpcAft())
- .map(spacing -> extractSpacing(spacing))
- .orElse(null);
+ .map(spacing -> extractSpacing(spacing)).orElse(null);
}
/**
- * Set the amount of vertical white space that will be present after the paragraph.
- * This may be specified in two different ways, percentage spacing or font points spacing:
+ * Set the amount of vertical white space that will be present after the
+ * paragraph. This may be specified in two different ways, percentage
+ * spacing or font points spacing:
* <p>
- * If spacing is instance of XDDFSpacingPercent, then spacing is a percentage of normal line height.
- * If spacing is instance of XDDFSpacingPoints, then spacing is expressed in points.
+ * If spacing is instance of XDDFSpacingPercent, then spacing is a
+ * percentage of normal line height. If spacing is instance of
+ * XDDFSpacingPoints, then spacing is expressed in points.
* </p>
* Examples:
- * <pre><code>
+ *
+ * <pre>
+ * <code>
* // The paragraph will be formatted to have a spacing after the paragraph text.
* // The spacing will be 200% of the size of the largest text on each line
* paragraph.setSpaceAfter(new XDDFSpacingPercent(200));
*
* // The spacing will be a size of 48 points
* paragraph.setSpaceAfter(new XDDFSpacingPoints(48.0));
- * </code></pre>
+ * </code>
+ * </pre>
*
- * @param spaceAfter the vertical white space after the paragraph.
+ * @param spaceAfter
+ * the vertical white space after the paragraph.
*/
public void setSpaceAfter(XDDFSpacing spaceAfter) {
if (spaceAfter != null || _p.isSetPPr()) {
/**
*
- * @return the color of bullet characters within a given paragraph.
- * A <code>null</code> value means to use the text font color.
+ * @return the color of bullet characters within a given paragraph. A
+ * <code>null</code> value means to use the text font color.
*/
- public XDDFColor getBulletColor(){
- return findDefinedParagraphProperty(
- props -> props.isSetBuClr() || props.isSetBuClrTx(),
- props -> new XDDFParagraphBulletProperties(props).getBulletColor()
- ).orElse(null);
+ public XDDFColor getBulletColor() {
+ return findDefinedParagraphProperty(props -> props.isSetBuClr() || props.isSetBuClrTx(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletColor()).orElse(null);
}
/**
* Set the color to be used on bullet characters within a given paragraph.
*
- * @param color the bullet color
+ * @param color
+ * the bullet color
*/
public void setBulletColor(XDDFColor color) {
if (color != null || _p.isSetPPr()) {
}
/**
- * Specifies the color to be used on bullet characters has to follow text color within a given paragraph.
+ * Specifies the color to be used on bullet characters has to follow text
+ * color within a given paragraph.
*/
public void setBulletColorFollowText() {
getOrCreateBulletProperties().setBulletColorFollowText();
/**
*
- * @return the font of bullet characters within a given paragraph.
- * A <code>null</code> value means to use the text font font.
+ * @return the font of bullet characters within a given paragraph. A
+ * <code>null</code> value means to use the text font font.
*/
- public XDDFFont getBulletFont(){
- return findDefinedParagraphProperty(
- props -> props.isSetBuFont() || props.isSetBuFontTx(),
- props -> new XDDFParagraphBulletProperties(props).getBulletFont()
- ).orElse(null);
+ public XDDFFont getBulletFont() {
+ return findDefinedParagraphProperty(props -> props.isSetBuFont() || props.isSetBuFontTx(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletFont()).orElse(null);
}
/**
* Set the font to be used on bullet characters within a given paragraph.
*
- * @param font the bullet font
+ * @param font
+ * the bullet font
*/
public void setBulletFont(XDDFFont font) {
if (font != null || _p.isSetPPr()) {
}
/**
- * Specifies the font to be used on bullet characters has to follow text font within a given paragraph.
+ * Specifies the font to be used on bullet characters has to follow text
+ * font within a given paragraph.
*/
public void setBulletFontFollowText() {
getOrCreateBulletProperties().setBulletFontFollowText();
}
/**
- * Returns the bullet size that is to be used within a paragraph.
- * This may be specified in three different ways, follows text size, percentage size and font points size:
+ * Returns the bullet size that is to be used within a paragraph. This may
+ * be specified in three different ways, follows text size, percentage size
+ * and font points size:
* <p>
- * If returned value is instance of XDDFBulletSizeFollowText, then bullet size is text size;
- * If returned value is instance of XDDFBulletSizePercent, then bullet size is a percentage of the font size;
- * If returned value is instance of XDDFBulletSizePoints, then bullet size is specified in points.
+ * If returned value is instance of XDDFBulletSizeFollowText, then bullet
+ * size is text size; If returned value is instance of
+ * XDDFBulletSizePercent, then bullet size is a percentage of the font size;
+ * If returned value is instance of XDDFBulletSizePoints, then bullet size
+ * is specified in points.
* </p>
*
* @return the bullet size
*/
- public XDDFBulletSize getBulletSize(){
+ public XDDFBulletSize getBulletSize() {
return findDefinedParagraphProperty(
- props -> props.isSetBuSzPct() || props.isSetBuSzPts() || props.isSetBuSzTx(),
- props -> new XDDFParagraphBulletProperties(props).getBulletSize()
- ).orElse(null);
+ props -> props.isSetBuSzPct() || props.isSetBuSzPts() || props.isSetBuSzTx(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletSize()).orElse(null);
}
/**
- * Sets the bullet size that is to be used within a paragraph.
- * This may be specified in three different ways, follows text size, percentage size and font points size:
+ * Sets the bullet size that is to be used within a paragraph. This may be
+ * specified in three different ways, follows text size, percentage size and
+ * font points size:
* <p>
- * If given value is instance of XDDFBulletSizeFollowText, then bullet size is text size;
- * If given value is instance of XDDFBulletSizePercent, then bullet size is a percentage of the font size;
- * If given value is instance of XDDFBulletSizePoints, then bullet size is specified in points.
+ * If given value is instance of XDDFBulletSizeFollowText, then bullet size
+ * is text size; If given value is instance of XDDFBulletSizePercent, then
+ * bullet size is a percentage of the font size; If given value is instance
+ * of XDDFBulletSizePoints, then bullet size is specified in points.
* </p>
*
- * @param size the bullet size specification
+ * @param size
+ * the bullet size specification
*/
public void setBulletSize(XDDFBulletSize size) {
if (size != null || _p.isSetPPr()) {
}
}
- public XDDFBulletStyle getBulletStyle(){
+ public XDDFBulletStyle getBulletStyle() {
return findDefinedParagraphProperty(
- props -> props.isSetBuAutoNum() || props.isSetBuBlip() || props.isSetBuChar() || props.isSetBuNone(),
- props -> new XDDFParagraphBulletProperties(props).getBulletStyle()
- ).orElse(null);
+ props -> props.isSetBuAutoNum() || props.isSetBuBlip() || props.isSetBuChar() || props.isSetBuNone(),
+ props -> new XDDFParagraphBulletProperties(props).getBulletStyle()).orElse(null);
}
public void setBulletStyle(XDDFBulletStyle style) {
}
public boolean hasEastAsianLineBreak() {
- return findDefinedParagraphProperty(props -> props.isSetEaLnBrk(), props -> props.getEaLnBrk())
- .orElse(false);
+ return findDefinedParagraphProperty(props -> props.isSetEaLnBrk(), props -> props.getEaLnBrk()).orElse(false);
}
public void setEastAsianLineBreak(Boolean value) {
}
public boolean isRightToLeft() {
- return findDefinedParagraphProperty(props -> props.isSetRtl(), props -> props.getRtl())
- .orElse(false);
+ return findDefinedParagraphProperty(props -> props.isSetRtl(), props -> props.getRtl()).orElse(false);
}
public void setRightToLeft(Boolean value) {
}
}
+ public XDDFRunProperties addAfterLastRunProperties() {
+ if (!_p.isSetEndParaRPr()) {
+ _p.addNewEndParaRPr();
+ }
+ return getAfterLastRunProperties();
+ }
+
public XDDFRunProperties getAfterLastRunProperties() {
if (_p.isSetEndParaRPr()) {
return new XDDFRunProperties(_p.getEndParaRPr());
public void setAfterLastRunProperties(XDDFRunProperties properties) {
if (properties == null) {
- _p.unsetEndParaRPr();
+ if (_p.isSetEndParaRPr()) {
+ _p.unsetEndParaRPr();
+ }
} else {
_p.setEndParaRPr(properties.getXmlObject());
}
import java.util.Optional;
import java.util.function.Function;
-import org.apache.poi.POIXMLRelation;
import org.apache.poi.common.usermodel.fonts.FontGroup;
+import org.apache.poi.ooxml.POIXMLRelation;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagePartName;
import org.apache.poi.openxml4j.opc.PackageRelationship;
public String getText() {
if (isLineBreak()) {
return "\n";
- } else if (isField()) {
+ } else if (isField()) {
return _tf.getT();
- } else {
+ } else {
return _rtr.getT();
}
}
/**
* Specifies whether this run of text will be formatted as bold text.
*
- * @param bold whether this run of text will be formatted as bold text.
+ * @param bold
+ * whether this run of text will be formatted as bold text.
*/
public void setBold(Boolean bold) {
getOrCreateProperties().setBold(bold);
}
/**
- * @param italic whether this run of text is formatted as italic text.
+ * @param italic
+ * whether this run of text is formatted as italic text.
*/
public void setItalic(Boolean italic) {
getOrCreateProperties().setItalic(italic);
}
/**
- * @param strike which strike style this run of text is formatted with.
+ * @param strike
+ * which strike style this run of text is formatted with.
*/
public void setStrikeThrough(StrikeType strike) {
getOrCreateProperties().setStrikeThrough(strike);
}
/**
- * @param underline which underline style this run of text is formatted with.
+ * @param underline
+ * which underline style this run of text is formatted with.
*/
public void setUnderline(UnderlineType underline) {
getOrCreateProperties().setUnderline(underline);
}
/**
- * @param caps which caps style this run of text is formatted with.
+ * @param caps
+ * which caps style this run of text is formatted with.
*/
public void setCapitals(CapsType caps) {
getOrCreateProperties().setCapitals(caps);
}
/**
- * @return whether a run of text will be formatted as a subscript text. Default is false.
+ * @return whether a run of text will be formatted as a subscript text.
+ * Default is false.
*/
public boolean isSubscript() {
return findDefinedProperty(props -> props.isSetBaseline(), props -> props.getBaseline())
}
/**
- * @return whether a run of text will be formatted as a superscript text. Default is false.
+ * @return whether a run of text will be formatted as a superscript text.
+ * Default is false.
*/
public boolean isSuperscript() {
return findDefinedProperty(props -> props.isSetBaseline(), props -> props.getBaseline())
*
* @param offset
*/
- public void setBaseline(Double offset){
- getOrCreateProperties().setBaseline((int)(offset * 1000));
+ public void setBaseline(Double offset) {
+ if (offset == null) {
+ getOrCreateProperties().setBaseline(null);
+ } else {
+ getOrCreateProperties().setBaseline((int) (offset * 1000));
+ }
}
/**
* Set whether the text in this run is formatted as superscript.
- * <p>
- * The size is specified using a percentage.
- * </p>
+ * <p>
+ * The size is specified using a percentage.
+ * </p>
*
* @param offset
*/
- public void setSuperscript(Double offset){
+ public void setSuperscript(Double offset) {
setBaseline(offset == null ? null : Math.abs(offset));
}
/**
* Set whether the text in this run is formatted as subscript.
- * <p>
- * The size is specified using a percentage.
- * </p>
+ * <p>
+ * The size is specified using a percentage.
+ * </p>
*
* @param offset
*/
- public void setSubscript(Double offset){
+ public void setSubscript(Double offset) {
setBaseline(offset == null ? null : -Math.abs(offset));
}
* <em>Note</em>: In order to get fonts to unset the property for a given font family use
* {@link XDDFFont#unsetFontForGroup(FontGroup)}
*
- * @param fonts to set or unset on the run.
+ * @param fonts
+ * to set or unset on the run.
*/
public void setFonts(XDDFFont[] fonts) {
getOrCreateProperties().setFonts(fonts);
}
/**
- * @param size font size in points.
- * The value <code>null</code> unsets the size for this run.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>1</dd>
- * <dt>Maximum inclusive =</dt><dd>400</dd>
- * </dt>
+ * @param size
+ * font size in points. The value <code>null</code> unsets the
+ * size for this run.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>1</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>400</dd></dt>
*
*/
public void setFontSize(Double size) {
public Double getFontSize() {
Integer size = findDefinedProperty(props -> props.isSetSz(), props -> props.getSz())
- .orElse(100 * XSSFFont.DEFAULT_FONT_SIZE); // default font size
+ .orElse(100 * XSSFFont.DEFAULT_FONT_SIZE); // default font size
double scale = _parent.getParentBody().getBodyProperties().getAutoFit().getFontScale() / 10_000_000.0;
return size * scale;
}
* The value <code>null</code> unsets the kerning for this run.
* </p>
*
- * @param kerning character kerning in points.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>0</dd>
- * <dt>Maximum inclusive =</dt><dd>4000</dd>
- * </dt>
+ * @param kerning
+ * character kerning in points.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>0</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4000</dd></dt>
*/
- public void setCharacterKerning(Double kerning){
+ public void setCharacterKerning(Double kerning) {
getOrCreateProperties().setCharacterKerning(kerning);
}
* The value <code>null</code> unsets the spacing for this run.
* </p>
*
- * @param spacing character spacing in points.
- * <dl>
- * <dt>Minimum inclusive =</dt><dd>-4000</dd>
- * <dt>Maximum inclusive =</dt><dd>4000</dd>
- * </dt>
+ * @param spacing
+ * character spacing in points.
+ * <dl>
+ * <dt>Minimum inclusive =</dt>
+ * <dd>-4000</dd>
+ * <dt>Maximum inclusive =</dt>
+ * <dd>4000</dd></dt>
*/
- public void setCharacterSpacing(Double spacing){
+ public void setCharacterSpacing(Double spacing) {
getOrCreateProperties().setCharacterSpacing(spacing);
}
CTShape shape = (CTShape) getXmlObject();
CTTextBody txBody = shape.getTxBody();
if (txBody == null && create) {
- txBody = shape.addNewTxBody();
- initTextBody(txBody);
+ XDDFTextBody body = new XDDFTextBody(this);
+ initTextBody(body);
+ shape.setTxBody(body.getXmlObject());
+ txBody = shape.getTxBody();
}
return txBody;
}