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 .
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()
31 , m_nBroadcastBlocked( 0 )
36 ConfigurationBroadcaster::~ConfigurationBroadcaster()
41 void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener
* pListener
)
44 mpList
= new IMPL_ConfigurationListenerList
;
45 mpList
->push_back( pListener
);
48 void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener
* pListener
)
51 for ( IMPL_ConfigurationListenerList::iterator it
= mpList
->begin();
55 if ( *it
== pListener
) {
63 void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint
)
65 if ( m_nBroadcastBlocked
)
66 m_nBlockedHint
|= nHint
;
69 nHint
|= m_nBlockedHint
;
72 for ( size_t n
= 0; n
< mpList
->size(); n
++ ) {
73 (*mpList
)[ n
]->ConfigurationChanged( this, nHint
);
79 void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock
)
82 ++m_nBroadcastBlocked
;
83 else if ( m_nBroadcastBlocked
)
85 if ( --m_nBroadcastBlocked
== 0 )
98 void Options::ConfigurationChanged( ConfigurationBroadcaster
*, sal_uInt32 nHint
)
100 NotifyListeners( nHint
);
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */