From bc0dcdf36929e2b5c8761faa9c5c5cf29be3f367 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Mon, 30 Dec 2019 19:57:11 +0000 Subject: Fix bug 63984: AND / OR should treat missing parameters as FALSE git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1872125 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/formula/functions/BooleanFunction.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/java/org') diff --git a/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java b/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java index 5b5b539fef..5177b851a6 100644 --- a/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java +++ b/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java @@ -55,7 +55,7 @@ public abstract class BooleanFunction implements Function,ArrayFunction { 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 implements Function,ArrayFunction { 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 implements Function,ArrayFunction { 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 implements Function,ArrayFunction { 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(); } -- cgit v1.2.3