include/xmloff/xmltoken.hxx                                 |    2 +
 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |   16 ++++++++--
 sd/source/core/stlsheet.cxx                                 |   16 ++++++++++
 svx/source/table/cell.cxx                                   |   16 ++++++++++
 svx/source/unodraw/unoshape.cxx                             |   16 ++++++++++
 xmloff/qa/unit/data/refer-to-theme.odp                      |binary
 xmloff/qa/unit/draw.cxx                                     |   19 ++++++++++++
 xmloff/source/core/xmltoken.cxx                             |    2 +
 xmloff/source/draw/sdpropls.cxx                             |    2 +
 xmloff/source/token/tokens.txt                              |    2 +
 10 files changed, 88 insertions(+), 3 deletions(-)

New commits:
commit 0c13e4768c3c7937c2fd71675c86ff8a0ca3fe50
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed May 4 20:23:16 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu May 5 08:07:49 2022 +0200

    sd theme: add ODP import/export for shape fill color effects
    
    Map a themed color with effects to:
    
    <style:graphic-properties draw:fill-color="..." 
loext:fill-theme-color="..." loext:fill-color-lum-mod="..." 
loext:fill-color-lum-off="...">
    
    Change-Id: I18d8ddf8d6050ef468a8d67a9e797a576f682e85
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133843
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 4db16a783e2d..5d1dc09e9937 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3486,6 +3486,8 @@ namespace xmloff::token {
         XML_FOLHLINK,
         XML_COLOR_LUM_MOD,
         XML_COLOR_LUM_OFF,
+        XML_FILL_COLOR_LUM_MOD,
+        XML_FILL_COLOR_LUM_OFF,
 
         XML_CONTENT_CONTROL,
         XML_SHOWING_PLACE_HOLDER,
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng 
b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index 511f31629eb4..cc9db62a04a3 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -1762,12 +1762,22 @@ 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
             <rng:ref name="color"/>
           </rng:attribute>
         </rng:optional>
-        <!-- TODO no proposal for theme color of shape fill -->
+        <!-- TODO(vmiklos) no proposal for theme color of shape fill -->
         <rng:optional>
           <rng:attribute name="loext:fill-theme-color">
             <rng:ref name="theme-color"/>
           </rng:attribute>
         </rng:optional>
+        <rng:optional>
+          <rng:attribute name="loext:fill-color-lum-mod">
+            <rng:ref name="zeroToHundredPercent"/>
+          </rng:attribute>
+        </rng:optional>
+        <rng:optional>
+          <rng:attribute name="loext:fill-color-lum-off">
+            <rng:ref name="zeroToHundredPercent"/>
+          </rng:attribute>
+        </rng:optional>
         <rng:optional>
           <rng:attribute name="draw:secondary-fill-color">
             <rng:ref name="color"/>
@@ -2264,7 +2274,7 @@ 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
         <rng:ref name="zeroToHundredPercent"/>
       </rng:attribute>
     </rng:optional>
-    <!-- TODO no proposal for theme color of shape text -->
+    <!-- TODO(vmiklos) no proposal for theme color of shape text -->
     <rng:optional>
       <rng:attribute name="loext:theme-color">
         <rng:ref name="theme-color"/>
@@ -3084,7 +3094,7 @@ 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
         <rng:ref name="office-forms"/>
       </rng:optional>
       <rng:optional>
-        <!-- TODO no proposal for defining a theme -->
+        <!-- TODO(vmiklos) no proposal for defining a theme -->
         <rng:ref name="loext-theme"/>
       </rng:optional>
       <rng:zeroOrMore>
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 48ae9b58c458..619614e7a2a6 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -1326,6 +1326,22 @@ PropertyState SAL_CALL SdStyleSheet::getPropertyState( 
const OUString& PropertyN
                         eState = PropertyState_DEFAULT_VALUE;
                     }
                 }
+                else if (pEntry->nMemberId == MID_COLOR_LUM_MOD)
+                {
+                    const XFillColorItem* pColor = 
rStyleSet.GetItem<XFillColorItem>(pEntry->nWID);
+                    if (pColor->GetThemeColor().GetLumMod() == 10000)
+                    {
+                        eState = PropertyState_DEFAULT_VALUE;
+                    }
+                }
+                else if (pEntry->nMemberId == MID_COLOR_LUM_OFF)
+                {
+                    const XFillColorItem* pColor = 
rStyleSet.GetItem<XFillColorItem>(pEntry->nWID);
+                    if (pColor->GetThemeColor().GetLumOff() == 0)
+                    {
+                        eState = PropertyState_DEFAULT_VALUE;
+                    }
+                }
                 break;
             }
         }
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index 696710da6cd1..27c928eb20f3 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -1455,6 +1455,22 @@ PropertyState SAL_CALL Cell::getPropertyState( const 
OUString& PropertyName )
                             eState = PropertyState_DEFAULT_VALUE;
                         }
                     }
+                    else if (pMap->nMemberId == MID_COLOR_LUM_MOD)
+                    {
+                        const XFillColorItem* pColor = 
rSet.GetItem<XFillColorItem>(pMap->nWID);
+                        if (pColor->GetThemeColor().GetLumMod() == 10000)
+                        {
+                            eState = PropertyState_DEFAULT_VALUE;
+                        }
+                    }
+                    else if (pMap->nMemberId == MID_COLOR_LUM_OFF)
+                    {
+                        const XFillColorItem* pColor = 
rSet.GetItem<XFillColorItem>(pMap->nWID);
+                        if (pColor->GetThemeColor().GetLumOff() == 0)
+                        {
+                            eState = PropertyState_DEFAULT_VALUE;
+                        }
+                    }
                 }
             }
         }
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 32f25b774a00..499c72092f40 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2017,6 +2017,22 @@ beans::PropertyState SvxShape::_getPropertyState( const 
OUString& PropertyName )
                         eState = beans::PropertyState_DEFAULT_VALUE;
                     }
                 }
