static String toStr(HSLFHyperlink link, String rawText) { //in ppt end index is inclusive String formatStr = "title: %1$s, address: %2$s" + (rawText == null ? "" : ", start: %3$s, end: %4$s, substring: %5$s"); return String.format(Locale.ROOT, formatStr, link.getLabel(), link.getAddress(), link.getStartIndex(), link.getEndIndex(), rawText); } }
@Override public HSLFHyperlink createHyperlink() { if (_hyperlink == null) { _hyperlink = HSLFHyperlink.createHyperlink(this); } return _hyperlink; }
/** * 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); }
thisLink.setEndIndex(thisLink.getEndIndex()+run.getLength()); } else { if (lastLink != null) { InteractiveInfo info = lastLink.getInfo(); TxInteractiveInfoAtom txinfo = lastLink.getTextRunInfo(); assert(info != null && txinfo != null); _txtbox.appendChildRecord(info); InteractiveInfo info = lastLink.getInfo(); TxInteractiveInfoAtom txinfo = lastLink.getTextRunInfo(); assert(info != null && txinfo != null); _txtbox.appendChildRecord(info);
protected static void applyHyperlinks(List<HSLFTextParagraph> paragraphs) { List<HSLFHyperlink> links = HSLFHyperlink.find(paragraphs); if (csIdx > h.getEndIndex()) { break; HSLFTextRun run = runs.get(rIdx); rlen = run.getLength(); if (csIdx < h.getEndIndex() && h.getStartIndex() < csIdx+rlen) { String rawText = run.getRawText(); int startIdx = h.getStartIndex()-csIdx; if (startIdx > 0) { continue; int endIdx = Math.min(rlen, h.getEndIndex()-h.getStartIndex()); if (endIdx < rlen) {
HSLFHyperlink hyper = new HSLFHyperlink(exHyper, info); hyper.linkToNextSlide(); txinfo.setStartIndex(startIdx); txinfo.setEndIndex(endIdx); hyper.setTextRunInfo(txinfo);
HSLFHyperlink link = new HSLFHyperlink(exHyper, hldr); out.add(link); continue; link.setTextRunInfo((TxInteractiveInfoAtom)r);
/** * Creates a new Hyperlink and assign it to a shape * This is only a helper method - use {@link HSLFSimpleShape#createHyperlink()} instead! * * @param shape the shape which receives the hyperlink * @return the new hyperlink * * @see HSLFSimpleShape#createHyperlink() */ /* package */ static HSLFHyperlink createHyperlink(HSLFSimpleShape shape) { // TODO: check if a hyperlink already exists ExHyperlink exHyper = new ExHyperlink(); int linkId = shape.getSheet().getSlideShow().addToObjListAtom(exHyper); ExHyperlinkAtom obj = exHyper.getExHyperlinkAtom(); obj.setNumber(linkId); InteractiveInfo info = new InteractiveInfo(); info.getInteractiveInfoAtom().setHyperlinkID(linkId); HSLFEscherClientDataRecord cldata = shape.getClientData(true); cldata.addChild(info); HSLFHyperlink hyper = new HSLFHyperlink(exHyper, info); hyper.linkToNextSlide(); shape.setHyperlink(hyper); return hyper; }
/** * Gets the type of the hyperlink action. * Must be a <code>LINK_*</code> constant</code> * * @return the hyperlink URL * @see InteractiveInfoAtom * @deprecated use <code>getType</code> instead */ @Deprecated @Removal(version = "4.2") @Override public HyperlinkType getTypeEnum() { return getType(); }
/** * 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()); }
@Override public HSLFHyperlink createHyperlink() { if (link == null) { link = HSLFHyperlink.createHyperlink(this); parentParagraph.setDirty(); } return link; }
/** * 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);