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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations