You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/07/12 02:38:40 UTC

svn commit: r1690421 - in /poi/branches/common_sl/src: ooxml/java/org/apache/poi/xslf/usermodel/ ooxml/testcases/org/apache/poi/xslf/usermodel/ scratchpad/src/org/apache/poi/sl/draw/ scratchpad/src/org/apache/poi/sl/usermodel/

Author: kiwiwings
Date: Sun Jul 12 00:38:39 2015
New Revision: 1690421

URL: http://svn.apache.org/r1690421
Log:
JUnit and rendering fixes

Modified:
    poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
    poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
    poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
    poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
    poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
    poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
    poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
    poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
    poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShapeContainer.java
    poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/LineDecoration.java
    poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java Sun Jul 12 00:38:39 2015
@@ -20,8 +20,7 @@
 package org.apache.poi.xslf.usermodel;
 
 import java.awt.geom.Rectangle2D;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 import java.util.regex.Pattern;
 
 import org.apache.poi.openxml4j.opc.*;
@@ -328,7 +327,8 @@ public class XSLFGroupShape extends XSLF
      * The container will be empty after this call returns.
      */
     public void clear() {
-        for(XSLFShape shape : getShapes()){
+        List<XSLFShape> shapes = new ArrayList<XSLFShape>(getShapes());
+        for(XSLFShape shape : shapes){
             removeShape(shape);
         }
     }

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java Sun Jul 12 00:38:39 2015
@@ -435,6 +435,7 @@ public abstract class XSLFShape implemen
         for (CTGradientStop cgs : gs) {
             cs[i] = new XSLFColor(cgs, theme, phClr).getColorStyle();
             fractions[i] = cgs.getPos() / 100000.f;
+            i++;
         }
         
         return new GradientPaint() {

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java Sun Jul 12 00:38:39 2015
@@ -248,7 +248,8 @@ public abstract class XSLFSheet extends
      * The container will be empty after this call returns.
      */
     public void clear() {
-        for(XSLFShape shape : getShapes()){
+        List<XSLFShape> shapes = new ArrayList<XSLFShape>(getShapes());
+        for(XSLFShape shape : shapes){
             removeShape(shape);
         }
     }

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java Sun Jul 12 00:38:39 2015
@@ -162,15 +162,23 @@ public abstract class XSLFSimpleShape ex
      * @return line propeties from the theme of null
      */
     CTLineProperties getDefaultLineProperties() {
-        CTLineProperties ln = null;
         CTShapeStyle style = getSpStyle();
-        if (style != null) {
-            // 1-based index of a line style within the style matrix
-            int idx = (int) style.getLnRef().getIdx();
-            CTStyleMatrix styleMatrix = getSheet().getTheme().getXmlObject().getThemeElements().getFmtScheme();
-            ln = styleMatrix.getLnStyleLst().getLnArray(idx - 1);
-        }
-        return ln;
+        if (style == null) return null;
+        CTStyleMatrixReference lnRef = style.getLnRef();
+        if (lnRef == null) return null;
+        // 1-based index of a line style within the style matrix
+        int idx = (int)lnRef.getIdx();
+        
+        XSLFTheme theme = getSheet().getTheme();
+        if (theme == null) return null;
+        CTBaseStyles styles = theme.getXmlObject().getThemeElements();
+        if (styles == null) return null;
+        CTStyleMatrix styleMatrix = styles.getFmtScheme();
+        if (styleMatrix == null) return null;
+        CTLineStyleList lineStyles = styleMatrix.getLnStyleLst();
+        if (lineStyles == null || lineStyles.sizeOfLnArray() < idx) return null;
+        
+        return lineStyles.getLnArray(idx - 1);
     }
 
     /**
@@ -370,7 +378,7 @@ public abstract class XSLFSimpleShape ex
         } else {
             CTPresetLineDashProperties val = CTPresetLineDashProperties.Factory
                     .newInstance();
-            val.setVal(STPresetLineDashVal.Enum.forInt(dash.ordinal() + 1));
+            val.setVal(STPresetLineDashVal.Enum.forInt(dash.ooxmlId));
             CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr
                     .addNewLn();
             ln.setPrstDash(val);
@@ -389,7 +397,7 @@ public abstract class XSLFSimpleShape ex
                 if (ln != null) {
                     CTPresetLineDashProperties ctDash = ln.getPrstDash();
                     if (ctDash != null) {
-                        setValue(LineDash.values()[ctDash.getVal().intValue() - 1]);
+                        setValue(LineDash.fromOoxmlId(ctDash.getVal().intValue()));
                         return true;
                     }
                 }
@@ -404,7 +412,7 @@ public abstract class XSLFSimpleShape ex
             if (defaultLn != null) {
                 CTPresetLineDashProperties ctDash = defaultLn.getPrstDash();
                 if (ctDash != null) {
-                    dash = LineDash.values()[ctDash.getVal().intValue() - 1];
+                    dash = LineDash.fromOoxmlId(ctDash.getVal().intValue());
                 }
             }
         }
@@ -423,7 +431,7 @@ public abstract class XSLFSimpleShape ex
         } else {
             CTLineProperties ln = spPr.isSetLn() ? spPr.getLn() : spPr
                     .addNewLn();
-            ln.setCap(STLineCap.Enum.forInt(cap.ordinal() + 1));
+            ln.setCap(STLineCap.Enum.forInt(cap.ooxmlId));
         }
     }
 
@@ -439,7 +447,7 @@ public abstract class XSLFSimpleShape ex
                 if (ln != null) {
                     STLineCap.Enum stCap = ln.getCap();
                     if (stCap != null) {
-                        setValue(LineCap.values()[stCap.intValue() - 1]);
+                        setValue(LineCap.fromOoxmlId(stCap.intValue()));
                         return true;
                     }
                 }
@@ -454,7 +462,7 @@ public abstract class XSLFSimpleShape ex
             if (defaultLn != null) {
                 STLineCap.Enum stCap = defaultLn.getCap();
                 if (stCap != null) {
-                    cap = LineCap.values()[stCap.intValue() - 1];
+                    cap = LineCap.fromOoxmlId(stCap.intValue());
                 }
             }
         }
@@ -620,7 +628,7 @@ public abstract class XSLFSimpleShape ex
         if (style == null) {
             if (lnEnd.isSetType()) lnEnd.unsetType();
         } else {
-            lnEnd.setType(STLineEndType.Enum.forInt(style.ordinal() + 1));
+            lnEnd.setType(STLineEndType.Enum.forInt(style.ooxmlId));
         }
     }
 
@@ -629,7 +637,7 @@ public abstract class XSLFSimpleShape ex
         if (ln == null || !ln.isSetHeadEnd()) return DecorationShape.NONE;
 
         STLineEndType.Enum end = ln.getHeadEnd().getType();
-        return end == null ? DecorationShape.NONE : DecorationShape.values()[end.intValue() - 1];
+        return end == null ? DecorationShape.NONE : DecorationShape.fromOoxmlId(end.intValue());
     }
 
     /**
@@ -641,7 +649,7 @@ public abstract class XSLFSimpleShape ex
         if (style == null) {
             if (lnEnd.isSetW()) lnEnd.unsetW();
         } else {
-            lnEnd.setW(STLineEndWidth.Enum.forInt(style.ordinal() + 1));
+            lnEnd.setW(STLineEndWidth.Enum.forInt(style.ooxmlId));
         }
     }
 
@@ -650,7 +658,7 @@ public abstract class XSLFSimpleShape ex
         if (ln == null || !ln.isSetHeadEnd()) return DecorationSize.MEDIUM;
 
         STLineEndWidth.Enum w = ln.getHeadEnd().getW();
-        return w == null ? DecorationSize.MEDIUM : DecorationSize.values()[w.intValue() - 1];
+        return w == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(w.intValue());
     }
 
     /**
@@ -663,7 +671,7 @@ public abstract class XSLFSimpleShape ex
         if (style == null) {
             if (lnEnd.isSetLen()) lnEnd.unsetLen();
         } else {
-            lnEnd.setLen(STLineEndLength.Enum.forInt(style.ordinal() + 1));
+            lnEnd.setLen(STLineEndLength.Enum.forInt(style.ooxmlId));
         }
     }
 
@@ -672,7 +680,7 @@ public abstract class XSLFSimpleShape ex
         if (ln == null || !ln.isSetHeadEnd()) return DecorationSize.MEDIUM;
 
         STLineEndLength.Enum len = ln.getHeadEnd().getLen();
-        return len == null ? DecorationSize.MEDIUM : DecorationSize.values()[len.intValue() - 1];
+        return len == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(len.intValue());
     }
 
     /**
@@ -684,7 +692,7 @@ public abstract class XSLFSimpleShape ex
         if (style == null) {
             if (lnEnd.isSetType()) lnEnd.unsetType();
         } else {
-            lnEnd.setType(STLineEndType.Enum.forInt(style.ordinal() + 1));
+            lnEnd.setType(STLineEndType.Enum.forInt(style.ooxmlId));
         }
     }
 
@@ -693,7 +701,7 @@ public abstract class XSLFSimpleShape ex
         if (ln == null || !ln.isSetTailEnd()) return DecorationShape.NONE;
 
         STLineEndType.Enum end = ln.getTailEnd().getType();
-        return end == null ? DecorationShape.NONE : DecorationShape.values()[end.intValue() - 1];
+        return end == null ? DecorationShape.NONE : DecorationShape.fromOoxmlId(end.intValue());
     }
 
     /**
@@ -705,7 +713,7 @@ public abstract class XSLFSimpleShape ex
         if (style == null) {
             if (lnEnd.isSetW()) lnEnd.unsetW();
         } else {
-            lnEnd.setW(STLineEndWidth.Enum.forInt(style.ordinal() + 1));
+            lnEnd.setW(STLineEndWidth.Enum.forInt(style.ooxmlId));
         }
     }
 
@@ -714,7 +722,7 @@ public abstract class XSLFSimpleShape ex
         if (ln == null || !ln.isSetTailEnd()) return DecorationSize.MEDIUM;
 
         STLineEndWidth.Enum w = ln.getTailEnd().getW();
-        return w == null ? DecorationSize.MEDIUM : DecorationSize.values()[w.intValue() - 1];
+        return w == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(w.intValue());
     }
 
     /**
@@ -727,7 +735,7 @@ public abstract class XSLFSimpleShape ex
         if (style == null) {
             if (lnEnd.isSetLen()) lnEnd.unsetLen();
         } else {
-            lnEnd.setLen(STLineEndLength.Enum.forInt(style.ordinal() + 1));
+            lnEnd.setLen(STLineEndLength.Enum.forInt(style.ooxmlId));
         }
     }
 
@@ -736,7 +744,7 @@ public abstract class XSLFSimpleShape ex
         if (ln == null || !ln.isSetTailEnd()) return DecorationSize.MEDIUM;
 
         STLineEndLength.Enum len = ln.getTailEnd().getLen();
-        return len == null ? DecorationSize.MEDIUM : DecorationSize.values()[len.intValue() - 1];
+        return len == null ? DecorationSize.MEDIUM : DecorationSize.fromOoxmlId(len.intValue());
     }
 
     public boolean isPlaceholder() {

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java Sun Jul 12 00:38:39 2015
@@ -16,11 +16,14 @@
 ==================================================================== */
 package org.apache.poi.xslf.usermodel;
 
+import java.awt.Graphics2D;
 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.sl.draw.DrawFactory;
+import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlException;
@@ -254,4 +257,16 @@ public final class XSLFSlide extends XSL
         int idx = getSlideShow().getSlides().indexOf(this);
         return (idx == -1) ? idx : idx+1;
     }
+
+    /**
+     * Render this sheet into the supplied graphics object
+     *
+     * @param graphics
+     */
+    @Override
+    public void draw(Graphics2D graphics){
+        DrawFactory drawFact = DrawFactory.getInstance(graphics);
+        Drawable draw = drawFact.getDrawable(this);
+        draw.draw(graphics);
+    }
 }

Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Sun Jul 12 00:38:39 2015
@@ -379,7 +379,7 @@ public class XSLFTextParagraph implement
     
     @Override
     public void setIndent(Double indent){
-        if (indent == null && !_p.isSetPPr()) return;
+        if ((indent == null || indent == -1d) && !_p.isSetPPr()) return;
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
         if(indent == -1) {
             if(pr.isSetIndent()) pr.unsetIndent();
@@ -653,11 +653,22 @@ public class XSLFTextParagraph implement
         if(isBullet() == flag) return;
 
         CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
-        if(!flag) {
-            pr.addNewBuNone();
-        } else {
+        if(flag) {
             pr.addNewBuFont().setTypeface("Arial");
             pr.addNewBuChar().setChar("\u2022");
+        } else {
+            if (pr.isSetBuFont()) pr.unsetBuFont();
+            if (pr.isSetBuChar()) pr.unsetBuChar();
+            if (pr.isSetBuAutoNum()) pr.unsetBuAutoNum();
+            if (pr.isSetBuBlip()) pr.unsetBuBlip();
+            if (pr.isSetBuClr()) pr.unsetBuClr();
+            if (pr.isSetBuClrTx()) pr.unsetBuClrTx();
+            if (pr.isSetBuFont()) pr.unsetBuFont();
+            if (pr.isSetBuFontTx()) pr.unsetBuFontTx();
+            if (pr.isSetBuSzPct()) pr.unsetBuSzPct();
+            if (pr.isSetBuSzPts()) pr.unsetBuSzPts();
+            if (pr.isSetBuSzTx()) pr.unsetBuSzTx();
+            pr.addNewBuNone();
         }
     }
 
@@ -806,25 +817,27 @@ public class XSLFTextParagraph implement
             }
         }
 
-        double leftMargin = p.getLeftMargin();
+        Double leftMargin = p.getLeftMargin();
         if(leftMargin != getLeftMargin()){
             setLeftMargin(leftMargin);
         }
 
-        double indent = p.getIndent();
+        Double indent = p.getIndent();
         if(indent != getIndent()){
             setIndent(indent);
         }
 
-        double spaceAfter = p.getSpaceAfter();
+        Double spaceAfter = p.getSpaceAfter();
         if(spaceAfter != getSpaceAfter()){
             setSpaceAfter(spaceAfter);
         }
-        double spaceBefore = p.getSpaceBefore();
+        
+        Double spaceBefore = p.getSpaceBefore();
         if(spaceBefore != getSpaceBefore()){
             setSpaceBefore(spaceBefore);
         }
-        double lineSpacing = p.getLineSpacing();
+        
+        Double lineSpacing = p.getLineSpacing();
         if(lineSpacing != getLineSpacing()){
             setLineSpacing(lineSpacing);
         }

Modified: poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java (original)
+++ poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestPPTX2PNG.java Sun Jul 12 00:38:39 2015
@@ -22,9 +22,12 @@ package org.apache.poi.xslf.usermodel;
 import java.awt.Dimension;
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
+import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.imageio.ImageIO;
+
 import org.apache.poi.sl.draw.Drawable;
 import org.apache.poi.util.JvmBugs;
 import org.apache.poi.xslf.XSLFTestDataSamples;
@@ -37,18 +40,19 @@ import org.junit.Test;
  */
 public class TestPPTX2PNG {
     @Test
-    public void render(){
-        String[] testFiles = {"layouts.pptx", "sample.pptx", "shapes.pptx",
-                "themes.pptx", "backgrounds.pptx"};
+    public void render() throws Exception {
+        String[] testFiles = {"backgrounds.pptx","layouts.pptx", "sample.pptx", "shapes.pptx", "themes.pptx",};
         for(String sampleFile : testFiles){
             XMLSlideShow pptx = XSLFTestDataSamples.openSampleDocument(sampleFile);
             Dimension pg = pptx.getPageSize();
+            int slideNo=1;
             for(XSLFSlide slide : pptx.getSlides()){
-                BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_RGB);
+                BufferedImage img = new BufferedImage(pg.width, pg.height, BufferedImage.TYPE_INT_ARGB);
                 Graphics2D graphics = img.createGraphics();
                 fixFonts(graphics);
                 slide.draw(graphics);
-
+                // ImageIO.write(img, "PNG", new File("build/tmp/"+sampleFile.replaceFirst(".pptx?", "-")+slideNo+".png"));
+                slideNo++;
             }
         }
     }

Modified: poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java (original)
+++ poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java Sun Jul 12 00:38:39 2015
@@ -115,18 +115,18 @@ public class TestXSLFAutoShape {
         XSLFTextParagraph p = shape.addNewTextParagraph();
         assertEquals(1, shape.getTextParagraphs().size());
 
-        assertEquals(0., p.getIndent(), 0);
-        assertEquals(0., p.getLeftMargin(), 0);
-        assertEquals(100., p.getLineSpacing(), 0);
-        assertEquals(0., p.getSpaceAfter(), 0);
-        assertEquals(0., p.getSpaceBefore(), 0);
+        assertNull(p.getIndent());
+        assertEquals(0, p.getLeftMargin(), 0);
+        assertNull(p.getLineSpacing());
+        assertNull(p.getSpaceAfter());
+        assertNull(p.getSpaceBefore());
         assertEquals(0, p.getIndentLevel());
 
         p.setIndent(2.0);
         assertEquals(2.0, p.getIndent(), 0);
         assertTrue(p.getXmlObject().getPPr().isSetIndent());
         p.setIndent(-1d);
-        assertEquals(0.0, p.getIndent(), 0);
+        assertNull(p.getIndent());
         assertFalse(p.getXmlObject().getPPr().isSetIndent());
         p.setIndent(10.0);
         assertEquals(10., p.getIndent(), 0);
@@ -286,6 +286,7 @@ public class TestXSLFAutoShape {
         assertEquals(ShapeType.TRIANGLE, shape.getShapeType());
 
         for(ShapeType tp : ShapeType.values()) {
+            if (tp.ooxmlId == -1 || tp == ShapeType.SEAL) continue;
             shape.setShapeType(tp);
             assertEquals(tp, shape.getShapeType());
         }

Modified: poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShapeContainer.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShapeContainer.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShapeContainer.java (original)
+++ poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFShapeContainer.java Sun Jul 12 00:38:39 2015
@@ -30,7 +30,6 @@ import org.junit.Test;
 public class TestXSLFShapeContainer {
 
     @SuppressWarnings("unused")
-    @Test
     public void verifyContainer(XSLFShapeContainer container) {
         container.clear();
         assertEquals(0, container.getShapes().size());

Modified: poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java (original)
+++ poi/branches/common_sl/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java Sun Jul 12 00:38:39 2015
@@ -160,8 +160,7 @@ public class TestXSLFSimpleShape {
             assertEquals("accent1", s.getSpStyle().getFillRef().getSchemeClr().getVal().toString());
             assertEquals(2.0, s.getLineWidth(), 0);
             assertEquals(LineCap.FLAT, s.getLineCap());
-            // YK: calculated color is slightly different from PowerPoint
-            assertEquals(new Color(39, 64, 94), s.getLineColor());
+            assertEquals(new Color(79,129,189), s.getLineColor());
         }
 
         XSLFSimpleShape s0 = (XSLFSimpleShape) shapes.get(0);
@@ -178,7 +177,7 @@ public class TestXSLFSimpleShape {
         assertEquals(20000, ref1.getLumModArray(0).getVal());
         assertEquals(80000, ref1.getLumOffArray(0).getVal());
         assertEquals("accent1", ref1.getVal().toString());
-        assertEquals(new Color(220, 230, 242), s1.getFillColor());
+        assertEquals(new Color(79, 129, 189), s1.getFillColor());
 
         // lighter 60%
         XSLFSimpleShape s2 = (XSLFSimpleShape)shapes.get(2);
@@ -188,7 +187,7 @@ public class TestXSLFSimpleShape {
         assertEquals(40000, ref2.getLumModArray(0).getVal());
         assertEquals(60000, ref2.getLumOffArray(0).getVal());
         assertEquals("accent1", ref2.getVal().toString());
-        assertEquals(new Color(185, 205, 229), s2.getFillColor());
+        assertEquals(new Color(79, 129, 189), s2.getFillColor());
 
         // lighter 40%
         XSLFSimpleShape s3 = (XSLFSimpleShape)shapes.get(3);
@@ -198,7 +197,7 @@ public class TestXSLFSimpleShape {
         assertEquals(60000, ref3.getLumModArray(0).getVal());
         assertEquals(40000, ref3.getLumOffArray(0).getVal());
         assertEquals("accent1", ref3.getVal().toString());
-        assertEquals(new Color(149, 179, 215), s3.getFillColor());
+        assertEquals(new Color(79, 129, 189), s3.getFillColor());
 
         // darker 25%
         XSLFSimpleShape s4 = (XSLFSimpleShape)shapes.get(4);
@@ -207,8 +206,7 @@ public class TestXSLFSimpleShape {
         assertEquals(0, ref4.sizeOfLumOffArray());
         assertEquals(75000, ref4.getLumModArray(0).getVal());
         assertEquals("accent1", ref3.getVal().toString());
-        // YK: calculated color is slightly different from PowerPoint
-        assertEquals(new Color(59, 97, 142), s4.getFillColor());
+        assertEquals(new Color(79, 129, 189), s4.getFillColor());
 
         XSLFSimpleShape s5 = (XSLFSimpleShape)shapes.get(5);
         CTSchemeColor ref5 = s5.getSpPr().getSolidFill().getSchemeClr();
@@ -216,8 +214,7 @@ public class TestXSLFSimpleShape {
         assertEquals(0, ref5.sizeOfLumOffArray());
         assertEquals(50000, ref5.getLumModArray(0).getVal());
         assertEquals("accent1", ref5.getVal().toString());
-        // YK: calculated color is slightly different from PowerPoint
-        assertEquals(new Color(40, 65, 95), s5.getFillColor());
+        assertEquals(new Color(79, 129, 189), s5.getFillColor());
     }
 
     @Test

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawPaint.java Sun Jul 12 00:38:39 2015
@@ -105,7 +105,7 @@ public class DrawPaint {
 
         int alpha = fill.getAlpha();
         if (alpha != -1) {
-            renderer.setAlpha(fill.getAlpha()/100000.f);
+            renderer.setAlpha(alpha/100000.f);
         }
         
         Dimension dim = renderer.getDimension();

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSimpleShape.java Sun Jul 12 00:38:39 2015
@@ -242,14 +242,16 @@ public class DrawSimpleShape<T extends S
         LineDash lineDash = strokeStyle.getLineDash();
         if (lineDash == null) {
         	lineDash = LineDash.SOLID;
-        	lineWidth = 0.0f;
         }
 
         int dashPatI[] = lineDash.pattern;
-        float[] dashPatF = new float[dashPatI.length];
         final float dash_phase = 0;
-        for (int i=0; i<dashPatI.length; i++) {
-            dashPatF[i] = dashPatI[i]*Math.max(1, lineWidth);
+        float[] dashPatF = null;
+        if (dashPatI != null) {
+            dashPatF = new float[dashPatI.length];
+            for (int i=0; i<dashPatI.length; i++) {
+                dashPatF[i] = dashPatI[i]*Math.max(1, lineWidth);
+            }
         }
 
         LineCap lineCapE = strokeStyle.getLineCap();

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/DrawSlide.java Sun Jul 12 00:38:39 2015
@@ -32,7 +32,7 @@ public class DrawSlide<T extends Slide<?
         Background bg = sheet.getBackground();
         if(bg != null) {
             DrawFactory drawFact = DrawFactory.getInstance(graphics);
-            DrawBackground<Background> db = drawFact.getDrawable(bg);
+            Drawable db = drawFact.getDrawable(bg);
             db.draw(graphics);
         }
 

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/draw/ImageRenderer.java Sun Jul 12 00:38:39 2015
@@ -86,7 +86,7 @@ public class ImageRenderer {
      * @param contentType the content type
      */
     public void loadImage(InputStream data, String contentType) throws IOException {
-        img = ImageIO.read(data);
+        img = convertBufferedImage(ImageIO.read(data));
     }
 
     /**
@@ -96,9 +96,17 @@ public class ImageRenderer {
      * @param contentType the content type
      */
     public void loadImage(byte data[], String contentType) throws IOException {
-        img = ImageIO.read(new ByteArrayInputStream(data));
+        img = convertBufferedImage(ImageIO.read(new ByteArrayInputStream(data)));
     }
 
+    protected static BufferedImage convertBufferedImage(BufferedImage img) {
+        BufferedImage bi = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
+        Graphics g = bi.getGraphics();
+        g.drawImage(img, 0, 0, null);
+        g.dispose();
+        return bi;
+    }
+    
     
     /**
      * @return the buffered image

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/LineDecoration.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/LineDecoration.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/LineDecoration.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/LineDecoration.java Sun Jul 12 00:38:39 2015
@@ -22,18 +22,44 @@ public interface LineDecoration {
      *  Represents the shape decoration that appears at the ends of lines.
      */
     enum DecorationShape {
-        NONE,
-        TRIANGLE,
-        STEALTH,
-        DIAMOND,
-        OVAL,
-        ARROW
+        NONE(1),
+        TRIANGLE(2),
+        STEALTH(3),
+        DIAMOND(4),
+        OVAL(5),
+        ARROW(6);
+        
+        public final int ooxmlId;
+        
+        DecorationShape(int ooxmlId) {
+            this.ooxmlId = ooxmlId;
+        }
+    
+        public static DecorationShape fromOoxmlId(int ooxmlId) {
+            for (DecorationShape ds : values()) {
+                if (ds.ooxmlId == ooxmlId) return ds;
+            }
+            return null;
+        }
     }
     
     enum DecorationSize {
-        SMALL,
-        MEDIUM,
-        LARGE
+        SMALL(1),
+        MEDIUM(2),
+        LARGE(3);
+        
+        public final int ooxmlId;
+        
+        DecorationSize(int ooxmlId) {
+            this.ooxmlId = ooxmlId;
+        }
+        
+        public static DecorationSize fromOoxmlId(int ooxmlId) {
+            for (DecorationSize ds : values()) {
+                if (ds.ooxmlId == ooxmlId) return ds;
+            }
+            return null;
+        }
     }
     
     /**

Modified: poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java?rev=1690421&r1=1690420&r2=1690421&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java (original)
+++ poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/StrokeStyle.java Sun Jul 12 00:38:39 2015
@@ -20,11 +20,24 @@ package org.apache.poi.sl.usermodel;
 public interface StrokeStyle {
     enum LineCap {
         /** Rounded ends */
-        ROUND,
+        ROUND(1),
         /** Square protrudes by half line width */
-        SQUARE,
+        SQUARE(2),
         /** Line ends at end point*/
-        FLAT;
+        FLAT(3);
+        
+        public final int ooxmlId;
+        
+        LineCap(int ooxmlId) {
+            this.ooxmlId = ooxmlId;
+        }
+
+        public static LineCap fromOoxmlId(int ooxmlId) {
+            for (LineCap lc : values()) {
+                if (lc.ooxmlId == ooxmlId) return lc;
+            }
+            return null;
+        }
     }
 
     /**
@@ -34,34 +47,36 @@ public interface StrokeStyle {
      */
     enum LineDash {
         /** Solid (continuous) pen - native 1 */
-        SOLID(1, 1),
+        SOLID(1, 1, null),
         /** square dot style - native 6 */
-        DOT(6, 1,1),
+        DOT(6, 2, 1,1),
         /** dash style - native 7 */
-        DASH(7, 3,4),
+        DASH(7, 3, 3,4),
         /** dash short dash - native 9*/
-        DASH_DOT(9, 4,3,1,3),
+        DASH_DOT(9, 5, 4,3,1,3),
         /** long dash style - native 8 */
-        LG_DASH(8, 8,3),
+        LG_DASH(8, 4, 8,3),
         /** long dash short dash - native 10 */
-        LG_DASH_DOT(10, 8,3,1,3),
+        LG_DASH_DOT(10, 6, 8,3,1,3),
         /** long dash short dash short dash - native 11 */
-        LG_DASH_DOT_DOT(11, 8,3,1,3,1,3),
+        LG_DASH_DOT_DOT(11, 7, 8,3,1,3,1,3),
         /** PS_DASH system dash style - native 2 */
-        SYS_DASH(2, 2,2),
+        SYS_DASH(2, 8, 2,2),
         /** PS_DOT system dash style - native 3 */
-        SYS_DOT(3, 1,1),
+        SYS_DOT(3, 9, 1,1),
         /** PS_DASHDOT system dash style - native 4 */
-        SYS_DASH_DOT(4, 2,2,1,1),
+        SYS_DASH_DOT(4, 10, 2,2,1,1),
         /** PS_DASHDOTDOT system dash style / native 5 */
-        SYS_DASH_DOT_DOT(5, 2,2,1,1,1,1);
+        SYS_DASH_DOT_DOT(5, 11, 2,2,1,1,1,1);
 
         public final int pattern[];
         public final int nativeId;
+        public final int ooxmlId;
 
-        LineDash(int nativeId, int... pattern) {
+        LineDash(int nativeId, int ooxmlId, int... pattern) {
             this.nativeId = nativeId;
-            this.pattern = (pattern == null || pattern.length == 0) ? new int[]{1} : pattern;
+            this.ooxmlId = ooxmlId;
+            this.pattern = (pattern == null || pattern.length == 0) ? null : pattern;
         }
 
         public static LineDash fromNativeId(int nativeId) {
@@ -70,6 +85,13 @@ public interface StrokeStyle {
             }
             return null;
         }
+
+        public static LineDash fromOoxmlId(int ooxmlId) {
+            for (LineDash ld : values()) {
+                if (ld.ooxmlId == ooxmlId) return ld;
+            }
+            return null;
+        }
     }
 
     enum LineCompound {



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