Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / dtrans / source / win32 / dnd / sourcecontext.cxx
blob8531fd8a1184d036049c10509be95a45e3907894
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
22 #include "sourcecontext.hxx"
24 using namespace com::sun::star::datatransfer::dnd;
25 using namespace com::sun::star::datatransfer::dnd::DNDConstants;
27 SourceContext::SourceContext( DragSource* pSource,
28 const Reference<XDragSourceListener>& listener):
29 WeakComponentImplHelper<XDragSourceContext>(m_mutex),
30 m_pDragSource( pSource),
31 m_dragSource( static_cast<XDragSource*>( m_pDragSource) )
33 #if OSL_DEBUG_LEVEL > 1
34 if( listener.is())
35 #endif
36 rBHelper.addListener( cppu::UnoType<decltype(listener)>::get(), listener );
39 SourceContext::~SourceContext()
43 void SourceContext::addDragSourceListener(
44 const Reference<XDragSourceListener >& )
48 void SourceContext::removeDragSourceListener(
49 const Reference<XDragSourceListener >& )
53 sal_Int32 SAL_CALL SourceContext::getCurrentCursor( )
55 return 0;
58 void SAL_CALL SourceContext::setCursor( sal_Int32 /*cursorId*/ )
62 void SAL_CALL SourceContext::setImage( sal_Int32 /*imageId*/ )
66 void SAL_CALL SourceContext::transferablesFlavorsChanged( )
70 // non -interface functions
71 // Fires XDragSourceListener::dragDropEnd events.
72 void SourceContext::fire_dragDropEnd( bool success, sal_Int8 effect)
75 DragSourceDropEvent e;
77 if( success )
79 e.DropAction= effect;
80 e.DropSuccess= true;
82 else
84 e.DropAction= ACTION_NONE;
85 e.DropSuccess= false;
87 e.DragSource= m_dragSource;
88 e.DragSourceContext= static_cast<XDragSourceContext*>( this);
89 e.Source.set( static_cast<XDragSourceContext*>( this), UNO_QUERY);
91 OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
92 cppu::UnoType<XDragSourceListener>::get());
94 if( pContainer)
96 OInterfaceIteratorHelper iter( *pContainer);
97 while( iter.hasMoreElements())
99 Reference<XDragSourceListener> listener(
100 static_cast<XDragSourceListener*>( iter.next()));
101 listener->dragDropEnd( e);
106 void SourceContext::fire_dropActionChanged( sal_Int8 dropAction, sal_Int8 userAction)
108 if( m_currentAction != dropAction)
110 m_currentAction= dropAction;
111 DragSourceDragEvent e;
112 e.DropAction= dropAction;
113 e.UserAction= userAction;
114 e.DragSource= m_dragSource;
115 e.DragSourceContext= static_cast<XDragSourceContext*>( this);
116 e.Source.set( static_cast<XDragSourceContext*>( this), UNO_QUERY);
118 OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
119 cppu::UnoType<XDragSourceListener>::get());
121 if( pContainer)
123 OInterfaceIteratorHelper iter( *pContainer);
124 while( iter.hasMoreElements())
126 Reference<XDragSourceListener> listener(
127 static_cast<XDragSourceListener*>( iter.next()));
128 listener->dropActionChanged( e);
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */