pos = _sheet.aggregateDrawingRecords(dm, true); agg = (EscherAggregate) _sheet.getRecords().get(pos); HSSFPatriarch patriarch = new HSSFPatriarch(this, agg); patriarch.afterCreate(); return patriarch; return new HSSFPatriarch(this, agg);
/** * used to clone patriarch * * create patriarch from existing one * @param patriarch - copy all the shapes from this patriarch to new one * @param sheet where must be located new patriarch * @return new patriarch with copies of all shapes from the existing patriarch */ static HSSFPatriarch createPatriarch(HSSFPatriarch patriarch, HSSFSheet sheet){ HSSFPatriarch newPatriarch = new HSSFPatriarch(sheet, new EscherAggregate(true)); newPatriarch.afterCreate(); for (HSSFShape shape: patriarch.getChildren()){ HSSFShape newShape; if (shape instanceof HSSFShapeGroup){ newShape = ((HSSFShapeGroup)shape).cloneShape(newPatriarch); } else { newShape = shape.cloneShape(); } newPatriarch.onCreate(newShape); newPatriarch.addShape(newShape); } return newPatriarch; }
/** * Returns the top-level drawing patriach, if there is * one. * This will hold any graphics or charts for the sheet. * WARNING - calling this will trigger a parsing of the * associated escher records. Any that aren't supported * (such as charts and complex drawing types) will almost * certainly be lost or corrupted when written out. Only * use this with simple drawings, otherwise call * {@link HSSFSheet#createDrawingPatriarch()} and * start from scratch! */ public HSSFPatriarch getDrawingPatriarch() { if(_patriarch != null) return _patriarch; EscherAggregate agg = getDrawingEscherAggregate(); if(agg == null) return null; _patriarch = new HSSFPatriarch(this, agg); agg.setPatriarch(_patriarch); // Have it process the records into high level objects // as best it can do (this step may eat anything // that isn't supported, you were warned...) agg.convertRecordsToUserModel(); // Return what we could cope with return _patriarch; }
pos = _sheet.aggregateDrawingRecords(dm, true); agg = (EscherAggregate) _sheet.getRecords().get(pos); patriarch = new HSSFPatriarch(this, agg); patriarch.afterCreate(); return patriarch; return new HSSFPatriarch(this, agg);
pos = _sheet.aggregateDrawingRecords(dm, true); agg = (EscherAggregate) _sheet.getRecords().get(pos); HSSFPatriarch patriarch = new HSSFPatriarch(this, agg); patriarch.afterCreate(); return patriarch; return new HSSFPatriarch(this, agg);
/** * Creates the top-level drawing patriarch. This will have * the effect of removing any existing drawings on this * sheet. * This may then be used to add graphics or charts * @return The new patriarch. */ public HSSFPatriarch createDrawingPatriarch() { if(_patriarch == null){ // Create the drawing group if it doesn't already exist. _workbook.initDrawings(); if(_patriarch == null){ _sheet.aggregateDrawingRecords(_book.getDrawingManager(), true); EscherAggregate agg = (EscherAggregate) _sheet.findFirstRecordBySid(EscherAggregate.sid); _patriarch = new HSSFPatriarch(this, agg); agg.setPatriarch(_patriarch); } } return _patriarch; }
/** * used to clone patriarch * * create patriarch from existing one * @param patriarch - copy all the shapes from this patriarch to new one * @param sheet where must be located new patriarch * @return new patriarch with copies of all shapes from the existing patriarch */ static HSSFPatriarch createPatriarch(HSSFPatriarch patriarch, HSSFSheet sheet){ HSSFPatriarch newPatriarch = new HSSFPatriarch(sheet, new EscherAggregate(true)); newPatriarch.afterCreate(); for (HSSFShape shape: patriarch.getChildren()){ HSSFShape newShape; if (shape instanceof HSSFShapeGroup){ newShape = ((HSSFShapeGroup)shape).cloneShape(newPatriarch); } else { newShape = shape.cloneShape(); } newPatriarch.onCreate(newShape); newPatriarch.addShape(newShape); } return newPatriarch; }
/** * used to clone patriarch * * create patriarch from existing one * @param patriarch - copy all the shapes from this patriarch to new one * @param sheet where must be located new patriarch * @return new patriarch with copies of all shapes from the existing patriarch */ static HSSFPatriarch createPatriarch(HSSFPatriarch patriarch, HSSFSheet sheet){ HSSFPatriarch newPatriarch = new HSSFPatriarch(sheet, new EscherAggregate(true)); newPatriarch.afterCreate(); for (HSSFShape shape: patriarch.getChildren()){ HSSFShape newShape; if (shape instanceof HSSFShapeGroup){ newShape = ((HSSFShapeGroup)shape).cloneShape(newPatriarch); } else { newShape = shape.cloneShape(); } newPatriarch.onCreate(newShape); newPatriarch.addShape(newShape); } return newPatriarch; }