[Libreoffice-commits] core.git: include/xmloff sc/inc sc/qa sc/source xmloff/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 6 06:35:21 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_test2.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, 65 insertions(+), 18 deletions(-)
New commits:
commit ba1e42f05e785c30d03553acd5647eebd7cdede6
Author: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Tue Aug 24 15:03:10 2021 +0200
Commit: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
CommitDate: Mon Sep 6 08:34:47 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>
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index a7a3fc17a4f6..d30f0781b950 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -2114,6 +2114,7 @@ namespace xmloff::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 070c574ba81f..7204a16eb1b6 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")
#define SCSTR_INSERT_RTL NC_("SCSTR_INSERT_RTL", "Shift cells left")
// "%1 is replaced to column letter, such as 'Column A'"
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_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index a25babe59134..12863985d79e 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -725,15 +725,34 @@ void ScExportTest2::testAutofilterColorsODF()
= 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/"
+ 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: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[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 ScExportTest2::testAutofilterColorsOOXML()
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index b236eff858c7..d6f5c6e749f6 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2434,13 +2434,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 437b2704f5a9..92fe12aa24b2 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -458,9 +458,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 7fb8b4e13a84..20a89d5763ec 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -432,7 +432,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 2ef44c4f33ab..1b9a0ba1cf6a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -932,8 +932,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 e3a45924091e..f2f3495671f7 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -2120,6 +2120,7 @@ namespace xmloff::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 3fde556acfee..f52e9c492db9 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -2027,6 +2027,7 @@ white
whole-page
widows
width
+window-font-color
word
word-count
wrap
More information about the Libreoffice-commits
mailing list