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

EscherSpRecord

public class EscherSpRecord extends EscherRecord
Together the the EscherOptRecord this record defines some of the basic properties of a shape.
author
Glen Stampoultzis (glens at apache.org)

Fields Summary
public static final short
RECORD_ID
public static final String
RECORD_DESCRIPTION
public static final int
FLAG_GROUP
public static final int
FLAG_CHILD
public static final int
FLAG_PATRIARCH
public static final int
FLAG_DELETED
public static final int
FLAG_OLESHAPE
public static final int
FLAG_HAVEMASTER
public static final int
FLAG_FLIPHORIZ
public static final int
FLAG_FLIPVERT
public static final int
FLAG_CONNECTOR
public static final int
FLAG_HAVEANCHOR
public static final int
FLAG_BACKGROUND
public static final int
FLAG_HASSHAPETYPE
private int
field_1_shapeId
private int
field_2_flags
Constructors Summary
Methods Summary
private java.lang.StringdecodeFlags(int flags)
Converts the shape flags into a more descriptive name.

        StringBuffer result = new StringBuffer();
        result.append( ( flags & FLAG_GROUP ) != 0 ? "|GROUP" : "" );
        result.append( ( flags & FLAG_CHILD ) != 0 ? "|CHILD" : "" );
        result.append( ( flags & FLAG_PATRIARCH ) != 0 ? "|PATRIARCH" : "" );
        result.append( ( flags & FLAG_DELETED ) != 0 ? "|DELETED" : "" );
        result.append( ( flags & FLAG_OLESHAPE ) != 0 ? "|OLESHAPE" : "" );
        result.append( ( flags & FLAG_HAVEMASTER ) != 0 ? "|HAVEMASTER" : "" );
        result.append( ( flags & FLAG_FLIPHORIZ ) != 0 ? "|FLIPHORIZ" : "" );
        result.append( ( flags & FLAG_FLIPVERT ) != 0 ? "|FLIPVERT" : "" );
        result.append( ( flags & FLAG_CONNECTOR ) != 0 ? "|CONNECTOR" : "" );
        result.append( ( flags & FLAG_HAVEANCHOR ) != 0 ? "|HAVEANCHOR" : "" );
        result.append( ( flags & FLAG_BACKGROUND ) != 0 ? "|BACKGROUND" : "" );
        result.append( ( flags & FLAG_HASSHAPETYPE ) != 0 ? "|HASSHAPETYPE" : "" );

        //need to check, else blows up on some records - bug 34435
        if(result.length() > 0) {
            result.deleteCharAt(0);
        }
        return result.toString();
    
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;
        field_1_shapeId    =  LittleEndian.getInt( data, pos + size );     size += 4;
        field_2_flags      =  LittleEndian.getInt( data, pos + size );     size += 4;
//        bytesRemaining -= size;
//        remainingData  =  new byte[bytesRemaining];
//        System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );
        return getRecordSize();
    
public intgetFlags()
The flags that apply to this shape.

see
#FLAG_GROUP
see
#FLAG_CHILD
see
#FLAG_PATRIARCH
see
#FLAG_DELETED
see
#FLAG_OLESHAPE
see
#FLAG_HAVEMASTER
see
#FLAG_FLIPHORIZ
see
#FLAG_FLIPVERT
see
#FLAG_CONNECTOR
see
#FLAG_HAVEANCHOR
see
#FLAG_BACKGROUND
see
#FLAG_HASSHAPETYPE

        return field_2_flags;
    
public shortgetRecordId()

return
the 16 bit identifier for this record.

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

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

return
Number of bytes

        return 8 + 8;
    
public intgetShapeId()

return
A number that identifies this shape

        return field_1_shapeId;
    
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 );
        LittleEndian.putShort( data, offset, getOptions() );
        LittleEndian.putShort( data, offset + 2, getRecordId() );
        int remainingBytes = 8;
        LittleEndian.putInt( data, offset + 4, remainingBytes );
        LittleEndian.putInt( data, offset + 8, field_1_shapeId );
        LittleEndian.putInt( data, offset + 12, field_2_flags );
//        System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length );
//        int pos = offset + 8 + 18 + remainingData.length;
        listener.afterRecordSerialize( offset + getRecordSize(), getRecordId(), getRecordSize(), this );
        return 8 + 8;
    
public voidsetFlags(int field_2_flags)
The flags that apply to this shape.

see
#FLAG_GROUP
see
#FLAG_CHILD
see
#FLAG_PATRIARCH
see
#FLAG_DELETED
see
#FLAG_OLESHAPE
see
#FLAG_HAVEMASTER
see
#FLAG_FLIPHORIZ
see
#FLAG_FLIPVERT
see
#FLAG_CONNECTOR
see
#FLAG_HAVEANCHOR
see
#FLAG_BACKGROUND
see
#FLAG_HASSHAPETYPE

        this.field_2_flags = field_2_flags;
    
public voidsetShapeId(int field_1_shapeId)
Sets a number that identifies this shape.

        this.field_1_shapeId = field_1_shapeId;
    
public java.lang.StringtoString()

return
the string representing this shape.

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

        return getClass().getName() + ":" + nl +
                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
                "  Options: 0x" + HexDump.toHex(getOptions()) + nl +
                "  ShapeId: " + field_1_shapeId + nl +
                "  Flags: " + decodeFlags(field_2_flags) + " (0x" + HexDump.toHex(field_2_flags) + ")" + nl;