/** * 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; }
/** * Add a hyperlink to this presentation * * @return 0-based index of the hyperlink */ public int addHyperlink(Hyperlink link) { ExObjList lst = (ExObjList) _documentRecord.findFirstOfType(RecordTypes.ExObjList.typeID); if (lst == null) { lst = new ExObjList(); _documentRecord.addChildAfter(lst, _documentRecord.getDocumentAtom()); } ExObjListAtom objAtom = lst.getExObjListAtom(); // increment the object ID seed int objectId = (int) objAtom.getObjectIDSeed() + 1; objAtom.setObjectIDSeed(objectId); ExHyperlink ctrl = new ExHyperlink(); ExHyperlinkAtom obj = ctrl.getExHyperlinkAtom(); obj.setNumber(objectId); ctrl.setLinkURL(link.getAddress()); ctrl.setLinkTitle(link.getTitle()); lst.addChildAfter(ctrl, objAtom); link.setId(objectId); return objectId; } }
ExHyperlink exHyper = new ExHyperlink(); int linkId = run.getTextParagraph().getSheet().getSlideShow().addToObjListAtom(exHyper); ExHyperlinkAtom obj = exHyper.getExHyperlinkAtom();