1*48123e16SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*48123e16SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*48123e16SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*48123e16SAndrew Rist * distributed with this work for additional information
6*48123e16SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*48123e16SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*48123e16SAndrew Rist * "License"); you may not use this file except in compliance
9*48123e16SAndrew Rist * with the License. You may obtain a copy of the License at
10*48123e16SAndrew Rist *
11*48123e16SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*48123e16SAndrew Rist *
13*48123e16SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*48123e16SAndrew Rist * software distributed under the License is distributed on an
15*48123e16SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*48123e16SAndrew Rist * KIND, either express or implied. See the License for the
17*48123e16SAndrew Rist * specific language governing permissions and limitations
18*48123e16SAndrew Rist * under the License.
19*48123e16SAndrew Rist *
20*48123e16SAndrew Rist *************************************************************/
21*48123e16SAndrew Rist
22*48123e16SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dtrans.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include "sourcecontext.hxx"
31cdf0e10cSrcweir #include <rtl/unload.h>
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace com::sun::star::datatransfer::dnd;
34cdf0e10cSrcweir using namespace com::sun::star::datatransfer::dnd::DNDConstants;
35cdf0e10cSrcweir extern rtl_StandardModuleCount g_moduleCount;
36cdf0e10cSrcweir
SourceContext(DragSource * pSource,const Reference<XDragSourceListener> & listener)37cdf0e10cSrcweir SourceContext::SourceContext( DragSource* pSource,
38cdf0e10cSrcweir const Reference<XDragSourceListener>& listener):
39cdf0e10cSrcweir WeakComponentImplHelper1<XDragSourceContext>(m_mutex),
40cdf0e10cSrcweir m_pDragSource( pSource),
41cdf0e10cSrcweir m_dragSource( static_cast<XDragSource*>( m_pDragSource) )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
44cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
45cdf0e10cSrcweir if( listener.is())
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir rBHelper.addListener( ::getCppuType( &listener ), listener );
48cdf0e10cSrcweir }
49cdf0e10cSrcweir
~SourceContext()50cdf0e10cSrcweir SourceContext::~SourceContext()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
53cdf0e10cSrcweir }
54cdf0e10cSrcweir
addDragSourceListener(const Reference<XDragSourceListener> &)55cdf0e10cSrcweir void SAL_CALL SourceContext::addDragSourceListener(
56cdf0e10cSrcweir const Reference<XDragSourceListener >& )
57cdf0e10cSrcweir throw( RuntimeException)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
removeDragSourceListener(const Reference<XDragSourceListener> &)61cdf0e10cSrcweir void SAL_CALL SourceContext::removeDragSourceListener(
62cdf0e10cSrcweir const Reference<XDragSourceListener >& )
63cdf0e10cSrcweir throw( RuntimeException)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
getCurrentCursor()67cdf0e10cSrcweir sal_Int32 SAL_CALL SourceContext::getCurrentCursor( )
68cdf0e10cSrcweir throw( RuntimeException)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir return 0;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir
setCursor(sal_Int32)73cdf0e10cSrcweir void SAL_CALL SourceContext::setCursor( sal_Int32 /*cursorId*/ )
74cdf0e10cSrcweir throw( RuntimeException)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
setImage(sal_Int32)78cdf0e10cSrcweir void SAL_CALL SourceContext::setImage( sal_Int32 /*imageId*/ )
79cdf0e10cSrcweir throw( RuntimeException)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
transferablesFlavorsChanged()83cdf0e10cSrcweir void SAL_CALL SourceContext::transferablesFlavorsChanged( )
84cdf0e10cSrcweir throw( RuntimeException)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir
89cdf0e10cSrcweir // non -interface functions
90cdf0e10cSrcweir // Fires XDragSourceListener::dragDropEnd events.
fire_dragDropEnd(sal_Bool success,sal_Int8 effect)91cdf0e10cSrcweir void SourceContext::fire_dragDropEnd( sal_Bool success, sal_Int8 effect)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir
94cdf0e10cSrcweir DragSourceDropEvent e;
95cdf0e10cSrcweir
96cdf0e10cSrcweir if( success == sal_True)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir e.DropAction= effect;
99cdf0e10cSrcweir e.DropSuccess= sal_True;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir else
102cdf0e10cSrcweir {
103cdf0e10cSrcweir e.DropAction= ACTION_NONE;
104cdf0e10cSrcweir e.DropSuccess= sal_False;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir e.DragSource= m_dragSource;
107cdf0e10cSrcweir e.DragSourceContext= static_cast<XDragSourceContext*>( this);
108cdf0e10cSrcweir e.Source= Reference<XInterface>( static_cast<XDragSourceContext*>( this), UNO_QUERY);
109cdf0e10cSrcweir
110cdf0e10cSrcweir OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
111cdf0e10cSrcweir getCppuType( (Reference<XDragSourceListener>* )0 ) );
112cdf0e10cSrcweir
113cdf0e10cSrcweir if( pContainer)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir OInterfaceIteratorHelper iter( *pContainer);
116cdf0e10cSrcweir while( iter.hasMoreElements())
117cdf0e10cSrcweir {
118cdf0e10cSrcweir Reference<XDragSourceListener> listener(
119cdf0e10cSrcweir static_cast<XDragSourceListener*>( iter.next()));
120cdf0e10cSrcweir listener->dragDropEnd( e);
121cdf0e10cSrcweir }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir
fire_dropActionChanged(sal_Int8 dropAction,sal_Int8 userAction)126cdf0e10cSrcweir void SourceContext::fire_dropActionChanged( sal_Int8 dropAction, sal_Int8 userAction)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir if( m_currentAction != dropAction)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir m_currentAction= dropAction;
131cdf0e10cSrcweir DragSourceDragEvent e;
132cdf0e10cSrcweir e.DropAction= dropAction;
133cdf0e10cSrcweir e.UserAction= userAction;
134cdf0e10cSrcweir e.DragSource= m_dragSource;
135cdf0e10cSrcweir e.DragSourceContext= static_cast<XDragSourceContext*>( this);
136cdf0e10cSrcweir e.Source= Reference<XInterface>( static_cast<XDragSourceContext*>( this), UNO_QUERY);
137cdf0e10cSrcweir
138cdf0e10cSrcweir OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
139cdf0e10cSrcweir getCppuType( (Reference<XDragSourceListener>* )0 ) );
140cdf0e10cSrcweir
141cdf0e10cSrcweir if( pContainer)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir OInterfaceIteratorHelper iter( *pContainer);
144cdf0e10cSrcweir while( iter.hasMoreElements())
145cdf0e10cSrcweir {
146cdf0e10cSrcweir Reference<XDragSourceListener> listener(
147cdf0e10cSrcweir static_cast<XDragSourceListener*>( iter.next()));
148cdf0e10cSrcweir listener->dropActionChanged( e);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir }
153