editeng/source/items/textitem.cxx                 |   19 +++
 editeng/source/uno/unotext.cxx                    |    6 +
 forms/qa/unoapi/knownissues.xcl                   |    2 
 include/editeng/memberids.h                       |    1 
 include/editeng/unoprnms.hxx                      |    3 
 include/editeng/unotext.hxx                       |    1 
 include/svx/unoshprp.hxx                          |    1 
 oox/Library_oox.mk                                |    1 
 oox/qa/unit/drawingml.cxx                         |   71 +++++++------
 oox/qa/unit/shape.cxx                             |   11 +-
 oox/source/drawingml/fillproperties.cxx           |   21 +++
 oox/source/drawingml/textcharacterproperties.cxx  |   23 +++-
 oox/source/export/drawingml.cxx                   |   99 ++++++++----------
 oox/source/token/properties.txt                   |    2 
 sd/qa/unit/uiimpress.cxx                          |   61 +++++------
 sd/source/core/stlsheet.cxx                       |    9 +
 svx/qa/unit/styles.cxx                            |   43 ++++---
 svx/qa/unit/xoutdev.cxx                           |   47 ++++----
 svx/source/styles/ColorSets.cxx                   |   62 ++++-------
 svx/source/table/cell.cxx                         |    9 +
 svx/source/unodraw/unoprov.cxx                    |    1 
 svx/source/unodraw/unoshap2.cxx                   |    1 
 svx/source/unodraw/unoshape.cxx                   |    9 +
 svx/source/xoutdev/xattr.cxx                      |   15 ++
 sw/qa/core/theme/ThemeTest.cxx                    |    9 +
 sw/source/core/unocore/unomap.cxx                 |    1 
 sw/source/core/unocore/unomap1.cxx                |    2 
 sw/source/core/unocore/unomapproperties.hxx       |    3 
 writerfilter/Library_writerfilter.mk              |    1 
 writerfilter/source/dmapper/DomainMapper.cxx      |  119 ++++++++++++----------
 writerfilter/source/dmapper/PropertyIds.cxx       |    3 
 writerfilter/source/dmapper/PropertyIds.hxx       |    3 
 writerfilter/source/dmapper/TDefTableHandler.cxx  |   38 +++----
 writerfilter/source/dmapper/TDefTableHandler.hxx  |    4 
 writerfilter/source/dmapper/ThemeColorHandler.hxx |   68 ++++++++++++
 35 files changed, 488 insertions(+), 281 deletions(-)

New commits:
commit 197e5f81213d14fdcbff40edf73385ecd4cd9815
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sun Jan 1 23:25:38 2023 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Jan 13 00:49:24 2023 +0000

    introduce {Char,Fill}ColorThemeReference which uses XThemeColor
    
    Adds a unified UNO property for theme colors *ColorTheme
    (CharColorTheme and FillColorTheme) which uses XThemeColor, that
    replaces the properties *Theme, *TintOrShade, *LumOff, *LumMod.
    The properties are still present for backwards compatibility and
    to keep ODF support working in tests as that needs a bigger change.
    
    Reactor the code and tests to accomodate for this change.
    
    Change-Id: If7983decb4ba528b49fe7b5968aa9efc696a9efc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144783
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/editeng/source/items/textitem.cxx 
b/editeng/source/items/textitem.cxx
index bf6017cdcf6d..5a53d6a8e14c 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -77,6 +77,7 @@
 #include <editeng/charreliefitem.hxx>
 #include <editeng/itemtype.hxx>
 #include <editeng/eerdll.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 #include <libxml/xmlwriter.h>
 
 using namespace ::com::sun::star;
@@ -1435,6 +1436,12 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 
nMemberId ) const
             rVal <<= nValue;
             break;
         }
+       case MID_COLOR_THEME_REFERENCE:
+        {
+            auto xThemeColor = model::theme::createXThemeColor(maThemeColor);
+            rVal <<= xThemeColor;
+            break;
+        }
         default:
         {
             rVal <<= mColor;
@@ -1509,6 +1516,18 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, 
sal_uInt8 nMemberId )
             maThemeColor.addTransformation({model::TransformationType::LumOff, 
nLumOff});
         }
         break;
+        case MID_COLOR_THEME_REFERENCE:
+        {
+            css::uno::Reference<css::util::XThemeColor> xThemeColor;
+            if (!(rVal >>= xThemeColor))
+                return false;
+
+            if (xThemeColor.is())
+            {
+                model::theme::setFromXThemeColor(maThemeColor, xThemeColor);
+            }
+        }
+        break;
         default:
         {
             return rVal >>= mColor;
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index e5877a7d2e5a..82a399f00e26 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1175,6 +1175,12 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const 
SfxItemSet* pSet, const Sf
                     }
                     break;
                 }
+                case MID_COLOR_THEME_REFERENCE:
+                    if (pColor->GetThemeColor().getType() == 
model::ThemeColorType::Unknown)
+                    {
+                        eItemState = SfxItemState::DEFAULT;
+                    }
+                    break;
             }
         }
 
diff --git a/forms/qa/unoapi/knownissues.xcl b/forms/qa/unoapi/knownissues.xcl
index 2e8f013ee79b..5d81d139d797 100644
--- a/forms/qa/unoapi/knownissues.xcl
+++ b/forms/qa/unoapi/knownissues.xcl
@@ -147,3 +147,5 @@ 
forms.OGridControlModel::com::sun::star::view::XSelectionSupplier
 
 ### i111333 ###
 forms.OImageControlControl::com::sun::star::awt::XControl
+
+forms.OEditModel::com::sun::star::io::XPersistObject
diff --git a/include/editeng/memberids.h b/include/editeng/memberids.h
index 9b89ebafaefb..0b110cb52c5d 100644
--- a/include/editeng/memberids.h
+++ b/include/editeng/memberids.h
@@ -188,6 +188,7 @@
 #define MID_COLOR_TINT_OR_SHADE 5
 #define MID_COLOR_LUM_MOD       6
 #define MID_COLOR_LUM_OFF       7
+#define MID_COLOR_THEME_REFERENCE 8
 
 
 #endif
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index 8569a3370464..7f82cd0b1fea 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -23,6 +23,7 @@
 inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR = u"CharColor";
 inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_THEME = u"CharColorTheme";
 inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_TINT_OR_SHADE = 
u"CharColorTintOrShade";
+inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_THEME_REFERENCE = 
u"CharColorThemeReference";
 inline constexpr OUStringLiteral UNO_NAME_CHAR_HEIGHT = u"CharHeight";
 inline constexpr OUStringLiteral UNO_NAME_CHAR_POSTURE = u"CharPosture";
 inline constexpr OUStringLiteral UNO_NAME_CHAR_SHADOWED = u"CharShadowed";
@@ -34,6 +35,7 @@ inline constexpr OUStringLiteral UNO_NAME_FILLCOLOR = 
u"FillColor";
 inline constexpr OUStringLiteral UNO_NAME_FILLCOLOR_THEME = u"FillColorTheme";
 inline constexpr OUStringLiteral UNO_NAME_FILLCOLOR_LUM_MOD = 
u"FillColorLumMod";
 inline constexpr OUStringLiteral UNO_NAME_FILLCOLOR_LUM_OFF = 
u"FillColorLumOff";
+inline constexpr OUStringLiteral UNO_NAME_FILLCOLOR_THEME_REFERENCE = 
u"FillColorThemeReference";
 inline constexpr OUStringLiteral UNO_NAME_FILLGRADIENT = u"FillGradient";
 inline constexpr OUStringLiteral UNO_NAME_FILLGRADIENTNAME = 
u"FillGradientName";
 inline constexpr OUStringLiteral UNO_NAME_FILLHATCH = u"FillHatch";
@@ -334,6 +336,7 @@ inline constexpr OUStringLiteral 
UNO_NAME_EDIT_CHAR_COLOR_THEME = u"CharColorThe
 inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE = 
u"CharColorTintOrShade";
 inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD = 
u"CharColorLumMod";
 inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_COLOR_LUM_OFF = 
u"CharColorLumOff";
+inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE = 
u"CharColorThemeReference";
 inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_TRANSPARENCE = 
u"CharTransparence";
 inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_CROSSEDOUT = 
u"CharCrossedOut";
 inline constexpr OUStringLiteral UNO_NAME_EDIT_CHAR_STRIKEOUT = 
