public org.apache.poi.ddf.EscherRecord | createRecord(byte[] data, int offset)Generates an escher record including the any children contained under that record.
An exception is thrown if the record could not be generated.
EscherRecord.EscherRecordHeader header = EscherRecord.EscherRecordHeader.readHeader( data, offset );
// Options of 0x000F means container record
// However, EscherTextboxRecord are containers of records for the
// host application, not of other Escher records, so treat them
// differently
if ( ( header.getOptions() & (short) 0x000F ) == (short) 0x000F
&& header.getRecordId() != EscherTextboxRecord.RECORD_ID ) {
EscherContainerRecord r = new EscherContainerRecord();
r.setRecordId( header.getRecordId() );
r.setOptions( header.getOptions() );
return r;
}
else if ( header.getRecordId() >= EscherBlipRecord.RECORD_ID_START && header.getRecordId() <= EscherBlipRecord.RECORD_ID_END )
{
EscherBlipRecord r;
if (header.getRecordId() == EscherBitmapBlip.RECORD_ID_DIB ||
header.getRecordId() == EscherBitmapBlip.RECORD_ID_JPEG ||
header.getRecordId() == EscherBitmapBlip.RECORD_ID_PNG)
{
r = new EscherBitmapBlip();
}
else
{
r = new EscherBlipRecord();
}
r.setRecordId( header.getRecordId() );
r.setOptions( header.getOptions() );
return r;
}
else
{
Constructor recordConstructor = (Constructor) recordsMap.get( new Short( header.getRecordId() ) );
EscherRecord escherRecord = null;
if ( recordConstructor != null )
{
try
{
escherRecord = (EscherRecord) recordConstructor.newInstance( new Object[]{} );
escherRecord.setRecordId( header.getRecordId() );
escherRecord.setOptions( header.getOptions() );
}
catch ( Exception e )
{
escherRecord = null;
}
}
return escherRecord == null ? new UnknownEscherRecord() : escherRecord;
}
|