File bsc1165849-1.diff of Package libreoffice.15776

From b4ed373a15b1e8d90c94ec7030ee3d3785f7e8f9 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.com>
Date: Fri, 8 May 2020 16:43:22 +0200
Subject: [PATCH] Related: tdf#129916 svx: improve shadow size of custom shapes

There are multiple problems with this bug document, the first is that
the shadow primitive got the default position (0) of the owning shape.
Do it the same way as commit 6454b6336b8de9a4c5899adeab552af6f794cdc4
(tdf#130058 Import shadow size., 2020-04-14) did for graphic objects.

This requires constructing a transform matrix in
ViewContactOfSdrObjCustomShape::createViewIndependentPrimitive2DSequence(),
include position and size in that as a start.

(cherry picked from commit e2b0e614e1185c960b3015414919f69a1ed35aa0)

Change-Id: Ia51df555c1984971afe7c52ba3f2658099a4e7b3
---
 .../primitive2d/sdrcustomshapeprimitive2d.hxx |  5 ++++-
 .../viewcontactofsdrobjcustomshape.cxx        | 19 +++++++++++++------
 .../primitive2d/sdrcustomshapeprimitive2d.cxx | 14 +++++++++++---
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/svx/inc/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx b/svx/inc/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx
index 285185684f15..84488906470a 100644
--- a/svx/inc/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx
+++ b/svx/inc/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx
@@ -47,6 +47,8 @@ namespace drawinglayer
             // making exceptions with shadow generation
             bool const                                        mb3DShape : 1;
 
+            basegfx::B2DHomMatrix maTransform;
+
         protected:
             // local decomposition.
             virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
@@ -57,7 +59,8 @@ namespace drawinglayer
                 const Primitive2DContainer& rSubPrimitives,
                 const basegfx::B2DHomMatrix& rTextBox,
                 bool bWordWrap,
-                bool b3DShape);
+                bool b3DShape,
+                const basegfx::B2DHomMatrix& rObjectMatrix);
 
             // data access
             const attribute::SdrShadowTextAttribute& getSdrSTAttribute() const { return maSdrSTAttribute; }
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
index 8630b6dd1923..7a5c0487a13f 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
@@ -157,13 +157,13 @@ namespace sdr
                 basegfx::B2DHomMatrix aTextBoxMatrix;
                 bool bWordWrap(false);
 
+                // take unrotated snap rect as default, then get the
+                // unrotated text box. Rotation needs to be done centered
+                const tools::Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect());
+                const basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(aObjectBound);
+
                 if(bHasText)
                 {
-                    // take unrotated snap rect as default, then get the
-                    // unrotated text box. Rotation needs to be done centered
-                    const tools::Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect());
-                    const basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(aObjectBound);
-
                     // #i101684# get the text range unrotated and absolute to the object range
                     const basegfx::B2DRange aTextRange(getCorrectedTextBoundRect());
 
@@ -238,6 +238,12 @@ namespace sdr
                     bWordWrap = GetCustomShapeObj().GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue();
                 }
 
+                // fill object matrix
+                const basegfx::B2DHomMatrix aObjectMatrix(basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
+                    aObjectRange.getWidth(), aObjectRange.getHeight(),
+                    /*fShearX=*/0, /*fRotate=*/0,
+                    aObjectRange.getMinX(), aObjectRange.getMinY()));
+
                 // create primitive
                 const drawinglayer::primitive2d::Primitive2DReference xReference(
                     new drawinglayer::primitive2d::SdrCustomShapePrimitive2D(
@@ -245,7 +251,8 @@ namespace sdr
                         xGroup,
                         aTextBoxMatrix,
                         bWordWrap,
-                        b3DShape));
+                        b3DShape,
+                        aObjectMatrix));
                 xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReference };
             }
 
diff --git a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
index fb3018f7ff88..3e0350aaf56c 100644
--- a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
@@ -68,7 +68,13 @@ namespace drawinglayer
                 // shadow will be correct (using ColorModifierStack), but expensive.
                 if(!get3DShape())
                 {
-                    aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow());
+                    basegfx::B2DTuple aScale;
+                    basegfx::B2DTuple aTranslate;
+                    double fRotate = 0;
+                    double fShearX = 0;
+                    maTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+                    aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow(),
+                                                            aTranslate.getX(), aTranslate.getY());
                 }
             }
 
@@ -80,13 +86,15 @@ namespace drawinglayer
             const Primitive2DContainer& rSubPrimitives,
             const basegfx::B2DHomMatrix& rTextBox,
             bool bWordWrap,
-            bool b3DShape)
+            bool b3DShape,
+            const basegfx::B2DHomMatrix& rTransform)
         :   BufferedDecompositionPrimitive2D(),
             maSdrSTAttribute(rSdrSTAttribute),
             maSubPrimitives(rSubPrimitives),
             maTextBox(rTextBox),
             mbWordWrap(bWordWrap),
-            mb3DShape(b3DShape)
+            mb3DShape(b3DShape),
+            maTransform(rTransform)
         {
         }
 
-- 
2.26.1
openSUSE Build Service is sponsored by