Search in sources :

Example 6 with EscherContainerRecord

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

the class MovieShape method createSpContainer.

/**
     * Create a new Placeholder and initialize internal structures
     *
     * @return the created <code>EscherContainerRecord</code> which holds shape data
     */
@Override
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
    EscherContainerRecord ecr = super.createSpContainer(idx, isChild);
    setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
    setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);
    ExObjRefAtom oe = new ExObjRefAtom();
    InteractiveInfo info = new InteractiveInfo();
    InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom();
    infoAtom.setAction(InteractiveInfoAtom.ACTION_MEDIA);
    infoAtom.setHyperlinkType(InteractiveInfoAtom.LINK_NULL);
    AnimationInfo an = new AnimationInfo();
    AnimationInfoAtom anAtom = an.getAnimationInfoAtom();
    anAtom.setFlag(AnimationInfoAtom.Automatic, true);
    HSLFEscherClientDataRecord cldata = getClientData(true);
    cldata.addChild(oe);
    cldata.addChild(an);
    cldata.addChild(info);
    return ecr;
}
Also used : ExObjRefAtom(org.apache.poi.hslf.record.ExObjRefAtom) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) InteractiveInfoAtom(org.apache.poi.hslf.record.InteractiveInfoAtom) AnimationInfo(org.apache.poi.hslf.record.AnimationInfo) AnimationInfoAtom(org.apache.poi.hslf.record.AnimationInfoAtom) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) InteractiveInfo(org.apache.poi.hslf.record.InteractiveInfo)

Example 7 with EscherContainerRecord

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

the class OLEShape method setObjectID.

/**
     * Set the unique identifier for the OLE object and
     * register it in the necessary structures
     * 
     * @param objectId the unique identifier for the OLE object
     */
public void setObjectID(int objectId) {
    setEscherProperty(EscherProperties.BLIP__PICTUREID, objectId);
    EscherContainerRecord ecr = getSpContainer();
    EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
    spRecord.setFlags(spRecord.getFlags() | EscherSpRecord.FLAG_OLESHAPE);
    HSLFEscherClientDataRecord cldata = getClientData(true);
    ExObjRefAtom uer = null;
    for (Record r : cldata.getHSLFChildRecords()) {
        if (r.getRecordType() == RecordTypes.ExObjRefAtom.typeID) {
            uer = (ExObjRefAtom) r;
            break;
        }
    }
    if (uer == null) {
        uer = new ExObjRefAtom();
        cldata.addChild(uer);
    }
    uer.setExObjIdRef(objectId);
}
Also used : ExObjRefAtom(org.apache.poi.hslf.record.ExObjRefAtom) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) HSLFEscherClientDataRecord(org.apache.poi.hslf.record.HSLFEscherClientDataRecord) Record(org.apache.poi.hslf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherSpRecord(org.apache.poi.ddf.EscherSpRecord)

Example 8 with EscherContainerRecord

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

the class PPDrawing method findAllEscherContainerRecordOfType.

protected EscherContainerRecord[] findAllEscherContainerRecordOfType(RecordTypes type, EscherContainerRecord parent) {
    if (null == parent) {
        return new EscherContainerRecord[0];
    }
    final List<EscherContainerRecord> children = parent.getChildContainers();
    final List<EscherContainerRecord> result = new LinkedList<EscherContainerRecord>();
    for (EscherContainerRecord child : children) {
        if (type.typeID == child.getRecordId()) {
            result.add(child);
        }
    }
    return result.toArray(new EscherContainerRecord[result.size()]);
}
Also used : EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) LinkedList(java.util.LinkedList)

Example 9 with EscherContainerRecord

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

the class HSLFSlide method onCreate.

/**
     * Called by SlideShow ater a new slide is created.
     * <p>
     * For Slide we need to do the following:
     *  <li> set id of the drawing group.
     *  <li> set shapeId for the container descriptor and background
     * </p>
     */
@Override
public void onCreate() {
    //initialize drawing group id
    EscherDggRecord dgg = getSlideShow().getDocumentRecord().getPPDrawingGroup().getEscherDggRecord();
    EscherContainerRecord dgContainer = getSheetContainer().getPPDrawing().getDgContainer();
    EscherDgRecord dg = (EscherDgRecord) HSLFShape.getEscherChild(dgContainer, EscherDgRecord.RECORD_ID);
    int dgId = dgg.getMaxDrawingGroupId() + 1;
    dg.setOptions((short) (dgId << 4));
    dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
    dgg.setMaxDrawingGroupId(dgId);
    for (EscherContainerRecord c : dgContainer.getChildContainers()) {
        EscherSpRecord spr = null;
        switch(c.getRecordId()) {
            case EscherContainerRecord.SPGR_CONTAINER:
                EscherContainerRecord dc = (EscherContainerRecord) c.getChild(0);
                spr = dc.getChildById(EscherSpRecord.RECORD_ID);
                break;
            case EscherContainerRecord.SP_CONTAINER:
                spr = c.getChildById(EscherSpRecord.RECORD_ID);
                break;
            default:
                break;
        }
        if (spr != null) {
            spr.setShapeId(allocateShapeId());
        }
    }
    //PPT doen't increment the number of saved shapes for group descriptor and background
    dg.setNumShapes(1);
}
Also used : EscherSpRecord(org.apache.poi.ddf.EscherSpRecord) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) EscherDgRecord(org.apache.poi.ddf.EscherDgRecord)

