LibreOffice Module vcl (master) 1
dndeventdispatcher.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_VCL_INC_DNDEVENTDISPATCHER_HXX
21#define INCLUDED_VCL_INC_DNDEVENTDISPATCHER_HXX
22
23#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp>
24#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp>
25
26#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp>
28#include <vcl/window.hxx>
29#include <mutex>
30
31class DNDEventDispatcher final : public ::cppu::WeakImplHelper<
32 css::datatransfer::dnd::XDropTargetListener,
33 css::datatransfer::dnd::XDropTargetDragContext,
34 css::datatransfer::dnd::XDragGestureListener >
35{
37
40 DECL_LINK(WindowEventListener, VclWindowEvent&, void);
41
42 std::recursive_mutex m_aMutex;
43 css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavorList;
44
46 /*
47 * fire the events on the dnd listener container of the specified window
48 */
49
51 static sal_Int32 fireDragEnterEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext >& xContext,
52 const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction,
53 const css::uno::Sequence< css::datatransfer::DataFlavor >& aFlavorList );
54
56 static sal_Int32 fireDragOverEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext >& xContext,
57 const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction );
58
60 static sal_Int32 fireDragExitEvent( vcl::Window *pWindow );
61
63 static sal_Int32 fireDropActionChangedEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext >& xContext,
64 const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction );
65
67 static sal_Int32 fireDropEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDropContext >& xContext,
68 const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction,
69 const css::uno::Reference< css::datatransfer::XTransferable >& xTransferable );
70
72 static sal_Int32 fireDragGestureEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDragSource >& xSource,
73 const css::uno::Any& event, const Point& rOrigin, const sal_Int8 nDragAction );
74
75public:
76
77 DNDEventDispatcher( vcl::Window * pTopWindow );
78 virtual ~DNDEventDispatcher() override;
79
80 /*
81 * XDropTargetDragContext
82 */
83
84 virtual void SAL_CALL acceptDrag( sal_Int8 dropAction ) override;
85 virtual void SAL_CALL rejectDrag() override;
86
87 /*
88 * XDropTargetListener
89 */
90
91 virtual void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
92 virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
93 virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
94 virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
95 virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
96
97 /*
98 * XDragGestureListener
99 */
100
101 virtual void SAL_CALL dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override;
102
103 /*
104 * XEventListener
105 */
106
107 virtual void SAL_CALL disposing( const css::lang::EventObject& eo ) override;
108};
109
110#endif
111
112/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
static sal_Int32 fireDragGestureEvent(vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDragSource > &xSource, const css::uno::Any &event, const Point &rOrigin, const sal_Int8 nDragAction)
virtual void SAL_CALL dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
virtual void SAL_CALL disposing(const css::lang::EventObject &eo) override
static sal_Int32 fireDragOverEvent(vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext > &xContext, const sal_Int8 nDropAction, const Point &rLocation, const sal_Int8 nSourceAction)
static sal_Int32 fireDropActionChangedEvent(vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext > &xContext, const sal_Int8 nDropAction, const Point &rLocation, const sal_Int8 nSourceAction)
void designate_currentwindow(vcl::Window *pWindow)
virtual void SAL_CALL dropActionChanged(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
virtual void SAL_CALL acceptDrag(sal_Int8 dropAction) override
static sal_Int32 fireDropEvent(vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDropContext > &xContext, const sal_Int8 nDropAction, const Point &rLocation, const sal_Int8 nSourceAction, const css::uno::Reference< css::datatransfer::XTransferable > &xTransferable)
VclPtr< vcl::Window > m_pTopWindow
static sal_Int32 fireDragExitEvent(vcl::Window *pWindow)
VclPtr< vcl::Window > m_pCurrentWindow
DECL_LINK(WindowEventListener, VclWindowEvent &, void)
static sal_Int32 fireDragEnterEvent(vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext > &xContext, const sal_Int8 nDropAction, const Point &rLocation, const sal_Int8 nSourceAction, const css::uno::Sequence< css::datatransfer::DataFlavor > &aFlavorList)
virtual void SAL_CALL rejectDrag() override
css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavorList
vcl::Window * findTopLevelWindow(Point &location)
virtual void SAL_CALL dragExit(const css::datatransfer::dnd::DropTargetEvent &dte) override
virtual ~DNDEventDispatcher() override
virtual void SAL_CALL dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
DNDEventDispatcher(vcl::Window *pTopWindow)
std::recursive_mutex m_aMutex
virtual void SAL_CALL dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee) override
signed char sal_Int8