]> source.dussan.org Git - poi.git/commitdiff
DV related fixes from Pierre Lavignotte
authorNick Burch <nick@apache.org>
Mon, 1 Sep 2008 16:51:09 +0000 (16:51 +0000)
committerNick Burch <nick@apache.org>
Mon, 1 Sep 2008 16:51:09 +0000 (16:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@691017 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java

index d1c464dc328a4a8905c9344a1e4847d6138b1577..807afae1606b3f4c652749def89962db4b346d77 100644 (file)
@@ -34,7 +34,14 @@ import org.apache.poi.ddf.EscherRecord;
 import org.apache.poi.hssf.model.FormulaParser;
 import org.apache.poi.hssf.model.Sheet;
 import org.apache.poi.hssf.model.Workbook;
-import org.apache.poi.hssf.record.*;
+import org.apache.poi.hssf.record.CellValueRecordInterface;
+import org.apache.poi.hssf.record.DVRecord;
+import org.apache.poi.hssf.record.EscherAggregate;
+import org.apache.poi.hssf.record.Record;
+import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.hssf.record.SCLRecord;
+import org.apache.poi.hssf.record.WSBoolRecord;
+import org.apache.poi.hssf.record.WindowTwoRecord;
 import org.apache.poi.hssf.record.aggregates.DataValidityTable;
 import org.apache.poi.hssf.record.formula.Ptg;
 import org.apache.poi.hssf.record.formula.RefPtg;
@@ -366,6 +373,22 @@ public final class HSSFSheet {
        DVRecord dvRecord = dataValidation.createDVRecord(workbook);
        dvt.addDataValidation(dvRecord);
     }
+    
+    /**
+     * Get the DVRecords objects that are associated to this sheet
+     * @return a list of DVRecord instances
+     */
+    public List getDVRecords() {
+        List dvRecords = new ArrayList();
+        List records = sheet.getRecords();
+        
+        for(int index=0; index<records.size(); index++) {
+           if(records.get(index) instanceof DVRecord) {
+                  dvRecords.add(records.get(index));
+           }
+        }
+        return dvRecords;
+    }
 
 
     /**
@@ -1254,11 +1277,9 @@ public final class HSSFSheet {
                     // Since it's a formula cell, process the
                     //  formula string, and look to see if
                     //  it contains any references
-                    FormulaParser fp = new FormulaParser(c.getCellFormula(), workbook);
-                    fp.parse();
 
                     // Look for references, and update if needed
-                    Ptg[] ptgs = fp.getRPNPtg();
+                    Ptg[] ptgs = FormulaParser.parse(c.getCellFormula(), workbook);
                     boolean changed = false;
                     for(int i=0; i<ptgs.length; i++) {
                         if(ptgs[i] instanceof RefPtg) {
@@ -1275,7 +1296,7 @@ public final class HSSFSheet {
                     //  re-create the formula string
                     if(changed) {
                         c.setCellFormula(
-                                fp.toFormulaString(ptgs)
+                             FormulaParser.toFormulaString(workbook, ptgs)
                         );
                     }
                 }