LibreOffice Module vcl (master) 1
qt5/QtDragAndDrop.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>
18
19class QtFrame;
20
21class QtDragSource final
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
29public:
31 : WeakComponentImplHelper(m_aMutex)
32 , m_pFrame(nullptr)
33 {
34 }
35
36 virtual ~QtDragSource() 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;
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
60class QtDropTarget final
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;
71 std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
73
74public:
76 virtual ~QtDropTarget() override;
77
78 // XInitialization
79 virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override;
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: */
virtual ~QtDragSource() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
OUString SAL_CALL getImplementationName() override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
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
virtual sal_Bool SAL_CALL isDragImageSupported() override
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > m_xListener
void fire_dragEnd(sal_Int8 nAction, bool bSuccessful)
void deinitialize()
osl::Mutex m_aMutex
virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction) override
virtual void SAL_CALL acceptDrop(sal_Int8 dropOperation) override
virtual void SAL_CALL dropComplete(sal_Bool success) override
sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArgs) override
virtual void SAL_CALL acceptDrag(sal_Int8 dragOperation) override
bool dropSuccessful() const
virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > &) override
virtual void SAL_CALL setActive(sal_Bool active) override
void deinitialize()
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~QtDropTarget() override
void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde)
virtual void SAL_CALL addDropTargetListener(const css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > &) override
OUString SAL_CALL getImplementationName() override
void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtde)
virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override
std::vector< css::uno::Reference< css::datatransfer::dnd::XDropTargetListener > > m_aListeners
void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent &dte)
virtual sal_Bool SAL_CALL isActive() override
osl::Mutex m_aMutex
virtual void SAL_CALL rejectDrop() override
sal_Int8 proposedDropAction() const
sal_Int8 m_nDefaultActions
virtual sal_Int8 SAL_CALL getDefaultActions() override
void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtde)
sal_Int8 m_nDropAction
virtual void SAL_CALL rejectDrag() override
unsigned char sal_Bool
signed char sal_Int8