LCOV - code coverage report
Current view: top level - libreoffice/unotools/source/config - options.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 43 81.4 %
Date: 2012-12-27 Functions: 9 13 69.2 %
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 "sal/config.h"
      22             : #include <unotools/options.hxx>
      23             : 
      24             : using utl::detail::Options;
      25             : using utl::ConfigurationBroadcaster;
      26             : 
      27       37016 : utl::ConfigurationListener::~ConfigurationListener() {}
      28             : 
      29       39288 : ConfigurationBroadcaster::ConfigurationBroadcaster()
      30             : : mpList(0)
      31             : , m_nBroadcastBlocked( 0 )
      32       39288 : , m_nBlockedHint( 0 )
      33             : {
      34       39288 : }
      35             : 
      36       37506 : ConfigurationBroadcaster::~ConfigurationBroadcaster()
      37             : {
      38       37506 :     delete mpList;
      39       37506 : }
      40             : 
      41        8199 : void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListener )
      42             : {
      43        8199 :     if ( !mpList )
      44        1670 :         mpList = new IMPL_ConfigurationListenerList;
      45        8199 :     mpList->push_back( pListener );
      46        8199 : }
      47             : 
      48        6903 : void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pListener )
      49             : {
      50        6903 :     if ( mpList ) {
      51      121542 :         for ( IMPL_ConfigurationListenerList::iterator it = mpList->begin();
      52       81028 :               it != mpList->end();
      53             :               ++it
      54             :         ) {
      55       40514 :             if ( *it == pListener ) {
      56        6903 :                 mpList->erase( it );
      57        6903 :                 break;
      58             :             }
      59             :         }
      60             :     }
      61        6903 : }
      62             : 
      63         186 : void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint )
      64             : {
      65         186 :     if ( m_nBroadcastBlocked )
      66           0 :         m_nBlockedHint |= nHint;
      67             :     else
      68             :     {
      69         186 :         nHint |= m_nBlockedHint;
      70         186 :         m_nBlockedHint = 0;
      71         186 :         if ( mpList ) {
      72         186 :             for ( size_t n = 0; n < mpList->size(); n++ ) {
      73         124 :                 (*mpList)[ n ]->ConfigurationChanged( this, nHint );
      74             :             }
      75             :         }
      76             :     }
      77         186 : }
      78             : 
      79           0 : void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
      80             : {
      81           0 :     if ( bBlock )
      82           0 :         ++m_nBroadcastBlocked;
      83           0 :     else if ( m_nBroadcastBlocked )
      84             :     {
      85           0 :         if ( --m_nBroadcastBlocked == 0 )
      86           0 :             NotifyListeners( 0 );
      87             :     }
      88           0 : }
      89             : 
      90       37718 : Options::Options()
      91             : {
      92       37718 : }
      93             : 
      94       36682 : Options::~Options()
      95             : {
      96       36682 : }
      97             : 
      98         124 : void Options::ConfigurationChanged( ConfigurationBroadcaster*, sal_uInt32 nHint )
      99             : {
     100         124 :     NotifyListeners( nHint );
     101         124 : }
     102             : 
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10