2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-04-11 18:29:47 +00:00
|
|
|
|
2013-10-23 19:16:30 +02:00
|
|
|
#ifndef INCLUDED_UNOTOOLS_OPTIONS_HXX
|
|
|
|
#define INCLUDED_UNOTOOLS_OPTIONS_HXX
|
2007-04-11 18:29:47 +00:00
|
|
|
|
2013-11-09 15:34:19 -06:00
|
|
|
#include <sal/config.h>
|
|
|
|
#include <unotools/unotoolsdllapi.h>
|
2011-02-16 07:15:00 -08:00
|
|
|
#include <vector>
|
2007-04-11 18:29:47 +00:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
/*
|
|
|
|
The class utl::detail::Options provides a kind of multiplexer. It implements a ConfigurationListener
|
|
|
|
that is usually registered at a ConfigItem class. At the same time it implements a ConfigurationBroadcaster
|
|
|
|
that allows further ("external") listeners to register.
|
|
|
|
Once the class deriving from Options is notified about
|
|
|
|
configuration changes by the ConfigItem if its content has been changed by calling some of its methods,
|
|
|
|
a call of the Options::NotifyListeners() method will send out notifications to all external listeners.
|
|
|
|
*/
|
|
|
|
|
2009-10-06 07:38:24 +02:00
|
|
|
namespace utl {
|
|
|
|
|
|
|
|
class ConfigurationBroadcaster;
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
// interface for configuration listener
|
2009-10-06 07:38:24 +02:00
|
|
|
class UNOTOOLS_DLLPUBLIC ConfigurationListener
|
|
|
|
{
|
|
|
|
public:
|
2011-10-24 12:27:16 +02:00
|
|
|
virtual ~ConfigurationListener();
|
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
virtual void ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) = 0;
|
2009-10-06 07:38:24 +02:00
|
|
|
};
|
2011-02-16 07:15:00 -08:00
|
|
|
typedef ::std::vector< ConfigurationListener* > IMPL_ConfigurationListenerList;
|
2009-10-06 07:38:24 +02:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
// complete broadcasting implementation
|
2009-10-06 07:38:24 +02:00
|
|
|
class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster
|
|
|
|
{
|
|
|
|
IMPL_ConfigurationListenerList* mpList;
|
2009-10-12 11:49:13 +02:00
|
|
|
sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0
|
2009-10-16 00:05:16 +02:00
|
|
|
sal_uInt32 m_nBlockedHint;
|
2009-10-12 11:49:13 +02:00
|
|
|
|
2009-10-06 07:38:24 +02:00
|
|
|
public:
|
|
|
|
void AddListener( utl::ConfigurationListener* pListener );
|
|
|
|
void RemoveListener( utl::ConfigurationListener* pListener );
|
2009-10-16 00:05:16 +02:00
|
|
|
|
|
|
|
// notify listeners; nHint is an implementation detail of the particular class deriving from ConfigurationBroadcaster
|
|
|
|
void NotifyListeners( sal_uInt32 nHint );
|
2009-10-06 07:38:24 +02:00
|
|
|
ConfigurationBroadcaster();
|
2009-11-04 21:54:56 +01:00
|
|
|
virtual ~ConfigurationBroadcaster();
|
2009-11-03 18:41:58 +01:00
|
|
|
virtual void BlockBroadcasts( bool bBlock );
|
2009-10-06 07:38:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace detail {
|
2007-04-11 18:29:47 +00:00
|
|
|
|
|
|
|
// A base class for the various option classes supported by
|
2009-10-06 07:38:24 +02:00
|
|
|
// unotools/source/config/itemholderbase.hxx (which must be public, as it is
|
2009-10-16 00:05:16 +02:00
|
|
|
// shared between unotools, svl and svt)
|
|
|
|
// It also provides an implementation for a Configuration Listener and inherits a broadcaster implementation
|
|
|
|
|
2012-11-30 09:36:49 +00:00
|
|
|
class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED Options
|
|
|
|
: public utl::ConfigurationBroadcaster, public utl::ConfigurationListener
|
2009-10-06 07:38:24 +02:00
|
|
|
{
|
2007-04-11 18:29:47 +00:00
|
|
|
public:
|
|
|
|
Options();
|
|
|
|
|
|
|
|
virtual ~Options() = 0;
|
|
|
|
|
|
|
|
private:
|
2015-10-12 15:25:41 +02:00
|
|
|
Options(Options &) = delete;
|
|
|
|
void operator =(Options &) = delete;
|
2009-10-16 00:05:16 +02:00
|
|
|
|
|
|
|
protected:
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) override;
|
2007-04-11 18:29:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
#endif
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|