Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ====================================================================
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
 
 package org.apache.poi.hslf.model;
 
 
 import java.util.List;
Represents a hyperlink in a PowerPoint document

Author(s):
Yegor Kozlov
 
 public final class Hyperlink {
     public static final byte LINK_NEXTSLIDE = .;
     public static final byte LINK_PREVIOUSSLIDE = .;
     public static final byte LINK_FIRSTSLIDE = .;
     public static final byte LINK_LASTSLIDE = .;
     public static final byte LINK_SLIDENUMBER = .;
     public static final byte LINK_URL = .;
     public static final byte LINK_NULL = .;
 
     private int id=-1;
     private int type;
     private String address;
     private String title;
     private int startIndexendIndex;

    
Gets the type of the hyperlink action. Must be a LINK_* constant

Returns:
the hyperlink URL
See also:
org.apache.poi.hslf.record.InteractiveInfoAtom
 
     public int getType() {
         return ;
     }
 
     public void setType(int val) {
          = val;
         switch(){
             case :
                  = "NEXT";
                  = "1,-1,NEXT";
                 break;
             case :
                  = "PREV";
                  = "1,-1,PREV";
                 break;
             case :
                  = "FIRST";
                  = "1,-1,FIRST";
                 break;
             case :
                  = "LAST";
                  = "1,-1,LAST";
                 break;
             case :
                 break;
             default:
                  = "";
                  = "";
                 break;
         }
     }

    
Gets the hyperlink URL

Returns:
the hyperlink URL
 
     public String getAddress() {
         return ;
     }
 
     public void setAddress(Slide slide) {
         String href = slide._getSheetNumber() + ","+slide.getSlideNumber()+",Slide " + slide.getSlideNumber();
        setAddress(href);;
        setTitle("Slide " + slide.getSlideNumber());
    }
    public void setAddress(String str) {
         = str;
    }
    public int getId() {
        return ;
    }
    public void setId(int id) {
        this. = id;
    }

    
Gets the hyperlink user-friendly title (if different from URL)

Returns:
the hyperlink user-friendly title
    public String getTitle() {
        return ;
    }
    public void setTitle(String str) {
         = str;
    }

    
Gets the beginning character position

Returns:
the beginning character position
    public int getStartIndex() {
        return ;
    }

    
Gets the ending character position

Returns:
the ending character position
    public int getEndIndex() {
        return ;
    }

    
Find hyperlinks in a text run

Parameters:
run TextRun to lookup hyperlinks in
Returns:
found hyperlinks or null if not found
    protected static Hyperlink[] find(TextRun run){
        ArrayList lst = new ArrayList();
        SlideShow ppt = run.getSheet().getSlideShow();
        //document-level container which stores info about all links in a presentation
        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
        if (exobj == null) {
            return null;
        }
        Record[] records = run._records;
        if(records != nullfind(recordsexobjlst);
        Hyperlink[] links = null;
        if (lst.size() > 0){
            links = new Hyperlink[lst.size()];
            lst.toArray(links);
        }
        return links;
    }

    
Find hyperlink assigned to the supplied shape

Parameters:
shape Shape to lookup hyperlink in
Returns:
found hyperlink or null
    protected static Hyperlink find(Shape shape){
        ArrayList lst = new ArrayList();
        SlideShow ppt = shape.getSheet().getSlideShow();
        //document-level container which stores info about all links in a presentation
        ExObjList exobj = ppt.getDocumentRecord().getExObjList();
        if (exobj == null) {
            return null;
        }
        EscherContainerRecord spContainer = shape.getSpContainer();
        for (Iterator<EscherRecordit = spContainer.getChildIterator(); it.hasNext(); ) {
            EscherRecord obj = it.next();
            if (obj.getRecordId() ==  .){
                byte[] data = obj.serialize();
                Record[] records = Record.findChildRecords(data, 8, data.length-8);
                if(records != nullfind(recordsexobjlst);
            }
        }
        return lst.size() == 1 ? (Hyperlink)lst.get(0) : null;
    }
    private static void find(Record[] recordsExObjList exobjList out){
        for (int i = 0; i < records.lengthi++) {
            //see if we have InteractiveInfo in the textrun's records
            ifrecords[iinstanceof 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[iinstanceof TxInteractiveInfoAtom){
                        TxInteractiveInfoAtom txinfo = (TxInteractiveInfoAtom)records[i];
                        link.startIndex = txinfo.getStartIndex();
                        link.endIndex = txinfo.getEndIndex();
                    }
                    out.add(link);
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X