Author: nick
Date: Mon Feb  4 21:46:30 2013
New Revision: 1442388

URL: http://svn.apache.org/viewvc?rev=1442388&view=rev
Log:
A bit more towards matching properties to chunks

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java
    
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java?rev=1442388&r1=1442387&r2=1442388&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIProperty.java 
Mon Feb  4 21:46:30 2013
@@ -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);

Modified: 
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java?rev=1442388&r1=1442387&r2=1442388&view=diff
==============================================================================
--- 
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java 
(original)
+++ 
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/PropertiesChunk.java 
Mon Feb  4 21:46:30 2013
@@ -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 ex
     *  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 {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to