include/svx/svddrag.hxx            |   12 ++++++++++++
 include/svx/svdoedge.hxx           |    2 +-
 include/svx/svdview.hxx            |    3 ++-
 sc/source/ui/drawfunc/drawsh.cxx   |    5 +++--
 sd/source/ui/view/drviews2.cxx     |    6 ++++--
 svx/sdi/svx.sdi                    |    2 +-
 svx/source/svdraw/svdoedge.cxx     |   22 ++++++++++++++++++++--
 svx/source/svdraw/svdview.cxx      |   17 ++++++++++++-----
 sw/source/uibase/shells/drawsh.cxx |    5 +++--
 sw/source/uibase/uiview/view2.cxx  |    5 +++--
 10 files changed, 61 insertions(+), 18 deletions(-)

New commits:
commit b18bff18785cc194f9918f6bdf000069523827ef
Author:     merttumer <mert.tu...@collabora.com>
AuthorDate: Fri Apr 2 16:18:05 2021 +0300
Commit:     Mert Tumer <mert.tu...@collabora.com>
CommitDate: Tue Apr 20 06:52:26 2021 +0200

    lok: Pass object ord num in the uno command
    
    When multiple objects' glue points collide the ordnum
    will be used to decide which glue point to connect to
    for the connectors. Without that the default logic chooses
    the lowest ordered object which is searched and found in the object list
    
    Change-Id: I64579d28bbe6cbd92bab745838fe2995585b6a3f
    Signed-off-by: merttumer <mert.tu...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113517
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114032
    Tested-by: Jenkins

diff --git a/include/svx/svddrag.hxx b/include/svx/svddrag.hxx
index 80c2406b9046..6718e5f36b5d 100644
--- a/include/svx/svddrag.hxx
+++ b/include/svx/svddrag.hxx
@@ -79,6 +79,16 @@ class SVXCORE_DLLPUBLIC SdrDragStat final
 
     sal_Int32 GetPrevPos() const { return mvPnts.size()-(mvPnts.size()>1 ? 2 : 
1); }
 
+    // This is passed all the way through to ApplySpecialDrag of the Edge 
Object
+    // For LOK, we cannot really specify which glue point to select by default
+    // It selects the nearest glue points after DragEnd event.
+    // When multiple objects are on top of each other or somehow their glue 
points
+    // collide, the glue point is selected from the lowest order numbered 
object
+    // We can pass the ord number information inside the draginfo and choose 
the correct shape
+    struct {
+        sal_Int32 objectOrdNum = -1;
+    } mGlueOptions;
+
 public:
     SdrDragStat()                                    { Reset(); }
     ~SdrDragStat();
@@ -158,6 +168,8 @@ public:
 
     // Also considering 1stPointAsCenter
     void         TakeCreateRect(tools::Rectangle& rRect) const;
+
+    auto&        GetGlueOptions() { return mGlueOptions; }
 };
 
 #endif // INCLUDED_SVX_SVDDRAG_HXX
diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx
index fe09104dbc4e..17108ad856ec 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -177,7 +177,7 @@ protected:
     XPolygon ImpCalcEdgeTrack(const Point& rPt1, tools::Long nAngle1, const 
tools::Rectangle& rBoundRect1, const tools::Rectangle& rBewareRect1,
         const Point& rPt2, tools::Long nAngle2, const tools::Rectangle& 
rBoundRect2, const tools::Rectangle& rBewareRect2,
         sal_uIntPtr* pnQuality, SdrEdgeInfoRec* pInfo) const;
-    static bool ImpFindConnector(const Point& rPt, const SdrPageView& rPV, 
SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut=nullptr);
+    static bool ImpFindConnector(const Point& rPt, const SdrPageView& rPV, 
SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut=nullptr, 
SdrDragStat* pDragStat = nullptr);
     static SdrEscapeDirection ImpCalcEscAngle(SdrObject const * pObj, const 
Point& aPt2);
     void ImpSetTailPoint(bool bTail1, const Point& rPt);
     void ImpUndirtyEdgeTrack();  // potential recalculation of the connection 
track
diff --git a/include/svx/svdview.hxx b/include/svx/svdview.hxx
index 149b17f9ece9..7020f6447b4d 100644
--- a/include/svx/svdview.hxx
+++ b/include/svx/svdview.hxx
@@ -242,7 +242,8 @@ public:
         SdrPageWindow& rPageWindow,
         const char* pDebugName) const;
 
-    bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint);
+    // Interactive Move Action programmaticaly
+    bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint, 
const sal_Int32 aObjectOrdNum = -1);
 };
 
 // First of all the app creates a SdrModel.
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 90bf9f8e51cd..4a46f3d69c90 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -205,16 +205,17 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq )
         case SID_MOVE_SHAPE_HANDLE:
         {
             const SfxItemSet *pArgs = rReq.GetArgs ();
-            if (pArgs && pArgs->Count () == 3)
+            if (pArgs && pArgs->Count () >= 3)
             {
                 const SfxUInt32Item* handleNumItem = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_1);
                 const SfxUInt32Item* newPosXTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
                 const SfxUInt32Item* newPosYTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_3);
