sc/qa/uitest/autofilter/tdf68113.py |   77 ++++++++++++++++++++++++++++++++++++
 sc/source/ui/view/gridwin.cxx       |   12 ++++-
 2 files changed, 87 insertions(+), 2 deletions(-)

New commits:
commit 00e13be1c3dd45597237f805a06b3e8a74187125
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Thu May 13 17:49:59 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri May 28 09:32:56 2021 +0200

    tdf#68113 sc autofilter: fix not empty button unchecks all entries
    
    Instead unchecks all entries, unchecks only empty entries.
    
    Change-Id: I6f0d6432151ad2c65871dc5f1dd206883994217a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115562
    Tested-by: Jenkins
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sc/qa/uitest/autofilter/tdf68113.py 
b/sc/qa/uitest/autofilter/tdf68113.py
new file mode 100644
index 000000000000..dd211665f614
--- /dev/null
+++ b/sc/qa/uitest/autofilter/tdf68113.py
@@ -0,0 +1,77 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+#Bug 68113 - UI Selecting "Not empty" unchecks all entries
+
+class tdf68113(UITestCase):
+    def test_tdf68113_empty_notempty_button(self):
+        self.ui_test.create_doc_in_start_center("calc")
+        document = self.ui_test.get_component()
+        calcDoc = self.xUITest.getTopFocusWindow()
+        xGridWin = calcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+
+        enter_text_to_cell(xGridWin, "A1", "A")
+        enter_text_to_cell(xGridWin, "A2", "1")
+        enter_text_to_cell(xGridWin, "A3", "2")
+        enter_text_to_cell(xGridWin, "A5", "4")
+        enter_text_to_cell(xGridWin, "A7", "6")
+
+        xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A7"}))
+
+        self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
+
+        # Empty button
+        xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", 
"COL": "0", "ROW": "0"}))
+        xFloatWindow = self.xUITest.getFloatWindow()
+        xMenu = xFloatWindow.getChild("menu")
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+
+        # Checkbox elements
+        xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", 
"COL": "0", "ROW": "0"}))
+        xFloatWindow = self.xUITest.getFloatWindow()
+        xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+        xTreeList = xCheckListMenu.getChild("check_list_box")
+        self.assertEqual(5, len(xTreeList.getChildren()))
+        self.assertEqual('false', 
get_state_as_dict(xTreeList.getChild('0'))['IsChecked'])
+        self.assertEqual('false', 
get_state_as_dict(xTreeList.getChild('2'))['IsChecked'])
+        self.assertEqual('true', 
get_state_as_dict(xTreeList.getChild('4'))['IsChecked'])
+        xCancelBtn = xFloatWindow.getChild("cancel")
+        xCancelBtn.executeAction("CLICK", tuple())
+
+        # Not Empty button
+        xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", 
"COL": "0", "ROW": "0"}))
+        xFloatWindow = self.xUITest.getFloatWindow()
+        xMenu = xFloatWindow.getChild("menu")
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+        xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+
+        # Checkbox elements
+        xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", 
"COL": "0", "ROW": "0"}))
+        xFloatWindow = self.xUITest.getFloatWindow()
+        xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+        xTreeList = xCheckListMenu.getChild("check_list_box")
+        self.assertEqual(5, len(xTreeList.getChildren()))
+        self.assertEqual('true', 
get_state_as_dict(xTreeList.getChild('0'))['IsChecked'])
+        self.assertEqual('true', 
get_state_as_dict(xTreeList.getChild('2'))['IsChecked'])
+        self.assertEqual('false', 
get_state_as_dict(xTreeList.getChild('4'))['IsChecked'])
+        xCancelBtn = xFloatWindow.getChild("cancel")
+        xCancelBtn.executeAction("CLICK", tuple())
+
+        self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 400a6a8184ce..635b13700b68 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -664,6 +664,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW 
nRow)
 
     ScQueryParam aParam;
     pDBData->GetQueryParam(aParam);
+    bool bQueryByNonEmpty = false;
     std::vector<ScQueryEntry*> aEntries = aParam.FindAllEntriesByField(nCol);
     std::unordered_set<OUString> aSelectedString;
     std::unordered_set<double> aSelectedValue;
@@ -671,8 +672,13 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW 
nRow)
     {
         if (pEntry && pEntry->bDoQuery && pEntry->eOp == SC_EQUAL)
         {
-            ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
-            std::for_each(rItems.begin(), rItems.end(), 
AddSelectedItemString(aSelectedString, aSelectedValue));
+            if (!pEntry->IsQueryByNonEmpty())
+            {
+                ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
+                std::for_each(rItems.begin(), rItems.end(), 
AddSelectedItemString(aSelectedString, aSelectedValue));
+            }
+            else
+                bQueryByNonEmpty = true;
         }
     }
 
@@ -691,6 +697,8 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW 
nRow)
                 bSelected
                     = aSelectedValue.count(aDoubleVal) > 0 || 
aSelectedString.count(aStringVal) > 0;
         }
+        else if (bQueryByNonEmpty)
+            bSelected = !aStringVal.isEmpty();
 
         if ( rEntry.IsDate() )
             rControl.addDateMember( aStringVal, rEntry.GetValue(), bSelected );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to