u"CharStrikeout";
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 1d6743a0e410..dec8c4cc50a5 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -91,6 +91,7 @@ struct SfxItemPropertyMapEntry;
     { UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE, EE_CHAR_COLOR, 
::cppu::UnoType<sal_Int16>::get(),     0, MID_COLOR_TINT_OR_SHADE }, \
     { UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD,       EE_CHAR_COLOR, 
::cppu::UnoType<sal_Int16>::get(),     0, MID_COLOR_LUM_MOD }, \
     { UNO_NAME_EDIT_CHAR_COLOR_LUM_OFF,       EE_CHAR_COLOR, 
::cppu::UnoType<sal_Int16>::get(),     0, MID_COLOR_LUM_OFF }, \
+    { UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE, EE_CHAR_COLOR,    
::cppu::UnoType<css::uno::XInterface>::get(), 0, MID_COLOR_THEME_REFERENCE }, \
     { u"CharBackColor",                EE_CHAR_BKGCOLOR,   
::cppu::UnoType<sal_Int32>::get(),        0, 0 }, \
     { u"CharBackTransparent",          EE_CHAR_BKGCOLOR,   
::cppu::UnoType<bool>::get(),             0, MID_GRAPHIC_TRANSPARENT }, \
     { UNO_NAME_EDIT_CHAR_ESCAPEMENT,  EE_CHAR_ESCAPEMENT, 
::cppu::UnoType<sal_Int16>::get(),        0, MID_ESC }, \
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 010cbbcd4b36..8af8142c1d43 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -292,6 +292,7 @@
     { UNO_NAME_FILLCOLOR_THEME,   XATTR_FILLCOLOR, 
::cppu::UnoType<sal_Int16>::get(),          0,     MID_COLOR_THEME_INDEX}, \
     { UNO_NAME_FILLCOLOR_LUM_MOD, XATTR_FILLCOLOR, 
::cppu::UnoType<sal_Int16>::get(),          0,     MID_COLOR_LUM_MOD}, \
     { UNO_NAME_FILLCOLOR_LUM_OFF, XATTR_FILLCOLOR, 
::cppu::UnoType<sal_Int16>::get(),          0,     MID_COLOR_LUM_OFF}, \
+    { UNO_NAME_FILLCOLOR_THEME_REFERENCE,   XATTR_FILLCOLOR, 
::cppu::UnoType<css::uno::XInterface>::get(),          0,     
MID_COLOR_THEME_REFERENCE}, \
     { UNO_NAME_GRAPHIC_GRAPHICCROP, SDRATTR_GRAFCROP      , 
::cppu::UnoType<css::text::GraphicCrop>::get(), 0, 0 }, \
     { UNO_NAME_FILLUSESLIDEBACKGROUND, XATTR_FILLUSESLIDEBACKGROUND, 
cppu::UnoType<bool>::get(), 0,   0},
 
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 9943c2e7eb38..7729003a3742 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_Library_use_libraries,oox,\
     cppu \
     cppuhelper \
     editeng \
+    docmodel \
     expwrap \
     drawinglayer \
     docmodel \
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index ab1a73a150c9..2faf2b28e909 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -29,6 +29,8 @@
 #include <com/sun/star/text/XTextRange.hpp>
 #include <com/sun/star/table/XCellRange.hpp>
 
+#include <docmodel/uno/UnoThemeColor.hxx>
+
 #include <comphelper/sequenceashashmap.hxx>
 
 using namespace ::com::sun::star;
@@ -393,24 +395,22 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme)
                                                         uno::UNO_QUERY);
     uno::Reference<beans::XPropertySet> 
xPortion(xPara->createEnumeration()->nextElement(),
                                                  uno::UNO_QUERY);
-    // 4 is accent1, see oox::drawingml::Color::getSchemeColorIndex().
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4),
-                         
xPortion->getPropertyValue("CharColorTheme").get<sal_Int32>());
-    // 60000 in the file, just 100th vs 1000th percents.
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 6000
-    // - Actual  : 10000
-    // i.e. we had the default 100% value, not the value from the file.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6000),
-                         
xPortion->getPropertyValue("CharColorLumMod").get<sal_Int32>());
 
-    // 40000 in the file, just 100th vs 1000th percents.
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 4000
-    // - Actual  : 0
-    // i.e. we had the default 0% value, not the value from the file.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4000),
-                         
xPortion->getPropertyValue("CharColorLumOff").get<sal_Int32>());
+    // Check the theme colors are as expected
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xPortion->getPropertyValue("CharColorThemeReference") 
>>= xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
+                             aThemeColor.getTransformations()[0].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), 
aThemeColor.getTransformations()[0].mnValue);
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
+                             aThemeColor.getTransformations()[1].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), 
aThemeColor.getTransformations()[1].mnValue);
+    }
 }
 
 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTdf132557_footerCustomShapes)
@@ -453,18 +453,31 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeTint)
     uno::Reference<table::XCellRange> xTable;
     CPPUNIT_ASSERT(xShape->getPropertyValue("Model") >>= xTable);
     uno::Reference<beans::XPropertySet> xA1(xTable->getCellByPosition(0, 0), 
uno::UNO_QUERY);
-    sal_Int16 nFillColorTheme{};
-    CPPUNIT_ASSERT(xA1->getPropertyValue("FillColorTheme") >>= 
nFillColorTheme);
-    // This is OK, no problematic effects:
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nFillColorTheme);
-    uno::Reference<beans::XPropertySet> xA2(xTable->getCellByPosition(0, 1), 
uno::UNO_QUERY);
-    CPPUNIT_ASSERT(xA2->getPropertyValue("FillColorTheme") >>= 
nFillColorTheme);
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: -1
-    // - Actual  : 4
-    // i.e. we remembered the theme index, without being able to remember the 
tint effect, leading
-    // to a bad background color.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(-1), nFillColorTheme);
+    // check theme color
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xA1->getPropertyValue("FillColorThemeReference") >>= 
xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        // This is OK, no problematic effects:
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+    }
+
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        uno::Reference<beans::XPropertySet> xA2(xTable->getCellByPosition(0, 
1), uno::UNO_QUERY);
+        CPPUNIT_ASSERT(xA2->getPropertyValue("FillColorThemeReference") >>= 
xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        // Without the accompanying fix in place, this test would have failed 
with:
+        // - Expected: -1
+        // - Actual  : 4
+        // i.e. we remembered the theme index, without being able to remember 
the tint effect, leading
+        // to a bad background color.
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Unknown, 
aThemeColor.getType());
+    }
 }
 
 CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testVert270AndTextRot)
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
index b03266b553f6..b5a3fe8b1113 100644
--- a/oox/qa/unit/shape.cxx
+++ b/oox/qa/unit/shape.cxx
@@ -33,6 +33,7 @@
 #include <rtl/math.hxx>
 #include <svx/svdoashp.hxx>
 #include <tools/color.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 
 using namespace ::com::sun::star;
 
@@ -308,11 +309,15 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, 
testTdf54095_SmartArtThemeTextColor)
     // - Actual  : 16777215 (0xFFFFFF), that is text was white
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x1F497D), nActualColor);
 
