From: Nick Burch Date: Fri, 1 Feb 2008 16:52:58 +0000 (+0000) Subject: More Hyperlink support. Doesn't end up in HSSFCell just yet, as the records are in... X-Git-Tag: REL_3_0_3_BETA1~158 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a755da02a84436d3ab38048e52e4e35806fc9e91;p=poi.git More Hyperlink support. Doesn't end up in HSSFCell just yet, as the records are in the wrong bit of the file, so don't get associated with the sheet. All tests still passing though git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@617555 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java index 08c236cda1..2ba50857ca 100644 --- a/src/java/org/apache/poi/hssf/model/Workbook.java +++ b/src/java/org/apache/poi/hssf/model/Workbook.java @@ -93,6 +93,8 @@ public class Workbook implements Model protected ArrayList formats = new ArrayList(); protected ArrayList names = new ArrayList(); + + protected ArrayList hyperlinks = new ArrayList(); protected int numxfs = 0; // hold the number of extended format records protected int numfonts = 0; // hold the number of font records @@ -133,7 +135,8 @@ public class Workbook implements Model Workbook retval = new Workbook(); ArrayList records = new ArrayList(recs.size() / 3); - for (int k = 0; k < recs.size(); k++) { + int k; + for (k = 0; k < recs.size(); k++) { Record rec = ( Record ) recs.get(k); if (rec.getSid() == EOFRecord.sid) { @@ -248,6 +251,17 @@ public class Workbook implements Model // retval.records.supbookpos = retval.records.bspos + 1; // retval.records.namepos = retval.records.supbookpos + 1; // } + + // Look for other interesting values that + // follow the EOFRecord + for ( ; k < recs.size(); k++) { + Record rec = ( Record ) recs.get(k); + switch (rec.getSid()) { + case HyperlinkRecord.sid: + retval.hyperlinks.add(rec); + break; + } + } retval.records.setRecords(records); @@ -2116,6 +2130,11 @@ public class Workbook implements Model return null; } + public List getHyperlinks() + { + return hyperlinks; + } + public List getRecords() { return records.getRecords(); diff --git a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java index 36a26f4151..ec91dc3419 100644 --- a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java +++ b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java @@ -14,11 +14,6 @@ limitations under the License. ==================================================================== */ -/* - * HyperlinkRecord - * - * Created on February 20th, 2005, 16:00 PM - */ package org.apache.poi.hssf.record; import java.io.IOException; @@ -27,20 +22,15 @@ import java.net.URL; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.poi.util.HexDump; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.StringUtil; -/**The HyperlinkRecord wraps an HLINK-record from the Excel-97 format +/** + * The HyperlinkRecord wraps an HLINK-record + * from the Excel-97 format. + * Supports only external links for now (eg http://) * - * @version 20-feb-2005 * @author Mark Hissink Muller