Search in sources :

Example 6 with EscherDggRecord

use of org.apache.poi.ddf.EscherDggRecord in project poi by apache.

the class InternalWorkbook method createDrawingGroup.

/**
     * 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.isEmpty()) {
            bstoreContainer = new EscherContainerRecord();
            bstoreContainer.setRecordId(EscherContainerRecord.BSTORE_CONTAINER);
            bstoreContainer.setOptions((short) ((escherBSERecords.size() << 4) | 0xF));
            for (EscherRecord escherRecord : escherBSERecords) {
                bstoreContainer.addChildRecord(escherRecord);
            }
        }
        opt.setRecordId((short) 0xF00B);
        opt.setOptions((short) 0x0033);
        opt.addEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 524296));
        opt.addEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, 0x08000041));
        opt.addEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, 134217792));
        splitMenuColors.setRecordId((short) 0xF11E);
        splitMenuColors.setOptions((short) 0x0040);
        splitMenuColors.setColor1(0x0800000D);
        splitMenuColors.setColor2(0x0800000C);
        splitMenuColors.setColor3(0x08000017);
        splitMenuColors.setColor4(0x100000F7);
        dggContainer.addChildRecord(dgg);
        if (bstoreContainer != null) {
            dggContainer.addChildRecord(bstoreContainer);
        }
        dggContainer.addChildRecord(opt);
        dggContainer.addChildRecord(splitMenuColors);
        int dgLoc = findFirstRecordLocBySid(DrawingGroupRecord.sid);
        if (dgLoc == -1) {
            DrawingGroupRecord drawingGroup = new DrawingGroupRecord();
            drawingGroup.addEscherRecord(dggContainer);
            int loc = findFirstRecordLocBySid(CountryRecord.sid);
            getRecords().add(loc + 1, drawingGroup);
        } else {
            DrawingGroupRecord drawingGroup = new DrawingGroupRecord();
            drawingGroup.addEscherRecord(dggContainer);
            getRecords().set(dgLoc, drawingGroup);
        }
    }
}
Also used : EscherSplitMenuColorsRecord(org.apache.poi.ddf.EscherSplitMenuColorsRecord) DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) EscherBoolProperty(org.apache.poi.ddf.EscherBoolProperty) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) EscherRGBProperty(org.apache.poi.ddf.EscherRGBProperty)

Example 7 with EscherDggRecord

use of org.apache.poi.ddf.EscherDggRecord in project poi by apache.

the class InternalWorkbook method cloneDrawings.

/**
     * Check if the cloned sheet has drawings. If yes, then allocate a new drawing group ID and
     * re-generate shape IDs
     *
     * @param sheet the cloned sheet
     */
public void cloneDrawings(InternalSheet sheet) {
    findDrawingGroup();
    if (drawingManager == null) {
        //this workbook does not have drawings
        return;
    }
    //check if the cloned sheet has drawings
    int aggLoc = sheet.aggregateDrawingRecords(drawingManager, false);
    if (aggLoc == -1) {
        return;
    }
    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 (EscherRecord er : escherContainer) {
        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) {
            // iterate over shapes and re-generate shapeId
            for (EscherRecord er2 : (EscherContainerRecord) er) {
                for (EscherRecord shapeChildRecord : (EscherContainerRecord) er2) {
                    int recordId = shapeChildRecord.getRecordId();
                    if (recordId == EscherSpRecord.RECORD_ID) {
                        if (dg == null) {
                            throw new RecordFormatException("EscherDgRecord wasn't set/processed before.");
                        }
                        EscherSpRecord sp = (EscherSpRecord) shapeChildRecord;
                        int shapeId = drawingManager.allocateShapeId((short) dgId, dg);
                        //allocateShapeId increments the number of shapes. roll back to the previous value
                        dg.setNumShapes(dg.getNumShapes() - 1);
                        sp.setShapeId(shapeId);
                    } else if (recordId == EscherOptRecord.RECORD_ID) {
                        EscherOptRecord opt = (EscherOptRecord) shapeChildRecord;
                        EscherSimpleProperty prop = (EscherSimpleProperty) opt.lookup(EscherProperties.BLIP__BLIPTODISPLAY);
                        if (prop != null) {
                            int pictureIndex = prop.getPropertyValue();
                            // increment reference count for pictures
                            EscherBSERecord bse = getBSERecord(pictureIndex);
                            bse.setRef(bse.getRef() + 1);
                        }
                    }
                }
            }
        }
    }
}
Also used : EscherAggregate(org.apache.poi.hssf.record.EscherAggregate) RecordFormatException(org.apache.poi.util.RecordFormatException) EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 8 with EscherDggRecord

use of org.apache.poi.ddf.EscherDggRecord in project poi by apache.

the class InternalWorkbook method findDrawingManager.

