Package org.apache.poi.ddf

Examples of org.apache.poi.ddf.EscherContainerRecord


            tailRec.clear();
            clearEscherRecords();
            if ( patriarch.getChildren().size() != 0 )
            {
                convertPatriarch( patriarch );
                EscherContainerRecord dgContainer = (EscherContainerRecord) getEscherRecord( 0 );
                EscherContainerRecord spgrContainer = null;
                for ( int i = 0; i < dgContainer.getChildRecords().size(); i++ )
                    if ( dgContainer.getChild( i ).getRecordId() == EscherContainerRecord.SPGR_CONTAINER )
                        spgrContainer = (EscherContainerRecord) dgContainer.getChild( i );
                convertShapes( patriarch, spgrContainer, shapeToObj );
View Full Code Here


    }

    private void convertGroup( HSSFShapeGroup shape, EscherContainerRecord escherParent, Map shapeToObj )
    {
        EscherContainerRecord spgrContainer = new EscherContainerRecord();
        EscherContainerRecord spContainer = new EscherContainerRecord();
        EscherSpgrRecord spgr = new EscherSpgrRecord();
        EscherSpRecord sp = new EscherSpRecord();
        EscherOptRecord opt = new EscherOptRecord();
        EscherRecord anchor;
        EscherClientDataRecord clientData = new EscherClientDataRecord();

        spgrContainer.setRecordId( EscherContainerRecord.SPGR_CONTAINER );
        spgrContainer.setOptions( (short) 0x000F );
        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
        spContainer.setOptions( (short) 0x000F );
        spgr.setRecordId( EscherSpgrRecord.RECORD_ID );
        spgr.setOptions( (short) 0x0001 );
        spgr.setRectX1( shape.getX1() );
        spgr.setRectY1( shape.getY1() );
        spgr.setRectX2( shape.getX2() );
        spgr.setRectY2( shape.getY2() );
        sp.setRecordId( EscherSpRecord.RECORD_ID );
        sp.setOptions( (short) 0x0002 );
        int shapeId = drawingManager.allocateShapeId(drawingGroupId);
        sp.setShapeId( shapeId );
        if (shape.getAnchor() instanceof HSSFClientAnchor)
            sp.setFlags( EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR );
        else
            sp.setFlags( EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_CHILD );
        opt.setRecordId( EscherOptRecord.RECORD_ID );
        opt.setOptions( (short) 0x0023 );
        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x00040004 ) );
        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.GROUPSHAPE__PRINT, 0x00080000 ) );

        anchor = ConvertAnchor.createAnchor( shape.getAnchor() );
//        clientAnchor.setCol1( ( (HSSFClientAnchor) shape.getAnchor() ).getCol1() );
//        clientAnchor.setRow1( (short) ( (HSSFClientAnchor) shape.getAnchor() ).getRow1() );
//        clientAnchor.setDx1( (short) shape.getAnchor().getDx1() );
//        clientAnchor.setDy1( (short) shape.getAnchor().getDy1() );
//        clientAnchor.setCol2( ( (HSSFClientAnchor) shape.getAnchor() ).getCol2() );
//        clientAnchor.setRow2( (short) ( (HSSFClientAnchor) shape.getAnchor() ).getRow2() );
//        clientAnchor.setDx2( (short) shape.getAnchor().getDx2() );
//        clientAnchor.setDy2( (short) shape.getAnchor().getDy2() );
        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
        clientData.setOptions( (short) 0x0000 );

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

        ObjRecord obj = new ObjRecord();
        CommonObjectDataSubRecord cmo = new CommonObjectDataSubRecord();
        cmo.setObjectType( CommonObjectDataSubRecord.OBJECT_TYPE_GROUP );
        cmo.setObjectId( (short) ( shapeId ) );
