xref: /trunk/main/dtrans/source/win32/dnd/sourcecontext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_dtrans.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "sourcecontext.hxx"
35*cdf0e10cSrcweir #include <rtl/unload.h>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir using namespace com::sun::star::datatransfer::dnd;
38*cdf0e10cSrcweir using namespace com::sun::star::datatransfer::dnd::DNDConstants;
39*cdf0e10cSrcweir extern rtl_StandardModuleCount g_moduleCount;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir SourceContext::SourceContext( DragSource* pSource,
42*cdf0e10cSrcweir                              const Reference<XDragSourceListener>& listener):
43*cdf0e10cSrcweir         WeakComponentImplHelper1<XDragSourceContext>(m_mutex),
44*cdf0e10cSrcweir         m_pDragSource( pSource),
45*cdf0e10cSrcweir         m_dragSource( static_cast<XDragSource*>( m_pDragSource) )
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
48*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
49*cdf0e10cSrcweir     if( listener.is())
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir     rBHelper.addListener( ::getCppuType( &listener ), listener );
52*cdf0e10cSrcweir }
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir SourceContext::~SourceContext()
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
57*cdf0e10cSrcweir }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir void SAL_CALL SourceContext::addDragSourceListener(
60*cdf0e10cSrcweir     const Reference<XDragSourceListener >& )
61*cdf0e10cSrcweir     throw( RuntimeException)
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir void SAL_CALL SourceContext::removeDragSourceListener(
66*cdf0e10cSrcweir      const Reference<XDragSourceListener >& )
67*cdf0e10cSrcweir     throw( RuntimeException)
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir sal_Int32 SAL_CALL SourceContext::getCurrentCursor(  )
72*cdf0e10cSrcweir     throw( RuntimeException)
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir     return 0;
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir void SAL_CALL SourceContext::setCursor( sal_Int32 /*cursorId*/ )
78*cdf0e10cSrcweir     throw( RuntimeException)
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir void SAL_CALL SourceContext::setImage( sal_Int32 /*imageId*/ )
83*cdf0e10cSrcweir     throw( RuntimeException)
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir void SAL_CALL SourceContext::transferablesFlavorsChanged(  )
88*cdf0e10cSrcweir     throw( RuntimeException)
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir // non -interface functions
94*cdf0e10cSrcweir // Fires XDragSourceListener::dragDropEnd events.
95*cdf0e10cSrcweir void SourceContext::fire_dragDropEnd( sal_Bool success, sal_Int8 effect)
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     DragSourceDropEvent e;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     if( success == sal_True)
101*cdf0e10cSrcweir     {
102*cdf0e10cSrcweir         e.DropAction=  effect;
103*cdf0e10cSrcweir         e.DropSuccess= sal_True;
104*cdf0e10cSrcweir     }
105*cdf0e10cSrcweir     else
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         e.DropAction= ACTION_NONE;
108*cdf0e10cSrcweir         e.DropSuccess= sal_False;
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir     e.DragSource= m_dragSource;
111*cdf0e10cSrcweir     e.DragSourceContext= static_cast<XDragSourceContext*>( this);
112*cdf0e10cSrcweir     e.Source= Reference<XInterface>( static_cast<XDragSourceContext*>( this), UNO_QUERY);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
115*cdf0e10cSrcweir         getCppuType( (Reference<XDragSourceListener>* )0 ) );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     if( pContainer)
118*cdf0e10cSrcweir     {
119*cdf0e10cSrcweir         OInterfaceIteratorHelper iter( *pContainer);
120*cdf0e10cSrcweir         while( iter.hasMoreElements())
121*cdf0e10cSrcweir         {
122*cdf0e10cSrcweir             Reference<XDragSourceListener> listener(
123*cdf0e10cSrcweir                 static_cast<XDragSourceListener*>( iter.next()));
124*cdf0e10cSrcweir             listener->dragDropEnd( e);
125*cdf0e10cSrcweir         }
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir void SourceContext::fire_dropActionChanged( sal_Int8 dropAction, sal_Int8 userAction)
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir     if( m_currentAction != dropAction)
133*cdf0e10cSrcweir     {
134*cdf0e10cSrcweir         m_currentAction= dropAction;
135*cdf0e10cSrcweir         DragSourceDragEvent e;
136*cdf0e10cSrcweir         e.DropAction= dropAction;
137*cdf0e10cSrcweir         e.UserAction= userAction;
138*cdf0e10cSrcweir         e.DragSource= m_dragSource;
139*cdf0e10cSrcweir         e.DragSourceContext= static_cast<XDragSourceContext*>( this);
140*cdf0e10cSrcweir         e.Source= Reference<XInterface>( static_cast<XDragSourceContext*>( this), UNO_QUERY);
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         OInterfaceContainerHelper* pContainer= rBHelper.getContainer(
143*cdf0e10cSrcweir             getCppuType( (Reference<XDragSourceListener>* )0 ) );
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir         if( pContainer)
146*cdf0e10cSrcweir         {
147*cdf0e10cSrcweir             OInterfaceIteratorHelper iter( *pContainer);
148*cdf0e10cSrcweir             while( iter.hasMoreElements())
149*cdf0e10cSrcweir             {
150*cdf0e10cSrcweir                 Reference<XDragSourceListener> listener(
151*cdf0e10cSrcweir                     static_cast<XDragSourceListener*>( iter.next()));
152*cdf0e10cSrcweir                 listener->dropActionChanged( e);
153*cdf0e10cSrcweir             }
154*cdf0e10cSrcweir         }
155*cdf0e10cSrcweir     }
156*cdf0e10cSrcweir }
157