<!-- Don't forget to update status.xml too! -->
<release version="3.1-beta1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">44593 - Improved handling of short DVRecords</actions>
<action dev="POI-DEVELOPERS" type="add">28627 / 44580 - Fix Range.delete() in HWPF</action>
<action dev="POI-DEVELOPERS" type="add">44539 - Support for area references in formulas of rows >= 32768</action>
<action dev="POI-DEVELOPERS" type="add">44536 - Improved support for detecting read-only recommended files</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1-beta1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="add">44593 - Improved handling of short DVRecords</actions>
<action dev="POI-DEVELOPERS" type="add">28627 / 44580 - Fix Range.delete() in HWPF</action>
<action dev="POI-DEVELOPERS" type="add">44539 - Support for area references in formulas of rows >= 32768</action>
<action dev="POI-DEVELOPERS" type="add">44536 - Improved support for detecting read-only recommended files</action>
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
import java.util.ArrayList;
/**
public class HSSFCellRangeAddress
{
+ private static POILogger logger = POILogFactory.getLogger(HSSFCellRangeAddress.class);
+
/**
* Number of following ADDR structures
*/
{
short first_row = in.readShort();
short first_col = in.readShort();
- short last_row = in.readShort();
- short last_col = in.readShort();
+
+ short last_row = first_row;
+ short last_col = first_col;
+ if(in.remaining() >= 4) {
+ last_row = in.readShort();
+ last_col = in.readShort();
+ } else {
+ // Ran out of data
+ // For now, issue a warning, finish, and
+ // hope for the best....
+ logger.log(POILogger.WARN, "Ran out of data reading cell references for DVRecord");
+ k = this.field_addr_number;
+ }
AddrStructure region = new AddrStructure(first_row, first_col, last_row, last_col);
this.field_regions_list.add(region);
in.close();
assertFalse(wb.isWriteProtected());
}
+
+ /**
+ * Some files were having problems with the DVRecord,
+ * probably due to dropdowns
+ */
+ public void test44593() throws Exception {
+ FileInputStream in = new FileInputStream(new File(cwd, "Bug44593.xls"));
+
+ // Used to blow up with an IllegalArgumentException
+ // when creating a DVRecord
+ // Now won't, but no idea if this means we have
+ // rubbish in the DVRecord or not...
+ HSSFWorkbook wb = new HSSFWorkbook(in);
+ in.close();
+
+ assertEquals(2, wb.getNumberOfSheets());
+ }
}