poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r668257 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hslf/model/TextShape.java testcases/org/apache/poi/hslf/data/text-margins.ppt testcases/org/apache/poi/hslf/model/TestTextShape.java
Date Mon, 16 Jun 2008 18:39:00 GMT
Author: yegor
Date: Mon Jun 16 11:38:59 2008
New Revision: 668257

URL: http://svn.apache.org/viewvc?rev=668257&view=rev
Log:
TextShape.getMarginLeft() returned incorrect value. Added a unit test for text margins.

Added:
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt   (with props)
Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java?rev=668257&r1=668256&r2=668257&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java Mon Jun 16 11:38:59
2008
@@ -355,7 +355,7 @@
      */
     public float getMarginLeft(){
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTBOTTOM);
+        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTLEFT);
         int val = prop == null ? EMU_PER_INCH/10 : prop.getPropertyValue();
         return (float)val/EMU_PER_POINT;
     }

Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt?rev=668257&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt
------------------------------------------------------------------------------
    svn:executable = *

Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/text-margins.ppt
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java?rev=668257&r1=668256&r2=668257&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTextShape.java Mon Jun
16 11:38:59 2008
@@ -23,6 +23,7 @@
 
 import java.io.*;
 import java.util.ArrayList;
+import java.util.HashMap;
 
 import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.hslf.record.TextHeaderAtom;
@@ -157,4 +158,46 @@
         assertEquals("Testing TextShape", shape1.getTextRun().getText());
     }
 
+    public void testMargins() throws IOException {
+        FileInputStream is = new FileInputStream(new File(cwd, "text-margins.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+
+        HashMap map = new HashMap();
+        Shape[] shape = slide.getShapes();
+        for (int i = 0; i < shape.length; i++) {
+            if(shape[i] instanceof TextShape){
+                TextShape tx = (TextShape)shape[i];
+                map.put(tx.getText(), tx);
+            }
+        }
+
+        TextShape tx;
+
+        tx = (TextShape)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");
+        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");
+        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");
+        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);
+    }
 }



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


Mime
View raw message