1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <svl/listener.hxx>
21 #include <svl/broadcast.hxx>
23 SvtListener::QueryBase::QueryBase( sal_uInt16 nId
) : mnId(nId
) {}
24 SvtListener::QueryBase::~QueryBase() {}
26 sal_uInt16
SvtListener::QueryBase::getId() const
31 SvtListener::SvtListener() {}
33 SvtListener::SvtListener( const SvtListener
& ) {}
35 SvtListener::~SvtListener() COVERITY_NOEXCEPT_FALSE
37 // Unregister itself from all broadcasters it's listening to.
41 // registers at a specific SvtBroadcaster
43 bool SvtListener::StartListening( SvtBroadcaster
& rBroadcaster
)
45 std::pair
<BroadcastersType::const_iterator
, bool> r
=
46 maBroadcasters
.insert(&rBroadcaster
);
49 // This is a new broadcaster.
50 rBroadcaster
.Add(this);
55 bool SvtListener::EndListening( SvtBroadcaster
& rBroadcaster
)
57 BroadcastersType::const_iterator it
= maBroadcasters
.find(&rBroadcaster
);
58 if (it
== maBroadcasters
.end())
59 // Not listening to this broadcaster.
62 rBroadcaster
.Remove(this);
63 maBroadcasters
.erase(it
);
67 // called from the SvtBroadcaster destructor, used to avoid calling
68 // back into the broadcaster again
69 void SvtListener::BroadcasterDying( SvtBroadcaster
& rBroadcaster
)
71 BroadcastersType::const_iterator it
= maBroadcasters
.find(&rBroadcaster
);
72 if (it
!= maBroadcasters
.end())
73 maBroadcasters
.erase(it
);
76 void SvtListener::EndListeningAll()
78 for (SvtBroadcaster
* p
: maBroadcasters
)
80 SvtBroadcaster
& rBC
= *p
;
83 maBroadcasters
.clear();
87 void SvtListener::CopyAllBroadcasters( const SvtListener
& r
)
90 BroadcastersType
aCopy(r
.maBroadcasters
);
91 maBroadcasters
.swap(aCopy
);
92 for (SvtBroadcaster
* p
: maBroadcasters
)
98 bool SvtListener::HasBroadcaster() const
100 return !maBroadcasters
.empty();
103 void SvtListener::Notify( const SfxHint
& /*rHint*/ ) {}
105 void SvtListener::Query( QueryBase
& /*rQuery*/ ) const {}
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */