bump product version to 6.4.3.1
[LibreOffice.git] / forms / source / inc / formnavigation.hxx
blob200ab9d019964f08a3ddf4c3e575bbe22b40ef14
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX
21 #define INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX
23 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
24 #include <com/sun/star/frame/XStatusListener.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <com/sun/star/util/XURLTransformer.hpp>
28 #include <cppuhelper/implbase2.hxx>
29 #include "featuredispatcher.hxx"
30 #include <vector>
31 #include <map>
32 #include <memory>
35 namespace frm
39 class UrlTransformer;
40 class ControlFeatureInterception;
43 //= OFormNavigationHelper
45 typedef ::cppu::ImplHelper2 < css::frame::XDispatchProviderInterception
46 , css::frame::XStatusListener
47 > OFormNavigationHelper_Base;
49 class OFormNavigationHelper
50 :public OFormNavigationHelper_Base
51 ,public IFeatureDispatcher
53 private:
54 struct FeatureInfo
56 css::util::URL aURL;
57 css::uno::Reference< css::frame::XDispatch > xDispatcher;
58 bool bCachedState;
59 css::uno::Any aCachedAdditionalState;
61 FeatureInfo() : bCachedState( false ) { }
63 typedef ::std::map< sal_Int16, FeatureInfo > FeatureMap;
65 private:
66 css::uno::Reference< css::uno::XComponentContext >
67 m_xORB;
68 ::std::unique_ptr< ControlFeatureInterception >
69 m_pFeatureInterception;
71 // all supported features
72 FeatureMap m_aSupportedFeatures;
73 // all features which we have an external dispatcher for
74 sal_Int32 m_nConnectedFeatures;
76 protected:
77 OFormNavigationHelper( const css::uno::Reference< css::uno::XComponentContext >& _rxORB );
78 virtual ~OFormNavigationHelper();
80 // XComponent
81 /// @throws css::uno::RuntimeException
82 void dispose( );
84 // XDispatchProviderInterception
85 virtual void SAL_CALL registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor ) override;
86 virtual void SAL_CALL releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor ) override;
88 // XStatusListener
89 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& State ) override;
91 // XEventListener
92 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
94 // IFeatureDispatcher
95 virtual void dispatch( sal_Int16 _nFeatureId ) const override;
96 virtual void dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamName, const css::uno::Any& _rParamValue ) const override;
97 virtual bool isEnabled( sal_Int16 _nFeatureId ) const override;
98 virtual bool getBooleanState( sal_Int16 _nFeatureId ) const override;
99 virtual OUString getStringState( sal_Int16 _nFeatureId ) const override;
100 virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const override;
102 // own overridables
103 /** is called when the interceptors have.
104 <p>The default implementations simply calls <member>updateDispatches</member>,
105 derived classes can prevent this in certain cases, or do additional handling.</p>
107 virtual void interceptorsChanged( );
109 /** called when the status of a feature changed
111 <p>The default implementation does nothing.</p>
113 <p>If the feature in question does support more state information that just the
114 enabled/disabled state, then this additional information is to be retrieved in
115 a separate call.</p>
117 @param _nFeatureId
118 the id of the feature
119 @param _bEnabled
120 determines if the features is enabled or disabled
121 @see getBooleanState
123 virtual void featureStateChanged( sal_Int16 _nFeatureId, bool _bEnabled );
125 /** notification for (potential) changes in the state of all features
126 <p>The base class implementation does nothing. Derived classes could force
127 their peer to update it's state, depending on the result of calls to
128 <member>IFeatureDispatcher::isEnabled</member>.</p>
130 virtual void allFeatureStatesChanged( );
132 /** retrieves the list of supported features
133 <p>To be overridden by derived classes</p>
134 @param _rFeatureIds
135 the array of features to support. Out parameter to fill by the derivee's implementation
136 @pure
138 virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) = 0;
140 protected:
141 /** update all our dispatches which are controlled by our dispatch interceptors
143 void updateDispatches();
145 /** connect to the dispatch interceptors
147 void connectDispatchers();
149 /** disconnect from the dispatch interceptors
151 void disconnectDispatchers();
153 /** queries the interceptor chain for a dispatcher for the given URL
155 css::uno::Reference< css::frame::XDispatch >
156 queryDispatch( const css::util::URL& _rURL );
158 /** invalidates the set of supported features
160 <p>This will invalidate all structures which are tied to the set of supported
161 features. All dispatches will be disconnected.<br/>
162 No automatic re-connection to potential external dispatchers is done, instead,
163 you have to call updateDispatches explicitly, if necessary.</p>
165 void invalidateSupportedFeaturesSet();
167 private:
168 /** initialize m_aSupportedFeatures, if necessary
170 void initializeSupportedFeatures();
173 /** helper class mapping between feature ids and feature URLs
175 class OFormNavigationMapper
177 private:
178 ::std::unique_ptr< UrlTransformer > m_pUrlTransformer;
180 public:
181 OFormNavigationMapper(
182 const css::uno::Reference< css::uno::XComponentContext >& _rxORB
184 ~OFormNavigationMapper( );
186 /** retrieves the ASCII representation of a feature URL belonging to an id
188 @complexity O(log n)
189 @return NULL if the given id is not a known feature id (which is a valid usage)
191 static const char* getFeatureURLAscii( sal_Int16 _nFeatureId );
193 /** retrieves the feature URL belonging to a feature id
195 @complexity O(log n), with n being the number of all potentially known URLs
196 @return
197 <TRUE/> if and only if the given id is a known feature id
198 (which is a valid usage)
200 bool getFeatureURL( sal_Int16 _nFeatureId, css::util::URL& /* [out] */ _rURL );
202 /** retrieves the feature id belonging to a feature URL
204 @complexity O(n), with n being the number of all potentially known URLs
205 @return
206 the id of the feature URL, or -1 if the URl is not known
207 (which is a valid usage)
209 static sal_Int16 getFeatureId( const OUString& _rCompleteURL );
211 private:
212 OFormNavigationMapper( const OFormNavigationMapper& ) = delete;
213 OFormNavigationMapper& operator=( const OFormNavigationMapper& ) = delete;
217 } // namespace frm
220 #endif // INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */