Update ooo320-m1
[ooovba.git] / forms / source / inc / formnavigation.hxx
blobd0abf0cf802f6c1e07998010e3e72e31371f474a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formnavigation.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef FORMS_FORM_NAVIGATION_HXX
32 #define FORMS_FORM_NAVIGATION_HXX
34 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
35 #include <com/sun/star/frame/XStatusListener.hpp>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/util/XURLTransformer.hpp>
38 #include <cppuhelper/implbase2.hxx>
39 #include "featuredispatcher.hxx"
40 #include <vector>
41 #include <map>
42 #include <memory>
45 //.........................................................................
46 namespace frm
48 //.........................................................................
50 class UrlTransformer;
51 class ControlFeatureInterception;
53 //==================================================================
54 //= OFormNavigationHelper
55 //==================================================================
56 typedef ::cppu::ImplHelper2 < ::com::sun::star::frame::XDispatchProviderInterception
57 , ::com::sun::star::frame::XStatusListener
58 > OFormNavigationHelper_Base;
60 class OFormNavigationHelper
61 :public OFormNavigationHelper_Base
62 ,public IFeatureDispatcher
64 private:
65 struct FeatureInfo
67 ::com::sun::star::util::URL aURL;
68 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatcher;
69 sal_Bool bCachedState;
70 ::com::sun::star::uno::Any aCachedAdditionalState;
72 FeatureInfo() : bCachedState( sal_False ) { }
74 typedef ::std::map< sal_Int32, FeatureInfo > FeatureMap;
76 private:
77 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
78 m_xORB;
79 ::std::auto_ptr< ControlFeatureInterception >
80 m_pFeatureInterception;
82 // all supported features
83 FeatureMap m_aSupportedFeatures;
84 // all features which we have an external dispatcher for
85 sal_Int32 m_nConnectedFeatures;
87 protected:
88 inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
89 getORB( ) const { return m_xORB; }
91 protected:
92 OFormNavigationHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
93 virtual ~OFormNavigationHelper();
95 // XComponent
96 void SAL_CALL dispose( ) throw( ::com::sun::star::uno::RuntimeException );
98 // XDispatchProviderInterception
99 virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
100 virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException);
102 // XStatusListener
103 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& State ) throw (::com::sun::star::uno::RuntimeException);
105 // XEventListener
106 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
108 // IFeatureDispatcher
109 virtual void dispatch( sal_Int32 _nFeatureId ) const;
110 virtual void dispatchWithArgument( sal_Int32 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const;
111 virtual bool isEnabled( sal_Int32 _nFeatureId ) const;
112 virtual bool getBooleanState( sal_Int32 _nFeatureId ) const;
113 virtual ::rtl::OUString getStringState( sal_Int32 _nFeatureId ) const;
114 virtual sal_Int32 getIntegerState( sal_Int32 _nFeatureId ) const;
116 // own overridables
117 /** is called when the interceptors have.
118 <p>The default implementations simply calls <member>updateDispatches</member>,
119 derived classes can prevent this in certain cases, or do additional handling.</p>
121 virtual void interceptorsChanged( );
123 /** called when the status of a feature changed
125 <p>The default implementation does nothing.</p>
127 <p>If the feature in question does support more state information that just the
128 enabled/disabled state, then this additional information is to be retrieved in
129 a separate call.</p>
131 @param _nFeatureId
132 the id of the feature
133 @param _bEnabled
134 determines if the features is enabled or disabled
135 @see getBooleanState
137 virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled );
139 /** notification for (potential) changes in the state of all features
140 <p>The base class implementation does nothing. Derived classes could force
141 their peer to update it's state, depending on the result of calls to
142 <member>IFeatureDispatcher::isEnabled</member>.</p>
144 virtual void allFeatureStatesChanged( );
146 /** retrieves the list of supported features
147 <p>To be overridden by derived classes</p>
148 @param _rFeatureIds
149 the array of features to support. Out parameter to fill by the derivee's implementation
150 @pure
152 virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ) = 0;
154 protected:
155 /** update all our dispatches which are controlled by our dispatch interceptors
157 void updateDispatches();
159 /** connect to the dispatch interceptors
161 void connectDispatchers();
163 /** disconnect from the dispatch interceptors
165 void disconnectDispatchers();
167 /** queries the interceptor chain for a dispatcher for the given URL
169 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
170 queryDispatch( const ::com::sun::star::util::URL& _rURL );
172 /** invalidates the set of supported features
174 <p>This will invalidate all structures which are tied to the set of supported
175 features. All dispatches will be disconnected.<br/>
176 No automatic re-connection to potential external dispatchers is done, instead,
177 you have to call updateDispatches explicitly, if necessary.</p>
179 void invalidateSupportedFeaturesSet();
181 private:
182 /** initialize m_aSupportedFeatures, if necessary
184 void initializeSupportedFeatures();
187 //==================================================================
188 //= OFormNavigationMapper
189 //==================================================================
190 /** helper class mapping between feature ids and feature URLs
192 class OFormNavigationMapper
194 private:
195 ::std::auto_ptr< UrlTransformer > m_pUrlTransformer;
197 public:
198 OFormNavigationMapper(
199 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
201 ~OFormNavigationMapper( );
203 /** retrieves the ASCII representation of a feature URL belonging to an id
205 @complexity O(log n)
206 @return NULL if the given id is not a known feature id (which is a valid usage)
208 const char* getFeatureURLAscii( sal_Int32 _nFeatureId );
210 /** retrieves the feature URL belonging to an feature id
212 @complexity O(log n), with n being the number of all potentially known URLs
213 @return
214 <TRUE/> if and only if the given id is a known feature id
215 (which is a valid usage)
217 bool getFeatureURL( sal_Int32 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL );
219 /** retrieves the feature id belonging to an feature URL
221 @complexity O(n), with n being the number of all potentially known URLs
222 @return
223 the id of the feature URL, or -1 if the URl is not known
224 (which is a valid usage)
226 sal_Int32 getFeatureId( const ::rtl::OUString& _rCompleteURL );
228 private:
229 OFormNavigationMapper( ); // never implemented
230 OFormNavigationMapper( const OFormNavigationMapper& ); // never implemented
231 OFormNavigationMapper& operator=( const OFormNavigationMapper& ); // never implemented
234 //.........................................................................
235 } // namespace frm
236 //.........................................................................
238 #endif // FORMS_FORM_NAVIGATION_HXX