private static DrawingManager2 findDrawingManager(DrawingGroupRecord dg, List<EscherBSERecord> escherBSERecords) {
    if (dg == null) {
        return null;
    }
    // If there is one, does it have a EscherDggRecord?
    EscherContainerRecord cr = dg.getEscherContainer();
    if (cr == null) {
        return null;
    }
    EscherDggRecord dgg = null;
    EscherContainerRecord bStore = null;
    for (EscherRecord er : cr) {
        if (er instanceof EscherDggRecord) {
            dgg = (EscherDggRecord) er;
        } else if (er.getRecordId() == EscherContainerRecord.BSTORE_CONTAINER) {
            bStore = (EscherContainerRecord) er;
        }
    }
    if (dgg == null) {
        return null;
    }
    DrawingManager2 dm = new DrawingManager2(dgg);
    if (bStore != null) {
        for (EscherRecord bs : bStore.getChildRecords()) {
            if (bs instanceof EscherBSERecord) {
                escherBSERecords.add((EscherBSERecord) bs);
            }
        }
    }
    return dm;
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 9 with EscherDggRecord

use of org.apache.poi.ddf.EscherDggRecord in project poi by apache.

the class InternalWorkbook method findDrawingGroup.

/**
     * Finds the primary drawing group, if one already exists
     *
     * @return the primary drawing group
     */
public DrawingManager2 findDrawingGroup() {
    if (drawingManager != null) {
        // We already have it!
        return drawingManager;
    }
    // Need to find a DrawingGroupRecord that contains a EscherDggRecord
    for (Record r : records) {
        if (!(r instanceof DrawingGroupRecord)) {
            continue;
        }
        DrawingGroupRecord dg = (DrawingGroupRecord) r;
        dg.processChildRecords();
        drawingManager = findDrawingManager(dg, escherBSERecords);
        if (drawingManager != null) {
            return drawingManager;
        }
    }
    // TODO: we've already scanned the records, why should this work any better now?
    // Look for the DrawingGroup record
    DrawingGroupRecord dg = (DrawingGroupRecord) findFirstRecordBySid(DrawingGroupRecord.sid);
    drawingManager = findDrawingManager(dg, escherBSERecords);
    return drawingManager;
}
Also used : DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) WindowProtectRecord(org.apache.poi.hssf.record.WindowProtectRecord) PasswordRev4Record(org.apache.poi.hssf.record.PasswordRev4Record) DateWindow1904Record(org.apache.poi.hssf.record.DateWindow1904Record) FormatRecord(org.apache.poi.hssf.record.FormatRecord) BookBoolRecord(org.apache.poi.hssf.record.BookBoolRecord) StyleRecord(org.apache.poi.hssf.record.StyleRecord) RecalcIdRecord(org.apache.poi.hssf.record.RecalcIdRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) HideObjRecord(org.apache.poi.hssf.record.HideObjRecord) Record(org.apache.poi.hssf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) HyperlinkRecord(org.apache.poi.hssf.record.HyperlinkRecord) ProtectionRev4Record(org.apache.poi.hssf.record.ProtectionRev4Record) EOFRecord(org.apache.poi.hssf.record.EOFRecord) MMSRecord(org.apache.poi.hssf.record.MMSRecord) PrecisionRecord(org.apache.poi.hssf.record.PrecisionRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) CountryRecord(org.apache.poi.hssf.record.CountryRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) NameCommentRecord(org.apache.poi.hssf.record.NameCommentRecord) FnGroupCountRecord(org.apache.poi.hssf.record.FnGroupCountRecord) DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) BackupRecord(org.apache.poi.hssf.record.BackupRecord) EscherSplitMenuColorsRecord(org.apache.poi.ddf.EscherSplitMenuColorsRecord) ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord) WriteAccessRecord(org.apache.poi.hssf.record.WriteAccessRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) CodepageRecord(org.apache.poi.hssf.record.CodepageRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) FilePassRecord(org.apache.poi.hssf.record.FilePassRecord) FontRecord(org.apache.poi.hssf.record.FontRecord) UseSelFSRecord(org.apache.poi.hssf.record.UseSelFSRecord) WindowOneRecord(org.apache.poi.hssf.record.WindowOneRecord) WriteProtectRecord(org.apache.poi.hssf.record.WriteProtectRecord) ProtectRecord(org.apache.poi.hssf.record.ProtectRecord) InterfaceHdrRecord(org.apache.poi.hssf.record.InterfaceHdrRecord) DSFRecord(org.apache.poi.hssf.record.DSFRecord) InterfaceEndRecord(org.apache.poi.hssf.record.InterfaceEndRecord) SupBookRecord(org.apache.poi.hssf.record.SupBookRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) TabIdRecord(org.apache.poi.hssf.record.TabIdRecord) PasswordRecord(org.apache.poi.hssf.record.PasswordRecord) PaletteRecord(org.apache.poi.hssf.record.PaletteRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord) ExtSSTRecord(org.apache.poi.hssf.record.ExtSSTRecord) ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) FileSharingRecord(org.apache.poi.hssf.record.FileSharingRecord) RefreshAllRecord(org.apache.poi.hssf.record.RefreshAllRecord)

