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 
30 using namespace ::com::sun::star;
31 
33 
34 void vcl::unohelper::DragAndDropClient::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& /*dge*/ )
35 {
36 }
37 
38 void vcl::unohelper::DragAndDropClient::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& /*dsde*/ )
39 {
40 }
41 
42 void vcl::unohelper::DragAndDropClient::drop( const css::datatransfer::dnd::DropTargetDropEvent& /*dtde*/ )
43 {
44 }
45 
46 void vcl::unohelper::DragAndDropClient::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& /*dtdee*/ )
47 {
48 }
49 
50 void vcl::unohelper::DragAndDropClient::dragExit( const css::datatransfer::dnd::DropTargetEvent& /*dte*/ )
51 {
52 }
53 
54 void 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
79 void 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
87 void 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
94 void vcl::unohelper::DragAndDropWrapper::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE )
95 {
96  if ( mpClient )
97  mpClient->dragDropEnd( rDSDE );
98 }
99 
100 void vcl::unohelper::DragAndDropWrapper::dragEnter( const css::datatransfer::dnd::DragSourceDragEvent& )
101 {
102 }
103 
104 void vcl::unohelper::DragAndDropWrapper::dragExit( const css::datatransfer::dnd::DragSourceEvent& )
105 {
106 }
107 
108 void vcl::unohelper::DragAndDropWrapper::dragOver( const css::datatransfer::dnd::DragSourceDragEvent& )
109 {
110 }
111 
112 void vcl::unohelper::DragAndDropWrapper::dropActionChanged( const css::datatransfer::dnd::DragSourceDragEvent& )
113 {
114 }
115 
116 // css::datatransfer::dnd::XDropTargetListener
117 void vcl::unohelper::DragAndDropWrapper::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
118 {
119  if ( mpClient )
120  mpClient->drop( rDTDE );
121 }
122 
123 void vcl::unohelper::DragAndDropWrapper::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rDTDEE )
124 {
125  if ( mpClient )
126  mpClient->dragEnter( rDTDEE );
127 }
128 
129 void vcl::unohelper::DragAndDropWrapper::dragExit( const css::datatransfer::dnd::DropTargetEvent& dte )
130 {
131  if ( mpClient )
132  mpClient->dragExit( dte );
133 }
134 
135 void vcl::unohelper::DragAndDropWrapper::dragOver( const css::datatransfer::dnd::DropTargetDragEvent& rDTDE )
136 {
137  if ( mpClient )
138  mpClient->dragOver( rDTDE );
139 }
140 
141 void vcl::unohelper::DragAndDropWrapper::dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& )
142 {
143 }
144 
145 css::uno::Reference<css::uno::XInterface>
146 vcl::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 
158 css::uno::Reference<css::uno::XInterface>
159 vcl::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: */
virtual ~DragAndDropWrapper() override
Definition: dndhelp.cxx:63
virtual ~DragAndDropClient() COVERITY_NOEXCEPT_FALSE
Definition: dndhelp.cxx:32
bool hasValue()
void SAL_CALL dragExit(const css::datatransfer::dnd::DragSourceEvent &dse) override
Definition: dndhelp.cxx:104
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
DragOrDrop
Definition: dndhelper.hxx:29
void SAL_CALL drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
Definition: dndhelp.cxx:117
static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection()
Definition: svapp.cxx:1624
virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde)
Definition: dndhelp.cxx:54
void SAL_CALL dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde) override
Definition: dndhelp.cxx:94
void SAL_CALL dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
Definition: dndhelp.cxx:87
virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde)
Definition: dndhelp.cxx:38
void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: dndhelp.cxx:79
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: dndhelp.cxx:68
void SAL_CALL dragEnter(const css::datatransfer::dnd::DragSourceDragEvent &dsde) override
Definition: dndhelp.cxx:100
void SAL_CALL dragOver(const css::datatransfer::dnd::DragSourceDragEvent &dsde) override
Definition: dndhelp.cxx:108
virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge)
Definition: dndhelp.cxx:34
virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee)
Definition: dndhelp.cxx:46
virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde)
Definition: dndhelp.cxx:42
VCL_DLLPUBLIC css::uno::Reference< css::uno::XInterface > OleDnDHelper(const css::uno::Reference< css::lang::XInitialization > &, sal_IntPtr pWin, DragOrDrop)
Definition: dndhelp.cxx:146
VCL_DLLPUBLIC DragAndDropWrapper(DragAndDropClient *pClient)
Definition: dndhelp.cxx:58
VCL_DLLPUBLIC css::uno::Reference< css::uno::XInterface > X11DnDHelper(const css::uno::Reference< css::lang::XInitialization > &, sal_IntPtr pWin)
Definition: dndhelp.cxx:159