cvs commit: jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel TestHSSFSheet.java TestUnfixedBugs.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

cvs commit: jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel TestHSSFSheet.java TestUnfixedBugs.java

AviK-5
avik        2005/05/31 12:03:19

  Modified:    src/java/org/apache/poi/hssf/model Sheet.java
               src/java/org/apache/poi/hssf/record/aggregates
                        FormulaRecordAggregate.java
               src/testcases/org/apache/poi/hssf/usermodel
                        TestHSSFSheet.java TestUnfixedBugs.java
  Log:
  bug 35084, reported by Stefano Rocca. fixed in Sheet.java
 
  Revision  Changes    Path
  1.55      +13 -2     jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java
 
  Index: Sheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- Sheet.java 16 May 2005 20:38:55 -0000 1.54
  +++ Sheet.java 31 May 2005 19:03:19 -0000 1.55
  @@ -340,9 +340,20 @@
             ValueRecordsAggregate vrAgg = (ValueRecordsAggregate)rec;
             for (Iterator cellIter = vrAgg.getIterator();cellIter.hasNext();) {
               Record valRec = (Record)cellIter.next();
  -            clonedRecords.add(valRec);
  +            
  +            if (valRec instanceof FormulaRecordAggregate) {
  +                FormulaRecordAggregate fmAgg = (FormulaRecordAggregate)valRec;
  +                Record fmAggRec = fmAgg.getFormulaRecord();
  +                if (fmAggRec != null)
  +                  clonedRecords.add(fmAggRec);
  +                fmAggRec =   fmAgg.getStringRecord();
  +                if (fmAggRec != null)
  +                  clonedRecords.add(fmAggRec);
  +              } else {
  +                clonedRecords.add(valRec);
  +              }
             }
  -        } else if (rec instanceof FormulaRecordAggregate) {
  +        } else if (rec instanceof FormulaRecordAggregate) {  //Is this required now??
             FormulaRecordAggregate fmAgg = (FormulaRecordAggregate)rec;
             Record fmAggRec = fmAgg.getFormulaRecord();
             if (fmAggRec != null)
 
 
 
  1.10      +0 -1      jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java
 
  Index: FormulaRecordAggregate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/FormulaRecordAggregate.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FormulaRecordAggregate.java 23 Aug 2004 08:52:28 -0000 1.9
  +++ FormulaRecordAggregate.java 31 May 2005 19:03:19 -0000 1.10
  @@ -234,5 +234,4 @@
           if(stringRecord==null) return null;
           return stringRecord.getString();
      }
  -
   }
 
 
 
  1.25      +16 -0     jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java
 
  Index: TestHSSFSheet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TestHSSFSheet.java 7 May 2005 17:25:26 -0000 1.24
  +++ TestHSSFSheet.java 31 May 2005 19:03:19 -0000 1.25
  @@ -437,6 +437,22 @@
           assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
       }
       
  +    /** cell with formula becomes null on cloning a sheet*/
  + public void test35084() {
  +  
  +   HSSFWorkbook wb = new HSSFWorkbook();
  +   HSSFSheet s =wb.createSheet("Sheet1");
  +   HSSFRow r = s.createRow(0);
  +   r.createCell((short)0).setCellValue(1);
  +   r.createCell((short)1).setCellFormula("A1*2");
  +   HSSFSheet s1 = wb.cloneSheet(0);
  +   r=s1.getRow(0);
  +   assertEquals("double" ,r.getCell((short)0).getNumericCellValue(),(double)1,0); //sanity check
  +   assertNotNull(r.getCell((short)1));
  +   assertEquals("formula", r.getCell((short)1).getCellFormula(), "A1*2");
  +   }
  +
  +
    public static void main(java.lang.String[] args) {
    junit.textui.TestRunner.run(TestHSSFSheet.class);
    }    
 
 
 
  1.4       +0 -17     jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
 
  Index: TestUnfixedBugs.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestUnfixedBugs.java 31 May 2005 18:41:19 -0000 1.3
  +++ TestUnfixedBugs.java 31 May 2005 19:03:19 -0000 1.4
  @@ -59,21 +59,4 @@
          assertTrue("Read book fine!" , true);
      }
   
  - /* cell with formula becomes null on cloning a sheet*/
  - public void test35084() {
  -    
  -     HSSFWorkbook wb = new HSSFWorkbook();
  -     HSSFSheet s =wb.createSheet("Sheet1");
  -     HSSFRow r = s.createRow(0);
  -     r.createCell((short)0).setCellValue(1);
  -     r.createCell((short)1).setCellFormula("A1*2");
  -     HSSFSheet s1 = wb.cloneSheet(0);
  -     r=s1.getRow(0);
  -     assertEquals("double" ,r.getCell((short)0).getNumericCellValue(),(double)1,0); //sanity check, pass
  -     assertNotNull(r.getCell((short)1)); //Fails
  -     assertEquals("formula", r.getCell((short)1).getCellFormula(), "A1*2"); //Fails
  -    
  -    
  -    
  -    }
   }
 
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/