/** * Background color */ public void setBackgroundColor(Color color){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); if (color == null) { Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, -1); } else { int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB(); Shape.setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb); } }
/** * Sets fill type. * Must be one of the <code>FILL_*</code> constants defined in this class. * * @param type type of the fill */ public void setFillType(int type){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE, type); }
/** * Foreground color */ public void setForegroundColor(Color color){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); if (color == null) { Shape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150000); } else { int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB(); Shape.setEscherProperty(opt, EscherProperties.FILL__FILLCOLOR, rgb); Shape.setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150011); } }
/** * Returns fill type. * Must be one of the <code>FILL_*</code> constants defined in this class. * * @return type of fill */ public int getFillType(){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); EscherSimpleProperty prop = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__FILLTYPE); return prop == null ? FILL_SOLID : prop.getPropertyValue(); }
/** * Foreground color */ public Color getForegroundColor(){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST); if(p != null && (p.getPropertyValue() & 0x10) == 0) return null; return shape.getColor(EscherProperties.FILL__FILLCOLOR, EscherProperties.FILL__FILLOPACITY, -1); }
/** * Background color */ public Color getBackgroundColor(){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST); if(p != null && (p.getPropertyValue() & 0x10) == 0) return null; return shape.getColor(EscherProperties.FILL__FILLBACKCOLOR, EscherProperties.FILL__FILLOPACITY, -1); }
/** * Find hyperlink assigned to the supplied shape * * @param shape <code>Shape</code> to lookup hyperlink in * @return found hyperlink or <code>null</code> */ protected static Hyperlink find(Shape shape){ ArrayList lst = new ArrayList(); SlideShow ppt = shape.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(); if (exobj == null) { return null; } EscherContainerRecord spContainer = shape.getSpContainer(); for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext(); ) { EscherRecord obj = it.next(); if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID){ byte[] data = obj.serialize(); Record[] records = Record.findChildRecords(data, 8, data.length-8); if(records != null) find(records, exobj, lst); } } return lst.size() == 1 ? (Hyperlink)lst.get(0) : null; }
/** * 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; }
/** */ protected void afterInsert(Sheet sh){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if(p != null) { int idx = p.getPropertyValue(); EscherBSERecord bse = getEscherBSERecord(idx); bse.setRef(bse.getRef() + 1); } }
/** * 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); }
/** * Assign picture used to fill the underlying shape. * * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method. */ public void setPictureData(int idx){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); Shape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), idx); if( idx != 0 ) { if( shape.getSheet() != null ) { EscherBSERecord bse = getEscherBSERecord(idx); bse.setRef(bse.getRef() + 1); } } }
/** * 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); }
/** * <code>PictureData</code> object used in a texture, pattern of picture fill. */ public PictureData getPictureData(){ EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(shape.getSpContainer(), EscherOptRecord.RECORD_ID); EscherSimpleProperty p = (EscherSimpleProperty)Shape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if (p == null) return null; SlideShow ppt = shape.getSheet().getSlideShow(); PictureData[] pict = ppt.getPictureData(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); java.util.List<EscherRecord> lst = bstore.getChildRecords(); int idx = p.getPropertyValue(); if (idx == 0){ logger.log(POILogger.WARN, "no reference to picture data found "); } else { EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); for ( int i = 0; i < pict.length; i++ ) { if (pict[i].getOffset() == bse.getOffset()){ return pict[i]; } } } return null; }