[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sc/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 9 09:02:59 UTC 2021


 sc/source/core/data/column3.cxx |   14 ++++++++++----
 sc/source/core/data/table3.cxx  |   16 +++++++++++++++-
 2 files changed, 25 insertions(+), 5 deletions(-)

New commits:
commit 97184f77739b833d4cb6a2ac54a76cb08b365848
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Tue Aug 31 10:49:51 2021 +0200
Commit:     Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Thu Sep 9 11:02:26 2021 +0200

    tdf#142579 Consider cond. format background colors in color filter
    
    In addition to color scale, consider background colors set by a
    conditional style.
    
    Change-Id: I203c4a5ae87aa7b47c2caafcac703b0a0c1a677c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121474
    Tested-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    (cherry picked from commit 88e81b3c5f7167d7dfc93617c3f9d9d6633ba0ad)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121721
    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 0040844f98ed..3f89d278a903 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2417,9 +2417,12 @@ class FilterEntriesHandler
         // Colors
         ScAddress aPos(rColumn.GetCol(), nRow, rColumn.GetTab());
 
-        // Text color
+        Color backgroundColor;
+        bool bHasConditionalBackgroundColor = false;
+
         Color textColor;
         bool bHasConditionalTextColor = false;
+        // Check text & background color from cond. formatting
         const ScPatternAttr* pPattern
             = mrColumn.GetDoc()->GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
         if (pPattern)
@@ -2431,8 +2434,13 @@ class FilterEntriesHandler
                 const SvxColorItem* pColor = &pPattern->GetItem(ATTR_FONT_COLOR, pCondSet);
                 textColor = pColor->GetValue();
                 bHasConditionalTextColor = true;
+
+                const SvxBrushItem* pBackgroundColor = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
+                backgroundColor = pBackgroundColor->GetColor();
+                bHasConditionalBackgroundColor = true;
             }
         }
+
         if (!bHasConditionalTextColor)
         {
             const SvxColorItem* pColor = rColumn.GetDoc()->GetAttr(aPos, ATTR_FONT_COLOR);
@@ -2440,9 +2448,7 @@ class FilterEntriesHandler
         }
         mrFilterEntries.addTextColor(textColor);
 
-        // Background color
-        Color backgroundColor;
-        bool bHasConditionalBackgroundColor = false;
+        // Color scale needs a different handling
         ScConditionalFormat* pCondFormat
             = rColumn.GetDoc()->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
         if (pCondFormat)
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 1da0019e56fb..3372b8aac247 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2726,9 +2726,23 @@ public:
     {
         ScAddress aPos(nCol, nRow, nTab);
         Color color;
+
         // Background color can be set via conditional formatting - check that first
-        ScConditionalFormat* pCondFormat = mrDoc.GetCondFormat(nCol, nRow, nTab);
         bool bHasConditionalColor = false;
+        const ScPatternAttr* pPattern = mrDoc.GetPattern(nCol, nRow, nTab);
+        if (pPattern)
+        {
+            if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
+            {
+                const SfxItemSet* pCondSet
+                    = mrDoc.GetCondResult(nCol, nRow, nTab);
+                const SvxBrushItem* pBackgroundColor = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
+                color = pBackgroundColor->GetColor();
+                bHasConditionalColor = true;
+            }
+        }
+
+        ScConditionalFormat* pCondFormat = mrDoc.GetCondFormat(nCol, nRow, nTab);
         if (pCondFormat)
         {
             for (size_t i = 0; i < pCondFormat->size(); i++)


More information about the Libreoffice-commits mailing list