/** * Returns the array of all hyperlinks in this text run * * @return the array of all hyperlinks in this text run * or <code>null</code> if not found. */ public Hyperlink[] getHyperlinks(){ return Hyperlink.find(this); }
/** * Returns the hyperlink assigned to this shape * * @return the hyperlink assigned to this shape * or <code>null</code> if not found. */ public Hyperlink getHyperlink(){ return Hyperlink.find(this); }
/** * 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; }
/** * 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; }