FileDocCategorySizeDatePackage
SimpleFilledShape.javaAPI DocApache Poi 3.0.14587Mon Jan 01 12:39:36 GMT 2007org.apache.poi.hssf.model

SimpleFilledShape

public class SimpleFilledShape extends AbstractShape

Fields Summary
private EscherContainerRecord
spContainer
private ObjRecord
objRecord
Constructors Summary
SimpleFilledShape(HSSFSimpleShape hssfShape, int shapeId)
Creates the low evel records for an oval.

param
hssfShape The highlevel shape.
param
shapeId The shape id to use for this shape.

        spContainer = createSpContainer( hssfShape, shapeId );
        objRecord = createObjRecord( hssfShape, shapeId );
    
Methods Summary
private org.apache.poi.hssf.record.ObjRecordcreateObjRecord(org.apache.poi.hssf.usermodel.HSSFShape hssfShape, int shapeId)
Creates the low level OBJ record for this shape.

        HSSFShape shape = hssfShape;

        ObjRecord obj = new ObjRecord();
        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
        c.setObjectType( (short) ( (HSSFSimpleShape) shape ).getShapeType() );
        c.setObjectId( (short) ( shapeId ) );
        c.setLocked( true );
        c.setPrintable( true );
        c.setAutofill( true );
        c.setAutoline( true );
        EndSubRecord e = new EndSubRecord();

        obj.addSubRecord( c );
        obj.addSubRecord( e );

        return obj;
    
private org.apache.poi.ddf.EscherContainerRecordcreateSpContainer(org.apache.poi.hssf.usermodel.HSSFSimpleShape hssfShape, int shapeId)
Generates the shape records for this shape.

param
hssfShape
param
shapeId
return

        HSSFShape shape = hssfShape;

        EscherContainerRecord spContainer = new EscherContainerRecord();
        EscherSpRecord sp = new EscherSpRecord();
        EscherOptRecord opt = new EscherOptRecord();
        EscherClientDataRecord clientData = new EscherClientDataRecord();

        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
        spContainer.setOptions( (short) 0x000F );
        sp.setRecordId( EscherSpRecord.RECORD_ID );
        short shapeType = objTypeToShapeType( hssfShape.getShapeType() );
        sp.setOptions( (short) ( ( shapeType << 4 ) | 0x2 ) );
        sp.setShapeId( shapeId );
        sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
        opt.setRecordId( EscherOptRecord.RECORD_ID );
        addStandardOptions(shape, opt);
        EscherRecord anchor = createAnchor( shape.getAnchor() );
        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
        clientData.setOptions( (short) 0x0000 );

        spContainer.addChildRecord( sp );
        spContainer.addChildRecord( opt );
        spContainer.addChildRecord( anchor );
        spContainer.addChildRecord( clientData );

        return spContainer;
    
public org.apache.poi.hssf.record.ObjRecordgetObjRecord()

        return objRecord;
    
public org.apache.poi.ddf.EscherContainerRecordgetSpContainer()

        return spContainer;
    
private shortobjTypeToShapeType(int objType)

        short shapeType;
        if (objType == HSSFSimpleShape.OBJECT_TYPE_OVAL)
            shapeType = EscherAggregate.ST_ELLIPSE;
        else if (objType == HSSFSimpleShape.OBJECT_TYPE_RECTANGLE)
            shapeType = EscherAggregate.ST_RECTANGLE;
        else
            throw new IllegalArgumentException("Unable to handle an object of this type");
        return shapeType;