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