\r
import java.io.*;\r
import java.util.ArrayList;\r
+import java.util.HashMap;\r
\r
import org.apache.poi.hslf.usermodel.SlideShow;\r
import org.apache.poi.hslf.record.TextHeaderAtom;\r
assertEquals("Testing TextShape", shape1.getTextRun().getText());\r
}\r
\r
+ public void testMargins() throws IOException {\r
+ FileInputStream is = new FileInputStream(new File(cwd, "text-margins.ppt"));\r
+ SlideShow ppt = new SlideShow(is);\r
+ is.close();\r
+\r
+ Slide slide = ppt.getSlides()[0];\r
+\r
+ HashMap map = new HashMap();\r
+ Shape[] shape = slide.getShapes();\r
+ for (int i = 0; i < shape.length; i++) {\r
+ if(shape[i] instanceof TextShape){\r
+ TextShape tx = (TextShape)shape[i];\r
+ map.put(tx.getText(), tx);\r
+ }\r
+ }\r
+\r
+ TextShape tx;\r
+\r
+ tx = (TextShape)map.get("TEST1");\r
+ assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.39, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+\r
+ tx = (TextShape)map.get("TEST2");\r
+ assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.39, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+\r
+ tx = (TextShape)map.get("TEST3");\r
+ assertEquals(0.39, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.1, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+\r
+ tx = (TextShape)map.get("TEST4");\r
+ assertEquals(0.1, tx.getMarginLeft()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.39, tx.getMarginRight()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.05, tx.getMarginTop()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ assertEquals(0.05, tx.getMarginBottom()*Shape.EMU_PER_POINT/Shape.EMU_PER_INCH, 0.01);\r
+ }\r
}\r