1*bae3752eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*bae3752eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*bae3752eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*bae3752eSAndrew Rist * distributed with this work for additional information 6*bae3752eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*bae3752eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*bae3752eSAndrew Rist * "License"); you may not use this file except in compliance 9*bae3752eSAndrew Rist * with the License. You may obtain a copy of the License at 10*bae3752eSAndrew Rist * 11*bae3752eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*bae3752eSAndrew Rist * 13*bae3752eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*bae3752eSAndrew Rist * software distributed under the License is distributed on an 15*bae3752eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*bae3752eSAndrew Rist * KIND, either express or implied. See the License for the 17*bae3752eSAndrew Rist * specific language governing permissions and limitations 18*bae3752eSAndrew Rist * under the License. 19*bae3752eSAndrew Rist * 20*bae3752eSAndrew Rist *************************************************************/ 21*bae3752eSAndrew Rist 22*bae3752eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_unotools_OPTIONS_HXX 25cdf0e10cSrcweir #define INCLUDED_unotools_OPTIONS_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "sal/config.h" 28cdf0e10cSrcweir #include "unotools/unotoolsdllapi.h" 29cdf0e10cSrcweir 30cdf0e10cSrcweir /* 31cdf0e10cSrcweir The class utl::detail::Options provides a kind of multiplexer. It implements a ConfigurationListener 32cdf0e10cSrcweir that is usually registered at a ConfigItem class. At the same time it implements a ConfigurationBroadcaster 33cdf0e10cSrcweir that allows further ("external") listeners to register. 34cdf0e10cSrcweir Once the class deriving from Options is notified about 35cdf0e10cSrcweir configuration changes by the ConfigItem if its content has been changed by calling some of its methods, 36cdf0e10cSrcweir a call of the Options::NotifyListeners() method will send out notifications to all external listeners. 37cdf0e10cSrcweir */ 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace utl { 40cdf0e10cSrcweir 41cdf0e10cSrcweir class ConfigurationBroadcaster; 42cdf0e10cSrcweir class IMPL_ConfigurationListenerList; 43cdf0e10cSrcweir 44cdf0e10cSrcweir // interface for configuration listener 45cdf0e10cSrcweir class UNOTOOLS_DLLPUBLIC ConfigurationListener 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir virtual void ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) = 0; 49cdf0e10cSrcweir }; 50cdf0e10cSrcweir 51cdf0e10cSrcweir // complete broadcasting implementation 52cdf0e10cSrcweir class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster 53cdf0e10cSrcweir { 54cdf0e10cSrcweir IMPL_ConfigurationListenerList* mpList; 55cdf0e10cSrcweir sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0 56cdf0e10cSrcweir sal_uInt32 m_nBlockedHint; 57cdf0e10cSrcweir 58cdf0e10cSrcweir public: 59cdf0e10cSrcweir void AddListener( utl::ConfigurationListener* pListener ); 60cdf0e10cSrcweir void RemoveListener( utl::ConfigurationListener* pListener ); 61cdf0e10cSrcweir 62cdf0e10cSrcweir // notify listeners; nHint is an implementation detail of the particular class deriving from ConfigurationBroadcaster 63cdf0e10cSrcweir void NotifyListeners( sal_uInt32 nHint ); 64cdf0e10cSrcweir ConfigurationBroadcaster(); 65cdf0e10cSrcweir virtual ~ConfigurationBroadcaster(); 66cdf0e10cSrcweir virtual void BlockBroadcasts( bool bBlock ); 67cdf0e10cSrcweir }; 68cdf0e10cSrcweir 69cdf0e10cSrcweir namespace detail { 70cdf0e10cSrcweir 71cdf0e10cSrcweir // A base class for the various option classes supported by 72cdf0e10cSrcweir // unotools/source/config/itemholderbase.hxx (which must be public, as it is 73cdf0e10cSrcweir // shared between unotools, svl and svt) 74cdf0e10cSrcweir // It also provides an implementation for a Configuration Listener and inherits a broadcaster implementation 75cdf0e10cSrcweir 76cdf0e10cSrcweir class UNOTOOLS_DLLPUBLIC Options : public utl::ConfigurationBroadcaster, public utl::ConfigurationListener 77cdf0e10cSrcweir { 78cdf0e10cSrcweir public: 79cdf0e10cSrcweir Options(); 80cdf0e10cSrcweir 81cdf0e10cSrcweir virtual ~Options() = 0; 82cdf0e10cSrcweir 83cdf0e10cSrcweir private: 84cdf0e10cSrcweir UNOTOOLS_DLLPRIVATE Options(Options &); // not defined 85cdf0e10cSrcweir UNOTOOLS_DLLPRIVATE void operator =(Options &); // not defined 86cdf0e10cSrcweir 87cdf0e10cSrcweir protected: 88cdf0e10cSrcweir virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ); 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir } } 92cdf0e10cSrcweir 93cdf0e10cSrcweir #endif 94