vcl/inc/qt5/Qt5DragAndDrop.hxx |    2 ++
 vcl/qt5/Qt5DragAndDrop.cxx     |   26 ++++++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 058537c95d172b4cb1256c1c6542860f4712cf21
Author:     Katarina Behrens <katarina.behr...@cib.de>
AuthorDate: Mon Apr 29 14:50:32 2019 +0200
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Tue Apr 30 23:46:20 2019 +0200

    tdf#124990: DnD operation can be set to fail in dropComplete
    
    thus we reimplement it for Qt5DropTarget. This is qt5 remix of
    tdf#118302 (in Calc drop into the same tab should cancel DnD, instead
    of causing data loss)
    
    Change-Id: Ib37ea5a018133779e85e8e131d81bb6cee7d9206
    Reviewed-on: https://gerrit.libreoffice.org/71531
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <katarina.behr...@cib.de>
    (cherry picked from commit cc6c1798b8d6d9d27dc40145e1ec71dd480c788a)
    Reviewed-on: https://gerrit.libreoffice.org/71569
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    Tested-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx
index 099ba444ea15..3547131587f3 100644
--- a/vcl/inc/qt5/Qt5DragAndDrop.hxx
+++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx
@@ -75,6 +75,8 @@ public:
     void fire_dragEnd(sal_Int8 nAction);
 
     static Qt5DragSource* m_ActiveDragSource;
+    static bool m_bDropSuccessSet;
+    static bool m_bDropSuccess;
 
     css::uno::Reference<css::datatransfer::XTransferable> const& 
GetTransferable() const
     {
diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx
index adc7a94fa0c2..42e61074a824 100644
--- a/vcl/qt5/Qt5DragAndDrop.cxx
+++ b/vcl/qt5/Qt5DragAndDrop.cxx
@@ -94,6 +94,9 @@ std::vector<css::datatransfer::DataFlavor> 
Qt5DnDTransferable::getTransferDataFl
     return aVector;
 }
 
+bool Qt5DragSource::m_bDropSuccessSet = false;
+bool Qt5DragSource::m_bDropSuccess = false;
+
 Qt5DragSource::~Qt5DragSource()
 {
     //if (m_pFrame)
@@ -140,6 +143,8 @@ void Qt5DragSource::startDrag(
     {
         Qt5Widget* qw = static_cast<Qt5Widget*>(m_pFrame->GetQWidget());
         m_ActiveDragSource = this;
+        m_bDropSuccessSet = false;
+        m_bDropSuccess = false;
         qw->startDrag(sourceActions);
     }
     else
@@ -165,7 +170,14 @@ void Qt5DragSource::fire_dragEnd(sal_Int8 nAction)
     {
         datatransfer::dnd::DragSourceDropEvent aEv;
         aEv.DropAction = nAction;
-        aEv.DropSuccess = true; // FIXME: what if drop didn't work out?
+
+        // internal DnD can accept the drop
+        // but still fail in Qt5DropTarget::dropComplete
+        if (m_bDropSuccessSet)
+            aEv.DropSuccess = m_bDropSuccess;
+        else
+            aEv.DropSuccess = true;
+
         auto xListener = m_xListener;
         m_xListener.clear();
         xListener->dragDropEnd(aEv);
@@ -341,6 +353,16 @@ void Qt5DropTarget::rejectDrop()
     return;
 }
 
-void Qt5DropTarget::dropComplete(sal_Bool /*success*/) { return; }
+void Qt5DropTarget::dropComplete(sal_Bool success)
+{
+    // internal DnD
+    if (Qt5DragSource::m_ActiveDragSource)
+    {
+        Qt5DragSource::m_bDropSuccessSet = true;
+        Qt5DragSource::m_bDropSuccess = success;
+    }
+
+    return;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to