diff options
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/notify/SfxBroadcaster.cxx | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/svl/source/notify/SfxBroadcaster.cxx b/svl/source/notify/SfxBroadcaster.cxx index ae1be1475c91..c1c5bee51f34 100644 --- a/svl/source/notify/SfxBroadcaster.cxx +++ b/svl/source/notify/SfxBroadcaster.cxx @@ -131,16 +131,33 @@ void SfxBroadcaster::RemoveListener(SfxListener& rListener) m_RemovedPositions.push_back(positionOfRemovedElement); } -bool SfxBroadcaster::HasListeners() const { return (GetListenerCount() != 0); } +void SfxBroadcaster::ForAllListeners(std::function<bool(SfxListener*)> f) const +{ + for (size_t i = 0; i < m_Listeners.size(); ++i) + { + SfxListener* const pListener = m_Listeners[i]; + if (pListener) + f(pListener); + } +} -size_t SfxBroadcaster::GetListenerCount() const +std::vector<SfxListener*> SfxBroadcaster::GetListenersForUnitTest() const { - assert(m_Listeners.size() >= m_RemovedPositions.size()); - return m_Listeners.size() - m_RemovedPositions.size(); + std::vector<SfxListener*> rv; + for (size_t i = 0; i < m_Listeners.size(); ++i) + { + SfxListener* const pListener = m_Listeners[i]; + if (pListener) + rv.push_back(pListener); + } + return rv; } -size_t SfxBroadcaster::GetSizeOfVector() const { return m_Listeners.size(); } +bool SfxBroadcaster::HasListeners() const { return GetListenerCount() != 0; } -SfxListener* SfxBroadcaster::GetListener(size_t nNo) const { return m_Listeners[nNo]; } +size_t SfxBroadcaster::GetListenerCount() const +{ + return m_Listeners.size() - m_RemovedPositions.size(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |