Create a new Placeholder and initialize internal structures
EscherContainerRecord spcont = super.createSpContainer(isChild);
EscherSpRecord spRecord = spcont.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HAVEMASTER);
EscherClientDataRecord cldata = new EscherClientDataRecord();
cldata.setOptions((short)15);
EscherOptRecord opt = (EscherOptRecord)getEscherChild(spcont, EscherOptRecord.RECORD_ID);
//Placeholders can't be grouped
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 262144);
//OEPlaceholderAtom tells powerpoint that this shape is a placeholder
//
OEPlaceholderAtom oep = new OEPlaceholderAtom();
/**
* Extarct from MSDN:
*
* There is a special case when the placeholder does not have a position in the layout.
* This occurs when the user has moved the placeholder from its original position.
* In this case the placeholder ID is -1.
*/
oep.setPlacementId(-1);
oep.setPlaceholderId(OEPlaceholderAtom.Body);
//convert hslf into ddf record
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
oep.writeOut(out);
} catch(Exception e){
throw new HSLFException(e);
}
cldata.setRemainingData(out.toByteArray());
//append placeholder container before EscherTextboxRecord
List lst = spcont.getChildRecords();
for (int i = 0; i < lst.size(); i++) {
EscherRecord rec = (EscherRecord)lst.get(i);
if(rec.getRecordId() == EscherTextboxRecord.RECORD_ID){
lst.add(i++, cldata);
}
}
return spcont;