FileDocCategorySizeDatePackage
EscherBSERecord.javaAPI DocApache Poi 3.0.113125Mon Jan 01 12:39:40 GMT 2007org.apache.poi.ddf

EscherBSERecord

public class EscherBSERecord extends EscherRecord
The BSE record is related closely to the EscherBlipRecord and stores extra information about the blip. A blip record is actually stored inside the BSE record even though the BSE record isn't actually a container record.
author
Glen Stampoultzis
see
EscherBlipRecord

Fields Summary
public static final short
RECORD_ID
public static final String
RECORD_DESCRIPTION
public static final byte
BT_ERROR
public static final byte
BT_UNKNOWN
public static final byte
BT_EMF
public static final byte
BT_WMF
public static final byte
BT_PICT
public static final byte
BT_JPEG
public static final byte
BT_PNG
public static final byte
BT_DIB
private byte
field_1_blipTypeWin32
private byte
field_2_blipTypeMacOS
private byte[]
field_3_uid
private short
field_4_tag
private int
field_5_size
private int
field_6_ref
private int
field_7_offset
private byte
field_8_usage
private byte
field_9_name
private byte
field_10_unused2
private byte
field_11_unused3
private EscherBlipRecord
field_12_blipRecord
private byte[]
remainingData
Constructors Summary
Methods Summary
public intfillFields(byte[] data, int offset, org.apache.poi.ddf.EscherRecordFactory recordFactory)
This method deserializes the record from a byte array.

param
data The byte array containing the escher record information
param
offset The starting offset into data.
param
recordFactory May be null since this is not a container record.
return
The number of bytes read from the byte array.


                                                                         
          
                               
                              
    
        int bytesRemaining = readHeader( data, offset );
        int pos = offset + 8;
        field_1_blipTypeWin32 = data[pos];
        field_2_blipTypeMacOS = data[pos + 1];
        System.arraycopy( data, pos + 2, field_3_uid = new byte[16], 0, 16 );
        field_4_tag = LittleEndian.getShort( data, pos + 18 );
        field_5_size = LittleEndian.getInt( data, pos + 20 );
        field_6_ref = LittleEndian.getInt( data, pos + 24 );
        field_7_offset = LittleEndian.getInt( data, pos + 28 );
        field_8_usage = data[pos + 32];
        field_9_name = data[pos + 33];
        field_10_unused2 = data[pos + 34];
        field_11_unused3 = data[pos + 35];
        bytesRemaining -= 36;
        int bytesRead = 0;
        if (bytesRemaining > 0)
        {
            field_12_blipRecord = (EscherBlipRecord) recordFactory.createRecord( data, pos + 36 );
            bytesRead = field_12_blipRecord.fillFields( data, pos + 36, recordFactory );
        }
        pos += 36 + bytesRead;
        bytesRemaining -= bytesRead;
//        if (field_1_blipTypeWin32 == BT_PNG)
//        {
//            byte[] uid = new byte[16];
//            System.arraycopy( data, pos + 36, uid, 0, 16 );
//            byte[] puid = new byte[16];
//            System.arraycopy( data, pos + 52, puid, 0, 16 );
//            byte tag = data[pos+68];
//            System.out.println( HexDump.dump( data, 0, 0 ) );
//            byte[] pngBytes = EscherBlipRecord.decompress( data, pos+69, bytesRemaining);
//        }

        remainingData = new byte[bytesRemaining];
        System.arraycopy( data, pos, remainingData, 0, bytesRemaining );
        return bytesRemaining + 8 + 36 + (field_12_blipRecord == null ? 0 : field_12_blipRecord.getRecordSize()) ;

    
public org.apache.poi.ddf.EscherBlipRecordgetBlipRecord()

        return field_12_blipRecord;
    
public java.lang.StringgetBlipType(byte b)
Retrieve the string representation given a blip id.

        switch ( b )
        {
            case BT_ERROR:
                return " ERROR";
            case BT_UNKNOWN:
                return " UNKNOWN";
            case BT_EMF:
                return " EMF";
            case BT_WMF:
                return " WMF";
            case BT_PICT:
                return " PICT";
            case BT_JPEG:
                return " JPEG";
            case BT_PNG:
                return " PNG";
            case BT_DIB:
                return " DIB";
            default:
                if ( b < 32 )
                    return " NotKnown";
                else
                    return " Client";
        }
    
public bytegetBlipTypeMacOS()
The expected blip type under MacOS (failure to match this blip type will result in Excel converting to this format).

        return field_2_blipTypeMacOS;
    
public bytegetBlipTypeWin32()
The expected blip type under windows (failure to match this blip type will result in Excel converting to this format).

        return field_1_blipTypeWin32;
    
public bytegetName()
The length in characters of the blip name.

        return field_9_name;
    
public intgetOffset()
File offset in the delay stream.

        return field_7_offset;
    
public java.lang.StringgetRecordName()
The short name for this record

        return "BSE";
    
public intgetRecordSize()
Returns the number of bytes that are required to serialize this record.

return
Number of bytes

        return 8 + 1 + 1 + 16 + 2 + 4 + 4 + 4 + 1 + 1 + 1 + 1 + field_12_blipRecord.getRecordSize() + (remainingData == null ? 0 : remainingData.length);
    
public intgetRef()
The reference count of this blip.

        return field_6_ref;
    
public byte[]getRemainingData()
Any remaining data in this record.

        return remainingData;
    
public intgetSize()
Blip size in stream.

        return field_5_size;
    
