[bug-66087] make DStar functions case insensitive

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901229 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2022-05-25 10:31:07 +00:00
parent e5398e8a88
commit 3f414c760c
2 changed files with 4 additions and 2 deletions

View File

@ -17,6 +17,7 @@
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
import java.util.Locale;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.apache.poi.ss.formula.eval.AreaEval; import org.apache.poi.ss.formula.eval.AreaEval;
@ -30,6 +31,7 @@ import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.StringValueEval; import org.apache.poi.ss.formula.eval.StringValueEval;
import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.util.NumberComparer; import org.apache.poi.ss.util.NumberComparer;
import org.apache.poi.util.LocaleUtil;
/** /**
* This class performs a D* calculation. It takes an {@link IDStarAlgorithm} object and * This class performs a D* calculation. It takes an {@link IDStarAlgorithm} object and
@ -316,7 +318,7 @@ public final class DStarRunner implements Function3Arg {
return testNumericCondition(value, operator.equal, stringOrNumber); return testNumericCondition(value, operator.equal, stringOrNumber);
} else { // It's a string. } else { // It's a string.
String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value); String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value);
return stringOrNumber.equals(valueString); return stringOrNumber.equalsIgnoreCase(valueString);
} }
} else { // It's a text starts-with condition. } else { // It's a text starts-with condition.
if(conditionString.isEmpty()) { if(conditionString.isEmpty()) {
@ -324,7 +326,7 @@ public final class DStarRunner implements Function3Arg {
} }
else { else {
String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value); String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value);
return valueString.startsWith(conditionString); return valueString.toLowerCase(LocaleUtil.getUserLocale()).startsWith(conditionString.toLowerCase(LocaleUtil.getUserLocale()));
} }
} }
} else if(condition instanceof NumericValueEval) { } else if(condition instanceof NumericValueEval) {

Binary file not shown.