private void linkToRelativeSlide(String jump) { PackagePart thisPP = _sheet.getPackagePart(); if (_link.isSetId() && !_link.getId().isEmpty()) { thisPP.removeRelationship(_link.getId()); } _link.setId(""); _link.setAction((jump.startsWith("ppaction") ? "" : "ppaction://hlinkshowjump?jump=") + jump); } }
@Override public String getAddress() { final String id = _link.getId(); if (id == null || id.isEmpty()) { return _link.getAction(); } final PackageRelationship rel = _sheet.getPackagePart().getRelationship(id); if (rel == null) { return null; } final URI targetURI = rel.getTargetURI(); return (targetURI == null) ? null : targetURI.toASCIIString(); }
public Boolean getEndSound() { if (link.isSetEndSnd()) { return link.getEndSnd(); } else { return null; } }
public Boolean getHistory() { if (link.isSetHistory()) { return link.getHistory(); } else { return null; } }
public String getInvalidURL() { if (link.isSetInvalidUrl()) { return link.getInvalidUrl(); } else { return null; } }
public String getTargetFrame() { if (link.isSetTgtFrame()) { return link.getTgtFrame(); } else { return null; } }
private void linkToExternal(String url) { PackagePart thisPP = _sheet.getPackagePart(); if (_link.isSetId() && !_link.getId().isEmpty()) { thisPP.removeRelationship(_link.getId()); } PackageRelationship rel = thisPP.addExternalRelationship(url, XSLFRelation.HYPERLINK.getRelation()); _link.setId(rel.getId()); if (_link.isSetAction()) { _link.unsetAction(); } }
private void extractHyperLinksFromShape(CTShape ctShape, XHTMLContentHandler xhtml) throws SAXException { if (ctShape == null) return; CTShapeNonVisual nvSpPR = ctShape.getNvSpPr(); if (nvSpPR == null) return; CTNonVisualDrawingProps cNvPr = nvSpPR.getCNvPr(); if (cNvPr == null) return; CTHyperlink ctHyperlink = cNvPr.getHlinkClick(); if (ctHyperlink == null) return; String url = drawingHyperlinks.get(ctHyperlink.getId()); if (url != null) { xhtml.startElement("a", "href", url); xhtml.characters(url); xhtml.endElement("a"); } CTHyperlink ctHoverHyperlink = cNvPr.getHlinkHover(); if (ctHoverHyperlink == null) return; url = drawingHyperlinks.get(ctHoverHyperlink.getId()); if (url != null) { xhtml.startElement("a", "href", url); xhtml.characters(url); xhtml.endElement("a"); } }
public void setAddress(XSLFSlide slide){ XSLFSheet sheet = _r.getParentParagraph().getParentShape().getSheet(); PackageRelationship rel = sheet.getPackagePart(). addRelationship(slide.getPackagePart().getPartName(), TargetMode.INTERNAL, XSLFRelation.SLIDE.getRelation()); _link.setId(rel.getId()); _link.setAction("ppaction://hlinksldjump"); }
public XDDFHyperlink(String id) { this(CTHyperlink.Factory.newInstance()); this.link.setId(id); }
public void example() throws Exception{ XWPFDocument document = new XWPFDocument(); //Append a link to appendExternalHyperlink("https://poi.apache.org", " Link to POI", document.createParagraph()); document.write(new FileOutputStream("resultat.docx")); } /** * Appends an external hyperlink to the paragraph. * * @param url The URL to the external target * @param text The linked text * @param paragraph the paragraph the link will be appended to. */ public static void appendExternalHyperlink(String url, String text, XWPFParagraph paragraph){ //Add the link as External relationship String id=paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId(); //Append the link and bind it to the relationship CTHyperlink cLink=paragraph.getCTP().addNewHyperlink(); cLink.setId(id); //Create the linked text CTText ctText=CTText.Factory.newInstance(); ctText.setStringValue(text); CTR ctr=CTR.Factory.newInstance(); ctr.setTArray(new CTText[]{ctText}); //Insert the linked text into the link cLink.setRArray(new CTR[]{ctr}); }
public String getAction() { if (link.isSetAction()) { return link.getAction(); } else { return null; } }
public XDDFExtensionList getExtensionList() { if (link.isSetExtLst()) { return new XDDFExtensionList(link.getExtLst()); } else { return null; } }
public Boolean getHighlightClick() { if (link.isSetHighlightClick()) { return link.getHighlightClick(); } else { return null; } }
public XDDFHyperlink(String id, String action) { this(id); this.link.setAction(action); }
@Override public HyperlinkType getType() { String action = _link.getAction(); if (action == null) { action = ""; } if (action.equals("ppaction://hlinksldjump") || action.startsWith("ppaction://hlinkshowjump")) { return HyperlinkType.DOCUMENT; } String address = getAddress(); if (address == null) { address = ""; } if (address.startsWith("mailto:")) { return HyperlinkType.EMAIL; } else { return HyperlinkType.URL; } }
private void linkToExternal(String url) { PackagePart thisPP = _sheet.getPackagePart(); if (_link.isSetId() && !_link.getId().isEmpty()) { thisPP.removeRelationship(_link.getId()); } PackageRelationship rel = thisPP.addExternalRelationship(url, XSLFRelation.HYPERLINK.getRelation()); _link.setId(rel.getId()); if (_link.isSetAction()) { _link.unsetAction(); } }