]> source.dussan.org Git - poi.git/commitdiff
Few little tweaks to dev helpers
authorNick Burch <nick@apache.org>
Sun, 17 Aug 2008 16:36:40 +0000 (16:36 +0000)
committerNick Burch <nick@apache.org>
Sun, 17 Aug 2008 16:36:40 +0000 (16:36 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@686621 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/dev/POIFSLister.java
src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java

index c9fa349d6609d5bc55de51aee9292b0954b6b321..cdd9902c40ff3f675f9a44e37eaccb21821611be 100644 (file)
@@ -45,37 +45,54 @@ public class POIFSLister {
             System.exit(1);
         }
 
-        for (int j = 0; j < args.length; j++)
-        {
-            viewFile(args[ j ]);
+        boolean withSizes = false;
+        for (int j = 0; j < args.length; j++) {
+               if(args[j].equalsIgnoreCase("-size") || 
+                               args[j].equalsIgnoreCase("-sizes")) {
+                       withSizes = true;
+               } else {
+                       viewFile(args[j], withSizes);
+               }
         }
     }
 
-    public static void viewFile(final String filename) throws IOException
+    public static void viewFile(final String filename, boolean withSizes) throws IOException
     {
        POIFSFileSystem fs = new POIFSFileSystem(
                        new FileInputStream(filename)
        );
-       displayDirectory(fs.getRoot(), "");
+       displayDirectory(fs.getRoot(), "", withSizes);
     }
     
-    public static void displayDirectory(DirectoryNode dir, String indent) {
+    public static void displayDirectory(DirectoryNode dir, String indent, boolean withSizes) {
        System.out.println(indent + dir.getName() + " -");
        String newIndent = indent + "  ";
        
+       boolean hadChildren = false;
        for(Iterator it = dir.getEntries(); it.hasNext(); ) {
+               hadChildren = true;
                Object entry = it.next();
                if(entry instanceof DirectoryNode) {
-                       displayDirectory((DirectoryNode)entry, newIndent);
+                       displayDirectory((DirectoryNode)entry, newIndent, withSizes);
                } else {
                        DocumentNode doc = (DocumentNode)entry;
                        String name = doc.getName();
+                       String size = "";
                        if(name.charAt(0) < 10) {
                                String altname = "(0x0" + (int)name.charAt(0) + ")" + name.substring(1);
                                name = name.substring(1) + " <" + altname + ">";
                        }
-                       System.out.println(newIndent + name);
+                       if(withSizes) {
+                               size = " [" +
+                                       doc.getSize() + " / 0x" +
+                                       Integer.toHexString(doc.getSize()) +
+                                       "]";
+                       }
+                       System.out.println(newIndent + name + size);
                }
        }
+       if(!hadChildren) {
+               System.out.println(newIndent + "(no children)");
+       }
     }
 }
\ No newline at end of file
index fde628261f8156a09de12fb3a4f9e8d918220bd0..7f1dade1439e8e25ddb288df49b055511ce1c1cf 100644 (file)
@@ -66,12 +66,12 @@ public class HPBFDumper {
                dump.dumpContents();
                dump.dumpEnvelope();
                dump.dumpEscher();
+               dump.dump001CompObj(dump.fs.getRoot());
+               dump.dumpQuill();
                
                // Still to go:
                //  (0x03)Internal
-               //  (0x01)CompObj
                //  Objects
-               //  Quill
        }
        
        /**
@@ -126,5 +126,55 @@ public class HPBFDumper {
                
                System.out.println("");
                System.out.println("Contents - " + data.length + " bytes long:");
+               
+               // 8 bytes, always seems to be
+               // E8 AC 2C 00 E8 03 05 01 
+               // E8 AC 2C 00 E8 03 05 01  
+               
+               // 4 bytes - size of contents
+               // 13/15 00 00 01
+               
+               // ....
+               
+           // E8 03 08 08 0C 20 03 00 00 00 00 88 16 00 00 00 ..... ..........
+               
+           // 01 18 27 00 03 20 00 00 E8 03 08 08 0C 20 03 00 ..'.. ....... ..
+               
+               // 01 18 30 00 03 20 00 00 
+               // E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
+               // 00 00 00 88 1E 00 00 00
+               
+               // 01 18 31 00 03 20 00 00
+               // E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
+               // 00 00 00 88 1E 00 00 00
+               
+               // 01 18 32 00 03 20 00 00
+               // E8 03 06 08 07 08 08 08 09 10 01 00 0C 20 04 00
+               // 00 00 00 88 1E 00 00 00
+       }
+       
+       public void dumpCONTENTS(DirectoryNode dir) throws IOException {
+               byte[] data = getData(dir, "CONTENTS");
+               
+               System.out.println("");
+               System.out.println("CONTENTS - " + data.length + " bytes long:");
+               
+               // Dump out up to 0x200
+               
+               // Text from 0x200 onwards for a bit
+       }
+       
+       protected void dump001CompObj(DirectoryNode dir) {
+               // TODO
+       }
+       
+       public void dumpQuill() throws IOException {
+               DirectoryNode quillDir = (DirectoryNode) 
+                       fs.getRoot().getEntry("Quill");
+               DirectoryNode quillSubDir = (DirectoryNode) 
+                       quillDir.getEntry("QuillSub");
+
+               dump001CompObj(quillSubDir);
+               dumpCONTENTS(quillSubDir);
        }
 }