diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-06-28 22:55:22 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-06-29 04:57:28 +0200 |
commit | ba29922dcc0a7b079fb76df445c4cd3a80102e83 (patch) | |
tree | 5c1d54c8029169ab51baabb2fe52685de318995d /oox | |
parent | e24a3a3c339d7a175ebfeef31a280becda9d5950 (diff) |
oox: convert Excel tint value into LumOff and LumMod
tint value can be converted into LumOff and LumMod values, so we
don't need a special Excel case for calculating the final color.
Change-Id: I0725c06f9df6a37a309ea5d17b183e4100a228f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153716
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/color.cxx | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index b653458300f4..1ed2e57b6242 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -434,10 +434,18 @@ void Color::addChartTintTransformation( double fTint ) maTransforms.emplace_back( XML_tint, MAX_PERCENT - nValue ); } -void Color::addExcelTintTransformation( double fTint ) +void Color::addExcelTintTransformation(double fTint) { - sal_Int32 nValue = getLimitedValue< sal_Int32, double >( fTint * MAX_PERCENT + 0.5, -MAX_PERCENT, MAX_PERCENT ); - maTransforms.emplace_back( XLS_TOKEN( tint ), nValue ); + sal_Int32 nValue = std::round(std::abs(fTint) * 100'000.0); + if (fTint > 0.0) + { + maTransforms.emplace_back(XML_lumMod, 100'000 - nValue); + maTransforms.emplace_back(XML_lumOff, nValue); + } + else if (fTint < 0.0) + { + maTransforms.emplace_back(XML_lumMod, 100'000 - nValue); + } } void Color::clearTransformations() @@ -723,23 +731,6 @@ model::ComplexColor Color::getComplexColor() const mnC3 = static_cast< sal_Int32 >( MAX_PERCENT - (MAX_PERCENT - mnC3) * fFactor ); } break; - case XLS_TOKEN( tint ): - // Excel tint: move luminance relative to current value - toHsl(); - OSL_ENSURE( (-MAX_PERCENT <= transform.mnValue) && (transform.mnValue <= MAX_PERCENT), "Color::getColor - invalid tint value" ); - if( (-MAX_PERCENT <= transform.mnValue) && (transform.mnValue < 0) ) - { - // negative: luminance towards 0% (black) - lclModValue( mnC3, transform.mnValue + MAX_PERCENT ); - } - else if( (0 < transform.mnValue) && (transform.mnValue <= MAX_PERCENT) ) - { - // positive: luminance towards 100% (white) - mnC3 = MAX_PERCENT - mnC3; - lclModValue( mnC3, MAX_PERCENT - transform.mnValue ); - mnC3 = MAX_PERCENT - mnC3; - } - break; case XML_gray: // change color to gray, weighted RGB: 22% red, 72% green, 6% blue @@ -844,7 +835,7 @@ model::ComplexColor Color::createComplexColor(const GraphicHelper& /*rGraphicHel { sal_Int16 nValue = sal_Int16(aTransform.mnValue / 10); - switch(aTransform.mnToken) + switch (aTransform.mnToken) { case XML_lumMod: if (nValue != 10'000) |