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;
}
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);
}
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()]);
}
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);
}
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;
}
};
}
Aggregations