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

Generated by: LCOV version 1.10