Example 10 with EscherDggRecord

use of org.apache.poi.ddf.EscherDggRecord in project poi by apache.

the class TestDrawingAggregate method testUnhandledContinue.

@Test
public void testUnhandledContinue() throws IOException {
    String data = "H4sIAAAAAAAAAO3adVRU2/4A8EPHAEOnlEooNaSUdCNIg4CUDCEtQ6gwlITSjYiSkoKA0ikg0i1IyCjS" + "QwpSEr8B73v3PS6+9+67vz/eH+615pyz9tn71PqevT/rfGcJOIcLBtDXrNgAgBjAXcMFAAAb9SPDBAAw" + "gLGmzna8xlxjR9WhAXhrxMAfCzqAf9IPQPXBAn6078IBgAyCH/VgVD2ADwCxAGhNBbXpc9LUF2h8n4we" + "iOoNAKEnywaAFmAEG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OcwY/Q6GjQGghDxtZ5GXkroNGSRBZXJVzXWn/V8EX8z" + "bh2EV1VrM2gkFVGxYum4qEsJHd2DPj6kJnJzVTADlCZWR7ItRI7zEPBUU2RiU8t1G6QOxXMhpekJvVQ4" + "IppKQdVys+cLtUY6Un0+hI2Z0wMzAxO8Lr0LbaILk8WtNsxpaFYMrTjC22723OH5GFkUi+ux8An2Hi0F" + "fvcr1v8aFU6POn+OCqfj4ffS/e+pcOEMKhABrCdUAAPhwB+pQHYGFcT/BBUEz6LC/wGpc+eRNSkAAA==";
    byte[] dgBytes = decompress(data);
    List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));
    assertEquals(20, dgRecords.size());
    short[] expectedSids = { DrawingRecord.sid, ObjRecord.sid, DrawingRecord.sid, TextObjectRecord.sid, DrawingRecord.sid, ObjRecord.sid, DrawingRecord.sid, TextObjectRecord.sid, DrawingRecord.sid, ObjRecord.sid, DrawingRecord.sid, TextObjectRecord.sid, DrawingRecord.sid, ObjRecord.sid, DrawingRecord.sid, TextObjectRecord.sid, ContinueRecord.sid, ObjRecord.sid, ContinueRecord.sid, TextObjectRecord.sid };
    for (int i = 0; i < expectedSids.length; i++) {
        assertEquals("unexpected record.sid and index[" + i + "]", expectedSids[i], dgRecords.get(i).getSid());
    }
    DrawingManager2 drawingManager = new DrawingManager2(new EscherDggRecord());
    // create a dummy sheet consisting of our test data
    InternalSheet sheet = InternalSheet.createSheet();
    List<RecordBase> records = sheet.getRecords();
    records.clear();
    records.addAll(dgRecords);
    records.add(EOFRecord.instance);
    sheet.aggregateDrawingRecords(drawingManager, false);
    assertEquals("drawing was not fully aggregated", 2, records.size());
    assertTrue("expected EscherAggregate", records.get(0) instanceof EscherAggregate);
    assertTrue("expected EOFRecord", records.get(1) instanceof EOFRecord);
    EscherAggregate agg = (EscherAggregate) records.get(0);
    byte[] dgBytesAfterSave = agg.serialize();
    assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
    assertTrue("drawing data before and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave));
}
Also used : EOFRecord(org.apache.poi.hssf.record.EOFRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) EscherAggregate(org.apache.poi.hssf.record.EscherAggregate) ByteArrayInputStream(java.io.ByteArrayInputStream) RecordBase(org.apache.poi.hssf.record.RecordBase) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) ContinueRecord(org.apache.poi.hssf.record.ContinueRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) Test(org.junit.Test)

Aggregations

EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)16 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)7 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)7 EscherRecord (org.apache.poi.ddf.EscherRecord)6 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)3 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)3 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)3 EOFRecord (org.apache.poi.hssf.record.EOFRecord)3 EscherAggregate (org.apache.poi.hssf.record.EscherAggregate)3 Record (org.apache.poi.hssf.record.Record)3 Test (org.junit.Test)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 EscherSplitMenuColorsRecord (org.apache.poi.ddf.EscherSplitMenuColorsRecord)2 ContinueRecord (org.apache.poi.hssf.record.ContinueRecord)2 DrawingGroupRecord (org.apache.poi.hssf.record.DrawingGroupRecord)2 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)2 RecordBase (org.apache.poi.hssf.record.RecordBase)2 EscherBoolProperty (org.apache.poi.ddf.EscherBoolProperty)1 EscherRGBProperty (org.apache.poi.ddf.EscherRGBProperty)1 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)1