public shortgetTag()
unused

        return field_4_tag;
    
public byte[]getUid()
16 byte MD4 checksum.

        return field_3_uid;
    
public bytegetUnused2()

        return field_10_unused2;
    
public bytegetUnused3()

        return field_11_unused3;
    
public bytegetUsage()
Defines the way this blip is used.

        return field_8_usage;
    
public intserialize(int offset, byte[] data, org.apache.poi.ddf.EscherSerializationListener listener)
This method serializes this escher record into a byte array.

param
offset The offset into data to start writing the record data to.
param
data The byte array to serialize to.
param
listener A listener to retrieve start and end callbacks. Use a NullEscherSerailizationListener to ignore these events.
return
The number of bytes written.
see
NullEscherSerializationListener

        listener.beforeRecordSerialize( offset, getRecordId(), this );

        if (remainingData == null)
            remainingData = new byte[0];

        LittleEndian.putShort( data, offset, getOptions() );
        LittleEndian.putShort( data, offset + 2, getRecordId() );
        if (remainingData == null) remainingData = new byte[0];
        int blipSize = field_12_blipRecord == null ? 0 : field_12_blipRecord.getRecordSize();
        int remainingBytes = remainingData.length + 36 + blipSize;
        LittleEndian.putInt( data, offset + 4, remainingBytes );

        data[offset + 8] = field_1_blipTypeWin32;
        data[offset + 9] = field_2_blipTypeMacOS;
        for ( int i = 0; i < 16; i++ )
            data[offset + 10 + i] = field_3_uid[i];
        LittleEndian.putShort( data, offset + 26, field_4_tag );
        LittleEndian.putInt( data, offset + 28, field_5_size );
        LittleEndian.putInt( data, offset + 32, field_6_ref );
        LittleEndian.putInt( data, offset + 36, field_7_offset );
        data[offset + 40] = field_8_usage;
        data[offset + 41] = field_9_name;
        data[offset + 42] = field_10_unused2;
        data[offset + 43] = field_11_unused3;
        int bytesWritten = 0;
        if (field_12_blipRecord != null)
        {
            bytesWritten = field_12_blipRecord.serialize( offset + 44, data, new NullEscherSerializationListener() );
        }
        if (remainingData == null)
            remainingData = new byte[0];
        System.arraycopy( remainingData, 0, data, offset + 44 + bytesWritten, remainingData.length );
        int pos = offset + 8 + 36 + remainingData.length + bytesWritten;

        listener.afterRecordSerialize(pos, getRecordId(), pos - offset, this);
        return pos - offset;
    
public voidsetBlipRecord(org.apache.poi.ddf.EscherBlipRecord field_12_blipRecord)

        this.field_12_blipRecord = field_12_blipRecord;
    
public voidsetBlipTypeMacOS(byte blipTypeMacOS)
Set the expected MacOS blip type

        this.field_2_blipTypeMacOS = blipTypeMacOS;
    
public voidsetBlipTypeWin32(byte blipTypeWin32)
Set the expected win32 blip type

        this.field_1_blipTypeWin32 = blipTypeWin32;
    
public voidsetName(byte name)
The length in characters of the blip name.

        this.field_9_name = name;
    
public voidsetOffset(int offset)
File offset in the delay stream.

        this.field_7_offset = offset;
    
public voidsetRef(int ref)
The reference count of this blip.

        this.field_6_ref = ref;
    
public voidsetRemainingData(byte[] remainingData)
Any remaining data in this record.

        this.remainingData = remainingData;
    
public voidsetSize(int size)
Blip size in stream.

        this.field_5_size = size;
    
public voidsetTag(short tag)
unused

        this.field_4_tag = tag;
    
public voidsetUid(byte[] uid)
16 byte MD4 checksum.

        this.field_3_uid = uid;
    
public voidsetUnused2(byte unused2)

        this.field_10_unused2 = unused2;
    
public voidsetUnused3(byte unused3)

        this.field_11_unused3 = unused3;
    
public voidsetUsage(byte usage)
Defines the way this blip is used.

        this.field_8_usage = usage;
    
public java.lang.StringtoString()
Calculate the string representation of this object

        String nl = System.getProperty( "line.separator" );

        String extraData;
        ByteArrayOutputStream b = new ByteArrayOutputStream();
        try
        {
            HexDump.dump( this.remainingData, 0, b, 0 );
            extraData = b.toString();
        }
        catch ( Exception e )
        {
            extraData = e.toString();
        }
        return getClass().getName() + ":" + nl +
                "  RecordId: 0x" + HexDump.toHex( RECORD_ID ) + nl +
                "  Options: 0x" + HexDump.toHex( getOptions() ) + nl +
                "  BlipTypeWin32: " + field_1_blipTypeWin32 + nl +
                "  BlipTypeMacOS: " + field_2_blipTypeMacOS + nl +
                "  SUID: " + HexDump.toHex(field_3_uid) + nl +
                "  Tag: " + field_4_tag + nl +
                "  Size: " + field_5_size + nl +
                "  Ref: " + field_6_ref + nl +
                "  Offset: " + field_7_offset + nl +
                "  Usage: " + field_8_usage + nl +
                "  Name: " + field_9_name + nl +
                "  Unused2: " + field_10_unused2 + nl +
                "  Unused3: " + field_11_unused3 + nl +
                "  blipRecord: " + field_12_blipRecord + nl +
                "  Extra Data:" + nl + extraData;