diff options
Diffstat (limited to 'sc/source/ui/view/gridwin.cxx')
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 27 |
1 files changed, 25 insertions, 2 deletions
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(); |