poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1693825 [2/2] - in /poi: site/src/documentation/content/xdocs/ site/src/documentation/content/xdocs/slideshow/ trunk/src/examples/src/org/apache/poi/hslf/examples/ trunk/src/examples/src/org/apache/poi/xslf/usermodel/ trunk/src/java/org/ap...
Date Sun, 02 Aug 2015 20:21:36 GMT
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java?rev=1693825&r1=1693824&r2=1693825&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java Sun Aug
 2 20:21:35 2015
@@ -33,7 +33,15 @@ import org.apache.poi.ddf.EscherProperti
 import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.ddf.EscherSimpleProperty;
 import org.apache.poi.hslf.record.Document;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.usermodel.HSLFAutoShape;
+import org.apache.poi.hslf.usermodel.HSLFFill;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFShape;
+import org.apache.poi.hslf.usermodel.HSLFSheet;
+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.sl.usermodel.PictureData.PictureType;
 import org.apache.poi.sl.usermodel.ShapeType;
 import org.junit.Test;
 
@@ -104,15 +112,15 @@ public final class TestBackground {
         HSLFSlide slide;
         HSLFFill fill;
         HSLFShape shape;
-        int idx;
+        HSLFPictureData data;
 
         //slide 1
         slide = ppt.createSlide();
         slide.setFollowMasterBackground(false);
         fill = slide.getBackground().getFill();
-        idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+        data = ppt.addPicture(_slTests.readFile("tomcat.png"), PictureType.PNG);
         fill.setFillType(HSLFFill.FILL_PICTURE);
-        fill.setPictureData(idx);
+        fill.setPictureData(data);
 
         shape = new HSLFAutoShape(ShapeType.RECT);
         shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
@@ -124,9 +132,9 @@ public final class TestBackground {
         slide = ppt.createSlide();
         slide.setFollowMasterBackground(false);
         fill = slide.getBackground().getFill();
-        idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+        data = ppt.addPicture(_slTests.readFile("tomcat.png"), PictureType.PNG);
         fill.setFillType(HSLFFill.FILL_PATTERN);
-        fill.setPictureData(idx);
+        fill.setPictureData(data);
         fill.setBackgroundColor(Color.green);
         fill.setForegroundColor(Color.red);
 
@@ -140,16 +148,16 @@ public final class TestBackground {
         slide = ppt.createSlide();
         slide.setFollowMasterBackground(false);
         fill = slide.getBackground().getFill();
-        idx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+        data = ppt.addPicture(_slTests.readFile("tomcat.png"), PictureType.PNG);
         fill.setFillType(HSLFFill.FILL_TEXTURE);
-        fill.setPictureData(idx);
+        fill.setPictureData(data);
 
         shape = new HSLFAutoShape(ShapeType.RECT);
         shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
         fill = shape.getFill();
         fill.setFillType(HSLFFill.FILL_PICTURE);
-        idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG);
-        fill.setPictureData(idx);
+        data = ppt.addPicture(_slTests.readFile("clock.jpg"), PictureType.JPEG);
+        fill.setPictureData(data);
         slide.addShape(shape);
 
         // slide 4
@@ -198,7 +206,6 @@ public final class TestBackground {
         assertEquals(HSLFFill.FILL_SHADE_CENTER, fill.getFillType());
         shape = slides.get(3).getShapes().get(0);
         assertEquals(HSLFFill.FILL_SHADE, shape.getFill().getFillType());
-
     }
 
     private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) {

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=1693825&r1=1693824&r2=1693825&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 Sun Aug
 2 20:21:35 2015
@@ -17,14 +17,19 @@
 
 package org.apache.poi.hslf.model;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.awt.geom.Rectangle2D;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFSlide;
+import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.junit.Test;
 
 /**
@@ -44,9 +49,9 @@ public final class TestMovieShape {
 
         String path = "/test-movie.mpg";
         int movieIdx = ppt.addMovie(path, MovieShape.MOVIE_MPEG);
-        int thumbnailIdx = ppt.addPicture(_slTests.readFile("tomcat.png"), HSLFPictureShape.PNG);
+        HSLFPictureData thumbnailData = ppt.addPicture(_slTests.readFile("tomcat.png"), PictureType.PNG);
 
-        MovieShape shape = new MovieShape(movieIdx, thumbnailIdx);
+        MovieShape shape = new MovieShape(movieIdx, thumbnailData);
         shape.setAnchor(new Rectangle2D.Float(300,225,120,90));
         slide.addShape(shape);
 

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=1693825&r1=1693824&r2=1693825&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 Sun
Aug  2 20:21:35 2015
@@ -30,6 +30,7 @@ import org.apache.poi.hssf.usermodel.HSS
 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.junit.Test;
 
 public final class TestOleEmbedding {
@@ -95,7 +96,7 @@ public final class TestOleEmbedding {
     	HSLFSlideShow ppt = new HSLFSlideShow(_hslfSlideShow);
     	
     	File pict = POIDataSamples.getSlideShowInstance().getFile("clock.jpg");
-    	int pictId = ppt.addPicture(pict, HSLFPictureShape.JPEG);
+    	HSLFPictureData pictData = ppt.addPicture(pict, PictureType.JPEG);
     	
     	InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("Employee.xls");
     	POIFSFileSystem poiData1 = new POIFSFileSystem(is);
@@ -104,14 +105,14 @@ public final class TestOleEmbedding {
     	int oleObjectId1 = ppt.addEmbed(poiData1);
     	
     	HSLFSlide slide1 = ppt.createSlide();
-    	OLEShape oleShape1 = new OLEShape(pictId);
+    	OLEShape oleShape1 = new OLEShape(pictData);
     	oleShape1.setObjectID(oleObjectId1);
     	slide1.addShape(oleShape1);
     	oleShape1.setAnchor(new Rectangle2D.Double(100,100,100,100));
     	
     	// add second slide with different order in object creation
     	HSLFSlide slide2 = ppt.createSlide();
-    	OLEShape oleShape2 = new OLEShape(pictId);
+    	OLEShape oleShape2 = new OLEShape(pictData);
 
         is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("SimpleWithImages.xls");
         POIFSFileSystem poiData2 = new POIFSFileSystem(is);

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=1693825&r1=1693824&r2=1693825&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 Sun Aug 
2 20:21:35 2015
@@ -17,19 +17,45 @@
 
 package org.apache.poi.hslf.model;
 
-import static org.junit.Assert.*;
-
-import java.awt.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Rectangle;
 import java.awt.geom.Rectangle2D;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.poi.POIDataSamples;
-import org.apache.poi.ddf.*;
-import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.ddf.EscherDgRecord;
+import org.apache.poi.ddf.EscherDggRecord;
+import org.apache.poi.ddf.EscherOptRecord;
+import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.ddf.EscherSimpleProperty;
+import org.apache.poi.hslf.usermodel.HSLFAutoShape;
+import org.apache.poi.hslf.usermodel.HSLFGroupShape;
+import org.apache.poi.hslf.usermodel.HSLFPictureData;
+import org.apache.poi.hslf.usermodel.HSLFPictureShape;
+import org.apache.poi.hslf.usermodel.HSLFShape;
+import org.apache.poi.hslf.usermodel.HSLFSimpleShape;
+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.hslf.usermodel.HSLFTextBox;
+import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
+import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFTextShape;
 import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -303,8 +329,8 @@ public final class TestShapes {
         group.setAnchor(new Rectangle(0, 0, (int)pgsize.getWidth(), (int)pgsize.getHeight()));
         slide.addShape(group);
 
-        int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG);
-        HSLFPictureShape pict = new HSLFPictureShape(idx, group);
+        HSLFPictureData data = ppt.addPicture(_slTests.readFile("clock.jpg"), PictureType.JPEG);
+        HSLFPictureShape pict = new HSLFPictureShape(data, group);
         pict.setAnchor(new Rectangle(0, 0, 200, 200));
         group.addShape(pict);
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1693825&r1=1693824&r2=1693825&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Sun Aug
 2 20:21:35 2015
@@ -17,11 +17,16 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import static org.junit.Assert.*;
-
-import java.awt.Color;
-import java.awt.Rectangle;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -39,15 +44,16 @@ import org.apache.poi.ddf.EscherOptRecor
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hslf.model.*;
-import org.apache.poi.hslf.model.textproperties.TextPropCollection;
-import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
-import org.apache.poi.hslf.record.*;
+import org.apache.poi.hslf.model.HeadersFooters;
+import org.apache.poi.hslf.record.Document;
+import org.apache.poi.hslf.record.Record;
+import org.apache.poi.hslf.record.SlideListWithText;
 import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
-import org.apache.poi.poifs.filesystem.DocumentEntry;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.util.*;
-import org.junit.Ignore;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.StringUtil;
+import org.apache.poi.util.Units;
 import org.junit.Test;
 
 /**
@@ -73,8 +79,8 @@ public final class TestBugs {
 
         HSLFPictureData[] pict = ppt.getPictureData();
         assertEquals(2, pict.length);
-        assertEquals(HSLFPictureShape.JPEG, pict[0].getType());
-        assertEquals(HSLFPictureShape.JPEG, pict[1].getType());
+        assertEquals(PictureType.JPEG, pict[0].getType());
+        assertEquals(PictureType.JPEG, pict[1].getType());
     }
 
     /**
@@ -354,7 +360,7 @@ public final class TestBugs {
 
         HSLFPictureData pict = f.getPictureData();
         assertNotNull(pict);
-        assertEquals(HSLFPictureShape.JPEG, pict.getType());
+        assertEquals(PictureType.JPEG, pict.getType());
     }
 
     /**

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java?rev=1693825&r1=1693824&r2=1693825&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestPicture.java Sun
Aug  2 20:21:35 2015
@@ -17,13 +17,24 @@
 
 package org.apache.poi.hslf.usermodel;
 
-import static org.junit.Assert.*;
-
-import java.awt.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
 import java.awt.image.BufferedImage;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
 import java.lang.reflect.Constructor;
-import java.util.*;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.imageio.ImageIO;
 
@@ -31,6 +42,7 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.ddf.EscherBSERecord;
 import org.apache.poi.hssf.usermodel.DummyGraphics2d;
 import org.apache.poi.sl.draw.Drawable;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.util.JvmBugs;
@@ -58,10 +70,10 @@ public final class TestPicture {
         HSLFSlide s2 = ppt.createSlide();
         HSLFSlide s3 = ppt.createSlide();
 
-        int idx = ppt.addPicture(_slTests.readFile("clock.jpg"), HSLFPictureShape.JPEG);
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        HSLFPictureShape pict2 = new HSLFPictureShape(idx);
-        HSLFPictureShape pict3 = new HSLFPictureShape(idx);
+        HSLFPictureData data = ppt.addPicture(_slTests.readFile("clock.jpg"), PictureType.JPEG);
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        HSLFPictureShape pict2 = new HSLFPictureShape(data);
+        HSLFPictureShape pict3 = new HSLFPictureShape(data);
 
         pict.setAnchor(new Rectangle(10,10,100,100));
         s.addShape(pict);
@@ -89,8 +101,9 @@ public final class TestPicture {
     public void bug46122() {
         HSLFSlideShow ppt = new HSLFSlideShow();
         HSLFSlide slide = ppt.createSlide();
-
-        HSLFPictureShape pict = new HSLFPictureShape(-1); //index to non-existing picture
data
+        HSLFPictureData pd = HSLFPictureData.create(PictureType.PNG);
+        
+        HSLFPictureShape pict = new HSLFPictureShape(pd); //index to non-existing picture
data
         pict.setSheet(slide);
         HSLFPictureData data = pict.getPictureData();
         assertNull(data);
@@ -125,15 +138,19 @@ public final class TestPicture {
                 null            // EMF
         };
 
-        for (int i = 0; i < pictures.length; i++) {
-            BufferedImage image = ImageIO.read(new ByteArrayInputStream(pictures[i].getData()));
-
-            if (pictures[i].getType() != HSLFPictureShape.WMF && pictures[i].getType()
!= HSLFPictureShape.EMF) {
-                assertNotNull(image);
-
-                int[] dimensions = expectedSizes[i];
-                assertEquals(dimensions[0], image.getWidth());
-                assertEquals(dimensions[1], image.getHeight());
+        int i = 0;
+        for (HSLFPictureData pd : pictures) {
+            int[] dimensions = expectedSizes[i++];
+            BufferedImage image = ImageIO.read(new ByteArrayInputStream(pd.getData()));
+            switch (pd.getType()) {
+                case WMF:
+                case EMF:
+                    break;
+                default:
+                    assertNotNull(image);
+                    assertEquals(dimensions[0], image.getWidth());
+                    assertEquals(dimensions[1], image.getHeight());
+                    break;
             }
         }
     }

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=1693825&r1=1693824&r2=1693825&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 Sun
Aug  2 20:21:35 2015
@@ -28,6 +28,7 @@ import junit.framework.TestCase;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hslf.blip.*;
+import org.apache.poi.sl.usermodel.PictureData.PictureType;
 
 /**
  * Test adding/reading pictures
@@ -47,9 +48,9 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] src_bytes = slTests.readFile("cow.pict");
-        int idx = ppt.addPicture(src_bytes, HSLFPictureShape.PICT);
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        assertEquals(idx, pict.getPictureIndex());
+        HSLFPictureData data = ppt.addPicture(src_bytes, PictureType.PICT);
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        assertEquals(data.getIndex(), pict.getPictureIndex());
         slide.addShape(pict);
 
         //serialize and read again
@@ -63,7 +64,7 @@ public final class TestPictures extends
         List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
         assertEquals(1, sh.size());
         pict = (HSLFPictureShape)sh.get(0);
-        assertEquals(idx, pict.getPictureIndex());
+        assertEquals(data.getIndex(), pict.getPictureIndex());
 
         //check picture data
         HSLFPictureData[] pictures = ppt.getPictureData();
@@ -71,7 +72,7 @@ public final class TestPictures extends
         assertEquals(pict.getPictureData(), pictures[0]);
 
         assertEquals(1, pictures.length);
-        assertEquals(HSLFPictureShape.PICT, pictures[0].getType());
+        assertEquals(PictureType.PICT, pictures[0].getType());
         assertTrue(pictures[0] instanceof PICT);
         //compare the content of the initial file with what is stored in the PictureData
         byte[] ppt_bytes = pictures[0].getData();
@@ -92,9 +93,9 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] src_bytes = slTests.readFile("santa.wmf");
-        int idx = ppt.addPicture(src_bytes, HSLFPictureShape.WMF);
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        assertEquals(idx, pict.getPictureIndex());
+        HSLFPictureData data = ppt.addPicture(src_bytes, PictureType.WMF);
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        assertEquals(data.getIndex(), pict.getPictureIndex());
         slide.addShape(pict);
 
         //serialize and read again
@@ -108,7 +109,7 @@ public final class TestPictures extends
         List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
         assertEquals(1, sh.size());
         pict = (HSLFPictureShape)sh.get(0);
-        assertEquals(idx, pict.getPictureIndex());
+        assertEquals(data.getIndex(), pict.getPictureIndex());
 
         //check picture data
         HSLFPictureData[] pictures = ppt.getPictureData();
@@ -116,7 +117,7 @@ public final class TestPictures extends
         assertEquals(pict.getPictureData(), pictures[0]);
 
         assertEquals(1, pictures.length);
-        assertEquals(HSLFPictureShape.WMF, pictures[0].getType());
+        assertEquals(PictureType.WMF, pictures[0].getType());
         assertTrue(pictures[0] instanceof WMF);
         //compare the content of the initial file with what is stored in the PictureData
         byte[] ppt_bytes = pictures[0].getData();
@@ -137,10 +138,10 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] src_bytes = slTests.readFile("wrench.emf");
-        int idx = ppt.addPicture(src_bytes, HSLFPictureShape.EMF);
+        HSLFPictureData data = ppt.addPicture(src_bytes, PictureType.EMF);
 
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        assertEquals(idx, pict.getPictureIndex());
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        assertEquals(data.getIndex(), pict.getPictureIndex());
         slide.addShape(pict);
 
         //serialize and read again
@@ -154,7 +155,7 @@ public final class TestPictures extends
         List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
         assertEquals(1, sh.size());
         pict = (HSLFPictureShape)sh.get(0);
-        assertEquals(idx, pict.getPictureIndex());
+        assertEquals(data.getIndex(), pict.getPictureIndex());
 
         //check picture data
         HSLFPictureData[] pictures = ppt.getPictureData();
@@ -162,7 +163,7 @@ public final class TestPictures extends
         assertEquals(pict.getPictureData(), pictures[0]);
 
         assertEquals(1, pictures.length);
-        assertEquals(HSLFPictureShape.EMF, pictures[0].getType());
+        assertEquals(PictureType.EMF, pictures[0].getType());
         assertTrue(pictures[0] instanceof EMF);
         //compare the content of the initial file with what is stored in the PictureData
         byte[] ppt_bytes = pictures[0].getData();
@@ -177,9 +178,9 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] src_bytes = slTests.readFile("tomcat.png");
-        int idx = ppt.addPicture(src_bytes, HSLFPictureShape.PNG);
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        assertEquals(idx, pict.getPictureIndex());
+        HSLFPictureData data = ppt.addPicture(src_bytes, PictureType.PNG);
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        assertEquals(data.getIndex(), pict.getPictureIndex());
         slide.addShape(pict);
 
         //serialize and read again
@@ -193,7 +194,7 @@ public final class TestPictures extends
         List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
         assertEquals(1, sh.size());
         pict = (HSLFPictureShape)sh.get(0);
-        assertEquals(idx, pict.getPictureIndex());
+        assertEquals(data.getIndex(), pict.getPictureIndex());
 
         //check picture data
         HSLFPictureData[] pictures = ppt.getPictureData();
@@ -201,7 +202,7 @@ public final class TestPictures extends
         assertEquals(pict.getPictureData(), pictures[0]);
 
         assertEquals(1, pictures.length);
-        assertEquals(HSLFPictureShape.PNG, pictures[0].getType());
+        assertEquals(PictureType.PNG, pictures[0].getType());
         assertTrue(pictures[0] instanceof PNG);
         //compare the content of the initial file with what is stored in the PictureData
         byte[] ppt_bytes = pictures[0].getData();
@@ -216,10 +217,10 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] src_bytes = slTests.readFile("clock.jpg");
-        int idx = ppt.addPicture(src_bytes, HSLFPictureShape.JPEG);
+        HSLFPictureData data = ppt.addPicture(src_bytes, PictureType.JPEG);
 
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        assertEquals(idx, pict.getPictureIndex());
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        assertEquals(data.getIndex(), pict.getPictureIndex());
         slide.addShape(pict);
 
         //serialize and read again
@@ -233,7 +234,7 @@ public final class TestPictures extends
         List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
         assertEquals(1, sh.size());
         pict = (HSLFPictureShape)sh.get(0);
-        assertEquals(idx, pict.getPictureIndex());
+        assertEquals(data.getIndex(), pict.getPictureIndex());
 
         //check picture data
         HSLFPictureData[] pictures = ppt.getPictureData();
@@ -241,7 +242,7 @@ public final class TestPictures extends
         assertEquals(pict.getPictureData(), pictures[0]);
 
         assertEquals(1, pictures.length);
-        assertEquals(HSLFPictureShape.JPEG, pictures[0].getType());
+        assertEquals(PictureType.JPEG, pictures[0].getType());
         assertTrue(pictures[0] instanceof JPEG);
         //compare the content of the initial file with what is stored in the PictureData
         byte[] ppt_bytes = pictures[0].getData();
@@ -256,9 +257,9 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] src_bytes = slTests.readFile("clock.dib");
-        int idx = ppt.addPicture(src_bytes, HSLFPictureShape.DIB);
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
-        assertEquals(idx, pict.getPictureIndex());
+        HSLFPictureData data = ppt.addPicture(src_bytes, PictureType.DIB);
+        HSLFPictureShape pict = new HSLFPictureShape(data);
+        assertEquals(data.getIndex(), pict.getPictureIndex());
         slide.addShape(pict);
 
         //serialize and read again
@@ -272,7 +273,7 @@ public final class TestPictures extends
         List<HSLFShape> sh = ppt.getSlides().get(0).getShapes();
         assertEquals(1, sh.size());
         pict = (HSLFPictureShape)sh.get(0);
-        assertEquals(idx, pict.getPictureIndex());
+        assertEquals(data.getIndex(), pict.getPictureIndex());
 
         //check picture data
         HSLFPictureData[] pictures = ppt.getPictureData();
@@ -280,7 +281,7 @@ public final class TestPictures extends
         assertEquals(pict.getPictureData(), pictures[0]);
 
         assertEquals(1, pictures.length);
-        assertEquals(HSLFPictureShape.DIB, pictures[0].getType());
+        assertEquals(PictureType.DIB, pictures[0].getType());
         assertTrue(pictures[0] instanceof DIB);
         //compare the content of the initial file with what is stored in the PictureData
         byte[] ppt_bytes = pictures[0].getData();
@@ -304,7 +305,7 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(0).getShapes().get(0); //the first slide contains
JPEG
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof JPEG);
-        assertEquals(HSLFPictureShape.JPEG, pdata.getType());
+        assertEquals(PictureType.JPEG, pdata.getType());
         src_bytes = pdata.getData();
         ppt_bytes = slTests.readFile("clock.jpg");
         assertArrayEquals(src_bytes, ppt_bytes);
@@ -312,7 +313,7 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(1).getShapes().get(0); //the second slide contains
PNG
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof PNG);
-        assertEquals(HSLFPictureShape.PNG, pdata.getType());
+        assertEquals(PictureType.PNG, pdata.getType());
         src_bytes = pdata.getData();
         ppt_bytes = slTests.readFile("tomcat.png");
         assertArrayEquals(src_bytes, ppt_bytes);
@@ -320,7 +321,7 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(2).getShapes().get(0); //the third slide contains
WMF
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
-        assertEquals(HSLFPictureShape.WMF, pdata.getType());
+        assertEquals(PictureType.WMF, pdata.getType());
         src_bytes = pdata.getData();
         ppt_bytes = slTests.readFile("santa.wmf");
         assertEquals(src_bytes.length, ppt_bytes.length);
@@ -334,7 +335,7 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(3).getShapes().get(0); //the forth slide contains
PICT
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof PICT);
-        assertEquals(HSLFPictureShape.PICT, pdata.getType());
+        assertEquals(PictureType.PICT, pdata.getType());
         src_bytes = pdata.getData();
         ppt_bytes = slTests.readFile("cow.pict");
         assertEquals(src_bytes.length, ppt_bytes.length);
@@ -348,7 +349,7 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(4).getShapes().get(0); //the fifth slide contains
EMF
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof EMF);
-        assertEquals(HSLFPictureShape.EMF, pdata.getType());
+        assertEquals(PictureType.EMF, pdata.getType());
         src_bytes = pdata.getData();
         ppt_bytes = slTests.readFile("wrench.emf");
         assertArrayEquals(src_bytes, ppt_bytes);
@@ -365,8 +366,8 @@ public final class TestPictures extends
 		// Should still have 2 real pictures
 		assertEquals(2, hslf.getPictures().length);
 		// Both are real pictures, both WMF
-		assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[0].getType());
-		assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[1].getType());
+		assertEquals(PictureType.WMF, hslf.getPictures()[0].getType());
+		assertEquals(PictureType.WMF, hslf.getPictures()[1].getType());
 
 		// Now test what happens when we use the SlideShow interface
 		HSLFSlideShow ppt = new HSLFSlideShow(hslf);
@@ -381,12 +382,12 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(0).getShapes().get(1); // 2nd object on 1st slide
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
-        assertEquals(HSLFPictureShape.WMF, pdata.getType());
+        assertEquals(PictureType.WMF, pdata.getType());
 
         pict = (HSLFPictureShape)slides.get(0).getShapes().get(2); // 3rd object on 1st slide
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
-        assertEquals(HSLFPictureShape.WMF, pdata.getType());
+        assertEquals(PictureType.WMF, pdata.getType());
 	}
 
     /**
@@ -401,8 +402,8 @@ public final class TestPictures extends
 		// Should still have 2 real pictures
 		assertEquals(2, hslf.getPictures().length);
 		// Both are real pictures, both WMF
-		assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[0].getType());
-		assertEquals(HSLFPictureShape.WMF, hslf.getPictures()[1].getType());
+		assertEquals(PictureType.WMF, hslf.getPictures()[0].getType());
+		assertEquals(PictureType.WMF, hslf.getPictures()[1].getType());
 
 		// Now test what happens when we use the SlideShow interface
 		HSLFSlideShow ppt = new HSLFSlideShow(hslf);
@@ -417,12 +418,12 @@ public final class TestPictures extends
         pict = (HSLFPictureShape)slides.get(6).getShapes().get(13);
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
-        assertEquals(HSLFPictureShape.WMF, pdata.getType());
+        assertEquals(PictureType.WMF, pdata.getType());
 
         pict = (HSLFPictureShape)slides.get(7).getShapes().get(13);
         pdata = pict.getPictureData();
         assertTrue(pdata instanceof WMF);
-        assertEquals(HSLFPictureShape.WMF, pdata.getType());
+        assertEquals(PictureType.WMF, pdata.getType());
 
         //add a new picture, it should be correctly appended to the Pictures stream
         ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -431,7 +432,7 @@ public final class TestPictures extends
 
         int streamSize = out.size();
 
-        HSLFPictureData data = HSLFPictureData.create(HSLFPictureShape.JPEG);
+        HSLFPictureData data = HSLFPictureData.create(PictureType.JPEG);
         data.setData(new byte[100]);
         int offset = hslf.addPicture(data);
         assertEquals(streamSize, offset);
@@ -452,8 +453,8 @@ public final class TestPictures extends
 
         HSLFSlide slide = ppt.createSlide();
         byte[] img = slTests.readFile("tomcat.png");
-        int idx = ppt.addPicture(img, HSLFPictureShape.PNG);
-        HSLFPictureShape pict = new HSLFPictureShape(idx);
+        HSLFPictureData data = ppt.addPicture(img, PictureType.PNG);
+        HSLFPictureShape pict = new HSLFPictureShape(data);
         pict.setPictureName("tomcat.png");
         slide.addShape(pict);
 



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


Mime
View raw message