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

EscherClientAnchorRecord

public class EscherClientAnchorRecord extends EscherRecord
The escher client anchor specifies which rows and cells the shape is bound to as well as the offsets within those cells. Each cell is 1024 units wide by 256 units long regardless of the actual size of the cell. The EscherClientAnchorRecord only applies to the top-most shapes. Shapes contained in groups are bound using the EscherChildAnchorRecords.
author
Glen Stampoultzis
see
EscherChildAnchorRecord

Fields Summary
public static final short
RECORD_ID
public static final String
RECORD_DESCRIPTION
private short
field_1_flag
private short
field_2_col1
private short
field_3_dx1
private short
field_4_row1
private short
field_5_dy1
private short
field_6_col2
private short
field_7_dx2
private short
field_8_row2
private short
field_9_dy2
private byte[]
remainingData
private boolean
shortRecord
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;
        int size           = 0;

        // Always find 4 two byte entries. Sometimes find 9
        field_1_flag   =  LittleEndian.getShort( data, pos + size );     size += 2;
        field_2_col1   =  LittleEndian.getShort( data, pos + size );     size += 2;
        field_3_dx1    =  LittleEndian.getShort( data, pos + size );     size += 2;
        field_4_row1   =  LittleEndian.getShort( data, pos + size );     size += 2;
        if(bytesRemaining >= 18) {
		    field_5_dy1    =  LittleEndian.getShort( data, pos + size );     size += 2;
		    field_6_col2   =  LittleEndian.getShort( data, pos + size );     size += 2;
		    field_7_dx2    =  LittleEndian.getShort( data, pos + size );     size += 2;
		    field_8_row2   =  LittleEndian.getShort( data, pos + size );     size += 2;
		    field_9_dy2    =  LittleEndian.getShort( data, pos + size );     size += 2;
			shortRecord = false;
        } else {
			shortRecord = true;
		}
        bytesRemaining -= size;
        remainingData  =  new byte[bytesRemaining];
        System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );
        return 8 + size + bytesRemaining;
    
public shortgetCol1()
The column number for the top-left position. 0 based.

        return field_2_col1;
    
public shortgetCol2()
The column of the bottom right corner of this shape.

        return field_6_col2;
    
public shortgetDx1()
The x offset within the top-left cell. Range is from 0 to 1023.

        return field_3_dx1;
    
public shortgetDx2()
The x offset withing the cell for the bottom-right corner of this shape.

        return field_7_dx2;
    
public shortgetDy1()
The y offset within the top-left corner of the current shape.

        return field_5_dy1;
    
public shortgetDy2()
The y offset withing the cell for the bottom-right corner of this shape.

        return field_9_dy2;
    
public shortgetFlag()
0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.

        return field_1_flag;
    
public shortgetRecordId()
The record id for this record.

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

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

return
Number of bytes

        return 8 + (shortRecord ? 8 : 18) + (remainingData == null ? 0 : remainingData.length);
    
public byte[]getRemainingData()
Any remaining data in the record

        return remainingData;
    
public shortgetRow1()
The row number for the top-left corner of the shape.

        return field_4_row1;
    
public shortgetRow2()
The row number for the bottom-right corner of the current shape.

        return field_8_row2;
    
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() );
        int remainingBytes = remainingData.length + (shortRecord ? 8 : 18);
        LittleEndian.putInt( data, offset + 4, remainingBytes );
        LittleEndian.putShort( data, offset + 8, field_1_flag );
        LittleEndian.putShort( data, offset + 10, field_2_col1 );
        LittleEndian.putShort( data, offset + 12, field_3_dx1 );
        LittleEndian.putShort( data, offset + 14, field_4_row1 );
        if(!shortRecord) {
            LittleEndian.putShort( data, offset + 16, field_5_dy1 );
            LittleEndian.putShort( data, offset + 18, field_6_col2 );
            LittleEndian.putShort( data, offset + 20, field_7_dx2 );
            LittleEndian.putShort( data, offset + 22, field_8_row2 );
            LittleEndian.putShort( data, offset + 24, field_9_dy2 );
        }
        System.arraycopy( remainingData, 0, data, offset + (shortRecord ? 16 : 26), remainingData.length );
        int pos = offset + 8 + (shortRecord ? 8 : 18) + remainingData.length;

        listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this );
        return pos - offset;
    
public voidsetCol1(short field_2_col1)
The column number for the top-left position. 0 based.

        this.field_2_col1 = field_2_col1;
    
public voidsetCol2(short field_6_col2)
The column of the bottom right corner of this shape.

        shortRecord = false;
        this.field_6_col2 = field_6_col2;
    
public voidsetDx1(short field_3_dx1)
The x offset within the top-left cell. Range is from 0 to 1023.

        this.field_3_dx1 = field_3_dx1;
    
public voidsetDx2(short field_7_dx2)
The x offset withing the cell for the bottom-right corner of this shape.

        shortRecord = false;
        this.field_7_dx2 = field_7_dx2;
    
public voidsetDy1(short field_5_dy1)
The y offset within the top-left corner of the current shape.

        shortRecord = false;
        this.field_5_dy1 = field_5_dy1;
    
public voidsetDy2(short field_9_dy2)
The y offset withing the cell for the bottom-right corner of this shape.

        shortRecord = false;
        this.field_9_dy2 = field_9_dy2;
    
public voidsetFlag(short field_1_flag)
0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.

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

        this.remainingData = remainingData;
    
public voidsetRow1(short field_4_row1)
The row number for the top-left corner of the shape.

        this.field_4_row1 = field_4_row1;
    
public voidsetRow2(short field_8_row2)
The row number for the bottom-right corner of the current shape.

        shortRecord = false;
        this.field_8_row2 = field_8_row2;
    
public java.lang.StringtoString()
Returns the string representation for this record.

return
A string

        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 = "error\n";
        }
        return getClass().getName() + ":" + nl +
                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
                "  Options: 0x" + HexDump.toHex(getOptions()) + nl +
                "  Flag: " + field_1_flag + nl +
                "  Col1: " + field_2_col1 + nl +
                "  DX1: " + field_3_dx1 + nl +
                "  Row1: " + field_4_row1 + nl +
                "  DY1: " + field_5_dy1 + nl +
                "  Col2: " + field_6_col2 + nl +
                "  DX2: " + field_7_dx2 + nl +
                "  Row2: " + field_8_row2 + nl +
                "  DY2: " + field_9_dy2 + nl +
                "  Extra Data:" + nl + extraData;