poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1704206 [2/2] - in /poi/trunk/src: examples/src/org/apache/poi/xslf/usermodel/ integrationtest/org/apache/poi/stress/ java/org/apache/poi/sl/draw/ java/org/apache/poi/sl/usermodel/ ooxml/java/org/apache/poi/xslf/usermodel/ ooxml/java/org/a...
Date Mon, 21 Sep 2015 00:09:58 GMT
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java Mon
Sep 21 00:09:45 2015
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hslf.usermodel;
 
+import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.GeneralPath;
 import java.awt.geom.PathIterator;
@@ -45,7 +46,6 @@ import org.apache.poi.util.Units;
  * Shapes drawn with the "Freeform" tool have cubic bezier curve segments in the smooth sections
  * and straight-line segments in the straight sections. This object closely corresponds to
<code>java.awt.geom.GeneralPath</code>.
  * </p>
- * @author Yegor Kozlov
  */
 public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFShape,HSLFTextParagraph>
{
 
@@ -90,7 +90,7 @@ public final class HSLFFreeformShape ext
 
     @Override
     public int setPath(GeneralPath path) {
-        Rectangle2D bounds = path.getBounds2D();
+        Rectangle bounds = path.getBounds();
         PathIterator it = path.getPathIterator(new AffineTransform());
 
         List<byte[]> segInfo = new ArrayList<byte[]>();
@@ -241,7 +241,7 @@ public final class HSLFFreeformShape ext
             }
         }
         
-        Rectangle2D anchor = getAnchor2D();
+        Rectangle2D anchor = getAnchor();
         Rectangle2D bounds = path.getBounds2D();
         AffineTransform at = new AffineTransform();
         at.translate(anchor.getX(), anchor.getY());

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java Mon Sep
21 00:09:45 2015
@@ -18,7 +18,6 @@
 package org.apache.poi.hslf.usermodel;
 
 import java.awt.Rectangle;
-import java.awt.geom.Rectangle2D;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -105,7 +104,7 @@ implements HSLFShapeContainer, GroupShap
     }
 
     @Override
