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

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


 include/xmloff/xmltoken.hxx                      |    1 
 sc/inc/strings.hrc                               |    2 +
 sc/qa/unit/data/ods/autofilter-colors.ods        |binary
 sc/qa/unit/subsequent_export-test.cxx            |   35 +++++++++++++++++++----
 sc/source/core/data/column3.cxx                  |    6 +--
 sc/source/filter/xml/XMLExportDatabaseRanges.cxx |   17 +++++++++--
 sc/source/filter/xml/xmlfilti.cxx                |    6 +++
 sc/source/ui/view/gridwin.cxx                    |   14 +++++++--
 xmloff/source/core/xmltoken.cxx                  |    1 
 xmloff/source/token/tokens.txt                   |    1 
 10 files changed, 68 insertions(+), 15 deletions(-)

New commits:
commit 66c025310b0b85cd8fd98b5dcbe77a161fe2ed36
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Tue Aug 24 15:03:10 2021 +0200
Commit:     Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Thu Sep 9 10:58:45 2021 +0200

    tdf#142965 color filter: allow filtering by no fill/automatic color
    
    Change-Id: Idd0a41cea936fd19adbc07561b0d9c0cba735f0d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120946
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    (cherry picked from commit ba1e42f05e785c30d03553acd5647eebd7cdede6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121706
    Tested-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 5421a90da5cb..cedcce7d2860 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -2083,6 +2083,7 @@ namespace xmloff { namespace token {
         XML_WHOLE_PAGE,
         XML_WIDOWS,
         XML_WIDTH,
+        XML_WINDOW_FONT_COLOR,
         XML_WORD,
         XML_WORD_COUNT,
         XML_WRAP,
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 95833ec5b2f2..ea550b491521 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -37,6 +37,8 @@
 #define SCSTR_FILTER_NOTEMPTY                       NC_("SCSTR_FILTER_NOTEMPTY", "Not Empty")
 #define SCSTR_FILTER_TEXT_COLOR                     NC_("SCSTR_FILTER_TEXT_COLOR", "Text color")
 #define SCSTR_FILTER_BACKGROUND_COLOR               NC_("SCSTR_FILTER_BACKGROUND_COLOR", "Background color")
+#define SCSTR_FILTER_NO_FILL                        NC_("SCSTR_FILTER_NO_FILL", "No fill")
+#define SCSTR_FILTER_AUTOMATIC_COLOR                NC_("SCSTR_FILTER_AUTOMATIC_COLOR", "Automatic")
 #define SCSTR_NONAME                                NC_("SCSTR_NONAME", "unnamed")
 // "%1 is replaced to column letter, such as 'Column A'"
 #define SCSTR_COLUMN                                NC_("SCSTR_COLUMN", "Column %1")
diff --git a/sc/qa/unit/data/ods/autofilter-colors.ods b/sc/qa/unit/data/ods/autofilter-colors.ods
index d5a88e9299fb..ad7c768412ea 100644
Binary files a/sc/qa/unit/data/ods/autofilter-colors.ods and b/sc/qa/unit/data/ods/autofilter-colors.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index ff2a2613d466..475dee2fc742 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -4065,13 +4065,38 @@ void ScExportTest::testAutofilterColorsODF()
     ScDocShellRef xDocSh = loadDoc(u"autofilter-colors.", FORMAT_ODS);
     CPPUNIT_ASSERT(xDocSh.is());
 
-    xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "content.xml", FORMAT_ODS);
+    xmlDocPtr pDoc
+        = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "content.xml", FORMAT_ODS);
     CPPUNIT_ASSERT(pDoc);
 
-    assertXPath(pDoc, "//table:filter/table:filter-and/table:filter-condition[1]", "value", "#e8f2a1");
-    assertXPath(pDoc, "//table:filter/table:filter-and/table:filter-condition[1][@loext:data-type='background-color']");
-    assertXPath(pDoc, "//table:filter/table:filter-and/table:filter-condition[2]", "value", "#3465a4");
-    assertXPath(pDoc, "//table:filter/table:filter-and/table:filter-condition[2][@loext:data-type='text-color']");
+    assertXPath(pDoc,
+                "//table:database-ranges/table:database-range[1]/table:filter/table:filter-and/"
+                "table:filter-condition[1]",
+                "value", "#e8f2a1");
+    assertXPath(pDoc,
+                "//table:database-ranges/table:database-range[1]/table:filter/table:filter-and/"
+                "table:filter-condition[1][@loext:data-type='background-color']");
+    assertXPath(pDoc,
+                "//table:database-ranges/table:database-range[1]/table:filter/table:filter-and/"
+                "table:filter-condition[2]",
+                "value", "#3465a4");
+    assertXPath(pDoc, "//table:database-ranges/table:database-range[1]/table:filter/"
+                      "table:filter-and/table:filter-condition[2][@loext:data-type='text-color']");
+
+    // tdf#142965 Check "none" value when automatic text color / no fill was selected
+    assertXPath(pDoc, "//table:database-ranges/table:database-range[2]/table:filter/"
+                      "table:filter-and/"
+                      "table:filter-condition[1][@loext:data-type='background-color']");
+    assertXPath(pDoc,
+                "//table:database-ranges/table:database-range[2]/table:filter/table:filter-and/"
+                "table:filter-condition[1]",
+                "value", "transparent");
+    assertXPath(pDoc, "//table:database-ranges/table:database-range[3]/table:filter/"
+                      "table:filter-and/table:filter-condition[1][@loext:data-type='text-color']");
+    assertXPath(pDoc,
+                "//table:database-ranges/table:database-range[3]/table:filter/table:filter-and/"
+                "table:filter-condition[1]",
+                "value", "window-font-color");
 }
 
 void ScExportTest::testAutofilterColorsOOXML()
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 4ee065ad92aa..9923e657f247 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2415,13 +2415,11 @@ class FilterEntriesHandler
         ScAddress aPos(rColumn.GetCol(), nRow, rColumn.GetTab());
         const SvxColorItem* pColor = rColumn.GetDoc()->GetAttr(aPos, ATTR_FONT_COLOR);
         Color textColor = pColor->GetValue();
