LCOV - code coverage report
Current view: top level - svtools/source/misc - cliplistener.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 28 67.9 %
Date: 2012-08-25 Functions: 5 7 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 36 33.3 %

           Branch data     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                 :        320 : TransferableClipboardListener::TransferableClipboardListener( const Link& rCallback ) :
      35                 :        320 :     aLink( rCallback )
      36                 :            : {
      37                 :        320 : }
      38                 :            : 
      39                 :        320 : TransferableClipboardListener::~TransferableClipboardListener()
      40                 :            : {
      41         [ -  + ]:        640 : }
      42                 :            : 
      43                 :          0 : void SAL_CALL TransferableClipboardListener::disposing( const lang::EventObject& )
      44                 :            :                                                         throw(uno::RuntimeException)
      45                 :            : {
      46                 :          0 : }
      47                 :            : 
      48                 :          0 : void SAL_CALL TransferableClipboardListener::changedContents(
      49                 :            :                             const datatransfer::clipboard::ClipboardEvent& rEventObject )
      50                 :            :                                                         throw(uno::RuntimeException)
      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                 :        640 : void TransferableClipboardListener::AddRemoveListener( Window* pWin, sal_Bool bAdd )
      62                 :            : {
      63                 :            :     try
      64                 :            :     {
      65         [ +  - ]:        640 :         if ( pWin )
      66                 :            :         {
      67         [ +  - ]:        640 :             uno::Reference<datatransfer::clipboard::XClipboard> xClipboard = pWin->GetClipboard();
      68         [ +  - ]:        640 :             uno::Reference<datatransfer::clipboard::XClipboardNotifier> xClpbrdNtfr( xClipboard, uno::UNO_QUERY );
      69         [ +  - ]:        640 :             if( xClpbrdNtfr.is() )
      70                 :            :             {
      71         [ +  - ]:        640 :                 uno::Reference<datatransfer::clipboard::XClipboardListener> xClipEvtLstnr( this );
      72         [ +  + ]:        640 :                 if( bAdd )
      73 [ +  - ][ +  - ]:        320 :                     xClpbrdNtfr->addClipboardListener( xClipEvtLstnr );
      74                 :            :                 else
      75 [ +  - ][ +  - ]:        640 :                     xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr );
      76         [ #  # ]:        640 :             }
      77                 :            :         }
      78                 :            :     }
      79                 :          0 :     catch( const ::com::sun::star::uno::Exception& )
      80                 :            :     {
      81                 :            :     }
      82                 :        640 : }
      83                 :            : 
      84                 :        320 : void TransferableClipboardListener::ClearCallbackLink()
      85                 :            : {
      86                 :        320 :     aLink = Link();
      87                 :        320 : }
      88                 :            : 
      89                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10