LCOV - code coverage report
Current view: top level - unotools/source/config - options.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 42 43 97.7 %
Date: 2014-11-03 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             : #include <sal/config.h>
      21             : #include <unotools/options.hxx>
      22             : 
      23             : using utl::detail::Options;
      24             : using utl::ConfigurationBroadcaster;
      25             : 
      26     1312824 : utl::ConfigurationListener::~ConfigurationListener() {}
      27             : 
      28     1331762 : ConfigurationBroadcaster::ConfigurationBroadcaster()
      29             : : mpList(0)
      30             : , m_nBroadcastBlocked( 0 )
      31     1331762 : , m_nBlockedHint( 0 )
      32             : {
      33     1331762 : }
      34             : 
      35     1328423 : ConfigurationBroadcaster::~ConfigurationBroadcaster()
      36             : {
      37     1328423 :     delete mpList;
      38     1328423 : }
      39             : 
      40      249949 : void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListener )
      41             : {
      42      249949 :     if ( !mpList )
      43       88341 :         mpList = new IMPL_ConfigurationListenerList;
      44      249949 :     mpList->push_back( pListener );
      45      249949 : }
      46             : 
      47      248789 : void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pListener )
      48             : {
      49      248789 :     if ( mpList ) {
      50     2345484 :         for ( IMPL_ConfigurationListenerList::iterator it = mpList->begin();
      51     1563656 :               it != mpList->end();
      52             :               ++it
      53             :         ) {
      54      781828 :             if ( *it == pListener ) {
      55      248789 :                 mpList->erase( it );
      56      248789 :                 break;
      57             :             }
      58             :         }
      59             :     }
      60      248789 : }
      61             : 
      62        1544 : void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint )
      63             : {
      64        1544 :     if ( m_nBroadcastBlocked )
      65           0 :         m_nBlockedHint |= nHint;
      66             :     else
      67             :     {
      68        1544 :         nHint |= m_nBlockedHint;
      69        1544 :         m_nBlockedHint = 0;
      70        1544 :         if ( mpList ) {
      71        2288 :             for ( size_t n = 0; n < mpList->size(); n++ ) {
      72        1478 :                 (*mpList)[ n ]->ConfigurationChanged( this, nHint );
      73             :             }
      74             :         }
      75             :     }
      76        1544 : }
      77             : 
      78          48 : void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
      79             : {
      80          48 :     if ( bBlock )
      81          24 :         ++m_nBroadcastBlocked;
      82          24 :     else if ( m_nBroadcastBlocked )
      83             :     {
      84          24 :         if ( --m_nBroadcastBlocked == 0 )
      85          24 :             NotifyListeners( 0 );
      86             :     }
      87          48 : }
      88             : 
      89     1291599 : Options::Options()
      90             : {
      91     1291599 : }
      92             : 
      93     1290692 : Options::~Options()
      94             : {
      95     1290692 : }
      96             : 
      97        1030 : void Options::ConfigurationChanged( ConfigurationBroadcaster*, sal_uInt32 nHint )
      98             : {
      99        1030 :     NotifyListeners( nHint );
     100        1030 : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10