Applied fixes from Shawn Laubach for footer and header records
PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7c64962203
commit
833b661cdb
@ -117,7 +117,7 @@ public class FooterRecord
|
|||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
field_1_footer_len = data[ 0 + offset ];
|
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) );
|
LittleEndian.ubyteToInt( field_1_footer_len) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,9 +153,9 @@ public class FooterRecord
|
|||||||
* @see #getFooter()
|
* @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 +189,15 @@ public class FooterRecord
|
|||||||
|
|
||||||
if (getFooterLength() > 0)
|
if (getFooterLength() > 0)
|
||||||
{
|
{
|
||||||
len++;
|
len+=3; // [Shawn] Fixed for two null bytes in the length
|
||||||
}
|
}
|
||||||
LittleEndian.putShort(data, 0 + offset, sid);
|
LittleEndian.putShort(data, 0 + offset, sid);
|
||||||
LittleEndian.putShort(data, 2 + offset,
|
LittleEndian.putShort(data, 2 + offset,
|
||||||
( short ) ((len - 4) + getFooterLength()));
|
( short ) ((len - 4) + getFooterLength()));
|
||||||
if (getFooterLength() > 0)
|
if (getFooterLength() > 0)
|
||||||
{
|
{
|
||||||
data[ 4 + offset ] = getFooterLength();
|
data[ 4 + offset ] = (byte)getFooterLength();
|
||||||
StringUtil.putCompressedUnicode(getFooter(), data, 5 + offset);
|
StringUtil.putCompressedUnicode(getFooter(), data, 7 + offset); // [Shawn] Place the string in the correct offset
|
||||||
}
|
}
|
||||||
return getRecordSize();
|
return getRecordSize();
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ public class FooterRecord
|
|||||||
|
|
||||||
if (getFooterLength() > 0)
|
if (getFooterLength() > 0)
|
||||||
{
|
{
|
||||||
retval++;
|
retval+=3; // [Shawn] Fixed for two null bytes in the length
|
||||||
}
|
}
|
||||||
return retval + getFooterLength();
|
return retval + getFooterLength();
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class HeaderRecord
|
|||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
field_1_header_len = data[ 0 + offset ];
|
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));
|
LittleEndian.ubyteToInt(field_1_header_len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,9 +153,9 @@ public class HeaderRecord
|
|||||||
* @see #getHeader()
|
* @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 +189,16 @@ public class HeaderRecord
|
|||||||
|
|
||||||
if (getHeaderLength() != 0)
|
if (getHeaderLength() != 0)
|
||||||
{
|
{
|
||||||
len++;
|
len+=3; // [Shawn] Fixed for two null bytes in the length
|
||||||
}
|
}
|
||||||
LittleEndian.putShort(data, 0 + offset, sid);
|
LittleEndian.putShort(data, 0 + offset, sid);
|
||||||
LittleEndian.putShort(data, 2 + offset,
|
LittleEndian.putShort(data, 2 + offset,
|
||||||
( short ) ((len - 4) + getHeaderLength()));
|
( short ) ((len - 4) + getHeaderLength()));
|
||||||
|
|
||||||
if (getHeaderLength() > 0)
|
if (getHeaderLength() > 0)
|
||||||
{
|
{
|
||||||
data[ 4 + offset ] = getHeaderLength();
|
data[ 4 + offset ] = (byte)getHeaderLength();
|
||||||
StringUtil.putCompressedUnicode(getHeader(), data, 5 + offset);
|
StringUtil.putCompressedUnicode(getHeader(), data, 7 + offset); // [Shawn] Place the string in the correct offset
|
||||||
}
|
}
|
||||||
return getRecordSize();
|
return getRecordSize();
|
||||||
}
|
}
|
||||||
@ -208,7 +209,7 @@ public class HeaderRecord
|
|||||||
|
|
||||||
if (getHeaderLength() != 0)
|
if (getHeaderLength() != 0)
|
||||||
{
|
{
|
||||||
retval++;
|
retval+=3; // [Shawn] Fixed for two null bytes in the length
|
||||||
}
|
}
|
||||||
retval += getHeaderLength();
|
retval += getHeaderLength();
|
||||||
return retval;
|
return retval;
|
||||||
|
Loading…
Reference in New Issue
Block a user