-    // clrScheme. For map between name in docx and index from CharColorTheme 
see
+    // clrScheme. For map between name in docx and index from 
CharColorThemeReference see
     // oox::drawingml::Color::getSchemeColorIndex()
     // Without fix the color scheme was "lt1" (1) but should be "dk2" (2).
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(2),
-                         
xPortion->getPropertyValue("CharColorTheme").get<sal_Int16>());
+    uno::Reference<util::XThemeColor> xThemeColor;
+    CPPUNIT_ASSERT(xPortion->getPropertyValue("CharColorThemeReference") >>= 
xThemeColor);
+    CPPUNIT_ASSERT(xThemeColor.is());
+    model::ThemeColor aThemeColor;
+    model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+    CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2, aThemeColor.getType());
 
     if (!bUseGroup)
     {
diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index ef709dd588ef..99fbfa41e990 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -26,6 +26,7 @@
 #include <vcl/graph.hxx>
 #include <vcl/BitmapFilter.hxx>
 #include <vcl/BitmapMonochromeFilter.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/awt/Gradient.hpp>
@@ -448,15 +449,27 @@ void FillProperties::pushToPropMap( ShapePropertyMap& 
rPropMap,
                 if( maFillColor.hasTransparency() )
                     rPropMap.setProperty( ShapeProperty::FillTransparency, 
maFillColor.getTransparency() );
 
+                model::ThemeColor aThemeColor;
                 if (aFillColor == nPhClr)
                 {
-                    rPropMap.setProperty(PROP_FillColorTheme, nPhClrTheme);
+                    
aThemeColor.setType(model::convertToThemeColorType(nPhClrTheme));
+                    rPropMap.setProperty(PROP_FillColorThemeReference, 
model::theme::createXThemeColor(aThemeColor));
                 }
                 else if (maFillColor.getTintOrShade() == 0)
                 {
-                    rPropMap.setProperty(PROP_FillColorTheme, 
maFillColor.getSchemeColorIndex());
-                    rPropMap.setProperty(PROP_FillColorLumMod, 
maFillColor.getLumMod());
-                    rPropMap.setProperty(PROP_FillColorLumOff, 
maFillColor.getLumOff());
+                    
aThemeColor.setType(model::convertToThemeColorType(maFillColor.getSchemeColorIndex()));
+                    if (maFillColor.getLumMod() != 10000)
+                        
aThemeColor.addTransformation({model::TransformationType::LumMod, 
maFillColor.getLumMod()});
+                    if (maFillColor.getLumOff() != 0)
+                        
aThemeColor.addTransformation({model::TransformationType::LumOff, 
maFillColor.getLumOff()});
+                    if (maFillColor.getTintOrShade() > 0)
+                        
aThemeColor.addTransformation({model::TransformationType::Tint, 
maFillColor.getTintOrShade()});
+                    if (maFillColor.getTintOrShade() < 0)
+                    {
+                        sal_Int16 nShade = 
o3tl::narrowing<sal_Int16>(-maFillColor.getTintOrShade());
+                        
aThemeColor.addTransformation({model::TransformationType::Shade, nShade});
+                    }
+                    rPropMap.setProperty(PROP_FillColorThemeReference, 
model::theme::createXThemeColor(aThemeColor));
                 }
 
                 eFillStyle = FillStyle_SOLID;
diff --git a/oox/source/drawingml/textcharacterproperties.cxx 
b/oox/source/drawingml/textcharacterproperties.cxx
index 3bc65ec1bb3d..a22606ef106c 100644
--- a/oox/source/drawingml/textcharacterproperties.cxx
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -26,6 +26,7 @@
 #include <i18nlangtag/languagetag.hxx>
 #include <i18nlangtag/mslangid.hxx>
 #include <editeng/escapementitem.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 #include <oox/helper/helper.hxx>
 #include <oox/helper/propertyset.hxx>
 #include <oox/core/xmlfilterbase.hxx>
@@ -133,11 +134,23 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& 
rPropMap, const XmlFil
                 aColor = aLineColor;
         }
         rPropMap.setProperty(PROP_CharColor, 
aColor.getColor(rFilter.getGraphicHelper()));
-        // set color theme index
-        rPropMap.setProperty(PROP_CharColorTheme, 
aColor.getSchemeColorIndex());
-        rPropMap.setProperty(PROP_CharColorTintOrShade, 
aColor.getTintOrShade());
-        rPropMap.setProperty(PROP_CharColorLumMod, aColor.getLumMod());
-        rPropMap.setProperty(PROP_CharColorLumOff, aColor.getLumOff());
+
+        // set theme color
+        model::ThemeColor aThemeColor;
+        
aThemeColor.setType(model::convertToThemeColorType(aColor.getSchemeColorIndex()));
+        if (aColor.getTintOrShade() > 0)
+            aThemeColor.addTransformation({model::TransformationType::Tint, 
aColor.getTintOrShade()});
+        if (aColor.getTintOrShade() < 0)
+        {
+            sal_Int16 nShade = 
o3tl::narrowing<sal_Int16>(-aColor.getTintOrShade());
+            aThemeColor.addTransformation({model::TransformationType::Shade, 
nShade});
+        }
+        if (aColor.getLumMod() != 10000)
+            aThemeColor.addTransformation({model::TransformationType::LumMod, 
aColor.getLumMod()});
+        if (aColor.getLumOff() != 0)
+            aThemeColor.addTransformation({model::TransformationType::LumOff, 
aColor.getLumOff()});
+
+        rPropMap.setProperty(PROP_CharColorThemeReference, 
model::theme::createXThemeColor(aThemeColor));
         rPropMap.setProperty(PROP_CharContoured, bContoured);
 
         if (aColor.hasTransparency())
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index b98a785eb582..dde41bd16c35 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -125,6 +125,7 @@
 #include <editeng/flditem.hxx>
 #include <editeng/escapementitem.hxx>
 #include <editeng/unonrule.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 #include <svx/svdoashp.hxx>
 #include <svx/svdomedia.hxx>
 #include <svx/svdtrans.hxx>
@@ -433,44 +434,41 @@ void DrawingML::WriteColorTransformations( const 
Sequence< PropertyValue >& aTra
 
 bool DrawingML::WriteCharColor(const 
css::uno::Reference<css::beans::XPropertySet>& xPropertySet)
 {
-    if 
(!xPropertySet->getPropertySetInfo()->hasPropertyByName("CharColorTheme"))
-    {
+    if 
(!xPropertySet->getPropertySetInfo()->hasPropertyByName("CharColorThemeReference"))
         return false;
-    }
 
-    sal_Int32 nCharColorTheme = -1;
-    xPropertySet->getPropertyValue("CharColorTheme") >>= nCharColorTheme;
-    if (nCharColorTheme < 0 || nCharColorTheme > 11)
-    {
+    uno::Reference<util::XThemeColor> xThemeColor;
+    xPropertySet->getPropertyValue("CharColorThemeReference") >>= xThemeColor;
+    if (!xThemeColor.is())
         return false;
-    }
-
-    const char* pColorName = g_aPredefinedClrNames[nCharColorTheme];
 
-    sal_Int32 nCharColorTintOrShade{};
-    xPropertySet->getPropertyValue("CharColorTintOrShade") >>= 
nCharColorTintOrShade;
-    if (nCharColorTintOrShade != 0)
-    {
+    model::ThemeColor aThemeColor;
+    model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+    if (aThemeColor.getType() == model::ThemeColorType::Unknown)
         return false;
-    }
-
+    const char* pColorName = 
g_aPredefinedClrNames[sal_Int16(aThemeColor.getType())];
     mpFS->startElementNS(XML_a, XML_solidFill);
     mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName);
-
-    sal_Int32 nCharColorLumMod{};
-    xPropertySet->getPropertyValue("CharColorLumMod") >>= nCharColorLumMod;
-    if (nCharColorLumMod != 10000)
+    for (auto const& rTransform : aThemeColor.getTransformations())
     {
-        mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, 
OString::number(nCharColorLumMod * 10));
-    }
-
-    sal_Int32 nCharColorLumOff{};
-    xPropertySet->getPropertyValue("CharColorLumOff") >>= nCharColorLumOff;
-    if (nCharColorLumOff != 0)
-    {
-        mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, 
OString::number(nCharColorLumOff * 10));
+        switch (rTransform.meType)
+        {
+            case model::TransformationType::LumMod:
+                mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, 
OString::number(rTransform.mnValue * 10));
+                break;
+            case model::TransformationType::LumOff:
+                mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, 
OString::number(rTransform.mnValue * 10));
+                break;
+            case model::TransformationType::Tint:
+                mpFS->singleElementNS(XML_a, XML_tint, XML_val, 
OString::number(rTransform.mnValue * 10));
+                break;
+            case model::TransformationType::Shade:
+                mpFS->singleElementNS(XML_a, XML_shade, XML_val, 
OString::number(rTransform.mnValue * 10));
+                break;
+            default:
+                break;
+        }
     }
-
     mpFS->endElementNS(XML_a, XML_schemeClr);
     mpFS->endElementNS(XML_a, XML_solidFill);
 
@@ -589,35 +587,34 @@ void DrawingML::WriteSolidFill( const Reference< 
XPropertySet >& rXPropSet )
 
 bool DrawingML::WriteFillColor(const uno::Reference<beans::XPropertySet>& 
xPropertySet)
 {
-    if 
(!xPropertySet->getPropertySetInfo()->hasPropertyByName("FillColorTheme"))
-    {
+    if 
(!xPropertySet->getPropertySetInfo()->hasPropertyByName("FillColorThemeReference"))
         return false;
-    }
 
-    sal_Int32 nFillColorTheme = -1;
-    xPropertySet->getPropertyValue("FillColorTheme") >>= nFillColorTheme;
-    if (nFillColorTheme < 0 || nFillColorTheme > 11)
-    {
+    uno::Reference<util::XThemeColor> xThemeColor;
+    xPropertySet->getPropertyValue("FillColorThemeReference") >>= xThemeColor;
+    if (!xThemeColor.is())
         return false;
-    }
-
-    const char* pColorName = g_aPredefinedClrNames[nFillColorTheme];
 
+    model::ThemeColor aThemeColor;
+    model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+    if (aThemeColor.getType() == model::ThemeColorType::Unknown)
+        return false;
+    const char* pColorName = 
g_aPredefinedClrNames[sal_Int16(aThemeColor.getType())];
     mpFS->startElementNS(XML_a, XML_solidFill);
     mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName);
