LibreOffice Module vcl (master)  1
Qt5DragAndDrop.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  */
10 
11 #pragma once
12 
13 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
14 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
15 #include <com/sun/star/lang/XInitialization.hpp>
16 #include <com/sun/star/lang/XServiceInfo.hpp>
17 #include <cppuhelper/compbase.hxx>
18 
19 class Qt5Frame;
20 
22  : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource,
23  css::lang::XInitialization, css::lang::XServiceInfo>
24 {
25  osl::Mutex m_aMutex;
27  css::uno::Reference<css::datatransfer::dnd::XDragSourceListener> m_xListener;
28 
29 public:
31  : WeakComponentImplHelper(m_aMutex)
32  , m_pFrame(nullptr)
33  {
34  }
35 
36  virtual ~Qt5DragSource() override;
37 
38  // XDragSource
39  virtual sal_Bool SAL_CALL isDragImageSupported() override;
40  virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction) override;
41  virtual void SAL_CALL startDrag(
42  const css::datatransfer::dnd::DragGestureEvent& trigger, sal_Int8 sourceActions,
43  sal_Int32 cursor, sal_Int32 image,
44  const css::uno::Reference<css::datatransfer::XTransferable>& transferable,
45  const css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& listener) override;
46 
47  // XInitialization
48  virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override;
49  void deinitialize();
50 
51  OUString SAL_CALL getImplementationName() override;
52 
53  sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
54 
55  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
56 
57  void fire_dragEnd(sal_Int8 nAction, bool bSuccessful);
58 };
59 
61  : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget,
62  css::datatransfer::dnd::XDropTargetDragContext,
63  css::datatransfer::dnd::XDropTargetDropContext,
64  css::lang::XInitialization, css::lang::XServiceInfo>
65 {
66  osl::Mutex m_aMutex;
69  bool m_bActive;
71  std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
73 
74 public:
75  Qt5DropTarget();
76  virtual ~Qt5DropTarget() override;
77 
78  // XInitialization
79  virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override;
80  void deinitialize();
81 
82  // XDropTarget
83  virtual void SAL_CALL addDropTargetListener(
84  const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
85  virtual void SAL_CALL removeDropTargetListener(
86  const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override;
87  virtual sal_Bool SAL_CALL isActive() override;
88  virtual void SAL_CALL setActive(sal_Bool active) override;
89  virtual sal_Int8 SAL_CALL getDefaultActions() override;
90  virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override;
91 
92  // XDropTargetDragContext
93  virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) override;
94  virtual void SAL_CALL rejectDrag() override;
95 
96  // XDropTargetDropContext
97  virtual void SAL_CALL acceptDrop(sal_Int8 dropOperation) override;
98  virtual void SAL_CALL rejectDrop() override;
99  virtual void SAL_CALL dropComplete(sal_Bool success) override;
100 
101  // XServiceInfo
102  OUString SAL_CALL getImplementationName() override;
103  sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
104  css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
105 
106  void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
107  void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent& dte);
108  void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde);
109  void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde);
110 
112  bool dropSuccessful() const { return m_bDropSuccessful; }
113 };
114 
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void deinitialize()
virtual void SAL_CALL acceptDrop(sal_Int8 dropOperation) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
signed char sal_Int8
void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent &dte)
sal_Int8 m_nDropAction
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
virtual void SAL_CALL rejectDrop() override
void deinitialize()
virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) override
virtual void SAL_CALL dropComplete(sal_Bool success) override
osl::Mutex m_aMutex
virtual void SAL_CALL startDrag(const css::datatransfer::dnd::DragGestureEvent &trigger, sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image, const css::uno::Reference< css::datatransfer::XTransferable > &transferable, const css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > &listener) override
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > m_xListener
void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtde)
OUString SAL_CALL getImplementationName() override
virtual ~Qt5DropTarget() override
virtual void SAL_CALL setActive(sal_Bool active) override
virtual ~Qt5DragSource() override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
bool dropSuccessful() const
unsigned char sal_Bool
void fire_dragEnd(sal_Int8 nAction, bool bSuccessful)
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
std::vector< css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > > m_aListeners
sal_Int8 m_nDefaultActions
virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction) override
OUString SAL_CALL getImplementationName() override
sal_Int8 proposedDropAction() const
Qt5Frame * m_pFrame
virtual sal_Bool SAL_CALL isActive() override
virtual void SAL_CALL rejectDrag() override
virtual void SAL_CALL addDropTargetListener(const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > &) override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override
void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtde)
virtual sal_Int8 SAL_CALL getDefaultActions() override
osl::Mutex m_aMutex
virtual sal_Bool SAL_CALL isDragImageSupported() override
Qt5Frame * m_pFrame
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArgs) override
virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > &) override
void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde)