Search in sources :

Example 36 with EscherRecord

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

the class OfficeDrawingsImpl method getBitmapRecord.

private EscherBlipRecord getBitmapRecord(int bitmapIndex) {
    List<? extends EscherContainerRecord> bContainers = _escherRecordHolder.getBStoreContainers();
    if (bContainers == null || bContainers.size() != 1)
        return null;
    EscherContainerRecord bContainer = bContainers.get(0);
    final List<EscherRecord> bitmapRecords = bContainer.getChildRecords();
    if (bitmapRecords.size() < bitmapIndex)
        return null;
    EscherRecord imageRecord = bitmapRecords.get(bitmapIndex - 1);
    if (imageRecord instanceof EscherBlipRecord) {
        return (EscherBlipRecord) imageRecord;
    }
    if (imageRecord instanceof EscherBSERecord) {
        EscherBSERecord bseRecord = (EscherBSERecord) imageRecord;
        EscherBlipRecord blip = bseRecord.getBlipRecord();
        if (blip != null) {
            return blip;
        }
        if (bseRecord.getOffset() > 0) {
            /*
                 * Blip stored in delay stream, which in a word doc, is the main
                 * stream
                 */
            EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
            EscherRecord record = recordFactory.createRecord(_mainStream, bseRecord.getOffset());
            if (record instanceof EscherBlipRecord) {
                record.fillFields(_mainStream, bseRecord.getOffset(), recordFactory);
                return (EscherBlipRecord) record;
            }
        }
    }
    return null;
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) DefaultEscherRecordFactory(org.apache.poi.ddf.DefaultEscherRecordFactory) EscherBlipRecord(org.apache.poi.ddf.EscherBlipRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) EscherRecordFactory(org.apache.poi.ddf.EscherRecordFactory) DefaultEscherRecordFactory(org.apache.poi.ddf.DefaultEscherRecordFactory)

Example 37 with EscherRecord

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

the class TestBackground method getFillPictureRefCount.

private int getFillPictureRefCount(HSLFShape shape, HSLFFill fill) {
    AbstractEscherOptRecord opt = shape.getEscherOptRecord();
    EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
    if (p != null) {
        int idx = p.getPropertyValue();
        HSLFSheet sheet = shape.getSheet();
        HSLFSlideShow ppt = sheet.getSlideShow();
        Document doc = ppt.getDocumentRecord();
        EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
        EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
        List<EscherRecord> lst = bstore.getChildRecords();
        return ((EscherBSERecord) lst.get(idx - 1)).getRef();
    }
    return 0;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) HSLFSheet(org.apache.poi.hslf.usermodel.HSLFSheet) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) Document(org.apache.poi.hslf.record.Document) AbstractEscherOptRecord(org.apache.poi.ddf.AbstractEscherOptRecord) HSLFSlideShow(org.apache.poi.hslf.usermodel.HSLFSlideShow) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 38 with EscherRecord

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

the class HSSFWorkbook method dumpDrawingGroupRecords.

/**
     * Spits out a list of all the drawing records in the workbook.
     */
public void dumpDrawingGroupRecords(boolean fat) {
    DrawingGroupRecord r = (DrawingGroupRecord) workbook.findFirstRecordBySid(DrawingGroupRecord.sid);
    r.decode();
    List<EscherRecord> escherRecords = r.getEscherRecords();
    PrintWriter w = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
    for (EscherRecord escherRecord : escherRecords) {
        if (fat) {
            System.out.println(escherRecord);
        } else {
            escherRecord.display(w, 0);
        }
    }
    w.flush();
}
Also used : DrawingGroupRecord(org.apache.poi.hssf.record.DrawingGroupRecord) OutputStreamWriter(java.io.OutputStreamWriter) EscherRecord(org.apache.poi.ddf.EscherRecord) PrintWriter(java.io.PrintWriter)

Example 39 with EscherRecord

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

the class HSSFWorkbook method searchForPictures.

/**
     * Performs a recursive search for pictures in the given list of escher records.
     *
     * @param escherRecords the escher records.
     * @param pictures the list to populate with the pictures.
     */
private void searchForPictures(List<EscherRecord> escherRecords, List<HSSFPictureData> pictures) {
    for (EscherRecord escherRecord : escherRecords) {
        if (escherRecord instanceof EscherBSERecord) {
            EscherBlipRecord blip = ((EscherBSERecord) escherRecord).getBlipRecord();
            if (blip != null) {
                // TODO: Some kind of structure.
                HSSFPictureData picture = new HSSFPictureData(blip);
                pictures.add(picture);
            }
        }
        // Recursive call.
        searchForPictures(escherRecord.getChildRecords(), pictures);
    }
}
Also used : EscherRecord(org.apache.poi.ddf.EscherRecord) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) EscherBlipRecord(org.apache.poi.ddf.EscherBlipRecord)

Example 40 with EscherRecord

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

the class SlideShowRecordDumper method printEscherContainerRecord.

private void printEscherContainerRecord(EscherContainerRecord ecr, int indent) {
    String ind = tabs.substring(0, indent);
    ps.println(ind + ecr.getClass().getName() + " (" + ecr.getRecordName() + "):");
    ps.println(ind + "  isContainer: " + ecr.isContainerRecord());
    ps.println(ind + "  options: 0x" + HexDump.toHex(ecr.getOptions()));
    ps.println(ind + "  recordId: 0x" + HexDump.toHex(ecr.getRecordId()));
    List<EscherRecord> childRecords = ecr.getChildRecords();
    ps.println(ind + "  numchildren: " + childRecords.size());
    ps.println(ind + "  children: ");
    int count = 0;
    for (EscherRecord record : childRecords) {
        ps.println(ind + "   Child " + count + ":");
        printEscherRecord(record, indent + 1);
        count++;
    }
}
Also used : EscherRecord(org.apache.poi.ddf.EscherRecord)

Aggregations

EscherRecord (org.apache.poi.ddf.EscherRecord)42 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)20 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)10 DefaultEscherRecordFactory (org.apache.poi.ddf.DefaultEscherRecordFactory)9 ArrayList (java.util.ArrayList)7 EscherRecordFactory (org.apache.poi.ddf.EscherRecordFactory)6 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)6 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)6 DrawingGroupRecord (org.apache.poi.hssf.record.DrawingGroupRecord)5 EscherBlipRecord (org.apache.poi.ddf.EscherBlipRecord)4 EscherClientDataRecord (org.apache.poi.ddf.EscherClientDataRecord)4 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)4 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)4 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)4 Document (org.apache.poi.hslf.record.Document)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)3 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)3 EscherSpgrRecord (org.apache.poi.ddf.EscherSpgrRecord)3 EscherProperty (org.apache.poi.ddf.EscherProperty)2