[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - include/svx sc/source sd/source svx/sdi svx/source sw/source

merttumer (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 9 06:15:30 UTC 2021


 include/svx/svddrag.hxx            |   12 +++++++
 include/svx/svdoedge.hxx           |    2 -
 include/svx/svdview.hxx            |    2 -
 sc/source/ui/drawfunc/drawsh.cxx   |    5 +-
 sd/source/ui/view/drviews2.cxx     |    6 ++-
 svx/sdi/svx.sdi                    |    2 -
 svx/source/svdraw/svdmrkv.cxx      |   62 ++++++++++++++++++++++---------------
 svx/source/svdraw/svdoedge.cxx     |   22 +++++++++++--
 svx/source/svdraw/svdview.cxx      |   13 +++++--
 sw/source/uibase/shells/drawsh.cxx |    5 +-
 sw/source/uibase/uiview/view2.cxx  |    5 +-
 11 files changed, 96 insertions(+), 40 deletions(-)

New commits:
commit a33f16fd4127030a25b4ef0e4e965b8aa07afcb7
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Fri Apr 2 16:18:05 2021 +0300
Commit:     Mert Tumer <mert.tumer at collabora.com>
CommitDate: Fri Apr 9 08:15:07 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.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113517
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/include/svx/svddrag.hxx b/include/svx/svddrag.hxx
index d1fde32edda0..c1956d56af9f 100644
--- a/include/svx/svddrag.hxx
+++ b/include/svx/svddrag.hxx
@@ -79,6 +79,16 @@ class SVX_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 e6399da73bda..56c2f21c66da 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -177,7 +177,7 @@ protected:
     XPolygon ImpCalcEdgeTrack(const Point& rPt1, long nAngle1, const tools::Rectangle& rBoundRect1, const tools::Rectangle& rBewareRect1,
         const Point& rPt2, 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 e4a6168ef425..5fda8cd58c13 100644
--- a/include/svx/svdview.hxx
+++ b/include/svx/svdview.hxx
@@ -243,7 +243,7 @@ public:
         const sal_Char* pDebugName) const;
 
     // Interactive Move Action programmaticaly
-    bool MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint);
+    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 57afdd6da65a..9e28af35c0d1 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -206,16 +206,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 b530b0bd1658..3bf1521a640f 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1501,16 +1501,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 e5107db90048..039c43171a45 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12279,7 +12279,7 @@ SfxVoidItem SpellCheckApplySuggestion SID_SPELLCHECK_APPLY_SUGGESTION
 ]
 
 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 99dee49aa2d2..d767a92bbbf6 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1909,7 +1909,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)
             {
@@ -2130,7 +2130,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();
@@ -2153,11 +2153,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_uInt32 requestedOrdNum = -1;
+
+    if (bTiledRendering && pDragStat)
+    {
+        auto& glueOptions = pDragStat->GetGlueOptions();
+        if (glueOptions.objectOrdNum != -1)
+        {
+            requestedOrdNum = static_cast<sal_uInt32>(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() != 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 394b3af6bd06..36fd070e1205 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -1426,7 +1426,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;
@@ -1438,7 +1438,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())
@@ -1453,9 +1453,16 @@ bool SdrView::MoveShapeHandle(const sal_uInt32 handleNum, const Point& aEndPoint
     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);
     if (bWasSnapEnabled)
diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx
index e5169e229041..a37d57f84e28 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -221,16 +221,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 760f18fc56df..1224842d09fe 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -1294,7 +1294,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)
@@ -1302,11 +1302,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;
         }
commit 47f5876b94d6c2d12df4fd08a92ba21320ca4fba
Author:     merttumer <mert.tumer at collabora.com>
AuthorDate: Fri Apr 2 16:14:55 2021 +0300
Commit:     Mert Tumer <mert.tumer at collabora.com>
CommitDate: Fri Apr 9 08:14:54 2021 +0200

    Improve dumpGluePointsAsJSON
    
    added gridoffset for the shape for calc
    changed the logic, now the ordnum would be enough
    
    Change-Id: Iebe7d29c569a4cb968fe2e5ef1692b59f0c4b2d8
    Signed-off-by: merttumer <mert.tumer at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113516

diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index c2d4c09282e3..875d0dfc3993 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -712,37 +712,51 @@ bool SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree)
         if (rOutDev->GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
             bConvertUnit = true;
         const SdrObjList* pOL = mpMarkedPV->GetObjList();
+        if (!pOL)
+            return false;
         const size_t nObjCount = pOL->GetObjCount();
         boost::property_tree::ptree elements;
         for (size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum)
         {
-            const SdrObject* pObj = pOL->GetObj(nObjNum);
+            SdrObject* pObj = pOL->GetObj(nObjNum);
+            if (!pObj)
+                continue;
+            if (pObj == GetMarkedObjectByIndex(0))
+                continue;
             const SdrGluePointList* pGPL = pObj->GetGluePointList();
-            if (pGPL != nullptr && pGPL->GetCount())
+            bool VertexObject = !(pGPL && pGPL->GetCount());
+            const size_t count = !VertexObject ? pGPL->GetCount() : 4;
+            boost::property_tree::ptree object;
+            boost::property_tree::ptree points;
+            for (size_t i = 0; i < count; ++i)
             {
-                boost::property_tree::ptree object;
-                boost::property_tree::ptree points;
-                for (size_t i = 0; i < pGPL->GetCount(); ++i)
-                {
-                    boost::property_tree::ptree node;
-                    boost::property_tree::ptree point;
-                    const SdrGluePoint& rGP = (*pGPL)[i];
-                    // coordinates are relative to the OBJ snap rect
-                    Point rPoint = pObj->GetSnapRect().TopLeft();
-                    rPoint.Move(rGP.GetPos().getX(), rGP.GetPos().getY());
-                    if (bConvertUnit)
-                        rPoint = OutputDevice::LogicToLogic(rPoint, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
-                    point.put("x", rPoint.getX());
-                    point.put("y", rPoint.getY());
-                    node.put("glueId", rGP.GetId());
-                    node.add_child("point", point);
-                    points.push_back(std::make_pair("", node));
-                }
-                object.put("id", reinterpret_cast<sal_IntPtr>(pObj));
-                object.add_child("gluepoints", points);
-                elements.push_back(std::make_pair("", object));
-                result = true;
+                boost::property_tree::ptree node;
+                boost::property_tree::ptree point;
+                const SdrGluePoint& rGP = !VertexObject ? (*pGPL)[i] : pObj->GetVertexGluePoint(i);
+                Point rPoint = rGP.GetAbsolutePos(*pObj);
+                if (bConvertUnit)
+                    rPoint = OutputDevice::LogicToLogic(rPoint, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+                point.put("x", rPoint.getX());
+                point.put("y", rPoint.getY());
+                node.add_child("point", point);
+                points.push_back(std::make_pair("", node));
+            }
+            basegfx::B2DVector aGridOffset(0.0, 0.0);
+            Point objLogicRectTopLeft = pObj->GetLogicRect().TopLeft();
+            if(getPossibleGridOffsetForPosition(aGridOffset, basegfx::B2DPoint(objLogicRectTopLeft.X(), objLogicRectTopLeft.Y()), GetSdrPageView()))
+            {
+                Point p(aGridOffset.getX(), aGridOffset.getY());
+                if (bConvertUnit)
+                    p = OutputDevice::LogicToLogic(p, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+                boost::property_tree::ptree gridOffset;
+                gridOffset.put("x", p.getX());
+                gridOffset.put("y", p.getY());
+                object.add_child("gridoffset", gridOffset);
             }
+            object.put("ordnum", pObj->GetOrdNum());
+            object.add_child("gluepoints", points);
+            elements.push_back(std::make_pair("", object));
+            result = true;
         }
         rTree.add_child("shapes", elements);
     }


More information about the Libreoffice-commits mailing list