@Override public String getLabel() { return exHyper.getLinkTitle(); }
@Override public String getAddress() { return exHyper.getLinkURL(); }
private void linkToDocument(int sheetNumber, int slideNumber, String alias, int options) { exHyper.setLinkURL(sheetNumber+","+slideNumber+","+alias); exHyper.setLinkTitle(alias); exHyper.setLinkOptions(options); }
/** * 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; } }
/** * 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; }
private static void find(Record[] records, ExObjList exobj, List out){ for (int i = 0; i < records.length; i++) { //see if we have InteractiveInfo in the textrun's records if( records[i] instanceof InteractiveInfo){ InteractiveInfo hldr = (InteractiveInfo)records[i]; InteractiveInfoAtom info = hldr.getInteractiveInfoAtom(); int id = info.getHyperlinkID(); ExHyperlink linkRecord = exobj.get(id); if (linkRecord != null){ Hyperlink link = new Hyperlink(); link.title = linkRecord.getLinkTitle(); link.address = linkRecord.getLinkURL(); link.type = info.getAction(); if (++i < records.length && records[i] instanceof TxInteractiveInfoAtom){ TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[i]; link.startIndex = txinfo.getStartIndex(); link.endIndex = txinfo.getEndIndex(); } out.add(link); } } } } }
/** * Set things up, and find our more interesting children */ protected ExHyperlink(byte[] source, int start, int len) { // Grab the header _header = new byte[8]; System.arraycopy(source,start,_header,0,8); // Find our children _children = Record.findChildRecords(source,start+8,len-8); findInterestingChildren(); }
public int getId() { return exHyper.getExHyperlinkAtom().getNumber(); }
/** * Write the contents of the record back, so it can be written * to disk */ public void writeOut(OutputStream out) throws IOException { writeOut(_header[0],_header[1],_type,_children,out); } }
@Override public void setLabel(String label) { exHyper.setLinkTitle(label); }
@Override public void setAddress(String str) { exHyper.setLinkURL(str); }
ExHyperlink exHyper = new ExHyperlink(); int linkId = run.getTextParagraph().getSheet().getSlideShow().addToObjListAtom(exHyper); ExHyperlinkAtom obj = exHyper.getExHyperlinkAtom(); obj.setNumber(linkId); InteractiveInfo info = new InteractiveInfo();
/** * Set things up, and find our more interesting children */ protected ExHyperlink(byte[] source, int start, int len) { // Grab the header _header = new byte[8]; System.arraycopy(source,start,_header,0,8); // Find our children _children = Record.findChildRecords(source,start+8,len-8); findInterestingChildren(); }
/** * Lookup a hyperlink by its unique id * * @param id hyperlink id * @return found <code>ExHyperlink</code> or <code>null</code> */ public ExHyperlink get(int id){ for(int i=0; i<_children.length; i++) { if(_children[i] instanceof ExHyperlink) { ExHyperlink rec = (ExHyperlink)_children[i]; if (rec.getExHyperlinkAtom().getNumber() == id){ return rec; } } } return null; } }
/** * Write the contents of the record back, so it can be written * to disk */ public void writeOut(OutputStream out) throws IOException { writeOut(_header[0],_header[1],_type,_children,out); } }
@Override public void linkToUrl(String url) { InteractiveInfoAtom iia = info.getInteractiveInfoAtom(); iia.setAction(InteractiveInfoAtom.ACTION_HYPERLINK); iia.setJump(InteractiveInfoAtom.JUMP_NONE); iia.setHyperlinkType(InteractiveInfoAtom.LINK_Url); exHyper.setLinkURL(url); exHyper.setLinkTitle(url); exHyper.setLinkOptions(0x10); }
/** * Create a new ExHyperlink, with blank fields */ public ExHyperlink() { _header = new byte[8]; _children = new Record[3]; // Setup our header block _header[0] = 0x0f; // We are a container record LittleEndian.putShort(_header, 2, (short)_type); // Setup our child records CString csa = new CString(); CString csb = new CString(); csa.setOptions(0x00); csb.setOptions(0x10); _children[0] = new ExHyperlinkAtom(); _children[1] = csa; _children[2] = csb; findInterestingChildren(); }
/** * Lookup a hyperlink by its unique id * * @param id hyperlink id * @return found <code>ExHyperlink</code> or <code>null</code> */ public ExHyperlink get(int id){ for(int i=0; i<_children.length; i++) { if(_children[i] instanceof ExHyperlink) { ExHyperlink rec = (ExHyperlink)_children[i]; if (rec.getExHyperlinkAtom().getNumber() == id){ return rec; } } } return null; } }
/** * Gets the type of the hyperlink action. * Must be a <code>LINK_*</code> constant</code> * * @return the hyperlink URL * @see InteractiveInfoAtom */ @Override public HyperlinkType getType() { switch (info.getInteractiveInfoAtom().getHyperlinkType()) { case InteractiveInfoAtom.LINK_Url: return (exHyper.getLinkURL().startsWith("mailto:")) ? HyperlinkType.EMAIL : HyperlinkType.URL; case InteractiveInfoAtom.LINK_NextSlide: case InteractiveInfoAtom.LINK_PreviousSlide: case InteractiveInfoAtom.LINK_FirstSlide: case InteractiveInfoAtom.LINK_LastSlide: case InteractiveInfoAtom.LINK_SlideNumber: return HyperlinkType.DOCUMENT; case InteractiveInfoAtom.LINK_CustomShow: case InteractiveInfoAtom.LINK_OtherPresentation: case InteractiveInfoAtom.LINK_OtherFile: return HyperlinkType.FILE; default: case InteractiveInfoAtom.LINK_NULL: return HyperlinkType.NONE; } }
@Override public void linkToEmail(String emailAddress) { InteractiveInfoAtom iia = info.getInteractiveInfoAtom(); iia.setAction(InteractiveInfoAtom.ACTION_HYPERLINK); iia.setJump(InteractiveInfoAtom.JUMP_NONE); iia.setHyperlinkType(InteractiveInfoAtom.LINK_Url); exHyper.setLinkURL("mailto:"+emailAddress); exHyper.setLinkTitle(emailAddress); exHyper.setLinkOptions(0x10); }