summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2022-09-01 14:59:51 +0300
committerMiklos Vajna <vmiklos@collabora.com>2022-09-05 10:01:40 +0200
commit2b902b6203a87bdca7856e17a9c0fcc403de4264 (patch)
treed9f174e2b6ff6cc91a2b243120455e659aa65a9f /oox
parentf438fd7e25254db8f501b86cdf37970194897e8f (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>
Diffstat (limited to 'oox')
-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 fef43b0ca238..1ef7579a7725 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;