Color toRGB(int val){ int a = (val >> 24) & 0xFF; int b = (val >> 16) & 0xFF; int g = (val >> 8) & 0xFF; int r = (val >> 0) & 0xFF; if(a == 0xFE){ // Color is an sRGB value specified by red, green, and blue fields. } else if (a == 0xFF){ // Color is undefined. } else { // index in the color scheme ColorSchemeAtom ca = getSheet().getColorScheme(); int schemeColor = ca.getColor(a); r = (schemeColor >> 0) & 0xFF; g = (schemeColor >> 8) & 0xFF; b = (schemeColor >> 16) & 0xFF; } return new Color(r, g, b); }
/** * Find hyperlink assigned to the supplied shape * * @param shape <code>Shape</code> to lookup hyperlink in * @return found hyperlink or <code>null</code> */ @SuppressWarnings("resource") protected static HSLFHyperlink find(HSLFShape shape){ HSLFSlideShow ppt = shape.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(false); HSLFEscherClientDataRecord cldata = shape.getClientData(false); if (exobj != null && cldata != null) { List<HSLFHyperlink> lst = new ArrayList<>(); find(cldata.getHSLFChildRecords(), exobj, lst); return lst.isEmpty() ? null : lst.get(0); } return null; }
@SuppressWarnings("resource") protected EscherBSERecord getEscherBSERecord(int idx){ HSLFSheet sheet = shape.getSheet(); if(sheet == null) { LOG.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet"); return null; } HSLFSlideShow ppt = sheet.getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); if(bstore == null) { LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); return null; } List<EscherRecord> lst = bstore.getChildRecords(); return (EscherBSERecord)lst.get(idx-1); }
/** * Assign picture used to fill the underlying shape. * * @param data the picture data added to this ppt by {@link HSLFSlideShow#addPicture(byte[], org.apache.poi.sl.usermodel.PictureData.PictureType)} method. */ public void setPictureData(HSLFPictureData data){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); HSLFShape.setEscherProperty(opt, (short)(EscherProperties.FILL__PATTERNTEXTURE + 0x4000), (data == null ? 0 : data.getIndex())); if(data != null && shape.getSheet() != null) { EscherBSERecord bse = getEscherBSERecord(data.getIndex()); if (bse != null) { bse.setRef(bse.getRef() + 1); } } }
HSLFSheet sheet = getSheet(); if (fSchemeIndex && sheet != null) {
/** * <code>PictureData</code> object used in a texture, pattern of picture fill. */ @SuppressWarnings("resource") public HSLFPictureData getPictureData(){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if (p == null) { return null; } HSLFSlideShow ppt = shape.getSheet().getSlideShow(); List<HSLFPictureData> pict = ppt.getPictureData(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); java.util.List<EscherRecord> lst = bstore.getChildRecords(); int idx = p.getPropertyValue(); if (idx == 0){ LOG.log(POILogger.WARN, "no reference to picture data found "); } else { EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); for (HSLFPictureData pd : pict) { if (pd.getOffset() == bse.getOffset()){ return pd; } } } return null; }