diff --git a/src/java/org/apache/poi/util/StringUtil.java b/src/java/org/apache/poi/util/StringUtil.java index 673b5246e..957068a67 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 92e936528..a2eadc52d 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