Search in sources :

Example 16 with EscherContainerRecord

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

the class HSLFPlaceholder method createSpContainer.

/**
     * Create a new Placeholder and initialize internal structures
     *
     * @return the created <code>EscherContainerRecord</code> which holds shape data
     */
@Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
    EscherContainerRecord ecr = super.createSpContainer(isChild);
    setPlaceholder(Placeholder.BODY);
    return ecr;
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord)

Example 17 with EscherContainerRecord

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

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

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

the class HSLFGroupShape method createSpContainer.

/**
     * Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
     */
@Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
    EscherContainerRecord ecr = super.createSpContainer(isChild);
    ecr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
    //The group itself is a shape, and always appears as the first EscherSpContainer in the group container.
    EscherContainerRecord spcont = new EscherContainerRecord();
    spcont.setRecordId(EscherContainerRecord.SP_CONTAINER);
    spcont.setOptions((short) 15);
    EscherSpgrRecord spg = new EscherSpgrRecord();
    spg.setOptions((short) 1);
    spcont.addChildRecord(spg);
    EscherSpRecord sp = new EscherSpRecord();
    short type = (short) ((ShapeType.NOT_PRIMITIVE.nativeId << 4) + 2);
    sp.setOptions(type);
    sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_GROUP);
    spcont.addChildRecord(sp);
    EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
    spcont.addChildRecord(anchor);
    ecr.addChildRecord(spcont);
    return ecr;
}
Also used : EscherSpgrRecord(org.apache.poi.ddf.EscherSpgrRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherClientAnchorRecord(org.apache.poi.ddf.EscherClientAnchorRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord)

Example 20 with EscherContainerRecord

use of org.apache.poi.ddf.EscherContainerRecord 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)

Aggregations

EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)53 EscherRecord (org.apache.poi.ddf.EscherRecord)17 EscherSpRecord (org.apache.poi.ddf.EscherSpRecord)17 EscherOptRecord (org.apache.poi.ddf.EscherOptRecord)11 EscherBSERecord (org.apache.poi.ddf.EscherBSERecord)8 EscherSimpleProperty (org.apache.poi.ddf.EscherSimpleProperty)8 AbstractEscherOptRecord (org.apache.poi.ddf.AbstractEscherOptRecord)6 EscherDgRecord (org.apache.poi.ddf.EscherDgRecord)6 DefaultEscherRecordFactory (org.apache.poi.ddf.DefaultEscherRecordFactory)5 ObjRecord (org.apache.poi.hssf.record.ObjRecord)5 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)4 EscherSpgrRecord (org.apache.poi.ddf.EscherSpgrRecord)4 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)4 Document (org.apache.poi.hslf.record.Document)4 PPDrawing (org.apache.poi.hslf.record.PPDrawing)4 LinkedList (java.util.LinkedList)3 EscherBoolProperty (org.apache.poi.ddf.EscherBoolProperty)3 EscherClientDataRecord (org.apache.poi.ddf.EscherClientDataRecord)3 EscherRGBProperty (org.apache.poi.ddf.EscherRGBProperty)3 ExObjRefAtom (org.apache.poi.hslf.record.ExObjRefAtom)3