xref: /AOO41X/main/svl/inc/svl/brdcst.hxx (revision 39a19a47feaddbaa21988da8c7bf801707fd3d48)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFXBRDCST_HXX
24 #define _SFXBRDCST_HXX
25 
26 #include "svl/svldllapi.h"
27 #include <tools/rtti.hxx>
28 #include <svl/svarray.hxx>
29 
30 class SfxListener;
31 class SfxHint;
32 
33 #ifndef _SFX_BRDCST_CXX
34 typedef SvPtrarr SfxListenerArr_Impl;
35 #endif
36 
37 //-------------------------------------------------------------------------
38 
39 class SVL_DLLPUBLIC SfxBroadcaster
40 {
41 friend class SfxListener;
42 
43     SfxListenerArr_Impl     aListeners;
44 
45 private:
46     sal_Bool         AddListener( SfxListener& rListener );
47     void                    RemoveListener( SfxListener& rListener );
48     const SfxBroadcaster&   operator=(const SfxBroadcaster &); // verboten
49 
50 protected:
51     void                    Forward(SfxBroadcaster& rBC, const SfxHint& rHint);
52     virtual void            ListenersGone();
53 
54 public:
55                             TYPEINFO();
56 
57                             SfxBroadcaster();
58                             SfxBroadcaster( const SfxBroadcaster &rBC );
59     virtual                 ~SfxBroadcaster();
60 
61     void                    Broadcast( const SfxHint &rHint );
62     void                    BroadcastDelayed( const SfxHint& rHint );
63     void                    BroadcastInIdle( const SfxHint& rHint );
64 
65     sal_Bool                    HasListeners() const;
GetListenerCount() const66     sal_uInt16                  GetListenerCount() const { return aListeners.Count(); }
GetListener(sal_uInt16 nNo) const67     SfxListener*            GetListener( sal_uInt16 nNo ) const
68                             { return (SfxListener*) aListeners[nNo]; }
69 };
70 
71 #endif
72