]> source.dussan.org Git - poi.git/commitdiff
fixed bug #45889:rrayIndexOutOfBoundsException when constructing HSLF Table with...
authorYegor Kozlov <yegor@apache.org>
Fri, 3 Oct 2008 05:27:06 +0000 (05:27 +0000)
committerYegor Kozlov <yegor@apache.org>
Fri, 3 Oct 2008 05:27:06 +0000 (05:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@701302 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/scratchpad/src/org/apache/poi/hslf/model/Table.java
src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java

index 76d53e6287b4734cbc56cc4688951d8b2687c481..6430582668566d152b1391bb659380ad9791a353 100644 (file)
@@ -37,6 +37,8 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.2-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45889 - fixed ArrayIndexOutOfBoundsException when constructing HSLF Table with a single row </action>
+           <action dev="POI-DEVELOPERS" type="add">Initial support for creating hyperlinks in HSLF</action>
            <action dev="POI-DEVELOPERS" type="fix">45876 - fixed BoundSheetRecord to allow sheet names longer than 31 chars</action>
            <action dev="POI-DEVELOPERS" type="add">45890 - fixed HSSFSheet.shiftRows to also update conditional formats</action>
            <action dev="POI-DEVELOPERS" type="add">45865 modified Formula Parser/Evaluator to handle cross-worksheet formulas</action>
index 34a3bc3271f0d96ee69286ee2fe8ec76b2914f63..c998f61de9c679c2888413308637864ca8eb8b60 100644 (file)
@@ -34,6 +34,8 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.2-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45889 - fixed ArrayIndexOutOfBoundsException when constructing HSLF Table with a single row </action>
+           <action dev="POI-DEVELOPERS" type="add">Initial support for creating hyperlinks in HSLF</action>
            <action dev="POI-DEVELOPERS" type="fix">45876 - fixed BoundSheetRecord to allow sheet names longer than 31 chars</action>
            <action dev="POI-DEVELOPERS" type="add">45890 - fixed HSSFSheet.shiftRows to also update conditional formats</action>
            <action dev="POI-DEVELOPERS" type="add">45865 modified Formula Parser/Evaluator to handle cross-worksheet formulas</action>
index 113a2d8f2b05b460bbfb2e0eaf8c149bb066fd46..bd27969fafe3dbfc9ad4b68803f51f1a1b42885e 100755 (executable)
@@ -53,6 +53,9 @@ public class Table extends ShapeGroup {
     public Table(int numrows, int numcols) {\r
         super();\r
 \r
+        if(numrows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");\r
+        if(numcols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");\r
+\r
         int x=0, y=0, tblWidth=0, tblHeight=0;\r
         cells = new TableCell[numrows][numcols];\r
         for (int i = 0; i < cells.length; i++) {\r
@@ -165,11 +168,11 @@ public class Table extends ShapeGroup {
                 Rectangle anchor = sh[i].getAnchor();\r
                 if(anchor.y != y0){\r
                     y0 = anchor.y;\r
-                    if(row != null) maxrowlen = Math.max(maxrowlen, row.size());\r
                     row = new ArrayList();\r
                     lst.add(row);\r
                 }\r
                 row.add(sh[i]);\r
+                maxrowlen = Math.max(maxrowlen, row.size());\r
             }\r
         }\r
         cells = new TableCell[lst.size()][maxrowlen];\r
index fff6482eccf4b74fdbbd25d71060fb4b628ddb1c..7202ff345fe76a67afdbce372769cf7bff22f82a 100755 (executable)
@@ -60,4 +60,40 @@ public class TestTable extends TestCase {
         assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());\r
     }\r
 \r
+    /**\r
+     * Error constructing Table when rownum=1\r
+     */\r
+    public void test45889(){\r
+        SlideShow ppt = new SlideShow();\r
+        Slide slide = ppt.createSlide();\r
+        Shape[] shapes;\r
+        Table tbl1 = new Table(1, 5);\r
+        assertEquals(5, tbl1.getNumberOfColumns());\r
+        assertEquals(1, tbl1.getNumberOfRows());\r
+        slide.addShape(tbl1);\r
+\r
+        shapes = slide.getShapes();\r
+        assertEquals(1, shapes.length);\r
+\r
+        Table tbl2 = (Table)shapes[0];\r
+        assertSame(tbl1.getSpContainer(), tbl2.getSpContainer());\r
+\r
+        assertEquals(tbl1.getNumberOfColumns(), tbl2.getNumberOfColumns());\r
+        assertEquals(tbl1.getNumberOfRows(), tbl2.getNumberOfRows());\r
+    }\r
+\r
+    public void testIllegalCOnstruction(){\r
+        try {\r
+            Table tbl = new Table(0, 5);\r
+            fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");\r
+        } catch (IllegalArgumentException e){\r
+\r
+        }\r
+        try {\r
+            Table tbl = new Table(5, 0);\r
+            fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");\r
+        } catch (IllegalArgumentException e){\r
+\r
+        }\r
+    }\r
 }\r