Search in sources :

Example 11 with DefaultEscherRecordFactory

use of org.apache.poi.ddf.DefaultEscherRecordFactory 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 12 with DefaultEscherRecordFactory

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

the class HSSFSimpleShape method cloneShape.

@Override
protected HSSFShape cloneShape() {
    TextObjectRecord txo = null;
    EscherContainerRecord spContainer = new EscherContainerRecord();
    byte[] inSp = getEscherContainer().serialize();
    spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
    ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
    if (getTextObjectRecord() != null && getString() != null && null != getString().getString()) {
        txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
    }
    return new HSSFSimpleShape(spContainer, obj, txo);
}
Also used : TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) DefaultEscherRecordFactory(org.apache.poi.ddf.DefaultEscherRecordFactory)

Aggregations

DefaultEscherRecordFactory (org.apache.poi.ddf.DefaultEscherRecordFactory)12 EscherRecord (org.apache.poi.ddf.EscherRecord)9 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)7 EscherRecordFactory (org.apache.poi.ddf.EscherRecordFactory)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)3 ObjRecord (org.apache.poi.hssf.record.ObjRecord)3 ArrayList (java.util.ArrayList)2 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)2 EscherBlipRecord (org.apache.poi.ddf.EscherBlipRecord)2 HSLFEscherRecordFactory (org.apache.poi.hslf.record.HSLFEscherRecordFactory)2 TextObjectRecord (org.apache.poi.hssf.record.TextObjectRecord)2 IOException (java.io.IOException)1 EscherClientDataRecord (org.apache.poi.ddf.EscherClientDataRecord)1 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)1 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)1 EscherSpgrRecord (org.apache.poi.ddf.EscherSpgrRecord)1 Record (org.apache.poi.hslf.record.Record)1 NoteRecord (org.apache.poi.hssf.record.NoteRecord)1 Picture (org.apache.poi.hwpf.usermodel.Picture)1