poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r884389 - in /poi/trunk/src/java/org/apache/poi: hssf/record/formula/functions/Choose.java hssf/record/formula/functions/If.java ss/formula/WorkbookEvaluator.java
Date Thu, 26 Nov 2009 02:57:25 GMT
Author: josh
Date: Thu Nov 26 02:57:24 2009
New Revision: 884389

URL: http://svn.apache.org/viewvc?rev=884389&view=rev
Log:
Moved handling of MissingArgEval into IF() or CHOOSE() for non-optimised (eager argument evaluation)
case

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Choose.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/If.java
    poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Choose.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Choose.java?rev=884389&r1=884388&r2=884389&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Choose.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/Choose.java Thu Nov 26
02:57:24 2009
@@ -17,8 +17,10 @@
 
 package org.apache.poi.hssf.record.formula.functions;
 
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
 import org.apache.poi.hssf.record.formula.eval.EvaluationException;
+import org.apache.poi.hssf.record.formula.eval.MissingArgEval;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
@@ -37,7 +39,11 @@
 			if (ix < 1 || ix >= args.length) {
 				return ErrorEval.VALUE_INVALID;
 			}
-			return OperandResolver.getSingleValue(args[ix], srcRowIndex, srcColumnIndex);
+			ValueEval result = OperandResolver.getSingleValue(args[ix], srcRowIndex, srcColumnIndex);
+			if (result == MissingArgEval.instance) {
+				return BlankEval.INSTANCE;
+			}
+			return result;
 		} catch (EvaluationException e) {
 			return e.getErrorEval();
 		}

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/If.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/If.java?rev=884389&r1=884388&r2=884389&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/If.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/functions/If.java Thu Nov 26 02:57:24
2009
@@ -17,8 +17,10 @@
 
 package org.apache.poi.hssf.record.formula.functions;
 
+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.EvaluationException;
+import org.apache.poi.hssf.record.formula.eval.MissingArgEval;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
@@ -34,7 +36,13 @@
 		} catch (EvaluationException e) {
 			return e.getErrorEval();
 		}
-		return b ? arg1 : BoolEval.FALSE;
+		if (b) {
+			if (arg1 == MissingArgEval.instance) {
+				return BlankEval.INSTANCE;
+			}
+			return arg1;
+		}
+		return BoolEval.FALSE;
 	}
 
 	public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval
arg1,
@@ -45,7 +53,16 @@
 		} catch (EvaluationException e) {
 			return e.getErrorEval();
 		}
-		return b ? arg1 : arg2;
+		if (b) {
+			if (arg1 == MissingArgEval.instance) {
+				return BlankEval.INSTANCE;
+			}
+			return arg1;
+		}
+		if (arg2 == MissingArgEval.instance) {
+			return BlankEval.INSTANCE;
+		}
+		return arg2;
 	}
 
 	public static boolean evaluateFirstArg(ValueEval arg, int srcCellRow, int srcCellCol)

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java?rev=884389&r1=884388&r2=884389&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java Thu Nov 26 02:57:24
2009
@@ -435,9 +435,6 @@
 				}
 //				logDebug("invoke " + operation + " (nAgs=" + numops + ")");
 				opResult = OperationEvaluatorFactory.evaluate(optg, ops, ec);
-				if (opResult == MissingArgEval.instance) {
-					opResult = BlankEval.INSTANCE;
-				}
 			} else {
 				opResult = getEvalForPtg(ptg, ec);
 			}



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


Mime
View raw message