LCOV - code coverage report
Current view: top level - libreoffice/svl/source/notify - broadcast.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 37 73.0 %
Date: 2012-12-17 Functions: 5 11 45.5 %
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 <svl/listener.hxx>
      22             : #include <svl/listeneriter.hxx>
      23             : #include <svl/broadcast.hxx>
      24             : #include <svl/smplhint.hxx>
      25             : 
      26             : 
      27             : //====================================================================
      28           0 : TYPEINIT0(SvtBroadcaster);
      29             : 
      30             : //====================================================================
      31             : 
      32             : // simple ctor of class SvtBroadcaster
      33             : 
      34       12548 : SvtBroadcaster::SvtBroadcaster()
      35       12548 :     : pRoot( 0 )
      36             : {
      37       12548 : }
      38             : 
      39             : //--------------------------------------------------------------------
      40             : 
      41             : // copy ctor of class SvtBroadcaster
      42             : 
      43           0 : SvtBroadcaster::SvtBroadcaster( const SvtBroadcaster &rBC )
      44           0 :     : pRoot( 0 )
      45             : {
      46           0 :     SvtListenerIter aIter( (SvtBroadcaster&)rBC );
      47           0 :     SvtListener* pLast = aIter.GoStart();
      48           0 :     if( pLast )
      49           0 :         do {
      50           0 :             pLast->StartListening( *this );
      51           0 :         } while( 0 != ( pLast = aIter.GoNext() ));
      52           0 : }
      53             : 
      54             : //--------------------------------------------------------------------
      55             : 
      56             : // unregister all listeners
      57             : 
      58       17606 : SvtBroadcaster::~SvtBroadcaster()
      59             : {
      60       10468 :     Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
      61             : 
      62       10468 :     SvtListenerIter aIter( *this );
      63       10468 :     SvtListener* pLast = aIter.GoStart();
      64       10468 :     if( pLast )
      65        1612 :         do {
      66        5770 :             pLast->EndListening( *this );
      67        5770 :             if( !HasListeners() )       // all gone ??
      68        4158 :                 break;
      69       10468 :         } while( 0 != ( pLast = aIter.GoNext() ));
      70       17606 : }
      71             : 
      72             : //--------------------------------------------------------------------
      73             : 
      74             : // broadcast immedeately
      75             : 
      76       10874 : void SvtBroadcaster::Broadcast( const SfxHint &rHint )
      77             : {
      78             :     // is anybody to notify?
      79       10874 :     if( HasListeners() /* && !IsModifyLocked()*/ )
      80             :     {
      81             : //      LockModify();
      82             : //      bInModify = sal_True;
      83             : 
      84        4478 :         SvtListenerIter aIter( *this );
      85        4478 :         SvtListener* pLast = aIter.GoStart();
      86        4478 :         if( pLast )
      87        6648 :             do {
      88        6650 :                 pLast->Notify( *this, rHint );
      89        6650 :                 if( !HasListeners() )       // all gone ??
      90           2 :                     break;
      91        4478 :             } while( 0 != ( pLast = aIter.GoNext() ));
      92             : 
      93             : //      bInModify = sal_False;
      94             : //      UnlockModify();
      95             :     }
      96       10874 : }
      97             : 
      98             : //--------------------------------------------------------------------
      99             : 
     100             : 
     101             : // called, if no more listeners exists
     102             : 
     103       10252 : void SvtBroadcaster::ListenersGone()
     104             : {
     105       10252 : }
     106             : 
     107             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10