From b68b2068d45f9c1117e378f9f228193ff43fd976 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 4 Feb 2013 21:46:30 +0000 Subject: [PATCH] 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 --- .../poi/hsmf/datatypes/MAPIProperty.java | 9 ++++++ .../poi/hsmf/datatypes/PropertiesChunk.java | 29 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java index a5ee6cdca..20a8a0a2d 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java @@ -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); diff --git a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java index 78034fec9..6e1b12bdf 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java @@ -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 chunks = new HashMap(); + for (Chunk chunk : parentGroup.getChunks()) { + chunks.put(chunk.chunkId, chunk); + } + + // Loop over our values, looking for chunk based ones + for (List 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 {