Methods Summary |
---|
protected static org.apache.poi.hslf.model.Hyperlink[] | find(org.apache.poi.hslf.model.TextRun run)Find hyperlinks in a text 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 != null) find(records, exobj, lst);
Hyperlink[] links = null;
if (lst.size() > 0){
links = new Hyperlink[lst.size()];
lst.toArray(links);
}
return links;
|
protected static org.apache.poi.hslf.model.Hyperlink | find(org.apache.poi.hslf.model.Shape shape)Find hyperlink assigned to the supplied 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();
List spchild = spContainer.getChildRecords();
for (Iterator it = spchild.iterator(); it.hasNext(); ) {
EscherRecord obj = (EscherRecord)it.next();
if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID){
byte[] data = ((EscherContainerRecord)obj).serialize();
Record[] records = Record.findChildRecords(data, 8, data.length-8);
if(records != null) find(records, exobj, lst);
}
}
return lst.size() == 1 ? (Hyperlink)lst.get(0) : null;
|
private static void | find(org.apache.poi.hslf.record.Record[] records, org.apache.poi.hslf.record.ExObjList exobj, java.util.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);
}
}
}
|
public java.lang.String | getAddress()Gets the hyperlink URL
return address;
|
public int | getEndIndex()Gets the ending character position
return endIndex;
|
public int | getStartIndex()Gets the beginning character position
return startIndex;
|
public java.lang.String | getTitle()Gets the hyperlink user-friendly title (if different from URL)
return title;
|
public int | getType()Gets the type of the hyperlink action.
Must be a ACTION_* constant defined in InteractiveInfoAtom
return type;
|