use of org.apache.poi.hslf.record.Record in project poi by apache.
the class ActiveXShape method getExControl.
/**
* Document-level container that specifies information about an ActiveX control
*
* @return container that specifies information about an ActiveX control
*/
public ExControl getExControl() {
int idx = getControlIndex();
Document doc = getSheet().getSlideShow().getDocumentRecord();
ExObjList lst = (ExObjList) doc.findFirstOfType(RecordTypes.ExObjList.typeID);
if (lst == null) {
return null;
}
for (Record ch : lst.getChildRecords()) {
if (ch instanceof ExControl) {
ExControl c = (ExControl) ch;
if (c.getExOleObjAtom().getObjID() == idx) {
return c;
}
}
}
return null;
}
use of org.apache.poi.hslf.record.Record in project poi by apache.
the class SLWTListing 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 the documents, and then their SLWT
Record[] records = ss.getRecords();
for (int i = 0; i < records.length; i++) {
if (records[i] instanceof Document) {
Document doc = (Document) records[i];
SlideListWithText[] slwts = doc.getSlideListWithTexts();
System.out.println("Document at " + i + " had " + slwts.length + " SlideListWithTexts");
if (slwts.length == 0) {
System.err.println("** Warning: Should have had at least 1! **");
}
if (slwts.length > 3) {
System.err.println("** Warning: Shouldn't have more than 3!");
}
// Check the SLWTs contain what we'd expect
for (int j = 0; j < slwts.length; j++) {
SlideListWithText slwt = slwts[j];
Record[] children = slwt.getChildRecords();
System.out.println(" - SLWT at " + j + " had " + children.length + " children:");
// Should only have SlideAtomSets if the second one
int numSAS = slwt.getSlideAtomsSets().length;
if (j == 1) {
if (numSAS == 0) {
System.err.println(" ** 2nd SLWT didn't have any SlideAtomSets!");
} else {
System.out.println(" - Contains " + numSAS + " SlideAtomSets");
}
} else {
if (numSAS > 0) {
System.err.println(" ** SLWT " + j + " had " + numSAS + " SlideAtomSets! (expected 0)");
}
}
// Report the first 5 children, to give a flavour
int upTo = 5;
if (children.length < 5) {
upTo = children.length;
}
for (int k = 0; k < upTo; k++) {
Record r = children[k];
int typeID = (int) r.getRecordType();
String typeName = RecordTypes.forTypeID(typeID).name();
System.out.println(" - " + typeID + " (" + typeName + ")");
}
}
}
}
ss.close();
}
use of org.apache.poi.hslf.record.Record in project poi by apache.
the class SlideAndNotesAtomListing 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]);
System.out.println("");
// Find either Slides or Notes
Record[] records = ss.getRecords();
for (int i = 0; i < records.length; i++) {
Record r = records[i];
// When we find them, print out their IDs
if (r instanceof Slide) {
Slide s = (Slide) r;
SlideAtom sa = s.getSlideAtom();
System.out.println("Found Slide at " + i);
System.out.println(" Slide's master ID is " + sa.getMasterID());
System.out.println(" Slide's notes ID is " + sa.getNotesID());
System.out.println("");
}
if (r instanceof Notes) {
Notes n = (Notes) r;
NotesAtom na = n.getNotesAtom();
System.out.println("Found Notes at " + i);
System.out.println(" Notes ID is " + na.getSlideID());
System.out.println("");
}
}
ss.close();
}
use of org.apache.poi.hslf.record.Record in project poi by apache.
the class OLEShape method setObjectID.
/**
* Set the unique identifier for the OLE object and
* register it in the necessary structures
*
* @param objectId the unique identifier for the OLE object
*/
public void setObjectID(int objectId) {
setEscherProperty(EscherProperties.BLIP__PICTUREID, objectId);
EscherContainerRecord ecr = getSpContainer();
EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setFlags(spRecord.getFlags() | EscherSpRecord.FLAG_OLESHAPE);
HSLFEscherClientDataRecord cldata = getClientData(true);
ExObjRefAtom uer = null;
for (Record r : cldata.getHSLFChildRecords()) {
if (r.getRecordType() == RecordTypes.ExObjRefAtom.typeID) {
uer = (ExObjRefAtom) r;
break;
}
}
if (uer == null) {
uer = new ExObjRefAtom();
cldata.addChild(uer);
}
uer.setExObjIdRef(objectId);
}
use of org.apache.poi.hslf.record.Record in project poi by apache.
the class SlideShowRecordDumper method printEscherTextBox.
private void printEscherTextBox(EscherTextboxRecord tbRecord, int indent) {
String ind = tabs.substring(0, indent);
ps.println(ind + "EscherTextboxRecord:");
EscherTextboxWrapper etw = new EscherTextboxWrapper(tbRecord);
Record prevChild = null;
for (Record child : etw.getChildRecords()) {
if (child instanceof StyleTextPropAtom) {
// need preceding Text[Chars|Bytes]Atom to initialize the data structure
String text = null;
if (prevChild instanceof TextCharsAtom) {
text = ((TextCharsAtom) prevChild).getText();
} else if (prevChild instanceof TextBytesAtom) {
text = ((TextBytesAtom) prevChild).getText();
} else {
ps.println(ind + "Error! Couldn't find preceding TextAtom for style");
continue;
}
StyleTextPropAtom tsp = (StyleTextPropAtom) child;
tsp.setParentTextSize(text.length());
}
ps.println(ind + child);
prevChild = child;
}
}
Aggregations