bump product version to 4.1.6.2
[LibreOffice.git] / dtrans / source / win32 / dnd / sourcecontext.cxx
bloba9f1c090dac1c93d6f81829edfb6f3604cf5d555
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 WeakComponentImplHelper1<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( ::getCppuType( &listener ), listener );
39 SourceContext::~SourceContext()
43 void SAL_CALL SourceContext::addDragSourceListener(
44 const Reference<XDragSourceListener >& )
45 throw( RuntimeException)
49 void SAL_CALL SourceContext::removeDragSourceListener(
50 const Reference<XDragSourceListener >& )
51 throw( RuntimeException)
55 sal_Int32 SAL_CALL SourceContext::getCurrentCursor( )
56 throw( RuntimeException)
58 return 0;
61 void SAL_CALL SourceContext::setCursor( sal_Int32 /*cursorId*/ )
62 throw( RuntimeException)
66 void SAL_CALL SourceContext::setImage( sal_Int32 /*imageId*/ )
67 throw( RuntimeException)
71 void SAL_CALL SourceContext::transferablesFlavorsChanged( )
72 throw( RuntimeException)
77 // non -interface functions
78 // Fires XDragSourceListener::dragDropEnd events.
79 void SourceContext::fire_dragDropEnd( sal_Bool success, sal_Int8 effect)
82 DragSourceDropEvent e;
84 if( success == sal_True)
86 e.DropAction= effect;
87 e.DropSuccess= sal_True;
89 else
91 e.DropAction= ACTION_NONE;
92 e.DropSuccess= sal_False;
94 e.DragSource= m_dragSource;
95 e.DragSourceContext= static_cast<XDragSourceContext*>( this);
96 e.Source= Reference<XInterface>( static_cast<XDragSourceContext*>( this), UNO_QUERY);
98 OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
99 getCppuType( (Reference<XDragSourceListener>* )0 ) );
101 if( pContainer)
103 OInterfaceIteratorHelper iter( *pContainer);
104 while( iter.hasMoreElements())
106 Reference<XDragSourceListener> listener(
107 static_cast<XDragSourceListener*>( iter.next()));
108 listener->dragDropEnd( e);
114 void SourceContext::fire_dropActionChanged( sal_Int8 dropAction, sal_Int8 userAction)
116 if( m_currentAction != dropAction)
118 m_currentAction= dropAction;
119 DragSourceDragEvent e;
120 e.DropAction= dropAction;
121 e.UserAction= userAction;
122 e.DragSource= m_dragSource;
123 e.DragSourceContext= static_cast<XDragSourceContext*>( this);
124 e.Source= Reference<XInterface>( static_cast<XDragSourceContext*>( this), UNO_QUERY);
126 OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
127 getCppuType( (Reference<XDragSourceListener>* )0 ) );
129 if( pContainer)
131 OInterfaceIteratorHelper iter( *pContainer);
132 while( iter.hasMoreElements())
134 Reference<XDragSourceListener> listener(
135 static_cast<XDragSourceListener*>( iter.next()));
136 listener->dropActionChanged( e);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */