diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-05-10 16:55:53 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-05-11 07:36:33 +0200 |
commit | 69b376d21dfe43482f67ece137421a7487f0cbae (patch) | |
tree | 9dbf0df372cf648b8dd6ac705da291d835e3372c /sc/source/ui/view | |
parent | a80eefb7413245f81692c443b06f7d3a6a92f28c (diff) |
tdf#76258 Various fixes for color filter
Change-Id: Ifb4114597efcb7a957d2e42867d1bdc8abfe7730
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115340
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sc/source/ui/view')
-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(); |