use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class HSLFTextShape method getEscherTextboxWrapper.
protected EscherTextboxWrapper getEscherTextboxWrapper() {
if (_txtbox != null) {
return _txtbox;
}
EscherTextboxRecord textRecord = getEscherChild(EscherTextboxRecord.RECORD_ID);
if (textRecord == null) {
return null;
}
HSLFSheet sheet = getSheet();
if (sheet != null) {
PPDrawing drawing = sheet.getPPDrawing();
if (drawing != null) {
EscherTextboxWrapper[] wrappers = drawing.getTextboxWrappers();
if (wrappers != null) {
for (EscherTextboxWrapper w : wrappers) {
// check for object identity
if (textRecord == w.getEscherRecord()) {
_txtbox = w;
return _txtbox;
}
}
}
}
}
_txtbox = new EscherTextboxWrapper(textRecord);
return _txtbox;
}
use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class TestSheet method verify.
private void verify(HSLFSheet sheet) {
assertNotNull(sheet.getSlideShow());
ColorSchemeAtom colorscheme = sheet.getColorScheme();
assertNotNull(colorscheme);
PPDrawing ppdrawing = sheet.getPPDrawing();
assertNotNull(ppdrawing);
HSLFBackground background = sheet.getBackground();
assertNotNull(background);
assertTrue(sheet._getSheetNumber() != 0);
assertTrue(sheet._getSheetRefId() != 0);
List<List<HSLFTextParagraph>> txt = sheet.getTextParagraphs();
// backgrounds.ppt has no texts
for (List<HSLFTextParagraph> t : txt) {
for (HSLFTextParagraph tp : t) {
assertNotNull(tp.getSheet());
}
}
List<HSLFShape> shape = sheet.getShapes();
assertTrue("no shapes", shape != null && !shape.isEmpty());
for (HSLFShape s : shape) {
assertNotNull(s.getSpContainer());
assertNotNull(s.getSheet());
assertNotNull(s.getShapeName());
assertNotNull(s.getAnchor());
}
}
use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class PPDrawingTextListing method main.
public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.err.println("Need to give a filename");
System.exit(1);
}
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
// Find PPDrawings at any second level position
Record[] records = ss.getRecords();
for (int i = 0; i < records.length; i++) {
Record[] children = records[i].getChildRecords();
if (children != null && children.length != 0) {
for (int j = 0; j < children.length; j++) {
if (children[j] instanceof PPDrawing) {
System.out.println("Found PPDrawing at " + j + " in top level record " + i + " (" + records[i].getRecordType() + ")");
// Look for EscherTextboxWrapper's
PPDrawing ppd = (PPDrawing) children[j];
EscherTextboxWrapper[] wrappers = ppd.getTextboxWrappers();
System.out.println(" Has " + wrappers.length + " textbox wrappers within");
// Loop over the wrappers, showing what they contain
for (int k = 0; k < wrappers.length; k++) {
EscherTextboxWrapper tbw = wrappers[k];
System.out.println(" " + k + " has " + tbw.getChildRecords().length + " PPT atoms within");
// Loop over the records, printing the text
Record[] pptatoms = tbw.getChildRecords();
for (int l = 0; l < pptatoms.length; l++) {
String text = null;
if (pptatoms[l] instanceof TextBytesAtom) {
TextBytesAtom tba = (TextBytesAtom) pptatoms[l];
text = tba.getText();
}
if (pptatoms[l] instanceof TextCharsAtom) {
TextCharsAtom tca = (TextCharsAtom) pptatoms[l];
text = tca.getText();
}
if (text != null) {
text = text.replace('\r', '\n');
System.out.println(" ''" + text + "''");
}
}
}
}
}
}
}
ss.close();
}
use of org.apache.poi.hslf.record.PPDrawing 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;
}
use of org.apache.poi.hslf.record.PPDrawing in project poi by apache.
the class HSLFSheet method addShape.
/**
* Add a new Shape to this Slide
*
* @param shape - the Shape to add
*/
@Override
public void addShape(HSLFShape shape) {
PPDrawing ppdrawing = getPPDrawing();
EscherContainerRecord dgContainer = ppdrawing.getDgContainer();
EscherContainerRecord spgr = (EscherContainerRecord) HSLFShape.getEscherChild(dgContainer, EscherContainerRecord.SPGR_CONTAINER);
spgr.addChildRecord(shape.getSpContainer());
shape.setSheet(this);
shape.setShapeId(allocateShapeId());
shape.afterInsert(this);
}
Aggregations