From 338801b916d312a91ebf5829ea6fc6be1c8b4fbb Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 26 Sep 2006 14:14:59 +0000 Subject: [PATCH] Don't just assume we'll only have container records for the shape's escher records git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@450057 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hslf/model/ShapeGroup.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) 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 a3f6584b28..11fafdb4b6 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java @@ -18,6 +18,7 @@ package org.apache.poi.hslf.model; import org.apache.poi.ddf.*; import org.apache.poi.util.LittleEndian; +import java.util.ArrayList; import java.util.List; /** @@ -50,16 +51,29 @@ public class ShapeGroup extends Shape{ * @return the shapes contained in this group container */ public Shape[] getShapes() { - //several SpContainers, the first of which is the group shape itself + // Out escher container record should contain serveral + // SpContainers, the first of which is the group shape itself List lst = _escherContainer.getChildRecords(); - //don't include the first SpContainer, it is always NotPrimitive - Shape[] shapes = new Shape[lst.size() - 1]; + ArrayList shapeList = new ArrayList(); + // Don't include the first SpContainer, it is always NotPrimitive for (int i = 1; i < lst.size(); i++){ - EscherContainerRecord container = (EscherContainerRecord)lst.get(i); - shapes[i-1] = ShapeFactory.createShape(container, this); + EscherRecord r = (EscherRecord)lst.get(i); + if(r instanceof EscherContainerRecord) { + // Create the Shape for it + EscherContainerRecord container = (EscherContainerRecord)r; + Shape shape = ShapeFactory.createShape(container, this); + shapeList.add( shape ); + } else { + // Should we do anything special with these non + // Container records? + System.err.println("Shape contained non container escher record, was " + r.getClass().getName()); + } } - return shapes; + + // Put the shapes into an array, and return + Shape[] shapes = (Shape[])shapeList.toArray(new Shape[shapeList.size()]); + return shapes; } /** -- 2.39.5