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/24 17:08:01 UTC
svn commit: r757873 - in /poi/trunk/src: documentation/content/xdocs/
java/org/apache/poi/hssf/ java/org/apache/poi/hssf/usermodel/
java/org/apache/poi/poifs/storage/ testcases/org/apache/poi/hssf/usermodel/
Author: nick
Date: Tue Mar 24 16:07:49 2009
New Revision: 757873
URL: http://svn.apache.org/viewvc?rev=757873&view=rev
Log:
Fix bug #46904, for old biff5/biff7 files where the block chain is terminated incorrectly
Added:
poi/trunk/src/java/org/apache/poi/hssf/OldExcelFormatException.java (with props)
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
poi/trunk/src/java/org/apache/poi/poifs/storage/BlockAllocationTableReader.java
poi/trunk/src/java/org/apache/poi/poifs/storage/BlockListImpl.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=757873&r1=757872&r2=757873&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Tue Mar 24 16:07:49 2009
@@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46904 - Fix POIFS issue with duplicate block 0 references on very old BIFF5/BIFF7 files</action>
<action dev="POI-DEVELOPERS" type="fix">46840 - PageSettingsBlock should include HEADERFOOTER record</action>
<action dev="POI-DEVELOPERS" type="fix">46885 - update cell type when setting cached formula result in XSSFCell</action>
<action dev="POI-DEVELOPERS" type="add">added modifiers for anchor type to XSSFClientAnchor</action>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=757873&r1=757872&r2=757873&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Mar 24 16:07:49 2009
@@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46904 - Fix POIFS issue with duplicate block 0 references on very old BIFF5/BIFF7 files</action>
<action dev="POI-DEVELOPERS" type="fix">46840 - PageSettingsBlock should include HEADERFOOTER record</action>
<action dev="POI-DEVELOPERS" type="fix">46885 - update cell type when setting cached formula result in XSSFCell</action>
<action dev="POI-DEVELOPERS" type="add">added modifiers for anchor type to XSSFClientAnchor</action>
Added: poi/trunk/src/java/org/apache/poi/hssf/OldExcelFormatException.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/OldExcelFormatException.java?rev=757873&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/OldExcelFormatException.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/OldExcelFormatException.java Tue Mar 24 16:07:49 2009
@@ -0,0 +1,23 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hssf;
+
+public class OldExcelFormatException extends IllegalArgumentException {
+ public OldExcelFormatException(String s) {
+ super(s);
+ }
+}
\ No newline at end of file
Propchange: poi/trunk/src/java/org/apache/poi/hssf/OldExcelFormatException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=757873&r1=757872&r2=757873&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Tue Mar 24 16:07:49 2009
@@ -34,6 +34,7 @@
import org.apache.poi.ddf.EscherBitmapBlip;
import org.apache.poi.ddf.EscherBlipRecord;
import org.apache.poi.ddf.EscherRecord;
+import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.model.HSSFFormulaParser;
import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.model.Sheet;
@@ -227,7 +228,7 @@
// check for previous version of file format
try {
directory.getEntry("Book");
- throw new IllegalArgumentException("The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. "
+ throw new OldExcelFormatException("The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. "
+ "POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)");
} catch (FileNotFoundException e) {
// fall through
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=757873&r1=757872&r2=757873&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 Tue Mar 24 16:07:49 2009
@@ -200,6 +200,10 @@
// 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) {
+ // 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)");
+ currentBlock = POIFSConstants.END_OF_CHAIN;
} else {
// Ripple up
throw e;
Modified: poi/trunk/src/java/org/apache/poi/poifs/storage/BlockListImpl.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/storage/BlockListImpl.java?rev=757873&r1=757872&r2=757873&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/storage/BlockListImpl.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/storage/BlockListImpl.java Tue Mar 24 16:07:49 2009
@@ -72,6 +72,14 @@
_blocks[ index ] = null;
}
}
+
+ /**
+ * Unit testing method. Gets, without sanity checks or
+ * removing.
+ */
+ protected ListManagedBlock get(final int index) throws IOException {
+ return _blocks[index];
+ }
/**
* remove and return the specified block from the list
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=757873&r1=757872&r2=757873&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Mar 24 16:07:49 2009
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.OldExcelFormatException;
import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.CellValueRecordInterface;
import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
@@ -1669,8 +1670,16 @@
/**
* java.io.IOException: block[ 0 ] already removed
+ * (is an excel 95 file though)
*/
- public void BROKENtest46904() throws IOException {
- HSSFWorkbook wb = openSample("46904.xls");
+ public void test46904() throws IOException {
+ try {
+ HSSFWorkbook wb = openSample("46904.xls");
+ fail();
+ } catch(OldExcelFormatException e) {
+ assertTrue(e.getMessage().startsWith(
+ "The supplied spreadsheet seems to be Excel"
+ ));
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org