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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/dndhelp.hxx>
22 #include <vcl/svapp.hxx>
23 #include <dndhelper.hxx>
25 #include <cppuhelper/queryinterface.hxx>
27 #include <com/sun/star/awt/XDisplayConnection.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
30 using namespace ::com::sun::star
;
32 vcl::unohelper::DragAndDropClient::~DragAndDropClient() COVERITY_NOEXCEPT_FALSE
{}
34 void vcl::unohelper::DragAndDropClient::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent
& /*dge*/ )
38 void vcl::unohelper::DragAndDropClient::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
& /*dsde*/ )
42 void vcl::unohelper::DragAndDropClient::drop( const css::datatransfer::dnd::DropTargetDropEvent
& /*dtde*/ )
46 void vcl::unohelper::DragAndDropClient::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent
& /*dtdee*/ )
50 void vcl::unohelper::DragAndDropClient::dragExit( const css::datatransfer::dnd::DropTargetEvent
& /*dte*/ )
54 void vcl::unohelper::DragAndDropClient::dragOver( const css::datatransfer::dnd::DropTargetDragEvent
& /*dtde*/ )
58 vcl::unohelper::DragAndDropWrapper::DragAndDropWrapper( DragAndDropClient
* pClient
)
63 vcl::unohelper::DragAndDropWrapper::~DragAndDropWrapper()
68 uno::Any
vcl::unohelper::DragAndDropWrapper::queryInterface( const uno::Type
& rType
)
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
));
78 // css::lang::XEventListener
79 void vcl::unohelper::DragAndDropWrapper::disposing( const css::lang::EventObject
& rEvent
)
81 // Empty Source means it's the client, because the client is not a XInterface
82 if ( !rEvent
.Source
.is() )
86 // css::datatransfer::dnd::XDragGestureListener
87 void vcl::unohelper::DragAndDropWrapper::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent
& rDGE
)
90 mpClient
->dragGestureRecognized( rDGE
);
93 // css::datatransfer::dnd::XDragSourceListener
94 void vcl::unohelper::DragAndDropWrapper::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent
& rDSDE
)
97 mpClient
->dragDropEnd( rDSDE
);
100 void vcl::unohelper::DragAndDropWrapper::dragEnter( const css::datatransfer::dnd::DragSourceDragEvent
& )
104 void vcl::unohelper::DragAndDropWrapper::dragExit( const css::datatransfer::dnd::DragSourceEvent
& )
108 void vcl::unohelper::DragAndDropWrapper::dragOver( const css::datatransfer::dnd::DragSourceDragEvent
& )
112 void vcl::unohelper::DragAndDropWrapper::dropActionChanged( const css::datatransfer::dnd::DragSourceDragEvent
& )
116 // css::datatransfer::dnd::XDropTargetListener
117 void vcl::unohelper::DragAndDropWrapper::drop( const css::datatransfer::dnd::DropTargetDropEvent
& rDTDE
)
120 mpClient
->drop( rDTDE
);
123 void vcl::unohelper::DragAndDropWrapper::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent
& rDTDEE
)
126 mpClient
->dragEnter( rDTDEE
);
129 void vcl::unohelper::DragAndDropWrapper::dragExit( const css::datatransfer::dnd::DropTargetEvent
& dte
)
132 mpClient
->dragExit( dte
);
135 void vcl::unohelper::DragAndDropWrapper::dragOver( const css::datatransfer::dnd::DropTargetDragEvent
& rDTDE
)
138 mpClient
->dragOver( rDTDE
);
141 void vcl::unohelper::DragAndDropWrapper::dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent
& )
145 css::uno::Reference
<css::uno::XInterface
>
146 vcl::OleDnDHelper(const css::uno::Reference
<css::lang::XInitialization
>& xDnD
, const sal_IntPtr pWin
, DragOrDrop eDoD
)
150 if (eDoD
== vcl::DragOrDrop::Drag
)
151 xDnD
->initialize({ uno::Any(), uno::Any(static_cast<sal_uInt64
>(pWin
)) });
153 xDnD
->initialize({ uno::Any(static_cast<sal_uInt64
>(pWin
)), uno::Any() });
158 css::uno::Reference
<css::uno::XInterface
>
159 vcl::X11DnDHelper(const css::uno::Reference
<css::lang::XInitialization
>& xDnD
, const sal_IntPtr pWin
)
162 xDnD
->initialize({ uno::Any(Application::GetDisplayConnection()),
163 uno::Any(static_cast<sal_uInt64
>(pWin
)) });
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */