tdf#129905 tdf#160365 sw: don't always draw text boundary on frames
[LibreOffice.git] / unotools / source / config / options.cxx
blob4da44fa274b554ca57fd2e65ba1505f4d5aaa9fa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
21 #include <unotools/options.hxx>
23 #include <algorithm>
25 using utl::detail::Options;
26 using utl::ConfigurationBroadcaster;
28 utl::ConfigurationListener::~ConfigurationListener() {}
30 ConfigurationBroadcaster::ConfigurationBroadcaster()
31 : m_nBroadcastBlocked( 0 )
32 , m_nBlockedHint( ConfigurationHints::NONE )
36 ConfigurationBroadcaster::ConfigurationBroadcaster(ConfigurationBroadcaster const & rSource)
37 : mpList( rSource.mpList ? new IMPL_ConfigurationListenerList(*rSource.mpList) : nullptr )
38 , m_nBroadcastBlocked( rSource.m_nBroadcastBlocked )
39 , m_nBlockedHint( rSource.m_nBlockedHint )
43 ConfigurationBroadcaster::~ConfigurationBroadcaster()
47 ConfigurationBroadcaster & ConfigurationBroadcaster::operator =(
48 ConfigurationBroadcaster const & other)
50 if (&other != this) {
51 mpList.reset(
52 other.mpList == nullptr ? nullptr : new IMPL_ConfigurationListenerList(*other.mpList));
53 m_nBroadcastBlocked = other.m_nBroadcastBlocked;
54 m_nBlockedHint = other.m_nBlockedHint;
56 return *this;
59 void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListener )
61 if ( !mpList )
62 mpList.reset(new IMPL_ConfigurationListenerList);
63 mpList->push_back( pListener );
66 void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener const * pListener )
68 if ( mpList ) {
69 auto it = std::find(mpList->begin(), mpList->end(), pListener);
70 if ( it != mpList->end() )
71 mpList->erase( it );
75 void ConfigurationBroadcaster::NotifyListeners( ConfigurationHints nHint )
77 if ( m_nBroadcastBlocked )
78 m_nBlockedHint |= nHint;
79 else
81 nHint |= m_nBlockedHint;
82 m_nBlockedHint = ConfigurationHints::NONE;
83 if ( mpList ) {
84 for ( size_t n = 0; n < mpList->size(); n++ )
85 (*mpList)[ n ]->ConfigurationChanged( this, nHint );
90 void ConfigurationBroadcaster::BlockBroadcasts( bool bBlock )
92 if ( bBlock )
93 ++m_nBroadcastBlocked;
94 else if ( m_nBroadcastBlocked )
96 if ( --m_nBroadcastBlocked == 0 )
97 NotifyListeners( ConfigurationHints::NONE );
101 Options::Options()
105 Options::~Options()
109 void Options::ConfigurationChanged( ConfigurationBroadcaster*, ConfigurationHints nHint )
111 NotifyListeners( nHint );
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */