Fixed zero length Label string reading

Fixed incorrect offset for uncompressed unicode


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353355 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Height 2003-09-17 05:34:29 +00:00
parent 9d22984e3d
commit dc4dd18965

View File

@ -150,15 +150,17 @@ public class LabelRecord
field_3_xf_index = LittleEndian.getShort(data, 4 + offset); field_3_xf_index = LittleEndian.getShort(data, 4 + offset);
field_4_string_len = LittleEndian.getShort(data, 6 + offset); field_4_string_len = LittleEndian.getShort(data, 6 + offset);
field_5_unicode_flag = data[ 8 + offset ]; field_5_unicode_flag = data[ 8 + offset ];
if (isUnCompressedUnicode()) if (field_4_string_len > 0) {
{ if (isUnCompressedUnicode())
field_6_value = StringUtil.getFromUnicodeBE(data, 8 + offset, {
field_4_string_len); field_6_value = StringUtil.getFromUnicodeBE(data, 9 + offset,
} field_4_string_len);
else }
{ else
field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength()); {
} field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
}
} else field_6_value = null;
} }
/* READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST! /* READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST!
@ -237,6 +239,27 @@ public class LabelRecord
return this.sid; return this.sid;
} }
public String toString()
{
StringBuffer buffer = new StringBuffer();
buffer.append("[LABEL]\n");
buffer.append(" .row = ")
.append(Integer.toHexString(getRow())).append("\n");
buffer.append(" .column = ")
.append(Integer.toHexString(getColumn())).append("\n");
buffer.append(" .xfindex = ")
.append(Integer.toHexString(getXFIndex())).append("\n");
buffer.append(" .string_len = ")
.append(Integer.toHexString(field_4_string_len)).append("\n");
buffer.append(" .unicode_flag = ")
.append(Integer.toHexString(field_5_unicode_flag)).append("\n");
buffer.append(" .value = ")
.append(getValue()).append("\n");
buffer.append("[/LABEL]\n");
return buffer.toString();
}
public boolean isBefore(CellValueRecordInterface i) public boolean isBefore(CellValueRecordInterface i)
{ {
if (this.getRow() > i.getRow()) if (this.getRow() > i.getRow())