Author: ugo
Date: Mon Jan 21 01:56:56 2008
New Revision: 613822

URL: http://svn.apache.org/viewvc?rev=613822&view=rev
Log:
Merged revisions 613395-613401 via svnmerge from 
https://svn.apache.org/repos/asf/poi/trunk

........
  r613395 | yegor | 2008-01-19 15:27:02 +0100 (Sat, 19 Jan 2008) | 1 line
  
  use JDK 1.4 compatible constructor for IllegalStateException
........
  r613396 | yegor | 2008-01-19 15:28:10 +0100 (Sat, 19 Jan 2008) | 1 line
  
  add a check to prevent NPE in HSSFSheet.autoSizeColumn(). See Bug 44246
........
  r613400 | yegor | 2008-01-19 15:44:07 +0100 (Sat, 19 Jan 2008) | 1 line
  
  added unit tests for closed Bug 37684: Unhandled Continue Record Error
........
  r613401 | yegor | 2008-01-19 15:54:06 +0100 (Sat, 19 Jan 2008) | 1 line
  
  added a unit test for fixed bug 41139: Constructing HSSFWorkbook is 
failed,threw threw ArrayIndexOutOfBoundsException for creating UnknownRecord
........

Added:
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/37684-1.xls
      - copied unchanged from r613401, 
poi/trunk/src/testcases/org/apache/poi/hssf/data/37684-1.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/37684-2.xls
      - copied unchanged from r613401, 
poi/trunk/src/testcases/org/apache/poi/hssf/data/37684-2.xls
Modified:
    poi/branches/ooxml/   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DVRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 21 01:56:56 2008
@@ -1 +1 @@
-/poi/trunk:1-612483,612512,612520
+/poi/trunk:1-612483,612512,612520,613395-613401

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DVRecord.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DVRecord.java?rev=613822&r1=613821&r2=613822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DVRecord.java 
(original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DVRecord.java Mon 
Jan 21 01:56:56 2008
@@ -187,10 +187,13 @@
        this.field_not_used_2 = in.readShort();
 
        //read sec formula data condition
-       // Not sure if this was needed or not...
+       //Not sure if this was needed or not...
        try {
            in.skip(this.field_size_sec_formula);
-       } catch(IOException e) { throw new IllegalStateException(e); } 
+       } catch(IOException e) {
+           e.printStackTrace();
+           throw new IllegalStateException(e.getMessage());
+       }
 
        token_pos = 0;
        while (token_pos < this.field_size_sec_formula)

Modified: 
poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=613822&r1=613821&r2=613822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java 
(original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java 
Mon Jan 21 01:56:56 2008
@@ -1748,27 +1748,28 @@
                 } else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
                     sval = String.valueOf(cell.getBooleanCellValue());
                 }
+                if(sval != null) {
+                    String txt = sval + defaultChar;
+                    str = new AttributedString(txt);
+                    copyAttributes(font, str, 0, txt.length());
 
-                String txt = sval + defaultChar;
-                str = new AttributedString(txt);
-                copyAttributes(font, str, 0, txt.length());
-
-                layout = new TextLayout(str.getIterator(), frc);
-                if(style.getRotation() != 0){
-                    /*
-                     * Transform the text using a scale so that it's height is 
increased by a multiple of the leading,
-                     * and then rotate the text before computing the bounds. 
The scale results in some whitespace around
-                     * the unrotated top and bottom of the text that normally 
wouldn't be present if unscaled, but
-                     * is added by the standard Excel autosize.
-                     */
-                    AffineTransform trans = new AffineTransform();
-                    
trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
-                    trans.concatenate(
-                    AffineTransform.getScaleInstance(1, fontHeightMultiple)
-                    );
-                    width = Math.max(width, 
layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth);
-                } else {
-                    width = Math.max(width, layout.getBounds().getWidth() / 
defaultCharWidth);
+                    layout = new TextLayout(str.getIterator(), frc);
+                    if(style.getRotation() != 0){
+                        /*
+                         * Transform the text using a scale so that it's 
height is increased by a multiple of the leading,
+                         * and then rotate the text before computing the 
bounds. The scale results in some whitespace around
+                         * the unrotated top and bottom of the text that 
normally wouldn't be present if unscaled, but
+                         * is added by the standard Excel autosize.
+                         */
+                        AffineTransform trans = new AffineTransform();
+                        
trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
+                        trans.concatenate(
+                        AffineTransform.getScaleInstance(1, fontHeightMultiple)
+                        );
+                        width = Math.max(width, 
layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth);
+                    } else {
+                        width = Math.max(width, layout.getBounds().getWidth() 
/ defaultCharWidth);
+                    }
                 }
             }
 

Modified: 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls?rev=613822&r1=613821&r2=613822&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=613822&r1=613821&r2=613822&view=diff
==============================================================================
--- 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java 
(original)
+++ 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java 
Mon Jan 21 01:56:56 2008
@@ -954,6 +954,63 @@
         assertTrue("No Exceptions while reading file", true);
 
     }
