poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1187328 [1/5] - in /poi/trunk: src/documentation/content/xdocs/ src/ooxml/java/org/apache/poi/util/ src/ooxml/java/org/apache/poi/xslf/model/ src/ooxml/java/org/apache/poi/xslf/usermodel/ src/ooxml/java/org/apache/poi/xslf/util/ src/ooxml/...
Date Fri, 21 Oct 2011 13:17:34 GMT
Author: yegor
Date: Fri Oct 21 13:17:33 2011
New Revision: 1187328

URL: http://svn.apache.org/viewvc?rev=1187328&view=rev
Log:
initial support for rendering pptx slides into images with a PPTX2PNG command-line utility

Added:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/CharacterPropertyFetcher.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPresetGeometry.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRenderingHint.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/util/PPTX2PNG.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
      - copied, changed from r1182759, poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
    poi/trunk/src/resources/scratchpad/org/apache/poi/xslf/usermodel/presetShapeDefinitions.xml   (with props)
    poi/trunk/test-data/slideshow/layouts.pptx   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/util/Units.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXMLSlideShow.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java
    poi/trunk/test-data/slideshow/shapes.pptx

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Oct 21 13:17:33 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="add">support for converting pptx files into images with a PPTX2PNG tool</action>
            <action dev="poi-developers" type="add">52050 - Support for the Excel RATE function</action>
            <action dev="poi-developers" type="fix">51566 - HSLF fix for finishing parsing the picture stream on the first non-valid type</action>
            <action dev="poi-developers" type="fix">51974 - Avoid HWPF issue when identifying the picture type</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/util/Units.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/util/Units.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/util/Units.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/util/Units.java Fri Oct 21 13:17:33 2011
@@ -13,7 +13,8 @@
    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.util;
+==================================================================== */
+package org.apache.poi.util;
 
 /**
  * @author Yegor Kozlov

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/CharacterPropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/CharacterPropertyFetcher.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/CharacterPropertyFetcher.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/CharacterPropertyFetcher.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,45 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xslf.model;
+
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
+
+/**
+ *
+ * @author Yegor Kozlov
+ */
+public abstract class CharacterPropertyFetcher<T> extends ParagraphPropertyFetcher<T> {
+
+    public CharacterPropertyFetcher(int level) {
+        super(level);
+    }
+
+    public boolean fetch(CTTextParagraphProperties props) {
+        if (props.isSetDefRPr()) {
+            return fetch(props.getDefRPr());
+        }
+
+        return false;
+    }
+
+    public abstract boolean fetch(CTTextCharacterProperties props);
+
+}
\ No newline at end of file

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,52 @@
+/*
+ *  ====================================================================
+ *    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.model;
+
+import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
+import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
+
+/**
+ *
+ * @author Yegor Kozlov
+ */
+public abstract class ParagraphPropertyFetcher<T> extends PropertyFetcher<T> {
+    int _level;
+
+    public ParagraphPropertyFetcher(int level) {
+        _level = level;
+    }
+
+    public boolean fetch(XSLFSimpleShape shape) {
+
+        XmlObject[] o = shape.getXmlObject().selectPath(
+                "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' " +
+                "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' " +
+                ".//p:txBody/a:lstStyle/a:lvl" + (_level + 1) + "pPr"
+        );
+        if (o.length == 1) {
+            CTTextParagraphProperties props = (CTTextParagraphProperties) o[0];
+            return fetch(props);
+        }
+        return false;
+    }
+
+    public abstract boolean fetch(CTTextParagraphProperties props);
+}
\ No newline at end of file

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,48 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.poi.xslf.model;
+
+import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
+import org.apache.poi.util.Internal;
+
+/**
+ *  Used internally to navigate the PresentationML text style hierarchy and fetch properties
+ *
+ * @author Yegor Kozlov
+*/
+@Internal
+public abstract class PropertyFetcher<T> {
+    private T _value;
+
+    /**
+     *
+     * @param shape the shape being examined
+     * @return true if the desired property was fetched
+     */
+    public abstract boolean fetch(XSLFSimpleShape shape) ;
+
+    public T getValue(){
+        return _value;
+    }
+
+    public void setValue(T val){
+        _value = val;
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,52 @@
+/*
+ *  ====================================================================
+ *    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.model;
+
+import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
+import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yegor
+ * Date: Oct 21, 2011
+ * Time: 1:18:52 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class TextBodyPropertyFetcher<T> extends PropertyFetcher<T> {
+
+    public boolean fetch(XSLFSimpleShape shape) {
+
+        XmlObject[] o = shape.getXmlObject().selectPath(
+                "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' " +
+                "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' " +
+                ".//p:txBody/a:bodyPr"
+        );
+        if (o.length == 1) {
+            CTTextBodyProperties props = (CTTextBodyProperties) o[0];
+            return fetch(props);
+        }
+
+        return false;
+    }
+
+    public abstract boolean fetch(CTTextBodyProperties props);
+
+}
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java Fri Oct 21 13:17:33 2011
@@ -21,6 +21,8 @@ package org.apache.poi.xslf.usermodel;
 
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Units;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuide;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGeomGuideList;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
@@ -39,8 +41,12 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
 
 import java.awt.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 
 /**
  * Represents a preset geometric shape. 
@@ -49,6 +55,7 @@ import java.util.List;
  */
 @Beta
 public class XSLFAutoShape extends XSLFTextShape {
+    private static final Pattern adjPtrn = Pattern.compile("val\\s+(\\d+)");
 
     /*package*/ XSLFAutoShape(CTShape shape, XSLFSheet sheet) {
         super(shape, sheet);
@@ -83,44 +90,6 @@ public class XSLFAutoShape extends XSLFT
         return ct;
     }
 
-    /**
-     * Specifies a solid color fill. The shape is filled entirely with the specified color.
-     *
-     * @param color the solid color fill.
-     * The value of <code>null</code> unsets the solidFIll attribute from the underlying xml
-     */
-    public void setFillColor(Color color) {
-        CTShapeProperties spPr = getSpPr();
-        if (color == null) {
-            if(spPr.isSetSolidFill()) spPr.unsetSolidFill();
-        }
-        else {
-            CTSolidColorFillProperties fill = spPr.isSetSolidFill() ? spPr.getSolidFill() : spPr.addNewSolidFill();
-
-            CTSRgbColor rgb = CTSRgbColor.Factory.newInstance();
-            rgb.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()});
-
-            fill.setSrgbClr(rgb);
-        }
-    }
-
-    /**
-     *
-     * @return solid fill color of null if not set
-     */
-    public Color getFillColor(){
-        CTShapeProperties spPr = getSpPr();
-        if(!spPr.isSetSolidFill() ) return null;
-
-        CTSolidColorFillProperties fill = spPr.getSolidFill();
-        if(!fill.isSetSrgbClr()) {
-            // TODO for now return null for all colors except explicit RGB
-            return null;
-        }
-        byte[] val = fill.getSrgbClr().getVal();
-        return new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
-    }
-
     protected CTTextBody getTextBody(boolean create){
         CTShape shape = (CTShape) getXmlObject();
         CTTextBody txBody = shape.getTxBody();
@@ -132,4 +101,38 @@ public class XSLFAutoShape extends XSLFT
         return txBody;
     }
 
-}
\ No newline at end of file
+    int getAdjustValue(String name, int defaultValue){
+        /*
+        CTShape shape = (CTShape) getXmlObject();
+        CTGeomGuideList av = shape.getSpPr().getPrstGeom().getAvLst();
+        if(av != null){
+            for(CTGeomGuide gd : av.getGdList()){
+                if(gd.getName().equals(name)) {
+                    String fmla = gd.getFmla();
+                    Matcher m = adjPtrn.matcher(fmla);
+                    if(m.matches()){
+                        int val = Integer.parseInt(m.group(1));
+                        return 21600*val/100000;
+                    }
+                }
+            }
+        }
+        */
+        return defaultValue;
+    }
+
+    @Override
+    protected java.awt.Shape getOutline(){
+        java.awt.Shape outline = XSLFPresetGeometry.getOutline(this);
+        Rectangle2D anchor = getAnchor();
+
+        AffineTransform at = new AffineTransform();
+        at.translate(anchor.getX(), anchor.getY());
+        at.scale(
+                1.0f/21600*anchor.getWidth(),
+                1.0f/21600*anchor.getHeight()
+        );
+        return outline == null ? anchor : at.createTransformedShape(outline);
+    }
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,70 @@
+/* ====================================================================
+   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.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+/**
+ * Background shape
+ *
+ * @author Yegor Kozlov
+ */
+public class XSLFBackground extends XSLFSimpleShape {
+
+    /* package */XSLFBackground(CTBackground shape, XSLFSheet sheet) {
+        super(shape, sheet);
+    }
+
+    public void draw(Graphics2D graphics) {
+        Dimension pg = getSheet().getSlideShow().getPageSize();
+        Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height);
+        CTBackgroundProperties pr = ((CTBackground) getXmlObject()).getBgPr();
+        if (pr == null) return;
+
+        XSLFTheme theme = getSheet().getTheme();
+        if (pr.isSetSolidFill()) {
+            Color color = theme.getSolidFillColor(pr.getSolidFill());
+            graphics.setPaint(color);
+            graphics.fill(anchor);
+        }
+        if (pr.isSetBlipFill()) {
+
+            String blipId = pr.getBlipFill().getBlip().getEmbed();
+            PackagePart p = getSheet().getPackagePart();
+            PackageRelationship rel = p.getRelationship(blipId);
+            if (rel != null) {
+                try {
+                    BufferedImage img = ImageIO.read(p.getRelatedPart(rel).getInputStream());
+                    graphics.drawImage(img, (int) anchor.getX(), (int) anchor.getY(),
+                            (int) anchor.getWidth(), (int) anchor.getHeight(), null);
+                }
+                catch (Exception e) {
+                    return;
+                }
+            }
+        }
+    }
+
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,54 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+package org.apache.poi.xslf.usermodel;
+
+import java.awt.Color;
+
+import org.apache.poi.util.Internal;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet;
+
+public class XSLFColor {
+	private final CTColor _ctColor;
+	
+	XSLFColor(CTColor ctColor){
+		_ctColor = ctColor;
+	}
+	
+    @Internal
+    public CTColor getXmlObject() {
+        return _ctColor;
+    }
+    
+    public Color getColor(){
+    	return getColor(0xFF);
+    }
+	
+    public Color getColor(int alpha){
+    	Color color = Color.black;
+    	if(_ctColor.isSetSrgbClr()){
+    		byte[] val = _ctColor.getSrgbClr().getVal();
+    		color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2], alpha);
+    	} else if (_ctColor.isSetSysClr()){
+    		byte[] val = _ctColor.getSysClr().getLastClr();
+    		color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2], alpha);
+    	}
+    	return color;
+    }
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java Fri Oct 21 13:17:33 2011
@@ -32,6 +32,10 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnectorNonVisual;
 
