/** * 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 List<HSLFHyperlink> getHyperlinks() { return HSLFHyperlink.find(this); }
/** * Find hyperlinks in a text shape * * @param shape <code>TextRun</code> to lookup hyperlinks in * @return found hyperlinks or <code>null</code> if not found */ public static List<HSLFHyperlink> find(HSLFTextShape shape){ return find(shape.getTextParagraphs()); }
/** * Find hyperlinks in a text paragraph * * @param paragraphs List of <code>TextParagraph</code> to lookup hyperlinks * @return found hyperlinks */ @SuppressWarnings("resource") protected static List<HSLFHyperlink> find(List<HSLFTextParagraph> paragraphs){ List<HSLFHyperlink> lst = new ArrayList<>(); if (paragraphs == null || paragraphs.isEmpty()) return lst; HSLFTextParagraph firstPara = paragraphs.get(0); HSLFSlideShow ppt = firstPara.getSheet().getSlideShow(); //document-level container which stores info about all links in a presentation ExObjList exobj = ppt.getDocumentRecord().getExObjList(false); if (exobj != null) { Record[] records = firstPara.getRecords(); find(Arrays.asList(records), exobj, lst); } return lst; }
/** * 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; }
HSLFHyperlink link = HSLFHyperlink.find(sh); if (link != null) { ((HSLFSimpleShape)sh).setHyperlink(link);
protected static void applyHyperlinks(List<HSLFTextParagraph> paragraphs) { List<HSLFHyperlink> links = HSLFHyperlink.find(paragraphs);