[Libreoffice-commits] core.git: sw/source

Bayram Çiçek (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 8 20:09:59 UTC 2021


 sw/source/core/graphic/ndgrf.cxx |   29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 59aed1d334de21270628c784920c61f2b8eb1da0
Author:     Bayram Çiçek <mail at bayramcicek.com.tr>
AuthorDate: Mon Jun 7 07:24:05 2021 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Tue Jun 8 22:09:19 2021 +0200

    tdf#104995: Fix opposite cropping issue on flipped images in Writer
    
    In Writer, cropping an flipped image crops the
    opposite side of the image instead of the
    selected side.
    
    Fix: update crop values after the flipping(mirroring).
    
    Change-Id: I55cfed086bbf63b0c516e1cb6b2624c02b04a6da
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116770
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 83e8a33a3527..680f142ef1d6 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -775,10 +775,31 @@ GraphicAttr& SwGrfNode::GetGraphicAttr( GraphicAttr& rGA,
     rGA.SetMirrorFlags( nMirror );
 
     const SwCropGrf& rCrop = rSet.GetCropGrf();
-    rGA.SetCrop( convertTwipToMm100( rCrop.GetLeft() ),
-                 convertTwipToMm100( rCrop.GetTop() ),
-                 convertTwipToMm100( rCrop.GetRight() ),
-                 convertTwipToMm100( rCrop.GetBottom() ));
+
+    tools::Long nCropLeft = rCrop.GetLeft();
+    tools::Long nCropTop = rCrop.GetTop();
+    tools::Long nCropRight = rCrop.GetRight();
+    tools::Long nCropBottom = rCrop.GetBottom();
+
+    // take mirroring of crop values into consideration
+    // while cropping a flipped image. otherwise,
+    // cropping will crop the opposite side of the image.
+    if (rGA.GetMirrorFlags() & BmpMirrorFlags::Vertical)
+    {
+        nCropTop = rCrop.GetBottom();
+        nCropBottom = rCrop.GetTop();
+    }
+
+    if (rGA.GetMirrorFlags() & BmpMirrorFlags::Horizontal)
+    {
+        nCropLeft = rCrop.GetRight();
+        nCropRight = rCrop.GetLeft();
+    }
+
+    rGA.SetCrop( convertTwipToMm100( nCropLeft ),
+                 convertTwipToMm100( nCropTop ),
+                 convertTwipToMm100( nCropRight ),
+                 convertTwipToMm100( nCropBottom ));
 
     const SwRotationGrf& rRotation = rSet.GetRotationGrf();
     rGA.SetRotation( rRotation.GetValue() );


More information about the Libreoffice-commits mailing list