use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class HSLFSheet method getShapes.
/**
* Returns all shapes contained in this Sheet
*
* @return all shapes contained in this Sheet (Slide or Notes)
*/
@Override
public List<HSLFShape> getShapes() {
PPDrawing ppdrawing = getPPDrawing();
EscherContainerRecord dg = ppdrawing.getDgContainer();
EscherContainerRecord spgr = null;
for (EscherRecord rec : dg) {
if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
spgr = (EscherContainerRecord) rec;
break;
}
}
if (spgr == null) {
throw new IllegalStateException("spgr not found");
}
List<HSLFShape> shapeList = new ArrayList<HSLFShape>();
boolean isFirst = true;
for (EscherRecord r : spgr) {
if (isFirst) {
// skip first item
isFirst = false;
continue;
}
EscherContainerRecord sp = (EscherContainerRecord) r;
HSLFShape sh = HSLFShapeFactory.createShape(sp, null);
sh.setSheet(this);
if (sh instanceof HSLFSimpleShape) {
HSLFHyperlink link = HSLFHyperlink.find(sh);
if (link != null) {
((HSLFSimpleShape) sh).setHyperlink(link);
}
}
shapeList.add(sh);
}
return shapeList;
}
use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class HSLFSheet method getBackground.
/**
* Returns the background shape for this sheet.
*
* @return the background shape for this sheet.
*/
@Override
public HSLFBackground getBackground() {
if (_background == null) {
PPDrawing ppdrawing = getPPDrawing();
EscherContainerRecord dg = ppdrawing.getDgContainer();
EscherContainerRecord spContainer = dg.getChildById(EscherContainerRecord.SP_CONTAINER);
_background = new HSLFBackground(spContainer, null);
_background.setSheet(this);
}
return _background;
}
use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class HSLFTextShape method afterInsert.
/**
* When a textbox is added to a sheet we need to tell upper-level
* <code>PPDrawing</code> about it.
*
* @param sh the sheet we are adding to
*/
@Override
protected void afterInsert(HSLFSheet sh) {
super.afterInsert(sh);
storeText();
EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
if (thisTxtbox != null) {
getSpContainer().addChildRecord(thisTxtbox.getEscherRecord());
PPDrawing ppdrawing = sh.getPPDrawing();
ppdrawing.addTextboxWrapper(thisTxtbox);
// Ensure the escher layer knows about the added records
try {
thisTxtbox.writeOut(null);
} catch (IOException e) {
throw new HSLFException(e);
}
boolean isInitialAnchor = getAnchor().equals(new Rectangle2D.Double());
boolean isFilledTxt = !"".equals(getText());
if (isInitialAnchor && isFilledTxt) {
resizeToFitText();
}
}
for (HSLFTextParagraph htp : _paragraphs) {
htp.setShapeId(getShapeId());
}
sh.onAddTextShape(this);
}
Aggregations