diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-12-13 08:41:10 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-06-29 09:04:59 +0200 |
commit | 8259a1ac609aaed4cea9c1d4e77c99d50037d287 (patch) | |
tree | e3c35f5f47ac328cad81443bf757c82a84d611d5 /xmloff | |
parent | ae2b901849bbc6a1a75ea3c9b855676617e0958e (diff) |
ODP import/export: refer to theme from shape text color with effects
Handle luminance modulation and offset (i.e. lighter and darker colors).
(cherry picked from commit 7d1e4d12baa85d47f5945872a3bc186dd6ce1889)
Conflicts:
xmloff/source/token/tokens.txt
Change-Id: I536bbca1ed994e991c7ceac153d6a47cb6ef35f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136528
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/qa/unit/data/refer-to-theme.odp | bin | 14488 -> 14547 bytes | |||
-rw-r--r-- | xmloff/qa/unit/draw.cxx | 17 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/prhdlfac.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/xmlbahdl.cxx | 30 | ||||
-rw-r--r-- | xmloff/source/style/xmlbahdl.hxx | 9 | ||||
-rw-r--r-- | xmloff/source/text/txtprmap.cxx | 4 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 2 |
8 files changed, 67 insertions, 0 deletions
diff --git a/xmloff/qa/unit/data/refer-to-theme.odp b/xmloff/qa/unit/data/refer-to-theme.odp Binary files differindex 83bad49b5f56..cba4bfda1538 100644 --- a/xmloff/qa/unit/data/refer-to-theme.odp +++ b/xmloff/qa/unit/data/refer-to-theme.odp diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 2ea5ec785f44..b354975fd891 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -197,10 +197,27 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme) // i.e. only the direct color was written, but not the theme reference. assertXPath(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties", "theme-color", "accent1"); + assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties", + "color-lum-mod"); + assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T1']/style:text-properties", + "color-lum-off"); + assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "theme-color", "accent1"); + // Without the accompanying fix in place, this test would have failed with: + // - XPath '//style:style[@style:name='T2']/style:text-properties' no attribute 'color-lum-mod' exist + // i.e. effects on a referenced theme color were lost. + assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "color-lum-mod", + "40%"); + assertXPath(pXmlDoc, "//style:style[@style:name='T2']/style:text-properties", "color-lum-off", + "60%"); + assertXPath(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", "theme-color", "accent1"); + assertXPath(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", "color-lum-mod", + "75%"); + assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties", + "color-lum-off"); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 6f6e02ecbe9c..6124ded2dcdb 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3484,6 +3484,8 @@ namespace xmloff::token { TOKEN("accent6", XML_ACCENT6 ), TOKEN("hlink", XML_HLINK ), TOKEN("folHlink", XML_FOLHLINK ), + TOKEN("color-lum-mod", XML_COLOR_LUM_MOD ), + TOKEN("color-lum-off", XML_COLOR_LUM_OFF ), TOKEN("content-control", XML_CONTENT_CONTROL ), TOKEN("showing-place-holder", XML_SHOWING_PLACE_HOLDER ), diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx index d8a9cf32f904..ca96e0421552 100644 --- a/xmloff/source/style/prhdlfac.cxx +++ b/xmloff/source/style/prhdlfac.cxx @@ -200,6 +200,9 @@ std::unique_ptr<XMLPropertyHandler> XMLPropertyHandlerFactory::CreatePropertyHan case XML_TYPE_PERCENT16 : pPropHdl.reset(new XMLPercentPropHdl( 2 )); break; + case XML_TYPE_PERCENT100: + pPropHdl.reset(new XML100thPercentPropHdl); + break; case XML_TYPE_DOUBLE_PERCENT : pPropHdl.reset(new XMLDoublePercentPropHdl); break; diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx index b1fa0c891c86..bc24a16ceb03 100644 --- a/xmloff/source/style/xmlbahdl.cxx +++ b/xmloff/source/style/xmlbahdl.cxx @@ -361,6 +361,36 @@ bool XMLDoublePercentPropHdl::exportXML( OUString& rStrExpValue, const Any& rVal return bRet; } +bool XML100thPercentPropHdl::importXML(const OUString& rStrImpValue, Any& rValue, + const SvXMLUnitConverter&) const +{ + bool bRet = false; + + sal_Int32 nValue = 0; + bRet = sax::Converter::convertPercent(nValue, rStrImpValue); + rValue <<= static_cast<sal_Int16>(nValue * 100); + + return bRet; +} + +bool XML100thPercentPropHdl::exportXML(OUString& rStrExpValue, const Any& rValue, + const SvXMLUnitConverter&) const +{ + bool bRet = false; + sal_Int16 nValue = 0; + + if (rValue >>= nValue) + { + nValue = std::round(static_cast<double>(nValue) / 100); + OUStringBuffer aOut; + sax::Converter::convertPercent(aOut, nValue); + rStrExpValue = aOut.makeStringAndClear(); + bRet = true; + } + + return bRet; +} + XMLNegPercentPropHdl::~XMLNegPercentPropHdl() { diff --git a/xmloff/source/style/xmlbahdl.hxx b/xmloff/source/style/xmlbahdl.hxx index e9120f5e9107..09e392d6cc6b 100644 --- a/xmloff/source/style/xmlbahdl.hxx +++ b/xmloff/source/style/xmlbahdl.hxx @@ -92,6 +92,15 @@ class XMLDoublePercentPropHdl : public XMLPropertyHandler virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; }; +/// Maps between XML percentage and our 100th percent ints. +class XML100thPercentPropHdl : public XMLPropertyHandler +{ + virtual bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter) const override; + virtual bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter) const override; +}; + /** PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT */ diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index f51db1aa2ab6..ce09a85c917a 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -139,6 +139,8 @@ XMLPropertyMapEntry const aXMLParaPropMap[] = MAP_EXT_I("CharTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), MAP_EXT("CharTransparence", XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), MAP_EXT("CharColorTheme", XML_NAMESPACE_LO_EXT, XML_THEME_COLOR, XML_TYPE_THEME_COLOR, 0), + MAP_EXT("CharColorLumMod", XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_MOD, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharColorLumOff", XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_OFF, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0), // RES_CHRATR_CONTOUR MT_E( "CharContoured", STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ), // RES_CHRATR_CROSSEDOUT @@ -483,6 +485,8 @@ XMLPropertyMapEntry const aXMLTextPropMap[] = MAP_EXT_I("CharTransparence", XML_NAMESPACE_DRAW, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), MAP_EXT("CharTransparence", XML_NAMESPACE_LO_EXT, XML_OPACITY, XML_TYPE_NEG_PERCENT16 | XML_TYPE_PROP_TEXT, 0), MAP_EXT("CharColorTheme", XML_NAMESPACE_LO_EXT, XML_THEME_COLOR, XML_TYPE_THEME_COLOR | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharColorLumMod", XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_MOD, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0), + MAP_EXT("CharColorLumOff", XML_NAMESPACE_LO_EXT, XML_COLOR_LUM_OFF, XML_TYPE_PERCENT100 | XML_TYPE_PROP_TEXT, 0), // RES_CHRATR_CONTOUR MT_E( "CharContoured", STYLE, TEXT_OUTLINE, XML_TYPE_BOOL, 0 ), // RES_CHRATR_CROSSEDOUT diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 2ef220bda33c..d41caf51445d 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3228,6 +3228,8 @@ accent5 accent6 hlink folHlink +color-lum-mod +color-lum-off content-control showing-place-holder checked-state |