-
-    sal_Int32 nFillColorLumMod{};
-    xPropertySet->getPropertyValue("FillColorLumMod") >>= nFillColorLumMod;
-    if (nFillColorLumMod != 10000)
+    for (auto const& rTransform : aThemeColor.getTransformations())
     {
-        mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, 
OString::number(nFillColorLumMod * 10));
-    }
-
-    sal_Int32 nFillColorLumOff{};
-    xPropertySet->getPropertyValue("FillColorLumOff") >>= nFillColorLumOff;
-    if (nFillColorLumOff != 0)
-    {
-        mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, 
OString::number(nFillColorLumOff * 10));
+        switch (rTransform.meType)
+        {
+            case model::TransformationType::LumMod:
+                mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, 
OString::number(rTransform.mnValue * 10));
+                break;
+            case model::TransformationType::LumOff:
+                mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, 
OString::number(rTransform.mnValue * 10));
+                break;
+            default:
+                break;
+        }
     }
 
     mpFS->endElementNS(XML_a, XML_schemeClr);
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 5df793846a50..439ecc9cd8a0 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -53,6 +53,7 @@ Change
 CharBackColor
 CharCaseMap
 CharColor
+CharColorThemeReference
 CharContoured
 CharColorTheme
 CharColorTintOrShade
@@ -176,6 +177,7 @@ FillColor
 FillColorTheme
 FillColorLumMod
 FillColorLumOff
+FillColorThemeReference
 FillGradient
 FillGradientName
 FillHatch
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index f01f8e25108e..5655e58c0700 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -43,6 +43,7 @@
 #include <svl/stritem.hxx>
 #include <undo/undomanager.hxx>
 #include <vcl/scheduler.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 
@@ -1020,19 +1021,20 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testCharColorTheme)
         xShapeParaAccess->createEnumeration()->nextElement(), uno::UNO_QUERY);
     uno::Reference<beans::XPropertySet> 
xPortion(xPara->createEnumeration()->nextElement(),
                                                  uno::UNO_QUERY);
-    sal_Int16 nCharColorTheme{};
-    xPortion->getPropertyValue("CharColorTheme") >>= nCharColorTheme;
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 4
-    // - Actual  : -1
-    // i.e. the theme index (accent1) was not set.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nCharColorTheme);
-    sal_Int16 nCharColorLumMod{};
-    xPortion->getPropertyValue("CharColorLumMod") >>= nCharColorLumMod;
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2000), nCharColorLumMod);
-    sal_Int16 nCharColorLumOff{};
-    xPortion->getPropertyValue("CharColorLumOff") >>= nCharColorLumOff;
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(8000), nCharColorLumOff);
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xPortion->getPropertyValue("CharColorThemeReference") 
>>= xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
+                             aThemeColor.getTransformations()[0].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), 
aThemeColor.getTransformations()[0].mnValue);
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
+                             aThemeColor.getTransformations()[1].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), 
aThemeColor.getTransformations()[1].mnValue);
+    }
 }
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorTheme)
@@ -1059,25 +1061,20 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testFillColorTheme)
     Scheduler::ProcessEventsToIdle();
 
     // Then make sure the theme index is not lost when the sidebar sets it:
-    sal_Int16 nFillColorTheme{};
-    xShape->getPropertyValue("FillColorTheme") >>= nFillColorTheme;
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 4
-    // - Actual  : -1
-    // i.e. the theme index was lost during the dispatch of the command.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nFillColorTheme);
-
-    // Then also verify the effects:
-    sal_Int16 nFillColorLumMod = 10000;
-    xShape->getPropertyValue("FillColorLumMod") >>= nFillColorLumMod;
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 4000
-    // - Actual  : 10000
-    // i.e. the theme index was set, but not the effects.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4000), nFillColorLumMod);
-    sal_Int16 nFillColorLumOff = 0;
-    xShape->getPropertyValue("FillColorLumOff") >>= nFillColorLumOff;
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(6000), nFillColorLumOff);
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= 
xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
+                             aThemeColor.getTransformations()[0].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), 
aThemeColor.getTransformations()[0].mnValue);
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
+                             aThemeColor.getTransformations()[1].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), 
aThemeColor.getTransformations()[1].mnValue);
+    }
 }
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorNoColor)
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index b12e280f231f..9575169356c4 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -1391,6 +1391,15 @@ PropertyState SAL_CALL SdStyleSheet::getPropertyState( 
const OUString& PropertyN
                         eState = PropertyState_DEFAULT_VALUE;
                     }
                 }
+                else if (pEntry->nMemberId == MID_COLOR_THEME_REFERENCE)
+                {
+                    const XFillColorItem* pColor = 
rStyleSet.GetItem<XFillColorItem>(pEntry->nWID);
+                    if (pColor->GetThemeColor().getType() == 
model::ThemeColorType::Unknown)
+                    {
+                        eState = PropertyState_DEFAULT_VALUE;
+                    }
+                }
+                break;
                 break;
             }
         }
diff --git a/svx/qa/unit/styles.cxx b/svx/qa/unit/styles.cxx
index e2b356529ca5..3a4aff375fc7 100644
--- a/svx/qa/unit/styles.cxx
+++ b/svx/qa/unit/styles.cxx
@@ -13,6 +13,7 @@
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
 #include <com/sun/star/text/XTextRange.hpp>
+#include <docmodel/uno/UnoThemeColor.hxx>
 
 using namespace ::com::sun::star;
 
@@ -71,28 +72,34 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange)
     uno::Reference<beans::XPropertySet> 
xShape4(xDrawPageShapes->getByIndex(4), uno::UNO_QUERY);
     // Blue.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472c4), 
GetShapeFillColor(xShape4));
-    // The theme index of this filled shape is set by the PPTX import:
-    sal_Int16 nColorTheme = -1;
-    xShape4->getPropertyValue("FillColorTheme") >>= nColorTheme;
-    // 4 means accent1, this was -1 without the PPTX import bit in place.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nColorTheme);
+
+    // The theme color of this filled shape is set by the PPTX import:
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xShape4->getPropertyValue("FillColorThemeReference") 
>>= xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+    }
     uno::Reference<beans::XPropertySet> 
xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY);
     // Blue, lighter.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), 
GetShapeFillColor(xShape5));
     // The theme index, and effects (lum mod, lum off) are set by the PPTX 
import:
-    nColorTheme = -1;
-    xShape5->getPropertyValue("FillColorTheme") >>= nColorTheme;
-    // 4 means accent1, this was -1 without the PPTX import bit in place.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nColorTheme);
-    sal_Int16 nColorLumMod = 10000;
-    xShape5->getPropertyValue("FillColorLumMod") >>= nColorLumMod;
-    // This was 10000 without the PPTX import bit in place.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4000), nColorLumMod);
-    sal_Int16 nColorLumOff = 0;
-    xShape5->getPropertyValue("FillColorLumOff") >>= nColorLumOff;
-    // This was 0 without the PPTX import bit in place.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(6000), nColorLumOff);
-
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xShape5->getPropertyValue("FillColorThemeReference") 
>>= xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
+                             aThemeColor.getTransformations()[0].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), 
aThemeColor.getTransformations()[0].mnValue);
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
+                             aThemeColor.getTransformations()[1].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), 
aThemeColor.getTransformations()[1].mnValue);
+    }
     // When changing the master slide of slide 1 to use the theme of the 
second master slide:
     uno::Reference<drawing::XMasterPageTarget> xDrawPage2(
         xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY);
diff --git a/svx/qa/unit/xoutdev.cxx b/svx/qa/unit/xoutdev.cxx
index 22b304e00579..6cd68a0c8172 100644
--- a/svx/qa/unit/xoutdev.cxx
+++ b/svx/qa/unit/xoutdev.cxx
@@ -19,6 +19,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <svx/xoutbmp.hxx>
 #include <vcl/filter/PDFiumLibrary.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 
 using namespace com::sun::star;
 
@@ -100,31 +101,31 @@ CPPUNIT_TEST_FIXTURE(XOutdevTest, 
testFillColorThemeUnoApi)
     uno::Reference<drawing::XDrawPage> 
xPage(xPagesSupplier->getDrawPages()->getByIndex(0),
                                              uno::UNO_QUERY);
     uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), 
uno::UNO_QUERY);
-    sal_Int16 nExpected = 4; // Accent 1
-    xShape->setPropertyValue("FillColorTheme", uno::Any(nExpected));
-
-    // 80% lighter
-    sal_Int16 nExpectedLumMod = 2000;
-    xShape->setPropertyValue("FillColorLumMod", uno::Any(nExpectedLumMod));
-    sal_Int16 nExpectedLumOff = 8000;
-    xShape->setPropertyValue("FillColorLumOff", uno::Any(nExpectedLumOff));
+    // Set theme color
+    {
+        model::ThemeColor aThemeColor;
+        aThemeColor.setType(model::ThemeColorType::Accent1);
+        aThemeColor.addTransformation({ model::TransformationType::LumMod, 
2000 });
+        aThemeColor.addTransformation({ model::TransformationType::LumOff, 
8000 });
+        xShape->setPropertyValue("FillColorThemeReference",
+                                 
uno::Any(model::theme::createXThemeColor(aThemeColor)));
+    }
 
     // Then make sure the value we read back is the expected one:
