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 24 #ifndef FORMS_SOURCE_RICHTEXT_FEATUREDISPATCHER_HXX 25 #define FORMS_SOURCE_RICHTEXT_FEATUREDISPATCHER_HXX 26 27 /** === begin UNO includes === **/ 28 #include <com/sun/star/frame/XDispatch.hpp> 29 #include <com/sun/star/lang/DisposedException.hpp> 30 /** === end UNO includes === **/ 31 #include <cppuhelper/interfacecontainer.hxx> 32 #include <cppuhelper/implbase1.hxx> 33 #include <comphelper/broadcasthelper.hxx> 34 35 class EditView; 36 //........................................................................ 37 namespace frm 38 { 39 //........................................................................ 40 41 //==================================================================== 42 //= ORichTextFeatureDispatcher 43 //==================================================================== 44 typedef ::cppu::WeakImplHelper1 < ::com::sun::star::frame::XDispatch 45 > ORichTextFeatureDispatcher_Base; 46 47 class ORichTextFeatureDispatcher :public ::comphelper::OBaseMutex 48 ,public ORichTextFeatureDispatcher_Base 49 { 50 private: 51 ::com::sun::star::util::URL m_aFeatureURL; 52 ::cppu::OInterfaceContainerHelper m_aStatusListeners; 53 EditView* m_pEditView; 54 bool m_bDisposed; 55 56 protected: getEditView()57 EditView* getEditView() { return m_pEditView; } getEditView() const58 const EditView* getEditView() const { return m_pEditView; } 59 60 protected: getFeatureURL() const61 inline const ::com::sun::star::util::URL& getFeatureURL() const { return m_aFeatureURL; } getStatusListeners()62 inline ::cppu::OInterfaceContainerHelper& getStatusListeners() { return m_aStatusListeners; } isDisposed() const63 inline bool isDisposed() const { return m_bDisposed; } checkDisposed() const64 inline void checkDisposed() const { if ( isDisposed() ) throw ::com::sun::star::lang::DisposedException(); } 65 66 protected: 67 ORichTextFeatureDispatcher( EditView& _rView, const ::com::sun::star::util::URL& _rURL ); 68 ~ORichTextFeatureDispatcher( ); 69 70 public: 71 /// clean up resources associated with this instance 72 void dispose(); 73 74 // invalidate the feature, re-retrieve it's state, and broadcast changes, if necessary 75 void invalidate(); 76 77 protected: 78 // overridables 79 virtual void newStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener ); 80 virtual void disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); 81 virtual void invalidateFeatureState_Broadcast(); 82 83 // to be overridden, and filled with the info special do your derived class 84 virtual ::com::sun::star::frame::FeatureStateEvent 85 buildStatusEvent() const; 86 87 void doNotify( 88 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, 89 const ::com::sun::star::frame::FeatureStateEvent& _rEvent 90 ) const SAL_THROW(()); 91 92 protected: 93 // XDispatch 94 virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); 95 virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); 96 }; 97 98 //........................................................................ 99 } // namespace frm 100 //........................................................................ 101 102 #endif // FORMS_SOURCE_RICHTEXT_FEATUREDISPATCHER_HXX 103 104