Methods Summary |
---|
public static byte[] | compress(byte[] data)Compress the contents of the provided array
ByteArrayOutputStream out = new ByteArrayOutputStream();
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream( out );
try
{
for ( int i = 0; i < data.length; i++ )
deflaterOutputStream.write( data[i] );
}
catch ( IOException e )
{
throw new RecordFormatException( e.toString() );
}
return out.toByteArray();
|
public static byte[] | decompress(byte[] data, int pos, int length)Decompresses a byte array.
byte[] compressedData = new byte[length];
System.arraycopy( data, pos + 50, compressedData, 0, length );
InputStream compressedInputStream = new ByteArrayInputStream( compressedData );
InflaterInputStream inflaterInputStream = new InflaterInputStream( compressedInputStream );
ByteArrayOutputStream out = new ByteArrayOutputStream();
int c;
try
{
while ( ( c = inflaterInputStream.read() ) != -1 )
out.write( c );
}
catch ( IOException e )
{
throw new RecordFormatException( e.toString() );
}
return out.toByteArray();
|
public int | fillFields(byte[] data, int offset, org.apache.poi.ddf.EscherRecordFactory recordFactory)This method deserializes the record from a byte array.
int bytesAfterHeader = readHeader( data, offset );
int pos = offset + HEADER_SIZE;
int size = 0;
field_1_secondaryUID = new byte[16];
System.arraycopy( data, pos + size, field_1_secondaryUID, 0, 16 ); size += 16;
field_2_cacheOfSize = LittleEndian.getInt( data, pos + size );size+=4;
field_3_boundaryTop = LittleEndian.getInt( data, pos + size );size+=4;
field_4_boundaryLeft = LittleEndian.getInt( data, pos + size );size+=4;
field_5_boundaryWidth = LittleEndian.getInt( data, pos + size );size+=4;
field_6_boundaryHeight = LittleEndian.getInt( data, pos + size );size+=4;
field_7_width = LittleEndian.getInt( data, pos + size );size+=4;
field_8_height = LittleEndian.getInt( data, pos + size );size+=4;
field_9_cacheOfSavedSize = LittleEndian.getInt( data, pos + size );size+=4;
field_10_compressionFlag = data[pos + size]; size++;
field_11_filter = data[pos + size]; size++;
int bytesRemaining = bytesAfterHeader - size;
field_12_data = new byte[bytesRemaining];
System.arraycopy(data, pos + size, field_12_data, 0, bytesRemaining);
size += bytesRemaining;
return HEADER_SIZE + size;
|
public int | getBoundaryHeight()Retrieve the boundary height of the metafile drawing commands
return field_6_boundaryHeight;
|
public int | getBoundaryLeft()Retrieve the left boundary of the metafile drawing commands
return field_4_boundaryLeft;
|
public int | getBoundaryTop()Retrieve the top boundary of the metafile drawing commands
return field_3_boundaryTop;
|
public int | getBoundaryWidth()Retrieve the boundary width of the metafile drawing commands
return field_5_boundaryWidth;
|
public int | getCacheOfSavedSize()Retrieve the cache of the saved size
return field_9_cacheOfSavedSize;
|
public int | getCacheOfSize()Retrieve the cache of the metafile size
return field_2_cacheOfSize;
|
public byte | getCompressionFlag()Is the contents of the blip compressed?
return field_10_compressionFlag;
|
public byte[] | getData()The BLIP data
return field_12_data;
|
public byte | getFilter()Filter should always be 0
return field_11_filter;
|
public int | getHeight()Retrieve the height of the metafile in EMU's (English Metric Units).
return field_8_height;
|
public java.lang.String | getRecordName()The short name for this record
return "Blip";
|
public int | getRecordSize()Returns the number of bytes that are required to serialize this record.
return 58 + field_12_data.length;
|
public byte[] | getSecondaryUID()Retrieve the secondary UID
return field_1_secondaryUID;
|
public int | getWidth()Retrieve the width of the metafile in EMU's (English Metric Units).
return field_7_width;
|
public int | serialize(int offset, byte[] data, org.apache.poi.ddf.EscherSerializationListener listener)This method serializes this escher record into a byte array.
listener.beforeRecordSerialize(offset, getRecordId(), this);
LittleEndian.putShort( data, offset, getOptions() );
LittleEndian.putShort( data, offset + 2, getRecordId() );
int remainingBytes = field_12_data.length + 36;
LittleEndian.putInt( data, offset + 4, remainingBytes );
int pos = offset + HEADER_SIZE;
System.arraycopy(field_1_secondaryUID, 0, data, pos, 16 ); pos += 16;
LittleEndian.putInt( data, pos, field_2_cacheOfSize); pos += 4;
LittleEndian.putInt( data, pos, field_3_boundaryTop); pos += 4;
LittleEndian.putInt( data, pos, field_4_boundaryLeft); pos += 4;
LittleEndian.putInt( data, pos, field_5_boundaryWidth); pos += 4;
LittleEndian.putInt( data, pos, field_6_boundaryHeight); pos += 4;
LittleEndian.putInt( data, pos, field_7_width); pos += 4;
LittleEndian.putInt( data, pos, field_8_height); pos += 4;
LittleEndian.putInt( data, pos, field_9_cacheOfSavedSize); pos += 4;
data[pos++] = field_10_compressionFlag;
data[pos++] = field_11_filter;
System.arraycopy(field_12_data, 0, data, pos, field_12_data.length); pos += field_12_data.length;
listener.afterRecordSerialize(pos, getRecordId(), pos - offset, this);
return pos - offset;
|
public void | setBoundaryHeight(int field_6_boundaryHeight)Set the boundary height of the metafile drawing commands
this.field_6_boundaryHeight = field_6_boundaryHeight;
|
public void | setBoundaryLeft(int field_4_boundaryLeft)Set the left boundary of the metafile drawing commands
this.field_4_boundaryLeft = field_4_boundaryLeft;
|
public void | setBoundaryTop(int field_3_boundaryTop)Set the top boundary of the metafile drawing commands
this.field_3_boundaryTop = field_3_boundaryTop;
|
public void | setBoundaryWidth(int field_5_boundaryWidth)Set the boundary width of the metafile drawing commands
this.field_5_boundaryWidth = field_5_boundaryWidth;
|
public void | setCacheOfSavedSize(int field_9_cacheOfSavedSize)Set the cache of the saved size
this.field_9_cacheOfSavedSize = field_9_cacheOfSavedSize;
|
public void | setCacheOfSize(int field_2_cacheOfSize)Set the cache of the metafile size
this.field_2_cacheOfSize = field_2_cacheOfSize;
|
public void | setCompressionFlag(byte field_10_compressionFlag)Set whether the contents of the blip is compressed
this.field_10_compressionFlag = field_10_compressionFlag;
|
public void | setData(byte[] field_12_data)The BLIP data
this.field_12_data = field_12_data;
|
public void | setFilter(byte field_11_filter)Filter should always be 0
this.field_11_filter = field_11_filter;
|
public void | setHeight(int height)Set the height of the metafile in EMU's (English Metric Units).
this.field_8_height = height;
|
public void | setSecondaryUID(byte[] field_1_secondaryUID)Set the secondary UID
this.field_1_secondaryUID = field_1_secondaryUID;
|
public void | setWidth(int width)Set the width of the metafile in EMU's (English Metric Units).
this.field_7_width = width;
|
public java.lang.String | toString()The string representation of this record.
String nl = System.getProperty( "line.separator" );
String extraData;
ByteArrayOutputStream b = new ByteArrayOutputStream();
try
{
HexDump.dump( this.field_12_data, 0, b, 0 );
extraData = b.toString();
}
catch ( Exception e )
{
extraData = e.toString();
}
return getClass().getName() + ":" + nl +
" RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
" Options: 0x" + HexDump.toHex( getOptions() ) + nl +
" Secondary UID: " + HexDump.toHex( field_1_secondaryUID ) + nl +
" CacheOfSize: " + field_2_cacheOfSize + nl +
" BoundaryTop: " + field_3_boundaryTop + nl +
" BoundaryLeft: " + field_4_boundaryLeft + nl +
" BoundaryWidth: " + field_5_boundaryWidth + nl +
" BoundaryHeight: " + field_6_boundaryHeight + nl +
" X: " + field_7_width + nl +
" Y: " + field_8_height + nl +
" CacheOfSavedSize: " + field_9_cacheOfSavedSize + nl +
" CompressionFlag: " + field_10_compressionFlag + nl +
" Filter: " + field_11_filter + nl +
" Data:" + nl + extraData;
|