tdf#145359 related: Fix SdNavigator dnd z ordering
Makes the object dnd z order follow the current behavior of bring
forward and send back actions. Object placement top to bottom in the
Navigator is wrt object z order back to front.
Change-Id: I42e0902eabe7a2758a075a5f4357868994825a51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150810
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 87780ba..efb027c 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -55,6 +55,8 @@
#include <vcl/commandevent.hxx>
#include <svx/svdview.hxx>
using namespace com::sun::star;
bool SdPageObjsTLV::bIsInDrag = false;
@@ -413,6 +415,7 @@ bool SdPageObjsTLV::DoDrag()
return true;
}
m_xDropTargetHelper->SetDrawView(pViewShell->GetDrawView());
bIsInDrag = true;
std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
@@ -559,8 +562,8 @@ sal_Int8 SdPageObjsTLVDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
m_rTreeView.iter_previous_sibling(*xTarget);
m_rTreeView.set_cursor(*xTarget);
if (m_rTreeView.iter_compare(*xSourceParent, *xTargetParent) == 0 && nIterCompare < 0)
nTargetPos = m_rTreeView.get_iter_index_in_parent(*xTarget);
// Remove and insert are required for moving objects in to and out of groups.
// PutMarked... by itself would suffice if this wasn't allowed.
// Remove the source object from source parent list and insert it in the target parent list.
SdrObject* pSourceParentObject = weld::fromId<SdrObject*>(m_rTreeView.get_id(*xSourceParent));
@@ -585,14 +588,14 @@ sal_Int8 SdPageObjsTLVDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
if (pTargetParentObject == reinterpret_cast<SdrObject*>(1))
{
pObjectList->NbcInsertObject(rSourceObject.get());
pObjectList->SetObjectNavigationPosition(*rSourceObject, nTargetPos);
}
else
{
SdrObjList* pList = pTargetParentObject->GetSubList();
pList->NbcInsertObject(rSourceObject.get(), nTargetPos);
pList->SetObjectNavigationPosition(*rSourceObject, nTargetPos);
pList->NbcInsertObject(rSourceObject.get());
}
m_pSdrView->PutMarkedBehindObj(pTargetObject);
}
return DND_ACTION_NONE;
diff --git a/sd/source/ui/inc/sdtreelb.hxx b/sd/source/ui/inc/sdtreelb.hxx
index 81a535c..07e79c5 100644
--- a/sd/source/ui/inc/sdtreelb.hxx
+++ b/sd/source/ui/inc/sdtreelb.hxx
@@ -28,6 +28,7 @@
#include <memory>
#include <vector>
class SdrView;
class SdDrawDocument;
class SfxMedium;
class SfxViewFrame;
@@ -54,12 +55,15 @@ class SdPageObjsTLVDropTarget final : public DropTargetHelper
{
private:
weld::TreeView& m_rTreeView;
SdrView* m_pSdrView;
virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
public:
SdPageObjsTLVDropTarget(weld::TreeView& rTreeView);
void SetDrawView(SdrView* pSdrView) { m_pSdrView = pSdrView; }
};
class SD_DLLPUBLIC SdPageObjsTLV