poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1058243 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hmef: MAPIAttribute.java dev/HMEFDumper.java
Date Wed, 12 Jan 2011 17:22:41 GMT
Author: nick
Date: Wed Jan 12 17:22:40 2011
New Revision: 1058243

URL: http://svn.apache.org/viewvc?rev=1058243&view=rev
Log:
HMEF dumping and properties tweaks

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hmef/MAPIAttribute.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hmef/dev/HMEFDumper.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hmef/MAPIAttribute.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hmef/MAPIAttribute.java?rev=1058243&r1=1058242&r2=1058243&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hmef/MAPIAttribute.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hmef/MAPIAttribute.java Wed Jan 12 17:22:40
2011
@@ -104,7 +104,8 @@ public class MAPIAttribute {
          MAPIProperty prop = MAPIProperty.get(id);
          if(id >= 0x8000 && id <= 0xFFFF) {
             // 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)
@@ -128,11 +129,10 @@ public class MAPIAttribute {
             
             // Data is always padded out to a 4 byte boundary
             if(len % 4 != 0) {
-               byte[] padding = new byte[len % 4];
+               byte[] padding = new byte[4 - (len % 4)];
                IOUtils.readFully(inp, padding);
             }
          }
-         break;
       }
       
       // All done

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hmef/dev/HMEFDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hmef/dev/HMEFDumper.java?rev=1058243&r1=1058242&r2=1058243&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hmef/dev/HMEFDumper.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hmef/dev/HMEFDumper.java Wed Jan 12 17:22:40
2011
@@ -37,15 +37,24 @@ public final class HMEFDumper {
          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(
-               new FileInputStream(filename)
+               new FileInputStream(args[i])
          );
+         dumper.setTruncatePropertyData(truncatePropData);
          dumper.dump();
       }
    }
    
    private InputStream inp;
+   private boolean truncatePropertyData;
+   
    public HMEFDumper(InputStream inp) throws IOException {
       this.inp = inp;
       
@@ -63,6 +72,10 @@ public final class HMEFDumper {
       LittleEndian.readUShort(inp);
    }
    
+   public void setTruncatePropertyData(boolean truncate) {
+      truncatePropertyData = truncate;
+   }
+   
    private void dump() throws IOException {
       int level;
       
@@ -86,7 +99,11 @@ public final class HMEFDumper {
          String indent = "  ";
          System.out.println(indent + "Data of length " + attr.getData().length);
          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;
             if(loops == 0) loops = 1;
             



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message