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

EscherDgRecord

public class EscherDgRecord extends EscherRecord
This record simply holds the number of shapes in the drawing group and the last shape id used for this drawing group.
author
Glen Stampoultzis

Fields Summary
public static final short
RECORD_ID
public static final String
RECORD_DESCRIPTION
private int
field_1_numShapes
private int
field_2_lastMSOSPID
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;
        field_1_numShapes   =  LittleEndian.getInt( data, pos + size );     size += 4;
        field_2_lastMSOSPID =  LittleEndian.getInt( data, pos + size );     size += 4;
//        bytesRemaining -= size;
//        remainingData  =  new byte[bytesRemaining];
//        System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );
        return getRecordSize();
    
public shortgetDrawingGroupId()
Gets the drawing group id for this record. This is encoded in the instance part of the option record.

return
a drawing group id.

        return (short) ( getOptions() >> 4 );
    
public intgetLastMSOSPID()
The last shape id used in this drawing group.

        return field_2_lastMSOSPID;
    
public intgetNumShapes()
The number of shapes in this drawing group.

        return field_1_numShapes;
    
public shortgetRecordId()

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

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

return
Number of bytes

        return 8 + 8;
    
public voidincrementShapeCount()

        this.field_1_numShapes++;
    
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() );
        LittleEndian.putInt( data, offset + 4, 8 );
        LittleEndian.putInt( data, offset + 8, field_1_numShapes );
        LittleEndian.putInt( data, offset + 12, field_2_lastMSOSPID );
//        System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length );
//        int pos = offset + 8 + 18 + remainingData.length;

        listener.afterRecordSerialize( offset + 16, getRecordId(), getRecordSize(), this );
        return getRecordSize();
    
public voidsetLastMSOSPID(int field_2_lastMSOSPID)
The last shape id used in this drawing group.

        this.field_2_lastMSOSPID = field_2_lastMSOSPID;
    
public voidsetNumShapes(int field_1_numShapes)
The number of shapes in this drawing group.

        this.field_1_numShapes = field_1_numShapes;
    
public java.lang.StringtoString()
Returns the string representation of this record.

        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";
//        }
        return getClass().getName() + ":" + nl +
                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
                "  Options: 0x" + HexDump.toHex(getOptions()) + nl +
                "  NumShapes: " + field_1_numShapes + nl +
                "  LastMSOSPID: " + field_2_lastMSOSPID + nl;