[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sc/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 28 07:55:44 UTC 2021
sc/source/core/data/column3.cxx | 8 ++------
sc/source/core/data/table3.cxx | 20 ++++++++++----------
sc/source/ui/cctrl/checklistmenu.cxx | 2 --
sc/source/ui/inc/checklistmenu.hxx | 12 ++++++------
sc/source/ui/view/gridwin.cxx | 27 +++++++++++++++++++++++++--
5 files changed, 43 insertions(+), 26 deletions(-)
New commits:
commit 7a249a23e73564e72916ad877a49ae2d6484ff6b
Author: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Mon May 10 16:55:53 2021 +0200
Commit: Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Mon Jun 28 09:55:12 2021 +0200
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 at allotropia.de>
(cherry picked from commit 69b376d21dfe43482f67ece137421a7487f0cbae)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116590
Tested-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 196369e54da8..cc3eee96f2cd 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2418,12 +2418,12 @@ class FilterEntriesHandler
const SvxBrushItem* pBrush = rColumn.GetDoc()->GetAttr(aPos, ATTR_BACKGROUND);
Color backgroundColor = pBrush->GetColor();
+ mrFilterEntries.addTextColor(textColor);
+ mrFilterEntries.addBackgroundColor(backgroundColor);
if (rCell.hasString())
{
mrFilterEntries.push_back(ScTypedStrData(aStr));
- mrFilterEntries.addTextColor(textColor);
- mrFilterEntries.addBackgroundColor(backgroundColor);
return;
}
@@ -2446,8 +2446,6 @@ class FilterEntriesHandler
if (!aErr.isEmpty())
{
mrFilterEntries.push_back(ScTypedStrData(aErr));
- mrFilterEntries.addTextColor(textColor);
- mrFilterEntries.addBackgroundColor(backgroundColor);
return;
}
}
@@ -2475,8 +2473,6 @@ class FilterEntriesHandler
}
// maybe extend ScTypedStrData enum is also an option here
mrFilterEntries.push_back(ScTypedStrData(aStr, fVal, ScTypedStrData::Value,bDate));
- mrFilterEntries.addTextColor(textColor);
- mrFilterEntries.addBackgroundColor(backgroundColor);
}
public:
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 60357a32d634..8c9153f302d9 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2809,31 +2809,31 @@ bool ScTable::ValidQuery(
{
for (const auto& rItem : rItems)
{
- if (aEval.isQueryByValue(rItem, nCol, nRow, aCell))
+ if (rItem.meType == ScQueryEntry::ByTextColor)
{
- std::pair<bool,bool> aThisRes =
- aEval.compareByValue(aCell, nCol, nRow, rEntry, rItem, pContext);
+ std::pair<bool, bool> aThisRes
+ = aEval.compareByTextColor(nCol, nRow, nTab, rItem);
aRes.first |= aThisRes.first;
aRes.second |= aThisRes.second;
}
- else if (aEval.isQueryByString(rEntry, rItem, nCol, nRow, aCell))
+ else if (rItem.meType == ScQueryEntry::ByBackgroundColor)
{
std::pair<bool,bool> aThisRes =
- aEval.compareByString(aCell, nRow, rEntry, rItem, pContext);
+ aEval.compareByBackgroundColor(nCol, nRow, nTab, rItem);
aRes.first |= aThisRes.first;
aRes.second |= aThisRes.second;
}
- if (rItem.meType == ScQueryEntry::ByTextColor)
+ else if (aEval.isQueryByValue(rItem, nCol, nRow, aCell))
{
- std::pair<bool, bool> aThisRes
- = aEval.compareByTextColor(nCol, nRow, nTab, rItem);
+ std::pair<bool,bool> aThisRes =
+ aEval.compareByValue(aCell, nCol, nRow, rEntry, rItem, pContext);
aRes.first |= aThisRes.first;
aRes.second |= aThisRes.second;
}
- if (rItem.meType == ScQueryEntry::ByBackgroundColor)
+ else if (aEval.isQueryByString(rEntry, rItem, nCol, nRow, aCell))
{
std::pair<bool,bool> aThisRes =
- aEval.compareByBackgroundColor(nCol, nRow, nTab, rItem);
+ aEval.compareByString(aCell, nRow, rEntry, rItem, pContext);
aRes.first |= aThisRes.first;
aRes.second |= aThisRes.second;
}
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index 462051061e55..fec0468a2bb7 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -453,8 +453,6 @@ void ScMenuFloatingWindow::executeMenuItem(size_t nPos)
return;
maMenuItems[nPos].mpAction->execute();
-
- terminateAllPopupMenus();
}
void ScMenuFloatingWindow::setSelectedMenuItem(size_t nPos, bool bSubMenuTimer, bool bEnsureSubMenu)
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index 2ff574a15252..c62c549f6cc5 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -79,6 +79,12 @@ public:
void getMenuItemPosSize(size_t nPos, Point& rPos, Size& rSize) const;
ScMenuFloatingWindow* getParentMenuWindow() const { return mpParentMenu;}
+ /**
+ * 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.
+ */
+ virtual void terminateAllPopupMenus();
+
protected:
virtual void handlePopupEnd();
@@ -139,12 +145,6 @@ private:
*/
void ensureSubMenuNotVisible();
- /**
- * 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:
struct MenuItemData
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index bb2a40368bfe..b8d89317c271 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -738,6 +738,11 @@ void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos)
void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
{
+ // Terminate autofilter popup now when there is no further user input needed
+ bool bColorMode = eMode == AutoFilterMode::TextColor || eMode == AutoFilterMode::BackgroundColor;
+ if (!bColorMode)
+ mpAutoFilterPopup->terminateAllPopupMenus();
+
const AutoFilterData* pData =
static_cast<const AutoFilterData*>(mpAutoFilterPopup->getExtendedData());
@@ -826,7 +831,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 && mpAutoFilterPopup->isAllSelected() ) )
{
@@ -879,19 +885,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();
+ mpAutoFilterPopup->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();
More information about the Libreoffice-commits
mailing list