/** * Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which * represents a group of shapes */ protected EscherContainerRecord createSpContainer(boolean isChild) { EscherContainerRecord spgr = new EscherContainerRecord(); spgr.setRecordId(EscherContainerRecord.SPGR_CONTAINER); spgr.setOptions((short) 15); // The group itself is a shape, and always appears as the first EscherSpContainer in the group // container. EscherContainerRecord spcont = new EscherContainerRecord(); spcont.setRecordId(EscherContainerRecord.SP_CONTAINER); spcont.setOptions((short) 15); EscherSpgrRecord spg = new EscherSpgrRecord(); spg.setOptions((short) 1); spcont.addChildRecord(spg); EscherSpRecord sp = new EscherSpRecord(); short type = (ShapeTypes.NotPrimitive << 4) + 2; sp.setOptions(type); sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_GROUP); spcont.addChildRecord(sp); EscherClientAnchorRecord anchor = new EscherClientAnchorRecord(); spcont.addChildRecord(anchor); spgr.addChildRecord(spcont); return spgr; }
/** * Return type of the shape. In most cases shape group type is {@link * org.apache.poi.hslf.model.ShapeTypes#NotPrimitive} * * @return type of the shape. */ public int getShapeType() { EscherContainerRecord groupInfoContainer = (EscherContainerRecord) _escherContainer.getChild(0); EscherSpRecord spRecord = groupInfoContainer.getChildById(EscherSpRecord.RECORD_ID); return spRecord.getOptions() >> 4; }