mirror of https://github.com/apache/poi.git
fixed bug #45889:rrayIndexOutOfBoundsException when constructing HSLF Table with a single row
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@701302 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3d3c4958d2
commit
301a0f834c
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -53,6 +53,9 @@ public class Table extends ShapeGroup {
|
|||
public Table(int numrows, int numcols) {
|
||||
super();
|
||||
|
||||
if(numrows < 1) throw new IllegalArgumentException("The number of rows must be greater than 1");
|
||||
if(numcols < 1) throw new IllegalArgumentException("The number of columns must be greater than 1");
|
||||
|
||||
int x=0, y=0, tblWidth=0, tblHeight=0;
|
||||
cells = new TableCell[numrows][numcols];
|
||||
for (int i = 0; i < cells.length; i++) {
|
||||
|
@ -165,11 +168,11 @@ public class Table extends ShapeGroup {
|
|||
Rectangle anchor = sh[i].getAnchor();
|
||||
if(anchor.y != y0){
|
||||
y0 = anchor.y;
|
||||
if(row != null) maxrowlen = Math.max(maxrowlen, row.size());
|
||||
row = new ArrayList();
|
||||
lst.add(row);
|
||||
}
|
||||
row.add(sh[i]);
|
||||
maxrowlen = Math.max(maxrowlen, row.size());
|
||||
}
|
||||
}
|
||||
cells = new TableCell[lst.size()][maxrowlen];
|
||||
|
|
|
@ -60,4 +60,40 @@ public class TestTable extends TestCase {
|
|||
assertEquals(tbl.getNumberOfRows(), tbl3.getNumberOfRows());
|
||||
}
|
||||
|
||||
/**
|
||||
* Error constructing Table when rownum=1
|
||||
*/
|
||||
public void test45889(){
|
||||
SlideShow ppt = new SlideShow();
|
||||
Slide slide = ppt.createSlide();
|
||||
Shape[] shapes;
|
||||
Table tbl1 = new Table(1, 5);
|
||||
assertEquals(5, tbl1.getNumberOfColumns());
|
||||
assertEquals(1, tbl1.getNumberOfRows());
|
||||
slide.addShape(tbl1);
|
||||
|
||||
shapes = slide.getShapes();
|
||||
assertEquals(1, shapes.length);
|
||||
|
||||
Table tbl2 = (Table)shapes[0];
|
||||
assertSame(tbl1.getSpContainer(), tbl2.getSpContainer());
|
||||
|
||||
assertEquals(tbl1.getNumberOfColumns(), tbl2.getNumberOfColumns());
|
||||
assertEquals(tbl1.getNumberOfRows(), tbl2.getNumberOfRows());
|
||||
}
|
||||
|
||||
public void testIllegalCOnstruction(){
|
||||
try {
|
||||
Table tbl = new Table(0, 5);
|
||||
fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
|
||||
} catch (IllegalArgumentException e){
|
||||
|
||||
}
|
||||
try {
|
||||
Table tbl = new Table(5, 0);
|
||||
fail("Table(rownum, colnum) must throw IllegalArgumentException if any of tghe arguments is less than 1");
|
||||
} catch (IllegalArgumentException e){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue