Bump version to 4.3-4
[LibreOffice.git] / unotools / source / config / options.cxx
blob6483d1d3e7ba59508f6801e348850a06c34814b5
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 .
20 #include <sal/config.h>
21 #include <unotools/options.hxx>
23 using utl::detail::Options;
24 using utl::ConfigurationBroadcaster;
26 utl::ConfigurationListener::~ConfigurationListener() {}
28 ConfigurationBroadcaster::ConfigurationBroadcaster()
29 : mpList(0)
30 , m_nBroadcastBlocked( 0 )
31 , m_nBlockedHint( 0 )
35 ConfigurationBroadcaster::~ConfigurationBroadcaster()
37 delete mpList;
40 void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListener )
42 if ( !mpList )
43 mpList = new IMPL_ConfigurationListenerList;
44 mpList->push_back( pListener );
47 void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pListener )
49 if ( mpList ) {
50 for ( IMPL_ConfigurationListenerList::iterator it = mpList->begin();
51 it != mpList->end();
52 ++it
53 ) {
54 if ( *it == pListener ) {
55 mpList->erase( it );
56 break;
62 void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint )
64 if ( m_nBroadcastBlocked )
65 m_nBlockedHint |= nHint;
66 else
68 nHint |= m_nBlockedHint;
69 m_nBlockedHint = 0;
70 if ( mpList ) {
71 for ( size_t n = 0; n < mpList->size(); n++ ) {
72 (*mpList)[ n ]->ConfigurationChanged( this, nHint );
78 void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
80 if ( bBlock )
81 ++m_nBroadcastBlocked;
82 else if ( m_nBroadcastBlocked )
84 if ( --m_nBroadcastBlocked == 0 )
85 NotifyListeners( 0 );
89 Options::Options()
93 Options::~Options()
97 void Options::ConfigurationChanged( ConfigurationBroadcaster*, sal_uInt32 nHint )
99 NotifyListeners( nHint );
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */