poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1513247 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java java/org/apache/poi/ss/formula/functions/MultiOperandNumericFunction.java testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
Date Mon, 12 Aug 2013 20:27:09 GMT
Author: centic
Date: Mon Aug 12 20:27:08 2013
New Revision: 1513247

URL: http://svn.apache.org/r1513247
Log:
Bug 55195: use interface instead of implementation for
NumericValueEval and others.

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/MultiOperandNumericFunction.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java?rev=1513247&r1=1513246&r2=1513247&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java Mon Aug 12
20:27:08 2013
@@ -22,8 +22,8 @@ import org.apache.poi.ss.formula.IStabil
 import org.apache.poi.ss.formula.WorkbookEvaluator;
 import org.apache.poi.ss.formula.eval.BoolEval;
 import org.apache.poi.ss.formula.eval.ErrorEval;
-import org.apache.poi.ss.formula.eval.NumberEval;
-import org.apache.poi.ss.formula.eval.StringEval;
+import org.apache.poi.ss.formula.eval.NumericValueEval;
+import org.apache.poi.ss.formula.eval.StringValueEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.udf.UDFFinder;
 import org.apache.poi.ss.usermodel.Cell;
@@ -348,20 +348,20 @@ public class HSSFFormulaEvaluator implem
 
 	/**
 	 * Returns a CellValue wrapper around the supplied ValueEval instance.
-	 * @param eval
+	 * @param cell
 	 */
 	private CellValue evaluateFormulaCellValue(Cell cell) {
 		ValueEval eval = _bookEvaluator.evaluate(new HSSFEvaluationCell((HSSFCell)cell));
-		if (eval instanceof NumberEval) {
-			NumberEval ne = (NumberEval) eval;
-			return new CellValue(ne.getNumberValue());
-		}
 		if (eval instanceof BoolEval) {
 			BoolEval be = (BoolEval) eval;
 			return CellValue.valueOf(be.getBooleanValue());
 		}
-		if (eval instanceof StringEval) {
-			StringEval ne = (StringEval) eval;
+		if (eval instanceof NumericValueEval) {
+			NumericValueEval ne = (NumericValueEval) eval;
+			return new CellValue(ne.getNumberValue());
+		}
+		if (eval instanceof StringValueEval) {
+			StringValueEval ne = (StringValueEval) eval;
 			return new CellValue(ne.getStringValue());
 		}
 		if (eval instanceof ErrorEval) {

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/MultiOperandNumericFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/MultiOperandNumericFunction.java?rev=1513247&r1=1513246&r2=1513247&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/MultiOperandNumericFunction.java
(original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/MultiOperandNumericFunction.java
Mon Aug 12 20:27:08 2013
@@ -22,9 +22,10 @@ import org.apache.poi.ss.formula.eval.Bo
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.EvaluationException;
 import org.apache.poi.ss.formula.eval.NumberEval;
+import org.apache.poi.ss.formula.eval.NumericValueEval;
 import org.apache.poi.ss.formula.eval.OperandResolver;
 import org.apache.poi.ss.formula.eval.RefEval;
-import org.apache.poi.ss.formula.eval.StringEval;
+import org.apache.poi.ss.formula.eval.StringValueEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.TwoDEval;
 
@@ -165,20 +166,24 @@ public abstract class MultiOperandNumeri
 		if (ve == null) {
 			throw new IllegalArgumentException("ve must not be null");
 		}
-		if (ve instanceof NumberEval) {
-			NumberEval ne = (NumberEval) ve;
-			temp.add(ne.getNumberValue());
+		if (ve instanceof BoolEval) {
+			if (!isViaReference || _isReferenceBoolCounted) {
+				BoolEval boolEval = (BoolEval) ve;
+				temp.add(boolEval.getNumberValue());
+			}
 			return;
 		}
-		if (ve instanceof ErrorEval) {
-			throw new EvaluationException((ErrorEval) ve);
+		if (ve instanceof NumericValueEval) {
+			NumericValueEval ne = (NumericValueEval) ve;
+			temp.add(ne.getNumberValue());
+			return;
 		}
-		if (ve instanceof StringEval) {
+		if (ve instanceof StringValueEval) {
 			if (isViaReference) {
 				// ignore all ref strings
 				return;
 			}
-			String s = ((StringEval) ve).getStringValue();
+			String s = ((StringValueEval) ve).getStringValue();
 			Double d = OperandResolver.parseDouble(s);
 			if(d == null) {
 				throw new EvaluationException(ErrorEval.VALUE_INVALID);
@@ -186,12 +191,8 @@ public abstract class MultiOperandNumeri
 			temp.add(d.doubleValue());
 			return;
 		}
-		if (ve instanceof BoolEval) {
-			if (!isViaReference || _isReferenceBoolCounted) {
-				BoolEval boolEval = (BoolEval) ve;
-				temp.add(boolEval.getNumberValue());
-			}
-			return;
+		if (ve instanceof ErrorEval) {
+			throw new EvaluationException((ErrorEval) ve);
 		}
 		if (ve == BlankEval.instance) {
 			if (_isBlankCounted) {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java?rev=1513247&r1=1513246&r2=1513247&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java Mon
Aug 12 20:27:08 2013
@@ -59,6 +59,7 @@ public final class TestHSSFFormulaEvalua
 	/**
 	 * Test for bug due to attempt to convert a cached formula error result to a boolean
 	 */
+	@Override
 	public void testUpdateCachedFormulaResultFromErrorToNumber_bug46479() {
 
 		HSSFWorkbook wb = new HSSFWorkbook();
@@ -132,6 +133,7 @@ public final class TestHSSFFormulaEvalua
 		public EvalCountListener() {
 			_evalCount = 0;
 		}
+		@Override
 		public void onStartEvaluate(EvaluationCell cell, ICacheEntry entry) {
 			_evalCount++;
 		}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message