LCOV - code coverage report
Current view: top level - vcl/source/components - dtranscomp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 121 0.0 %
Date: 2014-04-14 Functions: 0 47 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10