[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sc/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 24 12:21:25 UTC 2021


 sc/source/core/data/column3.cxx |   34 +++++++++++++++++++++++++++-------
 sc/source/core/data/table3.cxx  |   24 ++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 9 deletions(-)

New commits:
commit 52596dedfe629a008e198d023ffcae45a8a791ee
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Mon Aug 30 16:01:02 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Sep 24 14:20:48 2021 +0200

    tdf#142580 Consider cond. format text colors in color filter
    
    When using a conditional style to override the text color in conditional formatting,
    the color from the style overrides directly applied text color.
    Consider this in the color filter.
    
    Change-Id: Ieaa1c475d87866de1e2d497127be9d06d1f3d3f1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121311
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122466

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 905fa65a0f08..6532996d7b71 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -46,6 +46,7 @@
 #include <filterentries.hxx>
 #include <conditio.hxx>
 #include <colorscale.hxx>
+#include <stlpool.hxx>
 #include <editeng/brushitem.hxx>
 #include <editeng/colritem.hxx>
 
@@ -2433,14 +2434,34 @@ class FilterEntriesHandler
 
         // Colors
         ScAddress aPos(rColumn.GetCol(), nRow, rColumn.GetTab());
-        const SvxColorItem* pColor = rColumn.GetDoc().GetAttr(aPos, ATTR_FONT_COLOR);
-        Color textColor = pColor->GetValue();
+
+        // Text color
+        Color textColor;
+        bool bHasConditionalTextColor = false;
+        const ScPatternAttr* pPattern
+            = mrColumn.GetDoc().GetPattern(aPos.Col(), aPos.Row(), aPos.Tab());
+        if (pPattern)
+        {
+            if (!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
+            {
+                const SfxItemSet* pCondSet
+                    = mrColumn.GetDoc().GetCondResult(aPos.Col(), aPos.Row(), aPos.Tab());
+                const SvxColorItem* pColor = &pPattern->GetItem(ATTR_FONT_COLOR, pCondSet);
+                textColor = pColor->GetValue();
+                bHasConditionalTextColor = true;
+            }
+        }
+        if (!bHasConditionalTextColor)
+        {
+            const SvxColorItem* pColor = rColumn.GetDoc().GetAttr(aPos, ATTR_FONT_COLOR);
+            textColor = pColor->GetValue();
+        }
         if (textColor != COL_AUTO)
             mrFilterEntries.addTextColor(textColor);
 
-        // Background color can be set via conditional formatting - check that first
+        // Background color
         Color backgroundColor;
-        bool bHasConditionalColor = false;
+        bool bHasConditionalBackgroundColor = false;
         ScConditionalFormat* pCondFormat
             = rColumn.GetDoc().GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
         if (pCondFormat)
@@ -2453,12 +2474,11 @@ class FilterEntriesHandler
                     const ScColorScaleFormat* pColFormat
                         = static_cast<const ScColorScaleFormat*>(aEntry);
                     backgroundColor = *(pColFormat->GetColor(aPos));
-                    bHasConditionalColor = true;
+                    bHasConditionalBackgroundColor = true;
                 }
             }
         }
-
-        if (!bHasConditionalColor)
+        if (!bHasConditionalBackgroundColor)
         {
             const SvxBrushItem* pBrush = rColumn.GetDoc().GetAttr(aPos, ATTR_BACKGROUND);
             backgroundColor = pBrush->GetColor();
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index d41c53a08532..553223c685e9 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2819,8 +2819,28 @@ public:
                                              const ScQueryEntry::Item& rItem)
     {
         ScAddress aPos(nCol, nRow, nTab);
-        const SvxColorItem* pColor = mrDoc.GetAttr(aPos, ATTR_FONT_COLOR);
-        Color color = pColor->GetValue();
+        Color color;
+        bool bHasConditionalColor = false;
+        // Text color can be set via conditional formatting - check that first
+        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 SvxColorItem* pColor = &pPattern->GetItem(ATTR_FONT_COLOR, pCondSet);
+                color = pColor->GetValue();
+                bHasConditionalColor = true;
+            }
+        }
+
+        if (!bHasConditionalColor)
+        {
+            const SvxColorItem* pColor = mrDoc.GetAttr(aPos, ATTR_FONT_COLOR);
+            color = pColor->GetValue();
+        }
+
         bool bMatch = rItem.maColor == color;
         return std::pair<bool, bool>(bMatch, false);
     }


More information about the Libreoffice-commits mailing list