]> source.dussan.org Git - poi.git/commitdiff
#59702 - Setting background color in slide master
authorAndreas Beeker <kiwiwings@apache.org>
Sat, 18 Jun 2016 23:48:00 +0000 (23:48 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sat, 18 Jun 2016 23:48:00 +0000 (23:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749108 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
src/ooxml/testcases/org/apache/poi/xslf/TestXSLFSlideShow.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFConnectorShape.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFFreeformShape.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java

index 290b5f49450cd99106fb91f27cae75cd9509b86d..1eac4b2770b42a73451ecadef8078055e83f108a 100644 (file)
@@ -22,20 +22,16 @@ import java.awt.Dimension;
 import java.awt.geom.Rectangle2D;\r
 \r
 import org.apache.poi.POIXMLException;\r
-import org.apache.poi.sl.draw.DrawPaint;\r
 import org.apache.poi.sl.usermodel.Background;\r
-import org.apache.poi.sl.usermodel.ColorStyle;\r
-import org.apache.poi.sl.usermodel.FillStyle;\r
-import org.apache.poi.sl.usermodel.PaintStyle;\r
 import org.apache.poi.sl.usermodel.Placeholder;\r
-import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;\r
+import org.apache.xmlbeans.XmlObject;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;\r
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties;\r
 \r
 /**\r
  * Background shape\r
- *\r
- * @author Yegor Kozlov\r
  */\r
 public class XSLFBackground extends XSLFSimpleShape\r
     implements Background<XSLFShape,XSLFTextParagraph> {\r
@@ -50,27 +46,16 @@ public class XSLFBackground extends XSLFSimpleShape
         return new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());\r
     }\r
 \r
-    @Override\r
-    public Color getFillColor(){\r
-        FillStyle fs = getFillStyle();\r
-        PaintStyle ps = fs.getPaint();\r
-        if (ps instanceof SolidPaint) {\r
-            SolidPaint sp = (SolidPaint)ps;\r
-            ColorStyle cs = sp.getSolidColor();\r
-            return DrawPaint.applyColorTransform(cs);\r
-        }\r
-        return null;\r
-    }\r
-\r
     /**\r
-     * background does not have a associated transform.\r
-     * we return a dummy transform object to prevent exceptions in inherited methods.\r
+     * background does not have a associated transform, therefore we return null\r
+     * \r
+     * @param create ignored\r
      *\r
-     * @return  dummy  CTTransform2D bean\r
+     * @return null\r
      */\r
     @Override\r
-    protected CTTransform2D getXfrm() {\r
-        return CTTransform2D.Factory.newInstance();\r
+    protected CTTransform2D getXfrm(boolean create) {\r
+        return null;\r
     }\r
     \r
     @Override\r
@@ -78,4 +63,50 @@ public class XSLFBackground extends XSLFSimpleShape
         // extending XSLFSimpleShape is a bit unlucky ...\r
         throw new POIXMLException("Can't set a placeholder for a background");\r
     }\r
+\r
+    protected CTBackgroundProperties getBgPr(boolean create) {\r
+        CTBackground bg = (CTBackground)getXmlObject();\r
+        if (!bg.isSetBgPr() && create) {\r
+            if (bg.isSetBgRef()) {\r
+                bg.unsetBgRef();\r
+            }\r
+            return bg.addNewBgPr();\r
+        }\r
+        return bg.getBgPr();\r
+    }\r
+    \r
+    public void setFillColor(Color color) {\r
+        CTBackgroundProperties bgPr = getBgPr(true);\r
+        \r
+        if (color == null) {\r
+            if (bgPr.isSetSolidFill()) {\r
+                bgPr.unsetSolidFill();\r
+            }\r
+\r
+            if (!bgPr.isSetNoFill()) {\r
+                bgPr.addNewNoFill();\r
+            }\r
+        } else {\r
+            if (bgPr.isSetNoFill()) {\r
+                bgPr.unsetNoFill();\r
+            }\r
+\r
+            CTSolidColorFillProperties fill = bgPr.isSetSolidFill() ? bgPr.getSolidFill() : bgPr.addNewSolidFill();\r
+                    \r
+            XSLFColor col = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr());\r
+            col.setColor(color);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    protected XmlObject getShapeProperties() {\r
+        CTBackground bg = (CTBackground)getXmlObject();\r
+        if (bg.isSetBgPr()) {\r
+            return bg.getBgPr();\r
+        } else if (bg.isSetBgRef()) {\r
+            return bg.getBgRef();\r
+        } else {\r
+            return null;\r
+        }\r
+    }\r
 }\r
index 0e9e741b3b6e76115ca45ede1522aa9cd1ca5ff7..3e482d3ea334434251cd5fa9593687e57b09fe33 100644 (file)
@@ -45,8 +45,6 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
 /**\r
  * Represents a custom geometric shape.\r
  * This shape will consist of a series of lines and curves described within a creation path.\r
- *\r
- * @author Yegor Kozlov\r
  */\r
 @Beta\r
 public class XSLFFreeformShape extends XSLFAutoShape\r
@@ -115,7 +113,13 @@ public class XSLFFreeformShape extends XSLFAutoShape
             }\r
             it.next();\r
         }\r
-        getSpPr().getCustGeom().getPathLst().setPathArray(new CTPath2D[]{ctPath});\r
+        \r
+        XmlObject xo = getShapeProperties();\r
+        if (!(xo instanceof CTShapeProperties)) {\r
+            return -1;\r
+        }\r
+\r
+        ((CTShapeProperties)xo).getCustGeom().getPathLst().setPathArray(new CTPath2D[]{ctPath});\r
         setAnchor(bounds);\r
         return numPoints;\r
     }\r
@@ -125,7 +129,12 @@ public class XSLFFreeformShape extends XSLFAutoShape
         Path2D.Double path = new Path2D.Double();\r
         Rectangle2D bounds = getAnchor();\r
 \r
