1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
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>
21 class Qt5DragSource final
22 : public cppu::WeakComponentImplHelper
<css::datatransfer::dnd::XDragSource
,
23 css::lang::XInitialization
, css::lang::XServiceInfo
>
27 css::uno::Reference
<css::datatransfer::dnd::XDragSourceListener
> m_xListener
;
31 : WeakComponentImplHelper(m_aMutex
)
36 virtual ~Qt5DragSource() override
;
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
;
48 virtual void SAL_CALL
initialize(const css::uno::Sequence
<css::uno::Any
>& rArguments
) override
;
51 OUString SAL_CALL
getImplementationName() override
;
53 sal_Bool SAL_CALL
supportsService(OUString
const& ServiceName
) override
;
55 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
57 void fire_dragEnd(sal_Int8 nAction
, bool bSuccessful
);
60 class Qt5DropTarget 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
>
68 sal_Int8 m_nDropAction
;
70 sal_Int8 m_nDefaultActions
;
71 std::vector
<css::uno::Reference
<css::datatransfer::dnd::XDropTargetListener
>> m_aListeners
;
72 bool m_bDropSuccessful
;
76 virtual ~Qt5DropTarget() override
;
79 virtual void SAL_CALL
initialize(const css::uno::Sequence
<css::uno::Any
>& rArgs
) override
;
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
;
92 // XDropTargetDragContext
93 virtual void SAL_CALL
acceptDrag(sal_Int8 dragOperation
) override
;
94 virtual void SAL_CALL
rejectDrag() override
;
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
;
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
;
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
);
111 sal_Int8
proposedDropAction() const { return m_nDropAction
; }
112 bool dropSuccessful() const { return m_bDropSuccessful
; }
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */