You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by jh...@apache.org on 2003/09/17 07:34:29 UTC

cvs commit: jakarta-poi/src/java/org/apache/poi/hssf/record LabelRecord.java

jheight     2003/09/16 22:34:29

  Modified:    src/java/org/apache/poi/hssf/record LabelRecord.java
  Log:
  Fixed zero length Label string reading
  Fixed incorrect offset for uncompressed unicode
  
  Revision  Changes    Path
  1.8       +32 -9     jakarta-poi/src/java/org/apache/poi/hssf/record/LabelRecord.java
  
  Index: LabelRecord.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/LabelRecord.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LabelRecord.java	19 Aug 2003 14:07:40 -0000	1.7
  +++ LabelRecord.java	17 Sep 2003 05:34:29 -0000	1.8
  @@ -150,15 +150,17 @@
           field_3_xf_index     = LittleEndian.getShort(data, 4 + offset);
           field_4_string_len   = LittleEndian.getShort(data, 6 + offset);
           field_5_unicode_flag = data[ 8 + offset ];
  -        if (isUnCompressedUnicode())
  -        {
  -            field_6_value = StringUtil.getFromUnicodeBE(data, 8 + offset,
  -                                                      field_4_string_len);
  -        }
  -        else
  -        {
  -            field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
  -        }
  +        if (field_4_string_len > 0) {
  +          if (isUnCompressedUnicode())
  +          {
  +              field_6_value = StringUtil.getFromUnicodeBE(data, 9 + offset,
  +                                                        field_4_string_len);
  +          }
  +          else
  +          {
  +              field_6_value = StringUtil.getFromCompressedUnicode(data, 9 + offset, getStringLength());
  +          }
  +        } else field_6_value = null;
       }
   
   /* READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST!
  @@ -236,6 +238,27 @@
       {
           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)
       {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org