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
* @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