Search in sources :

Example 1 with ExHyperlinkAtom

use of org.apache.poi.hslf.record.ExHyperlinkAtom in project poi by apache.

the class HSLFHyperlink method createHyperlink.

/**
     * 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;
}
Also used : ExHyperlinkAtom(org.apache.poi.hslf.record.ExHyperlinkAtom) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) ExHyperlink(org.apache.poi.hslf.record.ExHyperlink) InteractiveInfo(org.apache.poi.hslf.record.InteractiveInfo)

Example 2 with ExHyperlinkAtom

use of org.apache.poi.hslf.record.ExHyperlinkAtom in project poi by apache.

the class HSLFHyperlink method createHyperlink.

/**
     * Creates a new Hyperlink for a textrun.
     * This is only a helper method - use {@link HSLFTextRun#createHyperlink()} instead!
     *
     * @param run the run which receives the hyperlink
     * @return the new hyperlink
     * 
     * @see HSLFTextRun#createHyperlink()
     */
/* package */
static HSLFHyperlink createHyperlink(HSLFTextRun run) {
    // TODO: check if a hyperlink already exists
    ExHyperlink exHyper = new ExHyperlink();
    int linkId = run.getTextParagraph().getSheet().getSlideShow().addToObjListAtom(exHyper);
    ExHyperlinkAtom obj = exHyper.getExHyperlinkAtom();
    obj.setNumber(linkId);
    InteractiveInfo info = new InteractiveInfo();
    info.getInteractiveInfoAtom().setHyperlinkID(linkId);
    // don't add the hyperlink now to text paragraph records
    // this will be done, when the paragraph is saved
    HSLFHyperlink hyper = new HSLFHyperlink(exHyper, info);
    hyper.linkToNextSlide();
    TxInteractiveInfoAtom txinfo = new TxInteractiveInfoAtom();
    int startIdx = run.getTextParagraph().getStartIdxOfTextRun(run);
    int endIdx = startIdx + run.getLength();
    txinfo.setStartIndex(startIdx);
    txinfo.setEndIndex(endIdx);
    hyper.setTextRunInfo(txinfo);
    run.setHyperlink(hyper);
    return hyper;
}
Also used : ExHyperlinkAtom(org.apache.poi.hslf.record.ExHyperlinkAtom) ExHyperlink(org.apache.poi.hslf.record.ExHyperlink) TxInteractiveInfoAtom(org.apache.poi.hslf.record.TxInteractiveInfoAtom) InteractiveInfo(org.apache.poi.hslf.record.InteractiveInfo)

Aggregations

ExHyperlink (org.apache.poi.hslf.record.ExHyperlink)2 ExHyperlinkAtom (org.apache.poi.hslf.record.ExHyperlinkAtom)2 InteractiveInfo (org.apache.poi.hslf.record.InteractiveInfo)2 HSLFEscherClientDataRecord (org.apache.poi.hslf.record.HSLFEscherClientDataRecord)1 TxInteractiveInfoAtom (org.apache.poi.hslf.record.TxInteractiveInfoAtom)1