View Full Code Here

        throw new IllegalArgumentException( "Can not find client data record" );
    }

    private void convertPatriarch( HSSFPatriarch patriarch )
    {
        EscherContainerRecord dgContainer = new EscherContainerRecord();
        EscherDgRecord dg;
        EscherContainerRecord spgrContainer = new EscherContainerRecord();
        EscherContainerRecord spContainer1 = new EscherContainerRecord();
        EscherSpgrRecord spgr = new EscherSpgrRecord();
        EscherSpRecord sp1 = new EscherSpRecord();

        dgContainer.setRecordId( EscherContainerRecord.DG_CONTAINER );
        dgContainer.setOptions( (short) 0x000F );
        dg = drawingManager.createDgRecord();
        drawingGroupId = dg.getDrawingGroupId();
//        dg.setOptions( (short) ( drawingId << 4 ) );
//        dg.setNumShapes( getNumberOfShapes( patriarch ) );
//        dg.setLastMSOSPID( 0 );  // populated after all shape id's are assigned.
        spgrContainer.setRecordId( EscherContainerRecord.SPGR_CONTAINER );
        spgrContainer.setOptions( (short) 0x000F );
        spContainer1.setRecordId( EscherContainerRecord.SP_CONTAINER );
        spContainer1.setOptions( (short) 0x000F );
        spgr.setRecordId( EscherSpgrRecord.RECORD_ID );
        spgr.setOptions( (short) 0x0001 );    // version
        spgr.setRectX1( patriarch.getX1() );
        spgr.setRectY1( patriarch.getY1() );
        spgr.setRectX2( patriarch.getX2() );
        spgr.setRectY2( patriarch.getY2() );
        sp1.setRecordId( EscherSpRecord.RECORD_ID );
        sp1.setOptions( (short) 0x0002 );
        sp1.setShapeId( drawingManager.allocateShapeId(dg.getDrawingGroupId()) );
        sp1.setFlags( EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_PATRIARCH );

        dgContainer.addChildRecord( dg );
        dgContainer.addChildRecord( spgrContainer );
        spgrContainer.addChildRecord( spContainer1 );
        spContainer1.addChildRecord( spgr );
        spContainer1.addChildRecord( sp1 );

        addEscherRecord( dgContainer );
    }
