/** * @return the shapes contained in this group container */ public Shape[] getShapes() { // Out escher container record should contain several // SpContainers, the first of which is the group shape itself Iterator<EscherRecord> iter = _escherContainer.getChildIterator(); // Don't include the first SpContainer, it is always NotPrimitive if (iter.hasNext()) { iter.next(); } List<Shape> shapeList = new ArrayList<Shape>(); while (iter.hasNext()) { EscherRecord r = iter.next(); if(r instanceof EscherContainerRecord) { // 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 // Container records? logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName()); } } // Put the shapes into an array, and return Shape[] shapes = shapeList.toArray(new Shape[shapeList.size()]); return shapes; }
EscherContainerRecord sp = (EscherContainerRecord) it.next(); Shape sh = ShapeFactory.createShape(sp, null); sh.setSheet(this); shapes.add(sh);
/** * Add a shape to this group. * * @param shape - the Shape to add */ public void addShape(Shape shape){ _escherContainer.addChildRecord(shape.getSpContainer()); Sheet sheet = getSheet(); shape.setSheet(sheet); shape.setShapeId(sheet.allocateShapeId()); shape.afterInsert(sheet); }
/** * Add a new Shape to this Slide * * @param shape - the Shape to add */ public void addShape(Shape shape) { PPDrawing ppdrawing = getPPDrawing(); EscherContainerRecord dgContainer = (EscherContainerRecord) ppdrawing.getEscherRecords()[0]; EscherContainerRecord spgr = (EscherContainerRecord) Shape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER); spgr.addChildRecord(shape.getSpContainer()); shape.setSheet(this); shape.setShapeId(allocateShapeId()); shape.afterInsert(this); }