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>
27 #include <cppuhelper/implbase.hxx>
28 #include <vcl/window.hxx>
29 
30 class DNDEventDispatcher: public ::cppu::WeakImplHelper<
31  css::datatransfer::dnd::XDropTargetListener,
32  css::datatransfer::dnd::XDropTargetDragContext,
33  css::datatransfer::dnd::XDragGestureListener >
34 {
36 
38  void designate_currentwindow(vcl::Window *pWindow);
39  DECL_LINK(WindowEventListener, VclWindowEvent&, void);
40 
41  ::osl::Mutex m_aMutex;
42  css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavorList;
43 
45  /*
46  * fire the events on the dnd listener container of the specified window
47  */
48 
50  static sal_Int32 fireDragEnterEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext >& xContext,
51  const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction,
52  const css::uno::Sequence< css::datatransfer::DataFlavor >& aFlavorList );
53 
55  static sal_Int32 fireDragOverEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext >& xContext,
56  const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction );
57 
59  static sal_Int32 fireDragExitEvent( vcl::Window *pWindow );
60 
62  static sal_Int32 fireDropActionChangedEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDragContext >& xContext,
63  const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction );
64 
66  static sal_Int32 fireDropEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDropTargetDropContext >& xContext,
67  const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction,
68  const css::uno::Reference< css::datatransfer::XTransferable >& xTransferable );
69 
71  static sal_Int32 fireDragGestureEvent( vcl::Window *pWindow, const css::uno::Reference< css::datatransfer::dnd::XDragSource >& xSource,
72  const css::uno::Any& event, const Point& rOrigin, const sal_Int8 nDragAction );
73 
74 public:
75 
76  DNDEventDispatcher( vcl::Window * pTopWindow );
77  virtual ~DNDEventDispatcher() override;
78 
79  /*
80  * XDropTargetDragContext
81  */
82 
83  virtual void SAL_CALL acceptDrag( sal_Int8 dropAction ) override;
84  virtual void SAL_CALL rejectDrag() override;
85 
86  /*
87  * XDropTargetListener
88  */
89 
90  virtual void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override;
91  virtual void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override;
92  virtual void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override;
93  virtual void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
94  virtual void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override;
95 
96  /*
97  * XDragGestureListener
98  */
99 
100  virtual void SAL_CALL dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override;
101 
102  /*
103  * XEventListener
104  */
105 
106  virtual void SAL_CALL disposing( const css::lang::EventObject& eo ) override;
107 };
108 
109 #endif
110 
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavorList
signed char sal_Int8
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 drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
DNDEventDispatcher(vcl::Window *pTopWindow)
virtual void SAL_CALL dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
virtual ~DNDEventDispatcher() override
void designate_currentwindow(vcl::Window *pWindow)
virtual void SAL_CALL disposing(const css::lang::EventObject &eo) override
virtual void SAL_CALL dropActionChanged(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
static sal_Int32 fireDragExitEvent(vcl::Window *pWindow)
virtual void SAL_CALL dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee) 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)
VclPtr< vcl::Window > m_pTopWindow
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)
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)
virtual void SAL_CALL dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
virtual void SAL_CALL rejectDrag() override
virtual void SAL_CALL acceptDrag(sal_Int8 dropAction) override
vcl::Window * findTopLevelWindow(Point location)
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)
virtual void SAL_CALL dragExit(const css::datatransfer::dnd::DropTargetEvent &dte) override
VclPtr< vcl::Window > m_pCurrentWindow
DECL_LINK(WindowEventListener, VclWindowEvent &, void)