DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7213>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7213

[Patch] Header and Footer Records fix?

           Summary: [Patch] Header and Footer Records fix?
           Product: POI
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: HSSF
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Index: src/java/org/apache/poi/hssf/record/FooterRecord.java
===================================================================
RCS file: /home/cvspublic/jakarta-
poi/src/java/org/apache/poi/hssf/record/FooterRecord.java,v
retrieving revision 1.4
diff -u -r1.4 FooterRecord.java
--- src/java/org/apache/poi/hssf/record/FooterRecord.java       1 Mar 2002 
13:10:15 -0000  1.4
+++ src/java/org/apache/poi/hssf/record/FooterRecord.java       18 Mar 2002 
17:00:17 -0000
@@ -63,6 +63,7 @@
  * Description:  Specifies the footer for a sheet<P>
  * REFERENCE:  PG 317 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
<P>
  * @author Andrew C. Oliver (acoliver at apache dot org)
+ * @author Shawn Laubach ([EMAIL PROTECTED]) Modified 3/14/02
  * @version 2.0-pre
  */
 
@@ -117,7 +118,7 @@
         if (size > 0)
         {
             field_1_footer_len = data[ 0 + offset ];
-            field_2_footer     = new String(data, 1 + offset,
+            field_2_footer     = new String(data, 3 + offset, // [Shawn] 
Changed 1 to 3 for offset of string
                                             LittleEndian.ubyteToInt( 
field_1_footer_len) );
         }
     }
@@ -153,9 +154,9 @@
      * @see #getFooter()
      */
 
-    public byte getFooterLength()
+    public short getFooterLength()
     {
-        return field_1_footer_len;
+        return (short)(0xFF & field_1_footer_len); // [Shawn] Fixed needing 
unsigned byte
     }
 
     /**
@@ -189,15 +190,15 @@
 
         if (getFooterLength() > 0)
         {
-            len++;
+            len+=3; // [Shawn] Fixed for two null bytes in the length
         }
         LittleEndian.putShort(data, 0 + offset, sid);
         LittleEndian.putShort(data, 2 + offset,
                               ( short ) ((len - 4) + getFooterLength()));
         if (getFooterLength() > 0)
         {
-            data[ 4 + offset ] = getFooterLength();
-            StringUtil.putCompressedUnicode(getFooter(), data, 5 + offset);
+            data[ 4 + offset ] = (byte)getFooterLength();
+            StringUtil.putCompressedUnicode(getFooter(), data, 7 + offset); // 
[Shawn] Place the string in the correct offset
         }
         return getRecordSize();
     }
@@ -208,7 +209,7 @@
 
         if (getFooterLength() > 0)
         {
-            retval++;
+            retval+=3; // [Shawn] Fixed for two null bytes in the length
         }
         return retval + getFooterLength();
     }
Index: src/java/org/apache/poi/hssf/record/HeaderRecord.java
===================================================================
RCS file: /home/cvspublic/jakarta-
poi/src/java/org/apache/poi/hssf/record/HeaderRecord.java,v
retrieving revision 1.4
diff -u -r1.4 HeaderRecord.java
--- src/java/org/apache/poi/hssf/record/HeaderRecord.java       1 Mar 2002 
13:10:15 -0000  1.4
+++ src/java/org/apache/poi/hssf/record/HeaderRecord.java       18 Mar 2002 
17:00:17 -0000
@@ -63,6 +63,7 @@
  * Description:  Specifies a header for a sheet<P>
  * REFERENCE:  PG 321 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
<P>
  * @author Andrew C. Oliver (acoliver at apache dot org)
+ * @author Shawn Laubach ([EMAIL PROTECTED]) Modified 3/14/02
  * @version 2.0-pre
  */
 
@@ -117,7 +118,7 @@
         if (size > 0)
         {
             field_1_header_len = data[ 0 + offset ];
-            field_2_header     = new String(data, 1 + offset,
+            field_2_header     = new String(data, 3 + offset, // [Shawn] 
Changed 1 to 3 for offset of string
                                             LittleEndian.ubyteToInt
(field_1_header_len));
         }
     }
@@ -153,9 +154,9 @@
      * @see #getHeader()
      */
 
-    public byte getHeaderLength()
+    public short getHeaderLength()
     {
-        return field_1_header_len;
+        return (short)(0xFF & field_1_header_len); // [Shawn] Fixed needing 
unsigned byte
     }
 
     /**
@@ -189,15 +190,16 @@
 
         if (getHeaderLength() != 0)
         {
-            len++;
+            len+=3; // [Shawn] Fixed for two null bytes in the length
         }
         LittleEndian.putShort(data, 0 + offset, sid);
         LittleEndian.putShort(data, 2 + offset,
                               ( short ) ((len - 4) + getHeaderLength()));
+
         if (getHeaderLength() > 0)
         {
-            data[ 4 + offset ] = getHeaderLength();
-            StringUtil.putCompressedUnicode(getHeader(), data, 5 + offset);
+            data[ 4 + offset ] = (byte)getHeaderLength();
+            StringUtil.putCompressedUnicode(getHeader(), data, 7 + offset); // 
[Shawn] Place the string in the correct offset
         }
         return getRecordSize();
     }
@@ -208,7 +210,7 @@
 
         if (getHeaderLength() != 0)
         {
-            retval++;
+            retval+=3; // [Shawn] Fixed for two null bytes in the length
         }
         retval += getHeaderLength();
         return retval;

Reply via email to