Search in sources :

Example 6 with EscherBlipRecord

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

the class HSSFPicture method getPictureData.

/**
     * Return picture data for this shape
     *
     * @return picture data for this shape or {@code null} if picture wasn't embedded, i.e. external linked
     */
@Override
public HSSFPictureData getPictureData() {
    int picIdx = getPictureIndex();
    if (picIdx == -1) {
        return null;
    }
    HSSFPatriarch patriarch = getPatriarch();
    HSSFShape parent = getParent();
    while (patriarch == null && parent != null) {
        patriarch = parent.getPatriarch();
        parent = parent.getParent();
    }
    if (patriarch == null) {
        throw new IllegalStateException("Could not find a patriarch for a HSSPicture");
    }
    InternalWorkbook iwb = patriarch.getSheet().getWorkbook().getWorkbook();
    EscherBSERecord bse = iwb.getBSERecord(picIdx);
    EscherBlipRecord blipRecord = bse.getBlipRecord();
    return new HSSFPictureData(blipRecord);
}
Also used : InternalWorkbook(org.apache.poi.hssf.model.InternalWorkbook) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord) EscherBlipRecord(org.apache.poi.ddf.EscherBlipRecord)

Aggregations

EscherBlipRecord (org.apache.poi.ddf.EscherBlipRecord)6 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)5 EscherRecord (org.apache.poi.ddf.EscherRecord)3 DefaultEscherRecordFactory (org.apache.poi.ddf.DefaultEscherRecordFactory)2 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)2 EscherRecordFactory (org.apache.poi.ddf.EscherRecordFactory)2 EscherBitmapBlip (org.apache.poi.ddf.EscherBitmapBlip)1 EscherMetafileBlip (org.apache.poi.ddf.EscherMetafileBlip)1 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)1 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)1 EscherTertiaryOptRecord (org.apache.poi.ddf.EscherTertiaryOptRecord)1 InternalWorkbook (org.apache.poi.hssf.model.InternalWorkbook)1 Picture (org.apache.poi.hwpf.usermodel.Picture)1