summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2022-09-01 14:59:51 +0300
committerAndras Timar <andras.timar@collabora.com>2022-09-16 22:39:02 +0200
commit448fd8c392edd5e632eaaacecff823189c7c8376 (patch)
tree49418e62cce8a9125b2d6ae398910e35b99c006e /oox/source
parented44dd9adea70fd9dcf3d7a2f30e0c49a66aade4 (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> (cherry picked from commit de325e4b603d6b57fa6b46021a1b4c83e2d44e82) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139673 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/fillproperties.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 0ef86bc75f5c..3fb6b4ca372e 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;