Author: nick
Date: Fri Feb 22 03:40:00 2008
New Revision: 630164

URL: http://svn.apache.org/viewvc?rev=630164&view=rev
Log:
Bug #44471 - Crystal Reports generates files with short StyleRecords, which 
isn't allowed in the spec. Work around this

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/record/StyleRecord.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=630164&r1=630163&r2=630164&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Feb 22 03:40:00 
2008
@@ -36,6 +36,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <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="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>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=630164&r1=630163&r2=630164&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Feb 22 03:40:00 
2008
@@ -33,6 +33,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <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="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>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java?rev=630164&r1=630163&r2=630164&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java Fri Feb 22 
03:40:00 2008
@@ -88,13 +88,18 @@
         else if (getType() == STYLE_USER_DEFINED)
         {
             field_2_name_length = in.readShort();
-            field_3_string_options = in.readByte();
             
-            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);
+            // Some files from Crystal Reports lack
+            //  the remaining fields, which is naughty
+            if(in.remaining() > 0) {
+                   field_3_string_options = in.readByte();
+                   
+                   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);
+                   }
             }
         }
 

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=630164&r1=630163&r2=630164&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 Fri Feb 
22 03:40:00 2008
@@ -1091,17 +1091,14 @@
     }
     
     /**
-     * Date: Tue, 19 Feb 2008 05:03:47 -0800 (PST)
-     * From: Setya <[EMAIL PROTECTED]>
-     * Subject: Exception when parsing excel file
+     * Crystal reports generates files with short 
+     *  StyleRecords, which is against the spec
      */
-    public void BROKENtest20080219() throws Exception {
+    public void test44471() throws Exception {
         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
-        // However, our code matches the latest Microsoft
-        //  docs, so no idea what's wrong
         HSSFWorkbook wb = new HSSFWorkbook(in);
         in.close();
         



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to