[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - svx/source

merttumer (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 29 12:07:07 UTC 2021


 svx/source/svdraw/svddrgv.cxx |   13 +++++++++----
 svx/source/svdraw/svdmrkv.cxx |   25 ++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 5 deletions(-)

New commits:
commit 5da18620f07e9cf389a37794029fdef80aa8b431
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Thu Mar 25 12:44:17 2021 +0300
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Mar 29 14:06:35 2021 +0200

    lok: Send gridOffset of the shape
    
    In core, the gridOffset is calculated based on the LogicRect's TopLeft coordinate
    In online, we have the SnapRect and we calculate it based on its TopLeft coordinate
    SnapRect's TopLeft and LogicRect's TopLeft match when there is no rotation
    but the rotation is not applied to the LogicRect. Therefore,
    what we calculate in online does not match in case of the rotated shape.
    Here we can send the correct gridOffset in the selection callback.
    whether the shape is rotated or not, we will always have the correct gridOffset
    Note that the gridOffset is always calculated from the first selected obj
    
    Change-Id: Icc62a94879367f9b55ad05887945393452021777
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113078
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index db05163b1ec4..a4af90341b25 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -710,6 +710,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView
     tools::Rectangle aSelection(rRect);
     bool bIsChart = false;
     Point addLogicOffset = Point(0,0);
+    bool convertMapMode = false;
     if (!rRect.IsEmpty())
     {
         sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
@@ -739,7 +740,10 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView
             if (OutputDevice* pOutputDevice = mpMarkedPV->GetView().GetFirstOutputDevice())
             {
                 if (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
+                {
                     aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+                    convertMapMode = true;
+                }
             }
         }
 
@@ -780,6 +784,26 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView
             aExtraInfo.append("\",\"type\":");
             aExtraInfo.append(OString::number(pO->GetObjIdentifier()));
 
+            // In core, the gridOffset is calculated based on the LogicRect's TopLeft coordinate
+            // In online, we have the SnapRect and we calculate it based on its TopLeft coordinate
+            // SnapRect's TopLeft and LogicRect's TopLeft match unless there is rotation
+            // but the rotation is not applied to the LogicRect. Therefore,
+            // what we calculate in online does not match with the core in case of the rotation.
+            // Here we can send the correct gridOffset in the selection callback, this way
+            // whether the shape is rotated or not, we will always have the correct gridOffset
+            // Note that the gridOffset is calculated from the first selected obj
+            basegfx::B2DVector aGridOffset(0.0, 0.0);
+            if(getPossibleGridOffsetForSdrObject(aGridOffset, GetMarkedObjectByIndex(0), GetSdrPageView()))
+            {
+                Point p(aGridOffset.getX(), aGridOffset.getY());
+                if (convertMapMode)
+                    p = OutputDevice::LogicToLogic(p, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+                aExtraInfo.append(",\"gridOffsetX\":");
+                aExtraInfo.append(OString::number(p.getX()));
+                aExtraInfo.append(",\"gridOffsetY\":");
+                aExtraInfo.append(OString::number(p.getY()));
+            }
+
             if (bWriterGraphic)
             {
                 aExtraInfo.append(", \"isWriterGraphic\": true");
@@ -916,7 +940,6 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxView
                 boost::property_tree::ptree poly;
                 boost::property_tree::ptree custom;
                 boost::property_tree::ptree nodes;
-                const bool convertMapMode = mpMarkedPV->GetView().GetFirstOutputDevice()->GetMapMode().GetMapUnit() == MapUnit::Map100thMM;
                 for (size_t i = 0; i < maHdlList.GetHdlCount(); i++)
                 {
                     SdrHdl *pHdl = maHdlList.GetHdl(i);
commit a4081f31d3b058c0016adb8b2cb83a64221cb3bc
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Wed Mar 24 12:06:08 2021 +0300
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon Mar 29 14:06:22 2021 +0200

    LOK: Fix Moving drag handles calculates wrong offset
    
    When dragging the shape handles for resizing,
    the handle's grid offset must be the shapes grid
    offset. In small numbered row&column orders, it is
    not visible much since the difference is very little
    but as the number gets greater, the difference becomes more visible.
    
    Change-Id: I44d03cc67a239c8b7758206930def331ed8e5e42
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113028
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
index e807b0a65610..78a065ff9fc5 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -41,6 +41,7 @@
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
 #include <svx/sdrpagewindow.hxx>
+#include <comphelper/lok.hxx>
 
 using namespace sdr;
 
@@ -225,10 +226,12 @@ bool SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl
 
         // Coordinate maybe affected by GridOffset, so we may need to
         // adapt to Model-coordinates here
-        if(getPossibleGridOffsetForPosition(
+        if((comphelper::LibreOfficeKit::isActive() && mpMarkedObj
+            && getPossibleGridOffsetForSdrObject(aGridOffset, GetMarkedObjectByIndex(0), GetSdrPageView()))
+            || (getPossibleGridOffsetForPosition(
             aGridOffset,
             basegfx::B2DPoint(aPnt.X(), aPnt.Y()),
-            GetSdrPageView()))
+            GetSdrPageView())))
         {
             aPnt.AdjustX(basegfx::fround(-aGridOffset.getX()));
             aPnt.AdjustY(basegfx::fround(-aGridOffset.getY()));
@@ -526,10 +529,12 @@ void SdrDragView::MovDragObj(const Point& rPnt)
 
         // Coordinate maybe affected by GridOffset, so we may need to
         // adapt to Model-coordinates here
-        if(getPossibleGridOffsetForPosition(
+        if((comphelper::LibreOfficeKit::isActive() && mpMarkedObj
+            && getPossibleGridOffsetForSdrObject(aGridOffset, GetMarkedObjectByIndex(0), GetSdrPageView()))
+            || (getPossibleGridOffsetForPosition(
             aGridOffset,
             basegfx::B2DPoint(aPnt.X(), aPnt.Y()),
-            GetSdrPageView()))
+            GetSdrPageView())))
         {
             aPnt.AdjustX(basegfx::fround(-aGridOffset.getX()));
             aPnt.AdjustY(basegfx::fround(-aGridOffset.getY()));


More information about the Libreoffice-commits mailing list