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

Generated by: LCOV version 1.10