Bug #44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@630164 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2008-02-22 11:40:00 +00:00
parent 7cdfaaa61d
commit d601a0b4b7
4 changed files with 17 additions and 13 deletions

View File

@ -36,6 +36,7 @@
<!-- Don't forget to update status.xml too! --> <!-- Don't forget to update status.xml too! -->
<release version="3.1-beta1" date="2008-??-??"> <release version="3.1-beta1" date="2008-??-??">
<action dev="POI-DEVELOPERS" type="fix">44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this</action>
<action dev="POI-DEVELOPERS" type="add">44450 - Support for Lookup, HLookup and VLookup functions</action> <action dev="POI-DEVELOPERS" type="add">44450 - Support for Lookup, HLookup and VLookup functions</action>
<action dev="POI-DEVELOPERS" type="fix">44449 - Avoid getting confused when two sheets have shared formulas for the same areas, and when the shared formula is set incorrectly</action> <action dev="POI-DEVELOPERS" type="fix">44449 - Avoid getting confused when two sheets have shared formulas for the same areas, and when the shared formula is set incorrectly</action>
<action dev="POI-DEVELOPERS" type="fix">44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied</action> <action dev="POI-DEVELOPERS" type="fix">44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied</action>

View File

@ -33,6 +33,7 @@
<!-- Don't forget to update changes.xml too! --> <!-- Don't forget to update changes.xml too! -->
<changes> <changes>
<release version="3.1-beta1" date="2008-??-??"> <release version="3.1-beta1" date="2008-??-??">
<action dev="POI-DEVELOPERS" type="fix">44471 - Crystal Reports generates files with short StyleRecords, which isn't allowed in the spec. Work around this</action>
<action dev="POI-DEVELOPERS" type="add">44450 - Support for Lookup, HLookup and VLookup functions</action> <action dev="POI-DEVELOPERS" type="add">44450 - Support for Lookup, HLookup and VLookup functions</action>
<action dev="POI-DEVELOPERS" type="fix">44449 - Avoid getting confused when two sheets have shared formulas for the same areas, and when the shared formula is set incorrectly</action> <action dev="POI-DEVELOPERS" type="fix">44449 - Avoid getting confused when two sheets have shared formulas for the same areas, and when the shared formula is set incorrectly</action>
<action dev="POI-DEVELOPERS" type="fix">44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied</action> <action dev="POI-DEVELOPERS" type="fix">44366 - InputStreams passed to POIFSFileSystem are now automatically closed. A warning is generated for people who might've relied on them not being closed before, and a wrapper to restore the old behaviour is supplied</action>

View File

@ -88,13 +88,18 @@ public class StyleRecord
else if (getType() == STYLE_USER_DEFINED) else if (getType() == STYLE_USER_DEFINED)
{ {
field_2_name_length = in.readShort(); field_2_name_length = in.readShort();
field_3_string_options = in.readByte();
byte[] string = in.readRemainder(); // Some files from Crystal Reports lack
if (fHighByte.isSet(field_3_string_options)) { // the remaining fields, which is naughty
field_4_name= StringUtil.getFromUnicodeBE(string, 0, field_2_name_length); if(in.remaining() > 0) {
}else { field_3_string_options = in.readByte();
field_4_name=StringUtil.getFromCompressedUnicode(string, 0, field_2_name_length);
byte[] string = in.readRemainder();
if (fHighByte.isSet(field_3_string_options)) {
field_4_name= StringUtil.getFromUnicodeBE(string, 0, field_2_name_length);
} else {
field_4_name=StringUtil.getFromCompressedUnicode(string, 0, field_2_name_length);
}
} }
} }

View File

@ -1091,17 +1091,14 @@ extends TestCase {
} }
/** /**
* Date: Tue, 19 Feb 2008 05:03:47 -0800 (PST) * Crystal reports generates files with short
* From: Setya <jsetya@gmail.com> * StyleRecords, which is against the spec
* Subject: Exception when parsing excel file
*/ */
public void BROKENtest20080219() throws Exception { public void test44471() throws Exception {
FileInputStream in = new FileInputStream(new File(cwd, "OddStyleRecord.xls")); FileInputStream in = new FileInputStream(new File(cwd, "OddStyleRecord.xls"));
// Blows up with an ArrayIndexOutOfBounds // Used to blow up with an ArrayIndexOutOfBounds
// when creating a StyleRecord // when creating a StyleRecord
// However, our code matches the latest Microsoft
// docs, so no idea what's wrong
HSSFWorkbook wb = new HSSFWorkbook(in); HSSFWorkbook wb = new HSSFWorkbook(in);
in.close(); in.close();