/** * Find hyperlinks in a text run * * @param run <code>TextRun</code> to lookup hyperlinks in * @return found hyperlinks or <code>null</code> if not found */ protected static Hyperlink[] find(TextRun run){ ArrayList lst = new ArrayList(); SlideShow ppt = run.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(); if (exobj == null) { return null; } Record[] records = run._records; if(records != null) find(records, exobj, lst); Hyperlink[] links = null; if (lst.size() > 0){ links = new Hyperlink[lst.size()]; lst.toArray(links); } return links; }
public void setSheet(Sheet sheet) { _sheet = sheet; // Initialize _txtrun object. // (We can't do it in the constructor because the sheet // is not assigned then, it's only built once we have // all the records) TextRun tx = getTextRun(); if (tx != null) { // Supply the sheet to our child RichTextRuns tx.setSheet(_sheet); RichTextRun[] rt = tx.getRichTextRuns(); for (int i = 0; i < rt.length; i++) { rt[i].supplySlideShow(_sheet.getSlideShow()); } } }
/** * 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; }
public void draw(Graphics2D graphics) { Fill f = getFill(); Dimension pg = getSheet().getSlideShow().getPageSize(); Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height); switch (f.getFillType()) {
protected EscherBSERecord getEscherBSERecord(int idx){ Sheet sheet = shape.getSheet(); if(sheet == null) { logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet"); return null; } SlideShow ppt = sheet.getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); if(bstore == null) { logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); return null; } List lst = bstore.getChildRecords(); return (EscherBSERecord)lst.get(idx-1); }
protected EscherBSERecord getEscherBSERecord(){ SlideShow ppt = getSheet().getSlideShow(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = (EscherContainerRecord)Shape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); if(bstore == null) { logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found "); return null; } List lst = bstore.getChildRecords(); int idx = getPictureIndex(); if (idx == 0){ logger.log(POILogger.DEBUG, "picture index was not found, returning "); return null; } return (EscherBSERecord)lst.get(idx-1); }
/** * Document-level container that specifies information about an ActiveX control * * @return container that specifies information about an ActiveX control */ public ExControl getExControl(){ int idx = getControlIndex(); ExControl ctrl = null; Document doc = getSheet().getSlideShow().getDocumentRecord(); ExObjList lst = (ExObjList)doc.findFirstOfType(RecordTypes.ExObjList.typeID); if(lst != null){ Record[] ch = lst.getChildRecords(); for (int i = 0; i < ch.length; i++) { if(ch[i] instanceof ExControl){ ExControl c = (ExControl)ch[i]; if(c.getExOleObjAtom().getObjID() == idx){ ctrl = c; break; } } } } return ctrl; }
/** * Returns the picture data for this picture. * * @return the picture data for this picture. */ public PictureData getPictureData(){ SlideShow ppt = getSheet().getSlideShow(); PictureData[] pict = ppt.getPictureData(); EscherBSERecord bse = getEscherBSERecord(); if (bse == null){ logger.log(POILogger.ERROR, "no reference to picture data found "); } else { for ( int i = 0; i < pict.length; i++ ) { if (pict[i].getOffset() == bse.getOffset()){ return pict[i]; } } logger.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset()); } return null; }
/** * Returns unique identifier for the OLE object. * * @return the unique identifier for the OLE object */ public ObjectData getObjectData(){ SlideShow ppt = getSheet().getSlideShow(); ObjectData[] ole = ppt.getEmbeddedObjects(); //persist reference ExEmbed exEmbed = getExEmbed(); ObjectData data = null; if(exEmbed != null) { int ref = exEmbed.getExOleObjAtom().getObjStgDataRef(); for (int i = 0; i < ole.length; i++) { if(ole[i].getExOleObjStg().getPersistId() == ref) { data=ole[i]; } } } if (data==null) { logger.log(POILogger.WARN, "OLE data not found"); } return data; }
SlideShow ppt = getSheet().getSlideShow();
/** * <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; }
/** * @return UNC or local path to a video file */ public String getPath(){ OEShapeAtom oe = (OEShapeAtom)getClientDataRecord(RecordTypes.OEShapeAtom.typeID); int idx = oe.getOptions(); SlideShow ppt = getSheet().getSlideShow(); ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID); if(lst == null) return null; Record[] r = lst.getChildRecords(); for (int i = 0; i < r.length; i++) { if(r[i] instanceof ExMCIMovie){ ExMCIMovie mci = (ExMCIMovie)r[i]; ExVideoContainer exVideo = mci.getExVideo(); int objectId = exVideo.getExMediaAtom().getObjectId(); if(objectId == idx){ return exVideo.getPathAtom().getText(); } } } return null; } }
wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width; PPFont bulletFont = _shape.getSheet().getSlideShow().getFont(fontIdx); bat.addAttribute(TextAttribute.FAMILY, bulletFont.getFontName());
txt.getTextRun().supplySlideShow(_group.getSheet().getSlideShow()); txt.getTextRun().setSheet(_group.getSheet()); txt.setText(s);