1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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()
30 , m_nBroadcastBlocked( 0 )
35 ConfigurationBroadcaster::~ConfigurationBroadcaster()
40 void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener
* pListener
)
43 mpList
= new IMPL_ConfigurationListenerList
;
44 mpList
->push_back( pListener
);
47 void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener
* pListener
)
50 for ( IMPL_ConfigurationListenerList::iterator it
= mpList
->begin();
54 if ( *it
== pListener
) {
62 void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint
)
64 if ( m_nBroadcastBlocked
)
65 m_nBlockedHint
|= nHint
;
68 nHint
|= m_nBlockedHint
;
71 for ( size_t n
= 0; n
< mpList
->size(); n
++ ) {
72 (*mpList
)[ n
]->ConfigurationChanged( this, nHint
);
78 void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock
)
81 ++m_nBroadcastBlocked
;
82 else if ( m_nBroadcastBlocked
)
84 if ( --m_nBroadcastBlocked
== 0 )
97 void Options::ConfigurationChanged( ConfigurationBroadcaster
*, sal_uInt32 nHint
)
99 NotifyListeners( nHint
);
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */