LCOV - code coverage report
Current view: top level - vcl/unx/generic/dtrans - X11_droptarget.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 84 0.0 %
Date: 2014-11-03 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::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           0 : 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           0 :     m_pSelectionManager( NULL )
      40             : {
      41           0 : }
      42             : 
      43           0 : DropTarget::~DropTarget()
      44             : {
      45           0 :     if( m_pSelectionManager )
      46           0 :         m_pSelectionManager->deregisterDropTarget( m_aTargetWindow );
      47           0 : }
      48             : 
      49           0 : void DropTarget::initialize( const Sequence< Any >& arguments ) throw( ::com::sun::star::uno::Exception, std::exception )
      50             : {
      51           0 :     if( arguments.getLength() > 1 )
      52             :     {
      53           0 :         OUString aDisplayName;
      54           0 :         Reference< XDisplayConnection > xConn;
      55           0 :         arguments.getConstArray()[0] >>= xConn;
      56           0 :         if( xConn.is() )
      57             :         {
      58           0 :             Any aIdentifier;
      59           0 :             aIdentifier >>= aDisplayName;
      60             :         }
      61             : 
      62           0 :         m_pSelectionManager = &SelectionManager::get( aDisplayName );
      63           0 :         m_xSelectionManager = static_cast< XDragSource* >(m_pSelectionManager);
      64           0 :         m_pSelectionManager->initialize( arguments );
      65             : 
      66           0 :         if( m_pSelectionManager->getDisplay() ) // #136582# sanity check
      67             :         {
      68           0 :             sal_Size aWindow = None;
      69           0 :             arguments.getConstArray()[1] >>= aWindow;
      70           0 :             m_pSelectionManager->registerDropTarget( aWindow, this );
      71           0 :             m_aTargetWindow = aWindow;
      72           0 :             m_bActive = true;
      73           0 :         }
      74             :     }
      75           0 : }
      76             : 
      77           0 : void DropTarget::addDropTargetListener( const Reference< XDropTargetListener >& xListener ) throw(std::exception)
      78             : {
      79           0 :     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
      80             : 
      81           0 :     m_aListeners.push_back( xListener );
      82           0 : }
      83             : 
      84           0 : void DropTarget::removeDropTargetListener( const Reference< XDropTargetListener >& xListener ) throw(std::exception)
      85             : {
      86           0 :     ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
      87             : 
      88           0 :     m_aListeners.remove( xListener );
      89           0 : }
      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           0 : sal_Int8 DropTarget::getDefaultActions() throw(std::exception)
     104             : {
     105           0 :     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.10