PPDrawing ppdrawing = getPPDrawing();
/** * Returns the background shape for this sheet. * * @return the background shape for this sheet. */ public Background getBackground() { if (_background == null) { PPDrawing ppdrawing = getPPDrawing(); EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0]; EscherContainerRecord spContainer = null; for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) { EscherRecord rec = it.next(); if (rec.getRecordId() == EscherContainerRecord.SP_CONTAINER) { spContainer = (EscherContainerRecord) rec; break; } } _background = new Background(spContainer, null); _background.setSheet(this); } return _background; }
/** * Removes the specified shape from this sheet. * * @param shape shape to be removed from this sheet, if present. * @return <tt>true</tt> if the shape was deleted. */ public boolean removeShape(Shape shape) { PPDrawing ppdrawing = getPPDrawing(); EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0]; EscherContainerRecord spgr = null; for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) { EscherRecord rec = it.next(); if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) { spgr = (EscherContainerRecord) rec; break; } } if(spgr == null) { return false; } List<EscherRecord> lst = spgr.getChildRecords(); boolean result = lst.remove(shape.getSpContainer()); spgr.setChildRecords(lst); return result; }
/** * When a textbox is added to a sheet we need to tell upper-level * <code>PPDrawing</code> about it. * * @param sh the sheet we are adding to */ protected void afterInsert(Sheet sh){ super.afterInsert(sh); EscherTextboxWrapper _txtbox = getEscherTextboxWrapper(); if(_txtbox != null){ PPDrawing ppdrawing = sh.getPPDrawing(); ppdrawing.addTextboxWrapper(_txtbox); // Ensure the escher layer knows about the added records try { _txtbox.writeOut(null); } catch (IOException e){ throw new HSLFException(e); } if(getAnchor().equals(new Rectangle()) && !"".equals(getText())) resizeToFitText(); } if(_txtrun != null) { _txtrun.setShapeId(getShapeId()); sh.onAddTextShape(this); } }
/** * 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); }