editeng/source/uno/unotext.cxx                              |   27 ++++++++--
 include/editeng/colritem.hxx                                |    4 +
 include/xmloff/xmltoken.hxx                                 |    2 
 include/xmloff/xmltypes.hxx                                 |    1 
 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |   10 ++++
 xmloff/qa/unit/data/refer-to-theme.odp                      |binary
 xmloff/qa/unit/draw.cxx                                     |   17 ++++++
 xmloff/source/core/xmltoken.cxx                             |    2 
 xmloff/source/style/prhdlfac.cxx                            |    3 +
 xmloff/source/style/xmlbahdl.cxx                            |   30 ++++++++++++
 xmloff/source/style/xmlbahdl.hxx                            |    9 +++
 xmloff/source/text/txtprmap.cxx                             |    4 +
 xmloff/source/token/tokens.txt                              |    2 
 13 files changed, 106 insertions(+), 5 deletions(-)

New commits:
commit 8259a1ac609aaed4cea9c1d4e77c99d50037d287
Author:     Miklos Vajna <[email protected]>
AuthorDate: Mon Dec 13 08:41:10 2021 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Jun 29 09:04:59 2022 +0200

    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 <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

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 85f6ca74847d..1f2e4163d9b1 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3481,6 +3481,8 @@ namespace xmloff::token {
         XML_ACCENT6,
         XML_HLINK,
         XML_FOLHLINK,
+        XML_COLOR_LUM_MOD,
+        XML_COLOR_LUM_OFF,
 
         XML_CONTENT_CONTROL,
         XML_SHOWING_PLACE_HOLDER,
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 b7c2d83b98e8..770ba54816f1 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -2283,6 +2283,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
index 83bad49b5f56..cba4bfda1538 100644
Binary files a/xmloff/qa/unit/data/refer-to-theme.odp and 
b/xmloff/qa/unit/data/refer-to-theme.odp differ
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

Reply via email to