-    public void setInteriorAnchor(Rectangle2D anchor){
+    public void setInteriorAnchor(Rectangle anchor){
         EscherSpgrRecord spgr = getEscherChild(EscherSpgrRecord.RECORD_ID);
 
         int x1 = Units.pointsToMaster(anchor.getX());
@@ -121,13 +120,13 @@ implements HSLFShapeContainer, GroupShap
     }
 
     @Override
-    public Rectangle2D getInteriorAnchor(){
+    public Rectangle getInteriorAnchor(){
         EscherSpgrRecord rec = getEscherChild(EscherSpgrRecord.RECORD_ID);
-        double x1 = Units.masterToPoints(rec.getRectX1());
-        double y1 = Units.masterToPoints(rec.getRectY1());
-        double x2 = Units.masterToPoints(rec.getRectX2());
-        double y2 = Units.masterToPoints(rec.getRectY2());
-        return new Rectangle2D.Double(x1,y1,x2-x1,y2-y1);
+        int x1 = (int)Units.masterToPoints(rec.getRectX1());
+        int y1 = (int)Units.masterToPoints(rec.getRectY1());
+        int x2 = (int)Units.masterToPoints(rec.getRectX2());
+        int y2 = (int)Units.masterToPoints(rec.getRectY2());
+        return new Rectangle(x1,y1,x2-x1,y2-y1);
     }
 
     /**
@@ -181,7 +180,7 @@ implements HSLFShapeContainer, GroupShap
      * @param y the y coordinate of the top left corner of the shape in new location
      */
     public void moveTo(int x, int y){
-        java.awt.Rectangle anchor = getAnchor();
+        Rectangle anchor = getAnchor();
         int dx = x - anchor.x;
         int dy = y - anchor.y;
         anchor.translate(dx, dy);
@@ -189,7 +188,7 @@ implements HSLFShapeContainer, GroupShap
 
         
         for (HSLFShape shape : getShapes()) {
-            java.awt.Rectangle chanchor = shape.getAnchor();
+            Rectangle chanchor = shape.getAnchor();
             chanchor.translate(dx, dy);
             shape.setAnchor(chanchor);
         }
@@ -201,7 +200,7 @@ implements HSLFShapeContainer, GroupShap
      *
      * @return the anchor of this shape group
      */
-    public Rectangle2D getAnchor2D(){
+    public Rectangle getAnchor(){
         EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
         int x1,y1,x2,y2;
         if(clientAnchor == null){
@@ -217,11 +216,11 @@ implements HSLFShapeContainer, GroupShap
             x2 = clientAnchor.getDx1();
             y2 = clientAnchor.getRow1();
         }
-        Rectangle2D anchor= new Rectangle2D.Double(
-            (x1 == -1 ? -1 : Units.masterToPoints(x1)),
-            (y1 == -1 ? -1 : Units.masterToPoints(y1)),
-            (x2 == -1 ? -1 : Units.masterToPoints(x2-x1)),
-            (y2 == -1 ? -1 : Units.masterToPoints(y2-y1))
+        Rectangle anchor= new Rectangle(
+            (int)(x1 == -1 ? -1 : Units.masterToPoints(x1)),
+            (int)(y1 == -1 ? -1 : Units.masterToPoints(y1)),
+            (int)(x2 == -1 ? -1 : Units.masterToPoints(x2-x1)),
+            (int)(y2 == -1 ? -1 : Units.masterToPoints(y2-y1))
         );
 
         return anchor;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureData.java Mon Sep
21 00:09:45 2015
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hslf.usermodel;
 
+import java.awt.Dimension;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.security.MessageDigest;
@@ -219,4 +220,13 @@ public abstract class HSLFPictureData im
     public final String getContentType() {
         return getType().contentType;
     }
+
+    @Override
+    public Dimension getImageDimensionInPixels() {
+        Dimension dim = getImageDimension();
+        return new Dimension(
+            Units.pointsToPixel(dim.getWidth()),
+            Units.pointsToPixel(dim.getHeight())
+        );
+    }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java Mon Sep
21 00:09:45 2015
@@ -17,9 +17,8 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import java.awt.Dimension;
 import java.awt.Insets;
-import java.awt.geom.Rectangle2D;
+import java.awt.Rectangle;
 import java.util.List;
 
 import org.apache.poi.ddf.AbstractEscherOptRecord;
@@ -31,6 +30,7 @@ import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSimpleProperty;
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hslf.record.Document;
+import org.apache.poi.sl.draw.DrawPictureShape;
 import org.apache.poi.sl.usermodel.PictureShape;
 import org.apache.poi.sl.usermodel.ShapeContainer;
 import org.apache.poi.sl.usermodel.ShapeType;
@@ -113,21 +113,6 @@ public class HSLFPictureShape extends HS
         return _escherContainer;
     }
 
-    /**
-     * Resize this picture to the default size.
-     * For PNG and JPEG resizes the image to 100%,
-     * for other types, if the size can't be determined it will be 200x200 pixels.
-     */
-    public void setDefaultSize(){
-        Dimension dim = getPictureData().getImageDimension();
-        Rectangle2D origRect = getAnchor2D();
-        double x = origRect.getX();
-        double y = origRect.getY();
-        double w = Units.pixelToPoints((int)dim.getWidth());
-        double h = Units.pixelToPoints((int)dim.getHeight());
-        setAnchor(new Rectangle2D.Double(x, y, w, h));
-    }
-
     @Override
     public HSLFPictureData getPictureData(){
         HSLFSlideShow ppt = getSheet().getSlideShow();
@@ -199,9 +184,9 @@ public class HSLFPictureShape extends HS
         EscherBSERecord bse = getEscherBSERecord();
         bse.setRef(bse.getRef() + 1);
 
-        java.awt.Rectangle anchor = getAnchor();
-        if (anchor.equals(new java.awt.Rectangle())){
-            setDefaultSize();
+        Rectangle anchor = getAnchor();
+        if (anchor.isEmpty()){
+            new DrawPictureShape(this).resize();
         }
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java Mon Sep 21 00:09:45
2015
@@ -19,14 +19,29 @@ package org.apache.poi.hslf.usermodel;
 
 import java.awt.Color;
 import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
+import java.awt.Rectangle;
 import java.util.Iterator;
 
-import org.apache.poi.ddf.*;
+import org.apache.poi.ddf.AbstractEscherOptRecord;
+import org.apache.poi.ddf.EscherChildAnchorRecord;
+import org.apache.poi.ddf.EscherClientAnchorRecord;
+import org.apache.poi.ddf.EscherColorRef;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherOptRecord;
+import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.ddf.EscherProperty;
+import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.ddf.EscherSimpleProperty;
+import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hslf.record.ColorSchemeAtom;
 import org.apache.poi.hslf.record.RecordTypes;
-import org.apache.poi.sl.usermodel.*;
-import org.apache.poi.util.*;
+import org.apache.poi.sl.usermodel.FillStyle;
+import org.apache.poi.sl.usermodel.Shape;
+import org.apache.poi.sl.usermodel.ShapeContainer;
+import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.Units;
 
 /**
  *  <p>
@@ -126,18 +141,7 @@ public abstract class HSLFShape implemen
      *
      * @return the anchor of this shape
      */
-    public java.awt.Rectangle getAnchor(){
-        Rectangle2D anchor2d = getAnchor2D();
-        return anchor2d.getBounds();
-    }
-
-    /**
-     * Returns the anchor (the bounding box rectangle) of this shape.
-     * All coordinates are expressed in points (72 dpi).
-     *
-     * @return the anchor of this shape
-     */
-    public Rectangle2D getAnchor2D(){
+    public Rectangle getAnchor() {
         EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
         int flags = spRecord.getFlags();
         int x1,y1,x2,y2;
@@ -160,11 +164,11 @@ public abstract class HSLFShape implemen
         }
 
         // TODO: find out where this -1 value comes from at #57820 (link to ms docs?)
-        Rectangle2D anchor = new Rectangle2D.Double(
-            (x1 == -1 ? -1 : Units.masterToPoints(x1)),
-            (y1 == -1 ? -1 : Units.masterToPoints(y1)),
-            (x2 == -1 ? -1 : Units.masterToPoints(x2-x1)),
-            (y2 == -1 ? -1 : Units.masterToPoints(y2-y1))
+        Rectangle anchor = new Rectangle(
+            (int)(x1 == -1 ? -1 : Units.masterToPoints(x1)),
+            (int)(y1 == -1 ? -1 : Units.masterToPoints(y1)),
+            (int)(x2 == -1 ? -1 : Units.masterToPoints(x2-x1)),
+            (int)(y2 == -1 ? -1 : Units.masterToPoints(y2-y1))
         );
         
         return anchor;
@@ -176,7 +180,7 @@ public abstract class HSLFShape implemen
      *
      * @param anchor new anchor
      */
-    public void setAnchor(Rectangle2D anchor){
+    public void setAnchor(Rectangle anchor){
         int x = Units.pointsToMaster(anchor.getX());
         int y = Units.pointsToMaster(anchor.getY());
         int w = Units.pointsToMaster(anchor.getWidth() + anchor.getX());
@@ -206,7 +210,7 @@ public abstract class HSLFShape implemen
      * @param y the y coordinate of the top left corner of the shape
      */
     public void moveTo(float x, float y){
-        Rectangle2D anchor = getAnchor2D();
+        Rectangle anchor = getAnchor();
         anchor.setRect(x, y, anchor.getWidth(), anchor.getHeight());
         setAnchor(anchor);
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java Mon Sep
21 00:09:45 2015
@@ -414,12 +414,12 @@ public abstract class HSLFSimpleShape ex
         return clr == null ? Color.black : clr;
     }    
     
-    public Shadow getShadow() {
+    public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
         AbstractEscherOptRecord opt = getEscherOptRecord();
         EscherProperty shadowType = opt.lookup(EscherProperties.SHADOWSTYLE__TYPE);
         if (shadowType == null) return null;
         
-        return new Shadow(){
+        return new Shadow<HSLFShape,HSLFTextParagraph>(){
             public SimpleShape<HSLFShape,HSLFTextParagraph> getShadowParent() {
                 return HSLFSimpleShape.this;
             }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java Mon Sep
21 00:09:45 2015
@@ -69,6 +69,7 @@ import org.apache.poi.hslf.record.SlideL
 import org.apache.poi.hslf.record.SlidePersistAtom;
 import org.apache.poi.hslf.record.UserEditAtom;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.sl.usermodel.MasterSheet;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
@@ -159,8 +160,8 @@ public final class HSLFSlideShow impleme
     /**
      * Constructs a Powerpoint document from an POIFSFileSystem.
      */
-    public HSLFSlideShow(POIFSFileSystem inputStream) throws IOException {
-        this(new HSLFSlideShowImpl(inputStream));
+    public HSLFSlideShow(NPOIFSFileSystem npoifs) throws IOException {
+        this(new HSLFSlideShowImpl(npoifs));
     }
 
     /**

Added: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowFactory.java?rev=1704206&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowFactory.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowFactory.java Mon
Sep 21 00:09:45 2015
@@ -0,0 +1,38 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.usermodel;
+
+import java.io.IOException;
+
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.sl.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.SlideShowFactory;
+import org.apache.poi.util.Internal;
+
+@Internal
+public class HSLFSlideShowFactory extends SlideShowFactory {
+    /**
+     * Creates a HSLFSlideShow from the given NPOIFSFileSystem
+     * <p>Note that in order to properly release resources the
+     *  SlideShow should be closed after use.
+     */
+    public static SlideShow<?,?> createSlideShow(NPOIFSFileSystem fs) throws IOException
{
+        return new HSLFSlideShow(fs);
+    }
+
+}

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java Mon Sep
21 00:09:45 2015
@@ -139,15 +139,15 @@ implements TextShape<HSLFShape,HSLFTextP
 
         storeText();
         
-        EscherTextboxWrapper _txtbox = getEscherTextboxWrapper();
-        if(_txtbox != null){
-            _escherContainer.addChildRecord(_txtbox.getEscherRecord());
+        EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
+        if(thisTxtbox != null){
+            _escherContainer.addChildRecord(thisTxtbox.getEscherRecord());
             
             PPDrawing ppdrawing = sh.getPPDrawing();
-            ppdrawing.addTextboxWrapper(_txtbox);
+            ppdrawing.addTextboxWrapper(thisTxtbox);
             // Ensure the escher layer knows about the added records
             try {
-                _txtbox.writeOut(null);
+                thisTxtbox.writeOut(null);
             } catch (IOException e){
                 throw new HSLFException(e);
             }
@@ -192,10 +192,10 @@ implements TextShape<HSLFShape,HSLFTextP
      * @return a <code>Rectangle2D</code> that is the bounds of this shape.
      */
     public Rectangle2D resizeToFitText(){
-        Rectangle2D anchor = getAnchor();
+        Rectangle anchor = getAnchor();
         if(anchor.getWidth() == 0.) {
             logger.log(POILogger.WARN, "Width of shape wasn't set. Defaulting to 200px");
-            anchor = new Rectangle2D.Double(anchor.getX(), anchor.getY(), 200, anchor.getHeight());
+            anchor.setSize(200, (int)anchor.getHeight());
             setAnchor(anchor);
         }
         double height = getTextHeight(); 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestMovieShape.java Mon Sep
21 00:09:45 2015
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import java.awt.geom.Rectangle2D;
+import java.awt.Rectangle;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 
@@ -34,8 +34,6 @@ import org.junit.Test;
 
 /**
  * Test <code>MovieShape</code> object.
- *
- * @author Yegor Kozlov
  */
 public final class TestMovieShape {
 
@@ -52,7 +50,7 @@ public final class TestMovieShape {
         HSLFPictureData thumbnailData = ppt.addPicture(_slTests.readFile("tomcat.png"), PictureType.PNG);
 
         MovieShape shape = new MovieShape(movieIdx, thumbnailData);
-        shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
+        shape.setAnchor(new Rectangle(300,225,120,90));
         slide.addShape(shape);
 
         assertEquals(path, shape.getPath());

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestOleEmbedding.java Mon
Sep 21 00:09:45 2015
@@ -20,18 +20,26 @@ package org.apache.poi.hslf.model;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
-import java.awt.geom.Rectangle2D;
-import java.io.*;
+import java.awt.Rectangle;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
 import java.util.List;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.usermodel.HSLFObjectData;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFShape;
+import org.apache.poi.hslf.usermodel.HSLFSlide;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFSlideShowImpl;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.util.IOUtils;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
+import org.apache.poi.util.IOUtils;
 import org.junit.Test;
 
 public final class TestOleEmbedding {
@@ -109,7 +117,7 @@ public final class TestOleEmbedding {
     	OLEShape oleShape1 = new OLEShape(pictData);
     	oleShape1.setObjectID(oleObjectId1);
     	slide1.addShape(oleShape1);
-    	oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100));
+    	oleShape1.setAnchor(new Rectangle(100,100,100,100));
     	
     	// add second slide with different order in object creation
     	HSLFSlide slide2 = ppt.createSlide();
@@ -123,7 +131,7 @@ public final class TestOleEmbedding {
 
         oleShape2.setObjectID(oleObjectId2);
         slide2.addShape(oleShape2);
-        oleShape2.setAnchor(new Rectangle2D.Double(100,100,100,100));
+        oleShape2.setAnchor(new Rectangle(100,100,100,100));
         
     	ByteArrayOutputStream bos = new ByteArrayOutputStream();
     	ppt.write(bos);

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Mon Sep 21
00:09:45 2015
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertTru
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Rectangle;
-import java.awt.geom.Rectangle2D;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -63,8 +62,6 @@ import org.junit.Test;
 
 /**
  * Test drawing shapes via Graphics2D
- *
- * @author Yegor Kozlov
  */
 public final class TestShapes {
     private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
@@ -165,8 +162,8 @@ public final class TestShapes {
     @SuppressWarnings("unused")
     @Test
     public void testParagraphs() throws Exception {
-        HSLFSlideShow ppt = new HSLFSlideShow();
-        HSLFSlide slide = ppt.createSlide();
+        HSLFSlideShow ss = new HSLFSlideShow();
+        HSLFSlide slide = ss.createSlide();
         HSLFTextBox shape = new HSLFTextBox();
         HSLFTextRun p1r1 = shape.setText("para 1 run 1. ");
         HSLFTextRun p1r2 = shape.appendText("para 1 run 2.", false);
@@ -178,15 +175,15 @@ public final class TestShapes {
         p2r2.setStrikethrough(true);
         // run 3 has same text properties as run 2 and will be merged when saving
         HSLFTextRun p2r3 = shape.appendText("para 2 run 3.", false);
-        shape.setAnchor(new Rectangle2D.Double(100,100,100,10));
+        shape.setAnchor(new Rectangle(100,100,100,10));
         slide.addShape(shape);
         shape.resizeToFitText();
         
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        ppt.write(bos);
+        ss.write(bos);
         
-        ppt = new HSLFSlideShow(new ByteArrayInputStream(bos.toByteArray()));
-        slide = ppt.getSlides().get(0);
+        ss = new HSLFSlideShow(new ByteArrayInputStream(bos.toByteArray()));
+        slide = ss.getSlides().get(0);
         HSLFTextBox tb = (HSLFTextBox)slide.getShapes().get(0);
         List<HSLFTextParagraph> para = tb.getTextParagraphs();
         HSLFTextRun tr = para.get(0).getTextRuns().get(0);
@@ -289,8 +286,8 @@ public final class TestShapes {
     }
 
     private void textBoxSet(String filename) throws Exception {
-        HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(filename));
-        for (HSLFSlide sld : ppt.getSlides()) {
+        HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream(filename));
+        for (HSLFSlide sld : ss.getSlides()) {
             ArrayList<String> lst1 = new ArrayList<String>();
             for (List<HSLFTextParagraph> txt : sld.getTextParagraphs()) {
                 for (HSLFTextParagraph p : txt) {
@@ -321,17 +318,17 @@ public final class TestShapes {
      */
     @Test
     public void shapeGroup() throws Exception {
-        HSLFSlideShow ppt = new HSLFSlideShow();
+        HSLFSlideShow ss = new HSLFSlideShow();
 
-        HSLFSlide slide = ppt.createSlide();
-        Dimension pgsize = ppt.getPageSize();
+        HSLFSlide slide = ss.createSlide();
+        Dimension pgsize = ss.getPageSize();
 
         HSLFGroupShape group = new HSLFGroupShape();
 
         group.setAnchor(new Rectangle(0, 0, (int)pgsize.getWidth(), (int)pgsize.getHeight()));
         slide.addShape(group);
 
-        HSLFPictureData data = ppt.addPicture(_slTests.readFile("clock.jpg"), PictureType.JPEG);
+        HSLFPictureData data = ss.addPicture(_slTests.readFile("clock.jpg"), PictureType.JPEG);
         HSLFPictureShape pict = new HSLFPictureShape(data, group);
         pict.setAnchor(new Rectangle(0, 0, 200, 200));
         group.addShape(pict);
@@ -342,14 +339,14 @@ public final class TestShapes {
 
         //serialize and read again.
         ByteArrayOutputStream  out = new ByteArrayOutputStream();
-        ppt.write(out);
+        ss.write(out);
         out.close();
 
         ByteArrayInputStream is = new ByteArrayInputStream(out.toByteArray());
-        ppt = new HSLFSlideShow(is);
+        ss = new HSLFSlideShow(is);
         is.close();
 
-        slide = ppt.getSlides().get(0);
+        slide = ss.getSlides().get(0);
 
         List<HSLFShape> shape = slide.getShapes();
         assertEquals(1, shape.size());
@@ -374,8 +371,8 @@ public final class TestShapes {
     @Test
     public void removeShapes() throws IOException {
         String file = "with_textbox.ppt";
-        HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream(file));
-        HSLFSlide sl = ppt.getSlides().get(0);
+        HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream(file));
+        HSLFSlide sl = ss.getSlides().get(0);
         List<HSLFShape> sh = sl.getShapes();
         assertEquals("expected four shaped in " + file, 4, sh.size());
         //remove all
@@ -388,11 +385,11 @@ public final class TestShapes {
 
         //serialize and read again. The file should be readable and contain no shapes
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        ppt.write(out);
+        ss.write(out);
         out.close();
 
-        ppt = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
-        sl = ppt.getSlides().get(0);
+        ss = new HSLFSlideShow(new ByteArrayInputStream(out.toByteArray()));
+        sl = ss.getSlides().get(0);
         assertEquals("expected 0 shaped in " + file, 0, sl.getShapes().size());
     }
 
@@ -413,12 +410,12 @@ public final class TestShapes {
 
     @Test
     public void shapeId() {
-        HSLFSlideShow ppt = new HSLFSlideShow();
-        HSLFSlide slide = ppt.createSlide();
+        HSLFSlideShow ss = new HSLFSlideShow();
+        HSLFSlide slide = ss.createSlide();
         HSLFShape shape = null;
 
         //EscherDgg is a document-level record which keeps track of the drawing groups
-        EscherDggRecord dgg = ppt.getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
+        EscherDggRecord dgg = ss.getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
         EscherDgRecord dg = slide.getSheetContainer().getPPDrawing().getEscherDgRecord();
 
         int dggShapesUsed = dgg.getNumShapesSaved();   //total number of shapes in the ppt
@@ -463,8 +460,8 @@ public final class TestShapes {
 
     @Test
     public void lineColor() throws IOException {
-        HSLFSlideShow ppt = new HSLFSlideShow(_slTests.openResourceAsStream("51731.ppt"));
-        List<HSLFShape> shape = ppt.getSlides().get(0).getShapes();
+        HSLFSlideShow ss = new HSLFSlideShow(_slTests.openResourceAsStream("51731.ppt"));
+        List<HSLFShape> shape = ss.getSlides().get(0).getShapes();
 
         assertEquals(4, shape.size());
 

Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShowFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShowFactory.java?rev=1704206&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShowFactory.java
(added)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestHSLFSlideShowFactory.java
Mon Sep 21 00:09:45 2015
@@ -0,0 +1,28 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.usermodel;
+
+import org.apache.poi.sl.usermodel.BaseTestSlideShowFactory;
+import org.junit.Test;
+
+public final class TestHSLFSlideShowFactory extends BaseTestSlideShowFactory {
+    @Test
+    public void testFactory() throws Exception {
+        testFactory("pictures.ppt", "Password_Protected-hello.ppt", "hello");
+    }
+}

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPictures.java Mon
Sep 21 00:09:45 2015
@@ -35,6 +35,7 @@ import org.apache.poi.hslf.blip.PICT;
 import org.apache.poi.hslf.blip.PNG;
 import org.apache.poi.hslf.blip.WMF;
 import org.apache.poi.sl.usermodel.PictureData.PictureType;
+import org.apache.poi.util.Units;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -46,8 +47,6 @@ import org.junit.Test;
 public final class TestPictures {
     private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
 
-    //protected File cwd;
-
     /**
      * Test read/write Macintosh PICT
      */
@@ -64,9 +63,9 @@ public final class TestPictures {
         assertEquals(expWidth, nDim.getWidth(), 0);
         assertEquals(expHeight, nDim.getHeight(), 0);
         
-        Dimension dim = data.getImageDimension();
-        assertEquals(expWidth, dim.getWidth(), 0);
-        assertEquals(expHeight, dim.getHeight(), 0);
+        Dimension dim = data.getImageDimensionInPixels();
+        assertEquals(Units.pointsToPixel(expWidth), dim.getWidth(), 0);
+        assertEquals(Units.pointsToPixel(expHeight), dim.getHeight(), 0);
         
         HSLFPictureShape pict = new HSLFPictureShape(data);
         assertEquals(data.getIndex(), pict.getPictureIndex());
@@ -127,9 +126,9 @@ public final class TestPictures {
         assertEquals(expWidth, nDim.getWidth(), 0);
         assertEquals(expHeight, nDim.getHeight(), 0);
 
-        Dimension dim = data.getImageDimension();
-        assertEquals(expWidth, dim.getWidth(), 0);
-        assertEquals(expHeight, dim.getHeight(), 0);
+        Dimension dim = data.getImageDimensionInPixels();
+        assertEquals(Units.pointsToPixel(expWidth), dim.getWidth(), 0);
+        assertEquals(Units.pointsToPixel(expHeight), dim.getHeight(), 0);
         
         HSLFPictureShape pict = new HSLFPictureShape(data);
         assertEquals(data.getIndex(), pict.getPictureIndex());
@@ -189,9 +188,9 @@ public final class TestPictures {
         assertEquals(expWidth, nDim.getWidth(), 0);
         assertEquals(expHeight, nDim.getHeight(), 0);
 
-        Dimension dim = data.getImageDimension();
-        assertEquals(expWidth, dim.getWidth(), 0);
-        assertEquals(expHeight, dim.getHeight(), 0);
+        Dimension dim = data.getImageDimensionInPixels();
+        assertEquals(Units.pointsToPixel(expWidth), dim.getWidth(), 0);
+        assertEquals(Units.pointsToPixel(expHeight), dim.getHeight(), 0);
         
         HSLFPictureShape pict = new HSLFPictureShape(data);
         assertEquals(data.getIndex(), pict.getPictureIndex());

Modified: poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java?rev=1704206&r1=1704205&r2=1704206&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/sl/draw/geom/TestPresetGeometries.java Mon Sep
21 00:09:45 2015
@@ -22,19 +22,14 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.awt.Rectangle;
 import java.awt.geom.GeneralPath;
-import java.awt.geom.Rectangle2D;
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.Map;
 
 import org.junit.Test;
 
-/**
- * Date: 10/24/11
- *
- * @author Yegor Kozlov
- */
 public class TestPresetGeometries {
     @Test
     public void testRead(){
@@ -43,8 +38,8 @@ public class TestPresetGeometries {
 
         for(String name : shapes.keySet()) {
             CustomGeometry geom = shapes.get(name);
-            Context ctx = new Context(geom, new Rectangle2D.Double(0, 0, 100, 100), new IAdjustableShape()
{
-                public Guide getAdjustValue(String name) {
+            Context ctx = new Context(geom, new Rectangle(0, 0, 100, 100), new IAdjustableShape()
{
+                public Guide getAdjustValue(String presetName) {
                     return null;
                 }
             });

Added: poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java?rev=1704206&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShowFactory.java Mon
Sep 21 00:09:45 2015
@@ -0,0 +1,73 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.sl.usermodel;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+
+public class BaseTestSlideShowFactory {
+    private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
+
+    public void testFactory(String file, String protectedFile, String password)
+    throws Exception {
+        SlideShow<?,?> ss;
+        // from file
+        ss = SlideShowFactory.create(fromFile(file));
+        assertNotNull(ss);
+        // from stream
+        ss = SlideShowFactory.create(fromStream(file));
+        assertNotNull(ss);
+        // from NPOIFS
+        if (!file.contains("pptx")) {
+            NPOIFSFileSystem npoifs = new NPOIFSFileSystem(fromFile(file));
+            ss = SlideShowFactory.create(npoifs);
+            assertNotNull(ss);
+            npoifs.close();
+        }
+        // from protected file
+        ss = SlideShowFactory.create(fromFile(protectedFile), password);
+        assertNotNull(ss);
+        // from protected stream
+        ss = SlideShowFactory.create(fromStream(protectedFile), password);
+        assertNotNull(ss);
+        // from protected NPOIFS
+        NPOIFSFileSystem npoifs = new NPOIFSFileSystem(fromFile(protectedFile));
+        ss = SlideShowFactory.create(npoifs, password);
+        assertNotNull(ss);
+        npoifs.close();
+    }
+    
+    private static File fromFile(String file) {
+        return (file.contains("/") || file.contains("\\"))
+            ? new File(file)
+            : _slTests.getFile(file);
+    }
+
+    private static InputStream fromStream(String file) throws IOException {
+        return (file.contains("/") || file.contains("\\"))
+            ? new FileInputStream(file)
+            : _slTests.openResourceAsStream(file);
+    }
+}




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


Mime
View raw message