diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-05-08 14:09:00 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-05-12 05:00:28 +0200 |
commit | 1df0565fb92972bd410e7db85eef1e4bec3fcc31 (patch) | |
tree | 863c5cf54a5941ca84e2d76b68c4e895159d78de /oox | |
parent | 99a88c9e55872214ce01d89447d18708e47e956b (diff) |
use ComplexColor instead of ThemeColor for better OOXML compat.
In OOXML a color definition includes more represenations, one of
which is scheme color (which is what is implemented in ThemeColor
currently), but it supports other representations too (RGB, HSL,
System,..). ComplexColor includes all the representations, so to
have a better compatibility with OOXML, this changes all uses of
ThemeColor to ComplexColor.
In many cases the usage of ComplexColor isn't the same as the
usage of ThemeColors, but this cases will need to be changed in a
later commit.
Change-Id: I9cc8acee2ac0a1998fe9b98247bcf4a96273149a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151492
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/drawingml/fontworkhelpers.hxx | 16 | ||||
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 99 | ||||
-rw-r--r-- | oox/qa/unit/shape.cxx | 15 | ||||
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 20 | ||||
-rw-r--r-- | oox/source/drawingml/fontworkhelpers.cxx | 94 | ||||
-rw-r--r-- | oox/source/drawingml/lineproperties.cxx | 21 | ||||
-rw-r--r-- | oox/source/drawingml/textcharacterproperties.cxx | 16 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 38 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 6 |
9 files changed, 156 insertions, 169 deletions
diff --git a/oox/inc/drawingml/fontworkhelpers.hxx b/oox/inc/drawingml/fontworkhelpers.hxx index b7d4c5594854..9a550b00904c 100644 --- a/oox/inc/drawingml/fontworkhelpers.hxx +++ b/oox/inc/drawingml/fontworkhelpers.hxx @@ -19,7 +19,7 @@ #pragma once -#include <docmodel/theme/ThemeColor.hxx> +#include <docmodel/color/ComplexColor.hxx> #include <rtl/ustring.hxx> #include <sal/types.h> #include <svx/msdffdef.hxx> @@ -53,7 +53,7 @@ void putCustomShapeIntoTextPathMode( OString GetVMLFontworkShapetypeMarkup(const MSO_SPT eShapeType); /** Collects the properties "CharColor", "CharLumMod", "CharLumOff", "CharColorTheme", - "CharColorThemeReference" and "CharTransparence" from the first non-empty run in rXText and puts + "CharComplexColor" and "CharTransparence" from the first non-empty run in rXText and puts them into rCharPropVec.*/ void collectCharColorProps(const css::uno::Reference<css::text::XText>& rXText, std::vector<css::beans::PropertyValue>& rCharPropVec); @@ -64,8 +64,8 @@ void applyPropsToRuns(const std::vector<css::beans::PropertyValue>& rTextPropVec css::uno::Reference<css::text::XText>& rXText); /** Generates the properties "CharColor", "CharLumMod", "CharLumOff", "CharColorTheme", - "CharColorThemeReference" and "CharTransparence" from the shape properties "FillColor", - "FillColorLumMod, "FillColorLumOff", "FillColorTheme", "FillColorThemeReference" and + "CharComplexColor" and "CharTransparence" from the shape properties "FillColor", + "FillColorLumMod, "FillColorLumOff", "FillColorTheme", "FillComplexColor" and "FillTransparence" and puts them into rCharPropVec.*/ void createCharFillPropsFromShape(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet, std::vector<css::beans::PropertyValue>& rCharPropVec); @@ -92,11 +92,11 @@ bool createPrstDashFromLineDash(const css::drawing::LineDash& rLineDash, const css::drawing::LineCap& rLineCap, OUString& rsPrstDash); /** Returns true if a theme color with other type than model::ThemeColorType::Unknown was found. - The theme color is then in aThemeColor. - Returns false otherwise. aThemeColor is then unchanged or its type is + The theme color is then in rComplexColor. + Returns false otherwise. rComplexColor is then unchanged or its type is model::ThemeColorType::Unknown */ bool getThemeColorFromShape(const OUString& rPropertyName, const css::uno::Reference<css::beans::XPropertySet>& xPropertySet, - model::ThemeColor& aThemeColor); + model::ComplexColor& rComplexColor); } -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
\ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index 14e9321562ee..10dc88e4954d 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -30,7 +30,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/util/XTheme.hpp> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <docmodel/uno/UnoTheme.hxx> #include <docmodel/theme/Theme.hxx> @@ -416,18 +416,17 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testPptxTheme) // 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()); + uno::Reference<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, - aThemeColor.getTransformations()[0].meType); - CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aThemeColor.getTransformations()[0].mnValue); + aComplexColor.getTransformations()[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor.getTransformations()[0].mnValue); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, - aThemeColor.getTransformations()[1].meType); - CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aThemeColor.getTransformations()[1].mnValue); + aComplexColor.getTransformations()[1].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aComplexColor.getTransformations()[1].mnValue); } } @@ -472,28 +471,26 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColorTint_Table) // 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); - CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + uno::Reference<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xA1->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); { - auto const& rTrans = aThemeColor.getTransformations(); + auto const& rTrans = aComplexColor.getTransformations(); CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size()); } } { - 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); - CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + uno::Reference<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xA2->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); { - auto const& rTrans = aThemeColor.getTransformations(); + auto const& rTrans = aComplexColor.getTransformations(); CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::Tint, rTrans[0].meType); CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans[0].mnValue); @@ -514,16 +511,15 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape) // check line and fill theme color of shape1 { - model::ThemeColor aThemeColor; - uno::Reference<util::XThemeColor> xThemeColor; uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); - - CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor); - CPPUNIT_ASSERT(xThemeColor.is()); - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType()); + uno::Reference<util::XComplexColor> xComplexColor; + CPPUNIT_ASSERT(xShape->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); { - auto const& rTrans = aThemeColor.getTransformations(); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType()); + + auto const& rTrans = aComplexColor.getTransformations(); CPPUNIT_ASSERT_EQUAL(size_t(2), rTrans.size()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType); CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans[0].mnValue); @@ -531,12 +527,13 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape) CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans[1].mnValue); } - CPPUNIT_ASSERT(xShape->getPropertyValue("LineColorThemeReference") >>= xThemeColor); - CPPUNIT_ASSERT(xThemeColor.is()); - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType()); + CPPUNIT_ASSERT(xShape->getPropertyValue("LineComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); { - auto const& rTrans = aThemeColor.getTransformations(); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aComplexColor.getSchemeType()); + + auto const& rTrans = aComplexColor.getTransformations(); CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType); CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans[0].mnValue); @@ -544,25 +541,25 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape) } // check line and fill theme color of shape2 { - model::ThemeColor aThemeColor; - uno::Reference<util::XThemeColor> xThemeColor; + uno::Reference<util::XComplexColor> xComplexColor; uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); - - CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor); - CPPUNIT_ASSERT(xThemeColor.is()); - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + CPPUNIT_ASSERT(xShape->getPropertyValue("FillComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); { - auto const& rTrans = aThemeColor.getTransformations(); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); + + auto const& rTrans = aComplexColor.getTransformations(); CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size()); } - CPPUNIT_ASSERT(xShape->getPropertyValue("LineColorThemeReference") >>= xThemeColor); - CPPUNIT_ASSERT(xThemeColor.is()); - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + CPPUNIT_ASSERT(xShape->getPropertyValue("LineComplexColor") >>= xComplexColor); + CPPUNIT_ASSERT(xComplexColor.is()); { - auto const& rTrans = aThemeColor.getTransformations(); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getSchemeType()); + + auto const& rTrans = aComplexColor.getTransformations(); CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size()); CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType); CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), rTrans[0].mnValue); diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx index e8d4f188b8d3..ad43fb52b4a1 100644 --- a/oox/qa/unit/shape.cxx +++ b/oox/qa/unit/shape.cxx @@ -36,7 +36,7 @@ #include <rtl/math.hxx> #include <svx/svdoashp.hxx> #include <tools/color.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <basegfx/utils/gradienttools.hxx> using namespace ::com::sun::star; @@ -313,15 +313,14 @@ 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 CharColorThemeReference see + // clrScheme. For map between name in docx and index from CharComplexColor see // oox::drawingml::Color::getSchemeColorIndex() // Without fix the color scheme was "lt1" (1) but should be "dk2" (2). - 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()); + uno::Reference<util::XComplexColor> xComplexColor; + xPortion->getPropertyValue("CharComplexColor") >>= xComplexColor; + CPPUNIT_ASSERT(xComplexColor.is()); + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Dark2, aComplexColor.getSchemeType()); if (!bUseGroup) { diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 2896ae14fe18..e6cded7e64c7 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -26,7 +26,7 @@ #include <vcl/graph.hxx> #include <vcl/BitmapFilter.hxx> #include <vcl/BitmapMonochromeFilter.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <basegfx/utils/gradienttools.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -427,27 +427,27 @@ void FillProperties::pushToPropMap(ShapePropertyMap& rPropMap, const GraphicHelp if( maFillColor.hasTransparency() ) rPropMap.setProperty( ShapeProperty::FillTransparency, maFillColor.getTransparency() ); - model::ThemeColor aThemeColor; + model::ComplexColor aComplexColor; if (aFillColor == nPhClr) { - aThemeColor.setType(model::convertToThemeColorType(nPhClrTheme)); - rPropMap.setProperty(PROP_FillColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + aComplexColor.setSchemeColor(model::convertToThemeColorType(nPhClrTheme)); + rPropMap.setProperty(PROP_FillComplexColor, model::color::createXComplexColor(aComplexColor)); } else { - aThemeColor.setType(model::convertToThemeColorType(maFillColor.getSchemeColorIndex())); + aComplexColor.setSchemeColor(model::convertToThemeColorType(maFillColor.getSchemeColorIndex())); if (maFillColor.getLumMod() != 10000) - aThemeColor.addTransformation({model::TransformationType::LumMod, maFillColor.getLumMod()}); + aComplexColor.addTransformation({model::TransformationType::LumMod, maFillColor.getLumMod()}); if (maFillColor.getLumOff() != 0) - aThemeColor.addTransformation({model::TransformationType::LumOff, maFillColor.getLumOff()}); + aComplexColor.addTransformation({model::TransformationType::LumOff, maFillColor.getLumOff()}); if (maFillColor.getTintOrShade() > 0) - aThemeColor.addTransformation({model::TransformationType::Tint, maFillColor.getTintOrShade()}); + aComplexColor.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}); + aComplexColor.addTransformation({model::TransformationType::Shade, nShade}); } - rPropMap.setProperty(PROP_FillColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + rPropMap.setProperty(PROP_FillComplexColor, model::color::createXComplexColor(aComplexColor)); } eFillStyle = FillStyle_SOLID; diff --git a/oox/source/drawingml/fontworkhelpers.cxx b/oox/source/drawingml/fontworkhelpers.cxx index 547c9382d0a9..3c8d28d634c6 100644 --- a/oox/source/drawingml/fontworkhelpers.cxx +++ b/oox/source/drawingml/fontworkhelpers.cxx @@ -23,7 +23,7 @@ #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <comphelper/sequenceashashmap.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <drawingml/customshapeproperties.hxx> #include <drawingml/presetgeometrynames.hxx> #include <oox/drawingml/drawingmltypes.hxx> @@ -51,7 +51,7 @@ #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/util/XThemeColor.hpp> +#include <com/sun/star/util/XComplexColor.hpp> #include <array> #include <map> @@ -849,12 +849,9 @@ void FontworkHelpers::collectCharColorProps(const uno::Reference<text::XText>& r continue; // We have found a non-empty run. Collect its simple color properties. - const std::array<OUString, 6> aNamesArray = { u"CharColor", - u"CharLumMod", - u"CharLumOff", - u"CharColorTheme", - u"CharColorThemeReference", - u"CharTransparence" }; + const std::array<OUString, 6> aNamesArray + = { u"CharColor", u"CharLumMod", u"CharLumOff", + u"CharColorTheme", u"CharComplexColor", u"CharTransparence" }; for (const auto& propName : aNamesArray) { if (xRunPropSetInfo->hasPropertyByName(propName)) @@ -934,10 +931,10 @@ void FontworkHelpers::createCharFillPropsFromShape( } const std::array<OUString, 5> aCharPropNames - = { u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", u"CharColorThemeReference", + = { u"CharColorLumMod", u"CharColorLumOff", u"CharColorTheme", u"CharComplexColor", u"CharTransparence" }; const std::array<OUString, 5> aShapePropNames - = { u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", u"FillColorThemeReference", + = { u"FillColorLumMod", u"FillColorLumOff", u"FillColorTheme", u"FillComplexColor", u"FillTransparence" }; for (size_t i = 0; i < 5; i++) { @@ -1004,17 +1001,17 @@ bool FontworkHelpers::createPrstDashFromLineDash(const drawing::LineDash& rLineD bool FontworkHelpers::getThemeColorFromShape( OUString const& rPropertyName, const uno::Reference<beans::XPropertySet>& xPropertySet, - model::ThemeColor& aThemeColor) + model::ComplexColor& rComplexColor) { auto xPropSetInfo = xPropertySet->getPropertySetInfo(); if (!xPropSetInfo.is()) return false; - uno::Reference<util::XThemeColor> xThemeColor; + uno::Reference<util::XComplexColor> xComplexColor; if (xPropSetInfo->hasPropertyByName(rPropertyName) - && (xPropertySet->getPropertyValue(rPropertyName) >>= xThemeColor) && xThemeColor.is()) + && (xPropertySet->getPropertyValue(rPropertyName) >>= xComplexColor) && xComplexColor.is()) { - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - if (aThemeColor.getType() == model::ThemeColorType::Unknown) + rComplexColor = model::color::getFromXComplexColor(xComplexColor); + if (rComplexColor.getSchemeType() == model::ThemeColorType::Unknown) return false; else return true; @@ -1030,7 +1027,7 @@ struct GradientStopColor // RGBColor contains no transformations. In case TTColor has other type than // ThemeColorType::Unknown, it has precedence. The color transformations in TTColor are used // for RGBColor as well. - model::ThemeColor TTColor; // ThemeColorType and color transformations + model::ComplexColor TTColor; // ThemeColorType and color transformations ::Color RGBColor; }; } @@ -1043,36 +1040,36 @@ typedef std::multimap<sal_Int32, GradientStopColor> ColorMapType; namespace { // Returns the string to be used in w14:schemeClr in case of w14:textOutline or w14:textFill -OUString lcl_getW14MarkupStringForThemeColor(const model::ThemeColor& rThemeColor) +OUString lcl_getW14MarkupStringForThemeColor(const model::ComplexColor& rComplexColor) { const std::array<OUString, 12> W14ColorNames = { u"tx1", u"bg1", u"tx2", u"bg2", u"accent1", u"accent2", u"accent3", u"accent4", u"accent5", u"accent6", u"hlink", u"folHlink" }; const sal_uInt8 nClrNameIndex = std::clamp<sal_uInt8>( - sal_Int32(rThemeColor.getType()), sal_Int32(model::ThemeColorType::Dark1), + sal_Int32(rComplexColor.getSchemeType()), sal_Int32(model::ThemeColorType::Dark1), sal_Int32(model::ThemeColorType::FollowedHyperlink)); return W14ColorNames[nClrNameIndex]; } // Returns the string to be used in w:themeColor. It is exported via CharThemeColor. -OUString lcl_getWMarkupStringForThemeColor(const model::ThemeColor& rThemeColor) +OUString lcl_getWMarkupStringForThemeColor(const model::ComplexColor& rComplexColor) { const std::array<OUString, 12> WColorNames = { u"text1", u"background1", u"text2", u"background2", u"accent1", u"accent2", u"accent3", u"accent4", u"accent5", u"accent6", u"hyperlink", u"followedHyperlink" }; const sal_uInt8 nClrNameIndex = std::clamp<sal_uInt8>( - sal_Int32(rThemeColor.getType()), sal_Int32(model::ThemeColorType::Dark1), + sal_Int32(rComplexColor.getSchemeType()), sal_Int32(model::ThemeColorType::Dark1), sal_Int32(model::ThemeColorType::FollowedHyperlink)); return WColorNames[nClrNameIndex]; } -// Puts the value of the first occurrence of rType in rThemeColor into rValue and returns true. +// Puts the value of the first occurrence of rType in rComplexColor into rValue and returns true. // If such does not exist, rValue is unchanged and the method returns false. -bool lcl_getThemeColorTransformationValue(const model::ThemeColor& rThemeColor, +bool lcl_getThemeColorTransformationValue(const model::ComplexColor& rComplexColor, const model::TransformationType& rType, sal_Int16& rValue) { - const std::vector<model::Transformation> aTransVec(rThemeColor.getTransformations()); + const std::vector<model::Transformation> aTransVec(rComplexColor.getTransformations()); auto bItemFound = [rType](const model::Transformation& rTrans) { return rType == rTrans.meType; }; auto pIt = std::find_if(aTransVec.begin(), aTransVec.end(), bItemFound); @@ -1083,14 +1080,14 @@ bool lcl_getThemeColorTransformationValue(const model::ThemeColor& rThemeColor, } // Adds the child elements 'lumMod' and 'lumOff' to 'schemeClr' maCurrentElement of pGrabStack, -// if such exist in rThemeColor. 'alpha' is contained in the maTransformations of rThemeColor +// if such exist in rComplexColor. 'alpha' is contained in the maTransformations of rComplexColor // in case of gradient fill. -void lcl_addColorTransformationToGrabBagStack(const model::ThemeColor& rThemeColor, +void lcl_addColorTransformationToGrabBagStack(const model::ComplexColor& rComplexColor, std::unique_ptr<oox::GrabBagStack>& pGrabBagStack) { if (pGrabBagStack == nullptr) return; - for (auto const& rColorTransform : rThemeColor.getTransformations()) + for (auto const& rColorTransform : rComplexColor.getTransformations()) { switch (rColorTransform.meType) { @@ -1215,7 +1212,6 @@ sal_Int16 lcl_getAlphaFromTransparenceGradient(const awt::Gradient& rTransparenc / (100.0 - nBorder) * 100 / 255.0); } -// GradientStopColor has components ::Color RGBColor and model::ThemeColor TTColor GradientStopColor lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet, const uno::Reference<beans::XPropertySetInfo>& rXPropSetInfo, @@ -1235,7 +1231,6 @@ lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet { // a color gradient is yet not enabled to use theme colors aStopColor.RGBColor = lcl_getColorFromColorGradient(rColorGradient, rnPos); - aStopColor.TTColor.setType(model::ThemeColorType::Unknown); sal_Int16 nIntensity = lcl_getIntensityFromColorGradient(rColorGradient, rnPos); if (nIntensity != 100) aStopColor.TTColor.addTransformation( @@ -1246,7 +1241,7 @@ lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet else // solid color { // fill color might be a theme color - if (!(FontworkHelpers::getThemeColorFromShape("FillColorThemeReference", rXPropSet, + if (!(FontworkHelpers::getThemeColorFromShape("FillComplexColor", rXPropSet, aStopColor.TTColor))) { // no theme color, use FillColor @@ -1254,7 +1249,7 @@ lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet if (rXPropSetInfo->hasPropertyByName("FillColor")) rXPropSet->getPropertyValue(u"FillColor") >>= nFillColor; aStopColor.RGBColor = ::Color(ColorTransparency, nFillColor); - aStopColor.TTColor.setType(model::ThemeColorType::Unknown); + aStopColor.TTColor = model::ComplexColor(); } } @@ -1280,7 +1275,7 @@ lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet { // a color gradient is yet not enabled to use theme colors aStopColor.RGBColor = lcl_getColorFromColorGradient(rColorGradient, rnPos); - aStopColor.TTColor.setType(model::ThemeColorType::Unknown); + aStopColor.TTColor = model::ComplexColor(); sal_Int16 nIntensity = lcl_getIntensityFromColorGradient(rColorGradient, rnPos); if (nIntensity != 100) aStopColor.TTColor.addTransformation( @@ -1292,7 +1287,7 @@ lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet { // solid color and solid transparency SAL_WARN("oox.drawingml", "method should not be called in this case"); - if (!(FontworkHelpers::getThemeColorFromShape("FillColorThemeReference", rXPropSet, + if (!(FontworkHelpers::getThemeColorFromShape("FillComplexColor", rXPropSet, aStopColor.TTColor))) { // no theme color, use FillColor @@ -1300,7 +1295,7 @@ lcl_createGradientStopColor(const uno::Reference<beans::XPropertySet>& rXPropSet if (rXPropSetInfo->hasPropertyByName(u"FillColor")) rXPropSet->getPropertyValue(u"FillColor") >>= nFillColor; aStopColor.RGBColor = ::Color(ColorTransparency, nFillColor); - aStopColor.TTColor.setType(model::ThemeColorType::Unknown); + aStopColor.TTColor = model::ComplexColor(); } } @@ -1462,7 +1457,7 @@ void FontworkHelpers::createCharInteropGrabBagUpdatesFromShapeProps( pGrabBagStack->push("attributes"); pGrabBagStack->addInt32("pos", (*it).first); pGrabBagStack->pop(); - if ((*it).second.TTColor.getType() == model::ThemeColorType::Unknown) + if ((*it).second.TTColor.getSchemeType() == model::ThemeColorType::Unknown) { pGrabBagStack->push("srgbClr"); pGrabBagStack->push("attributes"); @@ -1542,16 +1537,16 @@ void FontworkHelpers::createCharInteropGrabBagUpdatesFromShapeProps( case drawing::FillStyle_SOLID: { pGrabBagStack->push("solidFill"); - model::ThemeColor aThemeColor; + model::ComplexColor aComplexColor; // It is either "schemeClr" or "srgbClr". - if (FontworkHelpers::getThemeColorFromShape("FillColorThemeReference", rXPropSet, - aThemeColor)) + if (FontworkHelpers::getThemeColorFromShape("FillComplexColor", rXPropSet, + aComplexColor)) { pGrabBagStack->push("schemeClr"); pGrabBagStack->push("attributes"); - pGrabBagStack->addString("val", lcl_getW14MarkupStringForThemeColor(aThemeColor)); + pGrabBagStack->addString("val", lcl_getW14MarkupStringForThemeColor(aComplexColor)); pGrabBagStack->pop(); // maCurrentElement:'schemeClr', maPropertyList:'attributes' - lcl_addColorTransformationToGrabBagStack(aThemeColor, pGrabBagStack); + lcl_addColorTransformationToGrabBagStack(aComplexColor, pGrabBagStack); // maCurrentElement:'schemeClr', maPropertyList:'attributes', maybe 'lumMod' and // maybe 'lumOff' } @@ -1630,15 +1625,14 @@ void FontworkHelpers::createCharInteropGrabBagUpdatesFromShapeProps( { pGrabBagStack->push("solidFill"); // It is either "schemeClr" or "srgbClr". - model::ThemeColor aThemeColor; - if (FontworkHelpers::getThemeColorFromShape("LineColorThemeReference", rXPropSet, - aThemeColor)) + model::ComplexColor aComplexColor; + if (FontworkHelpers::getThemeColorFromShape("LineComplexColor", rXPropSet, aComplexColor)) { pGrabBagStack->push("schemeClr"); pGrabBagStack->push("attributes"); - pGrabBagStack->addString("val", lcl_getW14MarkupStringForThemeColor(aThemeColor)); + pGrabBagStack->addString("val", lcl_getW14MarkupStringForThemeColor(aComplexColor)); pGrabBagStack->pop(); - lcl_addColorTransformationToGrabBagStack(aThemeColor, pGrabBagStack); + lcl_addColorTransformationToGrabBagStack(aComplexColor, pGrabBagStack); // maCurrentElement:'schemeClr', maPropertylist:'attributes' } else // not a theme color @@ -1725,13 +1719,13 @@ void FontworkHelpers::createCharInteropGrabBagUpdatesFromShapeProps( // CharThemeOriginalColor, CharThemeColor, and CharThemeColorShade or CharThemeColorTint will be // used for <w:color> element. That is evaluated by applications, which do not understand w14 // namespace, or if w14:textFill is omitted. - model::ThemeColor aThemeColor; - if (FontworkHelpers::getThemeColorFromShape("FillColorThemeReference", rXPropSet, aThemeColor)) + model::ComplexColor aComplexColor; + if (FontworkHelpers::getThemeColorFromShape("FillComplexColor", rXPropSet, aComplexColor)) { // CharThemeColor beans::PropertyValue aCharThemeColor; aCharThemeColor.Name = u"CharThemeColor"; - aCharThemeColor.Value <<= lcl_getWMarkupStringForThemeColor(aThemeColor); + aCharThemeColor.Value <<= lcl_getWMarkupStringForThemeColor(aComplexColor); rUpdatePropVec.push_back(aCharThemeColor); // CharThemeColorShade or CharThemeColorTint @@ -1740,12 +1734,12 @@ void FontworkHelpers::createCharInteropGrabBagUpdatesFromShapeProps( // We made two assumption here: (1) If LumOff exists and is not zero, it is a 'tint'. // (2) LumMod + LumOff == 10000; sal_Int16 nLumMod; - if (lcl_getThemeColorTransformationValue(aThemeColor, model::TransformationType::LumMod, + if (lcl_getThemeColorTransformationValue(aComplexColor, model::TransformationType::LumMod, nLumMod)) { sal_Int16 nLumOff; bool bIsTint = lcl_getThemeColorTransformationValue( - aThemeColor, model::TransformationType::LumOff, nLumOff) + aComplexColor, model::TransformationType::LumOff, nLumOff) && nLumOff != 0; sal_uInt8 nValue = std::clamp<sal_uInt8>(lround(double(nLumMod) * 255.0 / 10000.0), 0, 255); @@ -1758,7 +1752,7 @@ void FontworkHelpers::createCharInteropGrabBagUpdatesFromShapeProps( } } // ToDo: Are FillColorLumMod, FillColorLumOff and FillColorTheme possible without - // FillColorThemeReference? If yes, we need an 'else' part here. + // FillComplexColor? If yes, we need an 'else' part here. // CharThemeOriginalColor. beans::PropertyValue aCharThemeOriginalColor; diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 898b5b702161..1372a6b96016 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -34,8 +34,7 @@ #include <oox/helper/graphichelper.hxx> #include <oox/token/tokens.hxx> #include <oox/token/properties.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> - +#include <docmodel/uno/UnoComplexColor.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -501,28 +500,28 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, if( aLineColor.hasTransparency() ) rPropMap.setProperty( ShapeProperty::LineTransparency, aLineColor.getTransparency() ); - model::ThemeColor aThemeColor; + model::ComplexColor aComplexColor; if (aColor == nPhClr) { - aThemeColor.setType(model::convertToThemeColorType(nPhClrTheme)); - rPropMap.setProperty(PROP_LineColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + aComplexColor.setSchemeColor(model::convertToThemeColorType(nPhClrTheme)); + rPropMap.setProperty(PROP_LineComplexColor, model::color::createXComplexColor(aComplexColor)); } else { - aThemeColor.setType(model::convertToThemeColorType(aLineColor.getSchemeColorIndex())); + aComplexColor.setSchemeColor(model::convertToThemeColorType(aLineColor.getSchemeColorIndex())); if (aLineColor.getLumMod() != 10000) - aThemeColor.addTransformation({model::TransformationType::LumMod, aLineColor.getLumMod()}); + aComplexColor.addTransformation({model::TransformationType::LumMod, aLineColor.getLumMod()}); if (aLineColor.getLumOff() != 0) - aThemeColor.addTransformation({model::TransformationType::LumOff, aLineColor.getLumOff()}); + aComplexColor.addTransformation({model::TransformationType::LumOff, aLineColor.getLumOff()}); if (aLineColor.getTintOrShade() > 0) - aThemeColor.addTransformation({model::TransformationType::Tint, aLineColor.getTintOrShade()}); + aComplexColor.addTransformation({model::TransformationType::Tint, aLineColor.getTintOrShade()}); if (aLineColor.getTintOrShade() < 0) { sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-aLineColor.getTintOrShade()); - aThemeColor.addTransformation({model::TransformationType::Shade, nShade}); + aComplexColor.addTransformation({model::TransformationType::Shade, nShade}); } - rPropMap.setProperty(PROP_LineColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + rPropMap.setProperty(PROP_LineComplexColor, model::color::createXComplexColor(aComplexColor)); } } diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index a22606ef106c..7d3dda284680 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -26,7 +26,7 @@ #include <i18nlangtag/languagetag.hxx> #include <i18nlangtag/mslangid.hxx> #include <editeng/escapementitem.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <oox/helper/helper.hxx> #include <oox/helper/propertyset.hxx> #include <oox/core/xmlfilterbase.hxx> @@ -136,21 +136,21 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap.setProperty(PROP_CharColor, aColor.getColor(rFilter.getGraphicHelper())); // set theme color - model::ThemeColor aThemeColor; - aThemeColor.setType(model::convertToThemeColorType(aColor.getSchemeColorIndex())); + model::ComplexColor aComplexColor; + aComplexColor.setSchemeColor(model::convertToThemeColorType(aColor.getSchemeColorIndex())); if (aColor.getTintOrShade() > 0) - aThemeColor.addTransformation({model::TransformationType::Tint, aColor.getTintOrShade()}); + aComplexColor.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}); + aComplexColor.addTransformation({model::TransformationType::Shade, nShade}); } if (aColor.getLumMod() != 10000) - aThemeColor.addTransformation({model::TransformationType::LumMod, aColor.getLumMod()}); + aComplexColor.addTransformation({model::TransformationType::LumMod, aColor.getLumMod()}); if (aColor.getLumOff() != 0) - aThemeColor.addTransformation({model::TransformationType::LumOff, aColor.getLumOff()}); + aComplexColor.addTransformation({model::TransformationType::LumOff, aColor.getLumOff()}); - rPropMap.setProperty(PROP_CharColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + rPropMap.setProperty(PROP_CharComplexColor, model::color::createXComplexColor(aComplexColor)); rPropMap.setProperty(PROP_CharContoured, bContoured); if (aColor.hasTransparency()) diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 9f705a20cf9e..fa587d6190bf 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -128,7 +128,7 @@ #include <editeng/flditem.hxx> #include <editeng/escapementitem.hxx> #include <editeng/unonrule.hxx> -#include <docmodel/uno/UnoThemeColor.hxx> +#include <docmodel/uno/UnoComplexColor.hxx> #include <svx/svdoashp.hxx> #include <svx/svdomedia.hxx> #include <svx/svdtrans.hxx> @@ -516,7 +516,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) else if ( nFillColor != nOriginalColor ) { // the user has set a different color for the shape - if (!WriteSchemeColor(u"FillColorThemeReference", rXPropSet)) + if (!WriteSchemeColor(u"FillComplexColor", rXPropSet)) { WriteSolidFill(::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha); } @@ -540,19 +540,18 @@ bool DrawingML::WriteSchemeColor(OUString const& rPropertyName, const uno::Refer if (!xPropertySet->getPropertySetInfo()->hasPropertyByName(rPropertyName)) return false; - uno::Reference<util::XThemeColor> xThemeColor; - xPropertySet->getPropertyValue(rPropertyName) >>= xThemeColor; - if (!xThemeColor.is()) + uno::Reference<util::XComplexColor> xComplexColor; + xPropertySet->getPropertyValue(rPropertyName) >>= xComplexColor; + if (!xComplexColor.is()) return false; - model::ThemeColor aThemeColor; - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - if (aThemeColor.getType() == model::ThemeColorType::Unknown) + auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); + if (aComplexColor.getSchemeType() == model::ThemeColorType::Unknown) return false; - const char* pColorName = g_aPredefinedClrNames[sal_Int16(aThemeColor.getType())]; + const char* pColorName = g_aPredefinedClrNames[sal_Int16(aComplexColor.getSchemeType())]; mpFS->startElementNS(XML_a, XML_solidFill); mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName); - for (auto const& rTransform : aThemeColor.getTransformations()) + for (auto const& rTransform : aComplexColor.getTransformations()) { switch (rTransform.meType) { @@ -574,13 +573,12 @@ bool DrawingML::WriteSchemeColor(OUString const& rPropertyName, const uno::Refer } // Alpha is actually not contained in maTransformations although possible (as of Mar 2023). sal_Int16 nAPITransparency(0); - if ((rPropertyName == u"FillColorThemeReference" - && GetProperty(xPropertySet, "FillTransparence")) - || (rPropertyName == u"LineColorThemeReference" - && GetProperty(xPropertySet, "LineTransparence")) - || (rPropertyName == u"CharColorThemeReference" - && GetProperty(xPropertySet, "CharTransparence"))) + if ((rPropertyName == u"FillComplexColor" && GetProperty(xPropertySet, "FillTransparence")) + || (rPropertyName == u"LineComplexColor" && GetProperty(xPropertySet, "LineTransparence")) + || (rPropertyName == u"CharComplexColor" && GetProperty(xPropertySet, "CharTransparence"))) + { mAny >>= nAPITransparency; + } if (nAPITransparency != 0) mpFS->singleElementNS(XML_a, XML_alpha, XML_val, OString::number(MAX_PERCENT - (PER_PERCENT * nAPITransparency))); @@ -1145,8 +1143,8 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc if( nColor != nOriginalColor ) { // the user has set a different color for the line - if (!WriteSchemeColor(u"LineColorThemeReference", rXPropSet)) - WriteSolidFill(nColor, nColorAlpha); + if (!WriteSchemeColor(u"LineComplexColor", rXPropSet)) + WriteSolidFill(nColor, nColorAlpha); } else if( !sColorFillScheme.isEmpty() ) { @@ -2673,7 +2671,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool else { color.SetAlpha(255); - if (!WriteSchemeColor(u"CharColorThemeReference", rXPropSet)) + if (!WriteSchemeColor(u"CharComplexColor", rXPropSet)) WriteSolidFill(color, nTransparency); } mpFS->endElementNS(XML_a, XML_ln); @@ -2686,7 +2684,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool { color.SetAlpha(255); // TODO: special handle embossed/engraved - if (!WriteSchemeColor(u"CharColorThemeReference", rXPropSet)) + if (!WriteSchemeColor(u"CharComplexColor", rXPropSet)) { WriteSolidFill(color, nTransparency); } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 0b6e5437b883..cf8b8781af23 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -53,12 +53,12 @@ Change CharBackColor CharCaseMap CharColor -CharColorThemeReference CharContoured CharColorTheme CharColorTintOrShade CharColorLumMod CharColorLumOff +CharComplexColor CharEscapement CharEscapementHeight CharFontCharSet @@ -177,7 +177,7 @@ FillColor FillColorTheme FillColorLumMod FillColorLumOff -FillColorThemeReference +FillComplexColor FillGradient FillGradientName FillHatch @@ -316,7 +316,7 @@ LeftPageHeaderContent LegacyFragment LineCap LineColor -LineColorThemeReference +LineComplexColor LineCount LineDash LineDashName |