-    sal_Int16 nActual = -1;
-    xShape->getPropertyValue("FillColorTheme") >>= nActual;
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 4
-    // - Actual  : -1
-    // i.e. setting the value was broken.
-    CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
-    xShape->getPropertyValue("FillColorLumMod") >>= nActual;
-    // Without the accompanying fix in place, this test would have failed with:
-    // - Expected: 2000
-    // - Actual  : 8000
-    // i.e. FillColorLumOff was set as FillColor, then getting FillColorLumMod 
returned FillColor.
-    CPPUNIT_ASSERT_EQUAL(nExpectedLumMod, nActual);
-    xShape->getPropertyValue("FillColorLumOff") >>= nActual;
-    CPPUNIT_ASSERT_EQUAL(nExpectedLumOff, nActual);
+    {
+        uno::Reference<util::XThemeColor> xThemeColor;
+        CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= 
xThemeColor);
+        CPPUNIT_ASSERT(xThemeColor.is());
+        model::ThemeColor aThemeColor;
+        model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+        CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
+                             aThemeColor.getTransformations()[0].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), 
aThemeColor.getTransformations()[0].mnValue);
+        CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
+                             aThemeColor.getTransformations()[1].meType);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), 
aThemeColor.getTransformations()[1].mnValue);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/styles/ColorSets.cxx b/svx/source/styles/ColorSets.cxx
index 00ffdae3b031..b8a4fa08e157 100644
--- a/svx/source/styles/ColorSets.cxx
+++ b/svx/source/styles/ColorSets.cxx
@@ -26,6 +26,7 @@
 #include <svx/svdpage.hxx>
 #include <svx/svditer.hxx>
 #include <editeng/unoprnms.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
 #include <o3tl/enumrange.hxx>
 #include <utility>
 
@@ -37,57 +38,44 @@ namespace
 void UpdateTextPortionColorSet(const uno::Reference<beans::XPropertySet>& 
xPortion,
                                const svx::ColorSet& rColorSet)
 {
-    sal_Int16 nCharColorTheme = -1;
-    xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME) >>= 
nCharColorTheme;
-    model::ThemeColorType eColorThemeType = 
model::convertToThemeColorType(nCharColorTheme);
+    if 
(!xPortion->getPropertySetInfo()->hasPropertyByName(UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE))
+        return;
 
-    if (eColorThemeType == model::ThemeColorType::Unknown)
+    uno::Reference<util::XThemeColor> xThemeColor;
+    xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE) >>= 
xThemeColor;
+    if (!xThemeColor.is())
         return;
 
-    Color aColor = rColorSet.getColor(eColorThemeType);
-    sal_Int32 nCharColorLumMod{};
-    xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_LUM_MOD) >>= 
nCharColorLumMod;
-    sal_Int32 nCharColorLumOff{};
-    xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_LUM_OFF) >>= 
nCharColorLumOff;
-    if (nCharColorLumMod != 10000 || nCharColorLumOff != 0)
-    {
-        aColor.ApplyLumModOff(nCharColorLumMod, nCharColorLumOff);
-    }
+    model::ThemeColor aThemeColor;
+    model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
 
-    sal_Int32 nCharColorTintOrShade{};
-    xPortion->getPropertyValue(UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE) >>= 
nCharColorTintOrShade;
-    if (nCharColorTintOrShade != 0)
-    {
-        aColor.ApplyTintOrShade(nCharColorTintOrShade);
-    }
+    if (aThemeColor.getType() == model::ThemeColorType::Unknown)
+        return;
+
+    Color aColor = rColorSet.getColor(aThemeColor.getType());
+    aColor = aThemeColor.applyTransformations(aColor);
 
-    xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR,
-                               uno::Any(static_cast<sal_Int32>(aColor)));
+    xPortion->setPropertyValue(UNO_NAME_EDIT_CHAR_COLOR, 
uno::Any(static_cast<sal_Int32>(aColor)));
 }
 
 void UpdateFillColorSet(const uno::Reference<beans::XPropertySet>& xShape, 
const svx::ColorSet& rColorSet)
 {
-    if 
(!xShape->getPropertySetInfo()->hasPropertyByName(UNO_NAME_FILLCOLOR_THEME))
-    {
+    if 
(!xShape->getPropertySetInfo()->hasPropertyByName(UNO_NAME_FILLCOLOR_THEME_REFERENCE))
         return;
-    }
 
-    sal_Int16 nFillColorTheme = -1;
-    xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME) >>= nFillColorTheme;
-    model::ThemeColorType eColorThemeType = 
model::convertToThemeColorType(nFillColorTheme);
-    if (eColorThemeType == model::ThemeColorType::Unknown)
+    uno::Reference<util::XThemeColor> xThemeColor;
+    xShape->getPropertyValue(UNO_NAME_FILLCOLOR_THEME_REFERENCE) >>= 
xThemeColor;
+    if (!xThemeColor.is())
         return;
 
-    Color aColor = rColorSet.getColor(eColorThemeType);
-    sal_Int32 nFillColorLumMod{};
-    xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_MOD) >>= nFillColorLumMod;
-    sal_Int32 nFillColorLumOff{};
-    xShape->getPropertyValue(UNO_NAME_FILLCOLOR_LUM_OFF) >>= nFillColorLumOff;
-    if (nFillColorLumMod != 10000 || nFillColorLumOff != 0)
-    {
-        aColor.ApplyLumModOff(nFillColorLumMod, nFillColorLumOff);
-    }
+    model::ThemeColor aThemeColor;
+    model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+
+    if (aThemeColor.getType() == model::ThemeColorType::Unknown)
+        return;
 
+    Color aColor = rColorSet.getColor(aThemeColor.getType());
+    aColor = aThemeColor.applyTransformations(aColor);
     xShape->setPropertyValue(UNO_NAME_FILLCOLOR, 
uno::Any(static_cast<sal_Int32>(aColor)));
 }
 
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index 4d200239c2e0..b8ca46ce9921 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -1487,6 +1487,15 @@ PropertyState SAL_CALL Cell::getPropertyState( const 
OUString& PropertyName )
                             eState = PropertyState_DEFAULT_VALUE;
                         }
                     }
+                    else if (pMap->nMemberId == MID_COLOR_THEME_REFERENCE)
+                    {
+                        const XFillColorItem* pColor = 
rSet.GetItem<XFillColorItem>(pMap->nWID);
+                        if (pColor->GetThemeColor().getType() == 
model::ThemeColorType::Unknown)
+                        {
+                            eState = PropertyState_DEFAULT_VALUE;
+                        }
+                    }
+                    break;
                 }
             }
         }
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 7eaa1053f9e5..139e9d3ac48e 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -566,6 +566,7 @@ static o3tl::span<SfxItemPropertyMapEntry const> 
ImplGetSvxControlShapePropertyM
         { UNO_NAME_EDIT_CHAR_COLOR,           0,  
cppu::UnoType<sal_Int32>::get(),        0, MID_COLOR_RGB },
         { UNO_NAME_EDIT_CHAR_COLOR_THEME,     0,  
cppu::UnoType<sal_Int16>::get(),        0, MID_COLOR_THEME_INDEX },
         { UNO_NAME_EDIT_CHAR_COLOR_TINT_OR_SHADE, 0, 
cppu::UnoType<sal_Int16>::get(),     0, MID_COLOR_TINT_OR_SHADE },
+        { UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE, 0,  
cppu::UnoType<css::uno::XInterface>::get(), 0, MID_COLOR_THEME_REFERENCE },
         { u"CharBackColor",                    0,  
cppu::UnoType<sal_Int32>::get(),        0, 0 },
         { u"CharBackTransparent",              0,  cppu::UnoType<bool>::get(), 
            0, 0 },
         { u"CharRelief",                       0,  
cppu::UnoType<sal_Int16>::get(),        0, 0 },
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index e2b11927e59a..e4ff92bc3bed 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -608,6 +608,7 @@ const SvxShapeControlPropertyMapping[] =
     { "CharCaseMap", "CharCaseMap" },
     { "CharColorTheme", "CharColorTheme" },
     { "CharColorTintOrShade", "CharColorTintOrShade" },
+    { UNO_NAME_EDIT_CHAR_COLOR_THEME_REFERENCE, "CharColorThemeReference" },
 };
 
 namespace
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 9692df8c130d..794df51242f1 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -1990,6 +1990,15 @@ beans::PropertyState SvxShape::_getPropertyState( const 
OUString& PropertyName )
                         eState = beans::PropertyState_DEFAULT_VALUE;
                     }
                 }
