From 57f8cb379daa50ebf6723f2ebf5309202ea71bb2 Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Tue, 23 Sep 2008 21:52:49 +0000 Subject: Merged revisions 698047 via svnmerge from https://svn.apache.org/repos/asf/poi/trunk ........ r698047 | josh | 2008-09-22 17:40:22 -0700 (Mon, 22 Sep 2008) | 1 line Optimised the FormulaEvaluator to take cell dependencies into account ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@698370 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/XSSFEvaluationWorkbook.java | 18 ++++++++++-------- .../poi/xssf/usermodel/XSSFFormulaEvaluator.java | 22 +++++++--------------- 2 files changed, 17 insertions(+), 23 deletions(-) (limited to 'src/ooxml/java/org') diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java index 2d442e8f4a..7c03ebe7ff 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java @@ -37,10 +37,16 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E return externSheetIndex; } /** - * @returns the external sheet index of the sheet with the given internal - * index, creating one if needed. Used by some of the more obscure - * formula and named range things. Fairly easy on XSSF (we - * think...) since the internal and external indicies are the same + * @return the sheet index of the sheet with the given external index. + */ + public int convertFromExternSheetIndex(int externSheetIndex) { + return externSheetIndex; + } + /** + * @return the external sheet index of the sheet with the given internal + * index. Used by some of the more obscure formula and named range things. + * Fairly easy on XSSF (we think...) since the internal and external + * indicies are the same */ private int convertToExternalSheetIndex(int sheetIndex) { return sheetIndex; @@ -73,10 +79,6 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E return _uBook.getSheetName(sheetIndex); } - public int getNameIndex(String name) { - return _uBook.getNameIndex(name); - } - public NameXPtg getNameXPtg(String name) { // may require to return null to make tests pass throw new RuntimeException("Not implemented yet"); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java index 3dcedf8f5e..10fb78caf7 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java @@ -19,12 +19,14 @@ package org.apache.poi.xssf.usermodel; import java.util.Iterator; +import org.apache.poi.hssf.record.formula.eval.BlankEval; import org.apache.poi.hssf.record.formula.eval.BoolEval; import org.apache.poi.hssf.record.formula.eval.ErrorEval; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.StringEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.ss.formula.WorkbookEvaluator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellValue; @@ -50,14 +52,6 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator { _bookEvaluator = new WorkbookEvaluator(XSSFEvaluationWorkbook.create(workbook)); } - /** - * TODO for debug/test use - */ - /* package */ int getEvaluationCount() { - return _bookEvaluator.getEvaluationCount(); - } - - /** * Should be called whenever there are major changes (e.g. moving sheets) to input cells * in the evaluated workbook. @@ -67,13 +61,11 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator { public void clearAllCachedResultValues() { _bookEvaluator.clearAllCachedResultValues(); } - /** - * Should be called whenever there are changes to individual input cells in the evaluated workbook. - * Failure to call this method after changing cell values will cause incorrect behaviour - * of the evaluate~ methods of this class - */ - public void clearCachedResultValue(Sheet sheet, int rowIndex, int columnIndex) { - _bookEvaluator.clearCachedResultValue(sheet, rowIndex, columnIndex); + public void setCachedPlainValue(Sheet sheet, int rowIndex, int columnIndex, ValueEval value) { + _bookEvaluator.setCachedPlainValue(sheet, rowIndex, columnIndex, value); + } + public void notifySetFormula(HSSFSheet sheet, int rowIndex, int columnIndex) { + _bookEvaluator.notifySetFormula(sheet, rowIndex, columnIndex); } /** -- cgit v1.2.3