Methods Summary |
---|
public void | close()Shuts things down. Closes underlying streams etc
if(doc != null) {
doc.close();
}
doc = null;
|
public int | getDiskLen(org.apache.poi.hslf.record.Record r)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
r.writeOut(baos);
byte[] b = baos.toByteArray();
return b.length;
|
public static void | main(java.lang.String[] args)right now this function takes one parameter: a ppt file, and outputs
a dump of what it contains
if(args.length == 0) {
System.err.println("Useage: SlideShowRecordDumper <filename>");
return;
}
String filename = args[0];
SlideShowRecordDumper foo = new SlideShowRecordDumper(filename);
foo.printDump();
foo.close();
|
public java.lang.String | makeHex(int number, int padding)
String hex = Integer.toHexString(number).toUpperCase();
while(hex.length() < padding) {
hex = "0" + hex;
}
return hex;
|
public void | printDump()
// Prints out the records in the tree
walkTree(0,0,doc.getRecords());
|
public java.lang.String | reverseHex(java.lang.String s)
StringBuffer ret = new StringBuffer();
// Get to a multiple of two
if((s.length() / 2) * 2 != s.length()) { s = "0" + s; }
// Break up into blocks
char[] c = s.toCharArray();
for(int i=c.length; i>0; i-=2) {
ret.append(c[i-2]);
ret.append(c[i-1]);
if(i != 2) { ret.append(' "); }
}
return ret.toString();
|
public void | walkTree(int depth, int pos, org.apache.poi.hslf.record.Record[] records)
int indent = depth;
String ind = "";
for(int i=0; i<indent; i++) { ind += " "; }
for(int i=0; i<records.length; i++) {
Record r = records[i];
// Figure out how big it is
int len = getDiskLen(r);
// Grab the type as hex
String hexType = makeHex((int)r.getRecordType(),4);
String rHexType = reverseHex(hexType);
// Grab the hslf.record type
Class c = r.getClass();
String cname = c.toString();
if(cname.startsWith("class ")) {
cname = cname.substring(6);
}
if(cname.startsWith("org.apache.poi.hslf.record.")) {
cname = cname.substring(27);
}
// Display the record
System.out.println(ind + "At position " + pos + " (" + makeHex(pos,6) + "):");
System.out.println(ind + " Record is of type " + cname);
System.out.println(ind + " Type is " + r.getRecordType() + " (" + hexType + " -> " + rHexType + " )");
System.out.println(ind + " Len is " + (len-8) + " (" + makeHex((len-8),8) + "), on disk len is " + len );
System.out.println();
// If it has children, show them
if(r.getChildRecords() != null) {
walkTree((depth+3),pos+8,r.getChildRecords());
}
// Wind on the position marker
pos += len;
}
|