+                else if (pMap->nMemberId == MID_COLOR_THEME_REFERENCE)
+                {
+                    const XFillColorItem* pColor = 
rSet.GetItem<XFillColorItem>(pMap->nWID);
+                    if (pColor->GetThemeColor().getType() == 
model::ThemeColorType::Unknown)
+                    {
+                        eState = beans::PropertyState_DEFAULT_VALUE;
+                    }
+                }
+                break;
                 break;
             }
         }
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 38a9431a47a6..4f402d02c48a 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -36,6 +36,7 @@
 #include <o3tl/any.hxx>
 #include <svl/itempool.hxx>
 #include <editeng/memberids.h>
+#include <docmodel/uno/UnoThemeColor.hxx>
 #include <tools/mapunit.hxx>
 #include <tools/UnitConversion.hxx>
 #include <osl/diagnose.h>
@@ -1948,6 +1949,12 @@ bool XFillColorItem::QueryValue( css::uno::Any& rVal, 
sal_uInt8 nMemberId ) cons
             rVal <<= nValue;
             break;
         }
+        case MID_COLOR_THEME_REFERENCE:
+        {
+            auto xThemeColor = 
model::theme::createXThemeColor(GetThemeColor());
+            rVal <<= xThemeColor;
+            break;
+        }
         default:
         {
             rVal <<= GetColorValue().GetRGBColor();
@@ -1989,6 +1996,14 @@ bool XFillColorItem::PutValue( const css::uno::Any& 
rVal, sal_uInt8 nMemberId )
             
GetThemeColor().addTransformation({model::TransformationType::LumOff, nLumOff});
         }
         break;
+        case MID_COLOR_THEME_REFERENCE:
+        {
+            css::uno::Reference<css::util::XThemeColor> xThemeColor;
+            if (!(rVal >>= xThemeColor))
+                return false;
+            model::theme::setFromXThemeColor(GetThemeColor(), xThemeColor);
+        }
+        break;
         default:
         {
             Color nValue;
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx
index a6591c6b77db..43cc2a669fe2 100644
--- a/sw/qa/core/theme/ThemeTest.cxx
+++ b/sw/qa/core/theme/ThemeTest.cxx
@@ -16,6 +16,9 @@
 #include <drawdoc.hxx>
 #include <IDocumentDrawModelAccess.hxx>
 #include <svx/svdpage.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
+
+using namespace css;
 
 class SwCoreThemeTest : public SwModelTestBase
 {
@@ -32,7 +35,11 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, 
testThemeColorInHeading)
     SwDoc* pDoc = getSwDoc();
     CPPUNIT_ASSERT(pDoc);
 
-    CPPUNIT_ASSERT_EQUAL(sal_Int16(4), getProperty<sal_Int16>(getParagraph(1), 
"CharColorTheme"));
+    auto xThemeColor = 
getProperty<uno::Reference<util::XThemeColor>>(getParagraph(1),
+                                                                      
"CharColorThemeReference");
+    model::ThemeColor aThemeColor;
+    model::theme::setFromXThemeColor(aThemeColor, xThemeColor);
+    CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, 
aThemeColor.getType());
 }
 
 CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testDrawPageThemeExists)
diff --git a/sw/source/core/unocore/unomap.cxx 
b/sw/source/core/unocore/unomap.cxx
index ffff63747b61..0e036bff1884 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1440,6 +1440,7 @@ o3tl::span<const SfxItemPropertyMapEntry> 
SwUnoPropertyMapProvider::GetPropertyM
                     { UNO_NAME_CHAR_COLOR,               RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE,  0 },
                     { UNO_NAME_CHAR_COLOR_THEME,         RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },
                     { UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },
+                    { UNO_NAME_CHAR_COLOR_THEME_REFERENCE,    
RES_CHRATR_COLOR, cppu::UnoType<css::uno::XInterface>::get(), PROPERTY_NONE, 
MID_COLOR_THEME_REFERENCE },
                     // SvxShadowedItem
                     { UNO_NAME_CHAR_SHADOWED,          RES_CHRATR_SHADOWED,    
cppu::UnoType<bool>::get(),               PROPERTY_NONE,  0                     
               },
                     // SvxContouredItem
diff --git a/sw/source/core/unocore/unomap1.cxx 
b/sw/source/core/unocore/unomap1.cxx
index 0d3e6870458f..e5fcd7779607 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -181,6 +181,7 @@ o3tl::span<const SfxItemPropertyMapEntry> 
SwUnoPropertyMapProvider::GetCharStyle
         { UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0 },
         { UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },
         { UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },
+        { UNO_NAME_CHAR_COLOR_THEME_REFERENCE,    RES_CHRATR_COLOR, 
cppu::UnoType<css::uno::XInterface>::get(), PROPERTY_NONE, 
MID_COLOR_THEME_REFERENCE },
         { UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},
         { UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT,  
cppu::UnoType<sal_Int16>::get(),                  PropertyAttribute::MAYBEVOID, 
MID_CROSS_OUT},
         { UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT,  
cppu::UnoType<bool>::get()  ,        PROPERTY_NONE, 0},
@@ -245,6 +246,7 @@ o3tl::span<const SfxItemPropertyMapEntry>  
SwUnoPropertyMapProvider::GetAutoChar
         { UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int32>::get(),           PROPERTY_NONE, 0},
         { UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },
         { UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },
+        { UNO_NAME_CHAR_COLOR_THEME_REFERENCE,    RES_CHRATR_COLOR, 
cppu::UnoType<css::uno::XInterface>::get(), PROPERTY_NONE, 
MID_COLOR_THEME_REFERENCE },
         { UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},
         { UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT,  
cppu::UnoType<sal_Int16>::get(),                  PropertyAttribute::MAYBEVOID, 
MID_CROSS_OUT},
         { UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT,  
cppu::UnoType<bool>::get()  ,        PROPERTY_NONE, 0},
diff --git a/sw/source/core/unocore/unomapproperties.hxx 
b/sw/source/core/unocore/unomapproperties.hxx
index de1a6aa1a2d6..583babbf2e3f 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -127,6 +127,7 @@
         { UNO_NAME_CHAR_COLOR,                          RES_CHRATR_COLOR,      
        cppu::UnoType<sal_Int32>::get(),         PropertyAttribute::MAYBEVOID, 
0                                      }, \
         { UNO_NAME_CHAR_COLOR_THEME,                    RES_CHRATR_COLOR,      
        cppu::UnoType<sal_Int16>::get(),         PropertyAttribute::MAYBEVOID, 
MID_COLOR_THEME_INDEX }, \
         { UNO_NAME_CHAR_COLOR_TINT_OR_SHADE,            RES_CHRATR_COLOR,      
        cppu::UnoType<sal_Int16>::get(),         PropertyAttribute::MAYBEVOID, 
MID_COLOR_TINT_OR_SHADE }, \
+        { UNO_NAME_CHAR_COLOR_THEME_REFERENCE,          RES_CHRATR_COLOR,      
        cppu::UnoType<css::uno::XInterface>::get(),     
PropertyAttribute::MAYBEVOID, MID_COLOR_THEME_REFERENCE }, \
         { UNO_NAME_CHAR_TRANSPARENCE,                   RES_CHRATR_COLOR,      
        cppu::UnoType<sal_Int16>::get(),         PropertyAttribute::MAYBEVOID, 
MID_COLOR_ALPHA }, \
         { UNO_NAME_CHAR_STRIKEOUT,                      RES_CHRATR_CROSSEDOUT, 
        cppu::UnoType<sal_Int16>::get(),         PropertyAttribute::MAYBEVOID, 
MID_CROSS_OUT                          }, \
         { UNO_NAME_CHAR_CROSSED_OUT,                    RES_CHRATR_CROSSEDOUT, 
        cppu::UnoType<bool>::get(),       PropertyAttribute::MAYBEVOID, 
MID_CROSSED_OUT                        }, \
@@ -373,6 +374,7 @@
                     { UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int32>::get(),           PROPERTY_NONE, 0},\
                     { UNO_NAME_CHAR_COLOR_THEME,  RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int16>::get(),           PROPERTY_NONE, MID_COLOR_THEME_INDEX 
}, \
                     { UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(),         PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE 
}, \
+                    { UNO_NAME_CHAR_COLOR_THEME_REFERENCE, RES_CHRATR_COLOR, 
cppu::UnoType<css::uno::XInterface>::get(), PropertyAttribute::MAYBEVOID, 
MID_COLOR_THEME_REFERENCE }, \
                     { UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int16>::get(),           PROPERTY_NONE, MID_COLOR_ALPHA},\
                     { UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT,  
cppu::UnoType<sal_Int16>::get(),                  PropertyAttribute::MAYBEVOID, 
MID_CROSS_OUT},\
                     { UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT,  
cppu::UnoType<bool>::get()  ,        PROPERTY_NONE, 0},\
@@ -485,6 +487,7 @@
                     { UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int32>::get(),           PROPERTY_NONE, 0},  \
                     { UNO_NAME_CHAR_COLOR_THEME,  RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int16>::get(),           PROPERTY_NONE, MID_COLOR_THEME_INDEX 
}, \
                     { UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, 
cppu::UnoType<sal_Int16>::get(),         PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE 
}, \
+                    { UNO_NAME_CHAR_COLOR_THEME_REFERENCE, RES_CHRATR_COLOR, 
cppu::UnoType<css::uno::XInterface>::get(), PropertyAttribute::MAYBEVOID, 
MID_COLOR_THEME_REFERENCE }, \
                     { UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR,      
cppu::UnoType<sal_Int16>::get(),           PROPERTY_NONE, MID_COLOR_ALPHA },  \
                     { UNO_NAME_CHAR_CONTOURED, RES_CHRATR_CONTOUR,    
cppu::UnoType<bool>::get()  ,       PROPERTY_NONE, 0},  \
                     { UNO_NAME_CHAR_EMPHASIS, RES_CHRATR_EMPHASIS_MARK,        
   cppu::UnoType<sal_Int16>::get(),   PROPERTY_NONE, MID_EMPHASIS},   \