+                else if (pMap->nMemberId == MID_COLOR_LUM_MOD)
+                {
+                    const XFillColorItem* pColor = 
rSet.GetItem<XFillColorItem>(pMap->nWID);
+                    if (pColor->GetThemeColor().GetLumMod() == 10000)
+                    {
+                        eState = beans::PropertyState_DEFAULT_VALUE;
+                    }
+                }
+                else if (pMap->nMemberId == MID_COLOR_LUM_OFF)
+                {
+                    const XFillColorItem* pColor = 
rSet.GetItem<XFillColorItem>(pMap->nWID);
+                    if (pColor->GetThemeColor().GetLumOff() == 0)
+                    {
+                        eState = beans::PropertyState_DEFAULT_VALUE;
+                    }
+                }
                 break;
             }
         }
diff --git a/xmloff/qa/unit/data/refer-to-theme.odp 
b/xmloff/qa/unit/data/refer-to-theme.odp
index 5fe9832d3eee..2c413ef766f9 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 e45f5bbb444b..3c6d7c707be9 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -242,6 +242,25 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme)
     // i.e. only the direct color was written, but not the theme reference.
     assertXPath(pXmlDoc, 
"//style:style[@style:name='gr2']/style:graphic-properties",
                 "fill-theme-color", "accent1");
+
+    // Shape fill, 60% lighter.
+    assertXPath(pXmlDoc, 
"//style:style[@style:name='gr3']/style:graphic-properties",
+                "fill-theme-color", "accent1");
+    // Without the accompanying fix in place, this test would have failed with:
+    // - XPath '//style:style[@style:name='gr3']/style:graphic-properties' no 
attribute 'fill-color-lum-mod' exist
+    // i.e. the themed color was fine, but its effects were lost.
+    assertXPath(pXmlDoc, 
"//style:style[@style:name='gr3']/style:graphic-properties",
+                "fill-color-lum-mod", "40%");
+    assertXPath(pXmlDoc, 
"//style:style[@style:name='gr3']/style:graphic-properties",
+                "fill-color-lum-off", "60%");
+
+    // Shape fill, 25% darker.
+    assertXPath(pXmlDoc, 
"//style:style[@style:name='gr4']/style:graphic-properties",
+                "fill-theme-color", "accent1");
+    assertXPath(pXmlDoc, 
"//style:style[@style:name='gr4']/style:graphic-properties",
+                "fill-color-lum-mod", "75%");
+    assertXPathNoAttribute(pXmlDoc, 
"//style:style[@style:name='gr4']/style:graphic-properties",
+                           "fill-color-lum-off");
 }
 
 CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape)
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index b84451538ebd..d1485460f83a 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3489,6 +3489,8 @@ namespace xmloff::token {
         TOKEN("folHlink",            XML_FOLHLINK ),
         TOKEN("color-lum-mod",       XML_COLOR_LUM_MOD ),
         TOKEN("color-lum-off",       XML_COLOR_LUM_OFF ),
+        TOKEN("fill-color-lum-mod",  XML_FILL_COLOR_LUM_MOD ),
+        TOKEN("fill-color-lum-off",  XML_FILL_COLOR_LUM_OFF ),
 
         TOKEN("content-control",     XML_CONTENT_CONTROL ),
         TOKEN("showing-place-holder", XML_SHOWING_PLACE_HOLDER ),
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index 49ed30583814..343436f71960 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -107,6 +107,8 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
     GMAP_D("FillColor",                     XML_NAMESPACE_DRAW, 
XML_FILL_COLOR,             XML_TYPE_COLOR, CTF_FILLCOLOR ),
     GMAP_D("FillColor2",                    XML_NAMESPACE_DRAW, 
XML_SECONDARY_FILL_COLOR,   XML_TYPE_COLOR, 0),
     GMAPV("FillColorTheme",                 XML_NAMESPACE_LO_EXT, 
XML_FILL_THEME_COLOR, XML_TYPE_THEME_COLOR, 0, 
SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
+    GMAPV("FillColorLumMod",                XML_NAMESPACE_LO_EXT, 
XML_FILL_COLOR_LUM_MOD, XML_TYPE_PERCENT100, 0, 
SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
+    GMAPV("FillColorLumOff",                XML_NAMESPACE_LO_EXT, 
XML_FILL_COLOR_LUM_OFF, XML_TYPE_PERCENT100, 0, 
SvtSaveOptions::ODFSVER_FUTURE_EXTENDED),
     GMAP( "FillGradientName",               XML_NAMESPACE_DRAW, 
XML_FILL_GRADIENT_NAME,     XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, 
CTF_FILLGRADIENTNAME ),
     GMAP( "FillGradientStepCount",          XML_NAMESPACE_DRAW, 
XML_GRADIENT_STEP_COUNT,    XML_TYPE_NUMBER16, 0 ),
     GMAP( "FillHatchName",                  XML_NAMESPACE_DRAW, 
XML_FILL_HATCH_NAME,        XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, 
CTF_FILLHATCHNAME ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index accdd853e9e1..2acc44abf3f7 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3233,6 +3233,8 @@ hlink
 folHlink
 color-lum-mod
 color-lum-off
+fill-color-lum-mod
+fill-color-lum-off
 content-control
 showing-place-holder
 checked-state

Reply via email to