LCOV - code coverage report
Current view: top level - svtools/source/misc - cliplistener.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 19 28 67.9 %
Date: 2014-11-03 Functions: 7 9 77.8 %
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 <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/window.hxx>
      25             : #include <osl/mutex.hxx>
      26             : 
      27             : #include <svtools/cliplistener.hxx>
      28             : #include <svtools/transfer.hxx>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32             : 
      33             : 
      34         361 : TransferableClipboardListener::TransferableClipboardListener( const Link& rCallback ) :
      35         361 :     aLink( rCallback )
      36             : {
      37         361 : }
      38             : 
      39         714 : TransferableClipboardListener::~TransferableClipboardListener()
      40             : {
      41         714 : }
      42             : 
      43           0 : void SAL_CALL TransferableClipboardListener::disposing( const lang::EventObject& )
      44             :                                                         throw(uno::RuntimeException, std::exception)
      45             : {
      46           0 : }
      47             : 
      48           0 : void SAL_CALL TransferableClipboardListener::changedContents(
      49             :                             const datatransfer::clipboard::ClipboardEvent& rEventObject )
      50             :                                                         throw(uno::RuntimeException, std::exception)
      51             : {
      52           0 :     if ( aLink.IsSet() )
      53             :     {
      54           0 :         const SolarMutexGuard aGuard;
      55             : 
      56           0 :         TransferableDataHelper aDataHelper( rEventObject.Contents );
      57           0 :         aLink.Call( &aDataHelper );
      58             :     }
      59           0 : }
      60             : 
      61         718 : void TransferableClipboardListener::AddRemoveListener( vcl::Window* pWin, bool bAdd )
      62             : {
      63             :     try
      64             :     {
      65         718 :         if ( pWin )
      66             :         {
      67         718 :             uno::Reference<datatransfer::clipboard::XClipboard> xClipboard = pWin->GetClipboard();
      68        1436 :             uno::Reference<datatransfer::clipboard::XClipboardNotifier> xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
      69         718 :             if( xClpbrdNtfr.is() )
      70             :             {
      71         694 :                 uno::Reference<datatransfer::clipboard::XClipboardListener> xClipEvtLstnr( this );
      72         694 :                 if( bAdd )
      73         347 :                     xClpbrdNtfr->addClipboardListener( xClipEvtLstnr );
      74             :                 else
      75         347 :                     xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr );
      76         718 :             }
      77             :         }
      78             :     }
      79           0 :     catch( const ::com::sun::star::uno::Exception& )
      80             :     {
      81             :     }
      82         718 : }
      83             : 
      84         357 : void TransferableClipboardListener::ClearCallbackLink()
      85             : {
      86         357 :     aLink = Link();
      87        1584 : }
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10