diff options
-rw-r--r-- | editeng/source/uno/unotext.cxx | 27 | ||||
-rw-r--r-- | include/editeng/colritem.hxx | 4 | ||||
-rw-r--r-- | include/xmloff/xmltoken.hxx | 2 | ||||
-rw-r--r-- | include/xmloff/xmltypes.hxx | 1 | ||||
-rw-r--r-- | schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 10 | ||||
-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 |
13 files changed, 106 insertions, 5 deletions
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 50aa8a9d632d..16ffaaa8bbfa 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -1133,14 +1133,31 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf if(bItemStateSet) { - if (pMap->nWID == EE_CHAR_COLOR && pMap->nMemberId == MID_COLOR_THEME_INDEX) + if (pMap->nWID == EE_CHAR_COLOR) { - // Theme can be DEFAULT_VALUE, even if the same pool item has a color which is a - // DIRECT_VALUE. + // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color + // which is a DIRECT_VALUE. const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR); - if (pColor->GetThemeIndex() == -1) + switch (pMap->nMemberId) { - eItemState = SfxItemState::DEFAULT; + case MID_COLOR_THEME_INDEX: + if (pColor->GetThemeIndex() == -1) + { + eItemState = SfxItemState::DEFAULT; + } + break; + case MID_COLOR_LUM_MOD: + if (pColor->GetLumMod() == 10000) + { + eItemState = SfxItemState::DEFAULT; + } + break; + case MID_COLOR_LUM_OFF: + if (pColor->GetLumOff() == 0) + { + eItemState = SfxItemState::DEFAULT; + } + break; } } diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx index cd223d2777bc..99ebed218748 100644 --- a/include/editeng/colritem.hxx +++ b/include/editeng/colritem.hxx @@ -83,6 +83,10 @@ public: maTintShade = nTintOrShade; } + sal_Int16 GetLumMod() const { return mnLumMod; } + + sal_Int16 GetLumOff() const { return mnLumOff; } + void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 67885e78cc21..c17ffe8af69a 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -3454,6 +3454,8 @@ namespace xmloff::token { XML_ACCENT6, XML_HLINK, XML_FOLHLINK, + XML_COLOR_LUM_MOD, + XML_COLOR_LUM_OFF, XML_TOKEN_END }; diff --git a/include/xmloff/xmltypes.hxx b/include/xmloff/xmltypes.hxx index 3711e5d5db52..13e7c3fcc6c0 100644 --- a/include/xmloff/xmltypes.hxx +++ b/include/xmloff/xmltypes.hxx @@ -153,6 +153,7 @@ #define XML_TYPE_NEG_PERCENT16 0x00002023 // (100-x) #define XML_TYPE_DOUBLE_PERCENT 0x00002024 // 50% (source is a double from 0.0 to 1.0) #define XML_TYPE_HEX 0x00002025 // 00544F1B +#define XML_TYPE_PERCENT100 0x00002026 // 100th percent // special basic types #define XML_TYPE_RECTANGLE_LEFT 0x00000100 // the Left member of an awt::Rectangle as a measure diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng index e24d3a5e8c8e..ce941afd1b77 100644 --- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng @@ -2118,6 +2118,16 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. </rng:choice> </rng:attribute> </rng:optional> + <rng:optional> + <rng:attribute name="loext:color-lum-mod"> + <rng:ref name="zeroToHundredPercent"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:attribute name="loext:color-lum-off"> + <rng:ref name="zeroToHundredPercent"/> + </rng:attribute> + </rng:optional> </rng:define> <rng:define name="style-text-properties-attlist" combine="interleave"> 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 a61ef6de2717..f13a60082d7d 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -195,10 +195,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 fd486a313aae..298dd431a0fe 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3457,6 +3457,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 ), #if OSL_DEBUG_LEVEL > 0 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 12de9d78a22d..a23326c71f17 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3201,4 +3201,6 @@ accent5 accent6 hlink folHlink +color-lum-mod +color-lum-off TOKEN_END_DUMMY |