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

EscherTextboxRecord

public class EscherTextboxRecord extends EscherRecord
Holds data from the parent application. Most commonly used to store text in the format of the parent application, rather than in Escher format. We don't attempt to understand the contents, since they will be in the parent's format, not Escher format.
author
Glen Stampoultzis (glens at apache.org)
author
Nick Burch (nick at torchbox dot com)

Fields Summary
public static final short
RECORD_ID
public static final String
RECORD_DESCRIPTION
private static final byte[]
NO_BYTES
private byte[]
thedata
The data for this record not including the the 8 byte header
Constructors Summary
public EscherTextboxRecord()


     
    
    
Methods Summary
public java.lang.Objectclone()

        // shallow clone
        return super.clone();
    
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 );

        // Save the data, ready for the calling code to do something
        //  useful with it
        thedata = new byte[bytesRemaining];
        System.arraycopy( data, offset + 8, thedata, 0, bytesRemaining );
        return bytesRemaining + 8;
    
public byte[]getData()
Returns any extra data associated with this record. In practice excel does not seem to put anything here, but with PowerPoint this will contain the bytes that make up a TextHeaderAtom followed by a TextBytesAtom/TextCharsAtom

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

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

return
Number of bytes

        return 8 + thedata.length;
    
public intserialize(int offset, byte[] data, org.apache.poi.ddf.EscherSerializationListener listener)
Writes this record and any contained records to the supplied byte array.

return
the number of bytes written.

        listener.beforeRecordSerialize( offset, getRecordId(), this );

        LittleEndian.putShort(data, offset, getOptions());
        LittleEndian.putShort(data, offset+2, getRecordId());
        int remainingBytes = thedata.length;
        LittleEndian.putInt(data, offset+4, remainingBytes);
        System.arraycopy(thedata, 0, data, offset+8, thedata.length);
        int pos = offset+8+thedata.length;

        listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this );
        int size = pos - offset;
        if (size != getRecordSize())
            throw new RecordFormatException(size + " bytes written but getRecordSize() reports " + getRecordSize());
        return size;
    
public voidsetData(byte[] b, int start, int length)
Sets the extra data (in the parent application's format) to be contained by the record. Used when the parent application changes the contents.

        thedata = new byte[length];
        System.arraycopy(b,start,thedata,0,length);
    
public voidsetData(byte[] b)

        setData(b,0,b.length);
    
public java.lang.StringtoString()

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

        String theDumpHex = "";
        try
        {
            if (thedata.length != 0)
            {
                theDumpHex = "  Extra Data:" + nl;
                theDumpHex += HexDump.dump(thedata, 0, 0);
            }
        }
        catch ( Exception e )
        {
            theDumpHex = "Error!!";
        }

        return getClass().getName() + ":" + nl +
                "  isContainer: " + isContainerRecord() + nl +
                "  options: 0x" + HexDump.toHex( getOptions() ) + nl +
                "  recordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
                "  numchildren: " + getChildRecords().size() + nl +
                theDumpHex;