+                const SfxInt32Item* OrdNum = 
rReq.GetArg<SfxInt32Item>(FN_PARAM_4);
 
                 const sal_uLong handleNum = handleNumItem->GetValue();
                 const sal_uLong newPosX = 
convertTwipToMm100(newPosXTwips->GetValue());
                 const sal_uLong newPosY = 
convertTwipToMm100(newPosYTwips->GetValue());
-                pView->MoveShapeHandle(handleNum, Point(newPosX, newPosY));
+                pView->MoveShapeHandle(handleNum, Point(newPosX, newPosY), 
OrdNum ? OrdNum->GetValue() : -1);
             }
         }
         break;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 950fdf5f15cc..273da605c81e 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1493,16 +1493,18 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_MOVE_SHAPE_HANDLE:
         {
             const SfxItemSet *pArgs = rReq.GetArgs ();
-            if (pArgs && pArgs->Count () == 3)
+            if (pArgs && pArgs->Count () >= 3)
             {
                 const SfxUInt32Item* handleNumItem = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_1);
                 const SfxUInt32Item* newPosXTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
                 const SfxUInt32Item* newPosYTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_3);
+                const SfxInt32Item* OrdNum = 
rReq.GetArg<SfxInt32Item>(FN_PARAM_4);
 
                 const sal_uLong handleNum = handleNumItem->GetValue();
                 const sal_uLong newPosX = 
convertTwipToMm100(newPosXTwips->GetValue());
                 const sal_uLong newPosY = 
convertTwipToMm100(newPosYTwips->GetValue());
-                mpDrawView->MoveShapeHandle(handleNum, Point(newPosX, 
newPosY));
+
+                mpDrawView->MoveShapeHandle(handleNum, Point(newPosX, 
newPosY), OrdNum ? OrdNum->GetValue() : -1);
                 Cancel();
             }
             break;
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 8e580d5977c1..a432c7032a7f 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12515,7 +12515,7 @@ SdrMetricItem SoftEdgeRadius SID_ATTR_SOFTEDGE_RADIUS
 ]
 
 SfxVoidItem MoveShapeHandle SID_MOVE_SHAPE_HANDLE
