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

svn commit: r1661322 [14/14] - in /poi/branches/common_sl: ./ src/examples/src/org/apache/poi/hslf/examples/ src/examples/src/org/apache/poi/xslf/usermodel/ src/java/org/apache/poi/common/usermodel/ src/java/org/apache/poi/hssf/usermodel/ src/java/org/...

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java?rev=1661322&r1=1661321&r2=1661322&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestBackground.java Sat Feb 21 10:56:03 2015
@@ -35,6 +35,7 @@ import org.apache.poi.ddf.EscherSimplePr
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.record.Document;
 import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.junit.Test;
 
 
@@ -59,7 +60,7 @@ public final class TestBackground {
         assertTrue(slide.getFollowMasterBackground());
         assertEquals(Fill.FILL_SOLID, slide.getBackground().getFill().getFillType());
 
-        Shape shape = new AutoShape(ShapeTypes.Rectangle);
+        Shape shape = new AutoShape(ShapeType.RECT);
         assertEquals(Fill.FILL_SOLID, shape.getFill().getFillType());
     }
 
@@ -114,7 +115,7 @@ public final class TestBackground {
         fill.setFillType(Fill.FILL_PICTURE);
         fill.setPictureData(idx);
 
-        shape = new AutoShape(ShapeTypes.Rectangle);
+        shape = new AutoShape(ShapeType.RECT);
         shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
         fill = shape.getFill();
         fill.setFillType(Fill.FILL_SOLID);
@@ -130,7 +131,7 @@ public final class TestBackground {
         fill.setBackgroundColor(Color.green);
         fill.setForegroundColor(Color.red);
 
-        shape = new AutoShape(ShapeTypes.Rectangle);
+        shape = new AutoShape(ShapeType.RECT);
         shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
         fill = shape.getFill();
         fill.setFillType(Fill.FILL_BACKGROUND);
@@ -144,7 +145,7 @@ public final class TestBackground {
         fill.setFillType(Fill.FILL_TEXTURE);
         fill.setPictureData(idx);
 
-        shape = new AutoShape(ShapeTypes.Rectangle);
+        shape = new AutoShape(ShapeType.RECT);
         shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
         fill = shape.getFill();
         fill.setFillType(Fill.FILL_PICTURE);
@@ -160,7 +161,7 @@ public final class TestBackground {
         fill.setBackgroundColor(Color.white);
         fill.setForegroundColor(Color.darkGray);
 
-        shape = new AutoShape(ShapeTypes.Rectangle);
+        shape = new AutoShape(ShapeType.RECT);
         shape.setAnchor(new java.awt.Rectangle(100, 100, 200, 200));
         fill = shape.getFill();
         fill.setFillType(Fill.FILL_SHADE);

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java?rev=1661322&r1=1661321&r2=1661322&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java Sat Feb 21 10:56:03 2015
@@ -41,6 +41,7 @@ import org.apache.poi.ddf.EscherSimplePr
 import org.apache.poi.hslf.HSLFSlideShow;
 import org.apache.poi.hslf.usermodel.RichTextRun;
 import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.ShapeType;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -81,7 +82,7 @@ public final class TestShapes {
         line.setLineColor(Color.red);
         slide.addShape(line);
 
-        AutoShape ellipse = new AutoShape(ShapeTypes.Ellipse);
+        AutoShape ellipse = new AutoShape(ShapeType.ELLIPSE);
         java.awt.Rectangle ellipseAnchor = new Rectangle(320, 154, 55, 111);
         ellipse.setAnchor(ellipseAnchor);
         ellipse.setLineWidth(2);
@@ -334,7 +335,7 @@ public final class TestShapes {
 
     @Test
     public void lineWidth() {
-        SimpleShape sh = new AutoShape(ShapeTypes.RightTriangle);
+        SimpleShape sh = new AutoShape(ShapeType.RT_TRIANGLE);
 
         EscherOptRecord opt = sh.getEscherOptRecord();
         EscherSimpleProperty prop = SimpleShape.getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java?rev=1661322&r1=1661321&r2=1661322&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java Sat Feb 21 10:56:03 2015
@@ -17,26 +17,38 @@
 
 package org.apache.poi.hslf.model;
 
-import junit.framework.TestCase;
-
-import java.io.*;
+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 static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
-import org.apache.poi.hslf.usermodel.SlideShow;
-import org.apache.poi.hslf.record.TextHeaderAtom;
 import org.apache.poi.POIDataSamples;
+import org.apache.poi.hslf.record.TextHeaderAtom;
+import org.apache.poi.hslf.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.ShapeType;
+import org.junit.Test;
 
 /**
  * Verify behavior of <code>TextShape</code> and its sub-classes
  *
  * @author Yegor Kozlov
  */
-public final class TestTextShape extends TestCase {
+public final class TestTextShape {
     private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance();
 
-    public void testCreateAutoShape(){
-        TextShape shape = new AutoShape(ShapeTypes.Trapezoid);
+    @Test
+    public void createAutoShape(){
+        TextShape shape = new AutoShape(ShapeType.TRAPEZOID);
         assertNull(shape.getTextRun());
         assertNull(shape.getText());
         assertNull(shape.getEscherTextboxWrapper());
@@ -50,7 +62,8 @@ public final class TestTextShape extends
         assertEquals(-1, run.getIndex());
     }
 
-    public void testCreateTextBox(){
+    @Test
+    public void createTextBox(){
         TextShape shape = new TextBox();
         TextRun run = shape.getTextRun();
         assertNotNull(run);
@@ -70,10 +83,11 @@ public final class TestTextShape extends
      *  - normal TextBox object
      *  - text in auto-shapes
      */
-    public void testRead() throws IOException {
+    @Test
+    public void read() throws IOException {
         SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text_shapes.ppt"));
 
-        ArrayList lst1 = new ArrayList();
+        List<String> lst1 = new ArrayList<String>();
         Slide slide = ppt.getSlides()[0];
         Shape[] shape = slide.getShapes();
         for (int i = 0; i < shape.length; i++) {
@@ -83,24 +97,24 @@ public final class TestTextShape extends
             assertNotNull(run);
             int runType = run.getRunType();
 
-            int type = shape[i].getShapeType();
+            ShapeType type = shape[i].getShapeType();
             switch (type){
-                case ShapeTypes.TextBox:
+                case TEXT_BOX:
                     assertEquals("Text in a TextBox", run.getText());
                     break;
-                case ShapeTypes.Rectangle:
+                case RECT:
                     if(runType == TextHeaderAtom.OTHER_TYPE)
                         assertEquals("Rectangle", run.getText());
                     else if(runType == TextHeaderAtom.TITLE_TYPE)
                         assertEquals("Title Placeholder", run.getText());
                     break;
-                case ShapeTypes.Octagon:
+                case OCTAGON:
                     assertEquals("Octagon", run.getText());
                     break;
-                case ShapeTypes.Ellipse:
+                case ELLIPSE:
                     assertEquals("Ellipse", run.getText());
                     break;
-                case ShapeTypes.RoundRectangle:
+                case ROUND_RECT:
                     assertEquals("RoundRectangle", run.getText());
                     break;
                 default:
@@ -110,7 +124,7 @@ public final class TestTextShape extends
             lst1.add(run.getText());
         }
 
-        ArrayList lst2 = new ArrayList();
+        List<String> lst2 = new ArrayList<String>();
         TextRun[] run = slide.getTextRuns();
         for (int i = 0; i < run.length; i++) {
             lst2.add(run[i].getText());
@@ -119,7 +133,8 @@ public final class TestTextShape extends
         assertTrue(lst1.containsAll(lst2));
     }
 
-    public void testReadWrite() throws IOException {
+    @Test
+    public void readWrite() throws IOException {
         SlideShow ppt = new SlideShow();
         Slide slide =  ppt.createSlide();
 
@@ -130,7 +145,7 @@ public final class TestTextShape extends
 
         shape1.moveTo(100, 100);
 
-        TextShape shape2 = new AutoShape(ShapeTypes.Arrow);
+        TextShape shape2 = new AutoShape(ShapeType.RIGHT_ARROW);
         TextRun run2 = shape2.createTextRun();
         run2.setText("Testing TextShape");
         slide.addShape(shape2);
@@ -146,21 +161,22 @@ public final class TestTextShape extends
 
         assertTrue(shape[0] instanceof TextShape);
         shape1 = (TextShape)shape[0];
-        assertEquals(ShapeTypes.TextBox, shape1.getShapeType());
+        assertEquals(ShapeType.TEXT_BOX, shape1.getShapeType());
         assertEquals("Hello, World!", shape1.getTextRun().getText());
 
         assertTrue(shape[1] instanceof TextShape);
         shape1 = (TextShape)shape[1];
-        assertEquals(ShapeTypes.Arrow, shape1.getShapeType());
+        assertEquals(ShapeType.RIGHT_ARROW, shape1.getShapeType());
         assertEquals("Testing TextShape", shape1.getTextRun().getText());
     }
 
-    public void testMargins() throws IOException {
+    @Test
+    public void margins() throws IOException {
         SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("text-margins.ppt"));
 
         Slide slide = ppt.getSlides()[0];
 
-        HashMap map = new HashMap();
+        Map<String,TextShape> map = new HashMap<String,TextShape>();
         Shape[] shape = slide.getShapes();
         for (int i = 0; i < shape.length; i++) {
             if(shape[i] instanceof TextShape){
@@ -171,32 +187,33 @@ public final class TestTextShape extends
 
         TextShape tx;
 
-        tx = (TextShape)map.get("TEST1");
+        tx = map.get("TEST1");
         assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.39, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
 
-        tx = (TextShape)map.get("TEST2");
+        tx = map.get("TEST2");
         assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.39, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
 
-        tx = (TextShape)map.get("TEST3");
+        tx = map.get("TEST3");
         assertEquals(0.39, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
 
-        tx = (TextShape)map.get("TEST4");
+        tx = map.get("TEST4");
         assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.39, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
         assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);
     }
 
-    public void test52599() throws IOException {
+    @Test
+    public void bug52599() throws IOException {
         SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("52599.ppt"));
 
         Slide slide = ppt.getSlides()[0];

Modified: poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1661322&r1=1661321&r2=1661322&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/branches/common_sl/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Sat Feb 21 10:56:03 2015
@@ -653,7 +653,7 @@ public final class TestBugs {
             for (byte data[] : ep) {
                 EscherColorRef ecr = new EscherColorRef(data, 0, 4);
                 int rgb[] = ecr.getRGB();
-                double pos = Units.fixedPointToDecimal(LittleEndian.getInt(data, 4));
+                double pos = Units.fixedPointToDouble(LittleEndian.getInt(data, 4));
                 assertEquals((int)exp[i][0], rgb[0]);
                 assertEquals((int)exp[i][1], rgb[1]);
                 assertEquals((int)exp[i][2], rgb[2]);

Added: poi/branches/common_sl/src/types/definitions/dml-shapeGeometry.xjb
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/types/definitions/dml-shapeGeometry.xjb?rev=1661322&view=auto
==============================================================================
--- poi/branches/common_sl/src/types/definitions/dml-shapeGeometry.xjb (added)
+++ poi/branches/common_sl/src/types/definitions/dml-shapeGeometry.xjb Sat Feb 21 10:56:03 2015
@@ -0,0 +1,7 @@
+<jxb:bindings version="1.0"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd">
+	<jxb:globalBindings generateIsSetMethod="true"/>
+</jxb:bindings>



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