+import java.awt.*;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+
 /**
  *
  * Specifies a connection shape. 
@@ -192,4 +196,36 @@ public class XSLFConnectorShape extends 
         return len == null ? null : LineEndLength.values()[len.intValue() - 1];
     }
 
+    @Override
+    public void draw(Graphics2D graphics){
+        java.awt.Shape outline = getOutline();
+
+        // shadow
+        XSLFShadow shadow = getShadow();
+        if(shadow != null) shadow.draw(graphics);
+
+        //border
+        Color lineColor = getLineColor();
+        if (lineColor != null){
+            graphics.setColor(lineColor);
+            applyStroke(graphics);
+            graphics.draw(outline);
+        }
+    }
+
+    @Override
+    protected java.awt.Shape getOutline(){
+        Rectangle2D anchor = getAnchor();
+        double  x1 = anchor.getX(),
+                y1 = anchor.getY(),
+                x2 = anchor.getX() + anchor.getWidth(),
+                y2 = anchor.getY() + anchor.getHeight();
+
+        GeneralPath line = new GeneralPath();
+        line.moveTo((float)x1, (float)y1);
+        line.lineTo((float)x2, (float)y2);
+
+        return line;
+    }
+
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java Fri Oct 21 13:17:33 2011
@@ -111,34 +111,45 @@ public class XSLFFreeformShape extends X
         return numPoints;
     }
 
+    /**
+     * Gets the shape path.
+     * <p>
+     *     The path is translated in the shape's coordinate system, i.e.
+     *     freeform.getPath().getBounds2D() equals to freeform.getAnchor()
+     *     (small discrepancies are possible due to rounding errors)
+     * </p>
+     *
+     * @return the path
+     */
     public GeneralPath getPath() {
         GeneralPath path = new GeneralPath();
         Rectangle2D bounds = getAnchor();
-        int x0 = Units.toEMU(bounds.getX());
-        int y0 = Units.toEMU(bounds.getY());
+
         CTCustomGeometry2D geom = getSpPr().getCustGeom();
         for(CTPath2D spPath : geom.getPathLst().getPathList()){
+            double scaleW = bounds.getWidth() / Units.toPoints(spPath.getW());
+            double scaleH = bounds.getHeight() / Units.toPoints(spPath.getH());
             for(XmlObject ch : spPath.selectPath("*")){
                 if(ch instanceof CTPath2DMoveTo){
                     CTAdjPoint2D pt = ((CTPath2DMoveTo)ch).getPt();
-                    path.moveTo((float)Units.toPoints((Long)pt.getX() + x0),
-                                (float)Units.toPoints((Long)pt.getY() + y0));
+                    path.moveTo((float)Units.toPoints((Long)pt.getX())*scaleW,
+                                (float)Units.toPoints((Long)pt.getY())*scaleH);
                 } else if (ch instanceof CTPath2DLineTo){
                     CTAdjPoint2D pt = ((CTPath2DLineTo)ch).getPt();
-                    path.lineTo((float)Units.toPoints((Long)pt.getX() + x0),
-                                (float)Units.toPoints((Long)pt.getY() + y0));
+                    path.lineTo((float)Units.toPoints((Long)pt.getX()),
+                                (float)Units.toPoints((Long)pt.getY()));
                 } else if (ch instanceof CTPath2DCubicBezierTo){
                     CTPath2DCubicBezierTo bez = ((CTPath2DCubicBezierTo)ch);
                     CTAdjPoint2D pt1 = bez.getPtArray(0);
                     CTAdjPoint2D pt2 = bez.getPtArray(1);
                     CTAdjPoint2D pt3 = bez.getPtArray(2);
                     path.curveTo(
-                            (float)Units.toPoints((Long) pt1.getX() + x0),
-                            (float)Units.toPoints((Long) pt1.getY() + y0),
-                            (float)Units.toPoints((Long) pt2.getX() + x0),
-                            (float)Units.toPoints((Long) pt2.getY() + y0),
-                            (float)Units.toPoints((Long) pt3.getX() + x0),
-                            (float)Units.toPoints((Long) pt3.getY() + y0)
+                            (float)Units.toPoints((Long) pt1.getX())*scaleW,
+                            (float)Units.toPoints((Long) pt1.getY())*scaleH,
+                            (float)Units.toPoints((Long) pt2.getX())*scaleW,
+                            (float)Units.toPoints((Long) pt2.getY())*scaleH,
+                            (float)Units.toPoints((Long) pt3.getX())*scaleW,
+                            (float)Units.toPoints((Long) pt3.getY())*scaleH
                     );
 
                 } else if (ch instanceof CTPath2DClose){
@@ -147,7 +158,11 @@ public class XSLFFreeformShape extends X
             }
         }
 
-        return path;
+        // the created path starts at (x=0, y=0).
+        // The returned path should fit in the bounding rectangle
+        AffineTransform at = new AffineTransform();
+        at.translate(bounds.getX(), bounds.getY());
+        return new GeneralPath(at.createTransformedShape(path));
     }
     /**
      * @param shapeId 1-based shapeId
@@ -175,4 +190,9 @@ public class XSLFFreeformShape extends X
         return ct;
     }
 
+    @Override
+    protected java.awt.Shape getOutline(){
+        return getPath();
+    }
+
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java Fri Oct 21 13:17:33 2011
@@ -23,8 +23,16 @@ import org.apache.poi.sl.usermodel.Shape
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.ShapeGroup;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.Units;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
 
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 
 /**
@@ -61,11 +69,31 @@ public class XSLFGraphicFrame extends XS
     }
 
     public Rectangle2D getAnchor(){
-        throw new RuntimeException("NotImplemented");
+        CTTransform2D xfrm = _shape.getXfrm();
+        CTPoint2D off = xfrm.getOff();
+        long x = off.getX();
+        long y = off.getY();
+        CTPositiveSize2D ext = xfrm.getExt();
+        long cx = ext.getCx();
+        long cy = ext.getCy();
+        return new Rectangle2D.Double(
+                Units.toPoints(x), Units.toPoints(y),
+                Units.toPoints(cx), Units.toPoints(cy));
     }
 
     public void setAnchor(Rectangle2D anchor){
-        throw new RuntimeException("NotImplemented");
+        CTTransform2D xfrm = _shape.getXfrm();
+        CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
+        long x = Units.toEMU(anchor.getX());
+        long y = Units.toEMU(anchor.getY());
+        off.setX(x);
+        off.setY(y);
+        CTPositiveSize2D ext = xfrm.isSetExt() ? xfrm.getExt() : xfrm
+                .addNewExt();
+        long cx = Units.toEMU(anchor.getWidth());
+        long cy = Units.toEMU(anchor.getHeight());
+        ext.setCx(cx);
+        ext.setCy(cy);
     }
 
 
@@ -78,4 +106,56 @@ public class XSLFGraphicFrame extends XS
         }
     }
 
+    /**
+     * Rotate this shape.
+     * <p>
+     * Positive angles are clockwise (i.e., towards the positive y axis);
+     * negative angles are counter-clockwise (i.e., towards the negative y axis).
+     * </p>
+     *
+     * @param theta the rotation angle in degrees.
+     */
+    public void setRotation(double theta){
+    	throw new IllegalArgumentException("Operation not supported");
+    }
+   
+    /**
+     * Rotation angle in degrees
+     * <p>
+     * Positive angles are clockwise (i.e., towards the positive y axis);
+     * negative angles are counter-clockwise (i.e., towards the negative y axis).
+     * </p>
+     *
+     * @return rotation angle in degrees
+     */
+    public double getRotation(){
+    	return 0;
+    }
+
+    public void setFlipHorizontal(boolean flip){
+    	throw new IllegalArgumentException("Operation not supported");
+    }
+
+    public void setFlipVertical(boolean flip){
+    	throw new IllegalArgumentException("Operation not supported");
+    }
+    
+    /**
+     * Whether the shape is horizontally flipped
+     *
+     * @return whether the shape is horizontally flipped
+     */
+    public boolean getFlipHorizontal(){
+    	return false;
+    }
+
+    public boolean getFlipVertical(){
+    	return false;
+    }
+
+    public void draw(Graphics2D graphics){
+
+    }
+
+
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java Fri Oct 21 13:17:33 2011
@@ -33,11 +33,14 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -217,4 +220,80 @@ public class XSLFGroupShape extends XSLF
         return sh;
     }
 
