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_vcl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "vos/mutex.hxx"
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "osl/mutex.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include "vcl/svapp.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "svdata.hxx"
38*cdf0e10cSrcweir #include "salinst.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
41*cdf0e10cSrcweir #include "com/sun/star/lang/XSingleServiceFactory.hpp"
42*cdf0e10cSrcweir #include "com/sun/star/lang/XInitialization.hpp"
43*cdf0e10cSrcweir #include "com/sun/star/lang/DisposedException.hpp"
44*cdf0e10cSrcweir #include "com/sun/star/datatransfer/XTransferable.hpp"
45*cdf0e10cSrcweir #include "com/sun/star/datatransfer/clipboard/XClipboard.hpp"
46*cdf0e10cSrcweir #include "com/sun/star/datatransfer/clipboard/XClipboardEx.hpp"
47*cdf0e10cSrcweir #include "com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp"
48*cdf0e10cSrcweir #include "com/sun/star/datatransfer/clipboard/XClipboardListener.hpp"
49*cdf0e10cSrcweir #include "com/sun/star/datatransfer/dnd/XDragSource.hpp"
50*cdf0e10cSrcweir #include "com/sun/star/datatransfer/dnd/XDropTarget.hpp"
51*cdf0e10cSrcweir #include "com/sun/star/datatransfer/dnd/DNDConstants.hpp"
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include "cppuhelper/compbase1.hxx"
54*cdf0e10cSrcweir #include "cppuhelper/compbase2.hxx"
55*cdf0e10cSrcweir #include "cppuhelper/compbase3.hxx"
56*cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx"
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir using rtl::OUString;
59*cdf0e10cSrcweir using namespace com::sun::star;
60*cdf0e10cSrcweir using namespace com::sun::star::uno;
61*cdf0e10cSrcweir using namespace com::sun::star::lang;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir // -----------------------------------------------------------------------
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir namespace vcl
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir // generic implementation to satisfy SalInstance
68*cdf0e10cSrcweir class GenericClipboard :
69*cdf0e10cSrcweir 		public cppu::WeakComponentImplHelper3 <
70*cdf0e10cSrcweir         datatransfer::clipboard::XClipboardEx,
71*cdf0e10cSrcweir     	datatransfer::clipboard::XClipboardNotifier,
72*cdf0e10cSrcweir         XServiceInfo
73*cdf0e10cSrcweir 		>
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     osl::Mutex                                                              m_aMutex;
76*cdf0e10cSrcweir     Reference< ::com::sun::star::datatransfer::XTransferable >              m_aContents;
77*cdf0e10cSrcweir     Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner > m_aOwner;
78*cdf0e10cSrcweir     std::list< Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener > > m_aListeners;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     void fireChangedContentsEvent();
81*cdf0e10cSrcweir     void clearContents();
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir public:
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     GenericClipboard() : cppu::WeakComponentImplHelper3<
86*cdf0e10cSrcweir         datatransfer::clipboard::XClipboardEx,
87*cdf0e10cSrcweir     	datatransfer::clipboard::XClipboardNotifier,
88*cdf0e10cSrcweir         XServiceInfo
89*cdf0e10cSrcweir 		>( m_aMutex )
90*cdf0e10cSrcweir     {}
91*cdf0e10cSrcweir     virtual ~GenericClipboard();
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     /*
94*cdf0e10cSrcweir      * XServiceInfo
95*cdf0e10cSrcweir      */
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getImplementationName() throw( RuntimeException );
98*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( RuntimeException );
99*cdf0e10cSrcweir     virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( RuntimeException );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     static rtl::OUString getImplementationName_static();
102*cdf0e10cSrcweir     static Sequence< rtl::OUString > getSupportedServiceNames_static();
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     /*
105*cdf0e10cSrcweir      * XClipboard
106*cdf0e10cSrcweir      */
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     virtual Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL getContents()
109*cdf0e10cSrcweir         throw(RuntimeException);
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     virtual void SAL_CALL setContents(
112*cdf0e10cSrcweir         const Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans,
113*cdf0e10cSrcweir         const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
114*cdf0e10cSrcweir         throw(RuntimeException);
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getName()
117*cdf0e10cSrcweir         throw(RuntimeException);
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     /*
120*cdf0e10cSrcweir      * XClipboardEx
121*cdf0e10cSrcweir      */
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     virtual sal_Int8 SAL_CALL getRenderingCapabilities()
124*cdf0e10cSrcweir         throw(RuntimeException);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     /*
127*cdf0e10cSrcweir      * XClipboardNotifier
128*cdf0e10cSrcweir      */
129*cdf0e10cSrcweir     virtual void SAL_CALL addClipboardListener(
130*cdf0e10cSrcweir         const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
131*cdf0e10cSrcweir         throw(RuntimeException);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     virtual void SAL_CALL removeClipboardListener(
134*cdf0e10cSrcweir         const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardListener >& listener )
135*cdf0e10cSrcweir         throw(RuntimeException);
136*cdf0e10cSrcweir };
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir GenericClipboard::~GenericClipboard()
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir rtl::OUString GenericClipboard::getImplementationName_static()
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.VCLGenericClipboard" ) );
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir Sequence< rtl::OUString > GenericClipboard::getSupportedServiceNames_static()
148*cdf0e10cSrcweir {
149*cdf0e10cSrcweir 	Sequence< OUString > aRet(1);
150*cdf0e10cSrcweir 	aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard");
151*cdf0e10cSrcweir 	return aRet;
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir rtl::OUString GenericClipboard::getImplementationName() throw( RuntimeException )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     return getImplementationName_static();
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir Sequence< rtl::OUString > GenericClipboard::getSupportedServiceNames() throw( RuntimeException )
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir     return getSupportedServiceNames_static();
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir sal_Bool GenericClipboard::supportsService( const ::rtl::OUString& ServiceName ) throw( RuntimeException )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir     Sequence< OUString > aServices( getSupportedServiceNames() );
167*cdf0e10cSrcweir     sal_Int32 nServices = aServices.getLength();
168*cdf0e10cSrcweir     for( sal_Int32 i = 0; i < nServices; i++ )
169*cdf0e10cSrcweir     {
170*cdf0e10cSrcweir         if( aServices[i] == ServiceName )
171*cdf0e10cSrcweir             return sal_True;
172*cdf0e10cSrcweir     }
173*cdf0e10cSrcweir     return sal_False;
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir Reference< ::com::sun::star::datatransfer::XTransferable > GenericClipboard::getContents() throw( RuntimeException )
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     return m_aContents;
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir void GenericClipboard::setContents(
182*cdf0e10cSrcweir         const Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans,
183*cdf0e10cSrcweir         const Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
184*cdf0e10cSrcweir     throw( RuntimeException )
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir     osl::ClearableMutexGuard aGuard( m_aMutex );
187*cdf0e10cSrcweir     Reference< datatransfer::clipboard::XClipboardOwner > xOldOwner( m_aOwner );
188*cdf0e10cSrcweir     Reference< datatransfer::XTransferable > xOldContents( m_aContents );
189*cdf0e10cSrcweir     m_aContents = xTrans;
190*cdf0e10cSrcweir     m_aOwner = xClipboardOwner;
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     std::list< Reference< datatransfer::clipboard::XClipboardListener > > xListeners( m_aListeners );
193*cdf0e10cSrcweir     datatransfer::clipboard::ClipboardEvent aEv;
194*cdf0e10cSrcweir     aEv.Contents = m_aContents;
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     aGuard.clear();
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     if( xOldOwner.is() && xOldOwner != xClipboardOwner )
199*cdf0e10cSrcweir         xOldOwner->lostOwnership( this, xOldContents );
200*cdf0e10cSrcweir     for( std::list< Reference< datatransfer::clipboard::XClipboardListener > >::iterator it =
201*cdf0e10cSrcweir          xListeners.begin(); it != xListeners.end() ; ++it )
202*cdf0e10cSrcweir     {
203*cdf0e10cSrcweir         (*it)->changedContents( aEv );
204*cdf0e10cSrcweir     }
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir rtl::OUString GenericClipboard::getName() throw( RuntimeException )
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CLIPBOARD" ) );
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir sal_Int8 GenericClipboard::getRenderingCapabilities() throw( RuntimeException )
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir     return 0;
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir void GenericClipboard::addClipboardListener( const Reference< datatransfer::clipboard::XClipboardListener >& listener )
218*cdf0e10cSrcweir     throw( RuntimeException )
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir     osl::ClearableMutexGuard aGuard( m_aMutex );
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     m_aListeners.push_back( listener );
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir void GenericClipboard::removeClipboardListener( const Reference< datatransfer::clipboard::XClipboardListener >& listener )
226*cdf0e10cSrcweir     throw( RuntimeException )
227*cdf0e10cSrcweir {
228*cdf0e10cSrcweir     osl::ClearableMutexGuard aGuard( m_aMutex );
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     m_aListeners.remove( listener );
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir // ------------------------------------------------------------------------
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir class ClipboardFactory : public ::cppu::WeakComponentImplHelper1<
236*cdf0e10cSrcweir     com::sun::star::lang::XSingleServiceFactory
237*cdf0e10cSrcweir >
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir     osl::Mutex m_aMutex;
240*cdf0e10cSrcweir public:
241*cdf0e10cSrcweir     ClipboardFactory();
242*cdf0e10cSrcweir     virtual ~ClipboardFactory();
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     /*
245*cdf0e10cSrcweir      *  XSingleServiceFactory
246*cdf0e10cSrcweir      */
247*cdf0e10cSrcweir     virtual Reference< XInterface > SAL_CALL createInstance() throw();
248*cdf0e10cSrcweir     virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& rArgs ) throw();
249*cdf0e10cSrcweir };
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir // ------------------------------------------------------------------------
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir ClipboardFactory::ClipboardFactory() :
254*cdf0e10cSrcweir         cppu::WeakComponentImplHelper1<
255*cdf0e10cSrcweir     com::sun::star::lang::XSingleServiceFactory
256*cdf0e10cSrcweir >( m_aMutex )
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir // ------------------------------------------------------------------------
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir ClipboardFactory::~ClipboardFactory()
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir // ------------------------------------------------------------------------
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir Reference< XInterface > ClipboardFactory::createInstance() throw()
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir     return createInstanceWithArguments( Sequence< Any >() );
271*cdf0e10cSrcweir }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir // ------------------------------------------------------------------------
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir Reference< XInterface > ClipboardFactory::createInstanceWithArguments( const Sequence< Any >& arguments ) throw()
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
278*cdf0e10cSrcweir     Reference< XInterface > xResult = ImplGetSVData()->mpDefInst->CreateClipboard( arguments );
279*cdf0e10cSrcweir     return xResult;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir // ------------------------------------------------------------------------
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir Sequence< OUString > SAL_CALL Clipboard_getSupportedServiceNames()
285*cdf0e10cSrcweir {
286*cdf0e10cSrcweir 	Sequence< OUString > aRet(1);
287*cdf0e10cSrcweir 	aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.clipboard.SystemClipboard");
288*cdf0e10cSrcweir 	return aRet;
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir OUString SAL_CALL Clipboard_getImplementationName()
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir     #if defined UNX
294*cdf0e10cSrcweir     return OUString( RTL_CONSTASCII_USTRINGPARAM(
295*cdf0e10cSrcweir     #if ! defined QUARTZ
296*cdf0e10cSrcweir     "com.sun.star.datatransfer.X11ClipboardSupport"
297*cdf0e10cSrcweir     #else
298*cdf0e10cSrcweir     "com.sun.star.datatransfer.clipboard.AquaClipboard"
299*cdf0e10cSrcweir     #endif
300*cdf0e10cSrcweir     ) );
301*cdf0e10cSrcweir     #else
302*cdf0e10cSrcweir     return GenericClipboard::getImplementationName_static();
303*cdf0e10cSrcweir     #endif
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir Reference< XSingleServiceFactory > SAL_CALL Clipboard_createFactory( const Reference< XMultiServiceFactory > &  )
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir     return Reference< XSingleServiceFactory >( new ClipboardFactory() );
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir /*
312*cdf0e10cSrcweir *   generic DragSource dummy
313*cdf0e10cSrcweir */
314*cdf0e10cSrcweir class GenericDragSource : public cppu::WeakComponentImplHelper2<
315*cdf0e10cSrcweir 			datatransfer::dnd::XDragSource,
316*cdf0e10cSrcweir 			XInitialization
317*cdf0e10cSrcweir             >
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir     osl::Mutex                          m_aMutex;
320*cdf0e10cSrcweir public:
321*cdf0e10cSrcweir     GenericDragSource() : cppu::WeakComponentImplHelper2< datatransfer::dnd::XDragSource, XInitialization >( m_aMutex ) {}
322*cdf0e10cSrcweir     virtual ~GenericDragSource();
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     // XDragSource
325*cdf0e10cSrcweir     virtual sal_Bool	SAL_CALL isDragImageSupported() throw();
326*cdf0e10cSrcweir     virtual sal_Int32	SAL_CALL getDefaultCursor( sal_Int8 dragAction ) throw();
327*cdf0e10cSrcweir     virtual void		SAL_CALL startDrag(
328*cdf0e10cSrcweir                                      const datatransfer::dnd::DragGestureEvent& trigger,
329*cdf0e10cSrcweir                                      sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image,
330*cdf0e10cSrcweir                                      const Reference< datatransfer::XTransferable >& transferable,
331*cdf0e10cSrcweir                                      const Reference< datatransfer::dnd::XDragSourceListener >& listener
332*cdf0e10cSrcweir                                      ) throw();
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir     // XInitialization
335*cdf0e10cSrcweir     virtual void		SAL_CALL initialize( const Sequence< Any >& arguments ) throw( ::com::sun::star::uno::Exception );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     static Sequence< OUString > getSupportedServiceNames_static()
338*cdf0e10cSrcweir     {
339*cdf0e10cSrcweir         Sequence< OUString > aRet( 1 );
340*cdf0e10cSrcweir         aRet[0] = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.GenericDragSource" );
341*cdf0e10cSrcweir         return aRet;
342*cdf0e10cSrcweir     }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     static OUString getImplementationName_static()
345*cdf0e10cSrcweir     {
346*cdf0e10cSrcweir         return OUString::createFromAscii( "com.sun.star.datatransfer.dnd.VclGenericDragSource" );
347*cdf0e10cSrcweir     }
348*cdf0e10cSrcweir };
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir GenericDragSource::~GenericDragSource()
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir sal_Bool GenericDragSource::isDragImageSupported() throw()
355*cdf0e10cSrcweir {
356*cdf0e10cSrcweir     return sal_False;
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir sal_Int32 GenericDragSource::getDefaultCursor( sal_Int8 ) throw()
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir     return 0;
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir void GenericDragSource::startDrag( const datatransfer::dnd::DragGestureEvent&,
365*cdf0e10cSrcweir                                    sal_Int8 /*sourceActions*/, sal_Int32 /*cursor*/, sal_Int32 /*image*/,
366*cdf0e10cSrcweir                                    const Reference< datatransfer::XTransferable >&,
367*cdf0e10cSrcweir                                    const Reference< datatransfer::dnd::XDragSourceListener >& listener
368*cdf0e10cSrcweir                                    ) throw()
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir     datatransfer::dnd::DragSourceDropEvent aEv;
371*cdf0e10cSrcweir     aEv.DropAction = datatransfer::dnd::DNDConstants::ACTION_COPY;
372*cdf0e10cSrcweir     aEv.DropSuccess = sal_False;
373*cdf0e10cSrcweir     listener->dragDropEnd( aEv );
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir void GenericDragSource::initialize( const Sequence< Any >& ) throw( Exception )
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir Sequence< OUString > SAL_CALL DragSource_getSupportedServiceNames()
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir     #if defined UNX
384*cdf0e10cSrcweir 	static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(
385*cdf0e10cSrcweir     #if ! defined QUARTZ
386*cdf0e10cSrcweir     "com.sun.star.datatransfer.dnd.X11DragSource"
387*cdf0e10cSrcweir     #else
388*cdf0e10cSrcweir     "com.sun.star.datatransfer.dnd.OleDragSource"
389*cdf0e10cSrcweir     #endif
390*cdf0e10cSrcweir                                                               ) );
391*cdf0e10cSrcweir 	static Sequence< OUString > aServiceNames( &aServiceName, 1 );
392*cdf0e10cSrcweir 	return aServiceNames;
393*cdf0e10cSrcweir     #else
394*cdf0e10cSrcweir     return GenericDragSource::getSupportedServiceNames_static();
395*cdf0e10cSrcweir     #endif
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir OUString SAL_CALL DragSource_getImplementationName()
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir     #if defined UNX
401*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM(
402*cdf0e10cSrcweir     #if ! defined QUARTZ
403*cdf0e10cSrcweir     "com.sun.star.datatransfer.dnd.XdndSupport"
404*cdf0e10cSrcweir     #else
405*cdf0e10cSrcweir     "com.sun.star.comp.datatransfer.dnd.OleDragSource_V1"
406*cdf0e10cSrcweir     #endif
407*cdf0e10cSrcweir                                                  ) );
408*cdf0e10cSrcweir     #else
409*cdf0e10cSrcweir     return GenericDragSource::getImplementationName_static();
410*cdf0e10cSrcweir     #endif
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir Reference< XInterface > SAL_CALL DragSource_createInstance( const Reference< XMultiServiceFactory >&  )
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
416*cdf0e10cSrcweir     Reference< XInterface > xResult = ImplGetSVData()->mpDefInst->CreateDragSource();
417*cdf0e10cSrcweir     return xResult;
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir /*
421*cdf0e10cSrcweir *   generic DragSource dummy
422*cdf0e10cSrcweir */
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir class GenericDropTarget : public cppu::WeakComponentImplHelper2<
425*cdf0e10cSrcweir 			                               datatransfer::dnd::XDropTarget,
426*cdf0e10cSrcweir                                            XInitialization
427*cdf0e10cSrcweir                                            >
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir     osl::Mutex m_aMutex;
430*cdf0e10cSrcweir public:
431*cdf0e10cSrcweir     GenericDropTarget() : cppu::WeakComponentImplHelper2<
432*cdf0e10cSrcweir 			                               datatransfer::dnd::XDropTarget,
433*cdf0e10cSrcweir                                            XInitialization
434*cdf0e10cSrcweir                                            > ( m_aMutex )
435*cdf0e10cSrcweir     {}
436*cdf0e10cSrcweir     virtual ~GenericDropTarget();
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir     // XInitialization
439*cdf0e10cSrcweir     virtual void		SAL_CALL initialize( const Sequence< Any >& args ) throw ( Exception );
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     // XDropTarget
442*cdf0e10cSrcweir     virtual void		SAL_CALL addDropTargetListener( const Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& ) throw();
443*cdf0e10cSrcweir     virtual void		SAL_CALL removeDropTargetListener( const Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& ) throw();
444*cdf0e10cSrcweir     virtual sal_Bool	SAL_CALL isActive() throw();
445*cdf0e10cSrcweir     virtual void		SAL_CALL setActive( sal_Bool active ) throw();
446*cdf0e10cSrcweir     virtual sal_Int8 	SAL_CALL getDefaultActions() throw();
447*cdf0e10cSrcweir     virtual void		SAL_CALL setDefaultActions( sal_Int8 actions ) throw();
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir     static Sequence< OUString > getSupportedServiceNames_static()
450*cdf0e10cSrcweir     {
451*cdf0e10cSrcweir         Sequence< OUString > aRet( 1 );
452*cdf0e10cSrcweir         aRet[0] = OUString::createFromAscii( "com.sun.star.datatransfer.dnd.GenericDropTarget" );
453*cdf0e10cSrcweir         return aRet;
454*cdf0e10cSrcweir     }
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir     static OUString getImplementationName_static()
457*cdf0e10cSrcweir     {
458*cdf0e10cSrcweir         return OUString::createFromAscii( "com.sun.star.datatransfer.dnd.VclGenericDropTarget" );
459*cdf0e10cSrcweir     }
460*cdf0e10cSrcweir };
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir GenericDropTarget::~GenericDropTarget()
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir }
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir void GenericDropTarget::initialize( const Sequence< Any >& ) throw( Exception )
467*cdf0e10cSrcweir {
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir void GenericDropTarget::addDropTargetListener( const Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& ) throw()
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir }
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir void GenericDropTarget::removeDropTargetListener( const Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& ) throw()
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir sal_Bool GenericDropTarget::isActive() throw()
479*cdf0e10cSrcweir {
480*cdf0e10cSrcweir     return sal_False;
481*cdf0e10cSrcweir }
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir void GenericDropTarget::setActive( sal_Bool ) throw()
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir sal_Int8 GenericDropTarget::getDefaultActions() throw()
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir     return 0;
490*cdf0e10cSrcweir }
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir void GenericDropTarget::setDefaultActions( sal_Int8) throw()
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir Sequence< OUString > SAL_CALL DropTarget_getSupportedServiceNames()
497*cdf0e10cSrcweir {
498*cdf0e10cSrcweir     #if defined UNX
499*cdf0e10cSrcweir 	static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM(
500*cdf0e10cSrcweir     #if ! defined QUARTZ
501*cdf0e10cSrcweir     "com.sun.star.datatransfer.dnd.X11DropTarget"
502*cdf0e10cSrcweir     #else
503*cdf0e10cSrcweir     "com.sun.star.datatransfer.dnd.OleDropTarget"
504*cdf0e10cSrcweir     #endif
505*cdf0e10cSrcweir                                                               ) );
506*cdf0e10cSrcweir 	static Sequence< OUString > aServiceNames( &aServiceName, 1 );
507*cdf0e10cSrcweir 	return aServiceNames;
508*cdf0e10cSrcweir     #else
509*cdf0e10cSrcweir     return GenericDropTarget::getSupportedServiceNames_static();
510*cdf0e10cSrcweir     #endif
511*cdf0e10cSrcweir }
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir OUString SAL_CALL DropTarget_getImplementationName()
514*cdf0e10cSrcweir {
515*cdf0e10cSrcweir     #if defined UNX
516*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM(
517*cdf0e10cSrcweir     #if ! defined QUARTZ
518*cdf0e10cSrcweir     "com.sun.star.datatransfer.dnd.XdndDropTarget"
519*cdf0e10cSrcweir     #else
520*cdf0e10cSrcweir     "com.sun.star.comp.datatransfer.dnd.OleDropTarget_V1"
521*cdf0e10cSrcweir     #endif
522*cdf0e10cSrcweir                     ) );
523*cdf0e10cSrcweir     #else
524*cdf0e10cSrcweir     return GenericDropTarget::getImplementationName_static();
525*cdf0e10cSrcweir     #endif
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir Reference< XInterface > SAL_CALL DropTarget_createInstance( const Reference< XMultiServiceFactory >&  )
529*cdf0e10cSrcweir {
530*cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
531*cdf0e10cSrcweir     Reference< XInterface > xResult = ImplGetSVData()->mpDefInst->CreateDropTarget();
532*cdf0e10cSrcweir     return xResult;
533*cdf0e10cSrcweir }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir } // namespace vcl
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir /*
539*cdf0e10cSrcweir *   SalInstance generic
540*cdf0e10cSrcweir */
541*cdf0e10cSrcweir Reference< XInterface > SalInstance::CreateClipboard( const Sequence< Any >& )
542*cdf0e10cSrcweir {
543*cdf0e10cSrcweir     return Reference< XInterface >( ( cppu::OWeakObject * )new vcl::GenericClipboard() );
544*cdf0e10cSrcweir }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir Reference< XInterface > SalInstance::CreateDragSource()
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir     return Reference< XInterface >( ( cppu::OWeakObject * )new vcl::GenericDragSource() );
549*cdf0e10cSrcweir }
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir Reference< XInterface > SalInstance::CreateDropTarget()
552*cdf0e10cSrcweir {
553*cdf0e10cSrcweir     return Reference< XInterface >( ( cppu::OWeakObject * )new vcl::GenericDropTarget() );
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir 
556