From 38e0e78998153463caf9c3c72ef7f4549ddff0e8 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 25 May 2023 13:55:21 +0900 Subject: xmloff: add color-type attribute to complex color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to identify what the color type of the complex color is. For now we mostly use "theme", but in the future we can also have other types like "rgb",... when the infrastructure for that is built. Change-Id: I38c91d294a191ca3124be4e99050977c9815d23e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152253 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- xmloff/qa/unit/data/theme.fodp | 20 ++++++++++---------- xmloff/qa/unit/draw.cxx | 6 ++++++ xmloff/source/text/XMLComplexColorContext.cxx | 8 ++++++++ xmloff/source/text/XMLComplexColorExport.cxx | 1 + 4 files changed, 25 insertions(+), 10 deletions(-) (limited to 'xmloff') diff --git a/xmloff/qa/unit/data/theme.fodp b/xmloff/qa/unit/data/theme.fodp index b1e719d77959..dd6460281897 100644 --- a/xmloff/qa/unit/data/theme.fodp +++ b/xmloff/qa/unit/data/theme.fodp @@ -351,28 +351,28 @@ - + - + - + - + @@ -490,7 +490,7 @@ - + @@ -532,7 +532,7 @@ - + @@ -625,19 +625,19 @@ - + - + - + @@ -994,4 +994,4 @@ - \ No newline at end of file + diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 7a379579b2e8..d71b41722783 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -243,6 +243,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport) // Text color OString aStyle1( "//style:style[@style:name='T2']/style:text-properties/loext:char-complex-color"); + assertXPath(pXmlDoc, aStyle1, "color-type", "theme"); assertXPath(pXmlDoc, aStyle1, "theme-type", "accent3"); assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "type", "lummod"); assertXPath(pXmlDoc, aStyle1 + "/loext:transformation[1]", "value", "2000"); @@ -251,6 +252,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport) OString aStyle2( "//style:style[@style:name='T3']/style:text-properties/loext:char-complex-color"); + assertXPath(pXmlDoc, aStyle1, "color-type", "theme"); assertXPath(pXmlDoc, aStyle2, "theme-type", "accent3"); assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "type", "lummod"); assertXPath(pXmlDoc, aStyle2 + "/loext:transformation[1]", "value", "6000"); @@ -259,6 +261,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport) OString aStyle3( "//style:style[@style:name='T4']/style:text-properties/loext:char-complex-color"); + assertXPath(pXmlDoc, aStyle1, "color-type", "theme"); assertXPath(pXmlDoc, aStyle3, "theme-type", "accent3"); assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "type", "lummod"); assertXPath(pXmlDoc, aStyle3 + "/loext:transformation[1]", "value", "5000"); @@ -266,6 +269,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport) // Shapes fill color OString aShape1("//style:style[@style:name='gr1']/style:graphic-properties/" "loext:fill-complex-color"); + assertXPath(pXmlDoc, aStyle1, "color-type", "theme"); assertXPath(pXmlDoc, aShape1, "theme-type", "accent2"); assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "type", "lummod"); assertXPath(pXmlDoc, aShape1 + "/loext:transformation[1]", "value", "2000"); @@ -274,6 +278,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport) OString aShape2("//style:style[@style:name='gr2']/style:graphic-properties/" "loext:fill-complex-color"); + assertXPath(pXmlDoc, aStyle1, "color-type", "theme"); assertXPath(pXmlDoc, aShape2, "theme-type", "accent2"); assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "type", "lummod"); assertXPath(pXmlDoc, aShape2 + "/loext:transformation[1]", "value", "6000"); @@ -282,6 +287,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeColorExportImport) OString aShape3("//style:style[@style:name='gr3']/style:graphic-properties/" "loext:fill-complex-color"); + assertXPath(pXmlDoc, aStyle1, "color-type", "theme"); assertXPath(pXmlDoc, aShape3, "theme-type", "accent2"); assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "type", "lummod"); assertXPath(pXmlDoc, aShape3 + "/loext:transformation[1]", "value", "5000"); diff --git a/xmloff/source/text/XMLComplexColorContext.cxx b/xmloff/source/text/XMLComplexColorContext.cxx index a01d6ae195af..3b0a8167ee6e 100644 --- a/xmloff/source/text/XMLComplexColorContext.cxx +++ b/xmloff/source/text/XMLComplexColorContext.cxx @@ -58,6 +58,14 @@ XMLComplexColorContext::XMLComplexColorContext( } break; } + case XML_ELEMENT(LO_EXT, XML_COLOR_TYPE): + { + const OUString aValue = aIter.toString(); + if (aValue == u"theme") + maComplexColor.setType(model::ColorType::Scheme); + // TODO - handle other color types + break; + } default: XMLOFF_WARN_UNKNOWN("xmloff", aIter); break; diff --git a/xmloff/source/text/XMLComplexColorExport.cxx b/xmloff/source/text/XMLComplexColorExport.cxx index 57457e19c656..c4554ad5ec3b 100644 --- a/xmloff/source/text/XMLComplexColorExport.cxx +++ b/xmloff/source/text/XMLComplexColorExport.cxx @@ -48,6 +48,7 @@ void XMLComplexColorExport::exportXML(const uno::Any& rAny, sal_uInt16 nPrefix, XMLTokenEnum nToken = constThemeColorTypeToToken[sal_Int16(aComplexColor.getSchemeType())]; mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_THEME_TYPE, nToken); + mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_COLOR_TYPE, "theme"); SvXMLElementExport aComplexColorElement(mrExport, nPrefix, rLocalName, true, true); for (auto const& rTransform : aComplexColor.getTransformations()) -- cgit