diff --git a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java index 76f9f531d..36a26f415 100644 --- a/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java +++ b/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java @@ -65,11 +65,13 @@ public class HyperlinkRecord extends Record implements CellValueRecordInterface private short field_3_xf_index; private short field_4_unknown; private byte[] field_5_unknown; - private int field_6_url_len; - private int field_7_label_len; - private String field_8_label; - private byte[] field_9_unknown; - private String field_10_url; + private int field_6_label_opts; + private int field_7_url_len; + private int field_8_label_len; + private String field_9_label; + private byte[] field_10_unknown; + private int field_11_url_opts; + private String field_12_url; /** Blank Constructor */ public HyperlinkRecord() @@ -186,33 +188,51 @@ public class HyperlinkRecord extends Record implements CellValueRecordInterface */ protected void fillFields(RecordInputStream in) { +// System.err.println(in.currentSid); +// System.err.println(in.currentLength); +// for(int i=0; i<300; i++) { +// System.err.println(in.readByte()); +// } +// if(1==1) +// throw new IllegalArgumentException(""); + field_1_row = in.readUShort(); field_2_column = in.readShort(); field_3_xf_index = in.readShort(); field_4_unknown = in.readShort(); - // Next up is 20 bytes we don't get - field_5_unknown = new byte[20]; + // Next up is 16 bytes we don't get + field_5_unknown = new byte[16]; try { in.read(field_5_unknown); } catch(IOException e) { throw new IllegalStateException(e); } + // Some sort of opts + field_6_label_opts = in.readInt(); + // Now for lengths, in characters - field_6_url_len = in.readInt(); - field_7_label_len = in.readInt(); + field_7_url_len = in.readInt(); + field_8_label_len = in.readInt(); // Now we have the label, as little endian unicode, // with a trailing \0 - field_8_label = in.readUnicodeLEString(field_7_label_len); + field_9_label = in.readUnicodeLEString(field_8_label_len); // Next up is some more data we can't make sense of - field_9_unknown = new byte[20]; + field_10_unknown = new byte[16]; try { - in.read(field_9_unknown); + in.read(field_10_unknown); } catch(IOException e) { throw new IllegalStateException(e); } + // Might need to nudge the length by one byte + // This is an empirical hack! + field_11_url_opts = in.readInt(); + if(field_11_url_opts == 44) { + field_7_url_len--; + } + // Finally it's the URL - field_10_url = in.readUnicodeLEString(field_6_url_len); + field_12_url = in.readUnicodeLEString(field_7_url_len); } /* (non-Javadoc) @@ -247,19 +267,23 @@ public class HyperlinkRecord extends Record implements CellValueRecordInterface offset++; } - LittleEndian.putInt(data, offset, field_6_url_len); + LittleEndian.putInt(data, offset, field_6_label_opts); offset += 4; - LittleEndian.putInt(data, offset, field_7_label_len); + LittleEndian.putInt(data, offset, field_7_url_len); offset += 4; - StringUtil.putUnicodeLE(field_8_label, data, offset); - offset += field_8_label.length()*2; + LittleEndian.putInt(data, offset, field_8_label_len); + offset += 4; + StringUtil.putUnicodeLE(field_9_label, data, offset); + offset += field_9_label.length()*2; - for(int i=0; i