Search in sources :

Example 11 with EscherRecord

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

the class HSLFPictureShape method getEscherBSERecord.

@SuppressWarnings("resource")
protected EscherBSERecord getEscherBSERecord() {
    HSLFSlideShow ppt = getSheet().getSlideShow();
    Document doc = ppt.getDocumentRecord();
    EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
    EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
    if (bstore == null) {
        LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
        return null;
    }
    List<EscherRecord> lst = bstore.getChildRecords();
    int idx = getPictureIndex();
    if (idx == 0) {
        LOG.log(POILogger.DEBUG, "picture index was not found, returning ");
        return null;
    }
    return (EscherBSERecord) lst.get(idx - 1);
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) Document(org.apache.poi.hslf.record.Document) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 12 with EscherRecord

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

the class HSLFGroupShape method getShapes.

@Override
public List<HSLFShape> getShapes() {
    // Our escher container record should contain several
    // SpContainers, the first of which is the group shape itself
    List<HSLFShape> shapeList = new ArrayList<HSLFShape>();
    boolean isFirst = true;
    for (EscherRecord r : getSpContainer()) {
        if (isFirst) {
            // Don't include the first SpContainer, it is always NotPrimitive
            isFirst = false;
            continue;
        }
        if (r instanceof EscherContainerRecord) {
            // Create the Shape for it
            EscherContainerRecord container = (EscherContainerRecord) r;
            HSLFShape shape = HSLFShapeFactory.createShape(container, this);
            shape.setSheet(getSheet());
            shapeList.add(shape);
        } else {
            // Should we do anything special with these non
            //  Container records?
            LOG.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
        }
    }
    return shapeList;
}
Also used : ArrayList(java.util.ArrayList) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord)

Example 13 with EscherRecord

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

the class HSLFFill method getPictureData.

/**
     * <code>PictureData</code> object used in a texture, pattern of picture fill.
     */
@SuppressWarnings("resource")
public HSLFPictureData getPictureData() {
    AbstractEscherOptRecord opt = shape.getEscherOptRecord();
    EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
    if (p == null) {
        return null;
    }
    HSLFSlideShow ppt = shape.getSheet().getSlideShow();
    List<HSLFPictureData> pict = ppt.getPictureData();
    Document doc = ppt.getDocumentRecord();
    EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
    EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
    java.util.List<EscherRecord> lst = bstore.getChildRecords();
    int idx = p.getPropertyValue();
    if (idx == 0) {
        LOG.log(POILogger.WARN, "no reference to picture data found ");
    } else {
        EscherBSERecord bse = (EscherBSERecord) lst.get(idx - 1);
        for (HSLFPictureData pd : pict) {
            if (pd.getOffset() == bse.getOffset()) {
                return pd;
            }
        }
    }
    return null;
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) 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) DrawPaint(org.apache.poi.sl.draw.DrawPaint) GradientPaint(org.apache.poi.sl.usermodel.PaintStyle.GradientPaint) TexturePaint(org.apache.poi.sl.usermodel.PaintStyle.TexturePaint) EscherBSERecord(org.apache.poi.ddf.EscherBSERecord)

Example 14 with EscherRecord

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

the class HSLFSheet method removeShape.

/**
     * Removes the specified shape from this sheet.
     *
     * @param shape shape to be removed from this sheet, if present.
     * @return <tt>true</tt> if the shape was deleted.
     */
@Override
public boolean removeShape(HSLFShape shape) {
    PPDrawing ppdrawing = getPPDrawing();
    EscherContainerRecord dg = ppdrawing.getDgContainer();
    EscherContainerRecord spgr = dg.getChildById(EscherContainerRecord.SPGR_CONTAINER);
    if (spgr == null) {
        return false;
    }
    List<EscherRecord> lst = spgr.getChildRecords();
    boolean result = lst.remove(shape.getSpContainer());
    spgr.setChildRecords(lst);
    return result;
}
Also used : PPDrawing(org.apache.poi.hslf.record.PPDrawing) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherRecord(org.apache.poi.ddf.EscherRecord)

Example 15 with EscherRecord

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

the class EscherAggregate method toString.

/**
     * Calculates the string representation of this record.  This is
     * simply a dump of all the records.
     */
public String toString() {
    String nl = System.getProperty("line.separtor");
    StringBuilder result = new StringBuilder();
    result.append('[').append(getRecordName()).append(']').append(nl);
    for (EscherRecord escherRecord : getEscherRecords()) {
        result.append(escherRecord);
    }
    result.append("[/").append(getRecordName()).append(']').append(nl);
    return result.toString();
}
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