summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-03-17 20:37:39 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-03-18 08:07:02 +0100
commit1868dea877b0c956ee34e92afad59920e66cad3f (patch)
tree1de6e3485125f09e6d3436c6a2d6b9f1e1bc0b06
parent778bbcede813dd51e11ee61583247db1199eda63 (diff)
sd theme: add ODP import/export for shape fill color
Refer to the 12 pre-defined colors by name + don't write the attribute for the case when there is no theme. Change-Id: I37c984b3371ec878a0d733977f5c937dce27c440 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131717 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--include/xmloff/xmltoken.hxx1
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng53
-rw-r--r--sd/source/core/stlsheet.cxx12
-rw-r--r--svx/source/table/cell.cxx10
-rw-r--r--svx/source/unodraw/unoshape.cxx11
-rw-r--r--xmloff/inc/enummaps.hxx1
-rw-r--r--xmloff/qa/unit/data/refer-to-theme.odpbin14547 -> 17899 bytes
-rw-r--r--xmloff/qa/unit/draw.cxx6
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/draw/sdpropls.cxx4
-rw-r--r--xmloff/source/token/tokens.txt1
11 files changed, 78 insertions, 22 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 26b46bf890d6..22e2459387ec 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3445,6 +3445,7 @@ namespace xmloff::token {
XML_THEME,
XML_THEME_COLOR,
+ XML_FILL_THEME_COLOR,
XML_DK1,
XML_LT1,
XML_DK2,
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index 7b3eff94de1c..63832dbb887f 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -1597,6 +1597,12 @@ 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 -->
+ <rng:optional>
+ <rng:attribute name="loext:fill-theme-color">
+ <rng:ref name="theme-color"/>
+ </rng:attribute>
+ </rng:optional>
<rng:optional>
<rng:attribute name="draw:secondary-fill-color">
<rng:ref name="color"/>
@@ -2093,29 +2099,10 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
<rng:ref name="zeroToHundredPercent"/>
</rng:attribute>
</rng:optional>
- <!-- TODO no proposal -->
+ <!-- TODO no proposal for theme color of shape text -->
<rng:optional>
<rng:attribute name="loext:theme-color">
- <rng:choice>
- <!-- Background 1 -->
- <rng:value>dk1</rng:value>
- <!-- Text 1 -->
- <rng:value>lt1</rng:value>
- <!-- Background 2 -->
- <rng:value>dk2</rng:value>
- <!-- Text 2 -->
- <rng:value>lt2</rng:value>
- <rng:value>accent1</rng:value>
- <rng:value>accent2</rng:value>
- <rng:value>accent3</rng:value>
- <rng:value>accent4</rng:value>
- <rng:value>accent5</rng:value>
- <rng:value>accent6</rng:value>
- <!-- Hyperlink -->
- <rng:value>hlink</rng:value>
- <!-- Followed hyperlink -->
- <rng:value>folHlink</rng:value>
- </rng:choice>
+ <rng:ref name="theme-color"/>
</rng:attribute>
</rng:optional>
<rng:optional>
@@ -2895,7 +2882,7 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
<rng:ref name="office-forms"/>
</rng:optional>
<rng:optional>
- <!-- TODO no proposal -->
+ <!-- TODO no proposal for defining a theme -->
<rng:ref name="loext-theme"/>
</rng:optional>
<rng:zeroOrMore>
@@ -2909,4 +2896,26 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:element>
</rng:define>
+ <rng:define name="theme-color">
+ <rng:choice>
+ <!-- Background 1 -->
+ <rng:value>dk1</rng:value>
+ <!-- Text 1 -->
+ <rng:value>lt1</rng:value>
+ <!-- Background 2 -->
+ <rng:value>dk2</rng:value>
+ <!-- Text 2 -->
+ <rng:value>lt2</rng:value>
+ <rng:value>accent1</rng:value>
+ <rng:value>accent2</rng:value>
+ <rng:value>accent3</rng:value>
+ <rng:value>accent4</rng:value>
+ <rng:value>accent5</rng:value>
+ <rng:value>accent6</rng:value>
+ <!-- Hyperlink -->
+ <rng:value>hlink</rng:value>
+ <!-- Followed hyperlink -->
+ <rng:value>folHlink</rng:value>
+ </rng:choice>
+ </rng:define>
</rng:grammar>
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 30b4bc38eee8..feff63dbf69a 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -51,6 +51,7 @@
#include <svx/sdtayitm.hxx>
#include <svx/sdtaiitm.hxx>
#include <svx/xit.hxx>
+#include <svx/xflclit.hxx>
#include <tools/diagnose_ex.h>
#include <stlsheet.hxx>
#include <sdresid.hxx>
@@ -1315,6 +1316,17 @@ PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyN
if( ( pItem == nullptr ) || pItem->GetName().isEmpty() )
eState = PropertyState_DEFAULT_VALUE;
}
+ break;
+ case XATTR_FILLCOLOR:
+ if (pEntry->nMemberId == MID_COLOR_THEME_INDEX)
+ {
+ const XFillColorItem* pColor = rStyleSet.GetItem<XFillColorItem>(pEntry->nWID);
+ if (pColor->GetThemeColor().GetThemeIndex() == -1)
+ {
+ eState = PropertyState_DEFAULT_VALUE;
+ }
+ }
+ break;
}
}
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index 8f1dbe55ddca..696710da6cd1 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -56,6 +56,7 @@
#include <svx/xflbstit.hxx>
#include <svx/xflbmtit.hxx>
#include <svx/svdpool.hxx>
+#include <svx/xflclit.hxx>
#include <tools/diagnose_ex.h>
@@ -1445,6 +1446,15 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName )
eState = PropertyState_DEFAULT_VALUE;
}
break;
+ case XATTR_FILLCOLOR:
+ if (pMap->nMemberId == MID_COLOR_THEME_INDEX)
+ {
+ const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID);
+ if (pColor->GetThemeColor().GetThemeIndex() == -1)
+ {
+ eState = PropertyState_DEFAULT_VALUE;
+ }
+ }
}
}
}
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index cd301d7b5480..32f25b774a00 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -89,6 +89,7 @@
#include <svx/sdtfsitm.hxx>
#include <svx/svdopath.hxx>
#include <svx/SvxXTextColumns.hxx>
+#include <svx/xflclit.hxx>
#include <memory>
#include <optional>
@@ -2007,6 +2008,16 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName )
eState = beans::PropertyState_DEFAULT_VALUE;
}
break;
+ case XATTR_FILLCOLOR:
+ if (pMap->nMemberId == MID_COLOR_THEME_INDEX)
+ {
+ const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID);
+ if (pColor->GetThemeColor().GetThemeIndex() == -1)
+ {
+ eState = beans::PropertyState_DEFAULT_VALUE;
+ }
+ }
+ break;
}
}
}
diff --git a/xmloff/inc/enummaps.hxx b/xmloff/inc/enummaps.hxx
index ae61adc3433a..a170559af996 100644
--- a/xmloff/inc/enummaps.hxx
+++ b/xmloff/inc/enummaps.hxx
@@ -19,5 +19,6 @@ template <typename EnumT> struct SvXMLEnumMapEntry;
extern SvXMLEnumMapEntry<css::drawing::FillStyle> const aXML_FillStyle_EnumMap[];
extern SvXMLEnumMapEntry<css::drawing::RectanglePoint> const aXML_RefPoint_EnumMap[];
extern SvXMLEnumMapEntry<css::drawing::BitmapMode> const aXML_BitmapMode_EnumMap[];
+extern SvXMLEnumMapEntry<sal_uInt16> const pXML_ThemeColor_Enum[];
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/xmloff/qa/unit/data/refer-to-theme.odp b/xmloff/qa/unit/data/refer-to-theme.odp
index cba4bfda1538..5fe9832d3eee 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 ac0801dce72b..481561ff062a 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -234,6 +234,12 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme)
"75%");
assertXPathNoAttribute(pXmlDoc, "//style:style[@style:name='T3']/style:text-properties",
"color-lum-off");
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - XPath '//style:style[@style:name='gr2']/style:graphic-properties' no attribute 'fill-theme-color' exist
+ // 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");
}
CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape)
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index d1827fcd2915..0b8f36badf13 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3448,6 +3448,7 @@ namespace xmloff::token {
TOKEN("theme", XML_THEME ),
TOKEN("theme-color", XML_THEME_COLOR ),
+ TOKEN("fill-theme-color", XML_FILL_THEME_COLOR ),
TOKEN("dk1", XML_DK1 ),
TOKEN("lt1", XML_LT1 ),
TOKEN("dk2", XML_DK2 ),
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index c554b2411f6e..49ed30583814 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -106,6 +106,7 @@ const XMLPropertyMapEntry aXMLSDProperties[] =
GMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, CTF_FILLSTYLE ),
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),
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 ),
@@ -1281,6 +1282,9 @@ const XMLPropertyHandler* XMLSdPropHdlFactory::GetPropertyHandler( sal_Int32 nTy
case XML_TYPE_TEXT_COLUMNS:
pHdl = new XMLTextColumnsPropertyHandler;
break;
+ case XML_TYPE_THEME_COLOR:
+ pHdl = new XMLConstantsPropertyHandler(pXML_ThemeColor_Enum, XML_TOKEN_INVALID);
+ break;
}
if(pHdl)
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index a5c981a7ce6c..86390065d09b 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3192,6 +3192,7 @@ symmetric
linked-style-name
theme
theme-color
+fill-theme-color
dk1
lt1
dk2