]> source.dussan.org Git - poi.git/commitdiff
fixed bug 42485: All TextBoxes inside ShapeGroups have null TextRuns
authorYegor Kozlov <yegor@apache.org>
Thu, 24 May 2007 11:38:36 +0000 (11:38 +0000)
committerYegor Kozlov <yegor@apache.org>
Thu, 24 May 2007 11:38:36 +0000 (11:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@541274 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
src/scratchpad/testcases/org/apache/poi/hslf/data/42485.ppt [new file with mode: 0644]
src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java

index 0b9071dcc0f28bdfb61505ec9394ad1815b54f6f..8519e88af3a65979799557ad605a21e0100b3bd3 100644 (file)
@@ -64,6 +64,7 @@ public class ShapeGroup extends Shape{
                        // Create the Shape for it
                        EscherContainerRecord container = (EscherContainerRecord)r;
                        Shape shape = ShapeFactory.createShape(container, this);
+                shape.setSheet(getSheet());
                        shapeList.add( shape );
                } else {
                        // Should we do anything special with these non
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/data/42485.ppt b/src/scratchpad/testcases/org/apache/poi/hslf/data/42485.ppt
new file mode 100644 (file)
index 0000000..e9e3dda
Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hslf/data/42485.ppt differ
index e79d05bc545cc1ebf801114fbeb93a04a9e67833..89f97959d772390fd7f0989f293f6ecbd4ceab4f 100644 (file)
@@ -19,10 +19,7 @@ package org.apache.poi.hslf.usermodel;
 \r
 import junit.framework.TestCase;\r
 import org.apache.poi.hslf.HSLFSlideShow;\r
-import org.apache.poi.hslf.model.Picture;\r
-import org.apache.poi.hslf.model.Slide;\r
-import org.apache.poi.hslf.model.Notes;\r
-import org.apache.poi.hslf.model.TextRun;\r
+import org.apache.poi.hslf.model.*;\r
 \r
 import java.io.*;\r
 import java.util.HashSet;\r
@@ -118,4 +115,29 @@ public class TestBugs extends TestCase {
             }\r
         }\r
     }\r
+\r
+    /**\r
+     * Bug 42485: All TextBoxes inside ShapeGroups have null TextRuns\r
+     */\r
+    public void test42485 () throws Exception {\r
+        FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt"));\r
+        HSLFSlideShow hslf = new HSLFSlideShow(is);\r
+        is.close();\r
+\r
+        SlideShow ppt = new SlideShow(hslf);\r
+        Shape[] shape = ppt.getSlides()[0].getShapes();\r
+        for (int i = 0; i < shape.length; i++) {\r
+            if(shape[i] instanceof ShapeGroup){\r
+                ShapeGroup  group = (ShapeGroup)shape[i];\r
+                Shape[] sh = group.getShapes();\r
+                for (int j = 0; j < sh.length; j++) {\r
+                    if( sh[j] instanceof TextBox){\r
+                        TextBox txt = (TextBox)sh[j];\r
+                        assertNotNull(txt.getTextRun());\r
+                    }\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
 }\r