A bit more towards matching properties to chunks

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1442388 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2013-02-04 21:46:30 +00:00
parent 000620ac52
commit b68b2068d4
2 changed files with 37 additions and 1 deletions

View File

@ -1058,6 +1058,15 @@ public class MAPIProperty {
attributes.put(id, this);
}
}
public String asFileName() {
String str = Integer.toHexString(id).toUpperCase();
while(str.length() < 4) {
str = "0" + str;
}
return str + usualType.asFileEnding();
}
public String toString() {
StringBuffer str = new StringBuffer();
str.append(name);

View File

@ -28,6 +28,7 @@ import java.util.Map;
import org.apache.poi.hsmf.datatypes.PropertyValue.LongLongPropertyValue;
import org.apache.poi.hsmf.datatypes.PropertyValue.TimePropertyValue;
import org.apache.poi.hsmf.datatypes.Types.MAPIType;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndian.BufferUnderrunException;
@ -103,7 +104,33 @@ public abstract class PropertiesChunk extends Chunk {
* up the Chunks in it with our Variable Sized Properties.
*/
protected void matchVariableSizedPropertiesToChunks() {
// TODO
// Index the Parent Group chunks for easy lookup
// TODO Is this the right way?
Map<Integer,Chunk> chunks = new HashMap<Integer, Chunk>();
for (Chunk chunk : parentGroup.getChunks()) {
chunks.put(chunk.chunkId, chunk);
}
// Loop over our values, looking for chunk based ones
for (List<PropertyValue> vals : properties.values()) {
if (vals != null) {
for (PropertyValue val : vals) {
if (val instanceof ChunkBasedPropertyValue) {
ChunkBasedPropertyValue cVal = (ChunkBasedPropertyValue)val;
Chunk chunk = chunks.get(cVal.getProperty().id);
//System.err.println(cVal + " -> " + HexDump.toHex(cVal.data));
// TODO Make sense of the raw offset value
if (chunk != null) {
cVal.setValue(chunk);
} else {
logger.log(POILogger.WARN, "No chunk found matching Property " + cVal);
}
}
}
}
}
}
protected void readProperties(InputStream value) throws IOException {