sc/Module_sc.mk | 1 sc/UITest_autofilter.mk | 15 ++++++++ sc/qa/uitest/autofilter/autofilter.py | 51 ++++++++++++++++++++++++++++ sc/qa/uitest/autofilter/data/autofilter.ods |binary sc/source/ui/cctrl/checklistmenu.cxx | 10 +++-- sc/source/ui/inc/checklistmenu.hxx | 13 ++++++- sc/source/ui/view/gridwin.cxx | 24 +++++-------- sc/source/ui/view/gridwin2.cxx | 14 +++---- 8 files changed, 102 insertions(+), 26 deletions(-)
New commits: commit 5d420856d432ff178560b2be37d33c6ddc439397 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Mar 26 23:00:24 2017 +0200 add test for tdf#106214 Change-Id: I9998aa40c3831a6033d4d61a6eab90d639ec5aa9 Reviewed-on: https://gerrit.libreoffice.org/35731 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 31c1a58b7d81..4659f55ebfeb 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -141,6 +141,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sc,\ UITest_conditional_format \ UITest_range_name \ UITest_hide_cols \ + UITest_autofilter \ )) # vim: set noet sw=4 ts=4: diff --git a/sc/UITest_autofilter.mk b/sc/UITest_autofilter.mk new file mode 100644 index 000000000000..93bf17200bb1 --- /dev/null +++ b/sc/UITest_autofilter.mk @@ -0,0 +1,15 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# 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/. +# + +$(eval $(call gb_UITest_UITest,autofilter)) + +$(eval $(call gb_UITest_add_modules,autofilter,$(SRCDIR)/sc/qa/uitest,\ + autofilter/ \ +)) +# vim: set noet sw=4 ts=4: diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py new file mode 100644 index 000000000000..ece49657d0c9 --- /dev/null +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -0,0 +1,51 @@ +# -*- 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.path import get_srcdir_url + +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_row + +import time + +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sc/qa/uitest/autofilter/data/" + file_name + +def is_row_hidden(doc, index): + row = get_row(doc, index) + val = row.getPropertyValue("IsVisible") + return not val + +class AutofilterTest(UITestCase): + + def test_tdf106214(self): + doc = self.ui_test.load_file(get_url_for_data_file("autofilter.ods")) + + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + 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") + xFirstEntry = xTreeList.getChild("0") + + xFirstEntry.executeAction("CLICK", tuple()) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.assertFalse(is_row_hidden(doc, 0)) + self.assertFalse(is_row_hidden(doc, 1)) + self.assertFalse(is_row_hidden(doc, 2)) + self.assertTrue(is_row_hidden(doc, 3)) + self.assertFalse(is_row_hidden(doc, 4)) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/data/autofilter.ods b/sc/qa/uitest/autofilter/data/autofilter.ods new file mode 100644 index 000000000000..49285933cec3 Binary files /dev/null and b/sc/qa/uitest/autofilter/data/autofilter.ods differ commit b3d498755238cb0d9a7a3e33b6070c1e4c0e3482 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Mar 26 22:50:18 2017 +0200 handle date autofilter entries correctly, tdf#106214 Change-Id: I8fd2896c8998e79794a0ccaae1c2442caf8b89ac Reviewed-on: https://gerrit.libreoffice.org/35730 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index ce637818191c..dba72366b4aa 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -1916,12 +1916,14 @@ void ScCheckListMenuWindow::getResult(ResultType& rResult) if (aLabel.isEmpty()) aLabel = ScGlobal::GetRscString(STR_EMPTYDATA); bool bState = maChecks->IsChecked( aLabel, maMembers[i].mpParent ); - OUString sName; + ResultEntry aResultEntry; + aResultEntry.bValid = bState; if ( maMembers[i].mbDate ) - sName = maMembers[i].maRealName; + aResultEntry.aName = maMembers[i].maRealName; else - sName = maMembers[i].maName; - aResult.insert(ResultType::value_type(sName, bState)); + aResultEntry.aName = maMembers[i].maName; + aResultEntry.bDate = maMembers[i].mbDate; + aResult.insert(aResultEntry); } } rResult.swap(aResult); diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index f2e208ad4f6b..1864415b6aaa 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -292,7 +292,18 @@ struct ScCheckListMember class ScCheckListMenuWindow : public ScMenuFloatingWindow { public: - typedef std::unordered_map<OUString, bool, OUStringHash> ResultType; + struct ResultEntry + { + OUString aName; + bool bValid; + bool bDate; + + bool operator<(const ResultEntry& rhs) const + { + return aName < rhs.aName; + } + }; + typedef std::set<ResultEntry> ResultType; /** * Extended data that the client code may need to store. Create a diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index bfbae1242a84..c590bc336b0d 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -590,13 +590,16 @@ class AddItemToEntry : public std::unary_function<OUString, void> public: AddItemToEntry(ScQueryEntry::QueryItemsType& rItems, svl::SharedStringPool& rPool) : mrItems(rItems), mrPool(rPool) {} - void operator() (const OUString& rSelected) + void operator() (const ScCheckListMenuWindow::ResultEntry& rEntry) { - ScQueryEntry::Item aNew; - aNew.maString = mrPool.intern(rSelected); - aNew.meType = ScQueryEntry::ByString; - aNew.mfVal = 0.0; - mrItems.push_back(aNew); + if (rEntry.bValid) + { + ScQueryEntry::Item aNew; + aNew.maString = mrPool.intern(rEntry.aName); + aNew.meType = rEntry.bDate ? ScQueryEntry::ByDate : ScQueryEntry::ByString; + aNew.mfVal = 0.0; + mrItems.push_back(aNew); + } } }; @@ -800,17 +803,10 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) ScCheckListMenuWindow::ResultType aResult; mpAutoFilterPopup->getResult(aResult); - std::vector<OUString> aSelected; - ScCheckListMenuWindow::ResultType::const_iterator itr = aResult.begin(), itrEnd = aResult.end(); - for (; itr != itrEnd; ++itr) - { - if (itr->second) - aSelected.push_back(itr->first); - } ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems(); rItems.clear(); - std::for_each(aSelected.begin(), aSelected.end(), AddItemToEntry(rItems, rPool)); + std::for_each(aResult.begin(), aResult.end(), AddItemToEntry(rItems, rPool)); } break; case Top10: diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index 1cdef6e1b205..59d70bdb2164 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -568,29 +568,29 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu() ScCheckListMenuWindow::ResultType aRawResult; mpDPFieldPopup->getResult(aRawResult); - ScCheckListMenuWindow::ResultType aResult; + std::unordered_map<OUString, bool, OUStringHash> aResult; ScCheckListMenuWindow::ResultType::const_iterator itr = aRawResult.begin(), itrEnd = aRawResult.end(); for (; itr != itrEnd; ++itr) { - MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(itr->first); + MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(itr->aName); if (itrNameMap == aMemNameMap.end()) { // This is an original member name. Use it as-is. - OUString aName = itr->first; + OUString aName = itr->aName; if (aName.equals(ScGlobal::GetRscString(STR_EMPTYDATA))) // Translate the special empty name into an empty string. aName.clear(); aResult.insert( - ScCheckListMenuWindow::ResultType::value_type( - aName, itr->second)); + std::unordered_map<OUString, bool, OUStringHash>::value_type( + aName, itr->bValid)); } else { // This is a layout name. Get the original member name and use it. aResult.insert( - ScCheckListMenuWindow::ResultType::value_type( - itrNameMap->second, itr->second)); + std::unordered_map<OUString, bool, OUStringHash>::value_type( + itrNameMap->second, itr->bValid)); } } pDim->UpdateMemberVisibility(aResult); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits