LibreOffice Module svl (master) 1
listener.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 <svl/listener.hxx>
21#include <svl/broadcast.hxx>
22
23SvtListener::~SvtListener() COVERITY_NOEXCEPT_FALSE
24{
25 // Unregister itself from all broadcasters it's listening to.
27}
28
29// registers at a specific SvtBroadcaster
30
32{
33 std::pair<BroadcastersType::const_iterator, bool> r =
34 maBroadcasters.insert(&rBroadcaster);
35 if (r.second)
36 {
37 // This is a new broadcaster.
38 rBroadcaster.Add(this);
39 }
40 return r.second;
41}
42
44{
46 if (it == maBroadcasters.end())
47 // Not listening to this broadcaster.
48 return;
50
51 rBroadcaster.Remove(this);
52}
53
54// called from the SvtBroadcaster destructor, used to avoid calling
55// back into the broadcaster again
57{
59 if (it != maBroadcasters.end())
61}
62
64{
66 {
67 SvtBroadcaster& rBC = *p;
68 rBC.Remove(this);
69 }
71}
72
73
75{
78 maBroadcasters.swap(aCopy);
80 {
81 p->Add(this);
82 }
83}
84
85void SvtListener::Notify( const SfxHint& /*rHint*/ ) {}
86
87void SvtListener::Query( QueryBase& /*rQuery*/ ) const {}
88
89/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Add(SvtListener *p)
Definition: broadcast.cxx:109
void Remove(SvtListener *p)
Definition: broadcast.cxx:140
void EndListeningAll()
Definition: listener.cxx:63
virtual void Notify(const SfxHint &rHint)
Definition: listener.cxx:85
void CopyAllBroadcasters(const SvtListener &r)
Overwrites existing broadcasters with the ones from the specified listener.
Definition: listener.cxx:74
virtual void Query(QueryBase &rQuery) const
Definition: listener.cxx:87
BroadcastersType maBroadcasters
Definition: listener.hxx:33
virtual ~SvtListener() COVERITY_NOEXCEPT_FALSE
Definition: listener.cxx:23
bool StartListening(SvtBroadcaster &rBroadcaster)
Definition: listener.cxx:31
void BroadcasterDying(SvtBroadcaster &rBroadcaster)
Definition: listener.cxx:56
void EndListening(SvtBroadcaster &rBroadcaster)
Definition: listener.cxx:43
void swap(sorted_vector &other)
std::vector< Value >::const_iterator const_iterator
const_iterator find(const Value &x) const
size_type erase(const Value &x)
const_iterator end() const
std::pair< const_iterator, bool > insert(Value &&x)
void * p