You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2019/12/30 19:57:12 UTC

svn commit: r1872125 - in /poi/trunk: src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java test-data/spreadsheet/BooleanFunctionsTestCaseData.xls

Author: centic
Date: Mon Dec 30 19:57:11 2019
New Revision: 1872125

URL: http://svn.apache.org/viewvc?rev=1872125&view=rev
Log:
Fix bug 63984: AND / OR should treat missing parameters as FALSE

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java
    poi/trunk/test-data/spreadsheet/BooleanFunctionsTestCaseData.xls

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java?rev=1872125&r1=1872124&r2=1872125&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java Mon Dec 30 19:57:11 2019
@@ -55,7 +55,7 @@ public abstract class BooleanFunction im
 	private boolean calculate(ValueEval[] args) throws EvaluationException {
 
 		boolean result = getInitialResultValue();
-		boolean atleastOneNonBlank = false;
+		boolean atLeastOneNonBlank = false;
 
 		/*
 		 * Note: no short-circuit boolean loop exit because any ErrorEvals will override the result
@@ -71,8 +71,8 @@ public abstract class BooleanFunction im
 						ValueEval ve = ae.getValue(rrIx, rcIx);
 						tempVe = OperandResolver.coerceValueToBoolean(ve, true);
 						if (tempVe != null) {
-							result = partialEvaluate(result, tempVe.booleanValue());
-							atleastOneNonBlank = true;
+							result = partialEvaluate(result, tempVe);
+							atLeastOneNonBlank = true;
 						}
 					}
 				}
@@ -86,26 +86,26 @@ public abstract class BooleanFunction im
                     ValueEval ve = re.getInnerValueEval(sIx);
                     tempVe = OperandResolver.coerceValueToBoolean(ve, true);
                     if (tempVe != null) {
-                        result = partialEvaluate(result, tempVe.booleanValue());
-                        atleastOneNonBlank = true;
+                        result = partialEvaluate(result, tempVe);
+                        atLeastOneNonBlank = true;
                     }
                 }
                 continue;
             }
-			
+
 			if (arg == MissingArgEval.instance) {
-				tempVe = null;		// you can leave out parameters, they are simply ignored
+				tempVe = false;		// missing parameters are treated as FALSE
 			} else {
 				tempVe = OperandResolver.coerceValueToBoolean(arg, false);
 			}
 
 			if (tempVe != null) {
-				result = partialEvaluate(result, tempVe.booleanValue());
-				atleastOneNonBlank = true;
+				result = partialEvaluate(result, tempVe);
+				atLeastOneNonBlank = true;
 			}
 		}
 
-		if (!atleastOneNonBlank) {
+		if (!atLeastOneNonBlank) {
 			throw new EvaluationException(ErrorEval.VALUE_INVALID);
 		}
 		return result;
@@ -161,7 +161,7 @@ public abstract class BooleanFunction im
 			try {
 				ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
 				Boolean b = OperandResolver.coerceValueToBoolean(ve, false);
-				boolArgVal = b == null ? false : b.booleanValue();
+				boolArgVal = b == null ? false : b;
 			} catch (EvaluationException e) {
 				return e.getErrorEval();
 			}

Modified: poi/trunk/test-data/spreadsheet/BooleanFunctionsTestCaseData.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/BooleanFunctionsTestCaseData.xls?rev=1872125&r1=1872124&r2=1872125&view=diff
==============================================================================
Binary files - no diff available.



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