diff options
Diffstat (limited to 'src/java/org')
-rw-r--r-- | src/java/org/apache/poi/hssf/record/HyperlinkRecord.java | 21 | ||||
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java | 14 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java index 94be338f07..ed7fee1fd2 100644 --- a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java +++ b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java @@ -675,6 +675,27 @@ public final class HyperlinkRecord extends StandardRecord { } /** + * Based on the link options, is this a url? + */ + public boolean isUrlLink() { + return (_linkOpts & HLINK_URL) > 0 + && (_linkOpts & HLINK_ABS) > 0; + } + /** + * Based on the link options, is this a file? + */ + public boolean isFileLink() { + return (_linkOpts & HLINK_URL) > 0 + && (_linkOpts & HLINK_ABS) == 0; + } + /** + * Based on the link options, is this a document? + */ + public boolean isDocumentLink() { + return (_linkOpts & HLINK_PLACE) > 0; + } + + /** * Initialize a new url link */ public void newUrlLink() { diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java index 669f52f065..711c6d145e 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java @@ -87,6 +87,20 @@ public class HSSFHyperlink implements Hyperlink { protected HSSFHyperlink( HyperlinkRecord record ) { this.record = record; + + // Figure out the type + if(record.isFileLink()) { + link_type = LINK_FILE; + } else if(record.isDocumentLink()) { + link_type = LINK_DOCUMENT; + } else { + if(record.getAddress() != null && + record.getAddress().startsWith("mailto:")) { + link_type = LINK_EMAIL; + } else { + link_type = LINK_URL; + } + } } /** |