+
+    public void setFlipHorizontal(boolean flip){
+        _spPr.getXfrm().setFlipH(flip);
+    }
+
+    public void setFlipVertical(boolean flip){
+        _spPr.getXfrm().setFlipV(flip);
+    }
+    /**
+     * Whether the shape is horizontally flipped
+     *
+     * @return whether the shape is horizontally flipped
+     */
+    public boolean getFlipHorizontal(){
+         return _spPr.getXfrm().getFlipH();
+    }
+
+    public boolean getFlipVertical(){
+         return _spPr.getXfrm().getFlipV();
+    }
+
+    /**
+     * Rotate this shape.
+     * <p>
+     * Positive angles are clockwise (i.e., towards the positive y axis);
+     * negative angles are counter-clockwise (i.e., towards the negative y axis).
+     * </p>
+     *
+     * @param theta the rotation angle in degrees.
+     */
+    public void setRotation(double theta){
+        _spPr.getXfrm().setRot((int)(theta*60000));
+    }
+
+    /**
+     * Rotation angle in degrees
+     * <p>
+     * Positive angles are clockwise (i.e., towards the positive y axis);
+     * negative angles are counter-clockwise (i.e., towards the negative y axis).
+     * </p>
+     *
+     * @return rotation angle in degrees
+     */
+    public double getRotation(){
+        return (double)_spPr.getXfrm().getRot()/60000;
+    }
+
+    public void draw(Graphics2D graphics){
+
+    	// the coordinate system of this group of shape
+        Rectangle2D interior = getInteriorAnchor();
+        // anchor of this group relative to the parent shape
+        Rectangle2D exterior = getAnchor();
+
+        graphics.translate(exterior.getX(), exterior.getY());
+        double scaleX = exterior.getWidth() / interior.getWidth();
+        double scaleY = exterior.getHeight() / interior.getHeight();
+        graphics.scale(scaleX, scaleY);
+        graphics.translate(-interior.getX(), -interior.getY());
+
+        for (XSLFShape shape : getShapes()) {
+        	// remember the initial transform and restore it after we are done with the drawing
+        	AffineTransform at0 = graphics.getTransform();
+            graphics.setRenderingHint(XSLFRenderingHint.GSAVE, true);
+
+            // apply rotation and flipping
+        	shape.applyTransform(graphics);
+
+        	shape.draw(graphics);
+
+            // restore the coordinate system
+            graphics.setTransform(at0);
+            graphics.setRenderingHint(XSLFRenderingHint.GRESTORE, true);
+        }
+    }
+
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java Fri Oct 21 13:17:33 2011
@@ -22,16 +22,24 @@ package org.apache.poi.xslf.usermodel;
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.POILogger;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
 
 import javax.imageio.ImageIO;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Rectangle;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