-(SfxUInt32Item HandleNum FN_PARAM_1 SfxUInt32Item NewPosX FN_PARAM_2 
SfxUInt32Item NewPosY FN_PARAM_3)
+(SfxUInt32Item HandleNum FN_PARAM_1 SfxUInt32Item NewPosX FN_PARAM_2 
SfxUInt32Item NewPosY FN_PARAM_3 SfxInt32Item OrdNum FN_PARAM_4)
 [
     AutoUpdate = FALSE,
     FastCall = TRUE,
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 4084f1e91dbe..e31e2bf8a85e 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1911,7 +1911,7 @@ bool SdrEdgeObj::applySpecialDrag(SdrDragStat& rDragStat)
             DisconnectFromNode(bDragA);
 
             // look for new connection
-            ImpFindConnector(aPointNow, *rDragStat.GetPageView(), 
*pDraggedOne, pOriginalEdge);
+            ImpFindConnector(aPointNow, *rDragStat.GetPageView(), 
*pDraggedOne, pOriginalEdge, nullptr, &rDragStat);
 
             if(pDraggedOne->pObj)
             {
@@ -2132,7 +2132,7 @@ PointerStyle SdrEdgeObj::GetCreatePointer() const
     return PointerStyle::DrawConnect;
 }
 
-bool SdrEdgeObj::ImpFindConnector(const Point& rPt, const SdrPageView& rPV, 
SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut)
+bool SdrEdgeObj::ImpFindConnector(const Point& rPt, const SdrPageView& rPV, 
SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut, 
SdrDragStat* pDragStat)
 {
     rCon.ResetVars();
     if (pOut==nullptr) pOut=rPV.GetView().GetFirstOutputDevice();
@@ -2155,11 +2155,29 @@ bool SdrEdgeObj::ImpFindConnector(const Point& rPt, 
const SdrPageView& rPV, SdrO
     size_t no=pOL->GetObjCount();
     bool bFnd = false;
     SdrObjConnection aTestCon;
+    bool bTiledRendering = comphelper::LibreOfficeKit::isActive();
+    bool bHasRequestedOrdNum = false;
+    sal_Int32 requestedOrdNum = -1;
+
+    if (bTiledRendering && pDragStat)
+    {
+        auto& glueOptions = pDragStat->GetGlueOptions();
+        if (glueOptions.objectOrdNum != -1)
+        {
+            requestedOrdNum = glueOptions.objectOrdNum;
+            bHasRequestedOrdNum = true;
+        }
+    }
 
     while (no>0 && !bFnd) {
         // issue: group objects on different layers return LayerID=0!
         no--;
         SdrObject* pObj=pOL->GetObj(no);
+        if (bHasRequestedOrdNum)
+        {
+            if (pObj->GetOrdNumDirect() != 
static_cast<sal_uInt32>(requestedOrdNum))
+                continue;
+        }
         if (rVisLayer.IsSet(pObj->GetLayer()) && pObj->IsVisible() &&      // 
only visible objects
             (pThis==nullptr || pObj!=static_cast<SdrObject const *>(pThis))) 
// don't connect it to itself
         {
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index c07eee69cee3..2cbed57bb1c2 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -1407,7 +1407,7 @@ bool SdrView::BegMark(const Point& rPnt, bool bAddMark, 
bool bUnmark)
     }
 }
 
-bool SdrView::MoveShapeHandle(const sal_uInt32 handleNum, const Point& 
aEndPoint)
+bool SdrView::MoveShapeHandle(const sal_uInt32 handleNum, const Point& 
aEndPoint, const sal_Int32 aObjectOrdNum)
 {
     if (GetHdlList().IsMoveOutside())
         return false;
@@ -1419,7 +1419,7 @@ bool SdrView::MoveShapeHandle(const sal_uInt32 handleNum, 
const Point& aEndPoint
     if (pHdl == nullptr)
         return false;
 
-    const SdrDragStat& rDragStat = GetDragStat();
+    SdrDragStat& rDragStat = const_cast<SdrDragStat&>(GetDragStat());
     // start dragging
     BegDragObj(pHdl->GetPos(), nullptr, pHdl, 0);
     if (!IsDragObj())
@@ -1430,15 +1430,22 @@ bool SdrView::MoveShapeHandle(const sal_uInt32 
handleNum, const Point& aEndPoint
 
     // switch snapping off
     if(!bWasNoSnap)
-        const_cast<SdrDragStat&>(rDragStat).SetNoSnap();
+        rDragStat.SetNoSnap();
     if(bWasSnapEnabled)
         SetSnapEnabled(false);
 
-    MovAction(aEndPoint);
+    if (aObjectOrdNum != -1)
+    {
+        rDragStat.GetGlueOptions().objectOrdNum = aObjectOrdNum;
+    }
+    MovDragObj(aEndPoint);
     EndDragObj();
 
+    // Clear Glue Options
+    rDragStat.GetGlueOptions().objectOrdNum = -1;
+
     if (!bWasNoSnap)
-        const_cast<SdrDragStat&>(rDragStat).SetNoSnap(bWasNoSnap);
+       rDragStat.SetNoSnap(bWasNoSnap);
     if (bWasSnapEnabled)
         SetSnapEnabled(bWasSnapEnabled);
 
diff --git a/sw/source/uibase/shells/drawsh.cxx 
b/sw/source/uibase/shells/drawsh.cxx
index 4c6629274bca..9f0de0c2a0f1 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -200,16 +200,17 @@ void SwDrawShell::Execute(SfxRequest &rReq)
             break;
         case SID_MOVE_SHAPE_HANDLE:
         {
-            if (pArgs && pArgs->Count() == 3)
+            if (pArgs && pArgs->Count() >= 3)
             {
                 const SfxUInt32Item* handleNumItem = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_1);
                 const SfxUInt32Item* newPosXTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
                 const SfxUInt32Item* newPosYTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_3);
+                const SfxInt32Item* OrdNum = 
rReq.GetArg<SfxInt32Item>(FN_PARAM_4);
 
                 const sal_uLong handleNum = handleNumItem->GetValue();
                 const sal_uLong newPosX = newPosXTwips->GetValue();
                 const sal_uLong newPosY = newPosYTwips->GetValue();
-                pSdrView->MoveShapeHandle(handleNum, Point(newPosX, newPosY));
+                pSdrView->MoveShapeHandle(handleNum, Point(newPosX, newPosY), 
OrdNum ? OrdNum->GetValue() : -1);
             }
         }
         break;
diff --git a/sw/source/uibase/uiview/view2.cxx 
b/sw/source/uibase/uiview/view2.cxx
index 941b82d038f8..db33b8c77c1d 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -1389,7 +1389,7 @@ void SwView::Execute(SfxRequest &rReq)
         break;
         case SID_MOVE_SHAPE_HANDLE:
         {
-            if (pArgs && pArgs->Count() == 3)
+            if (pArgs && pArgs->Count() >= 3)
             {
                 SdrView *pSdrView = m_pWrtShell->HasDrawView() ? 
m_pWrtShell->GetDrawView() : nullptr;
                 if (pSdrView == nullptr)
@@ -1397,11 +1397,12 @@ void SwView::Execute(SfxRequest &rReq)
                 const SfxUInt32Item* handleNumItem = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_1);
                 const SfxUInt32Item* newPosXTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
                 const SfxUInt32Item* newPosYTwips = 
rReq.GetArg<SfxUInt32Item>(FN_PARAM_3);
+                const SfxInt32Item* OrdNum = 
rReq.GetArg<SfxInt32Item>(FN_PARAM_4);
 
                 const sal_uLong handleNum = handleNumItem->GetValue();
                 const sal_uLong newPosX = newPosXTwips->GetValue();
                 const sal_uLong newPosY = newPosYTwips->GetValue();
-                pSdrView->MoveShapeHandle(handleNum, Point(newPosX, newPosY));
+                pSdrView->MoveShapeHandle(handleNum, Point(newPosX, newPosY), 
OrdNum ? OrdNum->GetValue() : -1);
             }
             break;
         }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to