+
+    /**
+     * Bug 37684  : Unhandled Continue Record Error
+     */
+    public void test37684 () throws Exception {
+        FileInputStream in = new FileInputStream(new File(cwd, "37684-1.xls"));
+        HSSFWorkbook wb = new HSSFWorkbook(in);
+        in.close();
+
+        assertTrue("No exceptions while reading workbook", true);
+
+        //serialize and read again
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        wb.write(out);
+        out.close();
+        assertTrue("No exceptions while saving workbook", true);
+
+        wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
+        assertTrue("No exceptions while reading saved stream", true);
+
+
+        in = new FileInputStream(new File(cwd, "37684-2.xls"));
+        wb = new HSSFWorkbook(in);
+        in.close();
+
+        assertTrue("No exceptions while reading workbook", true);
+
+        //serialize and read again
+        out = new ByteArrayOutputStream();
+        wb.write(out);
+        out.close();
+        assertTrue("No exceptions while saving workbook", true);
+
+        wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
+        assertTrue("No exceptions while reading saved stream", true);
+    }
+
+    /**
+     * Bug 41139: Constructing HSSFWorkbook is failed,threw threw 
ArrayIndexOutOfBoundsException for creating UnknownRecord
+     */
+    public void test41139() throws Exception {
+        FileInputStream in = new FileInputStream(new File(cwd, "41139.xls"));
+        HSSFWorkbook wb = new HSSFWorkbook(in);
+        in.close();
+
+        assertTrue("No Exceptions while reading file", true);
+
+        //serialize and read again
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        wb.write(out);
+        out.close();
+
+        wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
+        assertTrue("No Exceptions while reading file", true);
+
+    }
+
 }
 
 

Modified: 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
URL: 
http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java?rev=613822&r1=613821&r2=613822&view=diff
==============================================================================
--- 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
 (original)
+++ 
poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
 Mon Jan 21 01:56:56 2008
@@ -44,79 +44,13 @@
        protected String cwd = System.getProperty("HSSF.testdata.path");
        
         
-        /* ArrayIndexOutOfBound in BOFRecord */  
-        public void test28772() throws java.io.IOException {
-       String filename = System.getProperty("HSSF.testdata.path");
-       filename=filename+"/28772.xls";
-       FileInputStream in = new FileInputStream(filename);
-       HSSFWorkbook wb = new HSSFWorkbook(in);
-       assertTrue("Read book fine!" , true);
-   }
-        
-        /**
-            * Bug 37684: Unhandled Continue Record Error
-            * 
-            * BUT NOW(Jan07): It triggers bug 41026!!
-            * 
-            * java.lang.ArrayIndexOutOfBoundsException: 30
-         at 
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.rowHasCells(ValueRecordsAggregate.java:219)
-            */
-           public void test37684() throws Exception {
-               FileInputStream in = new FileInputStream(new File(cwd, 
"37684.xls"));
-               HSSFWorkbook wb = new HSSFWorkbook(in);
-               in.close();
 
-               HSSFSheet sheet = wb.getSheetAt( 0 );
-               assertNotNull(sheet);
-
-               assertTrue("No Exceptions while reading file", true);
-
-               //serialize and read again
-               ByteArrayOutputStream out = new ByteArrayOutputStream();
-               wb.write(out);
-               out.close();
-
-               wb = new HSSFWorkbook(new 
ByteArrayInputStream(out.toByteArray()));
-               assertTrue("No Exceptions while reading file", true);
-
-           }
-           
-           /**
-            * Bug 41139: Constructing HSSFWorkbook is failed,threw threw 
ArrayIndexOutOfBoundsException for creating UnknownRecord
-            * 
-            * BUT NOW (Jan07): It throws the following in write!!
-            * java.lang.RuntimeException: Coding Error: This method should 
never be called. This ptg should be converted
-         at 
org.apache.poi.hssf.record.formula.AreaNPtg.writeBytes(AreaNPtg.java:54)
-         at 
org.apache.poi.hssf.record.formula.Ptg.serializePtgStack(Ptg.java:384)
-         at 
org.apache.poi.hssf.record.NameRecord.serialize(NameRecord.java:544)
-         at org.apache.poi.hssf.model.Workbook.serialize(Workbook.java:757)
-         at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:952)
-         at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:898)
-
-            */
-           public void test41139() throws Exception {
-               FileInputStream in = new FileInputStream(new File(cwd, 
"41139.xls"));
-               HSSFWorkbook wb = new HSSFWorkbook(in);
-               in.close();
-
-               assertTrue("No Exceptions while reading file", true);
-
-               //serialize and read again
-               ByteArrayOutputStream out = new ByteArrayOutputStream();
-               wb.write(out);
-               out.close();
-
-               wb = new HSSFWorkbook(new 
ByteArrayInputStream(out.toByteArray()));
-               assertTrue("No Exceptions while reading file", true);
-
-           }
-           
-           public void test43493() throws Exception {
-               // Has crazy corrup subrecords on
-               //  a EmbeddedObjectRefSubRecord
-               File f = new File(cwd, "43493.xls");
-               HSSFWorkbook wb = new HSSFWorkbook(
-                               new FileInputStream(f)
-               );
-           }
+    public void test43493() throws Exception {
+        // Has crazy corrup subrecords on
+        //  a EmbeddedObjectRefSubRecord
+        File f = new File(cwd, "43493.xls");
+        HSSFWorkbook wb = new HSSFWorkbook(
+                new FileInputStream(f)
+        );
+    }
 }



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

Reply via email to