summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerttumer <mert.tumer@collabora.com>2021-04-02 16:18:05 +0300
committerMert Tumer <mert.tumer@collabora.com>2021-04-09 08:15:07 +0200
commita33f16fd4127030a25b4ef0e4e965b8aa07afcb7 (patch)
tree7ac6ee964d7d82c53a827682eef390eaaa6dd7b7
parent47f5876b94d6c2d12df4fd08a92ba21320ca4fba (diff)
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@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113517 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r--include/svx/svddrag.hxx12
-rw-r--r--include/svx/svdoedge.hxx2
-rw-r--r--include/svx/svdview.hxx2
-rw-r--r--sc/source/ui/drawfunc/drawsh.cxx5
-rw-r--r--sd/source/ui/view/drviews2.cxx6
-rw-r--r--svx/sdi/svx.sdi2
-rw-r--r--svx/source/svdraw/svdoedge.cxx22
-rw-r--r--svx/source/svdraw/svdview.cxx13
-rw-r--r--sw/source/uibase/shells/drawsh.cxx5
-rw-r--r--sw/source/uibase/uiview/view2.cxx5
10 files changed, 58 insertions, 16 deletions
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;
}