]> source.dussan.org Git - poi.git/commitdiff
tidy up eval
authorPJ Fanning <fanningpj@apache.org>
Sat, 14 Aug 2021 00:28:37 +0000 (00:28 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 14 Aug 2021 00:28:37 +0000 (00:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892322 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java
poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java

index bc371ec44cb2df29eec5f6ce40e3c99232040b7b..d6a92b3e1fa21c8124ca70d4786f331c4f7399f8 100644 (file)
@@ -305,14 +305,11 @@ public final class LookupUtils {
             StringEval se = (StringEval) other;
 
             String stringValue = se.getStringValue();
-            if (_wildCardPattern != null) {
+            if (_wildCardPattern != null && (_isMatchFunction || !_matchExact)) {
                 Matcher matcher = _wildCardPattern.matcher(stringValue);
                 boolean matches = matcher.matches();
 
-                if (_isMatchFunction ||
-                    !_matchExact) {
-                  return CompareResult.valueOf(matches);
-                }
+                return CompareResult.valueOf(matches);
             }
 
             return CompareResult.valueOf(_value.compareToIgnoreCase(stringValue));
index 4d3954fa784b2ae1d9ff6824809d658f3406c996..eec63048e65f751be9d89a42cc554d61646a9a7f 100644 (file)
@@ -53,6 +53,9 @@ public abstract class BaseTestConditionalFormatting {
 
     protected abstract void assertColor(String hexExpected, Color actual);
 
+    protected int defaultDataBarMinLength() { return 0; }
+    protected int defaultDataBarMaxLength() { return 100; }
+
     @Test
     void testBasic() throws Throwable {
         try (Workbook wb = _testDataProvider.createWorkbook()) {
@@ -764,8 +767,8 @@ public abstract class BaseTestConditionalFormatting {
         assertNotNull(databar);
         assertFalse(databar.isIconOnly());
         assertTrue(databar.isLeftToRight());
-        assertEquals(0, databar.getWidthMin());
-        assertEquals(100, databar.getWidthMax());
+        assertEquals(defaultDataBarMinLength(), databar.getWidthMin());
+        assertEquals(defaultDataBarMaxLength(), databar.getWidthMax());
 
         assertColor(color, databar.getColor());
 
@@ -1177,8 +1180,8 @@ public abstract class BaseTestConditionalFormatting {
 
             assertFalse(dbFmt.isIconOnly());
             assertTrue(dbFmt.isLeftToRight());
-            assertEquals(0, dbFmt.getWidthMin());
-            assertEquals(100, dbFmt.getWidthMax());
+            assertEquals(defaultDataBarMinLength(), dbFmt.getWidthMin());
+            assertEquals(defaultDataBarMaxLength(), dbFmt.getWidthMax());
             assertColor(colorHex, dbFmt.getColor());
 
             dbFmt.getMinThreshold().setRangeType(RangeType.MIN);
@@ -1201,8 +1204,8 @@ public abstract class BaseTestConditionalFormatting {
 
                 assertFalse(dbFmt.isIconOnly());
                 assertTrue(dbFmt.isLeftToRight());
-                assertEquals(0, dbFmt.getWidthMin());
-                assertEquals(100, dbFmt.getWidthMax());
+                assertEquals(defaultDataBarMinLength(), dbFmt.getWidthMin());
+                assertEquals(defaultDataBarMaxLength(), dbFmt.getWidthMax());
                 assertColor(colorHex, dbFmt.getColor());
 
                 assertEquals(RangeType.MIN, dbFmt.getMinThreshold().getRangeType());