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

Generated by: LCOV version 1.11