You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ab...@apache.org on 2018/08/27 19:25:34 UTC

svn commit: r1839369 [1/2] - in /poi/trunk/src/ooxml/java/org/apache/poi: openxml4j/opc/internal/ xddf/usermodel/chart/ xddf/usermodel/text/ xslf/usermodel/

Author: abearez
Date: Mon Aug 27 19:25:34 2018
New Revision: 1839369

URL: http://svn.apache.org/viewvc?rev=1839369&view=rev
Log:
rebase XDDF text package

Added:
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/AnchorType.java
      - copied, changed from r1839259, poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBodyProperties.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSize.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizeFollowText.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyle.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleAutoNumbered.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleCharacter.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleNone.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFFont.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFHyperlink.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFNormalAutoFit.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphBulletProperties.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPercent.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPoints.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTabStop.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextParagraph.java
    poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java Mon Aug 27 19:25:34 2018
@@ -26,11 +26,15 @@ import java.util.Locale;
 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;
@@ -150,10 +154,11 @@ public abstract class ContentTypeManager
         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);
+        }
     }
 
     /**
@@ -166,8 +171,9 @@ public abstract class ContentTypeManager
      */
     private void addOverrideContentType(PackagePartName partName,
             String contentType) {
-        if (overrideContentType == null)
+        if (overrideContentType == null) {
             overrideContentType = new TreeMap<>();
+        }
         overrideContentType.put(partName, contentType);
     }
 
@@ -206,8 +212,9 @@ public abstract class ContentTypeManager
      */
     public void removeContentType(PackagePartName partName)
             throws InvalidOperationException {
-        if (partName == null)
+        if (partName == null) {
             throw new IllegalArgumentException("partName");
+        }
 
         /* Override content type */
         if (this.overrideContentType != null
@@ -251,10 +258,11 @@ public abstract class ContentTypeManager
             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());
@@ -271,8 +279,9 @@ public abstract class ContentTypeManager
      *         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)));
@@ -318,16 +327,19 @@ public abstract class ContentTypeManager
      *                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
@@ -338,9 +350,11 @@ public abstract class ContentTypeManager
          */
         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;
     }
@@ -350,8 +364,9 @@ public abstract class ContentTypeManager
      */
     public void clearAll() {
         this.defaultContentType.clear();
-        if (this.overrideContentType != null)
+        if (this.overrideContentType != null) {
             this.overrideContentType.clear();
+        }
     }
 
     /**
@@ -359,8 +374,9 @@ public abstract class ContentTypeManager
      *
      */
     public void clearOverrideContentTypes() {
-        if (this.overrideContentType != null)
+        if (this.overrideContentType != null) {
             this.overrideContentType.clear();
+        }
     }
 
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java Mon Aug 27 19:25:34 2018
@@ -29,6 +29,8 @@ import java.util.HashMap;
 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;
 
@@ -46,6 +48,8 @@ import org.apache.poi.ss.util.CellRefere
 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;
@@ -65,15 +69,19 @@ import org.openxmlformats.schemas.drawin
 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
      */
@@ -109,8 +117,10 @@ public abstract class XDDFChart extends
     /**
      * 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 {
@@ -121,7 +131,8 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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
      */
@@ -152,8 +163,8 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * @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()) {
@@ -164,8 +175,9 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * @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()) {
@@ -202,6 +214,42 @@ public abstract class XDDFChart extends
         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;
@@ -336,18 +384,18 @@ public abstract class XDDFChart extends
         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;
         }
     }
 
@@ -360,7 +408,8 @@ public abstract class XDDFChart extends
 
     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;
     }
 
