poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1692593 [5/17] - in /poi: site/src/documentation/content/xdocs/ trunk/ trunk/src/examples/src/org/apache/poi/hslf/examples/ trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/ trunk/src/examples/src/org/apache/poi/xslf/usermodel...
Date Fri, 24 Jul 2015 21:47:58 GMT
Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/AutoShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/AutoShape.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/AutoShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/AutoShape.java Fri Jul 24 21:47:55 2015
@@ -17,6 +17,5 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface AutoShape extends SimpleShape {
-	public TextRun getTextRun();
+public interface AutoShape<T extends TextParagraph<? extends TextRun>> extends TextShape<T> {
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Background.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Background.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Background.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Background.java Fri Jul 24 21:47:55 2015
@@ -18,5 +18,5 @@
 package org.apache.poi.sl.usermodel;
 
 public interface Background extends Shape {
-
+    FillStyle getFillStyle();
 }

Copied: poi/trunk/src/java/org/apache/poi/sl/usermodel/FreeformShape.java (from r1691849, poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/FreeformShape.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/FreeformShape.java?p2=poi/trunk/src/java/org/apache/poi/sl/usermodel/FreeformShape.java&p1=poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/FreeformShape.java&r1=1691849&r2=1692593&rev=1692593&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/FreeformShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/FreeformShape.java Fri Jul 24 21:47:55 2015
@@ -17,6 +17,26 @@
 
 package org.apache.poi.sl.usermodel;
 
+import java.awt.geom.GeneralPath;
+
 public interface FreeformShape<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+    /**
+     * Gets the shape path.
+     * <p>
+     *     The path is translated in the shape's coordinate system, i.e.
+     *     freeform.getPath().getBounds2D() equals to freeform.getAnchor()
+     *     (small discrepancies are possible due to rounding errors)
+     * </p>
+     *
+     * @return the path
+     */
+    GeneralPath getPath();
 
+    /**
+     * Set the shape path
+     *
+     * @param path  shape outline
+     * @return the number of points written
+     */
+    int setPath(GeneralPath path);
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Line.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Line.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Line.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Line.java Fri Jul 24 21:47:55 2015
@@ -17,6 +17,6 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface Line extends AutoShape {
+public interface Line<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
 
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/MasterSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/MasterSheet.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/MasterSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/MasterSheet.java Fri Jul 24 21:47:55 2015
@@ -17,6 +17,6 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface MasterSheet extends Sheet {
+public interface MasterSheet<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> {
 
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Notes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Notes.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Notes.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Notes.java Fri Jul 24 21:47:55 2015
@@ -17,6 +17,8 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface Notes extends Sheet {
-	public TextRun getTextRun();
+import java.util.List;
+
+public interface Notes<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> {
+	List<? extends List<? extends TextParagraph<? extends TextRun>>> getTextParagraphs();
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/PictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/PictureData.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/PictureData.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/PictureData.java Fri Jul 24 21:47:55 2015
@@ -17,10 +17,11 @@
 
 package org.apache.poi.sl.usermodel;
 
+import java.io.IOException;
+
 public interface PictureData {
-	public int getType();
-	public byte[] getUID();
+	public String getContentType();
 
 	public byte[] getData();
-	public void setData(byte[] data);
+	public void setData(byte[] data) throws IOException;
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Shape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Shape.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Shape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Shape.java Fri Jul 24 21:47:55 2015
@@ -17,15 +17,13 @@
 
 package org.apache.poi.sl.usermodel;
 
-import java.awt.geom.Rectangle2D;
 
 public interface Shape {
-	public int getShapeType();
-
-	public Rectangle2D getAnchor();
-	public void setAnchor(Rectangle2D anchor);
-
-	public void moveTo(float x, float y);
-
-	public Shape getParent();
+	ShapeContainer<? extends Shape> getParent();
+	
+    /**
+    *
+    * @return the sheet this shape belongs to
+    */
+   Sheet<? extends Shape, ? extends SlideShow> getSheet();
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java Fri Jul 24 21:47:55 2015
@@ -17,8 +17,30 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface ShapeContainer {
-	public Shape[] getShapes();
-	public void addShape(Shape shape);
-	public boolean removeShape(Shape shape);
+import java.util.List;
+
+
+public interface ShapeContainer<T extends Shape> extends Iterable<T> {
+    /**
+     * Returns an list containing all of the elements in this container in proper
+     * sequence (from first to last element).
+     *
+     * @return an list containing all of the elements in this container in proper
+     *         sequence
+     */
+	List<T> getShapes();
+
+	void addShape(T shape);
+
+    /**
+     * Removes the specified shape from this sheet, if it is present
+     * (optional operation).  If this sheet does not contain the element,
+     * it is unchanged.
+     *
+     * @param xShape shape to be removed from this sheet, if present
+     * @return <tt>true</tt> if this sheet contained the specified element
+     * @throws IllegalArgumentException if the type of the specified shape
+     *         is incompatible with this sheet (optional)
+     */
+	boolean removeShape(T shape);
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Sheet.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Sheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Sheet.java Fri Jul 24 21:47:55 2015
@@ -17,13 +17,30 @@
 
 package org.apache.poi.sl.usermodel;
 
+import java.awt.Graphics2D;
+
+
 /**
  * Common parent of Slides, Notes and Masters
  */
-public interface Sheet extends ShapeContainer {
-	public SlideShow getSlideShow();
+public interface Sheet<T extends Shape, SS extends SlideShow> extends ShapeContainer<T> {
+	SS getSlideShow();
 
-	public MasterSheet getMasterSheet();
+    /**
+     * @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
+     * Sheets that support the notion of master (slide, slideLayout) should override it and
+     * check this setting in the sheet XML
+     */
+	boolean getFollowMasterGraphics();
+	
+	MasterSheet<T,SS> getMasterSheet();
 
-	public Background getBackground();
+	Background getBackground();
+	
+	/**
+	 * Convenience method to draw a sheet to a graphics context
+	 *
+	 * @param graphics
+	 */
+	void draw(Graphics2D graphics);
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java Fri Jul 24 21:47:55 2015
@@ -17,10 +17,20 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface SimpleShape extends Shape {
-	public Fill getFill();
-	public LineStyle getLineStyle();
+import org.apache.poi.sl.draw.geom.CustomGeometry;
+import org.apache.poi.sl.draw.geom.IAdjustableShape;
 
-	public Hyperlink getHyperlink();
-	public void setHyperlink(Hyperlink hyperlink);
+
+public interface SimpleShape extends Shape, IAdjustableShape, PlaceableShape {
+    FillStyle getFillStyle();
+    LineDecoration getLineDecoration();
+    StrokeStyle getStrokeStyle();
+
+    CustomGeometry getGeometry();
+    
+    ShapeType getShapeType();
+
+    boolean isPlaceholder();
+    
+	Shadow getShadow();
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/Slide.java Fri Jul 24 21:47:55 2015
@@ -17,16 +17,21 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface Slide extends Sheet {
-	public Notes getNotes();
-	public void setNotes(Notes notes);
+public interface Slide<T extends Shape, SS extends SlideShow, N extends Notes<T,SS>> extends Sheet<T, SS> {
+	N getNotes();
+	void setNotes(N notes);
 
-	public boolean getFollowMasterBackground();
-	public void setFollowMasterBackground(boolean follow);
+	boolean getFollowMasterBackground();
+	void setFollowMasterBackground(boolean follow);
 
-	public boolean getFollowMasterColourScheme();
-	public void setFollowMasterColourScheme(boolean follow);
+	boolean getFollowMasterColourScheme();
+	void setFollowMasterColourScheme(boolean follow);
 
-	public boolean getFollowMasterObjects();
-	public void setFollowMasterObjects(boolean follow);
+	boolean getFollowMasterObjects();
+	void setFollowMasterObjects(boolean follow);
+
+	/**
+	 * @return the 1-based slide no.
+	 */
+	int getSlideNumber();
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java Fri Jul 24 21:47:55 2015
@@ -17,14 +17,29 @@
 
 package org.apache.poi.sl.usermodel;
 
+import java.awt.Dimension;
 import java.io.IOException;
+import java.util.List;
 
 public interface SlideShow {
-	public Slide createSlide() throws IOException;
-	public MasterSheet createMasterSheet() throws IOException;
+	Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>> createSlide() throws IOException;
 
-	public Slide[] getSlides();
-	public MasterSheet[] getMasterSheet();
+	List<? extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> getSlides();
 
-	public Resources getResources();
+    MasterSheet<? extends Shape, ? extends SlideShow> createMasterSheet() throws IOException;
+
+	/**
+     * Returns all slide masters.
+     * This doesn't include notes master and other arbitrary masters.
+     */
+	List<? extends MasterSheet<? extends Shape, ? extends SlideShow>> getSlideMasters();
+
+	Resources getResources();
+
+    /**
+     * Returns the current page size
+     *
+     * @return the page size
+     */
+    Dimension getPageSize();    
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/TextBox.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/TextBox.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/TextBox.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/TextBox.java Fri Jul 24 21:47:55 2015
@@ -17,5 +17,5 @@
 
 package org.apache.poi.sl.usermodel;
 
-public interface TextBox extends AutoShape {
+public interface TextBox<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
 }

Modified: poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java Fri Jul 24 21:47:55 2015
@@ -17,14 +17,47 @@
 
 package org.apache.poi.sl.usermodel;
 
+import java.awt.Color;
+
 /**
  * Some text.
- *
- * TODO - decide on how we do rich text stuff
  */
 public interface TextRun {
-	public String getText();
-	public void setText(String text);
+    enum TextCap {
+        NONE,
+        SMALL,
+        ALL
+    }
+    
+    String getRawText();
+	void setText(String text);
+
+	TextCap getTextCap();
+	
+	Color getFontColor();
+	void setFontColor(Color color);
+	
+	
+    /**
+     * @return font size in points or null if font size is not set.
+     */
+	Double getFontSize();
 
-	// TODO - rich text formatting stuff
+    /**
+     * @param fontSize font size in points, if null the underlying fontsize will be unset
+     */
+	void setFontSize(Double fontSize);
+	String getFontFamily();
+	
+	boolean isBold();
+	boolean isItalic();
+	boolean isUnderlined();
+	boolean isStrikethrough();
+	boolean isSubscript();
+	boolean isSuperscript();
+	
+	/**
+	 * @return the pitch and family id or -1 if not applicable
+	 */
+	byte getPitchAndFamily();
 }

Modified: poi/trunk/src/java/org/apache/poi/util/HexDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/HexDump.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/HexDump.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/HexDump.java Fri Jul 24 21:47:55 2015
@@ -170,49 +170,41 @@ public class HexDump {
      * @return output string
      */
 
-    public static String dump(final byte [] data, final long offset,
-                            final int index) {
-        StringBuffer buffer;
-        if ((index < 0) || (index >= data.length))
+    public static String dump(final byte [] data, final long offset, final int index) {
+        if ((index < 0) || (index > data.length))
         {
             throw new ArrayIndexOutOfBoundsException(
                 "illegal index: " + index + " into array of length "
                 + data.length);
         }
-        long         display_offset = offset + index;
-        buffer         = new StringBuffer(74);
+        long  display_offset = offset + index;
+        StringBuilder buffer = new StringBuilder(74);
 
-        for (int j = index; j < data.length; j += 16)
-        {
+        for (int j = index; j <= data.length; j += 16) {
             int chars_read = data.length - j;
 
-            if (chars_read > 16)
-            {
+            if (chars_read > 16) {
                 chars_read = 16;
             }
+            
             buffer.append(dump(display_offset)).append(' ');
-            for (int k = 0; k < 16; k++)
-            {
-                if (k < chars_read)
-                {
-                    buffer.append(dump(data[ k + j ]));
-                }
-                else
-                {
-                    buffer.append("  ");
-                }
+            for (int k = 0; k < 16; k++) {
+                String hexDmp = (k < chars_read) ? dump(data[ k + j ]) : "  ";
+                buffer.append(hexDmp);
                 buffer.append(' ');
             }
-            for (int k = 0; k < chars_read; k++)
-            {
-                if ((data[ k + j ] >= ' ') && (data[ k + j ] < 127))
-                {
-                    buffer.append(( char ) data[ k + j ]);
-                }
-                else
-                {
-                    buffer.append('.');
+            for (int k = 0; k < chars_read; k++) {
+                byte dataB = data[ k + j ];
+                char charB = (char)(dataB & 0xFF);
+                switch (charB) {
+                case 127: case 128: case 129: case 141: case 142: case 143: case 144: case 157: case 158:
+                    charB = '.';
+                    break;
+                default:
+                    if (charB < ' ') charB = '.';
+                    break;
                 }
+                buffer.append(charB);
             }
             buffer.append(EOL);
             display_offset += chars_read;

Modified: poi/trunk/src/java/org/apache/poi/util/Units.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/Units.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/Units.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/Units.java Fri Jul 24 21:47:55 2015
@@ -20,8 +20,30 @@ package org.apache.poi.util;
  * @author Yegor Kozlov
  */
 public class Units {
+    /**
+     * In Escher absolute distances are specified in
+     * English Metric Units (EMUs), occasionally referred to as A units;
+     * there are 360000 EMUs per centimeter, 914400 EMUs per inch, 12700 EMUs per point.
+     */
     public static final int EMU_PER_PIXEL = 9525;
     public static final int EMU_PER_POINT = 12700;
+    public static final int EMU_PER_CENTIMETER = 360000;
+
+    /**
+     * Master DPI (576 pixels per inch).
+     * Used by the reference coordinate system in PowerPoint (HSLF)
+     */
+    public static final int MASTER_DPI = 576;    
+
+    /**
+     * Pixels DPI (96 pixels per inch)
+     */
+    public static final int PIXEL_DPI = 96;
+
+    /**
+     * Points DPI (72 pixels per inch)
+     */
+    public static final int POINT_DPI = 72;    
 
     /**
      * Converts points to EMUs
@@ -42,17 +64,58 @@ public class Units {
     }
     
     /**
-     * Converts a value of type FixedPoint to a decimal number
+     * Converts a value of type FixedPoint to a floating point
      *
      * @param fixedPoint
-     * @return decimal number
+     * @return floating point (double)
      * 
      * @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>
      */
-    public static double fixedPointToDecimal(int fixedPoint) {
+    public static double fixedPointToDouble(int fixedPoint) {
         int i = (fixedPoint >> 16);
         int f = (fixedPoint >> 0) & 0xFFFF;
-        double decimal = (i + f/65536.0);
-        return decimal;
+        double floatPoint = (i + f/65536d);
+        return floatPoint;
+    }
+    
+    /**
+     * Converts a value of type floating point to a FixedPoint
+     *
+     * @param floatPoint
+     * @return fixedPoint
+     * 
+     * @see <a href="http://msdn.microsoft.com/en-us/library/dd910765(v=office.12).aspx">[MS-OSHARED] - 2.2.1.6 FixedPoint</a>
+     */
+    public static int doubleToFixedPoint(double floatPoint) {
+        int i = (int)Math.floor(floatPoint);
+        int f = (int)((floatPoint % 1d)*65536d);
+        int fixedPoint = (i << 16) | (f & 0xFFFF);
+        return fixedPoint;
+    }
+
+    public static double masterToPoints(int masterDPI) {
+        double points = masterDPI;
+        points *= POINT_DPI;
+        points /= MASTER_DPI;
+        return points;
+    }
+    
+    public static int pointsToMaster(double points) {
+        points *= MASTER_DPI;
+        points /= POINT_DPI;
+        return (int)points;
+    }
+    
+    public static int pointsToPixel(double points) {
+        points *= PIXEL_DPI;
+        points /= POINT_DPI;
+        return (int)points;
+    }
+
+    public static double pixelToPoints(int pixel) {
+        double points = pixel;
+        points *= POINT_DPI;
+        points /= PIXEL_DPI;
+        return points;
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/extractor/XSLFPowerPointExtractor.java Fri Jul 24 21:47:55 2015
@@ -17,6 +17,7 @@
 package org.apache.poi.xslf.extractor;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.poi.POIXMLTextExtractor;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
@@ -122,7 +123,7 @@ public class XSLFPowerPointExtractor ext
    public String getText(boolean slideText, boolean notesText, boolean masterText) {
       StringBuffer text = new StringBuffer();
 
-      XSLFSlide[] slides = slideshow.getSlides();
+      List<XSLFSlide> slides = slideshow.getSlides();
       XSLFCommentAuthors commentAuthors = slideshow.getCommentAuthors();
 
       for (XSLFSlide slide : slides) {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java Fri Jul 24 21:47:55 2015
@@ -19,7 +19,7 @@
 
 package org.apache.poi.xslf.model;
 
-import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
+import org.apache.poi.xslf.usermodel.XSLFShape;
 import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
 
@@ -34,7 +34,7 @@ public abstract class ParagraphPropertyF
         _level = level;
     }
 
-    public boolean fetch(XSLFSimpleShape shape) {
+    public boolean fetch(XSLFShape shape) {
 
         XmlObject[] o = shape.getXmlObject().selectPath(
                 "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' " +

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/PropertyFetcher.java Fri Jul 24 21:47:55 2015
@@ -19,8 +19,8 @@
 
 package org.apache.poi.xslf.model;
 
-import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
 import org.apache.poi.util.Internal;
+import org.apache.poi.xslf.usermodel.XSLFShape;
 
 /**
  *  Used internally to navigate the PresentationML text style hierarchy and fetch properties
@@ -36,7 +36,7 @@ public abstract class PropertyFetcher<T>
      * @param shape the shape being examined
      * @return true if the desired property was fetched
      */
-    public abstract boolean fetch(XSLFSimpleShape shape) ;
+    public abstract boolean fetch(XSLFShape shape);
 
     public T getValue(){
         return _value;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/model/TextBodyPropertyFetcher.java Fri Jul 24 21:47:55 2015
@@ -19,7 +19,7 @@
 
 package org.apache.poi.xslf.model;
 
-import org.apache.poi.xslf.usermodel.XSLFSimpleShape;
+import org.apache.poi.xslf.usermodel.XSLFShape;
 import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
 
@@ -32,7 +32,7 @@ import org.openxmlformats.schemas.drawin
  */
 public abstract class TextBodyPropertyFetcher<T> extends PropertyFetcher<T> {
 
-    public boolean fetch(XSLFSimpleShape shape) {
+    public boolean fetch(XSLFShape shape) {
 
         XmlObject[] o = shape.getXmlObject().selectPath(
                 "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' " +

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -20,18 +20,24 @@ import java.awt.Dimension;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.*;
+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;
-import org.apache.poi.POIXMLRelation;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagePartName;
 import org.apache.poi.openxml4j.opc.TargetMode;
+import org.apache.poi.sl.usermodel.MasterSheet;
+import org.apache.poi.sl.usermodel.Resources;
+import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
@@ -60,7 +66,7 @@ import org.openxmlformats.schemas.presen
  *  top level object for creating new slides/etc.
  */
 @Beta
-public class XMLSlideShow  extends POIXMLDocument {
+public class XMLSlideShow extends POIXMLDocument implements SlideShow {
     private static POILogger _logger = POILogFactory.getLogger(XMLSlideShow.class);
 
     private CTPresentation _presentation;
@@ -323,7 +329,7 @@ public class XMLSlideShow  extends POIXM
         
         XSLFTheme theme = (XSLFTheme) createRelationship(XSLFRelation.THEME, 
                 XSLFFactory.getInstance(), themeIndex);
-        theme.importTheme(getSlides()[0].getTheme());
+        theme.importTheme(getSlides().get(0).getTheme());
         
         _notesMaster.addRelation(theme.getPackageRelationship().getId(), theme);
         PackagePartName themePackagePartName = theme.getPackagePart().getPartName();
@@ -339,15 +345,16 @@ public class XMLSlideShow  extends POIXM
         return _notesMaster; 
     }
 
-    public XSLFSlideMaster[] getSlideMasters() {
-        return _masters.values().toArray(new XSLFSlideMaster[_masters.size()]);
+    @Override
+    public List<XSLFSlideMaster> getSlideMasters() {
+        return new ArrayList<XSLFSlideMaster>(_masters.values());
     }
 
     /**
      * Return all the slides in the slideshow
      */
-    public XSLFSlide[] getSlides() {
-        return _slides.toArray(new XSLFSlide[_slides.size()]);
+    public List<XSLFSlide> getSlides() {
+        return _slides;
     }
     
     /**
@@ -437,7 +444,7 @@ public class XMLSlideShow  extends POIXM
      */
     public int addPicture(byte[] pictureData, int format) {
         XSLFPictureData img = findPictureData(pictureData);
-        POIXMLRelation relDesc = XSLFPictureData.RELATIONS[format];
+        // POIXMLRelation relDesc = XSLFPictureData.RELATIONS[format];
 
         if(img == null) {
             int imageNumber = _pictures.size();
@@ -485,4 +492,13 @@ public class XMLSlideShow  extends POIXM
         return null;
     }
 
+    public MasterSheet createMasterSheet() throws IOException {
+        // TODO: implement!
+        throw new UnsupportedOperationException();
+    }
+
+    public Resources getResources() {
+        // TODO: implement!
+        throw new UnsupportedOperationException();
+    }
 }

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -19,6 +19,7 @@
 
 package org.apache.poi.xslf.usermodel;
 
+import org.apache.poi.sl.usermodel.AutoShape;
 import org.apache.poi.util.Beta;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
@@ -35,7 +36,7 @@ import org.openxmlformats.schemas.presen
  * @author Yegor Kozlov
  */
 @Beta
-public class XSLFAutoShape extends XSLFTextShape {
+public class XSLFAutoShape extends XSLFTextShape implements AutoShape<XSLFTextParagraph> {
 
     /*package*/ XSLFAutoShape(CTShape shape, XSLFSheet sheet) {
         super(shape, sheet);
@@ -71,7 +72,7 @@ public class XSLFAutoShape extends XSLFT
     }
 
     protected CTTextBody getTextBody(boolean create){
-        CTShape shape = (CTShape) getXmlObject();
+        CTShape shape = (CTShape)getXmlObject();
         CTTextBody txBody = shape.getTxBody();
         if (txBody == null && create) {
             txBody = shape.addNewTxBody();

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -17,25 +17,25 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTBackgroundFillStyleList;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
-import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
-
 import java.awt.Color;
 import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.Paint;
 import java.awt.geom.Rectangle2D;
 
+import org.apache.poi.sl.draw.DrawPaint;
+import org.apache.poi.sl.usermodel.Background;
+import org.apache.poi.sl.usermodel.ColorStyle;
+import org.apache.poi.sl.usermodel.FillStyle;
+import org.apache.poi.sl.usermodel.PaintStyle;
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTBackground;
+
 /**
  * Background shape
  *
  * @author Yegor Kozlov
  */
-public class XSLFBackground extends XSLFSimpleShape {
+public class XSLFBackground extends XSLFSimpleShape implements Background {
 
     /* package */XSLFBackground(CTBackground shape, XSLFSheet sheet) {
         super(shape, sheet);
@@ -47,48 +47,14 @@ public class XSLFBackground extends XSLF
         return new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());
     }
 
-    public void draw(Graphics2D graphics) {
-        Rectangle2D anchor = getAnchor();
-
-        Paint fill = getPaint(graphics);
-        if(fill != null) {
-            graphics.setPaint(fill);
-            graphics.fill(anchor);
-        }
-    }
-
-    /**
-     * @return the Paint object to fill
-     */
-    Paint getPaint(Graphics2D graphics){
-        RenderableShape rShape = new RenderableShape(this);
-
-        Paint fill = null;
-        CTBackground bg = (CTBackground)getXmlObject();
-        if(bg.isSetBgPr()){
-            XmlObject spPr = bg.getBgPr();
-            fill = rShape.getPaint(graphics, spPr, null);
-        } else if (bg.isSetBgRef()){
-            CTStyleMatrixReference bgRef= bg.getBgRef();
-            CTSchemeColor phClr = bgRef.getSchemeClr();
-
-            int idx = (int)bgRef.getIdx() - 1001;
-            XSLFTheme theme = getSheet().getTheme();
-            CTBackgroundFillStyleList bgStyles =
-                    theme.getXmlObject().getThemeElements().getFmtScheme().getBgFillStyleLst();
-
-            XmlObject bgStyle = bgStyles.selectPath("*")[idx];
-            fill = rShape.selectPaint(graphics, bgStyle, phClr, theme.getPackagePart());
-        }
-
-        return fill;
-    }
-
     @Override
     public Color getFillColor(){
-        Paint p = getPaint(null);
-        if(p instanceof Color){
-            return (Color)p;
+        FillStyle fs = getFillStyle();
+        PaintStyle ps = fs.getPaint();
+        if (ps instanceof SolidPaint) {
+            SolidPaint sp = (SolidPaint)ps;
+            ColorStyle cs = sp.getSolidColor();
+            return DrawPaint.applyColorTransform(cs);
         }
         return null;
     }
@@ -100,7 +66,7 @@ public class XSLFBackground extends XSLF
      * @return  dummy  CTTransform2D bean
      */
     @Override
-    CTTransform2D getXfrm() {
+    protected CTTransform2D getXfrm() {
         return CTTransform2D.Factory.newInstance();
     }
 }

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -18,6 +18,12 @@
  */
 package org.apache.poi.xslf.usermodel;
 
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.poi.sl.draw.DrawPaint;
+import org.apache.poi.sl.usermodel.ColorStyle;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Internal;
 import org.apache.xmlbeans.XmlObject;
@@ -30,10 +36,6 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor;
 import org.w3c.dom.Node;
 
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * Encapsulates logic to read color definitions from DrawingML and convert them to java.awt.Color
  *
@@ -63,40 +65,37 @@ public class XSLFColor {
      * 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);
+        return DrawPaint.applyColorTransform(getColorStyle());
     }
 
-    private Color applyColorTransform(Color color){
-        Color result = color;
+    public ColorStyle getColorStyle() {
+        return new ColorStyle() {
+            public Color getColor() {
+                return _color;
+            }
 
-        int alpha = getAlpha();
-        if(alpha != -1){
-            result = new Color(
-                    result.getRed(), result.getGreen(), result.getBlue(), 
-                    Math.round(255 * alpha * 0.01f));
-        }
+            public int getAlpha() {
+                return getRawValue("alpha");
+            }
 
-        int lumOff = getLumOff();
-        int lumMod = getLumMod();
-        if(lumMod != -1 || lumOff != -1){
-            result = modulateLuminanace(result,
-                    lumMod == -1 ? 100 : lumMod,
-                    lumOff == -1 ? 0 : lumOff);
-        }
+            public int getLumOff() {
+                return getRawValue("lumOff");
+            }
 
-        int shade = getShade();
-        if(shade != -1){
-        	result = shade(result, shade);
-        }
+            public int getLumMod() {
+                return getRawValue("lumMod");
+            }
 
-        int tint = getTint();
-        if(tint != -1){
-            result = tint(result, tint);
-        }
+            public int getShade() {
+                return getRawValue("shade");
+            }
 
-        return result;
+            public int getTint() {
+                return getRawValue("tint");
+            }
+        };
     }
-
+    
     Color toColor(XmlObject obj, XSLFTheme theme) {
         Color color = null;
         for (XmlObject ch : obj.selectPath("*")) {
@@ -140,6 +139,7 @@ public class XSLFColor {
                     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
+                    @SuppressWarnings("unused")
                     String colorName = sys.getVal().toString();
                     color = Color.black;
                 }
@@ -150,66 +150,50 @@ public class XSLFColor {
         return color;
     }
 
-    /**
-     * Read a perecentage value from the supplied xml bean.
-     * Example:
-     *   <a:tint val="45000"/>
-     *
-     * the returned value is 45
-     *
-     * @return  the percentage value in the range [0 .. 100]
-     */
-    private int getPercentageValue(String elem){
+    private int getRawValue(String elem) {
         String query = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
 
         XmlObject[] obj;
 
         // first ask the context color and if not found, ask the actual color bean
-        if(_phClr != null){
+        if (_phClr != null){
             obj = _phClr.selectPath(query);
-            if(obj.length == 1){
+            if (obj.length == 1){
                 Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
                 if(attr != null) {
-                    return Integer.parseInt(attr.getNodeValue()) / 1000;
+                    return Integer.parseInt(attr.getNodeValue());
                 }
             }
         }
 
         obj = _xmlObject.selectPath(query);
-        if(obj.length == 1){
+        if (obj.length == 1){
             Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
             if(attr != null) {
-                return Integer.parseInt(attr.getNodeValue()) / 1000;
+                return Integer.parseInt(attr.getNodeValue());
             }
         }
 
-
-        return -1;
+        return -1;        
+    }
+    
+    /**
+     * Read a perecentage value from the supplied xml bean.
+     * Example:
+     *   <a:tint val="45000"/>
+     *
+     * the returned value is 45
+     *
+     * @return  the percentage value in the range [0 .. 100]
+     */
+    private int getPercentageValue(String elem){
+        int val = getRawValue(elem);
+        return (val == -1) ? val : (val / 1000);
     }
 
     private int getAngleValue(String elem){
-        String color = "declare namespace a='http://schemas.openxmlformats.org/drawingml/2006/main' $this//a:" + elem;
-        XmlObject[] obj;
-
-        // first ask the context color and if not found, ask the actual color bean
-        if(_phClr != null){
-            obj = _xmlObject.selectPath( color );
-            if(obj.length == 1){
-                Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
-                if(attr != null) {
-                    return Integer.parseInt(attr.getNodeValue()) / 60000;
-                }
-            }
-        }
-
-        obj = _xmlObject.selectPath( color );
-        if(obj.length == 1){
-            Node attr = obj[0].getDomNode().getAttributes().getNamedItem("val");
-            if(attr != null) {
-                return Integer.parseInt(attr.getNodeValue()) / 60000;
-            }
-        }
-        return -1;
+        int val = getRawValue(elem);
+        return (val == -1) ? val : (val / 60000);
     }
 
     /**
@@ -387,7 +371,7 @@ public class XSLFColor {
      * percentage with 0% indicating minimal shade and 100% indicating maximum
      * or -1 if the value is not set
      */
-    int getShade(){
+    public int getShade(){
         return getPercentageValue("shade");
     }
 
@@ -399,70 +383,12 @@ public class XSLFColor {
      * percentage with 0% indicating minimal tint and 100% indicating maximum
      * or -1 if the value is not set
      */
-    int getTint(){
+    public 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;
-    }
-
-    /**
-     * This algorithm returns result different from PowerPoint.
-     * TODO: revisit and improve
-     */
-    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());
-    }
-
-    /**
-     * This algorithm returns result different from PowerPoint.
-     * TODO: revisit and improve
-     */
-    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 final Map<String, Color> presetColors;

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -19,6 +19,7 @@
 
 package org.apache.poi.xslf.usermodel;
 
+import org.apache.poi.sl.usermodel.ConnectorShape;
 import org.apache.poi.util.Beta;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
@@ -34,7 +35,7 @@ import org.openxmlformats.schemas.presen
  * @author Yegor Kozlov
  */
 @Beta
-public class XSLFConnectorShape extends XSLFSimpleShape {
+public class XSLFConnectorShape extends XSLFSimpleShape implements ConnectorShape {
 
     /*package*/ XSLFConnectorShape(CTConnector shape, XSLFSheet sheet) {
         super(shape, sheet);
@@ -43,6 +44,7 @@ public class XSLFConnectorShape extends
     /**
      * @param shapeId 1-based shapeId
      */
+    @SuppressWarnings("unused")
     static CTConnector prototype(int shapeId) {
         CTConnector ct = CTConnector.Factory.newInstance();
         CTConnectorNonVisual nvSpPr = ct.addNewNvCxnSpPr();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFFreeformShape.java Fri Jul 24 21:47:55 2015
@@ -24,6 +24,7 @@ import java.awt.geom.GeneralPath;
 import java.awt.geom.PathIterator;
 import java.awt.geom.Rectangle2D;
 
+import org.apache.poi.sl.usermodel.FreeformShape;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Units;
 import org.apache.xmlbeans.XmlObject;
@@ -47,18 +48,13 @@ import org.openxmlformats.schemas.presen
  * @author Yegor Kozlov
  */
 @Beta
-public class XSLFFreeformShape extends XSLFAutoShape {
+public class XSLFFreeformShape extends XSLFAutoShape implements FreeformShape<XSLFTextParagraph> {
 
     /*package*/ XSLFFreeformShape(CTShape shape, XSLFSheet sheet) {
         super(shape, sheet);
     }
 
-    /**
-     * Set the shape path
-     *
-     * @param path  shape outline
-     * @return the number of points written
-     */
+    @Override
     public int setPath(GeneralPath path) {
         CTPath2D ctPath = CTPath2D.Factory.newInstance();
 
@@ -110,16 +106,7 @@ public class XSLFFreeformShape extends X
         return numPoints;
     }
 
-    /**
-     * Gets the shape path.
-     * <p>
-     *     The path is translated in the shape's coordinate system, i.e.
-     *     freeform.getPath().getBounds2D() equals to freeform.getAnchor()
-     *     (small discrepancies are possible due to rounding errors)
-     * </p>
-     *
-     * @return the path
-     */
+    @Override
     @SuppressWarnings("deprecation")
     public GeneralPath getPath() {
         GeneralPath path = new GeneralPath();

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -19,10 +19,15 @@
 
 package org.apache.poi.xslf.usermodel;
 
+import java.awt.geom.Rectangle2D;
+
+import javax.xml.namespace.QName;
+
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.Units;
 import org.apache.xmlbeans.XmlCursor;
@@ -33,45 +38,21 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
 
-import javax.xml.namespace.QName;
-import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
-
 /**
  * @author Yegor Kozlov
  */
 @Beta
 public class XSLFGraphicFrame extends XSLFShape {
-    private final CTGraphicalObjectFrame _shape;
-    private final XSLFSheet _sheet;
-
     /*package*/ XSLFGraphicFrame(CTGraphicalObjectFrame shape, XSLFSheet sheet){
-        _shape = shape;
-        _sheet = sheet;
-    }
-
-    public CTGraphicalObjectFrame getXmlObject(){
-        return _shape;
+        super(shape,sheet);
     }
 
-    public XSLFSheet getSheet(){
-        return _sheet;
-    }
-
-    public int getShapeType(){
-        throw new RuntimeException("NotImplemented");
-    }
-
-    public int getShapeId(){
-        return (int)_shape.getNvGraphicFramePr().getCNvPr().getId();
-    }
-
-    public String getShapeName(){
-        return _shape.getNvGraphicFramePr().getCNvPr().getName();
+    public ShapeType getShapeType(){
+        throw new UnsupportedOperationException();
     }
 
     public Rectangle2D getAnchor(){
-        CTTransform2D xfrm = _shape.getXfrm();
+        CTTransform2D xfrm = ((CTGraphicalObjectFrame)getXmlObject()).getXfrm();
         CTPoint2D off = xfrm.getOff();
         long x = off.getX();
         long y = off.getY();
@@ -84,7 +65,7 @@ public class XSLFGraphicFrame extends XS
     }
 
     public void setAnchor(Rectangle2D anchor){
-        CTTransform2D xfrm = _shape.getXfrm();
+        CTTransform2D xfrm = ((CTGraphicalObjectFrame)getXmlObject()).getXfrm();
         CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
         long x = Units.toEMU(anchor.getX());
         long y = Units.toEMU(anchor.getY());
@@ -155,15 +136,11 @@ public class XSLFGraphicFrame extends XS
     	return false;
     }
 
-    public void draw(Graphics2D graphics){
-
-    }
-
     @Override
     void copy(XSLFShape sh){
         super.copy(sh);
 
-        CTGraphicalObjectData data = _shape.getGraphic().getGraphicData();
+        CTGraphicalObjectData data = ((CTGraphicalObjectFrame)getXmlObject()).getGraphic().getGraphicData();
         String uri = data.getUri();
         if(uri.equals("http://schemas.openxmlformats.org/drawingml/2006/diagram")){
             copyDiagram(data, (XSLFGraphicFrame)sh);
@@ -185,22 +162,22 @@ public class XSLFGraphicFrame extends XS
                 String dm = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "dm"));
                 PackageRelationship dmRel = sheet.getPackagePart().getRelationship(dm);
                 PackagePart dmPart = sheet.getPackagePart().getRelatedPart(dmRel);
-                _sheet.importPart(dmRel, dmPart);
+                getSheet().importPart(dmRel, dmPart);
 
                 String lo = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "lo"));
                 PackageRelationship loRel = sheet.getPackagePart().getRelationship(lo);
                 PackagePart loPart = sheet.getPackagePart().getRelatedPart(loRel);
-                _sheet.importPart(loRel, loPart);
+                getSheet().importPart(loRel, loPart);
 
                 String qs = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "qs"));
                 PackageRelationship qsRel = sheet.getPackagePart().getRelationship(qs);
                 PackagePart qsPart = sheet.getPackagePart().getRelatedPart(qsRel);
-                _sheet.importPart(qsRel, qsPart);
+                getSheet().importPart(qsRel, qsPart);
 
                 String cs = c.getAttributeText(new QName("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "cs"));
                 PackageRelationship csRel = sheet.getPackagePart().getRelationship(cs);
                 PackagePart csPart = sheet.getPackagePart().getRelatedPart(csRel);
-                _sheet.importPart(csRel, csPart);
+                getSheet().importPart(csRel, csPart);
 
             } catch (InvalidFormatException e){
                 throw new POIXMLException(e);

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -19,10 +19,19 @@
 
 package org.apache.poi.xslf.usermodel;
 
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Pattern;
+
 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.GroupShape;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 import org.apache.poi.util.Units;
 import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
@@ -35,42 +44,41 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
 
-import java.awt.Graphics2D;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
 /**
  * Represents a group shape that consists of many shapes grouped together.
  * 
  * @author Yegor Kozlov
  */
 @Beta
-public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer {
-    private final CTGroupShape _shape;
-    private final XSLFSheet _sheet;
+public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, GroupShape<XSLFShape> {
+    private static POILogger _logger = POILogFactory.getLogger(XSLFGroupShape.class);
+    
     private final List<XSLFShape> _shapes;
-    private final CTGroupShapeProperties _spPr;
+    private final CTGroupShapeProperties _grpSpPr;
     private XSLFDrawing _drawing;
 
-    /*package*/ XSLFGroupShape(CTGroupShape shape, XSLFSheet sheet){
-        _shape = shape;
-        _sheet = sheet;
-
-        _shapes = _sheet.buildShapes(_shape);
-        _spPr = shape.getGrpSpPr();
-    }
-
-    @Override
-    public CTGroupShape getXmlObject(){
-        return _shape;
+    protected XSLFGroupShape(CTGroupShape shape, XSLFSheet sheet){
+        super(shape,sheet);
+        _shapes = sheet.buildShapes(shape);
+        _grpSpPr = shape.getGrpSpPr();
+    }
+
+    protected CTGroupShapeProperties getGrpSpPr() {
+        return _grpSpPr;
+    }
+    
+    protected CTGroupTransform2D getSafeXfrm() {
+        CTGroupTransform2D xfrm = getXfrm();
+        return (xfrm == null ? getGrpSpPr().addNewXfrm() : xfrm);
+    }
+    
+    protected CTGroupTransform2D getXfrm() {
+        return getGrpSpPr().getXfrm();
     }
 
     @Override
     public Rectangle2D getAnchor(){
-        CTGroupTransform2D xfrm = _spPr.getXfrm();
+        CTGroupTransform2D xfrm = getXfrm();
         CTPoint2D off = xfrm.getOff();
         long x = off.getX();
         long y = off.getY();
@@ -84,7 +92,7 @@ public class XSLFGroupShape extends XSLF
 
     @Override
     public void setAnchor(Rectangle2D anchor){
-        CTGroupTransform2D xfrm = _spPr.isSetXfrm() ? _spPr.getXfrm() : _spPr.addNewXfrm();
+        CTGroupTransform2D xfrm = getSafeXfrm();
         CTPoint2D off = xfrm.isSetOff() ? xfrm.getOff() : xfrm.addNewOff();
         long x = Units.toEMU(anchor.getX());
         long y = Units.toEMU(anchor.getY());
@@ -104,7 +112,7 @@ public class XSLFGroupShape extends XSLF
      * behavior of shapes placed within a group.
      */
     public Rectangle2D getInteriorAnchor(){
-        CTGroupTransform2D xfrm = _spPr.getXfrm();
+        CTGroupTransform2D xfrm = getXfrm();
         CTPoint2D off = xfrm.getChOff();
         long x = off.getX();
         long y = off.getY();
@@ -122,8 +130,8 @@ public class XSLFGroupShape extends XSLF
      * used for calculations of grouping, scaling, and rotation
      * behavior of shapes placed within a group.
      */
-    public void setInteriorAnchor(Rectangle2D anchor){
-        CTGroupTransform2D xfrm = _spPr.isSetXfrm() ? _spPr.getXfrm() : _spPr.addNewXfrm();
+    public void setInteriorAnchor(Rectangle2D anchor) {
+        CTGroupTransform2D xfrm = getSafeXfrm();
         CTPoint2D off = xfrm.isSetChOff() ? xfrm.getChOff() : xfrm.addNewChOff();
         long x = Units.toEMU(anchor.getX());
         long y = Units.toEMU(anchor.getY());
@@ -140,8 +148,9 @@ public class XSLFGroupShape extends XSLF
      *
      * @return child shapes contained witin this group
      */
-    public XSLFShape[] getShapes(){
-        return _shapes.toArray(new XSLFShape[_shapes.size()]);
+    @Override
+    public List<XSLFShape> getShapes(){
+        return _shapes;
     }
 
     /**
@@ -158,28 +167,19 @@ public class XSLFGroupShape extends XSLF
      */
     public boolean removeShape(XSLFShape xShape) {
         XmlObject obj = xShape.getXmlObject();
+        CTGroupShape grpSp = (CTGroupShape)getXmlObject();
         if(obj instanceof CTShape){
-            _shape.getSpList().remove(obj);
+            grpSp.getSpList().remove(obj);
         } else if (obj instanceof CTGroupShape){
-            _shape.getGrpSpList().remove(obj);
+            grpSp.getGrpSpList().remove(obj);
         } else if (obj instanceof CTConnector){
-            _shape.getCxnSpList().remove(obj);
+            grpSp.getCxnSpList().remove(obj);
         } else {
             throw new IllegalArgumentException("Unsupported shape: " + xShape);
         }
         return _shapes.remove(xShape);
     }
 
-    @Override
-    public String getShapeName(){
-        return _shape.getNvGrpSpPr().getCNvPr().getName();
-    }
-
-    @Override
-    public int getShapeId(){
-        return (int)_shape.getNvGrpSpPr().getCNvPr().getId();
-    }
-
     /**
      * @param shapeId 1-based shapeId
      */
@@ -199,7 +199,7 @@ public class XSLFGroupShape extends XSLF
     // shape factory methods
     private XSLFDrawing getDrawing(){
         if(_drawing == null) {
-            _drawing = new XSLFDrawing(_sheet, _shape);
+            _drawing = new XSLFDrawing(getSheet(), (CTGroupShape)getXmlObject());
         }
         return _drawing;
     }
@@ -207,36 +207,41 @@ public class XSLFGroupShape extends XSLF
     public XSLFAutoShape createAutoShape(){
         XSLFAutoShape sh = getDrawing().createAutoShape();
         _shapes.add(sh);
+        sh.setParent(this);
         return sh;
     }
 
     public XSLFFreeformShape createFreeform(){
         XSLFFreeformShape sh = getDrawing().createFreeform();
         _shapes.add(sh);
+        sh.setParent(this);
         return sh;
     }
 
     public XSLFTextBox createTextBox(){
         XSLFTextBox sh = getDrawing().createTextBox();
         _shapes.add(sh);
+        sh.setParent(this);
         return sh;
     }
 
     public XSLFConnectorShape createConnector(){
         XSLFConnectorShape sh = getDrawing().createConnector();
         _shapes.add(sh);
+        sh.setParent(this);
         return sh;
     }
 
     public XSLFGroupShape createGroup(){
         XSLFGroupShape sh = getDrawing().createGroup();
         _shapes.add(sh);
+        sh.setParent(this);
         return sh;
     }
 
     public XSLFPictureShape createPicture(int pictureIndex){
 
-        List<PackagePart>  pics = _sheet.getPackagePart().getPackage()
+        List<PackagePart>  pics = getSheet().getPackagePart().getPackage()
                 .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) + ".*?"));
 
         if(pics.size() == 0) {
@@ -245,91 +250,89 @@ public class XSLFGroupShape extends XSLF
 
         PackagePart pic = pics.get(0);
 
-        PackageRelationship rel = _sheet.getPackagePart().addRelationship(
+        PackageRelationship rel = getSheet().getPackagePart().addRelationship(
                 pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation());
 
         XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
         sh.resize();
         _shapes.add(sh);
+        sh.setParent(this);
         return sh;
     }
 
+    public XSLFTable createTable(){
+        XSLFTable sh = getDrawing().createTable();
+        _shapes.add(sh);
+        sh.setParent(this);
+        return sh;
+    }
+    
     @Override
     public void setFlipHorizontal(boolean flip){
-        _spPr.getXfrm().setFlipH(flip);
+        getSafeXfrm().setFlipH(flip);
     }
 
     @Override
     public void setFlipVertical(boolean flip){
-        _spPr.getXfrm().setFlipV(flip);
+        getSafeXfrm().setFlipV(flip);
     }
 
     @Override
     public boolean getFlipHorizontal(){
-         return _spPr.getXfrm().getFlipH();
+        CTGroupTransform2D xfrm = getXfrm();
+        return (xfrm == null || !xfrm.isSetFlipH()) ? false : xfrm.getFlipH();
     }
 
     @Override
     public boolean getFlipVertical(){
-         return _spPr.getXfrm().getFlipV();
+        CTGroupTransform2D xfrm = getXfrm();
+        return (xfrm == null || !xfrm.isSetFlipV()) ? false : xfrm.getFlipV();
     }
 
     @Override
     public void setRotation(double theta){
-        _spPr.getXfrm().setRot((int)(theta*60000));
+        getSafeXfrm().setRot((int) (theta * 60000));
     }
 
     @Override
     public double getRotation(){
-        return (double)_spPr.getXfrm().getRot()/60000;
-    }
-
-    @Override
-    public void draw(Graphics2D graphics){
-
-    	// the coordinate system of this group of shape
-        Rectangle2D interior = getInteriorAnchor();
-        // anchor of this group relative to the parent shape
-        Rectangle2D exterior = getAnchor();
-
-        AffineTransform tx = (AffineTransform)graphics.getRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM);
-        AffineTransform tx0 = new AffineTransform(tx);
-
-        double scaleX = interior.getWidth() == 0. ? 1.0 : exterior.getWidth() / interior.getWidth();
-        double scaleY = interior.getHeight() == 0. ? 1.0 : exterior.getHeight() / interior.getHeight();
-
-        tx.translate(exterior.getX(), exterior.getY());
-        tx.scale(scaleX, scaleY);
-        tx.translate(-interior.getX(), -interior.getY());
-
-        for (XSLFShape shape : getShapes()) {
-        	// remember the initial transform and restore it after we are done with the drawing
-        	AffineTransform at = graphics.getTransform();
-            graphics.setRenderingHint(XSLFRenderingHint.GSAVE, true);
-
-            shape.applyTransform(graphics);
-        	shape.draw(graphics);
-
-            // restore the coordinate system
-            graphics.setTransform(at);
-            graphics.setRenderingHint(XSLFRenderingHint.GRESTORE, true);
-        }
-
-        graphics.setRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM, tx0);
-        
+        CTGroupTransform2D xfrm = getXfrm();
+        return (xfrm == null || !xfrm.isSetRot()) ? 0 : (xfrm.getRot() / 60000.d);
     }
 
     @Override
     void copy(XSLFShape src){
         XSLFGroupShape gr = (XSLFGroupShape)src;
+        
+        // clear shapes
+        clear();
+        
         // recursively update each shape
-        XSLFShape[] tgtShapes = getShapes();
-        XSLFShape[] srcShapes = gr.getShapes();
-        for(int i = 0; i < tgtShapes.length; i++){
-            XSLFShape s1 = srcShapes[i];
-            XSLFShape s2 = tgtShapes[i];
+        for(XSLFShape shape : gr.getShapes()) {
+            XSLFShape newShape = null;
+            if (shape instanceof XSLFTextBox) {
+                newShape = createTextBox();
+            } else if (shape instanceof XSLFAutoShape) {
+                newShape = createAutoShape();
+            } else if (shape instanceof XSLFConnectorShape) {
+                newShape = createConnector();
+            } else if (shape instanceof XSLFFreeformShape) {
+                newShape = createFreeform();
+            } else if (shape instanceof XSLFPictureShape) {
+                XSLFPictureShape p = (XSLFPictureShape)shape;
+                XSLFPictureData pd = p.getPictureData();
+                int picId = getSheet().getSlideShow().addPicture(pd.getData(), pd.getPictureType());
+                newShape = createPicture(picId);
+            } else if (shape instanceof XSLFGroupShape) {
+                newShape = createGroup();
+            } else if (shape instanceof XSLFTable) {
+                newShape = createTable();
+            } else {
+                _logger.log(POILogger.WARN, "copying of class "+shape.getClass()+" not supported.");
+                continue;
+            }
 
-            s2.copy(s1);
+            newShape.copy(shape);
         }
     }
 
@@ -338,9 +341,15 @@ 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);
         }
     }
 
+    public void addShape(XSLFShape shape) {
+        throw new UnsupportedOperationException(
+            "Adding a shape from a different container is not supported -"
+            + " create it from scratch with XSLFGroupShape.create* methods");
+    }
 }
\ 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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -17,10 +17,13 @@
 package org.apache.poi.xslf.usermodel;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 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.Notes;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
@@ -28,7 +31,7 @@ import org.openxmlformats.schemas.presen
 import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
 
 @Beta
-public final class XSLFNotes extends XSLFSheet {
+public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape,XMLSlideShow> {
    private CTNotesSlide _notes;
 
     /**
@@ -80,7 +83,6 @@ public final class XSLFNotes extends XSL
     	return getMasterSheet().getTheme();
     }
 
-    @Override
     public XSLFNotesMaster getMasterSheet() {
         for (POIXMLDocumentPart p : getRelations()) {
            if (p instanceof XSLFNotesMaster){
@@ -89,4 +91,16 @@ public final class XSLFNotes extends XSL
         }
         return null;
     }
+
+    @Override
+    public List<List<XSLFTextParagraph>> getTextParagraphs() {
+        List<List<XSLFTextParagraph>> tp = new ArrayList<List<XSLFTextParagraph>>();
+        for (XSLFShape sh : super.getShapes()) {
+            if (sh instanceof XSLFTextShape) {
+                XSLFTextShape txt = (XSLFTextShape)sh;
+                tp.add(txt.getTextParagraphs());
+            }
+        }
+        return tp;
+    }
 }

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -23,6 +23,7 @@ import org.apache.poi.POIXMLDocumentPart
 import org.apache.poi.POIXMLException;
 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.CTColorMapping;
@@ -46,7 +47,7 @@ import org.openxmlformats.schemas.presen
  * @author Yegor Kozlov
 */
 @Beta
- public class XSLFNotesMaster extends XSLFSheet {
+ public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape,XMLSlideShow> {
 	 private CTNotesMaster _slide;
      private XSLFTheme _theme;
 
@@ -93,7 +94,7 @@ import org.openxmlformats.schemas.presen
     }
 
     @Override
-    public XSLFSheet getMasterSheet() {
+    public MasterSheet<XSLFShape,XMLSlideShow> getMasterSheet() {
         return null;
     }
     

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java?rev=1692593&r1=1692592&r2=1692593&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java Fri Jul 24 21:47:55 2015
@@ -20,12 +20,14 @@
 package org.apache.poi.xslf.usermodel;
 
 import java.io.IOException;
+import java.io.OutputStream;
 
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.POIXMLRelation;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.sl.usermodel.PictureData;
 import org.apache.poi.util.Beta;
 import org.apache.poi.util.IOUtils;
 
@@ -35,7 +37,7 @@ import org.apache.poi.util.IOUtils;
  * @author Yegor Kozlov
  */
 @Beta
-public final class XSLFPictureData extends POIXMLDocumentPart {
+public final class XSLFPictureData extends POIXMLDocumentPart implements PictureData {
     /**
      * Extended windows meta file
      */
@@ -215,4 +217,17 @@ public final class XSLFPictureData exten
     protected void prepareForCommit() {
         // do not clear the part here
     }
+    
+    public String getContentType() {
+        POIXMLRelation rel = RELATIONS[getPictureType()];
+        return (rel == null) ? null : rel.getContentType();
+    }
+
+    public void setData(byte[] data) throws IOException {
+        OutputStream os = getPackagePart().getOutputStream();
+        os.write(data);
+        os.close();
+    }
+    
+    
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureShape.java?rev=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -19,7 +19,6 @@
 
 package org.apache.poi.xslf.usermodel;
 
-import java.awt.Graphics2D;
 import java.awt.Insets;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
@@ -32,6 +31,7 @@ import javax.xml.namespace.QName;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.sl.usermodel.PictureShape;
 import org.apache.poi.util.Beta;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
@@ -52,7 +52,7 @@ import org.openxmlformats.schemas.presen
  * Represents a picture shape
  */
 @Beta
-public class XSLFPictureShape extends XSLFSimpleShape {
+public class XSLFPictureShape extends XSLFSimpleShape implements PictureShape {
     private XSLFPictureData _data;
 
     /*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) {
@@ -179,30 +179,14 @@ public class XSLFPictureShape extends XS
         return id;
     }
 
-    public Insets getBlipClip(){
+    @Override
+    public Insets getClipping(){
         CTPicture ct = (CTPicture)getXmlObject();
         CTRelativeRect r = ct.getBlipFill().getSrcRect();
         return (r == null) ? null : new Insets(r.getT(), r.getL(), r.getB(), r.getR());
     }
 
-    @Override
-    public void drawContent(Graphics2D graphics) {
-
-        XSLFPictureData data = getPictureData();
-    	if(data == null) return;
-
-        XSLFImageRenderer renderer = (XSLFImageRenderer)graphics.getRenderingHint(XSLFRenderingHint.IMAGE_RENDERER);
-        if(renderer == null) renderer = new XSLFImageRenderer();
-
-        RenderableShape rShape = new RenderableShape(this);
-        Rectangle2D anchor = rShape.getAnchor(graphics);
-        
-        Insets insets = getBlipClip();
-
-        renderer.drawImage(graphics, data, anchor, insets);
-    }
-
-
+    @SuppressWarnings("deprecation")
     @Override
     void copy(XSLFShape sh){
         super.copy(sh);

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=1692593&r1=1692592&r2=1692593&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 Jul 24 21:47:55 2015
@@ -17,21 +17,24 @@
 
 package org.apache.poi.xslf.usermodel;
 
+import java.awt.Color;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.poi.sl.draw.DrawPaint;
+import org.apache.poi.sl.usermodel.ColorStyle;
+import org.apache.poi.sl.usermodel.PaintStyle;
+import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
+import org.apache.poi.sl.usermodel.Shadow;
 import org.apache.poi.util.Units;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
 
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.geom.Rectangle2D;
-
 /**
  * Represents a shadow of a shape. For now supports only outer shadows.
  *
  * @author Yegor Kozlov
  */
-public class XSLFShadow extends XSLFSimpleShape {
+public class XSLFShadow extends XSLFShape implements Shadow {
 
     private XSLFSimpleShape _parent;
 
@@ -41,54 +44,15 @@ public class XSLFShadow extends XSLFSimp
         _parent = parentShape;
     }
 
-
-    public void fill(Graphics2D graphics, Shape outline) {
-
-        double shapeRotation = _parent.getRotation();
-        if(_parent.getFlipVertical()){
-            shapeRotation += 180;
-        }
-        double angle = getAngle() - shapeRotation;
-        double dist = getDistance();
-        double dx = dist * Math.cos(Math.toRadians(angle));
-        double dy = dist * Math.sin(Math.toRadians(angle));
-
-        graphics.translate(dx, dy);
-
-        Color fillColor = getFillColor();
-        if (fillColor != null) {
-            graphics.setColor(fillColor);
-            graphics.fill(outline);
-        }
-
-        graphics.translate(-dx, -dy);
-    }
-
-    public void draw(Graphics2D graphics, Shape outline) {
-
-        double angle = getAngle();
-        double dist = getDistance();
-        double dx = dist * Math.cos(Math.toRadians(angle));
-        double dy = dist * Math.sin(Math.toRadians(angle));
-
-        graphics.translate(dx, dy);
-
-        Color fillColor = getFillColor();
-        if (fillColor != null) {
-            graphics.setColor(fillColor);
-            graphics.draw(outline);
-        }
-
-        graphics.translate(-dx, -dy);
+    @Override
+    public XSLFSimpleShape getShadowParent() {
+        return _parent;
     }
 
-
-    @Override
     public Rectangle2D getAnchor(){
         return _parent.getAnchor();
     }
 
-    @Override
     public void setAnchor(Rectangle2D anchor){
         throw new IllegalStateException("You can't set anchor of a shadow");
     }
@@ -124,15 +88,25 @@ public class XSLFShadow extends XSLFSimp
      * @return the color of this shadow. 
      * Depending whether the parent shape is filled or stroked, this color is used to fill or stroke this shadow
      */
-    @Override
     public Color getFillColor() {
+        SolidPaint ps = getFillStyle();
+        if (ps == PaintStyle.TRANSPARENT_PAINT) return null;
+        Color col = DrawPaint.applyColorTransform(ps.getSolidColor());
+        return col;
+    }
+
+    @Override
+    public SolidPaint getFillStyle() {
         XSLFTheme theme = getSheet().getTheme();
         CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
-        if(ct == null) {
-            return null;
-        } else {
-            CTSchemeColor phClr = ct.getSchemeClr();
-            return new XSLFColor(ct, theme, phClr).getColor();
-        }
+        if(ct == null) return PaintStyle.TRANSPARENT_PAINT;
+            
+        CTSchemeColor phClr = ct.getSchemeClr();
+        final XSLFColor xc = new XSLFColor(ct, theme, phClr);
+        return new SolidPaint(){
+            public ColorStyle getSolidColor() {
+                return xc.getColorStyle();
+            }
+        };
     }
 }
\ No newline at end of file



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


Mime
View raw message