Line data Source code
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 : #ifndef _SFXBRDCST_HXX
20 : #define _SFXBRDCST_HXX
21 :
22 : #include "svl/svldllapi.h"
23 : #include <tools/rtti.hxx>
24 : #include <vector>
25 :
26 : class SfxListener;
27 : class SfxHint;
28 :
29 : //-------------------------------------------------------------------------
30 :
31 : class SVL_DLLPUBLIC SfxBroadcaster
32 : {
33 : friend class SfxListener;
34 : typedef std::vector<SfxListener*> SfxListenerArr_Impl;
35 :
36 : SfxListenerArr_Impl m_Listeners;
37 :
38 : private:
39 : void AddListener( SfxListener& rListener );
40 : void RemoveListener( SfxListener& rListener );
41 : const SfxBroadcaster& operator=(const SfxBroadcaster &); // verboten
42 :
43 : protected:
44 : void Forward(SfxBroadcaster& rBC, const SfxHint& rHint);
45 : virtual void ListenersGone();
46 :
47 : public:
48 : TYPEINFO();
49 :
50 : SfxBroadcaster();
51 : SfxBroadcaster( const SfxBroadcaster &rBC );
52 : virtual ~SfxBroadcaster();
53 :
54 : void Broadcast( const SfxHint &rHint );
55 : bool HasListeners() const;
56 2832 : size_t GetListenerCount() const
57 : {
58 2832 : return m_Listeners.size();
59 : }
60 41267 : SfxListener* GetListener( sal_uInt16 nNo ) const
61 : {
62 41267 : return m_Listeners[nNo];
63 : }
64 : };
65 :
66 : #endif
67 :
68 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|