LCOV - code coverage report
Current view: top level - vcl/unx/generic/dtrans - X11_droptarget.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 84 0.0 %
Date: 2014-04-14 Functions: 0 17 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 <cppuhelper/supportsservice.hxx>
      21             : #include <X11_selection.hxx>
      22             : 
      23             : using namespace x11;
      24             : using namespace com::sun::star::lang;
      25             : using namespace com::sun::star::awt;
      26             : using namespace com::sun::star::datatransfer;
      27             : using namespace com::sun::star::datatransfer::dnd;
      28             : 
      29           0 : DropTarget::DropTarget() :
      30             :         ::cppu::WeakComponentImplHelper3<
      31             :             XDropTarget,
      32             :             XInitialization,
      33             :             XServiceInfo
      34             :         >( m_aMutex ),
      35             :     m_bActive( false ),
      36             :     m_nDefaultActions( 0 ),
      37             :     m_aTargetWindow( None ),
      38           0 :     m_pSelectionManager( NULL )
      39             : {
      40           0 : }
      41             : 
      42           0 : DropTarget::~DropTarget()
      43             : {
      44           0 :     if( m_pSelectionManager )
      45           0 :         m_pSelectionManager->deregisterDropTarget( m_aTargetWindow );
      46           0 : }
      47             : 
      48           0 : void DropTarget::initialize( const Sequence< Any >& arguments ) throw( ::com::sun::star::uno::Exception, std::exception )
      49             : {
      50           0 :     if( arguments.getLength() > 1 )
      51             :     {
      52           0 :         OUString aDisplayName;
      53           0 :         Reference< XDisplayConnection > xConn;
      54           0 :         arguments.getConstArray()[0] >>= xConn;
      55           0 :         if( xConn.is() )
      56             :         {
      57           0 :             Any aIdentifier;
      58           0 :             aIdentifier >>= aDisplayName;
      59             :         }
      60             : 
      61           0 :         m_pSelectionManager = &SelectionManager::get( aDisplayName );
      62           0 :         m_xSelectionManager = static_cast< XDragSource* >(m_pSelectionManager);
      63           0 :         m_pSelectionManager->initialize( arguments );
      64             : 
      65           0 :         if( m_pSelectionManager->getDisplay() ) // #136582# sanity check
      66             :         {
      67           0 :             sal_Size aWindow = None;
      68           0 :             arguments.getConstArray()[1] >>= aWindow;
      69           0 :             m_pSelectionManager->registerDropTarget( aWindow, this );
      70           0 :             m_aTargetWindow = aWindow;
      71           0 :             m_bActive = true;
      72           0 :         }
      73             :     }
      74           0 : }
      75             : 
      76           0 : void DropTarget::addDropTargetListener( const Reference< XDropTargetListener >& xListener ) throw(std::exception)
      77             : {
      78           0 :     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
      79             : 
      80           0 :     m_aListeners.push_back( xListener );
      81           0 : }
      82             : 
      83           0 : void DropTarget::removeDropTargetListener( const Reference< XDropTargetListener >& xListener ) throw(std::exception)
      84             : {
      85           0 :     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
      86             : 
      87           0 :     m_aListeners.remove( xListener );
      88           0 : }
      89             : 
      90           0 : sal_Bool DropTarget::isActive() throw(std::exception)
      91             : {
      92           0 :     return m_bActive;
      93             : }
      94             : 
      95           0 : void DropTarget::setActive( sal_Bool active ) throw(std::exception)
      96             : {
      97           0 :     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
      98             : 
      99           0 :     m_bActive = active;
     100           0 : }
     101             : 
     102           0 : sal_Int8 DropTarget::getDefaultActions() throw(std::exception)
     103             : {
     104           0 :     return m_nDefaultActions;
     105             : }
     106             : 
     107           0 : void DropTarget::setDefaultActions( sal_Int8 actions ) throw(std::exception)
     108             : {
     109           0 :     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
     110             : 
     111           0 :     m_nDefaultActions = actions;
     112           0 : }
     113             : 
     114           0 : void DropTarget::drop( const DropTargetDropEvent& dtde ) throw()
     115             : {
     116           0 :     osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
     117           0 :     std::list< Reference< XDropTargetListener > > aListeners( m_aListeners );
     118           0 :     aGuard.clear();
     119             : 
     120           0 :     for( std::list< Reference< XDropTargetListener > >::iterator it = aListeners.begin(); it!= aListeners.end(); ++it )
     121             :     {
     122           0 :         (*it)->drop( dtde );
     123           0 :     }
     124           0 : }
     125             : 
     126           0 : void DropTarget::dragEnter( const DropTargetDragEnterEvent& dtde ) throw()
     127             : {
     128           0 :     osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
     129           0 :     std::list< Reference< XDropTargetListener > > aListeners( m_aListeners );
     130           0 :     aGuard.clear();
     131             : 
     132           0 :     for( std::list< Reference< XDropTargetListener > >::iterator it = aListeners.begin(); it!= aListeners.end(); ++it )
     133             :     {
     134           0 :         (*it)->dragEnter( dtde );
     135           0 :     }
     136           0 : }
     137             : 
     138           0 : void DropTarget::dragExit( const DropTargetEvent& dte ) throw()
     139             : {
     140           0 :     osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
     141           0 :     std::list< Reference< XDropTargetListener > > aListeners( m_aListeners );
     142           0 :     aGuard.clear();
     143             : 
     144           0 :     for( std::list< Reference< XDropTargetListener > >::iterator it = aListeners.begin(); it!= aListeners.end(); ++it )
     145             :     {
     146           0 :         (*it)->dragExit( dte );
     147           0 :     }
     148           0 : }
     149             : 
     150           0 : void DropTarget::dragOver( const DropTargetDragEvent& dtde ) throw()
     151             : {
     152           0 :     osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
     153           0 :     std::list< Reference< XDropTargetListener > > aListeners( m_aListeners );
     154           0 :     aGuard.clear();
     155             : 
     156           0 :     for( std::list< Reference< XDropTargetListener > >::iterator it = aListeners.begin(); it!= aListeners.end(); ++it )
     157             :     {
     158           0 :         (*it)->dragOver( dtde );
     159           0 :     }
     160           0 : }
     161             : 
     162             : // XServiceInfo
     163           0 : OUString DropTarget::getImplementationName() throw(std::exception)
     164             : {
     165           0 :     return OUString(XDND_DROPTARGET_IMPLEMENTATION_NAME);
     166             : }
     167             : 
     168           0 : sal_Bool DropTarget::supportsService( const OUString& ServiceName ) throw(std::exception)
     169             : {
     170           0 :     return cppu::supportsService(this, ServiceName);
     171             : }
     172             : 
     173           0 : Sequence< OUString > DropTarget::getSupportedServiceNames() throw(std::exception)
     174             : {
     175           0 :     return Xdnd_dropTarget_getSupportedServiceNames();
     176             : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10