diff --git a/writerfilter/Library_writerfilter.mk 
b/writerfilter/Library_writerfilter.mk
index dafc17c959e1..3e0662b4fb35 100644
--- a/writerfilter/Library_writerfilter.mk
+++ b/writerfilter/Library_writerfilter.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,writerfilter,\
     comphelper \
     cppu \
     cppuhelper \
+    docmodel \
     editeng \
     i18nlangtag \
     i18nutil \
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 649b17a1214a..61b4d6d114d4 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -69,6 +69,7 @@
 #include <com/sun/star/text/FontEmphasis.hpp>
 #include <com/sun/star/awt/CharSet.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XThemeColor.hpp>
 #include <comphelper/types.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/sequence.hxx>
@@ -79,6 +80,7 @@
 #include <unotools/mediadescriptor.hxx>
 
 #include "TextEffectsHandler.hxx"
+#include "ThemeColorHandler.hxx"
 #include "CellColorHandler.hxx"
 #include "SectionColumnHandler.hxx"
 #include "GraphicHelpers.hxx"
@@ -338,11 +340,6 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
             if (m_pImpl->GetTopContext())
                 handleUnderlineType(nIntValue, m_pImpl->GetTopContext());
             break;
-        case NS_ooxml::LN_CT_Color_val:
-            if (m_pImpl->GetTopContext())
-                m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR, uno::Any( 
nIntValue ) );
-            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", 
msfilter::util::ConvertColorOU(Color(ColorTransparency,nIntValue)));
-            break;
         case NS_ooxml::LN_CT_Underline_color:
             if (m_pImpl->GetTopContext())
             {
@@ -1030,31 +1027,6 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_FtnEdnRef_id:
             // footnote or endnote reference id - not needed
         break;
-        case NS_ooxml::LN_CT_Color_themeColor:
-            if (m_pImpl->GetTopContext())
-            {
-                sal_Int16 nIndex = 
TDefTableHandler::getThemeColorTypeIndex(nIntValue);
-                if (nIndex >= 0 && nIndex <= 11)
-                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_THEME_INDEX, uno::Any(nIndex));
-            }
-            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"themeColor", TDefTableHandler::getThemeColorTypeString(nIntValue));
-        break;
-        case NS_ooxml::LN_CT_Color_themeTint:
-            if (m_pImpl->GetTopContext())
-            {
-                if (nIntValue != 0)
-                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_TINT_OR_SHADE, 
uno::Any(sal_Int16((256 - nIntValue) * 10000 / 256)));
-            }
-            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeTint", 
OUString::number(nIntValue, 16));
-        break;
-        case NS_ooxml::LN_CT_Color_themeShade:
-            if (m_pImpl->GetTopContext())
-            {
-                if (nIntValue != 0)
-                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_TINT_OR_SHADE, 
uno::Any(sal_Int16((nIntValue - 256) * 10000 / 256)));
-            }
-            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"themeShade", OUString::number(nIntValue, 16));
-        break;
         case NS_ooxml::LN_CT_DocGrid_linePitch:
         {
             //see SwWW8ImplReader::SetDocumentGrid
@@ -2172,8 +2144,70 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
             }
         }
         break;
-    case NS_ooxml::LN_CT_PPr_sectPr:
     case NS_ooxml::LN_EG_RPrBase_color:
+    {
+        writerfilter::Reference<Properties>::Pointer_t pProperties = 
rSprm.getProps();
+        if (pProperties)
+        {
+            auto pThemeColorHandler = std::make_shared<ThemeColorHandler>();
+            pProperties->resolve(*pThemeColorHandler);
+
+            uno::Any 
aThemeColorName(TDefTableHandler::getThemeColorTypeString(pThemeColorHandler->mnIndex));
+            uno::Any 
aThemeColorTint(OUString::number(pThemeColorHandler->mnTint, 16));
+            uno::Any 
aThemeColorShade(OUString::number(pThemeColorHandler->mnShade, 16));
+
+            if (m_pImpl->GetTopContext())
+            {
+                m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR, 
uno::Any(pThemeColorHandler->mnColor));
+
+                auto eType = 
TDefTableHandler::getThemeColorTypeIndex(pThemeColorHandler->mnIndex);
+                if (eType != model::ThemeColorType::Unknown)
+                {
+                    model::ThemeColor aThemeColor;
+                    aThemeColor.setType(eType);
+
+                    if (pThemeColorHandler->mnTint > 0 )
+                    {
+                        sal_Int16 nTint = sal_Int16((256 - 
pThemeColorHandler->mnTint) * 10000 / 256);
+                        
aThemeColor.addTransformation({model::TransformationType::Tint, nTint});
+                    }
+                    if (pThemeColorHandler->mnShade > 0)
+                    {
+                        sal_Int16 nShade = sal_Int16((256 - 
pThemeColorHandler->mnShade) * 10000 / 256);
+                        
aThemeColor.addTransformation({model::TransformationType::Shade, nShade});
+                    }
+
+                    auto xThemeColor = 
model::theme::createXThemeColor(aThemeColor);
+                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_THEME_REFERENCE, 
uno::Any(xThemeColor));
+                }
+
+                uno::Any 
aColorAny(msfilter::util::ConvertColorOU(Color(ColorTransparency, 
pThemeColorHandler->mnColor)));
+                
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, aColorAny, 
true, CHAR_GRAB_BAG);
+
+                if (pThemeColorHandler->mnIndex >= 0)
+                    m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, 
aThemeColorName, true, CHAR_GRAB_BAG);
+
+                if (pThemeColorHandler->mnTint > 0)
+                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_TINT, aThemeColorTint, 
true, CHAR_GRAB_BAG);
+
+                if (pThemeColorHandler->mnShade > 0)
+                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, aThemeColorShade, 
true, CHAR_GRAB_BAG);
+            }
+            {
+                if (pThemeColorHandler->mnIndex >= 0)
+                {
+                    m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"themeColor", aThemeColorName.get<OUString>());
+                    if (pThemeColorHandler->mnTint > 0)
+                        m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"themeTint", aThemeColorTint.get<OUString>());
+                    if (pThemeColorHandler->mnShade > 0)
+                        m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"themeShade", aThemeColorShade.get<OUString>());
+                }
+                m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "color", 
m_pImpl->m_aSubInteropGrabBag);
+            }
+        }
+    }
+    break;
+    case NS_ooxml::LN_CT_PPr_sectPr:
     case NS_ooxml::LN_EG_RPrBase_rFonts:
     case NS_ooxml::LN_EG_RPrBase_eastAsianLayout:
     case NS_ooxml::LN_EG_RPrBase_u:
