diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2022-09-01 14:59:51 +0300 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-09-05 16:56:49 +0200 |
commit | de325e4b603d6b57fa6b46021a1b4c83e2d44e82 (patch) | |
tree | 9867027b839b3a307cc62a3347efa877ef9ee1c8 /oox | |
parent | 0854ae596afa863ab4db592fa484f8b0799b37da (diff) |
tdf#149670 fix color change api and adjust tolerance for ooxml
It appears at the start of Graphic::colorChange aBmpColorFrom &
aBmpColorTo gets initialized with wrong colors. Instead of {R,G,B},
they get initialized with {B,G,R}.
Instead of bitshifting use the ::Color constructor so that it is
initialized correctly.
For ooxml import adapt tolerance values of the image format in an
attempt to get similar results on how the results appear in
PowerPoint.
Change-Id: I1fa901691512de82936dba0e47158b7e0ca2223e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139203
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 2b902b6203a87bdca7856e17a9c0fcc403de4264)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139421
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index c2f4eaad4e03..451f2ad3a606 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -197,9 +197,31 @@ Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillPropert sal_Int16 nToTransparence = aBlipProps.maColorChangeTo.getTransparency(); sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) * 2.55 ); + sal_uInt8 nTolerance = 9; + Graphic aGraphic{ xGraphic }; + if( aGraphic.IsGfxLink() ) + { + // tdf#149670: Try to guess tolerance depending on image format + switch (aGraphic.GetGfxLink().GetType()) + { + case GfxLinkType::NativeJpg: + nTolerance = 15; + break; + case GfxLinkType::NativePng: + case GfxLinkType::NativeTif: + nTolerance = 1; + break; + case GfxLinkType::NativeBmp: + nTolerance = 0; + break; + default: + break; + } + } + uno::Reference<graphic::XGraphicTransformer> xTransformer(aBlipProps.mxFillGraphic, uno::UNO_QUERY); if (xTransformer.is()) - return xTransformer->colorChange(xGraphic, sal_Int32(nFromColor), 9, sal_Int32(nToColor), nToAlpha); + return xTransformer->colorChange(xGraphic, sal_Int32(nFromColor), nTolerance, sal_Int32(nToColor), nToAlpha); } } return xGraphic; |