From: Nick Burch Date: Sun, 31 Aug 2008 16:37:39 +0000 (+0000) Subject: Start to support HPBF hyperlinks X-Git-Tag: REL_3_2_FINAL~112 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea9ed46b9a7c97148a550f11f87b59cc079af9e9;p=poi.git Start to support HPBF hyperlinks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@690726 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java index 673b5246e1..957068a673 100644 --- a/src/java/org/apache/poi/util/StringUtil.java +++ b/src/java/org/apache/poi/util/StringUtil.java @@ -68,7 +68,7 @@ public class StringUtil { throw new ArrayIndexOutOfBoundsException("Illegal offset"); } if ((len < 0) || (((string.length - offset) / 2) < len)) { - throw new IllegalArgumentException("Illegal length"); + throw new IllegalArgumentException("Illegal length " + len); } try { diff --git a/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java b/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java index 92e936528a..a2eadc52d9 100644 --- a/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java +++ b/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCPLCBit.java @@ -17,6 +17,7 @@ package org.apache.poi.hpbf.model.qcbits; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.StringUtil; /** @@ -168,8 +169,98 @@ public class QCPLCBit extends QCBit { * Type 12 holds hyperlinks, and is very complex. */ public static class Type12 extends QCPLCBit { + private String[] hyperlinks; + + private static final int oneStartsAt = 0x4c; + private static final int twoStartsAt = 0x68; + private static final int threePlusIncrement = 22; + private Type12(String thingType, String bitType, byte[] data) { super(thingType, bitType, data); + + // How many hyperlinks do we really have? + // (zero hyperlinks gets numberOfPLCs=1) + if(data.length == 0x34) { + hyperlinks = new String[0]; + } else { + hyperlinks = new String[numberOfPLCs]; + } + + // We have 4 bytes, then the start point of each + // hyperlink, then the end point of the text. + preData = new int[1+numberOfPLCs+1]; + for(int i=0; i= 2) { + until = twoStartsAt + (numberOfPLCs-2)*threePlusIncrement; + } + + plcValA = new long[(until-at)/2]; + plcValB = new long[0]; + for(int i=0; i