HMEF dumping and properties tweaks

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1058243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2011-01-12 17:22:40 +00:00
parent 182eac4abc
commit ee734212a9
2 changed files with 23 additions and 6 deletions

View File

@ -104,7 +104,8 @@ public class MAPIAttribute {
MAPIProperty prop = MAPIProperty.get(id); MAPIProperty prop = MAPIProperty.get(id);
if(id >= 0x8000 && id <= 0xFFFF) { if(id >= 0x8000 && id <= 0xFFFF) {
// TODO // TODO
throw new UnsupportedOperationException("Not yet implemented for id " + id); System.err.println("Not yet implemented for id " + id);
break;
} }
// Now read in the value(s) // Now read in the value(s)
@ -128,11 +129,10 @@ public class MAPIAttribute {
// Data is always padded out to a 4 byte boundary // Data is always padded out to a 4 byte boundary
if(len % 4 != 0) { if(len % 4 != 0) {
byte[] padding = new byte[len % 4]; byte[] padding = new byte[4 - (len % 4)];
IOUtils.readFully(inp, padding); IOUtils.readFully(inp, padding);
} }
} }
break;
} }
// All done // All done

View File

@ -37,15 +37,24 @@ public final class HMEFDumper {
throw new IllegalArgumentException("Filename must be given"); throw new IllegalArgumentException("Filename must be given");
} }
for(String filename : args) { boolean truncatePropData = true;
for(int i=0; i<args.length; i++) {
if(args[i].equalsIgnoreCase("--full")) {
truncatePropData = false;
continue;
}
HMEFDumper dumper = new HMEFDumper( HMEFDumper dumper = new HMEFDumper(
new FileInputStream(filename) new FileInputStream(args[i])
); );
dumper.setTruncatePropertyData(truncatePropData);
dumper.dump(); dumper.dump();
} }
} }
private InputStream inp; private InputStream inp;
private boolean truncatePropertyData;
public HMEFDumper(InputStream inp) throws IOException { public HMEFDumper(InputStream inp) throws IOException {
this.inp = inp; this.inp = inp;
@ -63,6 +72,10 @@ public final class HMEFDumper {
LittleEndian.readUShort(inp); LittleEndian.readUShort(inp);
} }
public void setTruncatePropertyData(boolean truncate) {
truncatePropertyData = truncate;
}
private void dump() throws IOException { private void dump() throws IOException {
int level; int level;
@ -86,7 +99,11 @@ public final class HMEFDumper {
String indent = " "; String indent = " ";
System.out.println(indent + "Data of length " + attr.getData().length); System.out.println(indent + "Data of length " + attr.getData().length);
if(attr.getData().length > 0) { if(attr.getData().length > 0) {
int len = Math.min( attr.getData().length, 48 ); int len = attr.getData().length;
if(truncatePropertyData) {
len = Math.min( attr.getData().length, 48 );
}
int loops = len/16; int loops = len/16;
if(loops == 0) loops = 1; if(loops == 0) loops = 1;