-        CTCustomGeometry2D geom = getSpPr().getCustGeom();\r
+        XmlObject xo = getShapeProperties();\r
+        if (!(xo instanceof CTShapeProperties)) {\r
+            return null;\r
+        }\r
+        \r
+        CTCustomGeometry2D geom = ((CTShapeProperties)xo).getCustGeom();\r
         for(CTPath2D spPath : geom.getPathLst().getPathArray()){\r
             double scaleW = bounds.getWidth() / Units.toPoints(spPath.getW());\r
             double scaleH = bounds.getHeight() / Units.toPoints(spPath.getH());\r
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPropertiesDelegate.java
new file mode 100644 (file)
index 0000000..f6e5ad0
--- /dev/null
@@ -0,0 +1,1830 @@
+/* ====================================================================
+   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.xslf.usermodel;
+
+import org.apache.poi.util.Internal;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTCustomGeometry2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectContainer;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectList;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTNoFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPatternFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties;
+
+/**
+ * Internal helper class to unify property access.
+ * 
+ * This class is experimental and not (yet) supposed for public usage.
+ * Maybe the xml schemas might be enhanced with interfaces to make this class superfluous
+ * 
+ * @since POI 3.15-beta2
+ */
+@Internal
+/* package */ class XSLFPropertiesDelegate {
+    private static final POILogger LOG = POILogFactory.getLogger(XSLFPropertiesDelegate.class);
+
+    
+    public static XSLFFillProperties getFillDelegate(XmlObject props) {
+        return getDelegate(XSLFFillProperties.class, props);
+    }
+
+    public static XSLFGeometryProperties getGeometryDelegate(XmlObject props) {
+        return getDelegate(XSLFGeometryProperties.class, props);
+    }
+    
+    public static XSLFEffectProperties getEffectDelegate(XmlObject props) {
+        return getDelegate(XSLFEffectProperties.class, props);
+    }
+    
+    public interface XSLFFillProperties {
+        /**
+         * Gets the "noFill" element
+         */
+        CTNoFillProperties getNoFill();
+        
+        /**
+         * True if has "noFill" element
+         */
+        boolean isSetNoFill();
+        
+        /**
+         * Sets the "noFill" element
+         */
+        void setNoFill(CTNoFillProperties noFill);
+        
+        /**
+         * Appends and returns a new empty "noFill" element
+         */
+        CTNoFillProperties addNewNoFill();
+        
+        /**
+         * Unsets the "noFill" element
+         */
+        void unsetNoFill();
+        
+        /**
+         * Gets the "solidFill" element
+         */
+        CTSolidColorFillProperties getSolidFill();
+        
+        /**
+         * True if has "solidFill" element
+         */
+        boolean isSetSolidFill();
+        
+        /**
+         * Sets the "solidFill" element
+         */
+        void setSolidFill(CTSolidColorFillProperties solidFill);
+        
+        /**
+         * Appends and returns a new empty "solidFill" element
+         */
+        CTSolidColorFillProperties addNewSolidFill();
+        
+        /**
+         * Unsets the "solidFill" element
+         */
+        void unsetSolidFill();
+        
+        /**
+         * Gets the "gradFill" element
+         */
+        CTGradientFillProperties getGradFill();
+        
+        /**
+         * True if has "gradFill" element
+         */
+        boolean isSetGradFill();
+        
+        /**
+         * Sets the "gradFill" element
+         */
+        void setGradFill(CTGradientFillProperties gradFill);
+        
+        /**
+         * Appends and returns a new empty "gradFill" element
+         */
+        CTGradientFillProperties addNewGradFill();
+        
+        /**
+         * Unsets the "gradFill" element
+         */
+        void unsetGradFill();
+        
+        /**
+         * Gets the "blipFill" element
+         */
+        CTBlipFillProperties getBlipFill();
+        
+        /**
+         * True if has "blipFill" element
+         */
+        boolean isSetBlipFill();
+        
+        /**
+         * Sets the "blipFill" element
+         */
+        void setBlipFill(CTBlipFillProperties blipFill);
+        
+        /**
+         * Appends and returns a new empty "blipFill" element
+         */
+        CTBlipFillProperties addNewBlipFill();
+        
+        /**
+         * Unsets the "blipFill" element
+         */
+        void unsetBlipFill();
+        
+        /**
+         * Gets the "pattFill" element
+         */
+        CTPatternFillProperties getPattFill();
+        
+        /**
+         * True if has "pattFill" element
+         */
+        boolean isSetPattFill();
+        
+        /**
+         * Sets the "pattFill" element
+         */
+        void setPattFill(CTPatternFillProperties pattFill);
+        
+        /**
+         * Appends and returns a new empty "pattFill" element
+         */
+        CTPatternFillProperties addNewPattFill();
+        
+        /**
+         * Unsets the "pattFill" element
+         */
+        void unsetPattFill();
+        
+        /**
+         * Gets the "grpFill" element
+         */
+        CTGroupFillProperties getGrpFill();
+        
+        /**
+         * True if has "grpFill" element
+         */
+        boolean isSetGrpFill();
+        
+        /**
+         * Sets the "grpFill" element
+         */
+        void setGrpFill(CTGroupFillProperties grpFill);
+        
+        /**
+         * Appends and returns a new empty "grpFill" element
+         */
+        CTGroupFillProperties addNewGrpFill();
+        
+        /**
+         * Unsets the "grpFill" element
+         */
+        void unsetGrpFill();
+        
+        /**
+         * Helper method to unify other properties with style matrix references
+         * @return true, if this is a matrix style delegate
+         */
+        boolean isSetMatrixStyle();
+        
+        /**
+         * Helper method to unify other properties with style matrix references
+         */
+        CTStyleMatrixReference getMatrixStyle();
+        
+        /**
+         * Helper method to choose between fill and line style
+         *
+         * @return true, if this applies to a line
+         */
+        boolean isLineStyle();
+    }
+
+    public interface XSLFGeometryProperties {
+        /**
+         * Gets the "custGeom" element
+         */
+        CTCustomGeometry2D getCustGeom();
+        
+        /**
+         * True if has "custGeom" element
+         */
+        boolean isSetCustGeom();
+        
+        /**
+         * Sets the "custGeom" element
+         */
+        void setCustGeom(CTCustomGeometry2D custGeom);
+        
+        /**
+         * Appends and returns a new empty "custGeom" element
+         */
+        CTCustomGeometry2D addNewCustGeom();
+        
+        /**
+         * Unsets the "custGeom" element
+         */
+        void unsetCustGeom();
+        
+        /**
+         * Gets the "prstGeom" element
+         */
+        CTPresetGeometry2D getPrstGeom();
+        
+        /**
+         * True if has "prstGeom" element
+         */
+        boolean isSetPrstGeom();
+        
+        /**
+         * Sets the "prstGeom" element
+         */
+        void setPrstGeom(CTPresetGeometry2D prstGeom);
+        
+        /**
+         * Appends and returns a new empty "prstGeom" element
+         */
+        CTPresetGeometry2D addNewPrstGeom();
+        
+        /**
+         * Unsets the "prstGeom" element
+         */
+        void unsetPrstGeom();
+    }
+
+    public interface XSLFEffectProperties {
+        /**
+         * Gets the "effectLst" element
+         */
+        CTEffectList getEffectLst();
+        
+        /**
+         * True if has "effectLst" element
+         */
+        boolean isSetEffectLst();
+        
+        /**
+         * Sets the "effectLst" element
+         */
+        void setEffectLst(CTEffectList effectLst);
+        
+        /**
+         * Appends and returns a new empty "effectLst" element
+         */
+        CTEffectList addNewEffectLst();
+        
+        /**
+         * Unsets the "effectLst" element
+         */
+        void unsetEffectLst();
+        
+        /**
+         * Gets the "effectDag" element
+         */
+        CTEffectContainer getEffectDag();
+        
+        /**
+         * True if has "effectDag" element
+         */
+        boolean isSetEffectDag();
+        
+        /**
+         * Sets the "effectDag" element
+         */
+        void setEffectDag(CTEffectContainer effectDag);
+        
+        /**
+         * Appends and returns a new empty "effectDag" element
+         */
+        CTEffectContainer addNewEffectDag();
+        
+        /**
+         * Unsets the "effectDag" element
+         */
+        void unsetEffectDag();
+    }
+    
+    private static class ShapeDelegate implements XSLFFillProperties, XSLFGeometryProperties, XSLFEffectProperties {
+        final CTShapeProperties props;
+        
+        ShapeDelegate(CTShapeProperties props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return props.getNoFill();
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return props.isSetNoFill();
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {
+            props.setNoFill(noFill);
+        }
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return props.addNewNoFill();
+        }
+
+        @Override
+        public void unsetNoFill() {
+            props.unsetNoFill();
+        }
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return props.getSolidFill();
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return props.isSetSolidFill();
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {
+            props.setSolidFill(solidFill);
+        }
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return props.addNewSolidFill();
+        }
+
+        @Override
+        public void unsetSolidFill() {
+            props.unsetSolidFill();
+        }
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return props.getGradFill();
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return props.isSetGradFill();
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {
+            props.setGradFill(gradFill);
+        }
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return props.addNewGradFill();
+        }
+
+        @Override
+        public void unsetGradFill() {
+            props.unsetGradFill();
+        }
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return props.getBlipFill();
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return props.isSetBlipFill();
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {
+            props.setBlipFill(blipFill);
+        }
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return props.addNewBlipFill();
+        }
+
+        @Override
+        public void unsetBlipFill() {
+            props.unsetBlipFill();
+        }
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return props.getPattFill();
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return props.isSetPattFill();
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {
+            props.setPattFill(pattFill);
+        }
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return props.addNewPattFill();
+        }
+
+        @Override
+        public void unsetPattFill() {
+            props.unsetPattFill();
+        }
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return props.getGrpFill();
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return props.isSetGrpFill();
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {
+            props.setGrpFill(grpFill);
+        }
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return props.addNewGrpFill();
+        }
+
+        @Override
+        public void unsetGrpFill() {
+            props.unsetGrpFill();
+        }
+
+        @Override
+        public CTCustomGeometry2D getCustGeom() {
+            return props.getCustGeom();
+        }
+
+        @Override
+        public boolean isSetCustGeom() {
+            return props.isSetCustGeom();
+        }
+
+        @Override
+        public void setCustGeom(CTCustomGeometry2D custGeom) {
+            props.setCustGeom(custGeom);
+        }
+
+        @Override
+        public CTCustomGeometry2D addNewCustGeom() {
+            return props.addNewCustGeom();
+        }
+
+        @Override
+        public void unsetCustGeom() {
+            props.unsetCustGeom();
+        }
+
+        @Override
+        public CTPresetGeometry2D getPrstGeom() {
+            return props.getPrstGeom();
+        }
+
+        @Override
+        public boolean isSetPrstGeom() {
+            return props.isSetPrstGeom();
+        }
+
+        @Override
+        public void setPrstGeom(CTPresetGeometry2D prstGeom) {
+            props.setPrstGeom(prstGeom);
+        }
+
+        @Override
+        public CTPresetGeometry2D addNewPrstGeom() {
+            return props.addNewPrstGeom();
+        }
+
+        @Override
+        public void unsetPrstGeom() {
+            props.unsetPrstGeom();
+        }
+
+        @Override
+        public CTEffectList getEffectLst() {
+            return props.getEffectLst();
+        }
+
+        @Override
+        public boolean isSetEffectLst() {
+            return props.isSetEffectLst();
+        }
+
+        @Override
+        public void setEffectLst(CTEffectList effectLst) {
+            props.setEffectLst(effectLst);
+        }
+
+        @Override
+        public CTEffectList addNewEffectLst() {
+            return props.addNewEffectLst();
+        }
+
+        @Override
+        public void unsetEffectLst() {
+            props.unsetEffectLst();
+        }
+
+        @Override
+        public CTEffectContainer getEffectDag() {
+            return props.getEffectDag();
+        }
+
+        @Override
+        public boolean isSetEffectDag() {
+            return props.isSetEffectDag();
+        }
+
+        @Override
+        public void setEffectDag(CTEffectContainer effectDag) {
+            props.setEffectDag(effectDag);
+        }
+
+        @Override
+        public CTEffectContainer addNewEffectDag() {
+            return props.addNewEffectDag();
+        }
+
+        @Override
+        public void unsetEffectDag() {
+            props.unsetEffectDag();
+        }
+
+        @Override
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return false;
+        }
+    }
+
+    private static class BackgroundDelegate implements XSLFFillProperties, XSLFEffectProperties {
+        final CTBackgroundProperties props;
+        
+        BackgroundDelegate(CTBackgroundProperties props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return props.getNoFill();
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return props.isSetNoFill();
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {
+            props.setNoFill(noFill);
+        }
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return props.addNewNoFill();
+        }
+
+        @Override
+        public void unsetNoFill() {
+            props.unsetNoFill();
+        }
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return props.getSolidFill();
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return props.isSetSolidFill();
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {
+            props.setSolidFill(solidFill);
+        }
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return props.addNewSolidFill();
+        }
+
+        @Override
+        public void unsetSolidFill() {
+            props.unsetSolidFill();
+        }
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return props.getGradFill();
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return props.isSetGradFill();
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {
+            props.setGradFill(gradFill);
+        }
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return props.addNewGradFill();
+        }
+
+        @Override
+        public void unsetGradFill() {
+            props.unsetGradFill();
+        }
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return props.getBlipFill();
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return props.isSetBlipFill();
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {
+            props.setBlipFill(blipFill);
+        }
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return props.addNewBlipFill();
+        }
+
+        @Override
+        public void unsetBlipFill() {
+            props.unsetBlipFill();
+        }
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return props.getPattFill();
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return props.isSetPattFill();
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {
+            props.setPattFill(pattFill);
+        }
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return props.addNewPattFill();
+        }
+
+        @Override
+        public void unsetPattFill() {
+            props.unsetPattFill();
+        }
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return props.getGrpFill();
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return props.isSetGrpFill();
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {
+            props.setGrpFill(grpFill);
+        }
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return props.addNewGrpFill();
+        }
+
+        @Override
+        public void unsetGrpFill() {
+            props.unsetGrpFill();
+        }
+
+        @Override
+        public CTEffectList getEffectLst() {
+            return props.getEffectLst();
+        }
+
+        @Override
+        public boolean isSetEffectLst() {
+            return props.isSetEffectLst();
+        }
+
+        @Override
+        public void setEffectLst(CTEffectList effectLst) {
+            props.setEffectLst(effectLst);
+        }
+
+        @Override
+        public CTEffectList addNewEffectLst() {
+            return props.addNewEffectLst();
+        }
+
+        @Override
+        public void unsetEffectLst() {
+            props.unsetEffectLst();
+        }
+
+        @Override
+        public CTEffectContainer getEffectDag() {
+            return props.getEffectDag();
+        }
+
+        @Override
+        public boolean isSetEffectDag() {
+            return props.isSetEffectDag();
+        }
+
+        @Override
+        public void setEffectDag(CTEffectContainer effectDag) {
+            props.setEffectDag(effectDag);
+        }
+
+        @Override
+        public CTEffectContainer addNewEffectDag() {
+            return props.addNewEffectDag();
+        }
+
+        @Override
+        public void unsetEffectDag() {
+            props.unsetEffectDag();
+        }
+
+        @Override
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return false;
+        }
+    }
+
+    private static class TableCellDelegate implements XSLFFillProperties {
+        final CTTableCellProperties props;
+        
+        TableCellDelegate(CTTableCellProperties props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return props.getNoFill();
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return props.isSetNoFill();
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {
+            props.setNoFill(noFill);
+        }
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return props.addNewNoFill();
+        }
+
+        @Override
+        public void unsetNoFill() {
+            props.unsetNoFill();
+        }
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return props.getSolidFill();
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return props.isSetSolidFill();
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {
+            props.setSolidFill(solidFill);
+        }
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return props.addNewSolidFill();
+        }
+
+        @Override
+        public void unsetSolidFill() {
+            props.unsetSolidFill();
+        }
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return props.getGradFill();
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return props.isSetGradFill();
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {
+            props.setGradFill(gradFill);
+        }
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return props.addNewGradFill();
+        }
+
+        @Override
+        public void unsetGradFill() {
+            props.unsetGradFill();
+        }
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return props.getBlipFill();
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return props.isSetBlipFill();
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {
+            props.setBlipFill(blipFill);
+        }
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return props.addNewBlipFill();
+        }
+
+        @Override
+        public void unsetBlipFill() {
+            props.unsetBlipFill();
+        }
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return props.getPattFill();
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return props.isSetPattFill();
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {
+            props.setPattFill(pattFill);
+        }
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return props.addNewPattFill();
+        }
+
+        @Override
+        public void unsetPattFill() {
+            props.unsetPattFill();
+        }
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return props.getGrpFill();
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return props.isSetGrpFill();
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {
+            props.setGrpFill(grpFill);
+        }
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return props.addNewGrpFill();
+        }
+
+        @Override
+        public void unsetGrpFill() {
+            props.unsetGrpFill();
+        }
+
+        @Override
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return false;
+        }
+    }
+
+    private static class StyleMatrixDelegate implements XSLFFillProperties {
+        final CTStyleMatrixReference props;
+        
+        StyleMatrixDelegate(CTStyleMatrixReference props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return false;
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {}
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetNoFill() {}
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return false;
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {}
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetSolidFill() {}
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return false;
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {}
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetGradFill() {}
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return false;
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {}
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetBlipFill() {}
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return false;
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {}
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetPattFill() {}
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return false;
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {}
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetGrpFill() {}
+
+    
+        @Override
+        public boolean isSetMatrixStyle() {
+            return true;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return props;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            XmlCursor cur = props.newCursor();
+            String name = cur.getName().getLocalPart();
+            cur.dispose();
+            return "lnRef".equals(name);
+        }
+    }
+
+    private static class FillDelegate implements XSLFFillProperties {
+        final CTFillProperties props;
+        
+        FillDelegate(CTFillProperties props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return props.getNoFill();
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return props.isSetNoFill();
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {
+            props.setNoFill(noFill);
+        }
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return props.addNewNoFill();
+        }
+
+        @Override
+        public void unsetNoFill() {
+            props.unsetNoFill();
+        }
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return props.getSolidFill();
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return props.isSetSolidFill();
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {
+            props.setSolidFill(solidFill);
+        }
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return props.addNewSolidFill();
+        }
+
+        @Override
+        public void unsetSolidFill() {
+            props.unsetSolidFill();
+        }
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return props.getGradFill();
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return props.isSetGradFill();
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {
+            props.setGradFill(gradFill);
+        }
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return props.addNewGradFill();
+        }
+
+        @Override
+        public void unsetGradFill() {
+            props.unsetGradFill();
+        }
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return props.getBlipFill();
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return props.isSetBlipFill();
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {
+            props.setBlipFill(blipFill);
+        }
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return props.addNewBlipFill();
+        }
+
+        @Override
+        public void unsetBlipFill() {
+            props.unsetBlipFill();
+        }
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return props.getPattFill();
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return props.isSetPattFill();
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {
+            props.setPattFill(pattFill);
+        }
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return props.addNewPattFill();
+        }
+
+        @Override
+        public void unsetPattFill() {
+            props.unsetPattFill();
+        }
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return props.getGrpFill();
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return props.isSetGrpFill();
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {
+            props.setGrpFill(grpFill);
+        }
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return props.addNewGrpFill();
+        }
+
+        @Override
+        public void unsetGrpFill() {
+            props.unsetGrpFill();
+        }
+
+        @Override
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return false;
+        }
+    }
+
+    private static class FillPartDelegate implements XSLFFillProperties {
+        final XmlObject props;
+        
+        FillPartDelegate(XmlObject props) {
+            this.props = props;
+        }
+
+        public CTNoFillProperties getNoFill() {
+            return isSetNoFill() ? (CTNoFillProperties)props : null;
+        }
+
+        public boolean isSetNoFill() {
+            return (props instanceof CTNoFillProperties);
+        }
+
+        public void setNoFill(CTNoFillProperties noFill) {}
+
+        public CTNoFillProperties addNewNoFill() {
+            return null;
+        }
+
+        public void unsetNoFill() {}
+
+        public CTSolidColorFillProperties getSolidFill() {
+            return isSetSolidFill() ? (CTSolidColorFillProperties)props : null;
+        }
+
+        public boolean isSetSolidFill() {
+            return (props instanceof CTSolidColorFillProperties);
+        }
+
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {}
+
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return null;
+        }
+
+        public void unsetSolidFill() {}
+
+        public CTGradientFillProperties getGradFill() {
+            return isSetGradFill() ? (CTGradientFillProperties)props : null;
+        }
+
+        public boolean isSetGradFill() {
+            return (props instanceof CTGradientFillProperties);
+        }
+
+        public void setGradFill(CTGradientFillProperties gradFill) {}
+
+        public CTGradientFillProperties addNewGradFill() {
+            return null;
+        }
+
+        public void unsetGradFill() {}
+
+        public CTBlipFillProperties getBlipFill() {
+            return isSetBlipFill() ? (CTBlipFillProperties)props : null;
+        }
+
+        public boolean isSetBlipFill() {
+            return (props instanceof CTBlipFillProperties);
+        }
+
+        public void setBlipFill(CTBlipFillProperties blipFill) {}
+
+        public CTBlipFillProperties addNewBlipFill() {
+            return null;
+        }
+
+        public void unsetBlipFill() {}
+
+        public CTPatternFillProperties getPattFill() {
+            return isSetPattFill() ? (CTPatternFillProperties)props : null;
+        }
+
+        public boolean isSetPattFill() {
+            return (props instanceof CTPatternFillProperties);
+        }
+
+        public void setPattFill(CTPatternFillProperties pattFill) {}
+
+        public CTPatternFillProperties addNewPattFill() {
+            return null;
+        }
+
+        public void unsetPattFill() {}
+
+        public CTGroupFillProperties getGrpFill() {
+            return isSetGrpFill() ? (CTGroupFillProperties)props : null;
+        }
+
+        public boolean isSetGrpFill() {
+            return (props instanceof CTGroupFillProperties);
+        }
+
+        public void setGrpFill(CTGroupFillProperties grpFill) {}
+
+        public CTGroupFillProperties addNewGrpFill() {
+            return null;
+        }
+
+        public void unsetGrpFill() {}
+
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return false;
+        }
+    }
+    
+    private static class LineStyleDelegate implements XSLFFillProperties {
+        final CTLineProperties props;
+        
+        LineStyleDelegate(CTLineProperties props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return props.getNoFill();
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return props.isSetNoFill();
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {
+            props.setNoFill(noFill);
+        }
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return props.addNewNoFill();
+        }
+
+        @Override
+        public void unsetNoFill() {
+            props.unsetNoFill();
+        }
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return props.getSolidFill();
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return props.isSetSolidFill();
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {
+            props.setSolidFill(solidFill);
+        }
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return props.addNewSolidFill();
+        }
+
+        @Override
+        public void unsetSolidFill() {
+            props.unsetSolidFill();
+        }
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return props.getGradFill();
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return props.isSetGradFill();
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {
+            props.setGradFill(gradFill);
+        }
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return props.addNewGradFill();
+        }
+
+        @Override
+        public void unsetGradFill() {
+            props.unsetGradFill();
+        }
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return false;
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {}
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetBlipFill() {}
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return props.getPattFill();
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return props.isSetPattFill();
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {
+            props.setPattFill(pattFill);
+        }
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return props.addNewPattFill();
+        }
+
+        @Override
+        public void unsetPattFill() {
+            props.unsetPattFill();
+        }
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return null;
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return false;
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {}
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return null;
+        }
+
+        @Override
+        public void unsetGrpFill() {}
+
+        @Override
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return true;
+        }
+    }
+    
+    private static class TextCharDelegate implements XSLFFillProperties {
+        final CTTextCharacterProperties props;
+        
+        TextCharDelegate(CTTextCharacterProperties props) {
+            this.props = props;
+        }
+
+        @Override
+        public CTNoFillProperties getNoFill() {
+            return props.getNoFill();
+        }
+
+        @Override
+        public boolean isSetNoFill() {
+            return props.isSetNoFill();
+        }
+
+        @Override
+        public void setNoFill(CTNoFillProperties noFill) {
+            props.setNoFill(noFill);
+        }
+
+        @Override
+        public CTNoFillProperties addNewNoFill() {
+            return props.addNewNoFill();
+        }
+
+        @Override
+        public void unsetNoFill() {
+            props.unsetNoFill();
+        }
+
+        @Override
+        public CTSolidColorFillProperties getSolidFill() {
+            return props.getSolidFill();
+        }
+
+        @Override
+        public boolean isSetSolidFill() {
+            return props.isSetSolidFill();
+        }
+
+        @Override
+        public void setSolidFill(CTSolidColorFillProperties solidFill) {
+            props.setSolidFill(solidFill);
+        }
+
+        @Override
+        public CTSolidColorFillProperties addNewSolidFill() {
+            return props.addNewSolidFill();
+        }
+
+        @Override
+        public void unsetSolidFill() {
+            props.unsetSolidFill();
+        }
+
+        @Override
+        public CTGradientFillProperties getGradFill() {
+            return props.getGradFill();
+        }
+
+        @Override
+        public boolean isSetGradFill() {
+            return props.isSetGradFill();
+        }
+
+        @Override
+        public void setGradFill(CTGradientFillProperties gradFill) {
+            props.setGradFill(gradFill);
+        }
+
+        @Override
+        public CTGradientFillProperties addNewGradFill() {
+            return props.addNewGradFill();
+        }
+
+        @Override
+        public void unsetGradFill() {
+            props.unsetGradFill();
+        }
+
+        @Override
+        public CTBlipFillProperties getBlipFill() {
+            return props.getBlipFill();
+        }
+
+        @Override
+        public boolean isSetBlipFill() {
+            return props.isSetBlipFill();
+        }
+
+        @Override
+        public void setBlipFill(CTBlipFillProperties blipFill) {
+            props.setBlipFill(blipFill);
+        }
+
+        @Override
+        public CTBlipFillProperties addNewBlipFill() {
+            return props.addNewBlipFill();
+        }
+
+        @Override
+        public void unsetBlipFill() {
+            props.unsetBlipFill();
+        }
+
+        @Override
+        public CTPatternFillProperties getPattFill() {
+            return props.getPattFill();
+        }
+
+        @Override
+        public boolean isSetPattFill() {
+            return props.isSetPattFill();
+        }
+
+        @Override
+        public void setPattFill(CTPatternFillProperties pattFill) {
+            props.setPattFill(pattFill);
+        }
+
+        @Override
+        public CTPatternFillProperties addNewPattFill() {
+            return props.addNewPattFill();
+        }
+
+        @Override
+        public void unsetPattFill() {
+            props.unsetPattFill();
+        }
+
+        @Override
+        public CTGroupFillProperties getGrpFill() {
+            return props.getGrpFill();
+        }
+
+        @Override
+        public boolean isSetGrpFill() {
+            return props.isSetGrpFill();
+        }
+
+        @Override
+        public void setGrpFill(CTGroupFillProperties grpFill) {
+            props.setGrpFill(grpFill);
+        }
+
+        @Override
+        public CTGroupFillProperties addNewGrpFill() {
+            return props.addNewGrpFill();
+        }
+
+        @Override
+        public void unsetGrpFill() {
+            props.unsetGrpFill();
+        }
+
+        @Override
+        public boolean isSetMatrixStyle() {
+            return false;
+        }
+
+        @Override
+        public CTStyleMatrixReference getMatrixStyle() {
+            return null;
+        }
+        
+        @Override
+        public boolean isLineStyle() {
+            return false;
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    private static <T> T getDelegate(Class<T> clazz, XmlObject props) {
+        Object obj = null;
+        if (props == null) {
+            return null;
+        } else if (props instanceof CTShapeProperties) {
+            obj = new ShapeDelegate((CTShapeProperties)props);
+        } else if (props instanceof CTBackgroundProperties) {
+            obj = new BackgroundDelegate((CTBackgroundProperties)props);
+        } else if (props instanceof CTStyleMatrixReference) {
+            obj = new StyleMatrixDelegate((CTStyleMatrixReference)props);
+        } else if (props instanceof CTTableCellProperties) {
+            obj = new TableCellDelegate((CTTableCellProperties)props);
+        } else if (props instanceof CTNoFillProperties
+            || props instanceof CTSolidColorFillProperties
+            || props instanceof CTGradientFillProperties
+            || props instanceof CTBlipFillProperties
+            || props instanceof CTPatternFillProperties
+            || props instanceof CTGroupFillProperties) {
+            obj = new FillPartDelegate(props);
+        } else if (props instanceof CTFillProperties) {
+            obj = new FillDelegate((CTFillProperties)props);
+        } else if (props instanceof CTLineProperties) {
+            obj = new LineStyleDelegate((CTLineProperties)props);
+        } else if (props instanceof CTTextCharacterProperties) {
+            obj = new TextCharDelegate((CTTextCharacterProperties)props);
+        } else {
+            LOG.log(POILogger.ERROR, props.getClass().toString()+" is an unknown properties type");
+            return null;
+        }
+
+        if (clazz.isInstance(obj)) {
+            return (T)obj;
+        }
+        
+        LOG.log(POILogger.WARN, obj.getClass().toString()+" doesn't implement "+clazz.toString());
+        return null;
+    }
+}
index 6dfe1d0c935882a4c3ffdeb2a58582eaa145c079..0c4e4971d5375e020c2dbd1177487ac1ba556574 100644 (file)
@@ -41,13 +41,14 @@ import org.apache.poi.sl.usermodel.Shape;
 import org.apache.poi.util.Beta;\r
 import org.apache.poi.util.Internal;\r
 import org.apache.poi.xslf.model.PropertyFetcher;\r
+import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;\r
+import org.apache.xmlbeans.XmlCursor;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGradientStop;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTNoFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;\r
@@ -57,7 +58,6 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.STPathShadeType;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;\r
-import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;\r
@@ -68,11 +68,12 @@ import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
  */\r
 @Beta\r
 public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {\r
+    protected static final String PML_NS = "http://schemas.openxmlformats.org/presentationml/2006/main";\r
+    \r
     private final XmlObject _shape;\r
     private final XSLFSheet _sheet;\r
     private XSLFShapeContainer _parent;\r
 \r
-    private CTShapeProperties _spPr;\r
     private CTShapeStyle _spStyle;\r
     private CTNonVisualDrawingProps _nvPr;\r
     private CTPlaceholder _ph;\r
@@ -151,75 +152,52 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
         final XSLFTheme theme = getSheet().getTheme();\r
         PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                XmlObject pr = null;\r
-                try {\r
-                    pr = shape.getSpPr();\r
-                    if (((CTShapeProperties)pr).isSetNoFill()) {\r
-                        setValue(null);\r
-                        return true;\r
-                    }                    \r
-                } catch (IllegalStateException e) {}\r
-                // trying background properties now\r
-                if (pr == null) {\r
-                    pr = shape.getBgPr();\r
-                }\r
-                if (pr == null) {\r
-                    pr = shape.getGrpSpPr();\r
+                XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(shape.getShapeProperties());\r
+                if (fp == null) {\r
+                    return false;\r
                 }\r
-                if (pr == null) {\r
-                    if (shape.getXmlObject() instanceof CTBackground) {\r
-                        pr = shape.getXmlObject();\r
-                    }\r
+\r
+                if (fp.isSetNoFill()) {\r
+                    setValue(null);\r
+                    return true;\r
                 }\r
                 \r
-                if (pr == null) return false;\r
-                \r
-                PaintStyle paint = null;\r
-                PackagePart pp = getSheet().getPackagePart();\r
-                for (XmlObject obj : pr.selectPath("*")) {\r
-                    paint = selectPaint(obj, null, pp, theme);\r
-                    if (paint != null) {\r
-                        setValue(paint);\r
-                        return true;\r
-                    }\r
+                PackagePart pp = shape.getSheet().getPackagePart();\r
+                PaintStyle paint = selectPaint(fp, null, pp, theme);\r
+                if (paint != null) {\r
+                    setValue(paint);\r
+                    return true;\r
+                }\r
+\r
+                CTShapeStyle style = shape.getSpStyle();\r
+                if (style != null) {\r
+                    fp = XSLFPropertiesDelegate.getFillDelegate(style.getFillRef());\r
+                    paint = selectPaint(fp, null, pp, theme);\r
+                }\r
+                if (paint != null) {\r
+                    setValue(paint);\r
+                    return true;\r
                 }\r
                 \r
+                \r
                 return false;\r
             }\r
         };\r
         fetchShapeProperty(fetcher);\r
 \r
-        PaintStyle paint = fetcher.getValue();\r
-        if (paint != null) return paint;\r
-        \r
-        // fill color was not found, check if it is defined in the theme\r
-        // get a reference to a fill style within the style matrix.\r
-        CTStyleMatrixReference fillRef = null;\r
-        if (fillRef == null) {\r
-            CTShapeStyle style = getSpStyle();\r
-            if (style != null) fillRef = style.getFillRef();\r
-        }\r
-        if (fillRef == null) {\r
-            fillRef = getBgRef();\r
-        }\r
-        paint = selectPaint(fillRef, theme);\r
-\r
-        return paint;\r
+        return fetcher.getValue();\r
     }\r
 \r
     protected CTBackgroundProperties getBgPr() {\r
-        String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgPr";\r
-        return selectProperty(CTBackgroundProperties.class, xquery);\r
+        return getChild(CTBackgroundProperties.class, PML_NS, "bgPr");\r
     }\r
     \r
     protected CTStyleMatrixReference getBgRef() {\r
-        String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgRef";\r
-        return selectProperty(CTStyleMatrixReference.class, xquery);\r
+        return getChild(CTStyleMatrixReference.class, PML_NS, "bgRef");\r
     }\r
     \r
     protected CTGroupShapeProperties getGrpSpPr() {\r
-        String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:grpSpPr";\r
-        return selectProperty(CTGroupShapeProperties.class, xquery);\r
+        return getChild(CTGroupShapeProperties.class, PML_NS, "grpSpPr");\r
     }\r
     \r
     protected CTNonVisualDrawingProps getCNvPr() {\r
@@ -230,28 +208,35 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
         return _nvPr;\r
     }\r
 \r
-    protected CTShapeProperties getSpPr() {\r
-        if (_spPr == null) {\r
-            String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:spPr";\r
-            _spPr = selectProperty(CTShapeProperties.class, xquery);\r
-        }\r
-        if (_spPr == null) {\r
-            throw new IllegalStateException("CTShapeProperties was not found.");\r
-        }\r
-        return _spPr;\r
-    }\r
-\r
     protected CTShapeStyle getSpStyle() {\r
         if (_spStyle == null) {\r
-            String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:style";\r
-            _spStyle = selectProperty(CTShapeStyle.class, xquery);\r
+            _spStyle = getChild(CTShapeStyle.class, PML_NS, "style");\r
         }\r
         return _spStyle;\r
     }\r
 \r
+    /**\r
+     * Return direct child objects of this shape\r
+     *\r
+     * @param childClass the class to cast the properties to\r
+     * @param namespace the namespace - usually it is {@code "http://schemas.openxmlformats.org/presentationml/2006/main"}\r
+     * @param nodename the node name, without prefix\r
+     * @return the properties object or null if it can't be found\r
+     */\r
+    @SuppressWarnings("unchecked")\r
+    protected <T extends XmlObject> T getChild(Class<T> childClass, String namespace, String nodename) {\r
+        XmlCursor cur = getXmlObject().newCursor();\r
+        T child = null;\r
+        if (cur.toChild(namespace, nodename)) {\r
+            child = (T)cur.getObject();\r
+        }\r
+        cur.dispose();\r
+        return child;\r
+    }\r
+    \r
     protected CTPlaceholder getCTPlaceholder() {\r
         if (_ph == null) {\r
-            String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:nvPr/p:ph";\r
+            String xquery = "declare namespace p='"+PML_NS+"' .//*/p:nvPr/p:ph";\r
             _ph = selectProperty(CTPlaceholder.class, xquery);\r
         }\r
         return _ph;\r
@@ -275,7 +260,7 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
      * @param placeholder\r
      */\r
     protected void setPlaceholder(Placeholder placeholder) {\r
-        String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:nvPr";\r
+        String xquery = "declare namespace p='"+PML_NS+"' .//*/p:nvPr";\r
         CTApplicationNonVisualDrawingProps nv = selectProperty(CTApplicationNonVisualDrawingProps.class, xquery);\r
         if (nv == null) return;\r
         if(placeholder == null) {\r
@@ -362,48 +347,28 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
         return ok;\r
     }\r
 \r
-    protected PaintStyle getPaint(XmlObject spPr, CTSchemeColor phClr) {\r
-        PaintStyle paint = null;\r
-        XSLFSheet sheet = getSheet(); \r
-        PackagePart pp = sheet.getPackagePart();\r
-        XSLFTheme theme = sheet.getTheme();\r
-        for (XmlObject obj : spPr.selectPath("*")) {\r
-            paint = selectPaint(obj, phClr, pp, theme);\r
-            if(paint != null) break;\r
-        }\r
-        return paint;\r
-    }\r
-    \r
     /**\r
      * Convert shape fill into java.awt.Paint. The result is either Color or\r
      * TexturePaint or GradientPaint or null\r
      *\r
-     * @param obj       the xml to read. Must contain elements from the EG_ColorChoice group:\r
-     * <code>\r
-     *     a:scrgbClr    RGB Color Model - Percentage Variant\r
-     *     a:srgbClr    RGB Color Model - Hex Variant\r
-     *     a:hslClr    Hue, Saturation, Luminance Color Model\r
-     *     a:sysClr    System Color\r
-     *     a:schemeClr    Scheme Color\r
-     *     a:prstClr    Preset Color\r
-     *  </code>\r
-     *\r
-     * @param phClr     context color\r
-     * @param parentPart    the parent package part. Any external references (images, etc.) are resolved relative to it.\r
+     * @param fp          a properties handler specific to the underlying shape properties\r
+     * @param phClr       context color\r
+     * @param parentPart  the parent package part. Any external references (images, etc.) are resolved relative to it.\r
+     * @param theme       the theme for the shape/sheet\r
      *\r
      * @return  the applied Paint or null if none was applied\r
      */\r
-    protected static PaintStyle selectPaint(XmlObject obj, final CTSchemeColor phClr, final PackagePart parentPart, final XSLFTheme theme) {\r
-        if (obj instanceof CTNoFillProperties) {\r
+    protected static PaintStyle selectPaint(XSLFFillProperties fp, final CTSchemeColor phClr, final PackagePart parentPart, final XSLFTheme theme) {\r
+        if (fp == null || fp.isSetNoFill()) {\r
             return null;\r
-        } else if (obj instanceof CTSolidColorFillProperties) {\r
-            return selectPaint((CTSolidColorFillProperties)obj, phClr, theme);\r
-        } else if (obj instanceof CTBlipFillProperties) {\r
-            return selectPaint((CTBlipFillProperties)obj, parentPart);\r
-        } else if (obj instanceof CTGradientFillProperties) {\r
-            return selectPaint((CTGradientFillProperties) obj, phClr, theme);\r
-        } else if (obj instanceof CTStyleMatrixReference) {\r
-            return selectPaint((CTStyleMatrixReference)obj, theme);\r
+        } else if (fp.isSetSolidFill()) {\r
+            return selectPaint(fp.getSolidFill(), phClr, theme);\r
+        } else if (fp.isSetBlipFill()) {\r
+            return selectPaint(fp.getBlipFill(), parentPart);\r
+        } else if (fp.isSetGradFill()) {\r
+            return selectPaint(fp.getGradFill(), phClr, theme);\r
+        } else if (fp.isSetMatrixStyle()) {\r
+            return selectPaint(fp.getMatrixStyle(), theme, fp.isLineStyle());\r
         } else {\r
             return null;\r
         }\r
@@ -518,7 +483,7 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
         };        \r
     }\r
     \r
-    protected static PaintStyle selectPaint(CTStyleMatrixReference fillRef, final XSLFTheme theme) {\r
+    protected static PaintStyle selectPaint(CTStyleMatrixReference fillRef, final XSLFTheme theme, boolean isLineStyle) {\r
         if (fillRef == null) return null;\r
         \r
         // The idx attribute refers to the index of a fill style or\r
@@ -528,18 +493,39 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> {
         // values 1001 and above refer to the index of a background fill style within the bgFillStyleLst element.\r
         int idx = (int)fillRef.getIdx();\r
         CTSchemeColor phClr = fillRef.getSchemeClr();\r
-        XmlObject fillProps = null;\r
         CTStyleMatrix matrix = theme.getXmlObject().getThemeElements().getFmtScheme();\r
+        XmlObject styleLst = null;\r
+        int childIdx;\r
         if (idx >= 1 && idx <= 999) {\r
-            fillProps = matrix.getFillStyleLst().selectPath("*")[idx - 1];\r
+            childIdx = idx-1;\r
+            styleLst = (isLineStyle) ? matrix.getLnStyleLst() : matrix.getFillStyleLst();\r
         } else if (idx >= 1001 ){\r
-            fillProps = matrix.getBgFillStyleLst().selectPath("*")[idx - 1001];\r
+            childIdx = idx - 1001;\r
+            styleLst = matrix.getBgFillStyleLst();\r
+        } else {\r
+            return null;\r
+        }\r
+        XmlCursor cur = styleLst.newCursor();\r
+        XSLFFillProperties fp = null;\r
+        if (cur.toChild(childIdx)) {\r
+            fp = XSLFPropertiesDelegate.getFillDelegate(cur.getObject());\r
         }\r
-        return (fillProps == null) ? null : selectPaint(fillProps, phClr, theme.getPackagePart(), theme);\r
+        cur.dispose();\r
+        \r
+        return selectPaint(fp, phClr, theme.getPackagePart(), theme);\r
     }\r
     \r
     @Override\r
     public void draw(Graphics2D graphics, Rectangle2D bounds) {\r
         DrawFactory.getInstance(graphics).drawShape(graphics, this, bounds);\r
     }\r
+    \r
+    /**\r
+     * Return the shape specific (visual) properties\r
+     *\r
+     * @return the shape specific properties\r
+     */\r
+    protected XmlObject getShapeProperties() {\r
+        return getChild(CTShapeProperties.class, PML_NS, "spPr");\r
+    }\r
 }
\ No newline at end of file
index b90fbb06721aaec05db75d18600123dd773ee2eb..6116941cf03f3d060d5dfd5888c9718a0fe82447 100644 (file)
@@ -26,6 +26,7 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;\r
 \r
 import org.apache.poi.openxml4j.opc.PackagePart;\r
+import org.apache.poi.sl.draw.DrawPaint;\r
 import org.apache.poi.sl.draw.geom.CustomGeometry;\r
 import org.apache.poi.sl.draw.geom.Guide;\r
 import org.apache.poi.sl.draw.geom.PresetGeometries;\r
@@ -43,8 +44,13 @@ import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
 import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;\r
 import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;\r
 import org.apache.poi.util.Beta;\r
+import org.apache.poi.util.POILogFactory;\r
+import org.apache.poi.util.POILogger;\r
 import org.apache.poi.util.Units;\r
 import org.apache.poi.xslf.model.PropertyFetcher;\r
+import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFEffectProperties;\r
+import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;\r
+import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFGeometryProperties;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBaseStyles;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;\r
@@ -82,6 +88,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 public abstract class XSLFSimpleShape extends XSLFShape\r
     implements SimpleShape<XSLFShape,XSLFTextParagraph> {\r
     private static CTOuterShadowEffect NO_SHADOW = CTOuterShadowEffect.Factory.newInstance();\r
+    private static final POILogger LOG = POILogFactory.getLogger(XSLFSimpleShape.class);\r
 \r
     /* package */XSLFSimpleShape(XmlObject shape, XSLFSheet sheet) {\r
         super(shape,sheet);\r
@@ -89,40 +96,64 @@ public abstract class XSLFSimpleShape extends XSLFShape
 \r
     @Override\r
     public void setShapeType(ShapeType type) {\r
-        STShapeType.Enum geom = STShapeType.Enum.forInt(type.ooxmlId);\r
-        getSpPr().getPrstGeom().setPrst(geom);\r
+        XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());\r
+        if (gp == null) {\r
+            return;\r
+        }\r
+        if (gp.isSetCustGeom()) {\r
+            gp.unsetCustGeom();\r
+        }\r
+        CTPresetGeometry2D prst = (gp.isSetPrstGeom()) ? gp.getPrstGeom() : gp.addNewPrstGeom();\r
+        prst.setPrst(STShapeType.Enum.forInt(type.ooxmlId));\r
     }\r
 \r
     @Override\r
     public ShapeType getShapeType(){\r
-        STShapeType.Enum geom = getSpPr().getPrstGeom().getPrst();\r
-        return ShapeType.forId(geom.intValue(), true);\r
-    }\r
-\r
-    protected CTTransform2D getSafeXfrm() {\r
-        CTTransform2D xfrm = getXfrm();\r
-        return (xfrm == null ? getSpPr().addNewXfrm() : xfrm);\r
+        XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());\r
+        if (gp != null && gp.isSetPrstGeom()) {\r
+            STShapeType.Enum geom = gp.getPrstGeom().getPrst();\r
+            if (geom != null) {\r
+                return ShapeType.forId(geom.intValue(), true);\r
+            }\r
+        }\r
+        return null;\r
     }\r
 \r
-    protected CTTransform2D getXfrm() {\r
+    protected CTTransform2D getXfrm(boolean create) {\r
         PropertyFetcher<CTTransform2D> fetcher = new PropertyFetcher<CTTransform2D>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTShapeProperties pr = shape.getSpPr();\r
-                if (pr.isSetXfrm()) {\r
-                    setValue(pr.getXfrm());\r
+                XmlObject xo = shape.getShapeProperties();\r
+                if (xo instanceof CTShapeProperties && ((CTShapeProperties)xo).isSetXfrm()) {\r
+                    setValue(((CTShapeProperties)xo).getXfrm());\r
                     return true;\r
                 }\r
                 return false;\r
             }\r
         };\r
         fetchShapeProperty(fetcher);\r
-        return fetcher.getValue();\r
+        \r
+        CTTransform2D xfrm = fetcher.getValue();\r
+        if (!create || xfrm != null) {\r
+            return xfrm;\r
+        } else {\r
+            XmlObject xo = getShapeProperties();\r
+            if (xo instanceof CTShapeProperties) {\r
+                return ((CTShapeProperties)xo).addNewXfrm();\r
+            } else {\r
+                // ... group shapes have their own getXfrm()\r
+                LOG.log(POILogger.WARN, getClass().toString()+" doesn't have xfrm element.");\r
+                return null;\r
+            }\r
+        }\r
     }\r
 \r
     @Override\r
     public Rectangle2D getAnchor() {\r
 \r
-        CTTransform2D xfrm = getXfrm();\r
+        CTTransform2D xfrm = getXfrm(false);\r
+        if (xfrm == null) {\r
+            return null;\r
+        }\r
 \r
         CTPoint2D off = xfrm.getOff();\r
         double x = Units.toPoints(off.getX());\r
@@ -135,7 +166,10 @@ public abstract class XSLFSimpleShape extends XSLFShape
 \r
     @Override\r
     public void setAnchor(Rectangle2D anchor) {\r
-        CTTransform2D xfrm = getSafeXfrm();\r
+        CTTransform2D xfrm = getXfrm(true);\r
+        if (xfrm == null) {\r
+            return;\r
+        }\r
         CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();\r
         long x = Units.toEMU(anchor.getX());\r
         long y = Units.toEMU(anchor.getY());\r
@@ -151,35 +185,44 @@ public abstract class XSLFSimpleShape extends XSLFShape
 \r
     @Override\r
     public void setRotation(double theta) {\r
-        getSafeXfrm().setRot((int) (theta * 60000));\r
+        CTTransform2D xfrm = getXfrm(true);\r
+        if (xfrm != null) {\r
+            xfrm.setRot((int) (theta * 60000));\r
+        }\r
     }\r
 \r
     @Override\r
     public double getRotation() {\r
-        CTTransform2D xfrm = getXfrm();\r
+        CTTransform2D xfrm = getXfrm(false);\r
         return (xfrm == null || !xfrm.isSetRot()) ? 0 : (xfrm.getRot() / 60000.d);\r
     }\r
 \r
     @Override\r
     public void setFlipHorizontal(boolean flip) {\r
-        getSafeXfrm().setFlipH(flip);\r
+        CTTransform2D xfrm = getXfrm(true);\r
+        if (xfrm != null) {\r
+            xfrm.setFlipH(flip);\r
+        }\r
     }\r
 \r
     @Override\r
     public void setFlipVertical(boolean flip) {\r
-        getSafeXfrm().setFlipV(flip);\r
+        CTTransform2D xfrm = getXfrm(true);\r
+        if (xfrm != null) {\r
+            xfrm.setFlipV(flip);\r
+        }\r
     }\r
 \r
     @Override\r
     public boolean getFlipHorizontal() {\r
-        CTTransform2D xfrm = getXfrm();\r
-        return (xfrm == null || !xfrm.isSetFlipH()) ? false : getXfrm().getFlipH();\r
+        CTTransform2D xfrm = getXfrm(false);\r
+        return (xfrm == null || !xfrm.isSetFlipH()) ? false : xfrm.getFlipH();\r
     }\r
 \r
     @Override\r
     public boolean getFlipVertical() {\r
-        CTTransform2D xfrm = getXfrm();\r
-        return (xfrm == null || !xfrm.isSetFlipV()) ? false : getXfrm().getFlipV();\r
+        CTTransform2D xfrm = getXfrm(false);\r
+        return (xfrm == null || !xfrm.isSetFlipV()) ? false : xfrm.getFlipV();\r
     }\r
 \r
 \r
@@ -187,7 +230,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * Get default line properties defined in the theme (if any).\r
      * Used internally to resolve shape properties.\r
      *\r
-     * @return line propeties from the theme of null\r
+     * @return line properties from the theme of null\r
      */\r
     CTLineProperties getDefaultLineProperties() {\r
         CTShapeStyle style = getSpStyle();\r
@@ -214,30 +257,29 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * A <code>null</code> value turns off the shape outline.\r
      */\r
     public void setLineColor(Color color) {\r
-        CTShapeProperties spPr = getSpPr();\r
-        CTLineProperties ln = spPr.getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
+\r
+        if (ln.isSetSolidFill()) {\r
+            ln.unsetSolidFill();\r
+        }\r
+        if (ln.isSetGradFill()) {\r
+            ln.unsetGradFill();\r
+        }\r
+        if (ln.isSetPattFill()) {\r
+            ln.unsetPattFill();\r
+        }\r
+        if (ln.isSetNoFill()) {\r
+            ln.unsetNoFill();\r
+        }\r
+\r
+        \r
         if (color == null) {\r
-            if (ln == null) {\r
-                return;\r
-            }\r
-            \r
-            if (ln.isSetSolidFill()) {\r
-                ln.unsetSolidFill();\r
-            }\r
-            \r
-            if (!ln.isSetNoFill()) {\r
-                ln.addNewNoFill();\r
-            }\r
+            ln.addNewNoFill();\r
         } else {\r
-            if (ln == null) {\r
-                ln = spPr.addNewLn();\r
-            }\r
-            if (ln.isSetNoFill()) {\r
-                ln.unsetNoFill();\r
-            }\r
-            \r
-            CTSolidColorFillProperties fill = ln.isSetSolidFill() ? ln.getSolidFill() : ln.addNewSolidFill();\r
-\r
+            CTSolidColorFillProperties fill = ln.addNewSolidFill();\r
             XSLFColor col = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr());\r
             col.setColor(color);\r
         }\r
@@ -257,37 +299,29 @@ public abstract class XSLFSimpleShape extends XSLFShape
     }\r
 \r
     protected PaintStyle getLinePaint() {\r
-        final XSLFTheme theme = getSheet().getTheme();\r
+        XSLFSheet sheet = getSheet();\r
+        final XSLFTheme theme = sheet.getTheme();\r
         PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTLineProperties spPr = shape.getSpPr().getLn();\r
-                if (spPr != null) {\r
-                    if (spPr.isSetNoFill()) {\r
-                        setValue(null); // use it as 'nofill' value\r
-                        return true;\r
-                    }\r
-\r
-                    PaintStyle paint = null;\r
-                    PackagePart pp = getSheet().getPackagePart();\r
-                    for (XmlObject obj : spPr.selectPath("*")) {\r
-                        paint = selectPaint(obj, null, pp, theme);\r
-                        if (paint != null) {\r
-                            setValue(paint);\r
-                            return true;\r
-                        }\r
-                    }\r
+                CTLineProperties spPr = getLn(shape, false);\r
+                XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(spPr);\r
+                PackagePart pp = shape.getSheet().getPackagePart();\r
+                PaintStyle paint = selectPaint(fp, null, pp, theme);\r
+                if (paint != null) {\r
+                    setValue(paint);\r
+                    return true;\r
+                }\r
 \r
-                    CTShapeStyle style = shape.getSpStyle();\r
-                    if (style != null) {\r
-                        paint = selectPaint(style.getLnRef(), theme);\r
-                        if (paint != null) {\r
-                            setValue(paint);\r
-                            return true;\r
-                        }\r
-                    }\r
+                CTShapeStyle style = shape.getSpStyle();\r
+                if (style != null) {\r
+                    fp = XSLFPropertiesDelegate.getFillDelegate(style.getLnRef());\r
+                    paint = selectPaint(fp, null, pp, theme);\r
+                }\r
+                if (paint != null) {\r
+                    setValue(paint);\r
+                    return true;\r
                 }\r
                 return false;\r
-\r
             }\r
         };\r
         fetchShapeProperty(fetcher);\r
@@ -304,9 +338,10 @@ public abstract class XSLFSimpleShape extends XSLFShape
         int idx = (int)lnRef.getIdx();\r
         CTSchemeColor phClr = lnRef.getSchemeClr();\r
         if(idx > 0){\r
-            XmlObject lnProps = theme.getXmlObject().\r
-                    getThemeElements().getFmtScheme().getLnStyleLst().selectPath("*")[idx - 1];\r
-            paint = getPaint(lnProps, phClr);\r
+            CTLineProperties props = theme.getXmlObject().getThemeElements().getFmtScheme().getLnStyleLst().getLnArray(idx - 1);\r
+            XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);\r
+            PackagePart pp = sheet.getPackagePart();\r
+            paint = selectPaint(fp, phClr, pp, theme);\r
         }\r
 \r
         return paint;\r
@@ -317,14 +352,33 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * @param width line width in points. <code>0</code> means no line\r
      */\r
     public void setLineWidth(double width) {\r
-        CTShapeProperties spPr = getSpPr();\r
+        CTLineProperties lnPr = getLn(this, true);\r
+        if (lnPr == null) {\r
+            return;\r
+        }\r
+        \r
         if (width == 0.) {\r
-            if (spPr.isSetLn() && spPr.getLn().isSetW())\r
-                spPr.getLn().unsetW();\r
+            if (lnPr.isSetW()) {\r
+                lnPr.unsetW();\r
+            }\r
+            if (!lnPr.isSetNoFill()) {\r
+                lnPr.addNewNoFill();\r
+            }\r
+            if (lnPr.isSetSolidFill()) {\r
+                lnPr.unsetSolidFill();\r
+            }\r
+            if (lnPr.isSetGradFill()) {\r
+                lnPr.unsetGradFill();\r
+            }\r
+            if (lnPr.isSetPattFill()) {\r
+                lnPr.unsetPattFill();\r
+            }\r
         } else {\r
-            CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr\r
-                    .addNewLn();\r
-            ln.setW(Units.toEMU(width));\r
+            if (lnPr.isSetNoFill()) {\r
+                lnPr.unsetNoFill();\r
+            }\r
+\r
+            lnPr.setW(Units.toEMU(width));\r
         }\r
     }\r
 \r
@@ -334,8 +388,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
     public double getLineWidth() {\r
         PropertyFetcher<Double> fetcher = new PropertyFetcher<Double>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTShapeProperties spPr = shape.getSpPr();\r
-                CTLineProperties ln = spPr.getLn();\r
+                CTLineProperties ln = getLn(shape, false);\r
                 if (ln != null) {\r
                     if (ln.isSetNoFill()) {\r
                         setValue(0.);\r
@@ -370,12 +423,15 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * @param compound set the line compound style\r
      */\r
     public void setLineCompound(LineCompound compound) {\r
-        CTShapeProperties spPr = getSpPr();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
         if (compound == null) {\r
-            if (spPr.isSetLn() && spPr.getLn().isSetCmpd())\r
-                spPr.getLn().unsetCmpd();\r
+            if (ln.isSetCmpd()) {\r
+                ln.unsetCmpd();\r
+            }\r
         } else {\r
-            CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr.addNewLn();\r
             STCompoundLine.Enum xCmpd;\r
             switch (compound) {\r
                 default:\r
@@ -405,8 +461,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
     public LineCompound getLineCompound() {\r
         PropertyFetcher<Integer> fetcher = new PropertyFetcher<Integer>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTShapeProperties spPr = shape.getSpPr();\r
-                CTLineProperties ln = spPr.getLn();\r
+                CTLineProperties ln = getLn(shape, false);\r
                 if (ln != null) {\r
                     STCompoundLine.Enum stCmpd = ln.getCmpd();\r
                     if (stCmpd != null) {\r
@@ -422,29 +477,24 @@ public abstract class XSLFSimpleShape extends XSLFShape
         Integer cmpd = fetcher.getValue();\r
         if (cmpd == null) {\r
             CTLineProperties defaultLn = getDefaultLineProperties();\r
-            if (defaultLn != null) {\r
-                STCompoundLine.Enum stCmpd = defaultLn.getCmpd();\r
-                if (stCmpd != null) {\r
-                    cmpd = stCmpd.intValue();\r
+            if (defaultLn != null && defaultLn.isSetCmpd()) {\r
+                switch (defaultLn.getCmpd().intValue()) {\r
+                default:\r
+                case STCompoundLine.INT_SNG:\r
+                    return LineCompound.SINGLE;\r
+                case STCompoundLine.INT_DBL:\r
+                    return LineCompound.DOUBLE;\r
+                case STCompoundLine.INT_THICK_THIN:\r
+                    return LineCompound.THICK_THIN;\r
+                case STCompoundLine.INT_THIN_THICK:\r
+                    return LineCompound.THIN_THICK;\r
+                case STCompoundLine.INT_TRI:\r
+                    return LineCompound.TRIPLE;\r
                 }\r
             }\r
         }\r
 \r
-        if (cmpd == null) return null;\r
-\r
-        switch (cmpd) {\r
-        default:\r
-        case STCompoundLine.INT_SNG:\r
-            return LineCompound.SINGLE;\r
-        case STCompoundLine.INT_DBL:\r
-            return LineCompound.DOUBLE;\r
-        case STCompoundLine.INT_THICK_THIN:\r
-            return LineCompound.THICK_THIN;\r
-        case STCompoundLine.INT_THIN_THICK:\r
-            return LineCompound.THIN_THICK;\r
-        case STCompoundLine.INT_TRI:\r
-            return LineCompound.TRIPLE;\r
-        }\r
+        return null;\r
     }\r
 \r
     /**\r
@@ -452,34 +502,34 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * @param dash a preset line dashing scheme to stroke thr shape outline\r
      */\r
     public void setLineDash(LineDash dash) {\r
-        CTShapeProperties spPr = getSpPr();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
         if (dash == null) {\r
-            if (spPr.isSetLn() && spPr.getLn().isSetPrstDash())\r
-                spPr.getLn().unsetPrstDash();\r
+            if (ln.isSetPrstDash()) {\r
+                ln.unsetPrstDash();\r
+            }\r
         } else {\r
-            CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr.addNewLn();\r
             CTPresetLineDashProperties ldp = ln.isSetPrstDash() ? ln.getPrstDash() : ln.addNewPrstDash();\r
             ldp.setVal(STPresetLineDashVal.Enum.forInt(dash.ooxmlId));\r
         }\r
     }\r
 \r
     /**\r
-     * @return  a preset line dashing scheme to stroke thr shape outline\r
+     * @return  a preset line dashing scheme to stroke the shape outline\r
      */\r
     public LineDash getLineDash() {\r
 \r
         PropertyFetcher<LineDash> fetcher = new PropertyFetcher<LineDash>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTShapeProperties spPr = shape.getSpPr();\r
-                CTLineProperties ln = spPr.getLn();\r
-                if (ln != null) {\r
-                    CTPresetLineDashProperties ctDash = ln.getPrstDash();\r
-                    if (ctDash != null) {\r
-                        setValue(LineDash.fromOoxmlId(ctDash.getVal().intValue()));\r
-                        return true;\r
-                    }\r
+                CTLineProperties ln = getLn(shape, false);\r
+                if (ln == null || !ln.isSetPrstDash()) {\r
+                    return false;\r
                 }\r
-                return false;\r
+\r
+                setValue(LineDash.fromOoxmlId(ln.getPrstDash().getVal().intValue()));\r
+                return true;\r
             }\r
         };\r
         fetchShapeProperty(fetcher);\r
@@ -487,11 +537,8 @@ public abstract class XSLFSimpleShape extends XSLFShape
         LineDash dash = fetcher.getValue();\r
         if (dash == null) {\r
             CTLineProperties defaultLn = getDefaultLineProperties();\r
-            if (defaultLn != null) {\r
-                CTPresetLineDashProperties ctDash = defaultLn.getPrstDash();\r
-                if (ctDash != null) {\r
-                    dash = LineDash.fromOoxmlId(ctDash.getVal().intValue());\r
-                }\r
+            if (defaultLn != null && defaultLn.isSetPrstDash()) {\r
+                dash = LineDash.fromOoxmlId(defaultLn.getPrstDash().getVal().intValue());\r
             }\r
         }\r
         return dash;\r
@@ -502,13 +549,16 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * @param cap the line end cap style\r
      */\r
     public void setLineCap(LineCap cap) {\r
-        CTShapeProperties spPr = getSpPr();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
+        \r
         if (cap == null) {\r
-            if (spPr.isSetLn() && spPr.getLn().isSetCap())\r
-                spPr.getLn().unsetCap();\r
+            if (ln.isSetCap()) {\r
+                ln.unsetCap();\r
+            }\r
         } else {\r
-            CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr\r
-                    .addNewLn();\r
             ln.setCap(STLineCap.Enum.forInt(cap.ooxmlId));\r
         }\r
     }\r
@@ -520,14 +570,10 @@ public abstract class XSLFSimpleShape extends XSLFShape
     public LineCap getLineCap() {\r
         PropertyFetcher<LineCap> fetcher = new PropertyFetcher<LineCap>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTShapeProperties spPr = shape.getSpPr();\r
-                CTLineProperties ln = spPr.getLn();\r
-                if (ln != null) {\r
-                    STLineCap.Enum stCap = ln.getCap();\r
-                    if (stCap != null) {\r
-                        setValue(LineCap.fromOoxmlId(stCap.intValue()));\r
-                        return true;\r
-                    }\r
+                CTLineProperties ln = getLn(shape, false);\r
+                if (ln != null && ln.isSetCap()) {\r
+                    setValue(LineCap.fromOoxmlId(ln.getCap().intValue()));\r
+                    return true;\r
                 }\r
                 return false;\r
             }\r
@@ -537,11 +583,8 @@ public abstract class XSLFSimpleShape extends XSLFShape
         LineCap cap = fetcher.getValue();\r
         if (cap == null) {\r
             CTLineProperties defaultLn = getDefaultLineProperties();\r
-            if (defaultLn != null) {\r
-                STLineCap.Enum stCap = defaultLn.getCap();\r
-                if (stCap != null) {\r
-                    cap = LineCap.fromOoxmlId(stCap.intValue());\r
-                }\r
+            if (defaultLn != null && defaultLn.isSetCap()) {\r
+                cap = LineCap.fromOoxmlId(defaultLn.getCap().intValue());\r
             }\r
         }\r
         return cap;\r
@@ -549,21 +592,36 @@ public abstract class XSLFSimpleShape extends XSLFShape
 \r
     @Override\r
     public void setFillColor(Color color) {\r
-        CTShapeProperties spPr = getSpPr();\r
+        XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(getShapeProperties());\r
+        if (fp == null) {\r
+            return;\r
+        }\r
         if (color == null) {\r
-            if (spPr.isSetSolidFill()) {\r
-                spPr.unsetSolidFill();\r
+            if (fp.isSetSolidFill()) {\r
+                fp.unsetSolidFill();\r
+            }\r
+            \r
+            if (fp.isSetGradFill()) {\r
+                fp.unsetGradFill();\r
             }\r
 \r
-            if (!spPr.isSetNoFill()) {\r
-                spPr.addNewNoFill();\r
+            if (fp.isSetPattFill()) {\r
+                fp.unsetGradFill();\r
+            }\r
+            \r
+            if (fp.isSetBlipFill()) {\r
+                fp.unsetBlipFill();\r
+            }\r
+            \r
+            if (!fp.isSetNoFill()) {\r
+                fp.addNewNoFill();\r
             }\r
         } else {\r
-            if (spPr.isSetNoFill()) {\r
-                spPr.unsetNoFill();\r
+            if (fp.isSetNoFill()) {\r
+                fp.unsetNoFill();\r
             }\r
 \r
-            CTSolidColorFillProperties fill = spPr.isSetSolidFill() ? spPr.getSolidFill() : spPr.addNewSolidFill();\r
+            CTSolidColorFillProperties fill = fp.isSetSolidFill() ? fp.getSolidFill() : fp.addNewSolidFill();\r
                     \r
             XSLFColor col = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr());\r
             col.setColor(color);\r
@@ -574,7 +632,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
     public Color getFillColor() {\r
         PaintStyle ps = getFillPaint();\r
         if (ps instanceof SolidPaint) {\r
-            return ((SolidPaint)ps).getSolidColor().getColor();\r
+            return DrawPaint.applyColorTransform(((SolidPaint)ps).getSolidColor());\r
         }\r
         return null;\r
     }\r
@@ -585,9 +643,9 @@ public abstract class XSLFSimpleShape extends XSLFShape
     public XSLFShadow getShadow() {\r
         PropertyFetcher<CTOuterShadowEffect> fetcher = new PropertyFetcher<CTOuterShadowEffect>() {\r
             public boolean fetch(XSLFShape shape) {\r
-                CTShapeProperties spPr = shape.getSpPr();\r
-                if (spPr.isSetEffectLst()) {\r
-                    CTOuterShadowEffect obj = spPr.getEffectLst().getOuterShdw();\r
+                XSLFEffectProperties ep = XSLFPropertiesDelegate.getEffectDelegate(shape.getShapeProperties());\r
+                if (ep != null && ep.isSetEffectLst()) {\r
+                    CTOuterShadowEffect obj = ep.getEffectLst().getOuterShdw();\r
                     setValue(obj == null ? NO_SHADOW : obj);\r
                     return true;\r
                 }\r
@@ -600,7 +658,7 @@ public abstract class XSLFSimpleShape extends XSLFShape
         if (obj == null) {\r
             // fill color was not found, check if it is defined in the theme\r
             CTShapeStyle style = getSpStyle();\r
-            if (style != null) {\r
+            if (style != null && style.getEffectRef() != null) {\r
                 // 1-based index of a shadow style within the style matrix\r
                 int idx = (int) style.getEffectRef().getIdx();\r
                 if(idx != 0) {\r
@@ -618,17 +676,22 @@ public abstract class XSLFSimpleShape extends XSLFShape
      * @return definition of the shape geometry\r
      */\r
     public CustomGeometry getGeometry(){\r
-        CTShapeProperties spPr = getSpPr();\r
+        XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());\r
+        \r
+        if (gp == null) {\r
+            return null;\r
+        }\r
+        \r
         CustomGeometry geom;\r
         PresetGeometries dict = PresetGeometries.getInstance();\r
-        if(spPr.isSetPrstGeom()){\r
-            String name = spPr.getPrstGeom().getPrst().toString();\r
+        if(gp.isSetPrstGeom()){\r
+            String name = gp.getPrstGeom().getPrst().toString();\r
             geom = dict.get(name);\r
             if(geom == null) {\r
                 throw new IllegalStateException("Unknown shape geometry: " + name + ", available geometries are: " + dict.keySet());\r
             }\r
-        } else if (spPr.isSetCustGeom()){\r
-            XMLStreamReader staxReader = spPr.getCustGeom().newXMLStreamReader();\r
+        } else if (gp.isSetCustGeom()){\r
+            XMLStreamReader staxReader = gp.getCustGeom().newXMLStreamReader();\r
             geom = PresetGeometries.convertCustomGeometry(staxReader);\r
             try { staxReader.close(); }\r
             catch (XMLStreamException e) {}\r
@@ -650,8 +713,9 @@ public abstract class XSLFSimpleShape extends XSLFShape
             setFillColor(srsSolidFill);\r
         }\r
 \r
-        if(getSpPr().isSetBlipFill()){\r
-            CTBlip blip = getSpPr().getBlipFill().getBlip();\r
+        XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(getShapeProperties());\r
+        if(fp != null && fp.isSetBlipFill()){\r
+            CTBlip blip = fp.getBlipFill().getBlip();\r
             String blipId = blip.getEmbed();\r
 \r
             String relId = getSheet().importBlip(blipId, s.getSheet().getPackagePart());\r
@@ -686,130 +750,193 @@ public abstract class XSLFSimpleShape extends XSLFShape
 \r
     /**\r
      * Specifies the line end decoration, such as a triangle or arrowhead.\r
+     * \r
+     * @param style the line end docoration style\r
      */\r
     public void setLineHeadDecoration(DecorationShape style) {\r
-        CTLineProperties ln = getSpPr().getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
         CTLineEndProperties lnEnd = ln.isSetHeadEnd() ? ln.getHeadEnd() : ln.addNewHeadEnd();\r
         if (style == null) {\r
-            if (lnEnd.isSetType()) lnEnd.unsetType();\r
+            if (lnEnd.isSetType()) {\r
+                lnEnd.unsetType();\r
+            }\r
         } else {\r
             lnEnd.setType(STLineEndType.Enum.forInt(style.ooxmlId));\r
         }\r
     }\r
 \r
+    /**\r
+     * @return the line end decoration shape\r
+     */\r
     public DecorationShape getLineHeadDecoration() {\r
-        CTLineProperties ln = getSpPr().getLn();\r
-        if (ln == null || !ln.isSetHeadEnd()) return DecorationShape.NONE;\r
-\r
-        STLineEndType.Enum end = ln.getHeadEnd().getType();\r
-        return end == null ? DecorationShape.NONE : DecorationShape.fromOoxmlId(end.intValue());\r
+        CTLineProperties ln = getLn(this, false);\r
+        DecorationShape ds = DecorationShape.NONE;\r
+        if (ln != null && ln.isSetHeadEnd() && ln.getHeadEnd().isSetType()) {\r
+            ds = DecorationShape.fromOoxmlId(ln.getHeadEnd().getType().intValue());\r
+        }\r
+        return ds;\r
     }\r
 \r
     /**\r
-     * specifies decorations which can be added to the head of a line.\r
+     * specifies decoration width of the head of a line.\r
+     * \r
+     * @param style the decoration width \r
      */\r
     public void setLineHeadWidth(DecorationSize style) {\r
-        CTLineProperties ln = getSpPr().getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
         CTLineEndProperties lnEnd = ln.isSetHeadEnd() ? ln.getHeadEnd() : ln.addNewHeadEnd();\r
         if (style == null) {\r
-            if (lnEnd.isSetW()) lnEnd.unsetW();\r
+            if (lnEnd.isSetW()) {\r
+                lnEnd.unsetW();\r
+            }\r
         } else {\r
             lnEnd.setW(STLineEndWidth.Enum.forInt(style.ooxmlId));\r
         }\r
     }\r
 \r
+    /**\r
+     * @return the line end decoration width\r
+     */\r
     public DecorationSize getLineHeadWidth() {\r
-        CTLineProperties ln = getSpPr().getLn();\r
-        if (ln == null || !ln.isSetHeadEnd()) return DecorationSize.MEDIUM;\r
-\r
-        STLineEndWidth.Enum w = ln.getHeadEnd().getW();\r
-        return w == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(w.intValue());\r
+        CTLineProperties ln = getLn(this, false);\r
+        DecorationSize ds = DecorationSize.MEDIUM;\r
+        if (ln != null && ln.isSetHeadEnd() && ln.getHeadEnd().isSetW()) {\r
+            ds = DecorationSize.fromOoxmlId(ln.getHeadEnd().getW().intValue());\r
+        }\r
+        return ds;\r
     }\r
 \r
     /**\r
      * Specifies the line end width in relation to the line width.\r
      */\r
     public void setLineHeadLength(DecorationSize style) {\r
-        CTLineProperties ln = getSpPr().getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
+        \r
         CTLineEndProperties lnEnd = ln.isSetHeadEnd() ? ln.getHeadEnd() : ln.addNewHeadEnd();\r
-\r
         if (style == null) {\r
-            if (lnEnd.isSetLen()) lnEnd.unsetLen();\r
+            if (lnEnd.isSetLen()) {\r
+                lnEnd.unsetLen();\r
+            }\r
         } else {\r
             lnEnd.setLen(STLineEndLength.Enum.forInt(style.ooxmlId));\r
         }\r
     }\r
 \r
+    /**\r
+     * @return the line end decoration length\r
+     */\r
     public DecorationSize getLineHeadLength() {\r
-        CTLineProperties ln = getSpPr().getLn();\r
-        if (ln == null || !ln.isSetHeadEnd()) return DecorationSize.MEDIUM;\r
-\r
-        STLineEndLength.Enum len = ln.getHeadEnd().getLen();\r
-        return len == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(len.intValue());\r
+        CTLineProperties ln = getLn(this, false);\r
+        \r
+        DecorationSize ds = DecorationSize.MEDIUM;\r
+        if (ln != null && ln.isSetHeadEnd() && ln.getHeadEnd().isSetLen()) {\r
+            ds = DecorationSize.fromOoxmlId(ln.getHeadEnd().getLen().intValue());\r
+        }\r
+        return ds; \r
     }\r
 \r
     /**\r
      * Specifies the line end decoration, such as a triangle or arrowhead.\r
      */\r
     public void setLineTailDecoration(DecorationShape style) {\r
-        CTLineProperties ln = getSpPr().getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
+\r
         CTLineEndProperties lnEnd = ln.isSetTailEnd() ? ln.getTailEnd() : ln.addNewTailEnd();\r
         if (style == null) {\r
-            if (lnEnd.isSetType()) lnEnd.unsetType();\r
+            if (lnEnd.isSetType()) {\r
+                lnEnd.unsetType();\r
+            }\r
         } else {\r
             lnEnd.setType(STLineEndType.Enum.forInt(style.ooxmlId));\r
         }\r
     }\r
 \r
+    /**\r
+     * @return the line end decoration shape\r
+     */\r
     public DecorationShape getLineTailDecoration() {\r
-        CTLineProperties ln = getSpPr().getLn();\r
-        if (ln == null || !ln.isSetTailEnd()) return DecorationShape.NONE;\r
-\r
-        STLineEndType.Enum end = ln.getTailEnd().getType();\r
-        return end == null ? DecorationShape.NONE : DecorationShape.fromOoxmlId(end.intValue());\r
+        CTLineProperties ln = getLn(this, false);\r
+        \r
+        DecorationShape ds = DecorationShape.NONE;\r
+        if (ln != null && ln.isSetTailEnd() && ln.getTailEnd().isSetType()) {\r
+            ds = DecorationShape.fromOoxmlId(ln.getTailEnd().getType().intValue());\r
+        }\r
+        return ds;\r
     }\r
 \r
     /**\r
      * specifies decorations which can be added to the tail of a line.\r
      */\r
     public void setLineTailWidth(DecorationSize style) {\r
-        CTLineProperties ln = getSpPr().getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
+        \r
         CTLineEndProperties lnEnd = ln.isSetTailEnd() ? ln.getTailEnd() : ln.addNewTailEnd();\r
         if (style == null) {\r
-            if (lnEnd.isSetW()) lnEnd.unsetW();\r
+            if (lnEnd.isSetW()) {\r
+                lnEnd.unsetW();\r
+            }\r
         } else {\r
             lnEnd.setW(STLineEndWidth.Enum.forInt(style.ooxmlId));\r
         }\r
     }\r
 \r
+    /**\r
+     * @return the line end decoration width\r
+     */\r
     public DecorationSize getLineTailWidth() {\r
-        CTLineProperties ln = getSpPr().getLn();\r
-        if (ln == null || !ln.isSetTailEnd()) return DecorationSize.MEDIUM;\r
-\r
-        STLineEndWidth.Enum w = ln.getTailEnd().getW();\r
-        return w == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(w.intValue());\r
+        CTLineProperties ln = getLn(this, false);\r
+        DecorationSize ds = DecorationSize.MEDIUM;\r
+        if (ln != null && ln.isSetTailEnd() && ln.getTailEnd().isSetW()) {\r
+            ds = DecorationSize.fromOoxmlId(ln.getTailEnd().getW().intValue());\r
+        }\r
+        return ds;\r
     }\r
 \r
     /**\r
      * Specifies the line end width in relation to the line width.\r
      */\r
     public void setLineTailLength(DecorationSize style) {\r
-        CTLineProperties ln = getSpPr().getLn();\r
+        CTLineProperties ln = getLn(this, true);\r
+        if (ln == null) {\r
+            return;\r
+        }\r
+        \r
         CTLineEndProperties lnEnd = ln.isSetTailEnd() ? ln.getTailEnd() : ln.addNewTailEnd();\r
-\r
         if (style == null) {\r
-            if (lnEnd.isSetLen()) lnEnd.unsetLen();\r
+            if (lnEnd.isSetLen()) {\r
+                lnEnd.unsetLen();\r
+            }\r
         } else {\r
             lnEnd.setLen(STLineEndLength.Enum.forInt(style.ooxmlId));\r
         }\r
     }\r
 \r
+    /**\r
+     * @return the line end decoration length\r
+     */\r
     public DecorationSize getLineTailLength() {\r
-        CTLineProperties ln = getSpPr().getLn();\r
-        if (ln == null || !ln.isSetTailEnd()) return DecorationSize.MEDIUM;\r
-\r
-        STLineEndLength.Enum len = ln.getTailEnd().getLen();\r
-        return len == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(len.intValue());\r
+        CTLineProperties ln = getLn(this, false);\r
+        \r
+        DecorationSize ds = DecorationSize.MEDIUM;\r
+        if (ln != null && ln.isSetTailEnd() && ln.getTailEnd().isSetLen()) {\r
+            ds = DecorationSize.fromOoxmlId(ln.getTailEnd().getLen().intValue());\r
+        }\r
+        return ds; \r
     }\r
 \r
     public boolean isPlaceholder() {\r
@@ -818,9 +945,10 @@ public abstract class XSLFSimpleShape extends XSLFShape
     }\r
 \r
     public Guide getAdjustValue(String name) {\r
-        CTPresetGeometry2D prst = getSpPr().getPrstGeom();\r
-        if (prst.isSetAvLst()) {\r
-            for (CTGeomGuide g : prst.getAvLst().getGdArray()) {\r
+        XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());\r
+        \r
+        if (gp != null && gp.isSetPrstGeom() && gp.getPrstGeom().isSetAvLst()) {\r
+            for (CTGeomGuide g : gp.getPrstGeom().getAvLst().getGdArray()) {\r
                 if (g.getName().equals(name)) {\r
                     return new Guide(g.getName(), g.getFmla());\r
                 }\r
@@ -943,4 +1071,15 @@ public abstract class XSLFSimpleShape extends XSLFShape
         }\r
         return hl;\r
     }\r
-}\r
+\r
+    private static CTLineProperties getLn(XSLFShape shape, boolean create) {\r
+        XmlObject pr = shape.getShapeProperties();\r
+        if (!(pr instanceof CTShapeProperties)) {\r
+            LOG.log(POILogger.WARN, shape.getClass().toString()+" doesn't have line properties");\r
+            return null;\r
+        }\r
+        \r
+        CTShapeProperties spr = (CTShapeProperties)pr;\r
+        return (spr.isSetLn() || !create) ? spr.getLn() : spr.addNewLn();\r
+    }\r
+}
\ No newline at end of file
index 9a309157a1b6bc115e55e64b569fcc3d30150e85..de707dfd25ca96244a2a2eeb4d165442337bc475 100644 (file)
@@ -23,7 +23,9 @@ import java.awt.Color;
 import java.awt.geom.Rectangle2D;\r
 \r
 import org.apache.poi.sl.draw.DrawPaint;\r
+import org.apache.poi.sl.usermodel.ColorStyle;\r
 import org.apache.poi.sl.usermodel.PaintStyle;\r
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;\r
 import org.apache.poi.sl.usermodel.StrokeStyle;\r
 import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;\r
 import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;\r
@@ -31,9 +33,9 @@ import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
 import org.apache.poi.sl.usermodel.TableCell;\r
 import org.apache.poi.sl.usermodel.VerticalAlignment;\r
 import org.apache.poi.util.Units;\r
+import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;\r
 import org.apache.poi.xslf.usermodel.XSLFTableStyle.TablePartStyle;\r
 import org.apache.xmlbeans.XmlObject;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTFontReference;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;\r
@@ -41,13 +43,13 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTablePartStyle;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleCellStyle;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableStyleTextStyle;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;\r
@@ -393,22 +395,27 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
      */\r
     @Override\r
     public Color getFillColor(){\r
-        CTTableCellProperties spPr = getCellProperties(false);\r
-        if (spPr == null || !spPr.isSetSolidFill()) {\r
-            return null;\r
+        PaintStyle ps = getFillPaint();\r
+        if (ps instanceof SolidPaint) {\r
+            ColorStyle cs = ((SolidPaint)ps).getSolidColor();\r
+            return DrawPaint.applyColorTransform(cs);\r
         }\r
-\r
-        CTSolidColorFillProperties fill = spPr.getSolidFill();\r
-        XSLFColor c = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr());\r
-        return c.getColor();\r
+        \r
+        return null;\r
     }\r
 \r
     @SuppressWarnings("resource")\r
     @Override\r
     public PaintStyle getFillPaint() {\r
-        Color c = getFillColor();\r
-        if (c != null) {\r
-            return DrawPaint.createSolidPaint(c);\r
+        XSLFSheet sheet = getSheet();\r
+        XSLFTheme theme = sheet.getTheme();\r
+        XmlObject props = getCellProperties(false);\r
+        XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);\r
+        if (fp != null) {\r
+            PaintStyle paint = selectPaint(fp, null, sheet.getPackagePart(), theme);\r
+            if (paint != null) {\r
+                return paint;\r
+            }\r
         }\r
 \r
         CTTablePartStyle tps = getTablePartStyle(null);\r
@@ -419,20 +426,25 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
             }\r
         }\r
 \r
-        XMLSlideShow slideShow = table.getSheet().getSlideShow();\r
-        assert(slideShow != null);\r
-        XSLFTheme theme = slideShow.getSlides().get(0).getTheme();\r
-        CTFillProperties pr = tps.getTcStyle().getFill();\r
-\r
-          for (XmlObject obj : pr.selectPath("*")) {\r
-              PaintStyle paint = XSLFShape.selectPaint(obj, null, slideShow.getPackagePart(), theme);\r
-\r
-              if (paint != null) {\r
-                  return paint;\r
-              }\r
-          }\r
-\r
-          return null;\r
+        XMLSlideShow slideShow = sheet.getSlideShow();\r
+        CTTableStyleCellStyle tcStyle = tps.getTcStyle();\r
+        if (tcStyle.isSetFill()) {\r
+            props = tcStyle.getFill();\r
+        } else if (tcStyle.isSetFillRef()) {\r
+            props = tcStyle.getFillRef();\r
+        } else {\r
+            return null;\r
+        }\r
+        \r
+        fp = XSLFPropertiesDelegate.getFillDelegate(props);\r
+        if (fp != null)  {\r
+            PaintStyle paint = XSLFShape.selectPaint(fp, null, slideShow.getPackagePart(), theme);\r
+            if (paint != null) {\r
+                return paint;\r
+            }\r
+        }\r
+        \r
+        return null;\r
     }\r
 \r
     /**\r
@@ -671,17 +683,9 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
         return new XSLFCellTextParagraph(p, this);\r
     }\r
 \r
-    /**\r
-     * Return fake shape properties as a fallback for not overridden\r
-     * methods of XSLFSimpleShape\r
-     * \r
-     * @return fake shape properties\r
-     * \r
-     * @since POI 3.15-beta2\r
-     */\r
     @Override\r
-    protected CTShapeProperties getSpPr() {\r
-        return CTShapeProperties.Factory.newInstance();\r
+    protected XmlObject getShapeProperties() {\r
+        return getCellProperties(false);\r
     }\r
     \r
     /**\r
index 3c4f5936e3d3b5f6dc72187710ee67de851776e4..b0bbd4557036afc9d7736e4899ff2e077cac5b97 100644 (file)
@@ -18,13 +18,25 @@ package org.apache.poi.xslf.usermodel;
 \r
 import java.awt.Color;\r
 \r
+import org.apache.poi.openxml4j.opc.PackagePart;\r
 import org.apache.poi.sl.draw.DrawPaint;\r
 import org.apache.poi.sl.usermodel.PaintStyle;\r
 import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;\r
 import org.apache.poi.sl.usermodel.TextRun;\r
 import org.apache.poi.util.Beta;\r
 import org.apache.poi.xslf.model.CharacterPropertyFetcher;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
+import org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;\r
 \r
 /**\r
@@ -107,19 +119,26 @@ public class XSLFTextRun implements TextRun {
     public PaintStyle getFontColor(){\r
         CharacterPropertyFetcher<PaintStyle> fetcher = new CharacterPropertyFetcher<PaintStyle>(_p.getIndentLevel()){\r
             public boolean fetch(CTTextCharacterProperties props){\r
-                if (props != null) {\r
-                    XSLFShape shape = _p.getParentShape();\r
-                    CTShapeStyle style = shape.getSpStyle();\r
-                    CTSchemeColor phClr = null;\r
-                    if (style != null && style.getFontRef() != null) {\r
-                        phClr = style.getFontRef().getSchemeClr();\r
-                    }\r
-    \r
-                    PaintStyle ps = shape.getPaint(props, phClr);\r
-                    if (ps != null)  {\r
-                        setValue(ps);\r
-                        return true;\r
-                    }\r
+                if (props == null) {\r
+                    return false;\r
+                }\r
+                \r
+                XSLFShape shape = _p.getParentShape();\r
+                CTShapeStyle style = shape.getSpStyle();\r
+                CTSchemeColor phClr = null;\r
+                if (style != null && style.getFontRef() != null) {\r
+                    phClr = style.getFontRef().getSchemeClr();\r
+                }\r
+\r
+                XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);\r
+                XSLFSheet sheet = shape.getSheet();\r
+                PackagePart pp = sheet.getPackagePart();\r
+                XSLFTheme theme = sheet.getTheme();\r
+                PaintStyle ps = XSLFShape.selectPaint(fp, phClr, pp, theme);\r
+                \r
+                if (ps != null)  {\r
+                    setValue(ps);\r
+                    return true;\r
                 }\r
                 \r
                 return false;\r
index 8e13603dad031ac754cb82122c97a58a3e3ff826..95dd57d15489b34ca1e26cb4ccd1092d1472f1b7 100644 (file)
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 
 import org.apache.poi.POIDataSamples;
@@ -29,7 +31,12 @@ import org.apache.poi.POIXMLProperties.CoreProperties;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.xslf.usermodel.XMLSlideShow;
+import org.apache.poi.xslf.usermodel.XSLFAutoShape;
+import org.apache.poi.xslf.usermodel.XSLFBackground;
 import org.apache.poi.xslf.usermodel.XSLFRelation;
+import org.apache.poi.xslf.usermodel.XSLFSlide;
 import org.apache.poi.xslf.usermodel.XSLFSlideShow;
 import org.apache.xmlbeans.XmlException;
 import org.junit.Before;
@@ -126,4 +133,24 @@ public class TestXSLFSlideShow {
                
                xml.close();
        }
+    
+    @Test
+    public void testMasterBackground() throws IOException {
+        XMLSlideShow ppt = new XMLSlideShow();
+        XSLFBackground b = ppt.getSlideMasters().get(0).getBackground();
+        b.setFillColor(Color.RED);
+        
+        XSLFSlide sl = ppt.createSlide();
+        XSLFAutoShape as = sl.createAutoShape();
+        as.setAnchor(new Rectangle2D.Double(100,100,100,100));
+        as.setShapeType(ShapeType.CLOUD);
+        
+        XMLSlideShow ppt2 = XSLFTestDataSamples.writeOutAndReadBack(ppt);
+        ppt.close();
+        
+        XSLFBackground b2 = ppt2.getSlideMasters().get(0).getBackground();
+        assertEquals(Color.RED, b2.getFillColor());
+        
+        ppt2.close();
+    }
 }
index fb86c1926c04b08443fbcc034b8889160f3c6b09..059856242ccc1575c4c3bf35f826462a1ceb6e0e 100644 (file)
@@ -18,9 +18,11 @@ package org.apache.poi.xslf.usermodel;
 \r
 import static org.junit.Assert.assertEquals;\r
 import static org.junit.Assert.assertFalse;\r
+import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;\r
 \r
 import java.awt.Color;\r
 import java.awt.geom.Rectangle2D;\r
+import java.io.IOException;\r
 \r
 import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;\r
 import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;\r
@@ -34,21 +36,18 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
 import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;\r
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;\r
 \r
-/**\r
- * @author Yegor Kozlov\r
- */\r
 public class TestXSLFConnectorShape {\r
 \r
     @Test\r
-    public void testLineDecorations() {\r
+    public void testLineDecorations() throws IOException {\r
         XMLSlideShow ppt = new XMLSlideShow();\r
         XSLFSlide slide = ppt.createSlide();\r
 \r
         XSLFConnectorShape shape = slide.createConnector();\r
         assertEquals(1, slide.getShapes().size());\r
 \r
-        assertFalse(shape.getSpPr().getLn().isSetHeadEnd());\r
-        assertFalse(shape.getSpPr().getLn().isSetTailEnd());\r
+        assertFalse(getSpPr(shape).getLn().isSetHeadEnd());\r
+        assertFalse(getSpPr(shape).getLn().isSetTailEnd());\r
 \r
         // line decorations\r
         assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration());\r
@@ -57,22 +56,22 @@ public class TestXSLFConnectorShape {
         shape.setLineTailDecoration(null);\r
         assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration());\r
         assertEquals(DecorationShape.NONE, shape.getLineTailDecoration());\r
-        assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetType());\r
-        assertFalse(shape.getSpPr().getLn().getTailEnd().isSetType());\r
+        assertFalse(getSpPr(shape).getLn().getHeadEnd().isSetType());\r
+        assertFalse(getSpPr(shape).getLn().getTailEnd().isSetType());\r
 \r
         shape.setLineHeadDecoration(DecorationShape.ARROW);\r
         shape.setLineTailDecoration(DecorationShape.DIAMOND);\r
         assertEquals(DecorationShape.ARROW, shape.getLineHeadDecoration());\r
         assertEquals(DecorationShape.DIAMOND, shape.getLineTailDecoration());\r
-        assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getHeadEnd().getType());\r
-        assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getTailEnd().getType());\r
+        assertEquals(STLineEndType.ARROW, getSpPr(shape).getLn().getHeadEnd().getType());\r
+        assertEquals(STLineEndType.DIAMOND, getSpPr(shape).getLn().getTailEnd().getType());\r
 \r
         shape.setLineHeadDecoration(DecorationShape.DIAMOND);\r
         shape.setLineTailDecoration(DecorationShape.ARROW);\r
         assertEquals(DecorationShape.DIAMOND, shape.getLineHeadDecoration());\r
         assertEquals(DecorationShape.ARROW, shape.getLineTailDecoration());\r
-        assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getHeadEnd().getType());\r
-        assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getTailEnd().getType());\r
+        assertEquals(STLineEndType.DIAMOND, getSpPr(shape).getLn().getHeadEnd().getType());\r
+        assertEquals(STLineEndType.ARROW, getSpPr(shape).getLn().getTailEnd().getType());\r
 \r
         // line end width\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());\r
@@ -81,20 +80,20 @@ public class TestXSLFConnectorShape {
         shape.setLineHeadWidth(null);\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());\r
-        assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetW());\r
-        assertFalse(shape.getSpPr().getLn().getTailEnd().isSetW());\r
+        assertFalse(getSpPr(shape).getLn().getHeadEnd().isSetW());\r
+        assertFalse(getSpPr(shape).getLn().getTailEnd().isSetW());\r
         shape.setLineHeadWidth(DecorationSize.LARGE);\r
         shape.setLineTailWidth(DecorationSize.MEDIUM);\r
         assertEquals(DecorationSize.LARGE, shape.getLineHeadWidth());\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());\r
-        assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getHeadEnd().getW());\r
-        assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getTailEnd().getW());\r
+        assertEquals(STLineEndWidth.LG, getSpPr(shape).getLn().getHeadEnd().getW());\r
+        assertEquals(STLineEndWidth.MED, getSpPr(shape).getLn().getTailEnd().getW());\r
         shape.setLineHeadWidth(DecorationSize.MEDIUM);\r
         shape.setLineTailWidth(DecorationSize.LARGE);\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());\r
         assertEquals(DecorationSize.LARGE, shape.getLineTailWidth());\r
-        assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getHeadEnd().getW());\r
-        assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getTailEnd().getW());\r
+        assertEquals(STLineEndWidth.MED, getSpPr(shape).getLn().getHeadEnd().getW());\r
+        assertEquals(STLineEndWidth.LG, getSpPr(shape).getLn().getTailEnd().getW());\r
 \r
         // line end length\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());\r
@@ -103,25 +102,26 @@ public class TestXSLFConnectorShape {
         shape.setLineTailLength(null);\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());\r
-        assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetLen());\r
-        assertFalse(shape.getSpPr().getLn().getTailEnd().isSetLen());\r
+        assertFalse(getSpPr(shape).getLn().getHeadEnd().isSetLen());\r
+        assertFalse(getSpPr(shape).getLn().getTailEnd().isSetLen());\r
         shape.setLineHeadLength(DecorationSize.LARGE);\r
         shape.setLineTailLength(DecorationSize.MEDIUM);\r
         assertEquals(DecorationSize.LARGE, shape.getLineHeadLength());\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());\r
-        assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getHeadEnd().getLen());\r
-        assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getTailEnd().getLen());\r
+        assertEquals(STLineEndLength.LG, getSpPr(shape).getLn().getHeadEnd().getLen());\r
+        assertEquals(STLineEndLength.MED, getSpPr(shape).getLn().getTailEnd().getLen());\r
         shape.setLineHeadLength(DecorationSize.MEDIUM);\r
         shape.setLineTailLength(DecorationSize.LARGE);\r
         assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());\r
         assertEquals(DecorationSize.LARGE, shape.getLineTailLength());\r
-        assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getHeadEnd().getLen());\r
-        assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getTailEnd().getLen());\r
+        assertEquals(STLineEndLength.MED, getSpPr(shape).getLn().getHeadEnd().getLen());\r
+        assertEquals(STLineEndLength.LG, getSpPr(shape).getLn().getTailEnd().getLen());\r
 \r
+        ppt.close();\r
     }\r
 \r
     @Test\r
-    public void testAddConnector(){\r
+    public void testAddConnector() throws IOException {\r
         XMLSlideShow pptx = new XMLSlideShow();\r
         XSLFSlide slide = pptx.createSlide();\r
 \r
@@ -152,6 +152,8 @@ public class TestXSLFConnectorShape {
         end.setId(rect2.getShapeId());\r
         // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4\r
         end.setIdx(3);\r
+        \r
+        pptx.close();\r
     }\r
 \r
 }
\ No newline at end of file
index b7b902f54255840ede0bb95516a77bf2202989f1..5a4e100e62b8f771eeb4dd44ee21ef53ad53f583 100644 (file)
@@ -16,7 +16,9 @@
 ==================================================================== */\r
 package org.apache.poi.xslf.usermodel;\r
 \r
+\r
 import static org.junit.Assert.assertEquals;\r
+import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;\r
 \r
 import java.awt.geom.Ellipse2D;\r
 import java.awt.geom.Path2D;\r
@@ -25,9 +27,6 @@ import java.io.IOException;
 \r
 import org.junit.Test;\r
 \r
-/**\r
- * @author Yegor Kozlov\r
- */\r
 public class TestXSLFFreeformShape {\r
 \r
     @Test\r
@@ -49,7 +48,7 @@ public class TestXSLFFreeformShape {
         XSLFFreeformShape shape2 = slide.createFreeform();\r
         shape2.setPath(path2);\r
 \r
-        assertEquals(shape1.getSpPr().getCustGeom().toString(), shape2.getSpPr().getCustGeom().toString());\r
+        assertEquals(getSpPr(shape1).getCustGeom().toString(), getSpPr(shape2).getCustGeom().toString());\r
         \r
         ppt.close();\r
     }\r
index 64dde4e66970d12fab0ae4fc027552363dad2600..c000da8a49154703cbcbb9c09216acec8dd6170c 100644 (file)
@@ -23,7 +23,10 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;\r
 import static org.junit.Assert.fail;\r
 \r
-import java.awt.*;\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.Graphics2D;\r
+import java.awt.RenderingHints;\r
 import java.awt.image.BufferedImage;\r
 import java.io.IOException;\r
 import java.util.List;\r
@@ -36,6 +39,7 @@ import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
 import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;\r
 import org.apache.poi.util.Units;\r
 import org.apache.poi.xslf.XSLFTestDataSamples;\r
+import org.apache.xmlbeans.XmlObject;\r
 import org.junit.Test;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList;\r
@@ -48,9 +52,6 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
 import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;\r
 \r
-/**\r
- * @author Yegor Kozlov\r
- */\r
 public class TestXSLFSimpleShape {\r
     \r
     @Test\r
@@ -61,7 +62,7 @@ public class TestXSLFSimpleShape {
         XSLFSimpleShape shape = slide.createAutoShape();\r
         assertEquals(1, slide.getShapes().size());\r
         // line properties are not set by default\r
-        assertFalse(shape.getSpPr().isSetLn());\r
+        assertFalse(getSpPr(shape).isSetLn());\r
 \r
         assertEquals(0., shape.getLineWidth(), 0);\r
         assertEquals(null, shape.getLineColor());\r
@@ -73,60 +74,60 @@ public class TestXSLFSimpleShape {
         shape.setLineDash(null);\r
         shape.setLineCap(null);\r
 \r
-        // still no line properties\r
-        assertFalse(shape.getSpPr().isSetLn());\r
+        assertTrue(getSpPr(shape).isSetLn());\r
+        assertTrue(getSpPr(shape).getLn().isSetNoFill());\r
 \r
         // line width\r
         shape.setLineWidth(1.0);\r
         assertEquals(1.0, shape.getLineWidth(), 0);\r
-        assertEquals(Units.EMU_PER_POINT, shape.getSpPr().getLn().getW());\r
+        assertEquals(Units.EMU_PER_POINT, getSpPr(shape).getLn().getW());\r
         shape.setLineWidth(5.5);\r
         assertEquals(5.5, shape.getLineWidth(), 0);\r
-        assertEquals(Units.toEMU(5.5), shape.getSpPr().getLn().getW());\r
+        assertEquals(Units.toEMU(5.5), getSpPr(shape).getLn().getW());\r
         shape.setLineWidth(0.0);\r
         // setting line width to zero unsets the W attribute\r
-        assertFalse(shape.getSpPr().getLn().isSetW());\r
+        assertFalse(getSpPr(shape).getLn().isSetW());\r
 \r
         // line cap\r
         shape.setLineCap(LineCap.FLAT);\r
         assertEquals(LineCap.FLAT, shape.getLineCap());\r
-        assertEquals(STLineCap.FLAT, shape.getSpPr().getLn().getCap());\r
+        assertEquals(STLineCap.FLAT, getSpPr(shape).getLn().getCap());\r
         shape.setLineCap(LineCap.SQUARE);\r
         assertEquals(LineCap.SQUARE, shape.getLineCap());\r
-        assertEquals(STLineCap.SQ, shape.getSpPr().getLn().getCap());\r
+        assertEquals(STLineCap.SQ, getSpPr(shape).getLn().getCap());\r
         shape.setLineCap(LineCap.ROUND);\r
         assertEquals(LineCap.ROUND, shape.getLineCap());\r
-        assertEquals(STLineCap.RND, shape.getSpPr().getLn().getCap());\r
+        assertEquals(STLineCap.RND, getSpPr(shape).getLn().getCap());\r
         shape.setLineCap(null);\r
         // setting cap to null unsets the Cap attribute\r
-        assertFalse(shape.getSpPr().getLn().isSetCap());\r
+        assertFalse(getSpPr(shape).getLn().isSetCap());\r
 \r
         // line dash\r
         shape.setLineDash(LineDash.SOLID);\r
         assertEquals(LineDash.SOLID, shape.getLineDash());\r
-        assertEquals(STPresetLineDashVal.SOLID, shape.getSpPr().getLn().getPrstDash().getVal());\r
+        assertEquals(STPresetLineDashVal.SOLID, getSpPr(shape).getLn().getPrstDash().getVal());\r
         shape.setLineDash(LineDash.DASH_DOT);\r
         assertEquals(LineDash.DASH_DOT, shape.getLineDash());\r
-        assertEquals(STPresetLineDashVal.DASH_DOT, shape.getSpPr().getLn().getPrstDash().getVal());\r
+        assertEquals(STPresetLineDashVal.DASH_DOT, getSpPr(shape).getLn().getPrstDash().getVal());\r
         shape.setLineDash(LineDash.LG_DASH_DOT);\r
         assertEquals(LineDash.LG_DASH_DOT, shape.getLineDash());\r
-        assertEquals(STPresetLineDashVal.LG_DASH_DOT, shape.getSpPr().getLn().getPrstDash().getVal());\r
+        assertEquals(STPresetLineDashVal.LG_DASH_DOT, getSpPr(shape).getLn().getPrstDash().getVal());\r
         shape.setLineDash(null);\r
         // setting dash width to null unsets the Dash element\r
-        assertFalse(shape.getSpPr().getLn().isSetPrstDash());\r
+        assertFalse(getSpPr(shape).getLn().isSetPrstDash());\r
 \r
         // line color\r
-        assertFalse(shape.getSpPr().getLn().isSetSolidFill());\r
+        assertFalse(getSpPr(shape).getLn().isSetSolidFill());\r
         shape.setLineColor(Color.RED);\r
         assertEquals(Color.RED, shape.getLineColor());\r
-        assertTrue(shape.getSpPr().getLn().isSetSolidFill());\r
+        assertTrue(getSpPr(shape).getLn().isSetSolidFill());\r
         shape.setLineColor(Color.BLUE);\r
         assertEquals(Color.BLUE, shape.getLineColor());\r
-        assertTrue(shape.getSpPr().getLn().isSetSolidFill());\r
+        assertTrue(getSpPr(shape).getLn().isSetSolidFill());\r
         shape.setLineColor(null);\r
         assertEquals(null, shape.getLineColor());\r
         // setting dash width to null unsets the SolidFill element\r
-        assertFalse(shape.getSpPr().getLn().isSetSolidFill());\r
+        assertFalse(getSpPr(shape).getLn().isSetSolidFill());\r
 \r
         XSLFSimpleShape ln2 = slide.createAutoShape();\r
         ln2.setLineDash(LineDash.DOT);\r
@@ -152,22 +153,22 @@ public class TestXSLFSimpleShape {
 \r
         XSLFAutoShape shape = slide.createAutoShape();\r
         // line properties are not set by default\r
-        assertFalse(shape.getSpPr().isSetSolidFill());\r
+        assertFalse(getSpPr(shape).isSetSolidFill());\r
 \r
         assertNull(shape.getFillColor());\r
         shape.setFillColor(null);\r
         assertNull(shape.getFillColor());\r
-        assertFalse(shape.getSpPr().isSetSolidFill());\r
+        assertFalse(getSpPr(shape).isSetSolidFill());\r
 \r
         shape.setFillColor(Color.RED);\r
         assertEquals(Color.RED, shape.getFillColor());\r
         shape.setFillColor(Color.DARK_GRAY);\r
         assertEquals(Color.DARK_GRAY, shape.getFillColor());\r
-        assertTrue(shape.getSpPr().isSetSolidFill());\r
+        assertTrue(getSpPr(shape).isSetSolidFill());\r
 \r
         shape.setFillColor(null);\r
         assertNull(shape.getFillColor());\r
-        assertFalse(shape.getSpPr().isSetSolidFill());\r
+        assertFalse(getSpPr(shape).isSetSolidFill());\r
         ppt.close();\r
     }\r
 \r
@@ -188,56 +189,56 @@ public class TestXSLFSimpleShape {
 \r
         XSLFSimpleShape s0 = (XSLFSimpleShape) shapes.get(0);\r
         // fill is not set\r
-        assertNull(s0.getSpPr().getSolidFill());\r
+        assertNull(getSpPr(s0).getSolidFill());\r
         //assertEquals(slide6.getTheme().getColor("accent1").getColor(), s0.getFillColor());\r
         assertEquals(new Color(79, 129, 189), s0.getFillColor());\r
 \r
         // lighter 80%\r
         XSLFSimpleShape s1 = (XSLFSimpleShape)shapes.get(1);\r
-        CTSchemeColor ref1 = s1.getSpPr().getSolidFill().getSchemeClr();\r
+        CTSchemeColor ref1 = getSpPr(s1).getSolidFill().getSchemeClr();\r
         assertEquals(1, ref1.sizeOfLumModArray());\r
         assertEquals(1, ref1.sizeOfLumOffArray());\r
         assertEquals(20000, ref1.getLumModArray(0).getVal());\r
         assertEquals(80000, ref1.getLumOffArray(0).getVal());\r
         assertEquals("accent1", ref1.getVal().toString());\r
-        assertEquals(new Color(79, 129, 189), s1.getFillColor());\r
+        assertEquals(new Color(220, 230, 242), s1.getFillColor());\r
 \r
         // lighter 60%\r
         XSLFSimpleShape s2 = (XSLFSimpleShape)shapes.get(2);\r
-        CTSchemeColor ref2 = s2.getSpPr().getSolidFill().getSchemeClr();\r
+        CTSchemeColor ref2 = getSpPr(s2).getSolidFill().getSchemeClr();\r
         assertEquals(1, ref2.sizeOfLumModArray());\r
         assertEquals(1, ref2.sizeOfLumOffArray());\r
         assertEquals(40000, ref2.getLumModArray(0).getVal());\r
         assertEquals(60000, ref2.getLumOffArray(0).getVal());\r
         assertEquals("accent1", ref2.getVal().toString());\r
-        assertEquals(new Color(79, 129, 189), s2.getFillColor());\r
+        assertEquals(new Color(185, 205, 229), s2.getFillColor());\r
 \r
         // lighter 40%\r
         XSLFSimpleShape s3 = (XSLFSimpleShape)shapes.get(3);\r
-        CTSchemeColor ref3 = s3.getSpPr().getSolidFill().getSchemeClr();\r
+        CTSchemeColor ref3 = getSpPr(s3).getSolidFill().getSchemeClr();\r
         assertEquals(1, ref3.sizeOfLumModArray());\r
         assertEquals(1, ref3.sizeOfLumOffArray());\r
         assertEquals(60000, ref3.getLumModArray(0).getVal());\r
         assertEquals(40000, ref3.getLumOffArray(0).getVal());\r
         assertEquals("accent1", ref3.getVal().toString());\r
-        assertEquals(new Color(79, 129, 189), s3.getFillColor());\r
+        assertEquals(new Color(149, 179, 215), s3.getFillColor());\r
 \r
         // darker 25%\r
         XSLFSimpleShape s4 = (XSLFSimpleShape)shapes.get(4);\r
-        CTSchemeColor ref4 = s4.getSpPr().getSolidFill().getSchemeClr();\r
+        CTSchemeColor ref4 = getSpPr(s4).getSolidFill().getSchemeClr();\r
         assertEquals(1, ref4.sizeOfLumModArray());\r
         assertEquals(0, ref4.sizeOfLumOffArray());\r
         assertEquals(75000, ref4.getLumModArray(0).getVal());\r
         assertEquals("accent1", ref3.getVal().toString());\r
-        assertEquals(new Color(79, 129, 189), s4.getFillColor());\r
+        assertEquals(new Color(55, 96, 146), s4.getFillColor());\r
 \r
         XSLFSimpleShape s5 = (XSLFSimpleShape)shapes.get(5);\r
-        CTSchemeColor ref5 = s5.getSpPr().getSolidFill().getSchemeClr();\r
+        CTSchemeColor ref5 = getSpPr(s5).getSolidFill().getSchemeClr();\r
         assertEquals(1, ref5.sizeOfLumModArray());\r
         assertEquals(0, ref5.sizeOfLumOffArray());\r
         assertEquals(50000, ref5.getLumModArray(0).getVal());\r
         assertEquals("accent1", ref5.getVal().toString());\r
-        assertEquals(new Color(79, 129, 189), s5.getFillColor());\r
+        assertEquals(new Color(37, 64, 97), s5.getFillColor());\r
         \r
         ppt.close();\r
     }\r
@@ -253,13 +254,13 @@ public class TestXSLFSimpleShape {
         XSLFTextShape sh1 = (XSLFTextShape)shapes2.get(0);\r
         assertEquals(Placeholder.CENTERED_TITLE, sh1.getTextType());\r
         assertEquals("PPTX Title", sh1.getText());\r
-        assertNull(sh1.getSpPr().getXfrm()); // xfrm is not set, the query is delegated to the slide layout\r
+        assertFalse(getSpPr(sh1).isSetXfrm()); // xfrm is not set, the query is delegated to the slide layout\r
         assertEquals(sh1.getAnchor(), layout2.getTextShapeByType(Placeholder.CENTERED_TITLE).getAnchor());\r
 \r
         XSLFTextShape sh2 = (XSLFTextShape)shapes2.get(1);\r
         assertEquals("Subtitle\nAnd second line", sh2.getText());\r
         assertEquals(Placeholder.SUBTITLE, sh2.getTextType());\r
-        assertNull(sh2.getSpPr().getXfrm()); // xfrm is not set, the query is delegated to the slide layout\r
+        assertFalse(getSpPr(sh2).isSetXfrm()); // xfrm is not set, the query is delegated to the slide layout\r
         assertEquals(sh2.getAnchor(), layout2.getTextShapeByType(Placeholder.SUBTITLE).getAnchor());\r
 \r
         XSLFSlide slide5 = slide.get(4);\r
@@ -267,16 +268,16 @@ public class TestXSLFSimpleShape {
         XSLFTextShape shTitle = slide5.getTextShapeByType(Placeholder.TITLE);\r
         assertEquals("Hyperlinks", shTitle.getText());\r
         // xfrm is not set, the query is delegated to the slide layout\r
-        assertNull(shTitle.getSpPr().getXfrm());\r
+        assertFalse(getSpPr(shTitle).isSetXfrm());\r
         // xfrm is not set, the query is delegated to the slide master\r
-        assertNull(layout5.getTextShapeByType(Placeholder.TITLE).getSpPr().getXfrm());\r
-        assertNotNull(layout5.getSlideMaster().getTextShapeByType(Placeholder.TITLE).getSpPr().getXfrm());\r
+        assertFalse(getSpPr(layout5.getTextShapeByType(Placeholder.TITLE)).isSetXfrm());\r
+        assertTrue(getSpPr(layout5.getSlideMaster().getTextShapeByType(Placeholder.TITLE)).isSetXfrm());\r
         assertEquals(shTitle.getAnchor(), layout5.getSlideMaster().getTextShapeByType(Placeholder.TITLE).getAnchor());\r
 \r
         ppt.close();\r
     }\r
 \r
-    @SuppressWarnings({ "deprecation", "unused" })\r
+    @SuppressWarnings("unused")\r
     @Test\r
     public void testShadowEffects() throws IOException{\r
         XMLSlideShow ppt = new XMLSlideShow();\r
@@ -296,7 +297,7 @@ public class TestXSLFSimpleShape {
         XSLFSlide slide = ppt.createSlide();\r
 \r
         XSLFSimpleShape shape = slide.createAutoShape();\r
-        CTShapeProperties spPr = shape.getSpPr();\r
+        CTShapeProperties spPr = getSpPr(shape);\r
         \r
         CTPresetGeometry2D prstGeom = CTPresetGeometry2D.Factory.newInstance();\r
         prstGeom.setPrst(STShapeType.Enum.forInt(1));\r
@@ -320,7 +321,7 @@ public class TestXSLFSimpleShape {
         XSLFSlide slide = ppt.createSlide();\r
 \r
         XSLFSimpleShape shape = slide.createAutoShape();\r
-        CTShapeProperties spPr = shape.getSpPr();\r
+        CTShapeProperties spPr = getSpPr(shape);\r
         \r
         CTPresetGeometry2D prstGeom = CTPresetGeometry2D.Factory.newInstance();\r
         prstGeom.setPrst(STShapeType.Enum.forInt(1));\r
@@ -376,4 +377,10 @@ public class TestXSLFSimpleShape {
         }\r
         ppt.close();\r
     }\r
+    \r
+    static CTShapeProperties getSpPr(XSLFShape shape) {\r
+        XmlObject xo = shape.getShapeProperties();\r
+        assertTrue(xo instanceof CTShapeProperties);\r
+        return (CTShapeProperties)xo;\r
+    }\r
 }
\ No newline at end of file
index a87a9cb555fde1df681f6208b7f18f4834c5f24a..8ae19f26590329b67309e0db3ce1870004ff3c8e 100644 (file)
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;\r
 import static org.junit.Assert.assertSame;\r
 import static org.junit.Assert.assertTrue;\r
+import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr;\r
 \r
 import java.awt.Color;\r
 import java.io.File;\r
@@ -73,10 +74,10 @@ public class TestXSLFTextShape {
         CTPlaceholder ph1 = shape1.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.CTR_TITLE, ph1.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape1).getXfrm());\r
 \r
         XSLFTextShape masterShape1 = (XSLFTextShape)layout.getPlaceholder(ph1);\r
-        assertNotNull(masterShape1.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape1).getXfrm());\r
         assertEquals(masterShape1.getAnchor(), shape1.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();\r
@@ -103,10 +104,10 @@ public class TestXSLFTextShape {
         CTPlaceholder ph2 = shape2.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.SUB_TITLE, ph2.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape2.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape2).getXfrm());\r
 \r
         XSLFTextShape masterShape2 = (XSLFTextShape)layout.getPlaceholder(ph2);\r
-        assertNotNull(masterShape2.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape2).getXfrm());\r
         assertEquals(masterShape2.getAnchor(), shape2.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();\r
@@ -139,13 +140,13 @@ public class TestXSLFTextShape {
         CTPlaceholder ph1 = shape1.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.TITLE, ph1.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape1).getXfrm());\r
 \r
         XSLFTextShape masterShape1 = (XSLFTextShape)layout.getPlaceholder(ph1);\r
         // layout does not have anchor info either, it is in the slide master\r
-        assertNull(masterShape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(masterShape1).getXfrm());\r
         masterShape1 = (XSLFTextShape)layout.getSlideMaster().getPlaceholder(ph1);\r
-        assertNotNull(masterShape1.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape1).getXfrm());\r
         assertEquals(masterShape1.getAnchor(), shape1.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();\r
@@ -174,13 +175,13 @@ public class TestXSLFTextShape {
         assertTrue(ph2.isSetIdx());\r
         assertEquals(1, ph2.getIdx());\r
         // anchor is not defined in the shape\r
-        assertNull(shape2.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape2).getXfrm());\r
 \r
         XSLFTextShape masterShape2 = (XSLFTextShape)layout.getPlaceholder(ph2);\r
         // anchor of the body text is missing in the slide layout, llokup in the slide master\r
-        assertNull(masterShape2.getSpPr().getXfrm());\r
+        assertNull(getSpPr(masterShape2).getXfrm());\r
         masterShape2 = (XSLFTextShape)layout.getSlideMaster().getPlaceholder(ph2);\r
-        assertNotNull(masterShape2.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape2).getXfrm());\r
         assertEquals(masterShape2.getAnchor(), shape2.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();\r
@@ -252,10 +253,10 @@ public class TestXSLFTextShape {
         CTPlaceholder ph1 = shape1.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.TITLE, ph1.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape1).getXfrm());\r
 \r
         XSLFTextShape masterShape1 = (XSLFTextShape)layout.getPlaceholder(ph1);\r
-        assertNotNull(masterShape1.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape1).getXfrm());\r
         assertEquals(masterShape1.getAnchor(), shape1.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();\r
@@ -286,10 +287,10 @@ public class TestXSLFTextShape {
         CTPlaceholder ph2 = shape2.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.BODY, ph2.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape2.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape2).getXfrm());\r
 \r
         XSLFTextShape masterShape2 = (XSLFTextShape)layout.getPlaceholder(ph2);\r
-        assertNotNull(masterShape2.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape2).getXfrm());\r
         assertEquals(masterShape2.getAnchor(), shape2.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();\r
@@ -323,13 +324,13 @@ public class TestXSLFTextShape {
         CTPlaceholder ph1 = shape1.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.TITLE, ph1.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape1).getXfrm());\r
 \r
         XSLFTextShape masterShape1 = (XSLFTextShape)layout.getPlaceholder(ph1);\r
         // layout does not have anchor info either, it is in the slide master\r
-        assertNull(masterShape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(masterShape1).getXfrm());\r
         masterShape1 = (XSLFTextShape)layout.getSlideMaster().getPlaceholder(ph1);\r
-        assertNotNull(masterShape1.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape1).getXfrm());\r
         assertEquals(masterShape1.getAnchor(), shape1.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();\r
@@ -359,10 +360,10 @@ public class TestXSLFTextShape {
         assertTrue(ph2.isSetIdx());\r
         assertEquals(1, ph2.getIdx());  //<p:ph sz="half" idx="1"/>\r
         // anchor is not defined in the shape\r
-        assertNull(shape2.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape2).getXfrm());\r
 \r
         XSLFTextShape masterShape2 = (XSLFTextShape)layout.getPlaceholder(ph2);\r
-        assertNotNull(masterShape2.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape2).getXfrm());\r
         assertEquals(masterShape2.getAnchor(), shape2.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();\r
@@ -438,7 +439,7 @@ public class TestXSLFTextShape {
         CTPlaceholder ph1 = shape1.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.TITLE, ph1.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape1).getXfrm());\r
 \r
         CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();\r
         // none of the following properties are set in the shapes and fetched from the master shape\r
@@ -506,11 +507,11 @@ public class TestXSLFTextShape {
         CTPlaceholder ph1 = shape1.getCTPlaceholder();\r
         assertEquals(STPlaceholderType.TITLE, ph1.getType());\r
         // anchor is not defined in the shape\r
-        assertNull(shape1.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape1).getXfrm());\r
 \r
         XSLFTextShape masterShape1 = (XSLFTextShape)layout.getPlaceholder(ph1);\r
         // layout does not have anchor info either, it is in the slide master\r
-        assertNotNull(masterShape1.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape1).getXfrm());\r
         assertEquals(masterShape1.getAnchor(), shape1.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr1 = shape1.getTextBodyPr();\r
@@ -541,10 +542,10 @@ public class TestXSLFTextShape {
         assertTrue(ph2.isSetIdx());\r
         assertEquals(1, ph2.getIdx());\r
         // anchor is not defined in the shape\r
-        assertNull(shape2.getSpPr().getXfrm());\r
+        assertNull(getSpPr(shape2).getXfrm());\r
 \r
         XSLFTextShape masterShape2 = (XSLFTextShape)layout.getPlaceholder(ph2);\r
-        assertNotNull(masterShape2.getSpPr().getXfrm());\r
+        assertNotNull(getSpPr(masterShape2).getXfrm());\r
         assertEquals(masterShape2.getAnchor(), shape2.getAnchor());\r
 \r
         CTTextBodyProperties bodyPr2 = shape2.getTextBodyPr();\r