1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_unotools_OPTIONS_HXX 29 #define INCLUDED_unotools_OPTIONS_HXX 30 31 #include "sal/config.h" 32 #include "unotools/unotoolsdllapi.h" 33 34 /* 35 The class utl::detail::Options provides a kind of multiplexer. It implements a ConfigurationListener 36 that is usually registered at a ConfigItem class. At the same time it implements a ConfigurationBroadcaster 37 that allows further ("external") listeners to register. 38 Once the class deriving from Options is notified about 39 configuration changes by the ConfigItem if its content has been changed by calling some of its methods, 40 a call of the Options::NotifyListeners() method will send out notifications to all external listeners. 41 */ 42 43 namespace utl { 44 45 class ConfigurationBroadcaster; 46 class IMPL_ConfigurationListenerList; 47 48 // interface for configuration listener 49 class UNOTOOLS_DLLPUBLIC ConfigurationListener 50 { 51 public: 52 virtual void ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) = 0; 53 }; 54 55 // complete broadcasting implementation 56 class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster 57 { 58 IMPL_ConfigurationListenerList* mpList; 59 sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0 60 sal_uInt32 m_nBlockedHint; 61 62 public: 63 void AddListener( utl::ConfigurationListener* pListener ); 64 void RemoveListener( utl::ConfigurationListener* pListener ); 65 66 // notify listeners; nHint is an implementation detail of the particular class deriving from ConfigurationBroadcaster 67 void NotifyListeners( sal_uInt32 nHint ); 68 ConfigurationBroadcaster(); 69 virtual ~ConfigurationBroadcaster(); 70 virtual void BlockBroadcasts( bool bBlock ); 71 }; 72 73 namespace detail { 74 75 // A base class for the various option classes supported by 76 // unotools/source/config/itemholderbase.hxx (which must be public, as it is 77 // shared between unotools, svl and svt) 78 // It also provides an implementation for a Configuration Listener and inherits a broadcaster implementation 79 80 class UNOTOOLS_DLLPUBLIC Options : public utl::ConfigurationBroadcaster, public utl::ConfigurationListener 81 { 82 public: 83 Options(); 84 85 virtual ~Options() = 0; 86 87 private: 88 UNOTOOLS_DLLPRIVATE Options(Options &); // not defined 89 UNOTOOLS_DLLPRIVATE void operator =(Options &); // not defined 90 91 protected: 92 virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ); 93 }; 94 95 } } 96 97 #endif 98