@@ -381,11 +430,17 @@ public abstract class XDDFChart extends
 
     /**
      * 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);
@@ -407,16 +462,21 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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();
     }
@@ -424,14 +484,18 @@ public abstract class XDDFChart extends
     /**
      * 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);
@@ -440,7 +504,8 @@ public abstract class XDDFChart extends
     /**
      * 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
@@ -451,9 +516,7 @@ public abstract class XDDFChart extends
             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");
@@ -489,9 +552,12 @@ public abstract class XDDFChart extends
     /**
      * 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) {
@@ -504,15 +570,16 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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 {
@@ -521,15 +588,17 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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 {
@@ -540,7 +609,8 @@ public abstract class XDDFChart extends
     /**
      * 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) {
@@ -553,7 +623,8 @@ public abstract class XDDFChart extends
     @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 {
@@ -572,7 +643,8 @@ public abstract class XDDFChart extends
     /**
      * 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
      */
@@ -588,18 +660,20 @@ public abstract class XDDFChart extends
     /**
      * 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);
@@ -632,9 +706,9 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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
@@ -683,10 +757,12 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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) {
@@ -694,9 +770,12 @@ public abstract class XDDFChart extends
     }
 
     /**
-     * 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) {
@@ -714,7 +793,8 @@ public abstract class XDDFChart extends
     /**
      * 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;

Copied: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/AnchorType.java (from r1839259, poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/AnchorType.java?p2=poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/AnchorType.java&p1=poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java&r1=1839259&r2=1839369&rev=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/AnchorType.java Mon Aug 27 19:25:34 2018
@@ -17,32 +17,31 @@
 
 package org.apache.poi.xddf.usermodel.text;
 
-import org.apache.poi.util.Beta;
-import org.apache.poi.util.Internal;
-import org.apache.poi.xddf.usermodel.XDDFPicture;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBlipBullet;
-
-@Beta
-public class XDDFBulletStylePicture extends XDDFBulletStyle {
-    private CTTextBlipBullet style;
-
-    @Internal
-    protected XDDFBulletStylePicture(CTTextBlipBullet style) {
-        this.style = style;
-    }
+import java.util.HashMap;
 
-    @Internal
-    protected CTTextBlipBullet getXmlObject() {
-        return style;
-    }
+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);
 
-    public XDDFPicture getPicture() {
-        return new XDDFPicture(style.getBlip());
+    final STTextAnchoringType.Enum underlying;
+
+    AnchorType(STTextAnchoringType.Enum caps) {
+        this.underlying = caps;
     }
 
-    public void setPicture(XDDFPicture picture) {
-        if (picture != null) {
-            style.setBlip(picture.getXmlObject());
+    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);
+    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBodyProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBodyProperties.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBodyProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBodyProperties.java Mon Aug 27 19:25:34 2018
@@ -37,6 +37,42 @@ public class XDDFBodyProperties {
         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());
@@ -45,13 +81,19 @@ public class XDDFBodyProperties {
         } 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) {
@@ -71,7 +113,9 @@ public class XDDFBodyProperties {
 
     public void setExtensionList(XDDFExtensionList list) {
         if (list == null) {
-            props.unsetExtLst();
+            if (props.isSetExtLst()) {
+                props.unsetExtLst();
+            }
         } else {
             props.setExtLst(list.getXmlObject());
         }
@@ -87,7 +131,9 @@ public class XDDFBodyProperties {
 
     public void setBottomInset(Double points) {
         if (points == null || Double.isNaN(points)) {
-            props.unsetBIns();
+            if (props.isSetBIns()) {
+                props.unsetBIns();
+            }
         } else {
             props.setBIns(Units.toEMU(points));
         }
@@ -103,7 +149,9 @@ public class XDDFBodyProperties {
 
     public void setLeftInset(Double points) {
         if (points == null || Double.isNaN(points)) {
-            props.unsetLIns();
+            if (props.isSetLIns()) {
+                props.unsetLIns();
+            }
         } else {
             props.setLIns(Units.toEMU(points));
         }
@@ -119,7 +167,9 @@ public class XDDFBodyProperties {
 
     public void setRightInset(Double points) {
         if (points == null || Double.isNaN(points)) {
-            props.unsetRIns();
+            if (props.isSetRIns()) {
+                props.unsetRIns();
+            }
         } else {
             props.setRIns(Units.toEMU(points));
         }
@@ -135,9 +185,47 @@ public class XDDFBodyProperties {
 
     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);
+        }
+    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSize.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSize.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSize.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSize.java Mon Aug 27 19:25:34 2018
@@ -18,19 +18,7 @@
 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 {
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizeFollowText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizeFollowText.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizeFollowText.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizeFollowText.java Mon Aug 27 19:25:34 2018
@@ -22,7 +22,7 @@ import org.apache.poi.util.Internal;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizeFollowText;
 
 @Beta
-public class XDDFBulletSizeFollowText extends XDDFBulletSize {
+public class XDDFBulletSizeFollowText implements XDDFBulletSize {
     private CTTextBulletSizeFollowText follow;
 
     public XDDFBulletSizeFollowText() {
@@ -38,9 +38,4 @@ public class XDDFBulletSizeFollowText ex
     protected CTTextBulletSizeFollowText getXmlObject() {
         return follow;
     }
-
-    @Override
-    public Kind getType() {
-        return Kind.TEXT;
-    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePercent.java Mon Aug 27 19:25:34 2018
@@ -22,7 +22,7 @@ import org.apache.poi.util.Internal;
 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;
 
@@ -42,16 +42,11 @@ public class XDDFBulletSizePercent exten
         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));
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletSizePoints.java Mon Aug 27 19:25:34 2018
@@ -22,7 +22,7 @@ import org.apache.poi.util.Internal;
 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) {
@@ -40,16 +40,11 @@ public class XDDFBulletSizePoints extend
         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));
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyle.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyle.java Mon Aug 27 19:25:34 2018
@@ -20,6 +20,5 @@ package org.apache.poi.xddf.usermodel.te
 import org.apache.poi.util.Beta;
 
 @Beta
-public abstract class XDDFBulletStyle {
-
+public interface XDDFBulletStyle {
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleAutoNumbered.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleAutoNumbered.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleAutoNumbered.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleAutoNumbered.java Mon Aug 27 19:25:34 2018
@@ -22,12 +22,12 @@ import org.apache.poi.util.Internal;
 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
@@ -53,7 +53,9 @@ public class XDDFBulletStyleAutoNumbered
 
     public void setStartAt(Integer value) {
         if (value == null) {
-            style.unsetStartAt();
+            if (style.isSetStartAt()) {
+                style.unsetStartAt();
+            }
         } else {
             style.setStartAt(value);
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleCharacter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleCharacter.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleCharacter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleCharacter.java Mon Aug 27 19:25:34 2018
@@ -22,7 +22,7 @@ import org.apache.poi.util.Internal;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharBullet;
 
 @Beta
-public class XDDFBulletStyleCharacter extends XDDFBulletStyle {
+public class XDDFBulletStyleCharacter implements XDDFBulletStyle {
     private CTTextCharBullet style;
 
     @Internal

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleNone.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleNone.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleNone.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStyleNone.java Mon Aug 27 19:25:34 2018
@@ -22,7 +22,7 @@ import org.apache.poi.util.Internal;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNoBullet;
 
 @Beta
-public class XDDFBulletStyleNone extends XDDFBulletStyle {
+public class XDDFBulletStyleNone implements XDDFBulletStyle {
     private CTTextNoBullet style;
 
     @Internal

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFBulletStylePicture.java Mon Aug 27 19:25:34 2018
@@ -23,7 +23,7 @@ import org.apache.poi.xddf.usermodel.XDD
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBlipBullet;
 
 @Beta
-public class XDDFBulletStylePicture extends XDDFBulletStyle {
+public class XDDFBulletStylePicture implements XDDFBulletStyle {
     private CTTextBlipBullet style;
 
     @Internal

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFFont.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFFont.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFFont.java Mon Aug 27 19:25:34 2018
@@ -34,22 +34,30 @@ public class XDDFFont {
     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);
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFHyperlink.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFHyperlink.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFHyperlink.java Mon Aug 27 19:25:34 2018
@@ -28,7 +28,7 @@ public class XDDFHyperlink {
 
     public XDDFHyperlink(String id) {
         this(CTHyperlink.Factory.newInstance());
-        this.link.setId(id);;
+        this.link.setId(id);
     }
 
     public XDDFHyperlink(String id, String action) {
@@ -72,7 +72,9 @@ public class XDDFHyperlink {
 
     public void setEndSound(Boolean ends) {
         if (ends == null) {
-            link.unsetEndSnd();
+            if (link.isSetEndSnd()) {
+                link.unsetEndSnd();
+            }
         } else {
             link.setEndSnd(ends);
         }
@@ -88,11 +90,14 @@ public class XDDFHyperlink {
 
     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();
@@ -103,13 +108,14 @@ public class XDDFHyperlink {
 
     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();
@@ -120,7 +126,9 @@ public class XDDFHyperlink {
 
     public void setInvalidURL(String invalid) {
         if (invalid == null) {
-            link.unsetInvalidUrl();
+            if (link.isSetInvalidUrl()) {
+                link.unsetInvalidUrl();
+            }
         } else {
             link.setInvalidUrl(invalid);
         }
@@ -136,7 +144,9 @@ public class XDDFHyperlink {
 
     public void setTargetFrame(String frame) {
         if (frame == null) {
-            link.unsetTgtFrame();
+            if (link.isSetTgtFrame()) {
+                link.unsetTgtFrame();
+            }
         } else {
             link.setTgtFrame(frame);
         }
@@ -152,7 +162,9 @@ public class XDDFHyperlink {
 
     public void setTooltip(String tooltip) {
         if (tooltip == null) {
-            link.unsetTooltip();
+            if (link.isSetTooltip()) {
+                link.unsetTooltip();
+            }
         } else {
             link.setTooltip(tooltip);
         }
@@ -168,7 +180,9 @@ public class XDDFHyperlink {
 
     public void setExtensionList(XDDFExtensionList list) {
         if (list == null) {
-            link.unsetExtLst();
+            if (link.isSetExtLst()) {
+                link.unsetExtLst();
+            }
         } else {
             link.setExtLst(list.getXmlObject());
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFNormalAutoFit.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFNormalAutoFit.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFNormalAutoFit.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFNormalAutoFit.java Mon Aug 27 19:25:34 2018
@@ -50,7 +50,9 @@ public class XDDFNormalAutoFit implement
 
     public void setFontScale(Integer value) {
         if (value == null) {
-            autofit.unsetFontScale();
+            if (autofit.isSetFontScale()) {
+                autofit.unsetFontScale();
+            }
         } else {
             autofit.setFontScale(value);
         }
@@ -67,7 +69,9 @@ public class XDDFNormalAutoFit implement
 
     public void setLineSpaceReduction(Integer value) {
         if (value == null) {
-            autofit.unsetLnSpcReduction();
+            if (autofit.isSetLnSpcReduction()) {
+                autofit.unsetLnSpcReduction();
+            }
         } else {
             autofit.setLnSpcReduction(value);
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphBulletProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphBulletProperties.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphBulletProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphBulletProperties.java Mon Aug 27 19:25:34 2018
@@ -47,10 +47,18 @@ public class XDDFParagraphBulletProperti
     }
 
     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());
@@ -73,16 +81,22 @@ public class XDDFParagraphBulletProperti
     }
 
     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 {
@@ -99,16 +113,22 @@ public class XDDFParagraphBulletProperti
     }
 
     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 {
@@ -129,9 +149,15 @@ public class XDDFParagraphBulletProperti
     }
 
     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());
@@ -144,16 +170,38 @@ public class XDDFParagraphBulletProperti
     }
 
     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();
+        }
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFParagraphProperties.java Mon Aug 27 19:25:34 2018
@@ -57,7 +57,9 @@ public class XDDFParagraphProperties {
 
     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 {
@@ -75,7 +77,9 @@ public class XDDFParagraphProperties {
 
     public void setDefaultRunProperties(XDDFRunProperties properties) {
         if (properties == null) {
-            props.unsetDefRPr();
+            if (props.isSetDefRPr()) {
+                props.unsetDefRPr();
+            }
         } else {
             props.setDefRPr(properties.getXmlObject());
         }
@@ -83,7 +87,9 @@ public class XDDFParagraphProperties {
 
     public void setEastAsianLineBreak(Boolean value) {
         if (value == null) {
-            props.unsetEaLnBrk();
+            if (props.isSetEaLnBrk()) {
+                props.unsetEaLnBrk();
+            }
         } else {
             props.setEaLnBrk(value);
         }
@@ -91,7 +97,9 @@ public class XDDFParagraphProperties {
 
     public void setLatinLineBreak(Boolean value) {
         if (value == null) {
-            props.unsetLatinLnBrk();
+            if (props.isSetLatinLnBrk()) {
+                props.unsetLatinLnBrk();
+            }
         } else {
             props.setLatinLnBrk(value);
         }
@@ -99,7 +107,9 @@ public class XDDFParagraphProperties {
 
     public void setHangingPunctuation(Boolean value) {
         if (value == null) {
-            props.unsetHangingPunct();
+            if (props.isSetHangingPunct()) {
+                props.unsetHangingPunct();
+            }
         } else {
             props.setHangingPunct(value);
         }
@@ -107,7 +117,9 @@ public class XDDFParagraphProperties {
 
     public void setRightToLeft(Boolean value) {
         if (value == null) {
-            props.unsetRtl();
+            if (props.isSetRtl()) {
+                props.unsetRtl();
+            }
         } else {
             props.setRtl(value);
         }
@@ -115,7 +127,9 @@ public class XDDFParagraphProperties {
 
     public void setFontAlignment(FontAlignment align) {
         if (align == null) {
-            props.unsetFontAlgn();
+            if (props.isSetFontAlgn()) {
+                props.unsetFontAlgn();
+            }
         } else {
             props.setFontAlgn(align.underlying);
         }
@@ -123,7 +137,9 @@ public class XDDFParagraphProperties {
 
     public void setTextAlignment(TextAlignment align) {
         if (align == null) {
-            props.unsetAlgn();
+            if (props.isSetAlgn()) {
+                props.unsetAlgn();
+            }
         } else {
             props.setAlgn(align.underlying);
         }
@@ -131,7 +147,9 @@ public class XDDFParagraphProperties {
 
     public void setDefaultTabSize(Double points) {
         if (points == null) {
-            props.unsetDefTabSz();
+            if (props.isSetDefTabSz()) {
+                props.unsetDefTabSz();
+            }
         } else {
             props.setDefTabSz(Units.toEMU(points));
         }
@@ -139,7 +157,9 @@ public class XDDFParagraphProperties {
 
     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 {
@@ -149,7 +169,9 @@ public class XDDFParagraphProperties {
 
     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 {
@@ -159,7 +181,9 @@ public class XDDFParagraphProperties {
 
     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 {
@@ -169,7 +193,9 @@ public class XDDFParagraphProperties {
 
     public void setLineSpacing(XDDFSpacing spacing) {
         if (spacing == null) {
-            props.unsetLnSpc();
+            if (props.isSetLnSpc()) {
+                props.unsetLnSpc();
+            }
         } else {
             props.setLnSpc(spacing.getXmlObject());
         }
@@ -177,7 +203,9 @@ public class XDDFParagraphProperties {
 
     public void setSpaceAfter(XDDFSpacing spacing) {
         if (spacing == null) {
-            props.unsetSpcAft();
+            if (props.isSetSpcAft()) {
+                props.unsetSpcAft();
+            }
         } else {
             props.setSpcAft(spacing.getXmlObject());
         }
@@ -185,7 +213,9 @@ public class XDDFParagraphProperties {
 
     public void setSpaceBefore(XDDFSpacing spacing) {
         if (spacing == null) {
-            props.unsetSpcBef();
+            if (props.isSetSpcBef()) {
+                props.unsetSpcBef();
+            }
         } else {
             props.setSpcBef(spacing.getXmlObject());
         }
@@ -250,7 +280,9 @@ public class XDDFParagraphProperties {
 
     public void setExtensionList(XDDFExtensionList list) {
         if (list == null) {
-            props.unsetExtLst();
+            if (props.isSetExtLst()) {
+                props.unsetExtLst();
+            }
         } else {
             props.setExtLst(list.getXmlObject());
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFRunProperties.java Mon Aug 27 19:25:34 2018
@@ -56,7 +56,9 @@ public class XDDFRunProperties {
 
     public void setBaseline(Integer value) {
         if (value == null) {
-            props.unsetBaseline();
+            if (props.isSetBaseline()) {
+                props.unsetBaseline();
+            }
         } else {
             props.setBaseline(value);
         }
@@ -64,7 +66,9 @@ public class XDDFRunProperties {
 
     public void setDirty(Boolean dirty) {
         if (dirty == null) {
-            props.unsetDirty();
+            if (props.isSetDirty()) {
+                props.unsetDirty();
+            }
         } else {
             props.setDirty(dirty);
         }
@@ -72,7 +76,9 @@ public class XDDFRunProperties {
 
     public void setSpellError(Boolean error) {
         if (error == null) {
-            props.unsetErr();
+            if (props.isSetErr()) {
+                props.unsetErr();
+            }
         } else {
             props.setErr(error);
         }
@@ -80,7 +86,9 @@ public class XDDFRunProperties {
 
     public void setNoProof(Boolean noproof) {
         if (noproof == null) {
-            props.unsetNoProof();
+            if (props.isSetNoProof()) {
+                props.unsetNoProof();
+            }
         } else {
             props.setNoProof(noproof);
         }
@@ -88,7 +96,9 @@ public class XDDFRunProperties {
 
     public void setNormalizeHeights(Boolean normalize) {
         if (normalize == null) {
-            props.unsetNormalizeH();
+            if (props.isSetNormalizeH()) {
+                props.unsetNormalizeH();
+            }
         } else {
             props.setNormalizeH(normalize);
         }
@@ -96,7 +106,9 @@ public class XDDFRunProperties {
 
     public void setKumimoji(Boolean kumimoji) {
         if (kumimoji == null) {
-            props.unsetKumimoji();
+            if (props.isSetKumimoji()) {
+                props.unsetKumimoji();
+            }
         } else {
             props.setKumimoji(kumimoji);
         }
@@ -104,7 +116,9 @@ public class XDDFRunProperties {
 
     public void setBold(Boolean bold) {
         if (bold == null) {
-            props.unsetB();
+            if (props.isSetB()) {
+                props.unsetB();
+            }
         } else {
             props.setB(bold);
         }
@@ -112,7 +126,9 @@ public class XDDFRunProperties {
 
     public void setItalic(Boolean italic) {
         if (italic == null) {
-            props.unsetI();
+            if (props.isSetI()) {
+                props.unsetI();
+            }
         } else {
             props.setI(italic);
         }
@@ -120,21 +136,35 @@ public class XDDFRunProperties {
 
     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;
         }
@@ -155,49 +185,61 @@ public class XDDFRunProperties {
 
     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);
                 }
@@ -207,7 +249,9 @@ public class XDDFRunProperties {
 
     public void setUnderline(UnderlineType underline) {
         if (underline == null) {
-            props.unsetU();
+            if (props.isSetU()) {
+                props.unsetU();
+            }
         } else {
             props.setU(underline.underlying);
         }
@@ -215,7 +259,9 @@ public class XDDFRunProperties {
 
     public void setStrikeThrough(StrikeType strike) {
         if (strike == null) {
-            props.unsetStrike();
+            if (props.isSetStrike()) {
+                props.unsetStrike();
+            }
         } else {
             props.setStrike(strike.underlying);
         }
@@ -223,7 +269,9 @@ public class XDDFRunProperties {
 
     public void setCapitals(CapsType caps) {
         if (caps == null) {
-            props.unsetCap();
+            if (props.isSetCap()) {
+                props.unsetCap();
+            }
         } else {
             props.setCap(caps.underlying);
         }
@@ -231,7 +279,9 @@ public class XDDFRunProperties {
 
     public void setHyperlink(XDDFHyperlink link) {
         if (link == null) {
-            props.unsetHlinkClick();
+            if (props.isSetHlinkClick()) {
+                props.unsetHlinkClick();
+            }
         } else {
             props.setHlinkClick(link.getXmlObject());
         }
@@ -239,7 +289,9 @@ public class XDDFRunProperties {
 
     public void setMouseOver(XDDFHyperlink link) {
         if (link == null) {
-            props.unsetHlinkMouseOver();
+            if (props.isSetHlinkMouseOver()) {
+                props.unsetHlinkMouseOver();
+            }
         } else {
             props.setHlinkMouseOver(link.getXmlObject());
         }
@@ -247,7 +299,9 @@ public class XDDFRunProperties {
 
     public void setLanguage(Locale lang) {
         if (lang == null) {
-            props.unsetLang();
+            if (props.isSetLang()) {
+                props.unsetLang();
+            }
         } else {
             props.setLang(lang.toLanguageTag());
         }
@@ -255,7 +309,9 @@ public class XDDFRunProperties {
 
     public void setAlternativeLanguage(Locale lang) {
         if (lang == null) {
-            props.unsetAltLang();
+            if (props.isSetAltLang()) {
+                props.unsetAltLang();
+            }
         } else {
             props.setAltLang(lang.toLanguageTag());
         }
@@ -263,7 +319,9 @@ public class XDDFRunProperties {
 
     public void setHighlight(XDDFColor color) {
         if (color == null) {
-            props.unsetHighlight();
+            if (props.isSetHighlight()) {
+                props.unsetHighlight();
+            }
         } else {
             props.setHighlight(color.getColorContainer());
         }
@@ -271,7 +329,9 @@ public class XDDFRunProperties {
 
     public void setLineProperties(XDDFLineProperties properties) {
         if (properties == null) {
-            props.unsetLn();
+            if (props.isSetLn()) {
+                props.unsetLn();
+            }
         } else {
             props.setLn(properties.getXmlObject());
         }
@@ -279,7 +339,9 @@ public class XDDFRunProperties {
 
     public void setBookmark(String bookmark) {
         if (bookmark == null) {
-            props.unsetBmk();
+            if (props.isSetBmk()) {
+                props.unsetBmk();
+            }
         } else {
             props.setBmk(bookmark);
         }
@@ -295,7 +357,9 @@ public class XDDFRunProperties {
 
     public void setExtensionList(XDDFExtensionList list) {
         if (list == null) {
-            props.unsetExtLst();
+            if (props.isSetExtLst()) {
+                props.unsetExtLst();
+            }
         } else {
             props.setExtLst(list.getXmlObject());
         }
@@ -311,7 +375,9 @@ public class XDDFRunProperties {
 
     public void setEffectContainer(XDDFEffectContainer container) {
         if (container == null) {
-            props.unsetEffectDag();
+            if (props.isSetEffectDag()) {
+                props.unsetEffectDag();
+            }
         } else {
             props.setEffectDag(container.getXmlObject());
         }
@@ -327,7 +393,9 @@ public class XDDFRunProperties {
 
     public void setEffectList(XDDFEffectList list) {
         if (list == null) {
-            props.unsetEffectLst();
+            if (props.isSetEffectLst()) {
+                props.unsetEffectLst();
+            }
         } else {
             props.setEffectLst(list.getXmlObject());
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPercent.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPercent.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPercent.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPercent.java Mon Aug 27 19:25:34 2018
@@ -29,7 +29,9 @@ public class XDDFSpacingPercent extends
 
     public XDDFSpacingPercent(double value) {
         this(CTTextSpacing.Factory.newInstance(), CTTextSpacingPercent.Factory.newInstance(), null);
-        spacing.unsetSpcPts();
+        if (spacing.isSetSpcPts()) {
+            spacing.unsetSpcPts();
+        }
         spacing.setSpcPct(percent);
         setPercent(value);
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPoints.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPoints.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPoints.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFSpacingPoints.java Mon Aug 27 19:25:34 2018
@@ -28,7 +28,9 @@ public class XDDFSpacingPoints extends X
 
     public XDDFSpacingPoints(double value) {
         this(CTTextSpacing.Factory.newInstance(), CTTextSpacingPoint.Factory.newInstance());
-        spacing.unsetSpcPct();
+        if (spacing.isSetSpcPct()) {
+            spacing.unsetSpcPct();
+        }
         spacing.setSpcPts(points);
         setPoints(value);
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTabStop.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTabStop.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTabStop.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTabStop.java Mon Aug 27 19:25:34 2018
@@ -46,7 +46,9 @@ public class XDDFTabStop {
 
     public void setAlignment(TabAlignment align) {
         if (align == null) {
-            stop.unsetAlgn();
+            if (stop.isSetAlgn()) {
+                stop.unsetAlgn();
+            }
         } else {
             stop.setAlgn(align.underlying);
         }
@@ -62,7 +64,9 @@ public class XDDFTabStop {
 
     public void setPosition(Double position) {
         if (position == null) {
-            stop.unsetPos();
+            if (stop.isSetPos()) {
+                stop.unsetPos();
+            }
         } else {
             stop.setPos(Units.toEMU(position));
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java?rev=1839369&r1=1839368&r2=1839369&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextBody.java Mon Aug 27 19:25:34 2018
@@ -19,6 +19,7 @@ package org.apache.poi.xddf.usermodel.te
 
 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;
@@ -37,7 +38,7 @@ public class XDDFTextBody {
 
     public XDDFTextBody(TextContainer parent) {
         this(parent, CTTextBody.Factory.newInstance());
-        this._body.addNewBodyPr();
+        initialize();
     }
 
     @Internal
@@ -55,6 +56,20 @@ public class XDDFTextBody {
         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);
     }
@@ -72,11 +87,8 @@ public class XDDFTextBody {
     }
 
     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() {
@@ -102,7 +114,10 @@ public class XDDFTextBody {
     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();
@@ -121,7 +136,10 @@ public class XDDFTextBody {
     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();
@@ -140,7 +158,10 @@ public class XDDFTextBody {
     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();
@@ -159,7 +180,10 @@ public class XDDFTextBody {
     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();
@@ -178,7 +202,10 @@ public class XDDFTextBody {
     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();
@@ -197,7 +224,10 @@ public class XDDFTextBody {
     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();
@@ -216,7 +246,10 @@ public class XDDFTextBody {
     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();
@@ -235,7 +268,10 @@ public class XDDFTextBody {
     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();
@@ -254,7 +290,10 @@ public class XDDFTextBody {
     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();
@@ -273,7 +312,10 @@ public class XDDFTextBody {
     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();
@@ -292,8 +334,10 @@ public class XDDFTextBody {
             } else {
                 return findDefinedParagraphProperty(isSet, getter, level - 1);
             }
-        } else {
+        } else if (_parent != null) {
             return _parent.findDefinedParagraphProperty(isSet, getter);
+        } else {
+            return Optional.empty();
         }
     }
 
@@ -308,59 +352,71 @@ public class XDDFTextBody {
             } 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;
-        }
     }
 }



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