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 31 class SfxListener; 32 class SfxHint; 33 34 #ifndef _SFX_BRDCST_CXX 35 typedef SvPtrarr SfxListenerArr_Impl; 36 #endif 37 38 //------------------------------------------------------------------------- 39 40 class SVL_DLLPUBLIC SfxBroadcaster 41 { 42 friend class SfxListener; 43 44 SfxListenerArr_Impl aListeners; 45 46 private: 47 sal_Bool AddListener( SfxListener& rListener ); 48 void RemoveListener( SfxListener& rListener ); 49 const SfxBroadcaster& operator=(const SfxBroadcaster &); // verboten 50 51 protected: 52 void Forward(SfxBroadcaster& rBC, const SfxHint& rHint); 53 virtual void ListenersGone(); 54 55 public: 56 TYPEINFO(); 57 58 SfxBroadcaster(); 59 SfxBroadcaster( const SfxBroadcaster &rBC ); 60 virtual ~SfxBroadcaster(); 61 62 void Broadcast( const SfxHint &rHint ); 63 void BroadcastDelayed( const SfxHint& rHint ); 64 void BroadcastInIdle( const SfxHint& rHint ); 65 66 sal_Bool HasListeners() const; GetListenerCount() const67 sal_uInt16 GetListenerCount() const { return aListeners.Count(); } GetListener(sal_uInt16 nNo) const68 SfxListener* GetListener( sal_uInt16 nNo ) const 69 { return (SfxListener*) aListeners[nNo]; } 70 }; 71 72 #endif 73