poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r686621 - in /poi/trunk/src: java/org/apache/poi/poifs/dev/POIFSLister.java scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java
Date Sun, 17 Aug 2008 16:36:41 GMT
Author: nick
Date: Sun Aug 17 09:36:40 2008
New Revision: 686621

URL: http://svn.apache.org/viewvc?rev=686621&view=rev
Log:
Few little tweaks to dev helpers

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

Modified: poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSLister.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSLister.java?rev=686621&r1=686620&r2=686621&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSLister.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSLister.java Sun Aug 17 09:36:40 2008
@@ -45,37 +45,54 @@
             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

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java?rev=686621&r1=686620&r2=686621&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/dev/HPBFDumper.java Sun Aug 17 09:36:40
2008
@@ -66,12 +66,12 @@
 		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 @@
 		
 		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);
 	}
 }



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


Mime
View raw message