From: Yegor Kozlov Date: Thu, 24 May 2007 11:38:36 +0000 (+0000) Subject: fixed bug 42485: All TextBoxes inside ShapeGroups have null TextRuns X-Git-Tag: REL_3_0_1_RC1~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a0e489bb4d8d27f311cf5be7e75269a8f390ff8b;p=poi.git fixed bug 42485: All TextBoxes inside ShapeGroups have null TextRuns git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@541274 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java index 0b9071dcc0..8519e88af3 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java @@ -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 index 0000000000..e9e3dda1e5 Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hslf/data/42485.ppt differ diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java index e79d05bc54..89f97959d7 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java @@ -19,10 +19,7 @@ package org.apache.poi.hslf.usermodel; import junit.framework.TestCase; import org.apache.poi.hslf.HSLFSlideShow; -import org.apache.poi.hslf.model.Picture; -import org.apache.poi.hslf.model.Slide; -import org.apache.poi.hslf.model.Notes; -import org.apache.poi.hslf.model.TextRun; +import org.apache.poi.hslf.model.*; import java.io.*; import java.util.HashSet; @@ -118,4 +115,29 @@ public class TestBugs extends TestCase { } } } + + /** + * Bug 42485: All TextBoxes inside ShapeGroups have null TextRuns + */ + public void test42485 () throws Exception { + FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt")); + HSLFSlideShow hslf = new HSLFSlideShow(is); + is.close(); + + SlideShow ppt = new SlideShow(hslf); + Shape[] shape = ppt.getSlides()[0].getShapes(); + for (int i = 0; i < shape.length; i++) { + if(shape[i] instanceof ShapeGroup){ + ShapeGroup group = (ShapeGroup)shape[i]; + Shape[] sh = group.getShapes(); + for (int j = 0; j < sh.length; j++) { + if( sh[j] instanceof TextBox){ + TextBox txt = (TextBox)sh[j]; + assertNotNull(txt.getTextRun()); + } + } + } + } + } + }