/** * Add a new picture to this presentation. * * @return offset of this picture in the Pictures stream */ public int addPicture(HSLFPictureData img) { // Process any existing pictures if we haven't yet if (_pictures == null) { try { readPictures(); } catch (IOException e) { throw new CorruptPowerPointFileException(e.getMessage()); } } // Add the new picture in int offset = 0; if (_pictures.size() > 0) { HSLFPictureData prev = _pictures.get(_pictures.size() - 1); offset = prev.getOffset() + prev.getRawData().length + 8; } img.setOffset(offset); img.setIndex(_pictures.size() + 1); _pictures.add(img); return offset; }
@SuppressWarnings("resource") @Override public HSLFPictureData getPictureData(){ HSLFSlideShow ppt = getSheet().getSlideShow(); List<HSLFPictureData> pict = ppt.getPictureData(); EscherBSERecord bse = getEscherBSERecord(); if (bse == null){ LOG.log(POILogger.ERROR, "no reference to picture data found "); } else { for (HSLFPictureData pd : pict) { if (pd.getOffset() == bse.getOffset()){ return pd; } } LOG.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset()); } return 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; }