summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-04 20:23:16 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-07-01 15:16:07 +0200
commitff0eb613d8379e68eaf1754273b314afd28e0b00 (patch)
tree1aac86437647be8ea85248e53cce6e3164f70a38
parent4b304a96719f78cf531dc2ce1a67618615f318c7 (diff)
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="..."> (cherry picked from commit 0c13e4768c3c7937c2fd71675c86ff8a0ca3fe50) Change-Id: I18d8ddf8d6050ef468a8d67a9e797a576f682e85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136730 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--include/xmloff/xmltoken.hxx2
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng16
-rw-r--r--sd/source/core/stlsheet.cxx16
-rw-r--r--svx/source/table/cell.cxx16
-rw-r--r--svx/source/unodraw/unoshape.cxx16
-rw-r--r--xmloff/qa/unit/data/refer-to-theme.odpbin17899 -> 20677 bytes
-rw-r--r--xmloff/qa/unit/draw.cxx19
-rw-r--r--xmloff/source/core/xmltoken.cxx2
-rw-r--r--xmloff/source/draw/sdpropls.cxx2
-rw-r--r--xmloff/source/token/tokens.txt2
10 files changed, 88 insertions, 3 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 18f94dac4545..1b5a8eb0fd54 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3484,6 +3484,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 861b4481c1a6..959cc36e00b5 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -1762,13 +1762,23 @@ 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"/>
</rng:attribute>
@@ -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"/>
@@ -3103,7 +3113,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 feff63dbf69a..55b89637c6d1 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 5cb09e43bd35..a156174f56d6 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -1452,6 +1452,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 78285121aa4d..4d7e00b42cdc 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2049,6 +2049,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
--- a/xmloff/qa/unit/data/refer-to-theme.odp
+++ b/xmloff/qa/unit/data/refer-to-theme.odp
Binary files differ
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index 4e05b3f7f788..0b7c93c89073 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -224,6 +224,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_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 1b0adb6d210d..10727ffb2928 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3487,6 +3487,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 1183988d9eae..44d71eb8d9fe 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3231,6 +3231,8 @@ hlink
folHlink
color-lum-mod
color-lum-off
+fill-color-lum-mod
+fill-color-lum-off
content-control
showing-place-holder
checked-state