FileDocCategorySizeDatePackage
DrawingGroupRecord.javaAPI DocApache Poi 3.0.14558Mon Jan 01 12:39:40 GMT 2007org.apache.poi.hssf.record

DrawingGroupRecord

public class DrawingGroupRecord extends AbstractEscherHolderRecord

Fields Summary
public static final short
sid
static final int
MAX_RECORD_SIZE
private static final int
MAX_DATA_SIZE
Constructors Summary
public DrawingGroupRecord()


     
    
    
public DrawingGroupRecord(RecordInputStream in)

        super( in );
    
Methods Summary
public intgetRawDataSize()

        List escherRecords = getEscherRecords();
        byte[] rawData = getRawData();
        if (escherRecords.size() == 0 && rawData != null)
        {
            return rawData.length;
        }
        else
        {
            int size = 0;
            for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
            {
                EscherRecord r = (EscherRecord) iterator.next();
                size += r.getRecordSize();
            }
            return size;
        }
    
protected java.lang.StringgetRecordName()

        return "MSODRAWINGGROUP";
    
public intgetRecordSize()
Size of record (including 4 byte headers for all sections)

        return grossSizeFromDataSize( getRawDataSize() );
    
public shortgetSid()

        return sid;
    
static intgrossSizeFromDataSize(int dataSize)

        return dataSize + ( (dataSize - 1) / MAX_DATA_SIZE + 1 ) * 4;
    
public intserialize(int offset, byte[] data)

        byte[] rawData = getRawData();
        if (getEscherRecords().size() == 0 && rawData != null)
        {
            return writeData( offset, data, rawData );
        }
        else
        {
            byte[] buffer = new byte[getRawDataSize()];
            int pos = 0;
            for ( Iterator iterator = getEscherRecords().iterator(); iterator.hasNext(); )
            {
                EscherRecord r = (EscherRecord) iterator.next();
                pos += r.serialize(pos, buffer, new NullEscherSerializationListener() );
            }

            return writeData( offset, data, buffer );
        }
    
private voidwriteContinueHeader(byte[] data, int offset, int sizeExcludingHeader)

        LittleEndian.putShort(data, 0 + offset, ContinueRecord.sid);
        LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader);
    
private intwriteData(int offset, byte[] data, byte[] rawData)

        int writtenActualData = 0;
        int writtenRawData = 0;
        while (writtenRawData < rawData.length)
        {
            int segmentLength = Math.min( rawData.length - writtenRawData, MAX_DATA_SIZE);
            if (writtenRawData / MAX_DATA_SIZE >= 2)
                writeContinueHeader( data, offset, segmentLength );
            else
                writeHeader( data, offset, segmentLength );
            writtenActualData += 4;
            offset += 4;
            ArrayUtil.arraycopy( rawData, writtenRawData, data, offset, segmentLength );
            offset += segmentLength;
            writtenRawData += segmentLength;
            writtenActualData += segmentLength;
        }
        return writtenActualData;
    
private voidwriteHeader(byte[] data, int offset, int sizeExcludingHeader)

        LittleEndian.putShort(data, 0 + offset, getSid());
        LittleEndian.putShort(data, 2 + offset, (short) sizeExcludingHeader);