@@ -2187,12 +2221,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
     case NS_ooxml::LN_CT_PPr_rPr:
     case NS_ooxml::LN_CT_PPrBase_numPr:
     {
-        bool bTempGrabBag = !m_pImpl->isInteropGrabBagEnabled();
         if (nSprmId == NS_ooxml::LN_CT_PPr_sectPr)
             m_pImpl->SetParaSectpr(true);
-        else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color && bTempGrabBag)
-            // if DomainMapper grab bag is not enabled, enable it temporarily
-            m_pImpl->enableInteropGrabBag("TempColorPropsGrabBag");
         resolveSprmProps(*this, rSprm);
         if (nSprmId == NS_ooxml::LN_CT_PPrBase_spacing)
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "spacing", 
m_pImpl->m_aSubInteropGrabBag);
@@ -2200,25 +2230,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "rFonts", 
m_pImpl->m_aSubInteropGrabBag);
         else if (nSprmId == NS_ooxml::LN_EG_RPrBase_lang)
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lang", 
m_pImpl->m_aSubInteropGrabBag);
-        else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color)
-        {
-            for (const auto& rItem : m_pImpl->m_aSubInteropGrabBag)
-            {
-                if (rItem.Name == "val")
-                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_ORIGINAL_COLOR, rItem.Value, 
true, CHAR_GRAB_BAG);
-                else if (rItem.Name == "themeColor")
-                    m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR, 
rItem.Value, true, CHAR_GRAB_BAG);
-                else if (rItem.Name == "themeShade")
-                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_SHADE, rItem.Value, 
true, CHAR_GRAB_BAG);
-                else if (rItem.Name == "themeTint")
-                    
m_pImpl->GetTopContext()->Insert(PROP_CHAR_THEME_COLOR_TINT, rItem.Value, true, 
CHAR_GRAB_BAG);
-            }
-            if (bTempGrabBag)
-                //disable and clear DomainMapper grab bag if it wasn't enabled 
before
-                m_pImpl->disableInteropGrabBag();
-
-            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "color", 
m_pImpl->m_aSubInteropGrabBag);
-        }
         else if (nSprmId == NS_ooxml::LN_CT_PPrBase_ind)
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ind", 
m_pImpl->m_aSubInteropGrabBag);
     }
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx 
b/writerfilter/source/dmapper/PropertyIds.cxx
index 3f966d41f18e..98525149fcf9 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -32,8 +32,7 @@ OUString getPropertyName( PropertyIds eId )
         case PROP_CHAR_SHADOWED:   sName = "CharShadowed"; break;
         case PROP_CHAR_CASE_MAP:   sName = "CharCaseMap"; break;
         case PROP_CHAR_COLOR:      sName = "CharColor"; break;
-        case PROP_CHAR_COLOR_THEME_INDEX: sName = "CharColorTheme"; break;
-        case PROP_CHAR_COLOR_TINT_OR_SHADE: sName = "CharColorTintOrShade"; 
break;
+        case PROP_CHAR_COLOR_THEME_REFERENCE: sName = 
"CharColorThemeReference"; break;
         case PROP_CHAR_RELIEF:     sName = "CharRelief"; break;
         case PROP_CHAR_UNDERLINE:  sName = "CharUnderline"; break;
         case PROP_CHAR_UNDERLINE_COLOR:  sName = "CharUnderlineColor"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx 
b/writerfilter/source/dmapper/PropertyIds.hxx
index bddcbe56447a..52b989bf41c9 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -54,8 +54,7 @@ enum PropertyIds
         ,PROP_CHAR_CASE_MAP
         ,PROP_CHAR_CHAR_KERNING
         ,PROP_CHAR_COLOR
-        ,PROP_CHAR_COLOR_THEME_INDEX
-        ,PROP_CHAR_COLOR_TINT_OR_SHADE
+        ,PROP_CHAR_COLOR_THEME_REFERENCE
         ,PROP_CHAR_COMBINE_IS_ON
         ,PROP_CHAR_COMBINE_PREFIX
         ,PROP_CHAR_COMBINE_SUFFIX
diff --git a/writerfilter/source/dmapper/TDefTableHandler.cxx 
b/writerfilter/source/dmapper/TDefTableHandler.cxx
index 2dea73e65020..4d279ac4bc12 100644
--- a/writerfilter/source/dmapper/TDefTableHandler.cxx
+++ b/writerfilter/source/dmapper/TDefTableHandler.cxx
@@ -269,48 +269,48 @@ OUString 
TDefTableHandler::getThemeColorTypeString(sal_Int32 nType)
     return OUString();
 }
 
-sal_Int16 TDefTableHandler::getThemeColorTypeIndex(sal_Int32 nType)
+model::ThemeColorType TDefTableHandler::getThemeColorTypeIndex(sal_Int32 nType)
 {
     switch (nType)
     {
         case NS_ooxml::LN_Value_St_ThemeColor_dark1:
-                return 0;
+                return model::ThemeColorType::Dark1;
         case NS_ooxml::LN_Value_St_ThemeColor_light1:
-                return 1;
+                return model::ThemeColorType::Light1;
         case NS_ooxml::LN_Value_St_ThemeColor_dark2:
-                return 2;
+                return model::ThemeColorType::Dark2;
         case NS_ooxml::LN_Value_St_ThemeColor_light2:
-                return 3;
+                return model::ThemeColorType::Light2;
         case NS_ooxml::LN_Value_St_ThemeColor_accent1:
-                return 4;
+                return model::ThemeColorType::Accent1;
         case NS_ooxml::LN_Value_St_ThemeColor_accent2:
-                return 5;
+                return model::ThemeColorType::Accent2;
         case NS_ooxml::LN_Value_St_ThemeColor_accent3:
-                return 6;
+                return model::ThemeColorType::Accent3;
         case NS_ooxml::LN_Value_St_ThemeColor_accent4:
-                return 7;
+                return model::ThemeColorType::Accent4;
         case NS_ooxml::LN_Value_St_ThemeColor_accent5:
-                return 8;
+                return model::ThemeColorType::Accent5;
         case NS_ooxml::LN_Value_St_ThemeColor_accent6:
-                return 9;
+                return model::ThemeColorType::Accent6;
         case NS_ooxml::LN_Value_St_ThemeColor_hyperlink:
-                return 10;
+                return model::ThemeColorType::Hyperlink;
         case NS_ooxml::LN_Value_St_ThemeColor_followedHyperlink:
-                return 11;
+                return model::ThemeColorType::FollowedHyperlink;
         case NS_ooxml::LN_Value_St_ThemeColor_none:
-                return -1;
+                return model::ThemeColorType::Unknown;
         case NS_ooxml::LN_Value_St_ThemeColor_background1:
-                return 0;
+                return model::ThemeColorType::Dark1;
         case NS_ooxml::LN_Value_St_ThemeColor_text1:
-                return 1;
+                return model::ThemeColorType::Light1;
         case NS_ooxml::LN_Value_St_ThemeColor_background2:
-                return 2;
+                return model::ThemeColorType::Dark2;
         case NS_ooxml::LN_Value_St_ThemeColor_text2:
-                return 3;
+                return model::ThemeColorType::Light2;
         default:
                 break;
     }
-    return -1;
+    return model::ThemeColorType::Unknown;
 }
 
 void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
diff --git a/writerfilter/source/dmapper/TDefTableHandler.hxx 
b/writerfilter/source/dmapper/TDefTableHandler.hxx
index f9ae47eb5390..c997996a4f73 100644
--- a/writerfilter/source/dmapper/TDefTableHandler.hxx
+++ b/writerfilter/source/dmapper/TDefTableHandler.hxx
@@ -20,6 +20,8 @@
 
 #include "LoggedResources.hxx"
 #include <vector>
+#include <docmodel/theme/ThemeColorType.hxx>
+
 namespace com::sun::star{
     namespace table {
         struct BorderLine2;
@@ -66,7 +68,7 @@ public:
     css::beans::PropertyValue getInteropGrabBag(const OUString& aName = 
OUString());
     static OUString getBorderTypeString(sal_Int32 nType);
     static OUString getThemeColorTypeString(sal_Int32 nType);
-    static sal_Int16 getThemeColorTypeIndex(sal_Int32 nType);
+    static model::ThemeColorType getThemeColorTypeIndex(sal_Int32 nType);
 };
 }
 
diff --git a/writerfilter/source/dmapper/ThemeColorHandler.hxx 
b/writerfilter/source/dmapper/ThemeColorHandler.hxx
new file mode 100644
index 000000000000..88ae0cfaf418
--- /dev/null
+++ b/writerfilter/source/dmapper/ThemeColorHandler.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include "LoggedResources.hxx"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include "PropertyIds.hxx"
+
+#include <oox/helper/grabbagstack.hxx>
+#include <docmodel/uno/UnoThemeColor.hxx>
+
+#include <memory>
+#include <optional>
+
+namespace writerfilter::dmapper
+{
+/// Class to process all text effects like glow, textOutline, ...
+class ThemeColorHandler : public LoggedProperties
+{
+public:
+    sal_Int32 mnColor = 0;
+    sal_Int32 mnIndex = -1;
+    sal_Int32 mnTint = 0;
+    sal_Int32 mnShade = 0;
+
+    explicit ThemeColorHandler()
+        : LoggedProperties("ThemeColorHandler")
+    {
+    }
+
+    virtual void lcl_attribute(Id aName, Value& rValue) override
+    {
+        sal_Int32 nIntValue = rValue.getInt();
+
+        switch (aName)
+        {
+            case NS_ooxml::LN_CT_Color_val:
+                mnColor = nIntValue;
+                break;
+            case NS_ooxml::LN_CT_Color_themeColor:
+                mnIndex = nIntValue;
+                break;
+
+            case NS_ooxml::LN_CT_Color_themeTint:
+                mnTint = nIntValue;
+                break;
+
+            case NS_ooxml::LN_CT_Color_themeShade:
+                mnShade = nIntValue;
+                break;
+        }
+    }
+
+    virtual void lcl_sprm(Sprm& /*sprm*/) override {}
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to