LCOV - code coverage report
Current view: top level - chart2/source/tools - ModifyListenerCallBack.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 26 0.0 %
Date: 2014-04-11 Functions: 0 10 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 "ModifyListenerCallBack.hxx"
      21             : #include "MutexContainer.hxx"
      22             : #include <cppuhelper/compbase1.hxx>
      23             : 
      24             : using namespace ::com::sun::star;
      25             : using ::com::sun::star::uno::Reference;
      26             : 
      27             : namespace chart {
      28             : 
      29             : typedef ::cppu::WeakComponentImplHelper1<
      30             :         ::com::sun::star::util::XModifyListener >
      31             :     ModifyListenerCallBack_Base;
      32             : 
      33             : class ModifyListenerCallBack_impl
      34             :     : public ::chart::MutexContainer
      35             :     , public ModifyListenerCallBack_Base
      36             : {
      37             : public:
      38             :     explicit ModifyListenerCallBack_impl( const Link& rCallBack );
      39             :     virtual ~ModifyListenerCallBack_impl();
      40             : 
      41             :     void stopListening();
      42             : 
      43             :     //XModifyListener
      44             :     virtual void SAL_CALL modified( const lang::EventObject& aEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      45             : 
      46             :     //XEventListener
      47             :     virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
      48             : 
      49             :     using ::cppu::WeakComponentImplHelperBase::disposing;
      50             : 
      51             : private:
      52             :     Link m_aLink;//will be callef on modify
      53             :     Reference< util::XModifyBroadcaster > m_xBroadcaster;//broadcaster to listen at
      54             : };
      55             : 
      56           0 : ModifyListenerCallBack_impl::ModifyListenerCallBack_impl( const Link& rCallBack )
      57             :                         : ModifyListenerCallBack_Base( m_aMutex )
      58             :                         , m_aLink( rCallBack )
      59           0 :                         , m_xBroadcaster(0)
      60             : {
      61           0 : }
      62             : 
      63           0 : ModifyListenerCallBack_impl::~ModifyListenerCallBack_impl()
      64             : {
      65           0 : }
      66             : 
      67             : //XModifyListener
      68           0 : void SAL_CALL ModifyListenerCallBack_impl::modified( const lang::EventObject& /*aEvent*/ ) throw (uno::RuntimeException, std::exception)
      69             : {
      70           0 :     m_aLink.Call(0);
      71           0 : }
      72             : 
      73             : //XEventListener
      74           0 : void SAL_CALL ModifyListenerCallBack_impl::disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException, std::exception)
      75             : {
      76           0 :     m_xBroadcaster.clear();
      77           0 : }
      78             : 
      79           0 : void ModifyListenerCallBack_impl::stopListening()
      80             : {
      81           0 :     if( m_xBroadcaster.is() )
      82             :     {
      83           0 :         m_xBroadcaster->removeModifyListener( this );
      84           0 :         m_xBroadcaster.clear();
      85             :     }
      86           0 : }
      87             : 
      88           0 : ModifyListenerCallBack::ModifyListenerCallBack( const Link& rCallBack )
      89           0 :                         : pModifyListener_impl( new ModifyListenerCallBack_impl(rCallBack) )
      90           0 :                         , m_xModifyListener( pModifyListener_impl )
      91             : {
      92           0 : }
      93             : 
      94           0 : ModifyListenerCallBack::~ModifyListenerCallBack()
      95             : {
      96           0 :     stopListening();
      97           0 : }
      98             : 
      99           0 : void ModifyListenerCallBack::stopListening()
     100             : {
     101           0 :     pModifyListener_impl->stopListening();
     102           0 : }
     103             : 
     104             : } // namespace chart
     105             : 
     106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10