bump product version to 4.1.6.2
[LibreOffice.git] / unotools / source / config / options.cxx
blob202a2afc69d9bcb47864dd8354ef8b10ae1de572
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "sal/config.h"
22 #include <unotools/options.hxx>
24 using utl::detail::Options;
25 using utl::ConfigurationBroadcaster;
27 utl::ConfigurationListener::~ConfigurationListener() {}
29 ConfigurationBroadcaster::ConfigurationBroadcaster()
30 : mpList(0)
31 , m_nBroadcastBlocked( 0 )
32 , m_nBlockedHint( 0 )
36 ConfigurationBroadcaster::~ConfigurationBroadcaster()
38 delete mpList;
41 void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListener )
43 if ( !mpList )
44 mpList = new IMPL_ConfigurationListenerList;
45 mpList->push_back( pListener );
48 void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pListener )
50 if ( mpList ) {
51 for ( IMPL_ConfigurationListenerList::iterator it = mpList->begin();
52 it != mpList->end();
53 ++it
54 ) {
55 if ( *it == pListener ) {
56 mpList->erase( it );
57 break;
63 void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint )
65 if ( m_nBroadcastBlocked )
66 m_nBlockedHint |= nHint;
67 else
69 nHint |= m_nBlockedHint;
70 m_nBlockedHint = 0;
71 if ( mpList ) {
72 for ( size_t n = 0; n < mpList->size(); n++ ) {
73 (*mpList)[ n ]->ConfigurationChanged( this, nHint );
79 void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
81 if ( bBlock )
82 ++m_nBroadcastBlocked;
83 else if ( m_nBroadcastBlocked )
85 if ( --m_nBroadcastBlocked == 0 )
86 NotifyListeners( 0 );
90 Options::Options()
94 Options::~Options()
98 void Options::ConfigurationChanged( ConfigurationBroadcaster*, sal_uInt32 nHint )
100 NotifyListeners( nHint );
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */