LibreOffice Module unotools (master) 1
options.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21#include <unotools/options.hxx>
22
23#include <algorithm>
24
27
29
31: m_nBroadcastBlocked( 0 )
32, m_nBlockedHint( ConfigurationHints::NONE )
33{
34}
35
37: mpList( rSource.mpList ? new IMPL_ConfigurationListenerList(*rSource.mpList) : nullptr )
38, m_nBroadcastBlocked( rSource.m_nBroadcastBlocked )
39, m_nBlockedHint( rSource.m_nBlockedHint )
40{
41}
42
44{
45}
46
48 ConfigurationBroadcaster const & other)
49{
50 if (&other != this) {
51 mpList.reset(
52 other.mpList == nullptr ? nullptr : new IMPL_ConfigurationListenerList(*other.mpList));
55 }
56 return *this;
57}
58
60{
61 if ( !mpList )
63 mpList->push_back( pListener );
64}
65
67{
68 if ( mpList ) {
69 auto it = std::find(mpList->begin(), mpList->end(), pListener);
70 if ( it != mpList->end() )
71 mpList->erase( it );
72 }
73}
74
76{
78 m_nBlockedHint |= nHint;
79 else
80 {
81 nHint |= m_nBlockedHint;
83 if ( mpList ) {
84 for ( size_t n = 0; n < mpList->size(); n++ )
85 (*mpList)[ n ]->ConfigurationChanged( this, nHint );
86 }
87 }
88}
89
91{
92 if ( bBlock )
94 else if ( m_nBroadcastBlocked )
95 {
96 if ( --m_nBroadcastBlocked == 0 )
98 }
99}
100
102{
103}
104
106{
107}
108
109void Options::ConfigurationChanged( ConfigurationBroadcaster*, ConfigurationHints nHint )
110{
111 NotifyListeners( nHint );
112}
113
114/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
EdgeEntry * mpList
virtual ~Options()
Definition: options.cxx:105
Options()
Definition: options.cxx:101
std::unique_ptr< IMPL_ConfigurationListenerList > mpList
Definition: options.hxx:70
void AddListener(utl::ConfigurationListener *pListener)
Definition: options.cxx:59
virtual void BlockBroadcasts(bool bBlock)
Definition: options.cxx:90
void RemoveListener(utl::ConfigurationListener const *pListener)
Definition: options.cxx:66
ConfigurationBroadcaster & operator=(ConfigurationBroadcaster const &other)
Definition: options.cxx:47
virtual ~ConfigurationBroadcaster()
Definition: options.cxx:43
ConfigurationHints m_nBlockedHint
Definition: options.hxx:72
void NotifyListeners(ConfigurationHints nHint)
Definition: options.cxx:75
virtual ~ConfigurationListener()
Definition: options.cxx:28
sal_Int64 n
NONE
::std::vector< ConfigurationListener * > IMPL_ConfigurationListenerList
Definition: options.hxx:65
ConfigurationHints
Definition: options.hxx:30