]> source.dussan.org Git - poi.git/commitdiff
Partial fix for bug 45358 - parsing area refs with rows above 32767
authorJosh Micich <josh@apache.org>
Sun, 31 Aug 2008 19:44:11 +0000 (19:44 +0000)
committerJosh Micich <josh@apache.org>
Sun, 31 Aug 2008 19:44:11 +0000 (19:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@690772 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java

index 1ccebd0a72c8e1f31578fbfd8a1fdbd47240b356..9d2eeac1e0f6344c6af2e0ff4b43437ad18e3a62 100644 (file)
@@ -235,29 +235,20 @@ public final class Area3DPtg extends OperandPtg implements AreaI {
                field_5_last_column = colRelative.setBoolean( field_5_last_column, rel );
        }
 
-
-       /*public String getArea(){
-               RangeAddress ra = new RangeAddress( getFirstColumn(),getFirstRow() + 1, getLastColumn(), getLastRow() + 1);
-               String result = ra.getAddress();
-
-               return result;
-       }*/
-
-       public void setArea( String ref )
-       {
+       public void setArea( String ref ) {
                AreaReference ar = new AreaReference( ref );
                
                CellReference frstCell = ar.getFirstCell();
                CellReference lastCell = ar.getLastCell();
 
-               setFirstRow(    (short) frstCell.getRow() );
-               setFirstColumn(          frstCell.getCol() );
-               setLastRow(      (short) lastCell.getRow() );
-               setLastColumn(            lastCell.getCol() );
-               setFirstColRelative( !frstCell.isColAbsolute() );
-               setLastColRelative(  !lastCell.isColAbsolute() );
-               setFirstRowRelative( !frstCell.isRowAbsolute() );
-               setLastRowRelative(  !lastCell.isRowAbsolute() );
+               setFirstRow(frstCell.getRow());
+               setFirstColumn(frstCell.getCol());
+               setLastRow(lastCell.getRow());
+               setLastColumn(lastCell.getCol());
+               setFirstColRelative(!frstCell.isColAbsolute());
+               setLastColRelative(!lastCell.isColAbsolute());
+               setFirstRowRelative(!frstCell.isRowAbsolute());
+               setLastRowRelative(!lastCell.isRowAbsolute());
        }
 
        /**
index 3584e37ea4e41f0c1ac230857ad3a34976f4c539..c9fea7f1e44407b03f4a73c9360ea4333b9336bc 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.model.FormulaParser.FormulaParseException;
 import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
 import org.apache.poi.hssf.record.formula.AddPtg;
+import org.apache.poi.hssf.record.formula.AreaI;
 import org.apache.poi.hssf.record.formula.AreaPtg;
 import org.apache.poi.hssf.record.formula.AttrPtg;
 import org.apache.poi.hssf.record.formula.BoolPtg;
@@ -836,4 +837,29 @@ public final class TestFormulaParser extends TestCase {
                }
                cell.setCellFormula("count(fp1)"); // plain cell ref, col is in range
        }
-}
+       
+       public void testParseAreaRefHighRow_bug45358() {
+               Ptg[] ptgs;
+               AreaI aptg;
+               
+               HSSFWorkbook book = new HSSFWorkbook();
+               book.createSheet("Sheet1");
+               
+               ptgs = FormulaParser.parse("Sheet1!A10:A40000", book);
+               aptg = (AreaI) ptgs[0];
+               if (aptg.getLastRow() == -25537) {
+                       throw new AssertionFailedError("Identified bug 45358");
+               }
+               assertEquals(39999, aptg.getLastRow());
+               
+               ptgs = FormulaParser.parse("Sheet1!A10:A65536", book);
+               aptg = (AreaI) ptgs[0];
+               assertEquals(65535, aptg.getLastRow());
+               
+               // plain area refs should be ok too
+               ptgs = parseFormula("A10:A65536");
+               aptg = (AreaI) ptgs[0];
+               assertEquals(65535, aptg.getLastRow());
+               
+       }
+}
\ No newline at end of file