mirror of https://github.com/apache/poi.git
Tidy up.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352810 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f6f4a3fecf
commit
08a23e6608
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
|
@ -55,13 +54,8 @@
|
|||
|
||||
package org.apache.poi.hssf.record;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.poi.util.BinaryTree;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
import sun.awt.image.ByteInterleavedRaster;
|
||||
|
||||
/**
|
||||
* Title: Bound Sheet Record (aka BundleSheet) <P>
|
||||
|
@ -96,9 +90,9 @@ public class BoundSheetRecord
|
|||
* @param data data of the record (should not contain sid/len)
|
||||
*/
|
||||
|
||||
public BoundSheetRecord(short id, short size, byte [] data)
|
||||
public BoundSheetRecord( short id, short size, byte[] data )
|
||||
{
|
||||
super(id, size, data);
|
||||
super( id, size, data );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,16 +104,16 @@ public class BoundSheetRecord
|
|||
* @param offset of the record's data
|
||||
*/
|
||||
|
||||
public BoundSheetRecord(short id, short size, byte [] data, int offset)
|
||||
public BoundSheetRecord( short id, short size, byte[] data, int offset )
|
||||
{
|
||||
super(id, size, data, offset);
|
||||
super( id, size, data, offset );
|
||||
}
|
||||
|
||||
protected void validateSid(short id)
|
||||
protected void validateSid( short id )
|
||||
{
|
||||
if (id != sid)
|
||||
if ( id != sid )
|
||||
{
|
||||
throw new RecordFormatException("NOT A Bound Sheet RECORD");
|
||||
throw new RecordFormatException( "NOT A Bound Sheet RECORD" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,18 +128,20 @@ public class BoundSheetRecord
|
|||
*
|
||||
*/
|
||||
|
||||
protected void fillFields(byte [] data, short size, int offset)
|
||||
protected void fillFields( byte[] data, short size, int offset )
|
||||
{
|
||||
field_1_position_of_BOF = LittleEndian.getInt(data, 0 + offset); // bof
|
||||
field_2_option_flags = LittleEndian.getShort(data, 4 + offset); // flags
|
||||
field_3_sheetname_length = data[ 6 + offset ]; // len(str)
|
||||
field_4_compressed_unicode_flag = data[ 7 + offset ]; // unicode
|
||||
field_1_position_of_BOF = LittleEndian.getInt( data, 0 + offset ); // bof
|
||||
field_2_option_flags = LittleEndian.getShort( data, 4 + offset ); // flags
|
||||
field_3_sheetname_length = data[6 + offset]; // len(str)
|
||||
field_4_compressed_unicode_flag = data[7 + offset]; // unicode
|
||||
|
||||
int nameLength = LittleEndian.ubyteToInt( field_3_sheetname_length );
|
||||
if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 ) {
|
||||
if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 )
|
||||
{
|
||||
field_5_sheetname = StringUtil.getFromUnicodeHigh( data, 8 + offset, nameLength );
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
field_5_sheetname = new String( data, 8 + offset, nameLength );
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +152,7 @@ public class BoundSheetRecord
|
|||
* @param pos offset in bytes
|
||||
*/
|
||||
|
||||
public void setPositionOfBof(int pos)
|
||||
public void setPositionOfBof( int pos )
|
||||
{
|
||||
field_1_position_of_BOF = pos;
|
||||
}
|
||||
|
@ -167,7 +163,7 @@ public class BoundSheetRecord
|
|||
* @param flags to set
|
||||
*/
|
||||
|
||||
public void setOptionFlags(short flags)
|
||||
public void setOptionFlags( short flags )
|
||||
{
|
||||
field_2_option_flags = flags;
|
||||
}
|
||||
|
@ -179,7 +175,7 @@ public class BoundSheetRecord
|
|||
* @see #setSheetname(String)
|
||||
*/
|
||||
|
||||
public void setSheetnameLength(byte len)
|
||||
public void setSheetnameLength( byte len )
|
||||
{
|
||||
field_3_sheetname_length = len;
|
||||
}
|
||||
|
@ -248,7 +244,7 @@ public class BoundSheetRecord
|
|||
|
||||
public byte getRawSheetnameLength()
|
||||
{
|
||||
return (byte)( ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 )
|
||||
return (byte) ( ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 )
|
||||
? 2 * field_3_sheetname_length
|
||||
: field_3_sheetname_length );
|
||||
}
|
||||
|
@ -278,30 +274,30 @@ public class BoundSheetRecord
|
|||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append("[BOUNDSHEET]\n");
|
||||
buffer.append(" .bof = ")
|
||||
.append(Integer.toHexString(getPositionOfBof())).append("\n");
|
||||
buffer.append(" .optionflags = ")
|
||||
.append(Integer.toHexString(getOptionFlags())).append("\n");
|
||||
buffer.append(" .sheetname length= ")
|
||||
.append(Integer.toHexString(getSheetnameLength())).append("\n");
|
||||
buffer.append(" .unicodeflag = ")
|
||||
.append(Integer.toHexString(getCompressedUnicodeFlag()))
|
||||
.append("\n");
|
||||
buffer.append(" .sheetname = ").append(getSheetname())
|
||||
.append("\n");
|
||||
buffer.append("[/BOUNDSHEET]\n");
|
||||
buffer.append( "[BOUNDSHEET]\n" );
|
||||
buffer.append( " .bof = " )
|
||||
.append( Integer.toHexString( getPositionOfBof() ) ).append( "\n" );
|
||||
buffer.append( " .optionflags = " )
|
||||
.append( Integer.toHexString( getOptionFlags() ) ).append( "\n" );
|
||||
buffer.append( " .sheetname length= " )
|
||||
.append( Integer.toHexString( getSheetnameLength() ) ).append( "\n" );
|
||||
buffer.append( " .unicodeflag = " )
|
||||
.append( Integer.toHexString( getCompressedUnicodeFlag() ) )
|
||||
.append( "\n" );
|
||||
buffer.append( " .sheetname = " ).append( getSheetname() )
|
||||
.append( "\n" );
|
||||
buffer.append( "[/BOUNDSHEET]\n" );
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public int serialize(int offset, byte [] data)
|
||||
public int serialize( int offset, byte[] data )
|
||||
{
|
||||
LittleEndian.putShort(data, 0 + offset, sid);
|
||||
LittleEndian.putShort( data, 2 + offset, (short)( 8 + getRawSheetnameLength() ) );
|
||||
LittleEndian.putInt(data, 4 + offset, getPositionOfBof());
|
||||
LittleEndian.putShort(data, 8 + offset, getOptionFlags());
|
||||
data[ 10 + offset ] = (byte)( getSheetnameLength() );
|
||||
data[ 11 + offset ] = getCompressedUnicodeFlag();
|
||||
LittleEndian.putShort( data, 0 + offset, sid );
|
||||
LittleEndian.putShort( data, 2 + offset, (short) ( 8 + getRawSheetnameLength() ) );
|
||||
LittleEndian.putInt( data, 4 + offset, getPositionOfBof() );
|
||||
LittleEndian.putShort( data, 8 + offset, getOptionFlags() );
|
||||
data[10 + offset] = (byte) ( getSheetnameLength() );
|
||||
data[11 + offset] = getCompressedUnicodeFlag();
|
||||
|
||||
if ( ( field_4_compressed_unicode_flag & 0x01 ) == 1 )
|
||||
StringUtil.putUncompressedUnicode( getSheetname(), data, 12 + offset );
|
||||
|
@ -335,7 +331,7 @@ public class BoundSheetRecord
|
|||
|
||||
public int getRecordSize()
|
||||
{
|
||||
// return 30;
|
||||
// Includes sid length + size length
|
||||
return 12 + getRawSheetnameLength();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue