LibreOffice Module vcl (master) 1
dndhelp.cxx
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#include <vcl/dndhelp.hxx>
21
22#include <vcl/svapp.hxx>
23#include <dndhelper.hxx>
24
26
27#include <com/sun/star/awt/XDisplayConnection.hpp>
28#include <com/sun/star/lang/XInitialization.hpp>
29
30using namespace ::com::sun::star;
31
33
34void vcl::unohelper::DragAndDropClient::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& /*dge*/ )
35{
36}
37
38void vcl::unohelper::DragAndDropClient::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& /*dsde*/ )
39{
40}
41
42void vcl::unohelper::DragAndDropClient::drop( const css::datatransfer::dnd::DropTargetDropEvent& /*dtde*/ )
43{
44}
45
46void vcl::unohelper::DragAndDropClient::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& /*dtdee*/ )
47{
48}
49
50void vcl::unohelper::DragAndDropClient::dragExit( const css::datatransfer::dnd::DropTargetEvent& /*dte*/ )
51{
52}
53
54void vcl::unohelper::DragAndDropClient::dragOver( const css::datatransfer::dnd::DropTargetDragEvent& /*dtde*/ )
55{
56}
57
59{
60 mpClient = pClient;
61}
62
64{
65}
66
67// uno::XInterface
69{
70 uno::Any aRet = ::cppu::queryInterface( rType,
71 static_cast< css::lang::XEventListener* >( static_cast<css::datatransfer::dnd::XDragGestureListener*>(this) ),
72 static_cast< css::datatransfer::dnd::XDragGestureListener* >(this),
73 static_cast< css::datatransfer::dnd::XDragSourceListener* >(this),
74 static_cast< css::datatransfer::dnd::XDropTargetListener* >(this) );
75 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
76}
77
78// css::lang::XEventListener
79void vcl::unohelper::DragAndDropWrapper::disposing( const css::lang::EventObject& rEvent )
80{
81 // Empty Source means it's the client, because the client is not a XInterface
82 if ( !rEvent.Source.is() )
83 mpClient = nullptr;
84}
85
86// css::datatransfer::dnd::XDragGestureListener
87void vcl::unohelper::DragAndDropWrapper::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE )
88{
89 if ( mpClient )
90 mpClient->dragGestureRecognized( rDGE );
91}
92
93// css::datatransfer::dnd::XDragSourceListener
94void vcl::unohelper::DragAndDropWrapper::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE )
95{
96 if ( mpClient )
97 mpClient->dragDropEnd( rDSDE );
98}
99
100void vcl::unohelper::DragAndDropWrapper::dragEnter( const css::datatransfer::dnd::DragSourceDragEvent& )
101{
102}
103
104void vcl::unohelper::DragAndDropWrapper::dragExit( const css::datatransfer::dnd::DragSourceEvent& )
105{
106}
107
108void vcl::unohelper::DragAndDropWrapper::dragOver( const css::datatransfer::dnd::DragSourceDragEvent& )
109{
110}
111
112void vcl::unohelper::DragAndDropWrapper::dropActionChanged( const css::datatransfer::dnd::DragSourceDragEvent& )
113{
114}
115
116// css::datatransfer::dnd::XDropTargetListener
117void vcl::unohelper::DragAndDropWrapper::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
118{
119 if ( mpClient )
120 mpClient->drop( rDTDE );
121}
122
123void vcl::unohelper::DragAndDropWrapper::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rDTDEE )
124{
125 if ( mpClient )
126 mpClient->dragEnter( rDTDEE );
127}
128
129void vcl::unohelper::DragAndDropWrapper::dragExit( const css::datatransfer::dnd::DropTargetEvent& dte )
130{
131 if ( mpClient )
132 mpClient->dragExit( dte );
133}
134
135void vcl::unohelper::DragAndDropWrapper::dragOver( const css::datatransfer::dnd::DropTargetDragEvent& rDTDE )
136{
137 if ( mpClient )
138 mpClient->dragOver( rDTDE );
139}
140
141void vcl::unohelper::DragAndDropWrapper::dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& )
142{
143}
144
145css::uno::Reference<css::uno::XInterface>
146vcl::OleDnDHelper(const css::uno::Reference<css::lang::XInitialization>& xDnD, const sal_IntPtr pWin, DragOrDrop eDoD)
147{
148 if (pWin && xDnD)
149 {
150 if (eDoD == vcl::DragOrDrop::Drag)
151 xDnD->initialize({ uno::Any(), uno::Any(static_cast<sal_uInt64>(pWin)) });
152 else
153 xDnD->initialize({ uno::Any(static_cast<sal_uInt64>(pWin)), uno::Any() });
154 }
155 return xDnD;
156}
157
158css::uno::Reference<css::uno::XInterface>
159vcl::X11DnDHelper(const css::uno::Reference<css::lang::XInitialization>& xDnD, const sal_IntPtr pWin)
160{
161 if (pWin && xDnD)
162 xDnD->initialize({ uno::Any(Application::GetDisplayConnection()),
163 uno::Any(static_cast<sal_uInt64>(pWin)) });
164 return xDnD;
165}
166
167/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection()
Definition: svapp.cxx:1631
virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde)
Definition: dndhelp.cxx:42
virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde)
Definition: dndhelp.cxx:38
virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee)
Definition: dndhelp.cxx:46
virtual ~DragAndDropClient() COVERITY_NOEXCEPT_FALSE
Definition: dndhelp.cxx:32
virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde)
Definition: dndhelp.cxx:54
virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge)
Definition: dndhelp.cxx:34
virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent &dte)
Definition: dndhelp.cxx:50
void SAL_CALL dropActionChanged(const css::datatransfer::dnd::DragSourceDragEvent &dsde) override
Definition: dndhelp.cxx:112
void SAL_CALL drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
Definition: dndhelp.cxx:117
virtual ~DragAndDropWrapper() override
Definition: dndhelp.cxx:63
VCL_DLLPUBLIC DragAndDropWrapper(DragAndDropClient *pClient)
Definition: dndhelp.cxx:58
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: dndhelp.cxx:68
void SAL_CALL dragOver(const css::datatransfer::dnd::DragSourceDragEvent &dsde) override
Definition: dndhelp.cxx:108
void SAL_CALL dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
Definition: dndhelp.cxx:87
void SAL_CALL dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde) override
Definition: dndhelp.cxx:94
void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: dndhelp.cxx:79
void SAL_CALL dragEnter(const css::datatransfer::dnd::DragSourceDragEvent &dsde) override
Definition: dndhelp.cxx:100
void SAL_CALL dragExit(const css::datatransfer::dnd::DragSourceEvent &dse) override
Definition: dndhelp.cxx:104
VCL_DLLPUBLIC css::uno::Reference< css::uno::XInterface > OleDnDHelper(const css::uno::Reference< css::lang::XInitialization > &, sal_IntPtr pWin, DragOrDrop)
Definition: dndhelp.cxx:146
DragOrDrop
Definition: dndhelper.hxx:30
VCL_DLLPUBLIC css::uno::Reference< css::uno::XInterface > X11DnDHelper(const css::uno::Reference< css::lang::XInitialization > &, sal_IntPtr pWin)
Definition: dndhelp.cxx:159
bool hasValue()