use of org.apache.poi.ddf.EscherSpRecord in project poi by apache.
the class PPDrawing method findEscherTextboxRecord.
/**
* Look for EscherTextboxRecords
*/
private void findEscherTextboxRecord(List<EscherRecord> toSearch, List<EscherTextboxWrapper> found) {
EscherSpRecord sp = null;
for (EscherRecord r : toSearch) {
if (r instanceof EscherSpRecord) {
sp = (EscherSpRecord) r;
} else if (r instanceof EscherTextboxRecord) {
EscherTextboxRecord tbr = (EscherTextboxRecord) r;
EscherTextboxWrapper w = new EscherTextboxWrapper(tbr);
if (sp != null) {
w.setShapeId(sp.getShapeId());
}
found.add(w);
} else if (r.isContainerRecord()) {
// If it has children, walk them
List<EscherRecord> children = r.getChildRecords();
findEscherTextboxRecord(children, found);
}
}
}
use of org.apache.poi.ddf.EscherSpRecord 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.EscherSpRecord in project poi by apache.
the class EscherAggregate method setMainSpRecordId.
/**
* EscherDgContainer
* -EscherSpgrContainer
* --EscherSpContainer
* ---EscherSpRecord -set id for this record
* ---***
* --***
* -EscherDgRecord
* set id for the sp record of the first spContainer in main spgrConatiner
* @param shapeId - id which must be set
*/
public void setMainSpRecordId(int shapeId) {
EscherContainerRecord dgContainer = getEscherContainer();
EscherContainerRecord spgrConatiner = (EscherContainerRecord) dgContainer.getChildById(EscherContainerRecord.SPGR_CONTAINER);
EscherContainerRecord spContainer = (EscherContainerRecord) spgrConatiner.getChild(0);
EscherSpRecord sp = (EscherSpRecord) spContainer.getChildById(EscherSpRecord.RECORD_ID);
sp.setShapeId(shapeId);
}
use of org.apache.poi.ddf.EscherSpRecord in project poi by apache.
the class HSLFShape method setFlipVertical.
public void setFlipVertical(boolean flip) {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPVERT;
spRecord.setFlags(flag);
}
use of org.apache.poi.ddf.EscherSpRecord in project poi by apache.
the class HSLFShape method getAnchor.
/**
* Returns the anchor (the bounding box rectangle) of this shape.
* All coordinates are expressed in points (72 dpi).
*
* @return the anchor of this shape
*/
@Override
public Rectangle2D getAnchor() {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flags = spRecord.getFlags();
int x1, y1, x2, y2;
EscherChildAnchorRecord childRec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
boolean useChildRec = ((flags & EscherSpRecord.FLAG_CHILD) != 0);
if (useChildRec && childRec != null) {
x1 = childRec.getDx1();
y1 = childRec.getDy1();
x2 = childRec.getDx2();
y2 = childRec.getDy2();
} else {
if (useChildRec) {
LOG.log(POILogger.WARN, "EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
}
EscherClientAnchorRecord clientRec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
x1 = clientRec.getCol1();
y1 = clientRec.getFlag();
x2 = clientRec.getDx1();
y2 = clientRec.getRow1();
}
// TODO: find out where this -1 value comes from at #57820 (link to ms docs?)
Rectangle2D anchor = new Rectangle2D.Double((x1 == -1 ? -1 : Units.masterToPoints(x1)), (y1 == -1 ? -1 : Units.masterToPoints(y1)), (x2 == -1 ? -1 : Units.masterToPoints(x2 - x1)), (y2 == -1 ? -1 : Units.masterToPoints(y2 - y1)));
return anchor;
}
Aggregations