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

Generated by: LCOV version 1.10