poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1190347 [1/2] - in /poi/trunk: src/ooxml/java/org/apache/poi/xslf/usermodel/ src/ooxml/testcases/org/apache/poi/xslf/usermodel/ src/ooxml/testcases/org/apache/poi/xwpf/usermodel/ test-data/slideshow/
Date Fri, 28 Oct 2011 14:25:54 GMT
Author: yegor
Date: Fri Oct 28 14:25:53 2011
New Revision: 1190347

URL: http://svn.apache.org/viewvc?rev=1190347&view=rev
Log:
more progress with PPTX2PNG: support for gradient and texture fill, also refactored usages of colors in drawingML

Added:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/RenderableShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFColor.java
      - copied, changed from r1189653, poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShape.java
    poi/trunk/test-data/slideshow/backgrounds.pptx   (with props)
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTextBody.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/Placeholder.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.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/XSLFCommentAuthors.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFConnectorShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFDrawing.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/XSLFImageRendener.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.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/XSLFTableCell.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.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/TestXSLFSimpleShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFPictureData.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTextBody.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTextBody.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTextBody.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/DrawingTextBody.java Fri Oct 28 14:25:53 2011
@@ -17,11 +17,11 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import java.util.List;
-
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
 
+import java.util.List;
+
 public class DrawingTextBody {
     private final CTTextBody textBody;
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/Placeholder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/Placeholder.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/Placeholder.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/Placeholder.java Fri Oct 28 14:25:53 2011
@@ -32,5 +32,11 @@ public enum Placeholder {
     HEADER,
     OBJECT,
     CHART,
-    TABLE
+    TABLE,
+    CLIP_ART,
+    DGM,
+    MEDIA,
+    SLIDE_IMAGE,
+    PICTURE
+
 }

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/RenderableShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/RenderableShape.java?rev=1190347&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/RenderableShape.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/RenderableShape.java Fri Oct 28 14:25:53 2011
@@ -0,0 +1,11 @@
+package org.apache.poi.xslf.usermodel;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: yegor
+ * Date: Oct 27, 2011
+ * Time: 4:50:08 PM
+ * To change this template use File | Settings | File Templates.
+ */
+class RenderableShape {
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java Fri Oct 28 14:25:53 2011
@@ -16,17 +16,6 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import java.awt.Dimension;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
 import org.apache.poi.POIXMLDocument;
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
@@ -51,6 +40,17 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideSize;
 import org.openxmlformats.schemas.presentationml.x2006.main.PresentationDocument;
 
+import java.awt.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
 /**
  * High level representation of a ooxml slideshow.
  * This is the first object most users will construct whether

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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -20,38 +20,15 @@
 package org.apache.poi.xslf.usermodel;
 
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.Units;
-import org.apache.poi.xslf.model.geom.Context;
-import org.apache.poi.xslf.model.geom.CustomGeometry;
-import org.apache.poi.xslf.model.geom.Path;
-import org.apache.poi.xslf.model.geom.PresetGeometries;
-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;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
 import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextWrappingType;
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextVerticalType;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
-import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
 
-import java.awt.*;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-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. 

Modified: 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=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFBackground.java Fri Oct 28 14:25:53 2011
@@ -17,14 +17,17 @@
 
 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 org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTBackgroundFillStyleList;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlCursor;
 
-import javax.imageio.ImageIO;
+import javax.xml.namespace.QName;
 import java.awt.*;
-import java.awt.image.BufferedImage;
+import java.awt.geom.Rectangle2D;
 
 /**
  * Background shape
@@ -37,34 +40,40 @@ public class XSLFBackground extends XSLF
         super(shape, sheet);
     }
 
-    public void draw(Graphics2D graphics) {
+    @Override
+    public Rectangle2D getAnchor(){
         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);
+        return new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());
+    }
+
+    public void draw(Graphics2D graphics) {
+        Rectangle2D anchor = getAnchor();
+
+        XmlObject spPr = null;
+        CTBackground bg = (CTBackground)getXmlObject();
+        if(bg.isSetBgPr()){
+            spPr = bg.getBgPr();
+        } else if (bg.isSetBgRef()){
+            CTStyleMatrixReference bgRef= bg.getBgRef();
+            int idx = (int)bgRef.getIdx() - 1000;
+            XSLFTheme theme = getSheet().getTheme();
+            CTBackgroundFillStyleList bgStyles =
+                    theme.getXmlObject().getThemeElements().getFmtScheme().getBgFillStyleLst();
+
+            // TODO pass this to getPaint
+            XmlObject bgStyle = bgStyles.selectPath("*")[idx];
         }
-        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;
-                }
-            }
+        if(spPr == null){
+            return;
+        }
+
+        Paint fill = getPaint(graphics, spPr);
+        if(fill != null) {
+            graphics.setPaint(fill);
+            graphics.fill(anchor);
         }
     }
 
+    
 }

Modified: 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=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFColor.java Fri Oct 28 14:25:53 2011
@@ -18,37 +18,544 @@
  */
 package org.apache.poi.xslf.usermodel;
 
-import java.awt.Color;
-
+import org.apache.poi.util.Beta;
 import org.apache.poi.util.Internal;
+import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor;
+import org.w3c.dom.Node;
+
+import java.awt.*;
+import java.util.HashMap;
+import java.util.Map;
 
+/**
+ * Encapsulates logic to read color definitions from DrawingML and convert them to java.awt.Color
+ *
+ * @author Yegor Kozlov
+ */
+@Beta
 public class XSLFColor {
-	private final CTColor _ctColor;
-	
-	XSLFColor(CTColor ctColor){
-		_ctColor = ctColor;
-	}
-	
+    private XmlObject _xmlObject;
+    private Color _color;
+
+    XSLFColor(XmlObject obj, XSLFTheme theme) {
+        _xmlObject = obj;
+        _color = toColor(obj, theme);
+    }
+
     @Internal
-    public CTColor getXmlObject() {
-        return _ctColor;
+    public XmlObject getXmlObject() {
+        return _xmlObject;
+    }
+
+    /**
+     *
+     * @return  the displayed color as a Java Color.
+     * If not color information was found in the supplied xml object then a null is returned.
+     */
+    public Color getColor() {
+        return _color == null ? null : applyColorTransform(_color);
+    }
+
+    private Color applyColorTransform(Color color){
+        Color result = color;
+
+        int alpha = getAlpha();
+        if(alpha != -1){
+            result = new Color(
+                    result.getRed(), result.getGreen(), result.getBlue(), 
+                    Math.round(255 * alpha * 0.01f));
+        }
+
+        int lumOff = getLumOff();
+        int lumMod = getLumMod();
+        if(lumMod != -1 || lumOff != -1){
+            result = modulateLuminanace(result,
+                    lumMod == -1 ? 100 : lumMod,
+                    lumOff == -1 ? 0 : lumOff);
+        }
+
+        int shade = getShade();
+        if(shade != -1){
+        	result = shade(result, shade);
+        }
+
+        int tint = getTint();
+        if(tint != -1){
+            result = tint(result, tint);
+        }
+
+        return result;
+    }
+
+    static Color toColor(XmlObject obj, XSLFTheme theme) {
+        Color color = null;
+        for (XmlObject ch : obj.selectPath("*")) {
+            if (ch instanceof CTHslColor) {
+                CTHslColor hsl = (CTHslColor)ch;
+                int h = hsl.getHue2();
+                int s = hsl.getSat2();
+                int l = hsl.getLum2();
+                // is it correct ? 
+                color = Color.getHSBColor(h / 60000f, s / 100000f, l / 100000f);
+            } else if (ch instanceof CTPresetColor) {
+                CTPresetColor prst = (CTPresetColor)ch;
+                String colorName = prst.getVal().toString();
+                color = presetColors.get(colorName);
+            } else if (ch instanceof CTSchemeColor) {
+                CTSchemeColor schemeColor = (CTSchemeColor)ch;
+                String colorRef = schemeColor.getVal().toString();
+                // find referenced CTColor in the theme and convert it to java.awt.Color via a recursive call
+                CTColor ctColor = theme.getCTColor(colorRef);
+                if(ctColor != null) color = toColor(ctColor, null);
+                else {
+                    color = Color.black;
+                }
+            } else if (ch instanceof CTScRgbColor) {
+                // same as CTSRgbColor but with values expressed in percents
+                CTScRgbColor scrgb = (CTScRgbColor)ch;
+                int r = scrgb.getR();
+                int g = scrgb.getG();
+                int b = scrgb.getB();
+                color = new Color(255 * r / 100000, 255 * g / 100000, 255 * b / 100000);
+            } else if (ch instanceof CTSRgbColor) {
+                CTSRgbColor srgb = (CTSRgbColor)ch;
+                byte[] val = srgb.getVal();
+                color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
+            } else if (ch instanceof CTSystemColor) {
+                CTSystemColor sys = (CTSystemColor)ch;
+                if(sys.isSetLastClr()) {
+                    byte[] val = sys.getLastClr();
+                    color = new Color(0xFF & val[0], 0xFF & val[1], 0xFF & val[2]);
+                } else {
+                    // YK: color is a string like "menuText" or "windowText", we return black for such cases
+                    String colorName = sys.getVal().toString();
+                    color = Color.black;
+                }
+            } else {
+                throw new IllegalArgumentException("Unexpected color choice: " + ch.getClass());
+            }
+        }
+        return color;
+    }
+
+    private int getPercentageValue(String elem){
+        XmlObject[] obj = _xmlObject.selectPath(
+                "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem);
+        if(obj.length == 1){
+            Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
+            if(attr != null) {
+                return Integer.parseInt(attr.getNodeValue()) / 1000;
+            }
+        }
+        return -1;
+    }
+
+    private int getAngleValue(String elem){
+        XmlObject[] obj = _xmlObject.selectPath(
+                "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem);
+        if(obj.length == 1){
+            Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
+            if(attr != null) {
+                return Integer.parseInt(attr.getNodeValue()) / 60000;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * the opacity as expressed by a percentage value
+     *
+     * @return  opacity in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getAlpha(){
+        return getPercentageValue("alpha");        
+    }
+
+    /**
+     * the opacity as expressed by a percentage relative to the input color
+     *
+     * @return  opacity in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getAlphaMod(){
+        return getPercentageValue("alphaMod");
+    }
+
+    /**
+     * the opacity as expressed by a percentage offset increase or decrease relative to
+     * the input color. Increases will never increase the opacity beyond 100%, decreases will
+     * never decrease the opacity below 0%.
+     *
+     * @return  opacity shift in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getAlphaOff(){
+        return getPercentageValue("alphaOff");
+    }
+
+
+    int getHue(){
+        return getAngleValue("hue");
+    }
+
+    int getHueMod(){
+        return getPercentageValue("hueMod");
+    }
+
+    int getHueOff(){
+        return getPercentageValue("hueOff");
+    }
+
+    /**
+     * specifies the input color with the specified luminance,
+     * but with its hue and saturation unchanged.
+     *
+     * @return  luminance in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getLum(){
+        return getPercentageValue("lum");
+    }
+
+    /**
+     * the luminance as expressed by a percentage relative to the input color
+     *
+     * @return  luminance in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getLumMod(){
+        return getPercentageValue("lumMod");
+    }
+
+    /**
+     * the luminance shift as expressed by a percentage relative to the input color
+     *
+     * @return  luminance shift in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getLumOff(){
+        return getPercentageValue("lumOff");
     }
-    
-    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;
+
+    /**
+     * specifies the input color with the specified saturation,
+     * but with its hue and luminance unchanged.
+     *
+     * @return  saturation in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getSat(){
+        return getPercentageValue("sat");
+    }
+
+    /**
+     * the saturation as expressed by a percentage relative to the input color
+     *
+     * @return  saturation in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getSatMod(){
+        return getPercentageValue("satMod");
+    }
+
+    /**
+     * the saturation shift as expressed by a percentage relative to the input color
+     *
+     * @return  saturation shift in percents in the range [0..100]
+     * or -1 if the value is not set
+     */
+    int getSatOff(){
+        return getPercentageValue("satOff");
+    }
+
+    /**
+     * specifies the input color with the specific red component, but with the blue and green color
+     * components unchanged
+     * 
+     * @return the value of the red component specified as a
+     * percentage with 0% indicating minimal blue and 100% indicating maximum
+     * or -1 if the value is not set
+     */
+    int getRed(){
+        return getPercentageValue("red");
+    }
+
+    int getRedMod(){
+        return getPercentageValue("redMod");
+    }
+
+    int getRedOff(){
+        return getPercentageValue("redOff");
+    }
+
+    /**
+     * specifies the input color with the specific green component, but with the red and blue color
+     * components unchanged
+     *
+     * @return the value of the green component specified as a
+     * percentage with 0% indicating minimal blue and 100% indicating maximum
+     * or -1 if the value is not set
+     */
+    int getGreen(){
+        return getPercentageValue("green");
+    }
+
+    int getGreenMod(){
+        return getPercentageValue("greenMod");
+    }
+
+    int getGreenOff(){
+        return getPercentageValue("greenOff");
+    }
+
+    /**
+     * specifies the input color with the specific blue component, but with the red and green color
+     * components unchanged
+     *
+     * @return the value of the blue component specified as a
+     * percentage with 0% indicating minimal blue and 100% indicating maximum
+     * or -1 if the value is not set
+     */
+    int getBlue(){
+        return getPercentageValue("blue");
+    }
+
+    int getBlueMod(){
+        return getPercentageValue("blueMod");
+    }
+
+    int getBlueOff(){
+        return getPercentageValue("blueOff");
+    }
+
+    /**
+     * specifies a darker version of its input color.
+     * A 10% shade is 10% of the input color combined with 90% black.
+     * 
+     * @return the value of the shade specified as a
+     * percentage with 0% indicating minimal blue and 100% indicating maximum
+     * or -1 if the value is not set
+     */
+    int getShade(){
+        return getPercentageValue("shade");
+    }
+
+    /**
+     * specifies a lighter version of its input color.
+     * A 10% tint is 10% of the input color combined with 90% white.
+     *
+     * @return the value of the tint specified as a
+     * percentage with 0% indicating minimal blue and 100% indicating maximum
+     * or -1 if the value is not set
+     */
+    int getTint(){
+        return getPercentageValue("tint");
+    }
+
+
+    /**
+     * Apply lumMod / lumOff adjustments
+     *
+     * @param c the color to modify
+     * @param lumMod luminance modulation in the range [0..100]
+     * @param lumOff luminance offset in the range [0..100]
+     * @return  modified color
+     */
+    private static Color modulateLuminanace(Color c, int lumMod, int lumOff) {
+        Color color;
+        if (lumOff > 0) {
+            color = new Color(
+                    (int) (Math.round((255 - c.getRed()) * (100.0 - lumMod) / 100.0 + c.getRed())),
+                    (int) (Math.round((255 - c.getGreen()) * lumOff / 100.0 + c.getGreen())),
+                    (int) (Math.round((255 - c.getBlue()) * lumOff / 100.0 + c.getBlue())),
+                    c.getAlpha()
+            );
+        } else {
+            color = new Color(
+                    (int) (Math.round(c.getRed() * lumMod / 100.0)),
+                    (int) (Math.round(c.getGreen() * lumMod / 100.0)),
+                    (int) (Math.round(c.getBlue() * lumMod / 100.0)),
+                    c.getAlpha()
+            );
+        }
+        return color;
+    }
+
+    private static Color shade(Color c, int shade) {
+        return new Color(
+                (int)(c.getRed() * shade * 0.01),
+                (int)(c.getGreen() * shade * 0.01),
+                (int)(c.getBlue() * shade * 0.01),
+                c.getAlpha());
+    }
+
+    private static Color tint(Color c, int tint) {
+        int r = c.getRed();
+        int g = c.getGreen();
+        int b = c.getBlue();
+
+        float ftint = tint / 100.0f;
+
+        int red = Math.round(ftint * r + (1 - ftint) * 255);
+        int green = Math.round(ftint * g + (1 - ftint) * 255);
+        int blue = Math.round(ftint * b + (1 - ftint) * 255);
+
+        return new Color(red, green, blue);
+    }
+
+    /**
+     * Preset colors defined in DrawingML
+     */
+    static Map<String, Color> presetColors;
+
+    static {
+        presetColors = new HashMap<String, Color>();    
+        presetColors.put("aliceBlue", new Color(240, 248, 255));
+        presetColors.put("antiqueWhite", new Color(250, 235, 215));
+        presetColors.put("aqua", new Color(0, 255, 255));
+        presetColors.put("aquamarine", new Color(127, 255, 212));
+        presetColors.put("azure", new Color(240, 255, 255));
+        presetColors.put("beige", new Color(245, 245, 220));
+        presetColors.put("bisque", new Color(255, 228, 196));
+        presetColors.put("black", new Color(0, 0, 0));
+        presetColors.put("blanchedAlmond", new Color(255, 235, 205));
+        presetColors.put("blue", new Color(0, 0, 255));
+        presetColors.put("blueViolet", new Color(138, 43, 226));
+        presetColors.put("brown", new Color(165, 42, 42));
+        presetColors.put("burlyWood", new Color(222, 184, 135));
+        presetColors.put("cadetBlue", new Color(95, 158, 160));
+        presetColors.put("chartreuse", new Color(127, 255, 0));
+        presetColors.put("chocolate", new Color(210, 105, 30));
+        presetColors.put("coral", new Color(255, 127, 80));
+        presetColors.put("cornflowerBlue", new Color(100, 149, 237));
+        presetColors.put("crimson", new Color(220, 20, 60));
+        presetColors.put("cyan", new Color(0, 255, 255));
+        presetColors.put("deepPink", new Color(255, 20, 147));
+        presetColors.put("deepSkyBlue", new Color(0, 191, 255));
+        presetColors.put("dimGray", new Color(105, 105, 105));
+        presetColors.put("dkBlue", new Color(0, 0, 139));
+        presetColors.put("dkCyan", new Color(0, 139, 139));
+        presetColors.put("dkGoldenrod", new Color(184, 134, 11));
+        presetColors.put("dkGray", new Color(169, 169, 169));
+        presetColors.put("dkGreen", new Color(0, 100, 0));
+        presetColors.put("dkKhaki", new Color(189, 183, 107));
+        presetColors.put("dkMagenta", new Color(139, 0, 139));
+        presetColors.put("dkOliveGreen", new Color(85, 107, 47));
+        presetColors.put("dkOrange", new Color(255, 140, 0));
+        presetColors.put("dkOrchid", new Color(153, 50, 204));
+        presetColors.put("dkRed", new Color(139, 0, 0));
+        presetColors.put("dkSalmon", new Color(233, 150, 122));
+        presetColors.put("dkSeaGreen", new Color(143, 188, 139));
+        presetColors.put("dkSlateBlue", new Color(72, 61, 139));
+        presetColors.put("dkSlateGray", new Color(47, 79, 79));
+        presetColors.put("dkTurquoise", new Color(0, 206, 209));
+        presetColors.put("dkViolet", new Color(148, 0, 211));
+        presetColors.put("dodgerBlue", new Color(30, 144, 255));
+        presetColors.put("firebrick", new Color(178, 34, 34));
+        presetColors.put("floralWhite", new Color(255, 250, 240));
+        presetColors.put("forestGreen", new Color(34, 139, 34));
+        presetColors.put("fuchsia", new Color(255, 0, 255));
+        presetColors.put("gainsboro", new Color(220, 220, 220));
+        presetColors.put("ghostWhite", new Color(248, 248, 255));
+        presetColors.put("gold", new Color(255, 215, 0));
+        presetColors.put("goldenrod", new Color(218, 165, 32));
+        presetColors.put("gray", new Color(128, 128, 128));
+        presetColors.put("green", new Color(0, 128, 0));
+        presetColors.put("greenYellow", new Color(173, 255, 47));
+        presetColors.put("honeydew", new Color(240, 255, 240));
+        presetColors.put("hotPink", new Color(255, 105, 180));
+        presetColors.put("indianRed", new Color(205, 92, 92));
+        presetColors.put("indigo", new Color(75, 0, 130));
+        presetColors.put("ivory", new Color(255, 255, 240));
+        presetColors.put("khaki", new Color(240, 230, 140));
+        presetColors.put("lavender", new Color(230, 230, 250));
+        presetColors.put("lavenderBlush", new Color(255, 240, 245));
+        presetColors.put("lawnGreen", new Color(124, 252, 0));
+        presetColors.put("lemonChiffon", new Color(255, 250, 205));
+        presetColors.put("lime", new Color(0, 255, 0));
+        presetColors.put("limeGreen", new Color(50, 205, 50));
+        presetColors.put("linen", new Color(250, 240, 230));
+        presetColors.put("ltBlue", new Color(173, 216, 230));
+        presetColors.put("ltCoral", new Color(240, 128, 128));
+        presetColors.put("ltCyan", new Color(224, 255, 255));
+        presetColors.put("ltGoldenrodYellow", new Color(250, 250, 120));
+        presetColors.put("ltGray", new Color(211, 211, 211));
+        presetColors.put("ltGreen", new Color(144, 238, 144));
+        presetColors.put("ltPink", new Color(255, 182, 193));
+        presetColors.put("ltSalmon", new Color(255, 160, 122));
+        presetColors.put("ltSeaGreen", new Color(32, 178, 170));
+        presetColors.put("ltSkyBlue", new Color(135, 206, 250));
+        presetColors.put("ltSlateGray", new Color(119, 136, 153));
+        presetColors.put("ltSteelBlue", new Color(176, 196, 222));
+        presetColors.put("ltYellow", new Color(255, 255, 224));
+        presetColors.put("magenta", new Color(255, 0, 255));
+        presetColors.put("maroon", new Color(128, 0, 0));
+        presetColors.put("medAquamarine", new Color(102, 205, 170));
+        presetColors.put("medBlue", new Color(0, 0, 205));
+        presetColors.put("medOrchid", new Color(186, 85, 211));
+        presetColors.put("medPurple", new Color(147, 112, 219));
+        presetColors.put("medSeaGreen", new Color(60, 179, 113));
+        presetColors.put("medSlateBlue", new Color(123, 104, 238));
+        presetColors.put("medSpringGreen", new Color(0, 250, 154));
+        presetColors.put("medTurquoise", new Color(72, 209, 204));
+        presetColors.put("medVioletRed", new Color(199, 21, 133));
+        presetColors.put("midnightBlue", new Color(25, 25, 112));
+        presetColors.put("mintCream", new Color(245, 255, 250));
+        presetColors.put("mistyRose", new Color(255, 228, 225));
+        presetColors.put("moccasin", new Color(255, 228, 181));
+        presetColors.put("navajoWhite", new Color(255, 222, 173));
+        presetColors.put("navy", new Color(0, 0, 128));
+        presetColors.put("oldLace", new Color(253, 245, 230));
+        presetColors.put("olive", new Color(128, 128, 0));
+        presetColors.put("oliveDrab", new Color(107, 142, 35));
+        presetColors.put("orange", new Color(255, 165, 0));
+        presetColors.put("orangeRed", new Color(255, 69, 0));
+        presetColors.put("orchid", new Color(218, 112, 214));
+        presetColors.put("paleGoldenrod", new Color(238, 232, 170));
+        presetColors.put("paleGreen", new Color(152, 251, 152));
+        presetColors.put("paleTurquoise", new Color(175, 238, 238));
+        presetColors.put("paleVioletRed", new Color(219, 112, 147));
+        presetColors.put("papayaWhip", new Color(255, 239, 213));
+        presetColors.put("peachPuff", new Color(255, 218, 185));
+        presetColors.put("peru", new Color(205, 133, 63));
+        presetColors.put("pink", new Color(255, 192, 203));
+        presetColors.put("plum", new Color(221, 160, 221));
+        presetColors.put("powderBlue", new Color(176, 224, 230));
+        presetColors.put("purple", new Color(128, 0, 128));
+        presetColors.put("red", new Color(255, 0, 0));
+        presetColors.put("rosyBrown", new Color(188, 143, 143));
+        presetColors.put("royalBlue", new Color(65, 105, 225));
+        presetColors.put("saddleBrown", new Color(139, 69, 19));
+        presetColors.put("salmon", new Color(250, 128, 114));
+        presetColors.put("sandyBrown", new Color(244, 164, 96));
+        presetColors.put("seaGreen", new Color(46, 139, 87));
+        presetColors.put("seaShell", new Color(255, 245, 238));
+        presetColors.put("sienna", new Color(160, 82, 45));
+        presetColors.put("silver", new Color(192, 192, 192));
+        presetColors.put("skyBlue", new Color(135, 206, 235));
+        presetColors.put("slateBlue", new Color(106, 90, 205));
+        presetColors.put("slateGray", new Color(112, 128, 144));
+        presetColors.put("snow", new Color(255, 250, 250));
+        presetColors.put("springGreen", new Color(0, 255, 127));
+        presetColors.put("steelBlue", new Color(70, 130, 180));
+        presetColors.put("tan", new Color(210, 180, 140));
+        presetColors.put("teal", new Color(0, 128, 128));
+        presetColors.put("thistle", new Color(216, 191, 216));
+        presetColors.put("tomato", new Color(255, 99, 71));
+        presetColors.put("turquoise", new Color(64, 224, 208));
+        presetColors.put("violet", new Color(238, 130, 238));
+        presetColors.put("wheat", new Color(245, 222, 179));
+        presetColors.put("white", new Color(255, 255, 255));
+        presetColors.put("whiteSmoke", new Color(245, 245, 245));
+        presetColors.put("yellow", new Color(255, 255, 0));
+        presetColors.put("yellowGreen", new Color(154, 205, 50));
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFCommentAuthors.java Fri Oct 28 14:25:53 2011
@@ -17,8 +17,6 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import java.io.IOException;
-
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
@@ -28,6 +26,8 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentAuthorList;
 import org.openxmlformats.schemas.presentationml.x2006.main.CmAuthorLstDocument;
 
+import java.io.IOException;
+
 @Beta
 public class XSLFCommentAuthors extends POIXMLDocumentPart {
     private final CTCommentAuthorList _authors;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFComments.java Fri Oct 28 14:25:53 2011
@@ -17,8 +17,6 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import java.io.IOException;
-
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
@@ -28,6 +26,8 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommentList;
 import org.openxmlformats.schemas.presentationml.x2006.main.CmLstDocument;
 
+import java.io.IOException;
+
 @Beta
 public class XSLFComments extends POIXMLDocumentPart {
     private final CTCommentList _comments;

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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -20,20 +20,23 @@
 package org.apache.poi.xslf.usermodel;
 
 import org.apache.poi.util.Beta;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
-import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;
+import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnectorNonVisual;
 
 import java.awt.*;
-import java.awt.geom.*;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
 
 /**
  * Specifies a connection shape.
@@ -202,11 +205,11 @@ public class XSLFConnectorShape extends 
         XSLFShadow shadow = getShadow();
 
         //border
-        Color lineColor = getLineColor();
-        if (lineColor != null) {
+        Paint line = getLinePaint(graphics);
+        if (line != null) {
             if (shadow != null) shadow.draw(graphics);
 
-            graphics.setColor(lineColor);
+            graphics.setPaint(line);
             applyStroke(graphics);
             graphics.draw(outline);
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFDrawing.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFDrawing.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFDrawing.java Fri Oct 28 14:25:53 2011
@@ -16,15 +16,14 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
 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.CTGraphicalObjectFrame;
 
 import java.awt.*;
 

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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -19,20 +19,14 @@
 
 package org.apache.poi.xslf.usermodel;
 
-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 org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
 
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
+import java.awt.*;
 import java.awt.geom.Rectangle2D;
 
 /**

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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -22,9 +22,6 @@ package org.apache.poi.xslf.usermodel;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.openxml4j.opc.TargetMode;
-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.apache.xmlbeans.XmlObject;
@@ -33,13 +30,12 @@ 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.*;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.util.List;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFImageRendener.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFImageRendener.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFImageRendener.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFImageRendener.java Fri Oct 28 14:25:53 2011
@@ -22,10 +22,12 @@ package org.apache.poi.xslf.usermodel;
 import org.apache.poi.util.Beta;
 
 import javax.imageio.ImageIO;
-import java.awt.Graphics2D;
+import java.awt.*;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 
 /**
  * For now this class renders only images supported by the javax.imageio.ImageIO
@@ -74,14 +76,25 @@ public class XSLFImageRendener {
 	public boolean drawImage(Graphics2D graphics, XSLFPictureData data,
 			Rectangle2D anchor) {
 		try {
-			BufferedImage img = ImageIO.read(new ByteArrayInputStream(data
-					.getData()));
-			graphics.drawImage(img, (int) anchor.getX(), (int) anchor.getY(),
-					(int) anchor.getWidth(), (int) anchor.getHeight(), null);
+			BufferedImage img = readImage(new ByteArrayInputStream(data.getData()));
+			if (img != null){
+                graphics.drawImage(img, (int) anchor.getX(), (int) anchor.getY(),
+                        (int) anchor.getWidth(), (int) anchor.getHeight(), null);
+            }
 			return true;
 		} catch (Exception e) {
 			return false;
 		}
 
 	}
+
+    /**
+     * create a buffered image from input stream
+     *
+     * @return a <code>BufferedImage</code> containing the decoded
+     * contents of the input, or <code>null</code>.
+     */
+    public BufferedImage readImage(InputStream is) throws IOException {
+        return ImageIO.read(is);
+    }
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotes.java Fri Oct 28 14:25:53 2011
@@ -16,8 +16,6 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import java.io.IOException;
-
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
@@ -26,6 +24,8 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
 import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
 
+import java.io.IOException;
+
 @Beta
 public final class XSLFNotes extends XSLFSheet {
    private CTNotesSlide _notes;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFNotesMaster.java Fri Oct 28 14:25:53 2011
@@ -16,19 +16,14 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesMaster;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
 import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
-import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
 
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.Map;
 
 /**

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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -19,27 +19,21 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.poi.POIXMLDocumentPart;
-import org.apache.poi.sl.usermodel.ShapeContainer;
+import org.apache.poi.POIXMLException;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
 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.*;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
@@ -104,9 +98,15 @@ public class XSLFPictureShape extends XS
             CTPicture ct = (CTPicture)getXmlObject();
             String blipId = ct.getBlipFill().getBlip().getEmbed();
 
-            for (POIXMLDocumentPart part : getSheet().getRelations()) {
-                if(part.getPackageRelationship().getId().equals(blipId)){
-                    _data = (XSLFPictureData)part;
+            PackagePart p = getSheet().getPackagePart();
+            PackageRelationship rel = p.getRelationship(blipId);
+            if (rel != null) {
+                try {
+                    PackagePart imgPart = p.getRelatedPart(rel);
+                    _data = new XSLFPictureData(imgPart, rel);
+                }
+                catch (Exception e) {
+                    throw new POIXMLException(e);
                 }
             }
         }
@@ -120,31 +120,31 @@ public class XSLFPictureShape extends XS
         // shadow
         XSLFShadow shadow = getShadow();
 
-        //fill
-        Color fillColor = getFillColor();
-        if (fillColor != null) {
-            if(shadow != null) shadow.draw(graphics);
+        Paint fill = getFill(graphics);
+        Paint line = getLinePaint(graphics);
+        if(shadow != null) {
+        	shadow.draw(graphics);
+        }
 
-        	graphics.setColor(fillColor);
-            applyFill(graphics);
+        if(fill != null) {
+            graphics.setPaint(fill);
             graphics.fill(outline);
         }
-         
+
+
         XSLFPictureData data = getPictureData();
     	if(data == null) return;
     	
         XSLFImageRendener renderer = (XSLFImageRendener)graphics.getRenderingHint(XSLFRenderingHint.IMAGE_RENDERER);
         if(renderer == null) renderer = new XSLFImageRendener();
- 
+
         renderer.drawImage(graphics, data, getAnchor());
 
-        //border overlays the image
-        Color lineColor = getLineColor();
-        if (lineColor != null){
-            graphics.setColor(lineColor);
+        if (line != null){
+            graphics.setPaint(line);
             applyStroke(graphics);
             graphics.draw(outline);
         }
     }
 
-}
\ No newline at end of file
+}

Modified: 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=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShadow.java Fri Oct 28 14:25:53 2011
@@ -17,19 +17,11 @@
 
 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.
@@ -49,8 +41,8 @@ public class XSLFShadow extends XSLFSimp
     public void draw(Graphics2D graphics) {
         Shape outline = _parent.getOutline();
 
-        Color parentFillColor = _parent.getFillColor();
-        Color parentLineColor = _parent.getLineColor();
+        Paint parentFillColor = _parent.getFill(graphics);
+        Paint parentLineColor = _parent.getLinePaint(graphics);
 
         double angle = getAngle();
         double dist = getDistance();
@@ -120,16 +112,6 @@ public class XSLFShadow extends XSLFSimp
     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());
-        }
-        else if (ct.isSetSrgbClr()) {
-            return theme.getSrgbColor(ct.getSrgbClr());
-        }
-
-        return null;
+        return ct == null ? null : new XSLFColor(ct, theme).getColor();
     }
 }
\ 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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -21,9 +21,8 @@ package org.apache.poi.xslf.usermodel;
 
 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.*;
 import java.awt.geom.Rectangle2D;
 
 /**

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=1190347&r1=1190346&r2=1190347&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 28 14:25:53 2011
@@ -21,22 +21,20 @@ 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.drawingml.x2006.main.CTTextListStyle;
 import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
 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.CTPlaceholder;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextListStyle;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 
 import javax.xml.namespace.QName;
-import java.awt.Graphics2D;
+import java.awt.*;
 import java.awt.geom.AffineTransform;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -64,7 +62,14 @@ public abstract class XSLFSheet extends 
     }
 
     public XMLSlideShow getSlideShow() {
-       return (XMLSlideShow)getParent();
+        POIXMLDocumentPart p = getParent();
+        while(p != null) {
+            if(p instanceof XMLSlideShow){
+                return (XMLSlideShow)p;
+            }
+            p = p.getParent();
+        }
+        return null;
     }
 
     protected List<XSLFShape> buildShapes(CTGroupShape spTree){

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Fri Oct 28 14:25:53 2011
@@ -19,22 +19,39 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.poi.xslf.model.geom.*;
-import org.apache.poi.xslf.usermodel.LineCap;
-import org.apache.poi.xslf.usermodel.LineDash;
-import org.apache.poi.xslf.model.PropertyFetcher;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Units;
+import org.apache.poi.xslf.model.PropertyFetcher;
+import org.apache.poi.xslf.model.geom.Context;
+import org.apache.poi.xslf.model.geom.CustomGeometry;
+import org.apache.poi.xslf.model.geom.Guide;
+import org.apache.poi.xslf.model.geom.IAdjustableShape;
+import org.apache.poi.xslf.model.geom.Path;
+import org.apache.poi.xslf.model.geom.PresetGeometries;
 import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.*;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
 
-import java.awt.*;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.util.ArrayList;
+import java.awt.image.BufferedImage;
+import java.awt.Paint;
+import java.awt.Graphics2D;
+import java.awt.Color;
+import java.awt.TexturePaint;
+import java.awt.AlphaComposite;
+import java.awt.GradientPaint;
+import java.awt.BasicStroke;
+import java.awt.Stroke;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
 
 /**
  * @author Yegor Kozlov
@@ -265,40 +282,45 @@ public abstract class XSLFSimpleShape ex
     }
 
     public Color getLineColor() {
+        Paint paint = getLinePaint(null);
+        if(paint instanceof Color){
+            return (Color)paint;
+        }
+        return null;
+    }
+
+    public Paint getLinePaint(final Graphics2D graphics) {
         final XSLFTheme theme = _sheet.getTheme();
-        final Color noline = new Color(0,0,0,0);
-        PropertyFetcher<Color> fetcher = new PropertyFetcher<Color>(){
+        final Color nofill = new Color(0,0,0,0);
+        PropertyFetcher<Paint> fetcher = new PropertyFetcher<Paint>(){
             public boolean fetch(XSLFSimpleShape shape){
-                CTShapeProperties spPr = shape.getSpPr();
-                CTLineProperties ln = spPr.getLn();
-                if (ln != null) {
-                    if (ln.isSetNoFill()) {
-                        setValue(noline);
+                CTLineProperties spPr = shape.getSpPr().getLn();
+                if (spPr != null) {
+                    if (spPr.isSetNoFill()) {
+                        setValue(nofill); // use it as 'nofill' value
                         return true;
                     }
-                    CTSolidColorFillProperties solidLine = ln.getSolidFill();
-                    if (solidLine != null) {
-                        setValue( theme.getSolidFillColor(ln.getSolidFill()) );
+                    Paint paint = getPaint(graphics, spPr);
+                    if (paint != null) {
+                        setValue( paint );
                         return true;
                     }
                 }
                 return false;
+
             }
         };
         fetchShapeProperty(fetcher);
 
-        Color color = fetcher.getValue();
+        Paint color = fetcher.getValue();
         if(color == null){
             // line color was not found, check if it is defined in the theme
             CTShapeStyle style = getSpStyle();
             if (style != null) {
-                CTSchemeColor schemeColor = style.getLnRef().getSchemeClr();
-                if (schemeColor != null) {
-                    color = theme.getSchemeColor(schemeColor);
-                }
+                color = new XSLFColor(style.getLnRef(), theme).getColor();
             }
         }
-        return color == noline ? null : color;
+        return color == nofill ? null : color;
     }
 
     public void setLineWidth(double width) {
@@ -466,17 +488,31 @@ public abstract class XSLFSimpleShape ex
      * @return solid fill color of null if not set
      */
     public Color getFillColor() {
+        Paint paint = getFill(null);
+        if(paint instanceof Color){
+            return (Color)paint;
+        }
+        return null;
+    }
+
+    /**
+     * fetch shape fill as a java.awt.Paint
+     *
+     * @return either Color or GradientPaint or TexturePaint or null
+     */
+    Paint getFill(final Graphics2D graphics) {
         final XSLFTheme theme = _sheet.getTheme();
-        final Color nofill = new Color(0,0,0,0);
-        PropertyFetcher<Color> fetcher = new PropertyFetcher<Color>(){
+        final Color nofill = new Color(0xFF,0xFF,0xFF, 0);
+        PropertyFetcher<Paint> fetcher = new PropertyFetcher<Paint>(){
             public boolean fetch(XSLFSimpleShape shape){
                 CTShapeProperties spPr = shape.getSpPr();
                 if (spPr.isSetNoFill()) {
                     setValue(nofill); // use it as 'nofill' value
                     return true;
                 }
-                if (spPr.isSetSolidFill()) {
-                    setValue( theme.getSolidFillColor(spPr.getSolidFill()) );
+                Paint paint = getPaint(graphics, spPr);
+                if (paint != null) {
+                    setValue( paint );
                     return true;
                 }
                 return false;
@@ -484,18 +520,15 @@ public abstract class XSLFSimpleShape ex
         };
         fetchShapeProperty(fetcher);
 
-        Color color = fetcher.getValue();
-        if(color == null){
+        Paint paint = fetcher.getValue();
+        if(paint == null){
             // fill color was not found, check if it is defined in the theme
             CTShapeStyle style = getSpStyle();
             if (style != null) {
-                CTSchemeColor schemeColor = style.getFillRef().getSchemeClr();
-                if (schemeColor != null) {
-                    color = theme.getSchemeColor(schemeColor);
-                }
+                paint = new XSLFColor(style.getFillRef(), theme).getColor();
             }
         }
-        return color == nofill ? null : color;
+        return paint == nofill ? null : paint;
     }
 
     public XSLFShadow getShadow(){
@@ -532,8 +565,130 @@ public abstract class XSLFSimpleShape ex
 
     }
 
-    protected void applyFill(Graphics2D graphics) {
+    @SuppressWarnings("deprecation") //  getXYZArray() array accessors are deprecated
+    protected Paint getPaint(Graphics2D graphics, XmlObject spPr) {
+        XSLFTheme theme = getSheet().getTheme();
+        Rectangle2D anchor = getAnchor();
 
+        Paint paint = null;
+        for(XmlObject obj : spPr.selectPath("*")){
+            if(obj instanceof CTNoFillProperties){
+                paint = null;
+                break;
+            }
+            if(obj instanceof CTSolidColorFillProperties){
+                CTSolidColorFillProperties solidFill = (CTSolidColorFillProperties)obj;
+                XSLFColor c = new XSLFColor(solidFill, theme);
+                paint = c.getColor();
+            }
+            if(obj instanceof CTBlipFillProperties){
+                CTBlipFillProperties blipFill = (CTBlipFillProperties)obj;
+                CTBlip blip = blipFill.getBlip();
+                String blipId = blip.getEmbed();
+                PackagePart p = getSheet().getPackagePart();
+                PackageRelationship rel = p.getRelationship(blipId);
+                if (rel != null) {
+                    XSLFImageRendener renderer = null;
+                    if(graphics != null) renderer = (XSLFImageRendener)graphics.getRenderingHint(XSLFRenderingHint.IMAGE_RENDERER);
+                    if(renderer == null) renderer = new XSLFImageRendener();
+
+                    try {
+                        BufferedImage img = renderer.readImage(p.getRelatedPart(rel).getInputStream());
+                        if(blip.sizeOfAlphaModFixArray() > 0){
+                            float alpha = blip.getAlphaModFixArray(0).getAmt()/100000.f;
+                            AlphaComposite ac = AlphaComposite.getInstance(
+                                                   AlphaComposite.SRC_OVER, alpha);
+                            if(graphics != null) graphics.setComposite(ac);
+                        }
+
+                        paint = new TexturePaint(
+                                img, new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight()));
+                    }
+                    catch (Exception e) {
+                        return null;
+                    }
+                }
+            }
+            if(obj instanceof CTGradientFillProperties){
+                CTGradientFillProperties gradFill = (CTGradientFillProperties)obj;
+                double angle;
+                if(gradFill.isSetLin()) {
+                    angle = gradFill.getLin().getAng() / 60000;
+                } else {
+                    // XSLF only supports linear gradient fills. Other types are filled as liner with angle=90 degrees
+                    angle = 90;
+                }
+                CTGradientStop[] gs =  gradFill.getGsLst().getGsArray();
+
+                Arrays.sort(gs, new Comparator<CTGradientStop>(){
+                    public int compare(CTGradientStop o1, CTGradientStop o2){
+                        Integer pos1 = o1.getPos();
+                        Integer pos2 = o2.getPos();
+                        return pos1.compareTo(pos2);
+                    }
+                });
+
+                Color[] colors = new Color[gs.length];
+                float[] fractions = new float[gs.length];
+
+                AffineTransform at = AffineTransform.getRotateInstance(
+                        Math.toRadians(angle),
+                        anchor.getX() + anchor.getWidth()/2,
+                        anchor.getY() + anchor.getHeight()/2);
+
+                double diagonal = Math.sqrt(anchor.getHeight()*anchor.getHeight() + anchor.getWidth()*anchor.getWidth());
+                Point2D p1 = new Point2D.Double(anchor.getX() + anchor.getWidth()/2 - diagonal/2,
+                        anchor.getY() + anchor.getHeight()/2);
+                p1 = at.transform(p1, null);
+
+                Point2D p2 = new Point2D.Double(anchor.getX() + anchor.getWidth(), anchor.getY() + anchor.getHeight()/2);
+                p2 = at.transform(p2, null);
+
+                norm(p1, anchor);
+                norm(p2, anchor);
+
+                for(int i = 0; i < gs.length; i++){
+                    CTGradientStop stop = gs[i];
+                    colors[i] = new XSLFColor(stop, theme).getColor();
+                    fractions[i] = stop.getPos() / 100000.f;
+                }
+
+                paint = createGradientPaint(p1, p2, fractions, colors);
+            }
+        }
+        return paint;
+    }
+
+    /**
+     * Trick to return GradientPaint on JDK 1.5 and LinearGradientPaint on JDK 1.6+
+     */
+    private Paint createGradientPaint(Point2D p1, Point2D p2, float[] fractions, Color[] colors){
+        Paint paint;
+        try {
+            Class clz = Class.forName("java.awt.LinearGradientPaint");
+            Constructor c =
+                    clz.getConstructor(Point2D.class, Point2D.class, float[].class, Color[].class);
+            paint = (Paint)c.newInstance(p1, p2, fractions, colors);
+        } catch (ClassNotFoundException e){
+            paint = new GradientPaint(p1, colors[0], p2, colors[colors.length - 1]);
+        } catch (Exception e){
+            throw new RuntimeException(e);
+        }
+        return paint;
+    }
+
+    void norm(Point2D p, Rectangle2D anchor){
+        if(p.getX() < anchor.getX()){
+            p.setLocation(anchor.getX(), p.getY());
+        } else if(p.getX() > (anchor.getX() + anchor.getWidth())){
+            p.setLocation(anchor.getX() + anchor.getWidth(), p.getY());
+        }
+
+        if(p.getY() < anchor.getY()){
+            p.setLocation(p.getX(), anchor.getY());
+        } else if (p.getY() > (anchor.getY() + anchor.getHeight())){
+            p.setLocation(p.getX(), anchor.getY() + anchor.getHeight());
+        }
     }
 
     protected float[] getDashPattern(LineDash lineDash, float lineWidth) {
@@ -665,7 +820,13 @@ public abstract class XSLFSimpleShape ex
     @Override
     protected java.awt.Shape getOutline(){
         PresetGeometries dict = PresetGeometries.getInstance();
-        String name = getSpPr().getPrstGeom().getPrst().toString();
+        CTShapeProperties spPr = getSpPr();
+        String name;
+        if(spPr.isSetPrstGeom()) {
+            name = spPr.getPrstGeom().getPrst().toString();
+        } else {
+            name = "rect";
+        }
         CustomGeometry geom = dict.get(name);
         Rectangle2D anchor = getAnchor();
         if(geom != null) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Fri Oct 28 14:25:53 2011
@@ -16,28 +16,24 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
-import java.awt.*;
-import java.io.IOException;
-
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
 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.drawingml.x2006.main.CTTextListStyle;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
 import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
+
+import java.awt.*;
+import java.io.IOException;
 
 @Beta
 public final class XSLFSlide extends XSLFSheet {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java Fri Oct 28 14:25:53 2011
@@ -22,18 +22,12 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextListStyle;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideLayout;
 import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument;
-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 java.io.IOException;
-import java.util.Map;
-import java.util.HashMap;
-import java.awt.*;
-import java.awt.geom.AffineTransform;
 
 @Beta
 public class XSLFSlideLayout extends XSLFSheet {
@@ -106,9 +100,6 @@ public class XSLFSlideLayout extends XSL
         return _master;
     }
 
-    public XMLSlideShow getSlideShow() {
-        return (XMLSlideShow)getParent().getParent();
-    }
     
     public XSLFTheme getTheme(){
     	return getSlideMaster().getTheme();
@@ -143,6 +134,6 @@ public class XSLFSlideLayout extends XSL
         if(_layout.getCSld().isSetBg()) {
             return new XSLFBackground(_layout.getCSld().getBg(), this);
         }
-        return null;
+        return getSlideMaster().getBackground();
     }
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java Fri Oct 28 14:25:53 2011
@@ -19,13 +19,12 @@ package org.apache.poi.xslf.usermodel;
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
-import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlException;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextListStyle;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
-import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterTextStyles;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextListStyle;
+import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -123,4 +122,11 @@ import java.util.Map;
         return props;
     }
 
+    @Override
+    public XSLFBackground getBackground(){
+        if(_slide.getCSld().isSetBg()) {
+            return new XSLFBackground(_slide.getCSld().getBg(), this);
+        }
+        return null;
+    }
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java Fri Oct 28 14:25:53 2011
@@ -27,10 +27,6 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
-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.presentationml.x2006.main.CTGraphicalObjectFrame;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrameNonVisual;
 
@@ -39,7 +35,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.awt.geom.Rectangle2D;
 
 /**
  * Represents a table in a .pptx presentation

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java Fri Oct 28 14:25:53 2011
@@ -19,24 +19,21 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties;
+import org.apache.poi.util.Units;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;
 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.STPenAlignment;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
 import org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
-import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndLength;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
-import org.apache.poi.util.Internal;
-import org.apache.poi.util.Units;
+import org.openxmlformats.schemas.drawingml.x2006.main.STPenAlignment;
+import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
 
 import java.awt.*;
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableRow.java Fri Oct 28 14:25:53 2011
@@ -20,16 +20,13 @@
 package org.apache.poi.xslf.usermodel;
 
 import org.apache.poi.util.Units;
-import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Represents a table in a .pptx presentation

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableStyles.java Fri Oct 28 14:25:53 2011
@@ -26,9 +26,9 @@ import org.openxmlformats.schemas.drawin
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Collections;
 
 @Beta
 public class XSLFTableStyles extends POIXMLDocumentPart implements Iterable<XSLFTableStyle>{

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java?rev=1190347&r1=1190346&r2=1190347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java Fri Oct 28 14:25:53 2011
@@ -19,25 +19,17 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.util.Beta;
-import org.apache.poi.util.Units;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
 import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShapeNonVisual;
 import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
 
-import java.awt.geom.Rectangle2D;
-
 
 /**
  * @author Yegor Kozlov



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


Mime
View raw message