[Libreoffice-commits] core.git: include/xmloff schema/libreoffice sc/qa sc/source xmloff/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 4 11:03:08 UTC 2021
include/xmloff/xmltoken.hxx | 1
sc/qa/unit/data/ods/autofilter-colors.ods |binary
sc/qa/unit/subsequent_export-test.cxx | 16 +++++++
sc/source/filter/xml/XMLExportDatabaseRanges.cxx | 26 ++++++++++--
sc/source/filter/xml/xmlfilti.cxx | 9 ++++
schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng | 12 +++++
xmloff/source/core/xmltoken.cxx | 1
xmloff/source/token/tokens.txt | 1
8 files changed, 62 insertions(+), 4 deletions(-)
New commits:
commit e2bdd31c0231444f1ba1463bffb5656c230c3073
Author: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Wed Apr 28 16:25:42 2021 +0200
Commit: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
CommitDate: Tue May 4 13:02:27 2021 +0200
tdf#76258 Add ODF import/export
XML looks like:
<table:filter-condition table:field-number="0" loext:data-type="background-color" table:value="#ffd7d7" table:operator="="/>
<table:filter-condition table:field-number="1" loext:data-type="text-color" table:value="#3465a4" table:operator="="/>
Change-Id: Idcddf0ce436da69567e5a7e9dfd7d796dc872586
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114812
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 12a0632a5af7..b75907d8cba4 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1914,6 +1914,7 @@ namespace xmloff::token {
XML_TEXT_BACKGROUND_COLOR,
XML_TEXT_BLINKING,
XML_TEXT_BOX,
+ XML_TEXT_COLOR,
XML_TEXT_COMBINE,
XML_TEXT_COMBINE_END_CHAR,
XML_TEXT_COMBINE_START_CHAR,
diff --git a/sc/qa/unit/data/ods/autofilter-colors.ods b/sc/qa/unit/data/ods/autofilter-colors.ods
new file mode 100644
index 000000000000..d5a88e9299fb
Binary files /dev/null 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 b25aae6c4ab4..01cf0a236a24 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -218,6 +218,7 @@ public:
void testTdf95640_ods_to_xlsx_with_standard_list();
void testTdf95640_xlsx_to_xlsx();
void testDateAutofilterXLSX();
+ void testAutofilterColorsODF();
void testRefStringXLSX();
void testRefStringConfigXLSX();
@@ -404,6 +405,7 @@ public:
CPPUNIT_TEST(testTdf95640_ods_to_xlsx_with_standard_list);
CPPUNIT_TEST(testTdf95640_xlsx_to_xlsx);
CPPUNIT_TEST(testDateAutofilterXLSX);
+ CPPUNIT_TEST(testAutofilterColorsODF);
CPPUNIT_TEST(testRefStringXLSX);
CPPUNIT_TEST(testRefStringConfigXLSX);
@@ -4611,6 +4613,20 @@ void ScExportTest::testDateAutofilterXLSX()
xDocSh->DoClose();
}
+void ScExportTest::testAutofilterColorsODF()
+{
+ ScDocShellRef xDocSh = loadDoc(u"autofilter-colors.", FORMAT_ODS);
+ CPPUNIT_ASSERT(xDocSh.is());
+
+ xmlDocUniquePtr 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']");
+}
+
void ScExportTest::testTdf88657ODS()
{
ScDocShellRef xDocSh = loadDoc(u"tdf88657.", FORMAT_ODS);
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index d329bdf2385f..c3f651e5416b 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -448,10 +448,6 @@ private:
return;
}
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(rEntry.nField - nFieldStart));
- if (bCaseSens)
- mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
-
if (rItems.size() == 1)
{
// Single item condition.
@@ -463,6 +459,22 @@ private:
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_TEXT);
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, rItem.maString.getString());
}
+ else if (rItem.meType == ScQueryEntry::ByTextColor
+ || rItem.meType == ScQueryEntry::ByBackgroundColor)
+ {
+ if (mrExport.getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
+ {
+ if (rItem.meType == ScQueryEntry::ByTextColor)
+ mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_DATA_TYPE, XML_TEXT_COLOR);
+ else
+ mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_DATA_TYPE,
+ XML_BACKGROUND_COLOR);
+ }
+
+ OUStringBuffer buffer;
+ sax::Converter::convertColor(buffer, rItem.maColor);
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, buffer.makeStringAndClear());
+ }
else
{
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, XML_NUMBER);
@@ -472,6 +484,9 @@ private:
}
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, getOperatorXML(rEntry, eSearchType));
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(rEntry.nField - nFieldStart));
+ if (bCaseSens)
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
SvXMLElementExport aElemC(mrExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, true, true);
}
else
@@ -495,6 +510,9 @@ private:
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_VALUE, rItem.maString.getString());
}
mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_OPERATOR, OUString("="));
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_FIELD_NUMBER, OUString::number(rEntry.nField - nFieldStart));
+ if (bCaseSens)
+ mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, XML_TRUE);
SvXMLElementExport aElemC(mrExport, XML_NAMESPACE_TABLE, XML_FILTER_CONDITION, true, true);
std::for_each(rItems.begin(), rItems.end(), WriteSetItem(mrExport, mpDoc));
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index 7e22395a90d9..3990849cf6a4 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -26,6 +26,7 @@
#include <document.hxx>
#include <o3tl/safeint.hxx>
+#include <sax/tools/converter.hxx>
#include <svl/sharedstringpool.hxx>
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlnamespace.hxx>
@@ -304,6 +305,7 @@ ScXMLConditionContext::ScXMLConditionContext(
}
break;
case XML_ELEMENT( TABLE, XML_DATA_TYPE ):
+ case XML_ELEMENT( LO_EXT, XML_DATA_TYPE ):
{
sDataType = aIter.toString();
}
@@ -425,6 +427,13 @@ void SAL_CALL ScXMLConditionContext::endFastElement( sal_Int32 /*nElement*/ )
rItem.mfVal = sConditionValue.toDouble();
rItem.meType = ScQueryEntry::ByValue;
}
+ else if (IsXMLToken(sDataType, XML_TEXT_COLOR)
+ || IsXMLToken(sDataType, XML_BACKGROUND_COLOR))
+ {
+ rItem.meType = IsXMLToken(sDataType, XML_TEXT_COLOR) ? ScQueryEntry::ByTextColor
+ : ScQueryEntry::ByBackgroundColor;
+ sax::Converter::convertColor(rItem.maColor, sConditionValue);
+ }
else
{
svl::SharedStringPool& rPool = GetScImport().GetDocument()->GetSharedStringPool();
diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
index 8907ac4eb3b2..7e0dfbb07b6c 100644
--- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
+++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng
@@ -2639,4 +2639,16 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:define>
+ <!-- TODO no proposal -->
+ <rng:define name="table-filter-condition-attlist" combine="interleave">
+ <rng:optional>
+ <rng:attribute name="loext:data-type">
+ <rng:choice>
+ <rng:value>background-color</rng:value>
+ <rng:value>text-color</rng:value>
+ </rng:choice>
+ </rng:attribute>
+ </rng:optional>
+ </rng:define>
+
</rng:grammar>
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 0a2f9104d0a7..f557d0e8102b 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1920,6 +1920,7 @@ namespace xmloff::token {
TOKEN( "text-background-color", XML_TEXT_BACKGROUND_COLOR ),
TOKEN( "text-blinking", XML_TEXT_BLINKING ),
TOKEN( "text-box", XML_TEXT_BOX ),
+ TOKEN( "text-color", XML_TEXT_COLOR ),
TOKEN( "text-combine", XML_TEXT_COMBINE ),
TOKEN( "text-combine-end-char", XML_TEXT_COMBINE_END_CHAR ),
TOKEN( "text-combine-start-char", XML_TEXT_COMBINE_START_CHAR ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 10af0324fee6..53b2f76cbde8 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1827,6 +1827,7 @@ text-autospace
text-background-color
text-blinking
text-box
+text-color
text-combine
text-combine-end-char
text-combine-start-char
More information about the Libreoffice-commits
mailing list