summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2021-07-08 10:04:53 +0200
committerLászló Németh <nemeth@numbertext.org>2021-07-20 15:15:28 +0200
commitd824db8ee208cff8029752ca753815be8ca2fff4 (patch)
tree0f79f1887eb6207b3224567d8c11b5f1db2c2e87 /sc
parentec77a2ed0283cb3446f6e352fc329afd3dfb785c (diff)
tdf#46184 sc AutoFilter: reset filter options to default values
when the old filter entries are removed in auto-filter rules, because these options are not visible from the AutoFilter. E.g. now using AutoFilter doesn't apply copying of the previous standard filtering, changing also the active sheet etc. This fixes regression from LibreOffice 3.5 or more. Change-Id: I26b272dc738f3918ff5b2ca7e8fee3481d21460a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118603 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc')
-rwxr-xr-xsc/qa/uitest/autofilter/tdf46184.py84
-rw-r--r--sc/source/ui/view/gridwin.cxx35
2 files changed, 109 insertions, 10 deletions
diff --git a/sc/qa/uitest/autofilter/tdf46184.py b/sc/qa/uitest/autofilter/tdf46184.py
new file mode 100755
index 000000000000..08dfc520b640
--- /dev/null
+++ b/sc/qa/uitest/autofilter/tdf46184.py
@@ -0,0 +1,84 @@
+# -*- 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 select_by_text, get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import get_row
+
+#Bug 46184 - [Calc] [AutoFilter] Option "Copy results to ..." remains activated in AutoFilter
+
+class tdf46184(UITestCase):
+ def test_tdf46184_copy_results_to(self):
+ with self.ui_test.create_doc_in_start_center("calc") as document:
+ calcDoc = self.xUITest.getTopFocusWindow()
+ gridwin = calcDoc.getChild("grid_window")
+
+ enter_text_to_cell(gridwin, "A1", "A")
+ enter_text_to_cell(gridwin, "A2", "1")
+ enter_text_to_cell(gridwin, "A3", "2")
+ enter_text_to_cell(gridwin, "A4", "3")
+
+ gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"}))
+
+ self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
+
+ gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ #Choose Standard Filter... button
+ 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":"DOWN"}))
+ xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+ xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"}))
+ self.assertEqual("Standard Filter...", get_state_as_dict(xMenu)['SelectEntryText'])
+ xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"}))
+
+ xDialog = self.xUITest.getTopFocusWindow()
+ xfield1 = xDialog.getChild("field1")
+ xcond1 = xDialog.getChild("cond1")
+ xval1 = xDialog.getChild("val1")
+ xcopyresult = xDialog.getChild("copyresult")
+ xedcopyarea = xDialog.getChild("edcopyarea")
+ xdestpers = xDialog.getChild("destpers")
+
+ select_by_text(xfield1, "A")
+ select_by_text(xcond1, ">")
+ xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
+ xcopyresult.executeAction("CLICK", tuple())
+ xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"A6"}))
+ if get_state_as_dict(xdestpers)['Selected'] == 'false':
+ xdestpers.executeAction("CLICK", tuple())
+ self.assertEqual('true', get_state_as_dict(xcopyresult)['Selected'])
+ xOKBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOKBtn)
+
+
+ row1 = get_row(document, 1)
+ row2 = get_row(document, 2)
+ row3 = get_row(document, 3)
+ self.assertTrue(row1.getPropertyValue("IsVisible"))
+ self.assertTrue(row2.getPropertyValue("IsVisible"))
+ self.assertTrue(row3.getPropertyValue("IsVisible"))
+
+ gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
+ xFloatWindow = self.xUITest.getFloatWindow()
+ xCheckListMenu = xFloatWindow.getChild("check_list_menu")
+ xTreeList = xCheckListMenu.getChild("check_list_box")
+ xEntry = xTreeList.getChild("1")
+ xEntry.executeAction("CLICK", tuple())
+ xOkBtn = xFloatWindow.getChild("ok")
+ xOkBtn.executeAction("CLICK", tuple())
+
+ self.assertTrue(row1.getPropertyValue("IsVisible"))
+ self.assertFalse(row2.getPropertyValue("IsVisible"))
+ self.assertTrue(row3.getPropertyValue("IsVisible"))
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 9c2889e19145..effb52c917c1 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -833,20 +833,19 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
mrViewData.GetViewShell()->UISort(aSortParam);
return;
}
+ case AutoFilterMode::Custom:
+ {
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ mrViewData.GetView()->MarkRange(aRange);
+ mrViewData.GetView()->SetCursor(rPos.Col(), rPos.Row());
+ mrViewData.GetDispatcher().Execute(SID_FILTER, SfxCallMode::SLOT | SfxCallMode::RECORD);
+ return;
+ }
default:
;
}
- if (eMode == AutoFilterMode::Custom)
- {
- ScRange aRange;
- pDBData->GetArea(aRange);
- mrViewData.GetView()->MarkRange(aRange);
- mrViewData.GetView()->SetCursor(rPos.Col(), rPos.Row());
- mrViewData.GetDispatcher().Execute(SID_FILTER, SfxCallMode::SLOT|SfxCallMode::RECORD);
- return;
- }
-
ScQueryParam aParam;
pDBData->GetQueryParam(aParam);
@@ -877,8 +876,16 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
// Remove old entries in auto-filter rules
if (!bColorMode)
+ {
aParam.RemoveAllEntriesByField(rPos.Col());
+ // tdf#46184 reset filter options to default values
+ aParam.eSearchType = utl::SearchParam::SearchType::Normal;
+ aParam.bCaseSens = false;
+ aParam.bDuplicate = true;
+ aParam.bInplace = true;
+ }
+
if (eMode != AutoFilterMode::Clear
&& !(eMode == AutoFilterMode::Normal && rControl.isAllSelected()))
{
@@ -960,8 +967,16 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
// Disable color filter when active color was selected
if (nSelected == nActive)
+ {
aParam.RemoveAllEntriesByField(rPos.Col());
+ // tdf#46184 reset filter options to default values
+ aParam.eSearchType = utl::SearchParam::SearchType::Normal;
+ aParam.bCaseSens = false;
+ aParam.bDuplicate = true;
+ aParam.bInplace = true;
+ }
+
// Get selected color from set
std::set<Color>::iterator it = aColors.begin();
std::advance(it, nSelected - 1);