LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/toolpanel - paneldecklisteners.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 48 85.4 %
Date: 2013-07-09 Functions: 10 11 90.9 %
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 "paneldecklisteners.hxx"
      22             : #include "svtools/toolpanel/toolpaneldeck.hxx"
      23             : 
      24             : //........................................................................
      25             : namespace svt
      26             : {
      27             : //........................................................................
      28             : 
      29             :     //====================================================================
      30             :     //= PanelDeckListeners
      31             :     //====================================================================
      32             :     //--------------------------------------------------------------------
      33          26 :     PanelDeckListeners::PanelDeckListeners()
      34             :     {
      35          26 :     }
      36             : 
      37             :     //--------------------------------------------------------------------
      38          26 :     PanelDeckListeners::~PanelDeckListeners()
      39             :     {
      40          26 :     }
      41             : 
      42             :     //--------------------------------------------------------------------
      43         130 :     void PanelDeckListeners::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition )
      44             :     {
      45         130 :         ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
      46         780 :         for (   ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
      47         520 :                 loop != aListeners.end();
      48             :                 ++loop
      49             :             )
      50             :         {
      51         130 :             (*loop)->PanelInserted( i_pPanel, i_nPosition );
      52         130 :         }
      53         130 :     }
      54             : 
      55             :     //--------------------------------------------------------------------
      56           0 :     void PanelDeckListeners::PanelRemoved( const size_t i_nPosition )
      57             :     {
      58           0 :         ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
      59           0 :         for (   ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
      60           0 :                 loop != aListeners.end();
      61             :                 ++loop
      62             :             )
      63             :         {
      64           0 :             (*loop)->PanelRemoved( i_nPosition );
      65           0 :         }
      66           0 :     }
      67             : 
      68             :     //--------------------------------------------------------------------
      69          32 :     void PanelDeckListeners::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive )
      70             :     {
      71          32 :         ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
      72         288 :         for (   ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
      73         192 :                 loop != aListeners.end();
      74             :                 ++loop
      75             :             )
      76             :         {
      77          64 :             (*loop)->ActivePanelChanged( i_rOldActive, i_rNewActive );
      78          32 :         }
      79          32 :     }
      80             : 
      81             :     //--------------------------------------------------------------------
      82          13 :     void PanelDeckListeners::LayouterChanged( const PDeckLayouter& i_rNewLayouter )
      83             :     {
      84          13 :         ::std::vector< IToolPanelDeckListener* > aListeners( m_aListeners );
      85          78 :         for (   ::std::vector< IToolPanelDeckListener* >::const_iterator loop = aListeners.begin();
      86          52 :                 loop != aListeners.end();
      87             :                 ++loop
      88             :             )
      89             :         {
      90          13 :             (*loop)->LayouterChanged( i_rNewLayouter );
      91          13 :         }
      92          13 :     }
      93             : 
      94             :     //--------------------------------------------------------------------
      95          26 :     void PanelDeckListeners::Dying()
      96             :     {
      97          65 :         while ( !m_aListeners.empty() )
      98             :         {
      99          13 :             IToolPanelDeckListener* pListener( *m_aListeners.begin() );
     100          13 :             m_aListeners.erase( m_aListeners.begin() );
     101          13 :             pListener->Dying();
     102             :         }
     103          26 :     }
     104             : 
     105             :     //--------------------------------------------------------------------
     106          52 :     void PanelDeckListeners::AddListener( IToolPanelDeckListener& i_rListener )
     107             :     {
     108          52 :         m_aListeners.push_back( &i_rListener );
     109          52 :     }
     110             : 
     111             :     //--------------------------------------------------------------------
     112          65 :     void PanelDeckListeners::RemoveListener( IToolPanelDeckListener& i_rListener )
     113             :     {
     114         312 :         for (   ::std::vector< IToolPanelDeckListener* >::iterator lookup = m_aListeners.begin();
     115         208 :                 lookup != m_aListeners.end();
     116             :                 ++lookup
     117             :             )
     118             :         {
     119          78 :             if ( *lookup == &i_rListener )
     120             :             {
     121          39 :                 m_aListeners.erase( lookup );
     122         104 :                 return;
     123             :             }
     124             :         }
     125             :     }
     126             : 
     127             : //........................................................................
     128         465 : } // namespace svt
     129             : //........................................................................
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10