poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r450057 - /jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
Date Tue, 26 Sep 2006 14:15:00 GMT
Author: nick
Date: Tue Sep 26 07:14:59 2006
New Revision: 450057

URL: http://svn.apache.org/viewvc?view=rev&rev=450057
Log:
Don't just assume we'll only have container records for the shape's escher records

Modified:
    jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java

Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java?view=diff&rev=450057&r1=450056&r2=450057
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java Tue Sep
26 07:14:59 2006
@@ -18,6 +18,7 @@
 import org.apache.poi.ddf.*;
 import org.apache.poi.util.LittleEndian;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -50,16 +51,29 @@
      * @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;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message