LCOV - code coverage report
Current view: top level - forms/source/inc - formnavigation.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX
      21             : #define INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX
      22             : 
      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>
      33             : 
      34             : 
      35             : 
      36             : namespace frm
      37             : {
      38             : 
      39             : 
      40             :     class UrlTransformer;
      41             :     class ControlFeatureInterception;
      42             : 
      43             : 
      44             :     //= OFormNavigationHelper
      45             : 
      46             :     typedef ::cppu::ImplHelper2 <   ::com::sun::star::frame::XDispatchProviderInterception
      47             :                                 ,   ::com::sun::star::frame::XStatusListener
      48             :                                 >   OFormNavigationHelper_Base;
      49             : 
      50             :     class OFormNavigationHelper
      51             :                         :public OFormNavigationHelper_Base
      52             :                         ,public IFeatureDispatcher
      53             :     {
      54             :     private:
      55           0 :         struct FeatureInfo
      56             :         {
      57             :             ::com::sun::star::util::URL                                             aURL;
      58             :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >  xDispatcher;
      59             :             sal_Bool                                                                bCachedState;
      60             :             ::com::sun::star::uno::Any                                              aCachedAdditionalState;
      61             : 
      62           0 :             FeatureInfo() : bCachedState( sal_False ) { }
      63             :         };
      64             :         typedef ::std::map< sal_Int16, FeatureInfo >    FeatureMap;
      65             : 
      66             :     private:
      67             :         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
      68             :                             m_xORB;
      69             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
      70             :         ::std::auto_ptr< ControlFeatureInterception >
      71             :                             m_pFeatureInterception;
      72             :         SAL_WNODEPRECATED_DECLARATIONS_POP
      73             : 
      74             :         // all supported features
      75             :         FeatureMap          m_aSupportedFeatures;
      76             :         // all features which we have an external dispatcher for
      77             :         sal_Int32           m_nConnectedFeatures;
      78             : 
      79             :     protected:
      80             :         inline const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
      81             :             getORB( ) const { return m_xORB; }
      82             : 
      83             :     protected:
      84             :         OFormNavigationHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB );
      85             :         virtual ~OFormNavigationHelper();
      86             : 
      87             :         // XComponent
      88             :         void SAL_CALL dispose(  ) throw( ::com::sun::star::uno::RuntimeException );
      89             : 
      90             :         // XDispatchProviderInterception
      91             :         virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      92             :         virtual void SAL_CALL releaseDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      93             : 
      94             :         // XStatusListener
      95             :         virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& State ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      96             : 
      97             :         // XEventListener
      98             :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      99             : 
     100             :         // IFeatureDispatcher
     101             :         virtual void            dispatch( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
     102             :         virtual void            dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const SAL_OVERRIDE;
     103             :         virtual bool            isEnabled( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
     104             :         virtual bool            getBooleanState( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
     105             :         virtual OUString getStringState( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
     106             :         virtual sal_Int32       getIntegerState( sal_Int16 _nFeatureId ) const SAL_OVERRIDE;
     107             : 
     108             :         // own overridables
     109             :         /** is called when the interceptors have.
     110             :             <p>The default implementations simply calls <member>updateDispatches</member>,
     111             :             derived classes can prevent this in certain cases, or do additional handling.</p>
     112             :         */
     113             :         virtual void    interceptorsChanged( );
     114             : 
     115             :         /** called when the status of a feature changed
     116             : 
     117             :             <p>The default implementation does nothing.</p>
     118             : 
     119             :             <p>If the feature in question does support more state information that just the
     120             :             enabled/disabled state, then this additional information is to be retrieved in
     121             :             a separate call.</p>
     122             : 
     123             :             @param _nFeatureId
     124             :                 the id of the feature
     125             :             @param _bEnabled
     126             :                 determines if the features is enabled or disabled
     127             :             @see getBooleanState
     128             :         */
     129             :         virtual void    featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled );
     130             : 
     131             :         /** notification for (potential) changes in the state of all features
     132             :             <p>The base class implementation does nothing. Derived classes could force
     133             :             their peer to update it's state, depending on the result of calls to
     134             :             <member>IFeatureDispatcher::isEnabled</member>.</p>
     135             :         */
     136             :         virtual void    allFeatureStatesChanged( );
     137             : 
     138             :         /** retrieves the list of supported features
     139             :             <p>To be overridden by derived classes</p>
     140             :             @param _rFeatureIds
     141             :                 the array of features to support. Out parameter to fill by the derivee's implementation
     142             :             @pure
     143             :         */
     144             :         virtual void    getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) = 0;
     145             : 
     146             :     protected:
     147             :         /** update all our dispatches which are controlled by our dispatch interceptors
     148             :         */
     149             :         void    updateDispatches();
     150             : 
     151             :         /** connect to the dispatch interceptors
     152             :         */
     153             :         void    connectDispatchers();
     154             : 
     155             :         /** disconnect from the dispatch interceptors
     156             :         */
     157             :         void    disconnectDispatchers();
     158             : 
     159             :         /** queries the interceptor chain for a dispatcher for the given URL
     160             :         */
     161             :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
     162             :                 queryDispatch( const ::com::sun::star::util::URL& _rURL );
     163             : 
     164             :         /** invalidates the set of supported features
     165             : 
     166             :             <p>This will invalidate all structures which are tied to the set of supported
     167             :             features. All dispatches will be disconnected.<br/>
     168             :             No automatic re-connection to potential external dispatchers is done, instead,
     169             :             you have to call updateDispatches explicitly, if necessary.</p>
     170             :         */
     171             :         void    invalidateSupportedFeaturesSet();
     172             : 
     173             :     private:
     174             :         /** initialize m_aSupportedFeatures, if necessary
     175             :         */
     176             :         void    initializeSupportedFeatures();
     177             :     };
     178             : 
     179             : 
     180             :     //= OFormNavigationMapper
     181             : 
     182             :     /** helper class mapping between feature ids and feature URLs
     183             :     */
     184             :     class OFormNavigationMapper
     185             :     {
     186             :     private:
     187             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     188             :         ::std::auto_ptr< UrlTransformer >   m_pUrlTransformer;
     189             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     190             : 
     191             :     public:
     192             :         OFormNavigationMapper(
     193             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB
     194             :         );
     195             :         ~OFormNavigationMapper( );
     196             : 
     197             :         /** retrieves the ASCII representation of a feature URL belonging to an id
     198             : 
     199             :             @complexity O(log n)
     200             :             @return NULL if the given id is not a known feature id (which is a valid usage)
     201             :         */
     202             :         const char* getFeatureURLAscii( sal_Int16 _nFeatureId );
     203             : 
     204             :         /** retrieves the feature URL belonging to an feature id
     205             : 
     206             :             @complexity O(log n), with n being the number of all potentially known URLs
     207             :             @return
     208             :                 <TRUE/> if and only if the given id is a known feature id
     209             :                 (which is a valid usage)
     210             :         */
     211             :         bool        getFeatureURL( sal_Int16 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL );
     212             : 
     213             :         /** retrieves the feature id belonging to an feature URL
     214             : 
     215             :             @complexity O(n), with n being the number of all potentially known URLs
     216             :             @return
     217             :                 the id of the feature URL, or -1 if the URl is not known
     218             :                 (which is a valid usage)
     219             :         */
     220             :         sal_Int16   getFeatureId( const OUString& _rCompleteURL );
     221             : 
     222             :     private:
     223             :         OFormNavigationMapper( );                                           // never implemented
     224             :         OFormNavigationMapper( const OFormNavigationMapper& );              // never implemented
     225             :         OFormNavigationMapper& operator=( const OFormNavigationMapper& );   // never implemented
     226             :     };
     227             : 
     228             : 
     229             : }   // namespace frm
     230             : 
     231             : 
     232             : #endif // INCLUDED_FORMS_SOURCE_INC_FORMNAVIGATION_HXX
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10