1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef FORMS_SOURCE_RICHTEXT_FEATUREDISPATCHER_HXX
29 #define FORMS_SOURCE_RICHTEXT_FEATUREDISPATCHER_HXX
30 
31 /** === begin UNO includes === **/
32 #include <com/sun/star/frame/XDispatch.hpp>
33 #include <com/sun/star/lang/DisposedException.hpp>
34 /** === end UNO includes === **/
35 #include <cppuhelper/interfacecontainer.hxx>
36 #include <cppuhelper/implbase1.hxx>
37 #include <comphelper/broadcasthelper.hxx>
38 
39 class EditView;
40 //........................................................................
41 namespace frm
42 {
43 //........................................................................
44 
45 	//====================================================================
46 	//= ORichTextFeatureDispatcher
47 	//====================================================================
48     typedef ::cppu::WeakImplHelper1 <   ::com::sun::star::frame::XDispatch
49                                     >   ORichTextFeatureDispatcher_Base;
50 
51     class ORichTextFeatureDispatcher    :public ::comphelper::OBaseMutex
52                                         ,public ORichTextFeatureDispatcher_Base
53 	{
54     private:
55         ::com::sun::star::util::URL         m_aFeatureURL;
56         ::cppu::OInterfaceContainerHelper   m_aStatusListeners;
57         EditView*                           m_pEditView;
58         bool                                m_bDisposed;
59 
60     protected:
61               EditView*   getEditView()       { return m_pEditView; }
62         const EditView*   getEditView() const { return m_pEditView; }
63 
64     protected:
65         inline const ::com::sun::star::util::URL&       getFeatureURL() const { return m_aFeatureURL; }
66         inline       ::cppu::OInterfaceContainerHelper& getStatusListeners() { return m_aStatusListeners; }
67         inline       bool                               isDisposed() const { return m_bDisposed; }
68         inline       void                               checkDisposed() const { if ( isDisposed() ) throw ::com::sun::star::lang::DisposedException(); }
69 
70     protected:
71         ORichTextFeatureDispatcher( EditView& _rView, const ::com::sun::star::util::URL&  _rURL );
72         ~ORichTextFeatureDispatcher( );
73 
74     public:
75         /// clean up resources associated with this instance
76         void    dispose();
77 
78         // invalidate the feature, re-retrieve it's state, and broadcast changes, if necessary
79         void    invalidate();
80 
81     protected:
82         // overridables
83         virtual void    newStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener );
84         virtual void    disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify );
85         virtual void    invalidateFeatureState_Broadcast();
86 
87         // to be overridden, and filled with the info special do your derived class
88         virtual ::com::sun::star::frame::FeatureStateEvent
89                         buildStatusEvent() const;
90 
91         void    doNotify(
92                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener,
93                     const ::com::sun::star::frame::FeatureStateEvent& _rEvent
94                 ) const SAL_THROW(());
95 
96     protected:
97         // XDispatch
98         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);
99         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);
100 	};
101 
102 //........................................................................
103 } // namespace frm
104 //........................................................................
105 
106 #endif // FORMS_SOURCE_RICHTEXT_FEATUREDISPATCHER_HXX
107 
108