]> source.dussan.org Git - poi.git/commitdiff
Don't just assume we'll only have container records for the shape's escher records
authorNick Burch <nick@apache.org>
Tue, 26 Sep 2006 14:14:59 +0000 (14:14 +0000)
committerNick Burch <nick@apache.org>
Tue, 26 Sep 2006 14:14:59 +0000 (14:14 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@450057 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java

index a3f6584b2856cb2841cd1b4f905ee0566fd290ab..11fafdb4b6a6b86a74496b7afc9609d92e2983a9 100644 (file)
@@ -18,6 +18,7 @@ package org.apache.poi.hslf.model;
 import org.apache.poi.ddf.*;\r
 import org.apache.poi.util.LittleEndian;\r
 \r
+import java.util.ArrayList;\r
 import java.util.List;\r
 \r
 /**\r
@@ -50,16 +51,29 @@ public class ShapeGroup extends Shape{
      * @return the shapes contained in this group container\r
      */\r
     public Shape[] getShapes() {\r
-        //several SpContainers, the first of which is the group shape itself\r
+       // Out escher container record should contain serveral\r
+        //  SpContainers, the first of which is the group shape itself\r
         List lst = _escherContainer.getChildRecords();\r
 \r
-        //don't include the first SpContainer, it is always NotPrimitive\r
-        Shape[] shapes = new Shape[lst.size() - 1];\r
+        ArrayList shapeList = new ArrayList();\r
+        // Don't include the first SpContainer, it is always NotPrimitive\r
         for (int i = 1; i < lst.size(); i++){\r
-            EscherContainerRecord container = (EscherContainerRecord)lst.get(i);\r
-            shapes[i-1] = ShapeFactory.createShape(container, this);\r
+               EscherRecord r = (EscherRecord)lst.get(i);\r
+               if(r instanceof EscherContainerRecord) {\r
+                       // Create the Shape for it\r
+                       EscherContainerRecord container = (EscherContainerRecord)r;\r
+                       Shape shape = ShapeFactory.createShape(container, this);\r
+                       shapeList.add( shape );\r
+               } else {\r
+                       // Should we do anything special with these non\r
+                       //  Container records?\r
+                       System.err.println("Shape contained non container escher record, was " + r.getClass().getName());\r
+               }\r
         }\r
-         return shapes;\r
+        \r
+        // Put the shapes into an array, and return\r
+        Shape[] shapes = (Shape[])shapeList.toArray(new Shape[shapeList.size()]);\r
+        return shapes;\r
     }\r
 \r
     /**\r