-        if (textColor != COL_AUTO)
-            mrFilterEntries.addTextColor(textColor);
+        mrFilterEntries.addTextColor(textColor);
 
         const SvxBrushItem* pBrush = rColumn.GetDoc()->GetAttr(aPos, ATTR_BACKGROUND);
         Color backgroundColor = pBrush->GetColor();
-        if (backgroundColor != COL_AUTO)
-            mrFilterEntries.addBackgroundColor(backgroundColor);
+        mrFilterEntries.addBackgroundColor(backgroundColor);
 
         if (rCell.hasString())
         {
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 687168abe5cf..d378bd47e5ba 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -453,9 +453,20 @@ private:
                                               XML_BACKGROUND_COLOR);
                 }
 
-                OUStringBuffer buffer;
-                sax::Converter::convertColor(buffer, rItem.maColor);
-                mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, buffer.makeStringAndClear());
+                OUString colorValue;
+                if (rItem.maColor == COL_AUTO) // tdf#142965
+                {
+                    colorValue = rItem.meType == ScQueryEntry::ByTextColor
+                                     ? GetXMLToken(XML_WINDOW_FONT_COLOR)
+                                     : GetXMLToken(XML_TRANSPARENT);
+                }
+                else
+                {
+                    OUStringBuffer buffer;
+                    sax::Converter::convertColor(buffer, rItem.maColor);
+                    colorValue = buffer.makeStringAndClear();
+                }
+                mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, colorValue);
             }
             else
             {
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 000dbdfaf302..2c2726c45bd7 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -444,7 +444,11 @@ void SAL_CALL ScXMLConditionContext::endFastElement( sal_Int32 /*nElement*/ )
         {
             rItem.meType = IsXMLToken(sDataType, XML_TEXT_COLOR) ? ScQueryEntry::ByTextColor
                                                                  : ScQueryEntry::ByBackgroundColor;
-            sax::Converter::convertColor(rItem.maColor, sConditionValue);
+            if (IsXMLToken(sConditionValue, XML_TRANSPARENT)
+                || IsXMLToken(sConditionValue, XML_WINDOW_FONT_COLOR))
+                rItem.maColor = COL_AUTO;
+            else
+                sax::Converter::convertColor(rItem.maColor, sConditionValue);
         }
         else
         {
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 02a8d9e8f370..7a84eb74405c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -890,8 +890,18 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
                 sal_Int32 nActive = -1;
                 for (auto& rColor : aColors)
                 {
-                    pColorMenu->InsertItem(i, OUString(), MenuItemBits::CHECKABLE);
-                    pColorMenu->SetItemColor(i, rColor);
+                    if (rColor == COL_AUTO)
+                    {
+                        OUString sText = eMode == AutoFilterMode::TextColor
+                                             ? ScResId(SCSTR_FILTER_AUTOMATIC_COLOR)
+                                             : ScResId(SCSTR_FILTER_NO_FILL);
+                        pColorMenu->InsertItem(i, sText, MenuItemBits::CHECKABLE);
+                    }
+                    else
+                    {
+                        pColorMenu->InsertItem(i, OUString(), MenuItemBits::CHECKABLE);
+                        pColorMenu->SetItemColor(i, rColor);
+                    }
                     auto aItem = pEntry->GetQueryItem();
                     if (aItem.maColor == rColor
                         && ((eMode == AutoFilterMode::TextColor
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 8c2276ab1251..5f0868b4e5c0 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -2085,6 +2085,7 @@ namespace xmloff { namespace token {
         TOKEN( "whole-page",                      XML_WHOLE_PAGE ),
         TOKEN( "widows",                          XML_WIDOWS ),
         TOKEN( "width",                           XML_WIDTH ),
+        TOKEN( "window-font-color",               XML_WINDOW_FONT_COLOR ),
         TOKEN( "word",                            XML_WORD ),
         TOKEN( "word-count",                      XML_WORD_COUNT ),
         TOKEN( "wrap",                            XML_WRAP ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index d2dd36122280..178a5bda3161 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -2000,6 +2000,7 @@ white
 whole-page
 widows
 width
+window-font-color
 word
 word-count
 wrap


More information about the Libreoffice-commits mailing list