Example 10 with EscherContainerRecord

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

the class OfficeDrawingsImpl method getOfficeDrawing.

private OfficeDrawing getOfficeDrawing(final FSPA fspa) {
    return new OfficeDrawing() {

        public HorizontalPositioning getHorizontalPositioning() {
            int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSH, -1);
            switch(value) {
                case 0:
                    return HorizontalPositioning.ABSOLUTE;
                case 1:
                    return HorizontalPositioning.LEFT;
                case 2:
                    return HorizontalPositioning.CENTER;
                case 3:
                    return HorizontalPositioning.RIGHT;
                case 4:
                    return HorizontalPositioning.INSIDE;
                case 5:
                    return HorizontalPositioning.OUTSIDE;
            }
            return HorizontalPositioning.ABSOLUTE;
        }

        public HorizontalRelativeElement getHorizontalRelative() {
            int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSRELH, -1);
            switch(value) {
                case 1:
                    return HorizontalRelativeElement.MARGIN;
                case 2:
                    return HorizontalRelativeElement.PAGE;
                case 3:
                    return HorizontalRelativeElement.TEXT;
                case 4:
                    return HorizontalRelativeElement.CHAR;
            }
            return HorizontalRelativeElement.TEXT;
        }

        public EscherContainerRecord getOfficeArtSpContainer() {
            return getEscherShapeRecordContainer(getShapeId());
        }

        public byte[] getPictureData() {
            EscherContainerRecord shapeDescription = getEscherShapeRecordContainer(getShapeId());
            if (shapeDescription == null)
                return null;
            EscherOptRecord escherOptRecord = shapeDescription.getChildById(EscherOptRecord.RECORD_ID);
            if (escherOptRecord == null)
                return null;
            EscherSimpleProperty escherProperty = escherOptRecord.lookup(EscherProperties.BLIP__BLIPTODISPLAY);
            if (escherProperty == null)
                return null;
            int bitmapIndex = escherProperty.getPropertyValue();
            EscherBlipRecord escherBlipRecord = getBitmapRecord(bitmapIndex);
            if (escherBlipRecord == null)
                return null;
            return escherBlipRecord.getPicturedata();
        }

        public int getRectangleBottom() {
            return fspa.getYaBottom();
        }

        public int getRectangleLeft() {
            return fspa.getXaLeft();
        }

        public int getRectangleRight() {
            return fspa.getXaRight();
        }

        public int getRectangleTop() {
            return fspa.getYaTop();
        }

        public int getShapeId() {
            return fspa.getSpid();
        }

        private int getTertiaryPropertyValue(int propertyId, int defaultValue) {
            EscherContainerRecord shapeDescription = getEscherShapeRecordContainer(getShapeId());
            if (shapeDescription == null)
                return defaultValue;
            EscherTertiaryOptRecord escherTertiaryOptRecord = shapeDescription.getChildById(EscherTertiaryOptRecord.RECORD_ID);
            if (escherTertiaryOptRecord == null)
                return defaultValue;
            EscherSimpleProperty escherProperty = escherTertiaryOptRecord.lookup(propertyId);
            if (escherProperty == null)
                return defaultValue;
            int value = escherProperty.getPropertyValue();
            return value;
        }

        public VerticalPositioning getVerticalPositioning() {
            int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSV, -1);
            switch(value) {
                case 0:
                    return VerticalPositioning.ABSOLUTE;
                case 1:
                    return VerticalPositioning.TOP;
                case 2:
                    return VerticalPositioning.CENTER;
                case 3:
                    return VerticalPositioning.BOTTOM;
                case 4:
                    return VerticalPositioning.INSIDE;
                case 5:
                    return VerticalPositioning.OUTSIDE;
            }
            return VerticalPositioning.ABSOLUTE;
        }

        public VerticalRelativeElement getVerticalRelativeElement() {
            int value = getTertiaryPropertyValue(EscherProperties.GROUPSHAPE__POSV, -1);
            switch(value) {
                case 1:
                    return VerticalRelativeElement.MARGIN;
                case 2:
                    return VerticalRelativeElement.PAGE;
                case 3:
                    return VerticalRelativeElement.TEXT;
                case 4:
                    return VerticalRelativeElement.LINE;
            }
            return VerticalRelativeElement.TEXT;
        }

        @Override
        public String toString() {
            return "OfficeDrawingImpl: " + fspa;
        }
    };
}
Also used : EscherSimpleProperty(org.apache.poi.ddf.EscherSimpleProperty) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherTertiaryOptRecord(org.apache.poi.ddf.EscherTertiaryOptRecord) EscherOptRecord(org.apache.poi.ddf.EscherOptRecord) EscherBlipRecord(org.apache.poi.ddf.EscherBlipRecord)

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