summaryrefslogtreecommitdiff
path: root/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-05-11 16:38:12 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-05-12 10:11:35 +0200
commiteb9f59aac5c31816cb95cbc7023f44f1e9245ea0 (patch)
treed1fbb420040a81427359a2857ebc8847eccb8814 /svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
parentf9dcb113bc2f81ef6abd2044d8512cd4e02f176c (diff)
tdf#129916 svx: fix origin of scaled shadow
We assumed that the top left corner is the origin for scaling, but that is not necessarily the case. The intention is that the shadow direction can be determined from its x and y offset, and the origin is the opposite corner of the shape. (cherry picked from commit e21d522dddce2590ed435890ae8d5fe39658a71a) Conflicts: svx/CppunitTest_svx_unit.mk Change-Id: I6759302767d20739b6e2be79d379740dd06f70f5
Diffstat (limited to 'svx/source/sdr/primitive2d/sdrdecompositiontools.cxx')
-rw-r--r--svx/source/sdr/primitive2d/sdrdecompositiontools.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index 42c0bb60ecc9..48575d3b4917 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -499,9 +499,19 @@ namespace drawinglayer
double fShearX = 0;
rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
// Scale the shadow
- aShadowOffset.translate(-aTranslate.getX(), -aTranslate.getY());
+ double nTranslateX = aTranslate.getX();
+ double nTranslateY = aTranslate.getY();
+
+ // The origin for scaling is the top left corner by default. A negative
+ // shadow offset changes the origin.
+ if (rShadow.getOffset().getX() < 0)
+ nTranslateX += aScale.getX();
+ if (rShadow.getOffset().getY() < 0)
+ nTranslateY += aScale.getY();
+
+ aShadowOffset.translate(-nTranslateX, -nTranslateY);
aShadowOffset.scale(rShadow.getSize().getX() * 0.00001, rShadow.getSize().getY() * 0.00001);
- aShadowOffset.translate(aTranslate.getX(), aTranslate.getY());
+ aShadowOffset.translate(nTranslateX, nTranslateY);
}
aShadowOffset.translate(rShadow.getOffset().getX(), rShadow.getOffset().getY());