View Full Code Here

            if(r instanceof DrawingGroupRecord) {
                DrawingGroupRecord dg = (DrawingGroupRecord)r;
                dg.processChildRecords();

                EscherContainerRecord cr =
                    dg.getEscherContainer();
                if(cr == null) {
                    continue;
                }

                EscherDggRecord dgg = null;
                for(Iterator it = cr.getChildRecords().iterator(); it.hasNext();) {
                    Object er = it.next();
                    if(er instanceof EscherDggRecord) {
                        dgg = (EscherDggRecord)er;
                    }
                }
View Full Code Here

     * Creates a primary drawing group record.  If it already
     *  exists then it's modified.
     */
    public void createDrawingGroup() {
        if (drawingManager == null) {
            EscherContainerRecord dggContainer = new EscherContainerRecord();
            EscherDggRecord dgg = new EscherDggRecord();
            EscherOptRecord opt = new EscherOptRecord();
            EscherSplitMenuColorsRecord splitMenuColors = new EscherSplitMenuColorsRecord();

            dggContainer.setRecordId((short) 0xF000);
            dggContainer.setOptions((short) 0x000F);
            dgg.setRecordId(EscherDggRecord.RECORD_ID);
            dgg.setOptions((short)0x0000);
            dgg.setShapeIdMax(1024);
            dgg.setNumShapesSaved(0);
            dgg.setDrawingsSaved(0);
            dgg.setFileIdClusters(new EscherDggRecord.FileIdCluster[] {} );
            drawingManager = new DrawingManager2(dgg);
            EscherContainerRecord bstoreContainer = null;
            if (escherBSERecords.size() > 0)
            {
                bstoreContainer = new EscherContainerRecord();
                bstoreContainer.setRecordId( EscherContainerRecord.BSTORE_CONTAINER );
                bstoreContainer.setOptions( (short) ( (escherBSERecords.size() << 4) | 0xF ) );
                for ( Iterator iterator = escherBSERecords.iterator(); iterator.hasNext(); )
                {
                    EscherRecord escherRecord = (EscherRecord) iterator.next();
                    bstoreContainer.addChildRecord( escherRecord );
                }
            }
            opt.setRecordId((short) 0xF00B);
            opt.setOptions((short) 0x0033);
            opt.addEscherProperty( new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296) );
View Full Code Here

        escherBSERecords.add( e );

        int dgLoc = findFirstRecordLocBySid(DrawingGroupRecord.sid);
        DrawingGroupRecord drawingGroup = (DrawingGroupRecord) getRecords().get( dgLoc );

        EscherContainerRecord dggContainer = (EscherContainerRecord) drawingGroup.getEscherRecord( 0 );
        EscherContainerRecord bstoreContainer;
        if (dggContainer.getChild( 1 ).getRecordId() == EscherContainerRecord.BSTORE_CONTAINER )
        {
            bstoreContainer = (EscherContainerRecord) dggContainer.getChild( 1 );
        }
        else
        {
            bstoreContainer = new EscherContainerRecord();
            bstoreContainer.setRecordId( EscherContainerRecord.BSTORE_CONTAINER );
            dggContainer.getChildRecords().add( 1, bstoreContainer );
        }
        bstoreContainer.setOptions( (short) ( (escherBSERecords.size() << 4) | 0xF ) );

        bstoreContainer.addChildRecord( e );

        return escherBSERecords.size();
    }
View Full Code Here

        //check if the cloned sheet has drawings
        int aggLoc = sheet.aggregateDrawingRecords(drawingManager, false);
        if(aggLoc != -1) {
            EscherAggregate agg = (EscherAggregate) sheet.findFirstRecordBySid(EscherAggregate.sid);
            EscherContainerRecord escherContainer = agg.getEscherContainer();
            if (escherContainer == null) {
                return;
            }

            EscherDggRecord dgg = drawingManager.getDgg();

            //register a new drawing group for the cloned sheet
            int dgId = drawingManager.findNewDrawingGroupId();
            dgg.addCluster( dgId, 0 );
            dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);

            EscherDgRecord dg = null;
            for(Iterator it = escherContainer.getChildRecords().iterator(); it.hasNext();) {
                Object er = it.next();
                if(er instanceof EscherDgRecord) {
                    dg = (EscherDgRecord)er;
                    //update id of the drawing in the cloned sheet
                    dg.setOptions( (short) ( dgId << 4 ) );
                } else if (er instanceof EscherContainerRecord){
                    //recursively find shape records and re-generate shapeId
                    ArrayList spRecords = new ArrayList();
                    EscherContainerRecord cp = (EscherContainerRecord)er;
                    cp.getRecordsById(EscherSpRecord.RECORD_ID,  spRecords);
                    for(Iterator spIt = spRecords.iterator(); spIt.hasNext();) {
                        EscherSpRecord sp = (EscherSpRecord)spIt.next();
                        int shapeId = drawingManager.allocateShapeId((short)dgId, dg);
                        //allocateShapeId increments the number of shapes. roll back to the previous value
                        dg.setNumShapes(dg.getNumShapes()-1);
View Full Code Here

     * @return all shapes contained in this Sheet (Slide or Notes)
     */
    public Shape[] getShapes() {
        PPDrawing ppdrawing = getPPDrawing();

        EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
        EscherContainerRecord spgr = null;
        List ch = dg.getChildRecords();

        for (Iterator it = ch.iterator(); it.hasNext();) {
            EscherRecord rec = (EscherRecord) it.next();
            if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
                spgr = (EscherContainerRecord) rec;
                break;
            }
        }
        ch = spgr.getChildRecords();

        ArrayList shapes = new ArrayList();
        for (int i = 1; i < ch.size(); i++) {
            EscherContainerRecord sp = (EscherContainerRecord) ch.get(i);
            Shape sh = ShapeFactory.createShape(sp, null);
            sh.setSheet(this);
            shapes.add(sh);
        }

View Full Code Here

     * @param shape - the Shape to add
     */
    public void addShape(Shape shape) {
        PPDrawing ppdrawing = getPPDrawing();

        EscherContainerRecord dgContainer = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
        EscherContainerRecord spgr = (EscherContainerRecord) Shape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
        spgr.addChildRecord(shape.getSpContainer());

        EscherDgRecord dg = (EscherDgRecord) Shape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
        dg.setNumShapes(dg.getNumShapes() + 1);

        int shapeId = dg.getLastMSOSPID()+1;
View Full Code Here

     */
    public Background getBackground() {
        if (_background == null) {
            PPDrawing ppdrawing = getPPDrawing();

            EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
            EscherContainerRecord spContainer = null;
            List ch = dg.getChildRecords();

            for (Iterator it = ch.iterator(); it.hasNext();) {
                EscherRecord rec = (EscherRecord) it.next();
                if (rec.getRecordId() == EscherContainerRecord.SP_CONTAINER) {
View Full Code Here

TOP

Related Classes of org.apache.poi.ddf.EscherContainerRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.