1*b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b5088357SAndrew Rist * distributed with this work for additional information
6*b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b5088357SAndrew Rist * "License"); you may not use this file except in compliance
9*b5088357SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b5088357SAndrew Rist * software distributed under the License is distributed on an
15*b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b5088357SAndrew Rist * KIND, either express or implied. See the License for the
17*b5088357SAndrew Rist * specific language governing permissions and limitations
18*b5088357SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*b5088357SAndrew Rist *************************************************************/
21*b5088357SAndrew Rist
22*b5088357SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_unotools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir #include <tools/list.hxx>
29cdf0e10cSrcweir #include <unotools/options.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir namespace utl
32cdf0e10cSrcweir {
33cdf0e10cSrcweir DECLARE_LIST( IMPL_ConfigurationListenerList, ConfigurationListener* )
34cdf0e10cSrcweir }
35cdf0e10cSrcweir
36cdf0e10cSrcweir using utl::detail::Options;
37cdf0e10cSrcweir using utl::ConfigurationBroadcaster;
38cdf0e10cSrcweir
ConfigurationBroadcaster()39cdf0e10cSrcweir ConfigurationBroadcaster::ConfigurationBroadcaster()
40cdf0e10cSrcweir : mpList(0)
41cdf0e10cSrcweir , m_nBroadcastBlocked( 0 )
42cdf0e10cSrcweir , m_nBlockedHint( 0 )
43cdf0e10cSrcweir {
44cdf0e10cSrcweir }
45cdf0e10cSrcweir
~ConfigurationBroadcaster()46cdf0e10cSrcweir ConfigurationBroadcaster::~ConfigurationBroadcaster()
47cdf0e10cSrcweir {
48cdf0e10cSrcweir delete mpList;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
AddListener(utl::ConfigurationListener * pListener)51cdf0e10cSrcweir void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListener )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir if ( !mpList )
54cdf0e10cSrcweir mpList = new IMPL_ConfigurationListenerList;
55cdf0e10cSrcweir mpList->Insert( pListener );
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
RemoveListener(utl::ConfigurationListener * pListener)58cdf0e10cSrcweir void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener* pListener )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir if ( mpList )
61cdf0e10cSrcweir mpList->Remove( pListener );
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
NotifyListeners(sal_uInt32 nHint)64cdf0e10cSrcweir void ConfigurationBroadcaster::NotifyListeners( sal_uInt32 nHint )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir if ( m_nBroadcastBlocked )
67cdf0e10cSrcweir m_nBlockedHint |= nHint;
68cdf0e10cSrcweir else
69cdf0e10cSrcweir {
70cdf0e10cSrcweir nHint |= m_nBlockedHint;
71cdf0e10cSrcweir m_nBlockedHint = 0;
72cdf0e10cSrcweir if ( mpList )
73cdf0e10cSrcweir for ( sal_uInt32 n=0; n<mpList->Count(); n++ )
74cdf0e10cSrcweir mpList->GetObject(n)->ConfigurationChanged( this, nHint );
75cdf0e10cSrcweir }
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
BlockBroadcasts(bool bBlock)78cdf0e10cSrcweir void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir if ( bBlock )
81cdf0e10cSrcweir ++m_nBroadcastBlocked;
82cdf0e10cSrcweir else if ( m_nBroadcastBlocked )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir if ( --m_nBroadcastBlocked == 0 )
85cdf0e10cSrcweir NotifyListeners( 0 );
86cdf0e10cSrcweir }
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
Options()89cdf0e10cSrcweir Options::Options()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
~Options()93cdf0e10cSrcweir Options::~Options()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
ConfigurationChanged(ConfigurationBroadcaster *,sal_uInt32 nHint)97cdf0e10cSrcweir void Options::ConfigurationChanged( ConfigurationBroadcaster*, sal_uInt32 nHint )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir NotifyListeners( nHint );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103