Package org.apache.poi.ddf

Examples of org.apache.poi.ddf.EscherDggRecord


public class TestDrawingManager extends TestCase
{
    public void testFindFreeSPIDBlock() throws Exception
    {
        EscherDggRecord dgg = new EscherDggRecord();
        DrawingManager dm = new DrawingManager( dgg );
        dgg.setShapeIdMax( 1024 );
        assertEquals( 2048, dm.findFreeSPIDBlock() );
        dgg.setShapeIdMax( 1025 );
        assertEquals( 2048, dm.findFreeSPIDBlock() );
        dgg.setShapeIdMax( 2047 );
        assertEquals( 2048, dm.findFreeSPIDBlock() );
    }
View Full Code Here


        records.add( d1 );
        records.add( r1 );
        records.add( d2 );
        records.add( r2 );

        DrawingManager2 drawingManager = new DrawingManager2(new EscherDggRecord() );
        EscherAggregate aggregate = EscherAggregate.createAggregate( records, 0, drawingManager );

        assertEquals( 1, aggregate.getEscherRecords().size() );
        assertEquals( (short) 0xF002, aggregate.getEscherRecord( 0 ).getRecordId() );
        assertEquals( 2, aggregate.getEscherRecord( 0 ).getChildRecords().size() );
View Full Code Here

        assertEquals( 2048, dm.findFreeSPIDBlock() );
    }

    public void testFindNewDrawingGroupId() throws Exception
    {
        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 1 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
            new EscherDggRecord.FileIdCluster( 2, 10 )} );
        DrawingManager dm = new DrawingManager( dgg );
        assertEquals( 1, dm.findNewDrawingGroupId() );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
            new EscherDggRecord.FileIdCluster( 1, 10 ),
            new EscherDggRecord.FileIdCluster( 2, 10 )} );
        assertEquals( 3, dm.findNewDrawingGroupId() );
    }
View Full Code Here

        assertEquals( 3, dm.findNewDrawingGroupId() );
    }

    public void testDrawingGroupExists() throws Exception
    {
        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 1 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{
            new EscherDggRecord.FileIdCluster( 2, 10 )} );
        DrawingManager dm = new DrawingManager( dgg );
        assertFalse( dm.drawingGroupExists( (short) 1 ) );
        assertTrue( dm.drawingGroupExists( (short) 2 ) );
        assertFalse( dm.drawingGroupExists( (short) 3 ) );
View Full Code Here

        assertFalse( dm.drawingGroupExists( (short) 3 ) );
    }

    public void testCreateDgRecord() throws Exception
    {
        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 0 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} );
        DrawingManager dm = new DrawingManager( dgg );

        EscherDgRecord dgRecord = dm.createDgRecord();
        assertEquals( -1, dgRecord.getLastMSOSPID() );
        assertEquals( 0, dgRecord.getNumShapes() );
View Full Code Here

        assertEquals( 0, dm.getDgg().getFileIdClusters()[0].getNumShapeIdsUsed() );
    }

    public void testAllocateShapeId() throws Exception
    {
        EscherDggRecord dgg = new EscherDggRecord();
        dgg.setDrawingsSaved( 0 );
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[]{} );
        DrawingManager dm = new DrawingManager( dgg );

        EscherDgRecord dg = dm.createDgRecord();
        int shapeId = dm.allocateShapeId( dg.getDrawingGroupId() );
        assertEquals( 1024, shapeId );
        assertEquals( 1025, dgg.getShapeIdMax() );
        assertEquals( 1, dgg.getDrawingsSaved() );
        assertEquals( 1, dgg.getFileIdClusters()[0].getDrawingGroupId() );
        assertEquals( 1, dgg.getFileIdClusters()[0].getNumShapeIdsUsed() );
        assertEquals( 1024, dg.getLastMSOSPID() );
        assertEquals( 1, dg.getNumShapes() );
    }
View Full Code Here

    private EscherDggRecord dgg;

    protected void setUp() throws Exception
    {
        super.setUp();
        dgg = new EscherDggRecord();
        dgg.setFileIdClusters( new EscherDggRecord.FileIdCluster[0] );
        drawingManager2 = new DrawingManager2( dgg );
    }
View Full Code Here

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

                EscherDggRecord dgg = null;
                for(Iterator<EscherRecord> it = cr.getChildIterator(); it.hasNext();) {
                    Object er = it.next();
                    if(er instanceof EscherDggRecord) {
                        dgg = (EscherDggRecord)er;
                    }
                }

                if(dgg != null) {
                    drawingManager = new DrawingManager2(dgg);
                    return;
                }
            }
        }

        // Look for the DrawingGroup record
        int dgLoc = findFirstRecordLocBySid(DrawingGroupRecord.sid);

        // If there is one, does it have a EscherDggRecord?
        if(dgLoc != -1) {
            DrawingGroupRecord dg = (DrawingGroupRecord)records.get(dgLoc);
            EscherDggRecord dgg = null;
            for(Iterator it = dg.getEscherRecords().iterator(); it.hasNext();) {
                Object er = it.next();
                if(er instanceof EscherDggRecord) {
                    dgg = (EscherDggRecord)er;
                }
View Full Code Here

     *  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();
View Full Code Here

            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<EscherRecord> it = escherContainer.getChildIterator(); it.hasNext();) {
                EscherRecord er = it.next();
                if(er instanceof EscherDgRecord) {
View Full Code Here

TOP

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

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.