You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2009/03/25 18:22:15 UTC

svn commit: r758353 - in /poi/trunk/src: java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java

Author: nick
Date: Wed Mar 25 17:22:06 2009
New Revision: 758353

URL: http://svn.apache.org/viewvc?rev=758353&view=rev
Log:
Fix the block allocation test, but still leave the recent blocks hssf bug fixed

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java
    poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java?rev=758353&r1=758352&r2=758353&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java Wed Mar 25 17:22:06 2009
@@ -186,6 +186,7 @@
         List blocks       = new ArrayList();
         int  currentBlock = startBlock;
         boolean firstPass = true;
+        ListManagedBlock dataBlock = null;
         
         // Process the chain from the start to the end
         // Normally we have header, data, end
@@ -193,16 +194,21 @@
         // For those cases, stop at the header, not the end
         while (currentBlock != POIFSConstants.END_OF_CHAIN) {
         	try {
-        		blocks.add(blockList.remove(currentBlock));
+        		// Grab the data at the current block offset
+        		dataBlock = blockList.remove(currentBlock);
+        		blocks.add(dataBlock);
+        		// Now figure out which block we go to next
                 currentBlock = _entries.get(currentBlock);
+                firstPass = false;
         	} catch(IOException e) {
         		if(currentBlock == headerPropertiesStartBlock) {
         			// Special case where things are in the wrong order
         			System.err.println("Warning, header block comes after data blocks in POIFS block listing");
         			currentBlock = POIFSConstants.END_OF_CHAIN;
-        		} else if(currentBlock == 0) {
+        		} else if(currentBlock == 0 && firstPass) {
         			// Special case where the termination isn't done right
-        			System.err.println("Warning, incorrectly terminated data blocks in POIFS block listing (should end at -2, ended at 0)");
+        			//  on an empty set
+        			System.err.println("Warning, incorrectly terminated empty data blocks in POIFS block listing (should end at -2, ended at 0)");
         			currentBlock = POIFSConstants.END_OF_CHAIN;
         		} else {
         			// Ripple up
@@ -212,7 +218,7 @@
         }
         
         return ( ListManagedBlock [] ) blocks
-            .toArray(new ListManagedBlock[ 0 ]);
+            .toArray(new ListManagedBlock[ blocks.size() ]);
     }
 
     // methods for debugging reader

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java?rev=758353&r1=758352&r2=758353&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java Wed Mar 25 17:22:06 2009
@@ -1329,7 +1329,7 @@
 
                 if (expected_length[ j ] == -1)
                 {
-                    fail("document " + j + " should have failed");
+                    fail("document " + j + " should have failed, but found a length of " + dataBlocks.length);
                 }
                 else
                 {



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