@@ -104,4 +112,43 @@ public class XSLFPictureShape extends XS
         }
         return _data;
     }
+
+    @Override
+    public void draw(Graphics2D graphics){
+        java.awt.Shape outline = getOutline();
+
+        //fill
+        Color fillColor = getFillColor();
+        if (fillColor != null) {
+            graphics.setColor(fillColor);
+            applyFill(graphics);
+            graphics.fill(outline);
+        }
+        
+        // text
+    	
+    	XSLFPictureData data = getPictureData();
+    	if(data == null) return;
+    	
+        BufferedImage img;
+        try {
+               img = ImageIO.read(new ByteArrayInputStream(data.getData()));
+        }
+        catch (Exception e){
+            return;
+        }
+        Rectangle2D anchor = getAnchor();
+        graphics.drawImage(img, (int)anchor.getX(), (int)anchor.getY(), 
+        		(int)anchor.getWidth(), (int)anchor.getHeight(), null);
+
+
+        //border overlays the image
+        Color lineColor = getLineColor();
+        if (lineColor != null){
+            graphics.setColor(lineColor);
+            applyStroke(graphics);
+            graphics.draw(outline);
+        }
+    }
+
 }
\ No newline at end of file

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPresetGeometry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPresetGeometry.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPresetGeometry.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPresetGeometry.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,637 @@
+/*
+ *  ====================================================================
+ *    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 java.awt.*;
+import java.awt.geom.*;
+
+/**
+ * TODO: re-write and initialize from presetShapeDefinitions.xml
+ *
+ * @author Yegor Kozlov
+ */
+public class XSLFPresetGeometry {
+    public static final int LINE = 1;
+    public static final int LINE_INV = 2;
+    public static final int TRIANGLE = 3;
+    public static final int RT_TRIANGLE = 4;
+    public static final int RECT = 5;
+    public static final int DIAMOND = 6;
+    public static final int PARALLELOGRAM = 7;
+    public static final int TRAPEZOID = 8;
+    public static final int NON_ISOSCELES_TRAPEZOID = 9;
+    public static final int PENTAGON = 10;
+    public static final int HEXAGON = 11;
+    public static final int HEPTAGON = 12;
+    public static final int OCTAGON = 13;
+    public static final int DECAGON = 14;
+    public static final int DODECAGON = 15;
+    public static final int STAR_4 = 16;
+    public static final int STAR_5 = 17;
+    public static final int STAR_6 = 18;
+    public static final int STAR_7 = 19;
+    public static final int STAR_8 = 20;
+    public static final int STAR_10 = 21;
+    public static final int STAR_12 = 22;
+    public static final int STAR_16 = 23;
+    public static final int STAR_24 = 24;
+    public static final int STAR_32 = 25;
+    public static final int ROUND_RECT = 26;
+    public static final int ROUND_1_RECT = 27;
+    public static final int ROUND_2_SAME_RECT = 28;
+    public static final int ROUND_2_DIAG_RECT = 29;
+    public static final int SNIP_ROUND_RECT = 30;
+    public static final int SNIP_1_RECT = 31;
+    public static final int SNIP_2_SAME_RECT = 32;
+    public static final int SNIP_2_DIAG_RECT = 33;
+    public static final int PLAQUE = 34;
+    public static final int ELLIPSE = 35;
+    public static final int TEARDROP = 36;
+    public static final int HOME_PLATE = 37;
+    public static final int CHEVRON = 38;
+    public static final int PIE_WEDGE = 39;
+    public static final int PIE = 40;
+    public static final int BLOCK_ARC = 41;
+    public static final int DONUT = 42;
+    public static final int NO_SMOKING = 43;
+    public static final int RIGHT_ARROW = 44;
+    public static final int LEFT_ARROW = 45;
+    public static final int UP_ARROW = 46;
+    public static final int DOWN_ARROW = 47;
+    public static final int STRIPED_RIGHT_ARROW = 48;
+    public static final int NOTCHED_RIGHT_ARROW = 49;
+    public static final int BENT_UP_ARROW = 50;
+    public static final int LEFT_RIGHT_ARROW = 51;
+    public static final int UP_DOWN_ARROW = 52;
+    public static final int LEFT_UP_ARROW = 53;
+    public static final int LEFT_RIGHT_UP_ARROW = 54;
+    public static final int QUAD_ARROW = 55;
+    public static final int LEFT_ARROW_CALLOUT = 56;
+    public static final int RIGHT_ARROW_CALLOUT = 57;
+    public static final int UP_ARROW_CALLOUT = 58;
+    public static final int DOWN_ARROW_CALLOUT = 59;
+    public static final int LEFT_RIGHT_ARROW_CALLOUT = 60;
+    public static final int UP_DOWN_ARROW_CALLOUT = 61;
+    public static final int QUAD_ARROW_CALLOUT = 62;
+    public static final int BENT_ARROW = 63;
+    public static final int UTURN_ARROW = 64;
+    public static final int CIRCULAR_ARROW = 65;
+    public static final int LEFT_CIRCULAR_ARROW = 66;
+    public static final int LEFT_RIGHT_CIRCULAR_ARROW = 67;
+    public static final int CURVED_RIGHT_ARROW = 68;
+    public static final int CURVED_LEFT_ARROW = 69;
+    public static final int CURVED_UP_ARROW = 70;
+    public static final int CURVED_DOWN_ARROW = 71;
+    public static final int SWOOSH_ARROW = 72;
+    public static final int CUBE = 73;
+    public static final int CAN = 74;
+    public static final int LIGHTNING_BOLT = 75;
+    public static final int HEART = 76;
+    public static final int SUN = 77;
+    public static final int MOON = 78;
+    public static final int SMILEY_FACE = 79;
+    public static final int IRREGULAR_SEAL_1 = 80;
+    public static final int IRREGULAR_SEAL_2 = 81;
+    public static final int FOLDED_CORNER = 82;
+    public static final int BEVEL = 83;
+    public static final int FRAME = 84;
+    public static final int HALF_FRAME = 85;
+    public static final int CORNER = 86;
+    public static final int DIAG_STRIPE = 87;
+    public static final int CHORD = 88;
+    public static final int ARC = 89;
+    public static final int LEFT_BRACKET = 90;
+    public static final int RIGHT_BRACKET = 91;
+    public static final int LEFT_BRACE = 92;
+    public static final int RIGHT_BRACE = 93;
+    public static final int BRACKET_PAIR = 94;
+    public static final int BRACE_PAIR = 95;
+    public static final int STRAIGHT_CONNECTOR_1 = 96;
+    public static final int BENT_CONNECTOR_2 = 97;
+    public static final int BENT_CONNECTOR_3 = 98;
+    public static final int BENT_CONNECTOR_4 = 99;
+    public static final int BENT_CONNECTOR_5 = 100;
+    public static final int CURVED_CONNECTOR_2 = 101;
+    public static final int CURVED_CONNECTOR_3 = 102;
+    public static final int CURVED_CONNECTOR_4 = 103;
+    public static final int CURVED_CONNECTOR_5 = 104;
+    public static final int CALLOUT_1 = 105;
+    public static final int CALLOUT_2 = 106;
+    public static final int CALLOUT_3 = 107;
+    public static final int ACCENT_CALLOUT_1 = 108;
+    public static final int ACCENT_CALLOUT_2 = 109;
+    public static final int ACCENT_CALLOUT_3 = 110;
+    public static final int BORDER_CALLOUT_1 = 111;
+    public static final int BORDER_CALLOUT_2 = 112;
+    public static final int BORDER_CALLOUT_3 = 113;
+    public static final int ACCENT_BORDER_CALLOUT_1 = 114;
+    public static final int ACCENT_BORDER_CALLOUT_2 = 115;
+    public static final int ACCENT_BORDER_CALLOUT_3 = 116;
+    public static final int WEDGE_RECT_CALLOUT = 117;
+    public static final int WEDGE_ROUND_RECT_CALLOUT = 118;
+    public static final int WEDGE_ELLIPSE_CALLOUT = 119;
+    public static final int CLOUD_CALLOUT = 120;
+    public static final int CLOUD = 121;
+    public static final int RIBBON = 122;
+    public static final int RIBBON_2 = 123;
+    public static final int ELLIPSE_RIBBON = 124;
+    public static final int ELLIPSE_RIBBON_2 = 125;
+    public static final int LEFT_RIGHT_RIBBON = 126;
+    public static final int VERTICAL_SCROLL = 127;
+    public static final int HORIZONTAL_SCROLL = 128;
+    public static final int WAVE = 129;
+    public static final int DOUBLE_WAVE = 130;
+    public static final int PLUS = 131;
+    public static final int FLOW_CHART_PROCESS = 132;
+    public static final int FLOW_CHART_DECISION = 133;
+    public static final int FLOW_CHART_INPUT_OUTPUT = 134;
+    public static final int FLOW_CHART_PREDEFINED_PROCESS = 135;
+    public static final int FLOW_CHART_INTERNAL_STORAGE = 136;
+    public static final int FLOW_CHART_DOCUMENT = 137;
+    public static final int FLOW_CHART_MULTIDOCUMENT = 138;
+    public static final int FLOW_CHART_TERMINATOR = 139;
+    public static final int FLOW_CHART_PREPARATION = 140;
+    public static final int FLOW_CHART_MANUAL_INPUT = 141;
+    public static final int FLOW_CHART_MANUAL_OPERATION = 142;
+    public static final int FLOW_CHART_CONNECTOR = 143;
+    public static final int FLOW_CHART_PUNCHED_CARD = 144;
+    public static final int FLOW_CHART_PUNCHED_TAPE = 145;
+    public static final int FLOW_CHART_SUMMING_JUNCTION = 146;
+    public static final int FLOW_CHART_OR = 147;
+    public static final int FLOW_CHART_COLLATE = 148;
+    public static final int FLOW_CHART_SORT = 149;
+    public static final int FLOW_CHART_EXTRACT = 150;
+    public static final int FLOW_CHART_MERGE = 151;
+    public static final int FLOW_CHART_OFFLINE_STORAGE = 152;
+    public static final int FLOW_CHART_ONLINE_STORAGE = 153;
+    public static final int FLOW_CHART_MAGNETIC_TAPE = 154;
+    public static final int FLOW_CHART_MAGNETIC_DISK = 155;
+    public static final int FLOW_CHART_MAGNETIC_DRUM = 156;
+    public static final int FLOW_CHART_DISPLAY = 157;
+    public static final int FLOW_CHART_DELAY = 158;
+    public static final int FLOW_CHART_ALTERNATE_PROCESS = 159;
+    public static final int FLOW_CHART_OFFPAGE_CONNECTOR = 160;
+    public static final int ACTION_BUTTON_BLANK = 161;
+    public static final int ACTION_BUTTON_HOME = 162;
+    public static final int ACTION_BUTTON_HELP = 163;
+    public static final int ACTION_BUTTON_INFORMATION = 164;
+    public static final int ACTION_BUTTON_FORWARD_NEXT = 165;
+    public static final int ACTION_BUTTON_BACK_PREVIOUS = 166;
+    public static final int ACTION_BUTTON_END = 167;
+    public static final int ACTION_BUTTON_BEGINNING = 168;
+    public static final int ACTION_BUTTON_RETURN = 169;
+    public static final int ACTION_BUTTON_DOCUMENT = 170;
+    public static final int ACTION_BUTTON_SOUND = 171;
+    public static final int ACTION_BUTTON_MOVIE = 172;
+    public static final int GEAR_6 = 173;
+    public static final int GEAR_9 = 174;
+    public static final int FUNNEL = 175;
+    public static final int MATH_PLUS = 176;
+    public static final int MATH_MINUS = 177;
+    public static final int MATH_MULTIPLY = 178;
+    public static final int MATH_DIVIDE = 179;
+    public static final int MATH_EQUAL = 180;
+    public static final int MATH_NOT_EQUAL = 181;
+    public static final int CORNER_TABS = 182;
+    public static final int SQUARE_TABS = 183;
+    public static final int PLAQUE_TABS = 184;
+    public static final int CHART_X = 185;
+    public static final int CHART_STAR = 186;
+    public static final int CHART_PLUS = 187;
+
+    private static interface ShapeOutline {
+        java.awt.Shape getOutline(XSLFAutoShape shape);
+    }
+    
+    
+    static ShapeOutline[] shapes;
+    static {
+        shapes = new ShapeOutline[255];
+
+        shapes[RECT] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                Rectangle2D path = new Rectangle2D.Float(0, 0, 21600, 21600);
+                return path;
+            }
+        };
+
+        shapes[ROUND_RECT] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+                RoundRectangle2D path = new RoundRectangle2D.Float(0, 0, 21600, 21600, adjval, adjval);
+                return path;
+            }
+        };
+
+        shapes[ELLIPSE] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                Ellipse2D path = new Ellipse2D.Float(0, 0, 21600, 21600);
+                return path;
+            }
+        };
+
+        shapes[DIAMOND] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                GeneralPath path = new GeneralPath();
+                path.moveTo(10800, 0);
+                path.lineTo(21600, 10800);
+                path.lineTo(10800, 21600);
+                path.lineTo(0, 10800);
+                path.closePath();
+                return path;
+           }
+        };
+
+        //m@0,l,21600r21600
+        shapes[TRIANGLE] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(0, 21600);
+                path.lineTo(21600, 21600);
+                path.closePath();
+                return path;
+           }
+        };
+
+        shapes[RT_TRIANGLE] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+                path.lineTo(21600, 21600);
+                path.lineTo(0, 21600);
+                path.closePath();
+                return path;
+           }
+        };
+
+        shapes[PARALLELOGRAM] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600, 0);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(0, 21600);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[TRAPEZOID] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+                path.lineTo(adjval, 21600);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(21600, 0);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[HEXAGON] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600, 10800);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[OCTAGON] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 6324);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600, adjval);
+                path.lineTo(21600, 21600-adjval);
+                path.lineTo(21600-adjval, 21600);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 21600-adjval);
+                path.lineTo(0, adjval);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[PLUS] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600 - adjval, adjval);
+                path.lineTo(21600, adjval);
+                path.lineTo(21600, 21600-adjval);
+                path.lineTo(21600-adjval, 21600-adjval);
+                path.lineTo(21600-adjval, 21600);
+                path.lineTo(adjval, 21600);
+                path.lineTo(adjval, 21600-adjval);
+                path.lineTo(0, 21600-adjval);
+                path.lineTo(0, adjval);
+                path.lineTo(adjval, adjval);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[PENTAGON] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(10800, 0);
+                path.lineTo(21600, 8259);
+                path.lineTo(21600 - 4200, 21600);
+                path.lineTo(4200, 21600);
+                path.lineTo(0, 8259);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[HOME_PLATE] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+
+                GeneralPath path = new GeneralPath();
+                int adjval = shape.getAdjustValue("adj1", 16200);
+                path.moveTo(0, 0);
+                path.lineTo(adjval, 0 );
+                path.lineTo(21600, 10800);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 21600);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[CHEVRON] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                GeneralPath path = new GeneralPath();
+                int adjval = shape.getAdjustValue("adj1", 16200);
+                path.moveTo(0, 0);
+                path.lineTo(adjval, 0 );
+                path.lineTo(21600, 10800);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 21600);
+                path.lineTo(21600 - adjval, 10800);
+                path.closePath();
+                return path;
+           }
+        };
+
+        shapes[CAN] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                int adjval = shape.getAdjustValue("adj1", 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+                path.lineTo(21600, 0);
+                path.lineTo(21600, 21600);
+                path.lineTo(0, 21600);
+
+                //path.lineTo(21600, adjval);
+
+                path.closePath();
+                path.moveTo(10800, 0);
+                //path.append(new Arc2D.Float(10800, 0, 10800, adjval, 0, 90, Arc2D.OPEN), true);
+                path.moveTo(10800, adjval/2);
+                path.append(new Arc2D.Float(10800, adjval/2, 10800, adjval, 90, 180, Arc2D.OPEN), true);
+                //path.append(new Arc2D.Float(0, adjval/2, 10800, adjval, 180, 270, Arc2D.OPEN), true);
+                //path.append(new Arc2D.Float(0, 0, 10800, adjval, 270, 360, Arc2D.OPEN), true);
+                return path;
+            }
+        };
+
+        shapes[DOWN_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m0@0 l@1@0 @1,0 @2,0 @2@0,21600@0,10800,21600xe
+                int adjval = shape.getAdjustValue("adj1", 16200);
+                int adjval2 = shape.getAdjustValue("adj2", 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, adjval);
+                path.lineTo(adjval2, adjval);
+                path.lineTo(adjval2, 0);
+                path.lineTo(21600-adjval2, 0);
+                path.lineTo(21600-adjval2, adjval);
+                path.lineTo(21600, adjval);
+                path.lineTo(10800, 21600);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[UP_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m0@0 l@1@0 @1,21600@2,21600@2@0,21600@0,10800,xe
+                int adjval = shape.getAdjustValue("adj1", 5400);
+                int adjval2 = shape.getAdjustValue("adj2", 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, adjval);
+                path.lineTo(adjval2, adjval);
+                path.lineTo(adjval2, 21600);
+                path.lineTo(21600-adjval2, 21600);
+                path.lineTo(21600-adjval2, adjval);
+                path.lineTo(21600, adjval);
+                path.lineTo(10800, 0);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[RIGHT_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m@0, l@0@1 ,0@1,0@2@0@2@0,21600,21600,10800xe
+                int adjval = shape.getAdjustValue("adj1", 16200);
+                int adjval2 = shape.getAdjustValue("adj2", 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(adjval, adjval2);
+                path.lineTo(0, adjval2);
+                path.lineTo(0, 21600-adjval2);
+                path.lineTo(adjval, 21600-adjval2);
+                path.lineTo(adjval, 21600);
+                path.lineTo(21600, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[LEFT_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m@0, l@0@1,21600@1,21600@2@0@2@0,21600,,10800xe
+                int adjval = shape.getAdjustValue("adj1", 5400);
+                int adjval2 = shape.getAdjustValue("adj2", 5400);
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval, 0);
+                path.lineTo(adjval, adjval2);
+                path.lineTo(21600, adjval2);
+                path.lineTo(21600, 21600-adjval2);
+                path.lineTo(adjval, 21600-adjval2);
+                path.lineTo(adjval, 21600);
+                path.lineTo(0, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+        shapes[LEFT_BRACE] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m21600,qx10800@0l10800@2qy0@11,10800@3l10800@1qy21600,21600e
+                int adjval = shape.getAdjustValue("adj1", 1800);
+                int adjval2 = shape.getAdjustValue("adj2", 10800);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(21600, 0);
+
+                path.append(new Arc2D.Float(10800, 0, 21600, adjval*2, 90, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval);
+
+                path.lineTo(10800, adjval2 - adjval);
+
+                path.append(new Arc2D.Float(-10800, adjval2 - 2*adjval, 21600, adjval*2, 270, 90, Arc2D.OPEN), false);
+                path.moveTo(0, adjval2);
+
+                path.append(new Arc2D.Float(-10800, adjval2, 21600, adjval*2, 0, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval2 + adjval);
+
+                path.lineTo(10800, 21600 - adjval);
+
+                path.append(new Arc2D.Float(10800, 21600 - 2*adjval, 21600, adjval*2, 180, 90, Arc2D.OPEN), false);
+
+                return path;
+            }
+        };
+
+        shapes[RIGHT_BRACE] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m,qx10800@0 l10800@2qy21600@11,10800@3l10800@1qy,21600e
+                int adjval = shape.getAdjustValue("adj1", 1800);
+                int adjval2 = shape.getAdjustValue("adj2", 10800);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 0);
+
+                path.append(new Arc2D.Float(-10800, 0, 21600, adjval*2, 0, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval);
+
+                path.lineTo(10800, adjval2 - adjval);
+
+                path.append(new Arc2D.Float(10800, adjval2 - 2*adjval, 21600, adjval*2, 180, 90, Arc2D.OPEN), false);
+                path.moveTo(21600, adjval2);
+
+                path.append(new Arc2D.Float(10800, adjval2, 21600, adjval*2, 90, 90, Arc2D.OPEN), false);
+                path.moveTo(10800, adjval2 + adjval);
+
+                path.lineTo(10800, 21600 - adjval);
+
+                path.append(new Arc2D.Float(-10800, 21600 - 2*adjval, 21600, adjval*2, 270, 90, Arc2D.OPEN), false);
+
+                return path;
+            }
+        };
+
+
+        shapes[LEFT_RIGHT_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m,10800l@0,21600@0@3@2@3@2,21600,21600,10800@2,0@2@1@0@1@0,xe
+                int adjval = shape.getAdjustValue("adj1", 4320);
+                int adjval2 = shape.getAdjustValue("adj2", 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(0, 10800);
+                path.lineTo(adjval, 0);
+                path.lineTo(adjval, adjval2);
+                path.lineTo(21600 - adjval, adjval2);
+                path.lineTo(21600 - adjval, 0);
+                path.lineTo(21600, 10800);
+                path.lineTo(21600 - adjval, 21600);
+                path.lineTo(21600 - adjval, 21600 - adjval2);
+                path.lineTo(adjval, 21600 - adjval2);
+                path.lineTo(adjval, 21600);
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[UP_DOWN_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m10800,l21600@0@3@0@3@2,21600@2,10800,21600,0@2@1@2@1@0,0@0xe
+                int adjval1 = shape.getAdjustValue("adj1", 5400);
+                int adjval2 = shape.getAdjustValue("adj2", 4320);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(10800, 0);
+                path.lineTo(21600, adjval2);
+                path.lineTo(21600 - adjval1, adjval2);
+                path.lineTo(21600 - adjval1, 21600 - adjval2);
+                path.lineTo(21600, 21600 - adjval2);
+
+                path.lineTo(10800, 21600);
+                path.lineTo(0, 21600 - adjval2);
+                path.lineTo(adjval1, 21600 - adjval2);
+                path.lineTo(adjval1, adjval2);
+                path.lineTo(0, adjval2);
+
+                path.closePath();
+                return path;
+            }
+        };
+
+        shapes[NOTCHED_RIGHT_ARROW] = new ShapeOutline(){
+            public java.awt.Shape getOutline(XSLFAutoShape shape){
+                //m@0,l@0@1,0@1@5,10800,0@2@0@2@0,21600,21600,10800xe
+                int adjval1 = shape.getAdjustValue("adj1", 16200);
+                int adjval2 = shape.getAdjustValue("adj2", 5400);
+
+                GeneralPath path = new GeneralPath();
+                path.moveTo(adjval1, 0);
+                path.lineTo(adjval1, adjval2);
+                path.lineTo(0, adjval2);
+                //The notch at the end stays adjusted so that it matches the shape of the arrowhead.
+                int notch = (21600-2*adjval2)*(21600-adjval1)/21600;
+                path.lineTo(notch, 10800);
+                path.lineTo(0, 21600 - adjval2);
+                path.lineTo(adjval1, 21600 - adjval2);
+                path.lineTo(adjval1, 21600);
+                path.lineTo(21600, 10800);
+                path.closePath();
+                return path;
+            }
+        };
+    }
+    
+    static Shape getOutline(XSLFAutoShape shape){
+        ShapeOutline outline = shapes[shape.getShapeType()];
+        return outline == null ? null : outline.getOutline(shape);
+    }
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRenderingHint.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRenderingHint.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRenderingHint.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRenderingHint.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,42 @@
+/*
+ *  ====================================================================
+ *    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 java.awt.*;
+
+/**
+ *
+ * @author Yegor Kozlov
+ */
+public class XSLFRenderingHint extends RenderingHints.Key {
+
+    public XSLFRenderingHint(int i){
+        super(i);
+    }
+
+    @Override
+    public boolean isCompatibleValue(Object val) {
+        return true;
+    }
+
+    public static final XSLFRenderingHint GSAVE = new XSLFRenderingHint(1);
+    public static final XSLFRenderingHint GRESTORE = new XSLFRenderingHint(2);
+    public static final XSLFRenderingHint SKIP_PLACEHOLDERS = new XSLFRenderingHint(3);
+}
\ No newline at end of file

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java?rev=1187328&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java Fri Oct 21 13:17:33 2011
@@ -0,0 +1,106 @@
+/* ====================================================================
+   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.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.util.Units;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+
+/**
+ * Represents a shadow of a shape. For now supports only outer shadows.
+ *
+ * @author Yegor Kozlov
+ */
+public class XSLFShadow extends XSLFSimpleShape {
+    private XSLFSimpleShape _parent;
+
+    /* package */XSLFShadow(CTOuterShadowEffect shape, XSLFSimpleShape parentShape) {
+        super(shape, parentShape.getSheet());
+
+        _parent = parentShape;
+    }
+
+    public void draw(Graphics2D graphics) {
+        Shape outline = _parent.getOutline();
+
+        double angle = getAngle();
+        double dist = getDistance();
+        double dx = dist * Math.cos( Math.toRadians(angle));
+        double dy = dist * Math.sin( Math.toRadians(angle));
+
+        graphics.translate(dx, dy);
+
+        //fill
+        Color fillColor = getFillColor();
+        if (fillColor != null) {
+            graphics.setColor(fillColor);
+            graphics.fill(outline);
+        }
+
+        graphics.translate(-dx, -dy);
+    }
+
+    @Override
+    public Rectangle2D getAnchor(){
+        return _parent.getAnchor();
+    }
+
+    @Override
+    public void setAnchor(Rectangle2D anchor){
+        throw new IllegalStateException("You can't set anchor of a shadow");
+    }
+
+    public double getDistance(){
+        CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
+        return ct.isSetDist() ? Units.toPoints(ct.getDist()) : 0;        
+    }
+
+    public double getAngle(){
+        CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
+        return ct.isSetDir() ? (double)ct.getDir() / 60000 : 0;
+    }
+
+    public double getBlur(){
+        CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
+        return ct.isSetBlurRad() ? Units.toPoints(ct.getBlurRad()) : 0;
+    }
+
+    @Override
+    public Color getFillColor() {
+        XSLFTheme theme = getSheet().getTheme();
+        CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
+        if(ct.isSetSchemeClr()) {
+            return theme.getSchemeColor(ct.getSchemeClr());
+        }
+        else if (ct.isSetPrstClr()) {
+            return theme.getPresetColor(ct.getPrstClr());
+        }
+
+        return Color.black;
+    }
+}
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java Fri Oct 21 13:17:33 2011
@@ -19,10 +19,11 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.poi.sl.usermodel.Shape;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
 
+import java.awt.Graphics2D;
 import java.awt.geom.Rectangle2D;
 
 /**
@@ -41,4 +42,76 @@ public abstract class XSLFShape {
     public abstract String getShapeName();
 
     public abstract int getShapeId();
+
+    /**
+     * Rotate this shape.
+     * <p>
+     * Positive angles are clockwise (i.e., towards the positive y axis);
+     * negative angles are counter-clockwise (i.e., towards the negative y axis).
+     * </p>
+     *
+     * @param theta the rotation angle in degrees.
+     */
+    public abstract void setRotation(double theta);
+   
+    /**
+     * Rotation angle in degrees
+     * <p>
+     * Positive angles are clockwise (i.e., towards the positive y axis);
+     * negative angles are counter-clockwise (i.e., towards the negative y axis).
+     * </p>
+     *
+     * @return rotation angle in degrees
+     */
+    public abstract double getRotation();
+
+    public abstract void setFlipHorizontal(boolean flip);
+
+    public abstract void setFlipVertical(boolean flip);
+    
+    /**
+     * Whether the shape is horizontally flipped
+     *
+     * @return whether the shape is horizontally flipped
+     */
+    public abstract boolean getFlipHorizontal();
+
+    public abstract boolean getFlipVertical();
+
+    public abstract void draw(Graphics2D graphics);
+
+    protected java.awt.Shape getOutline(){
+        return getAnchor();
+    }
+    
+    protected void applyTransform(Graphics2D graphics){
+        Rectangle2D anchor = getAnchor();
+
+        // rotation
+        double rotation = getRotation();
+        if(rotation != 0.) {
+        	// PowerPoint rotates shapes relative to the geometric center
+            double centerX = anchor.getX() + anchor.getWidth()/2;
+            double centerY = anchor.getY() + anchor.getHeight()/2;
+
+            graphics.translate(centerX, centerY);
+            graphics.rotate(Math.toRadians(rotation));
+            graphics.translate(-centerX, -centerY);
+        }
+
+        //flip horizontal
+        if(getFlipHorizontal()){
+            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
+            graphics.scale(-1, 1);
+            graphics.translate(-anchor.getX() , -anchor.getY());
+        }
+
+        //flip vertical
+        if(getFlipVertical()){
+            graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
+            graphics.scale(1, -1);
+            graphics.translate(-anchor.getX(), -anchor.getY());
+        }
+    }
+    
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1187328&r1=1187327&r2=1187328&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Fri Oct 21 13:17:33 2011
@@ -21,6 +21,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
@@ -30,9 +31,13 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextListStyle;
 
 import javax.xml.namespace.QName;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -47,6 +52,8 @@ public abstract class XSLFSheet extends 
     private XSLFDrawing _drawing;
     private List<XSLFShape> _shapes;
     private CTGroupShape _spTree;
+    private Map<Integer, XSLFSimpleShape> _placeholderByIdMap;
+    private Map<Integer, XSLFSimpleShape> _placeholderByTypeMap;
 
     public XSLFSheet() {
         super();
@@ -187,6 +194,10 @@ public abstract class XSLFSheet extends 
         return getShapeList().remove(xShape);
     }
 
+    public XSLFBackground getBackground(){
+        return null;
+    }
+
     protected abstract String getRootElementName();
 
     protected CTGroupShape getSpTree(){
@@ -232,4 +243,112 @@ public abstract class XSLFSheet extends 
         getXmlObject().set(src.getXmlObject());
     }
 
+    public XSLFTheme getTheme(){
+    	return null;
+    }
+
+    public XSLFSlideMaster getSlideMaster(){
+    	return null;
+    }
+
+    public XSLFSlideLayout getSlideLayout(){
+    	return null;
+    }
+
+    protected CTTextListStyle getTextProperties(Placeholder textType) {
+        return null;
+    }
+    
+    protected XSLFTextShape getTextShapeByType(Placeholder type){
+        for(XSLFShape shape : this.getShapes()){
+            if(shape instanceof XSLFTextShape) {
+               XSLFTextShape txt = (XSLFTextShape)shape;
+                if(txt.getTextType() == type) {
+                    return txt;
+                }
+            }
+        }
+        return null;
+    }
+
+    XSLFSimpleShape getPlaceholder(CTPlaceholder ph) {
+        XSLFSimpleShape shape = null;
+        if(ph.isSetIdx()) shape = getPlaceholderById((int)ph.getIdx());
+
+        if (shape == null && ph.isSetType()) {
+            shape = getPlaceholderByType(ph.getType().intValue());
+        }
+        return shape;
+    }
+
+    XSLFSimpleShape getPlaceholderById(int id) {
+        if(_placeholderByIdMap == null) {
+            _placeholderByIdMap = new HashMap<Integer, XSLFSimpleShape>();
+            for(XSLFShape sh : getShapes()){
+                if(sh instanceof XSLFSimpleShape){
+                    XSLFSimpleShape sShape = (XSLFSimpleShape)sh;
+                    CTPlaceholder ph = sShape.getCTPlaceholder();
+                    if(ph != null && ph.isSetIdx()){
+                        int idx = (int)ph.getIdx();
+                        _placeholderByIdMap.put(idx, sShape);
+                    }
+                }
+            }
+        }
+        return _placeholderByIdMap.get(id);
+    }
+
+    XSLFSimpleShape getPlaceholderByType(int ordinal) {
+        if(_placeholderByTypeMap == null) {
+            _placeholderByTypeMap = new HashMap<Integer, XSLFSimpleShape>();
+            for(XSLFShape sh : getShapes()){
+                if(sh instanceof XSLFSimpleShape){
+                    XSLFSimpleShape sShape = (XSLFSimpleShape)sh;
+                    CTPlaceholder ph = sShape.getCTPlaceholder();
+                    if(ph != null && ph.isSetType()){
+                        _placeholderByTypeMap.put(ph.getType().intValue(), sShape);
+                    }
+                }
+            }
+        }
+        return _placeholderByTypeMap.get(ordinal);
+    }
+
+    /**
+     * Checks if this <code>sheet</code> displays the specified shape.
+     *
+     * Subclasses can override it and skip certain shapes from drawings.
+     */
+    protected boolean canDraw(XSLFShape shape){
+        return true;
+    }
+
+    /**
+     * Render this sheet into the supplied graphics object
+     *
+     * @param graphics
+     */
+    public void draw(Graphics2D graphics){
+        XSLFBackground bg = getBackground();
+        if(bg != null) bg.draw(graphics);
+
+        for(XSLFShape shape : getShapeList()) {
+            if(!canDraw(shape)) continue;
+
+        	// remember the initial transform and restore it after we are done with drawing
+        	AffineTransform at0 = graphics.getTransform();
+
+            graphics.setRenderingHint(XSLFRenderingHint.GSAVE, true);
+
+            // apply rotation and flipping
+            shape.applyTransform(graphics);
+
+            shape.draw(graphics);
+
+            // restore the coordinate system
+            graphics.setTransform(at0);
+            graphics.setRenderingHint(XSLFRenderingHint.GRESTORE, true);
+
+        }
+    }
 }
\ No newline at end of file



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


Mime
View raw message