diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-06-09 23:34:24 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-06-14 08:34:08 +0200 |
commit | b9aa62a714370b63ff93f55f1e599e4cad4c7eef (patch) | |
tree | 60d92d97b6467d55b12d68325bc15d915b7438e9 /oox | |
parent | 81ae86d5f9e6d06300a2d6cf160de004c881ade5 (diff) |
oox: remove code duplication and add getComplexColor to oox::Color
Change-Id: I9cfbc851d4f303a5a8c92183f01cb5b6545b7984
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152800
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit c1470e15bd0643be8d91aaf6a0d25c78867d0b3e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152969
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/color.cxx | 24 | ||||
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 16 | ||||
-rw-r--r-- | oox/source/drawingml/textcharacterproperties.cxx | 15 |
3 files changed, 27 insertions, 28 deletions
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 592d0734efc2..e9c645b99b7c 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -567,6 +567,30 @@ sal_Int16 Color::getLumOff() const return 0; } +model::ComplexColor Color::getComplexColor() const +{ + model::ComplexColor aComplexColor; + aComplexColor.setSchemeColor(model::convertToThemeColorType(getSchemeColorIndex())); + + if (getTintOrShade() > 0) + { + aComplexColor.addTransformation({model::TransformationType::Tint, getTintOrShade()}); + } + else if (getTintOrShade() < 0) + { + sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-getTintOrShade()); + aComplexColor.addTransformation({model::TransformationType::Shade, nShade}); + } + + if (getLumMod() != 10000) + aComplexColor.addTransformation({model::TransformationType::LumMod, getLumMod()}); + + if (getLumOff() != 0) + aComplexColor.addTransformation({model::TransformationType::LumOff, getLumOff()}); + + return aComplexColor; +} + ::Color Color::getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr ) const { const sal_Int32 nTempC1 = mnC1; diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index fe00d12cf078..0a2e53928076 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -430,24 +430,12 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap, if (aFillColor == nPhClr) { aComplexColor.setSchemeColor(model::convertToThemeColorType(nPhClrTheme)); - rPropMap.setProperty(PROP_FillComplexColor, model::color::createXComplexColor(aComplexColor)); } else { - aComplexColor.setSchemeColor(model::convertToThemeColorType(maFillColor.getSchemeColorIndex())); - if (maFillColor.getLumMod() != 10000) - aComplexColor.addTransformation({model::TransformationType::LumMod, maFillColor.getLumMod()}); - if (maFillColor.getLumOff() != 0) - aComplexColor.addTransformation({model::TransformationType::LumOff, maFillColor.getLumOff()}); - if (maFillColor.getTintOrShade() > 0) - aComplexColor.addTransformation({model::TransformationType::Tint, maFillColor.getTintOrShade()}); - if (maFillColor.getTintOrShade() < 0) - { - sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-maFillColor.getTintOrShade()); - aComplexColor.addTransformation({model::TransformationType::Shade, nShade}); - } - rPropMap.setProperty(PROP_FillComplexColor, model::color::createXComplexColor(aComplexColor)); + aComplexColor = maFillColor.getComplexColor(); } + rPropMap.setProperty(PROP_FillComplexColor, model::color::createXComplexColor(aComplexColor)); eFillStyle = FillStyle_SOLID; } diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index 7d3dda284680..0e1e2830a67f 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -136,20 +136,7 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap.setProperty(PROP_CharColor, aColor.getColor(rFilter.getGraphicHelper())); // set theme color - model::ComplexColor aComplexColor; - aComplexColor.setSchemeColor(model::convertToThemeColorType(aColor.getSchemeColorIndex())); - if (aColor.getTintOrShade() > 0) - aComplexColor.addTransformation({model::TransformationType::Tint, aColor.getTintOrShade()}); - if (aColor.getTintOrShade() < 0) - { - sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-aColor.getTintOrShade()); - aComplexColor.addTransformation({model::TransformationType::Shade, nShade}); - } - if (aColor.getLumMod() != 10000) - aComplexColor.addTransformation({model::TransformationType::LumMod, aColor.getLumMod()}); - if (aColor.getLumOff() != 0) - aComplexColor.addTransformation({model::TransformationType::LumOff, aColor.getLumOff()}); - + model::ComplexColor aComplexColor = aColor.getComplexColor(); rPropMap.setProperty(PROP_CharComplexColor, model::color::createXComplexColor(aComplexColor)); rPropMap.setProperty(PROP_CharContoured, bContoured); |