diff options
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/checklistmenu.hxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 27 |
3 files changed, 31 insertions, 10 deletions
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index a7ae8ddbd960..1e8cb5662d82 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -198,8 +198,6 @@ void ScCheckListMenuControl::executeMenuItem(size_t nPos) return; maMenuItems[nPos].mxAction->execute(); - - terminateAllPopupMenus(); } void ScCheckListMenuControl::setSelectedMenuItem(size_t nPos, bool bSubMenuTimer) diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index a97f519d1fd7..363de1b51a78 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -173,6 +173,12 @@ public: int GetTextWidth(const OUString& rsName) const; int IncreaseWindowWidthToFitText(int nMaxTextWidth); + /** + * Dismiss all visible popup menus and set focus back to the application + * window. This method is called e.g. when a menu action is fired. + */ + void terminateAllPopupMenus(); + private: std::vector<MenuItemData> maMenuItems; @@ -200,12 +206,6 @@ private: void executeMenuItem(size_t nPos); - /** - * Dismiss all visible popup menus and set focus back to the application - * window. This method is called e.g. when a menu action is fired. - */ - void terminateAllPopupMenus(); - void endSubMenu(ScCheckListMenuControl& rSubMenu); struct SubMenuItemData; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1580640dd40a..c6c1f5250bf3 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -745,6 +745,11 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) { ScCheckListMenuControl& rControl = mpAutoFilterPopup->get_widget(); + // Terminate autofilter popup now when there is no further user input needed + bool bColorMode = eMode == AutoFilterMode::TextColor || eMode == AutoFilterMode::BackgroundColor; + if (!bColorMode) + rControl.terminateAllPopupMenus(); + const AutoFilterData* pData = static_cast<const AutoFilterData*>(rControl.getExtendedData()); @@ -833,7 +838,8 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) } // Remove old entries in auto-filter rules - aParam.RemoveAllEntriesByField(rPos.Col()); + if (!bColorMode) + aParam.RemoveAllEntriesByField(rPos.Col()); if( !(eMode == AutoFilterMode::Normal && rControl.isAllSelected() ) ) { @@ -886,19 +892,36 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) std::set<Color> aColors = eMode == AutoFilterMode::TextColor ? aFilterEntries.getTextColors() : aFilterEntries.getBackgroundColors(); + sal_Int32 i = 1; + sal_Int32 nActive = -1; for (auto& rColor : aColors) { pColorMenu->InsertItem(i, OUString(), MenuItemBits::CHECKABLE); pColorMenu->SetItemColor(i, rColor); + auto aItem = pEntry->GetQueryItem(); + if (aItem.maColor == rColor + && ((eMode == AutoFilterMode::TextColor + && aItem.meType == ScQueryEntry::ByTextColor) + || (eMode == AutoFilterMode::BackgroundColor + && aItem.meType == ScQueryEntry::ByBackgroundColor))) + { + nActive = i; + pColorMenu->CheckItem(i, true); + } i++; } sal_uInt16 nSelected = pColorMenu->Execute(this, mpAutoFilterPopup->GetPosPixel()); pColorMenu.disposeAndClear(); + rControl.terminateAllPopupMenus(); if (nSelected == 0) - break; + return; + + // Disable color filter when active color was selected + if (nSelected == nActive) + aParam.RemoveAllEntriesByField(rPos.Col()); // Get selected color from set std::set<Color>::iterator it = aColors.begin(); |