LCOV - code coverage report
Current view: top level - forms/source/inc - formnavigation.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef FORMS_FORM_NAVIGATION_HXX
      30                 :            : #define FORMS_FORM_NAVIGATION_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      33                 :            : #include <com/sun/star/frame/XStatusListener.hpp>
      34                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      35                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      36                 :            : #include <cppuhelper/implbase2.hxx>
      37                 :            : #include "featuredispatcher.hxx"
      38                 :            : #include <vector>
      39                 :            : #include <map>
      40                 :            : #include <memory>
      41                 :            : 
      42                 :            : 
      43                 :            : //.........................................................................
      44                 :            : namespace frm
      45                 :            : {
      46                 :            : //.........................................................................
      47                 :            : 
      48                 :            :     class UrlTransformer;
      49                 :            :     class ControlFeatureInterception;
      50                 :            : 
      51                 :            :     //==================================================================
      52                 :            :     //= OFormNavigationHelper
      53                 :            :     //==================================================================
      54                 :            :     typedef ::cppu::ImplHelper2 <   ::com::sun::star::frame::XDispatchProviderInterception
      55                 :            :                                 ,   ::com::sun::star::frame::XStatusListener
      56                 :            :                                 >   OFormNavigationHelper_Base;
      57                 :            : 
      58                 :            :     class OFormNavigationHelper
      59                 :            :                         :public OFormNavigationHelper_Base
      60                 :            :                         ,public IFeatureDispatcher
      61                 :            :     {
      62                 :            :     private:
      63                 :        190 :         struct FeatureInfo
      64                 :            :         {
      65                 :            :             ::com::sun::star::util::URL                                             aURL;
      66                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >  xDispatcher;
      67                 :            :             sal_Bool                                                                bCachedState;
      68                 :            :             ::com::sun::star::uno::Any                                              aCachedAdditionalState;
      69                 :            : 
      70                 :         38 :             FeatureInfo() : bCachedState( sal_False ) { }
      71                 :            :         };
      72                 :            :         typedef ::std::map< sal_Int16, FeatureInfo >    FeatureMap;
      73                 :            : 
      74                 :            :     private:
      75                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
      76                 :            :                             m_xORB;
      77                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
      78                 :            :         ::std::auto_ptr< ControlFeatureInterception >
      79                 :            :                             m_pFeatureInterception;
      80                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
      81                 :            : 
      82                 :            :         // all supported features
      83                 :            :         FeatureMap          m_aSupportedFeatures;
      84                 :            :         // all features which we have an external dispatcher for
      85                 :            :         sal_Int32           m_nConnectedFeatures;
      86                 :            : 
      87                 :            :     protected:
      88                 :            :         inline const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
      89                 :            :             getORB( ) const { return m_xORB; }
      90                 :            : 
      91                 :            :     protected:
      92                 :            :         OFormNavigationHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
      93                 :            :         virtual ~OFormNavigationHelper();
      94                 :            : 
      95                 :            :         // XComponent
      96                 :            :         void SAL_CALL dispose(  ) throw( ::com::sun::star::uno::RuntimeException );
      97                 :            : 
      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);
     101                 :            : 
     102                 :            :         // XStatusListener
     103                 :            :         virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& State ) throw (::com::sun::star::uno::RuntimeException);
     104                 :            : 
     105                 :            :         // XEventListener
     106                 :            :         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
     107                 :            : 
     108                 :            :         // IFeatureDispatcher
     109                 :            :         virtual void            dispatch( sal_Int16 _nFeatureId ) const;
     110                 :            :         virtual void            dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const;
     111                 :            :         virtual bool            isEnabled( sal_Int16 _nFeatureId ) const;
     112                 :            :         virtual bool            getBooleanState( sal_Int16 _nFeatureId ) const;
     113                 :            :         virtual ::rtl::OUString getStringState( sal_Int16 _nFeatureId ) const;
     114                 :            :         virtual sal_Int32       getIntegerState( sal_Int16 _nFeatureId ) const;
     115                 :            : 
     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>
     120                 :            :         */
     121                 :            :         virtual void    interceptorsChanged( );
     122                 :            : 
     123                 :            :         /** called when the status of a feature changed
     124                 :            : 
     125                 :            :             <p>The default implementation does nothing.</p>
     126                 :            : 
     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>
     130                 :            : 
     131                 :            :             @param _nFeatureId
     132                 :            :                 the id of the feature
     133                 :            :             @param _bEnabled
     134                 :            :                 determines if the features is enabled or disabled
     135                 :            :             @see getBooleanState
     136                 :            :         */
     137                 :            :         virtual void    featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled );
     138                 :            : 
     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>
     143                 :            :         */
     144                 :            :         virtual void    allFeatureStatesChanged( );
     145                 :            : 
     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
     151                 :            :         */
     152                 :            :         virtual void    getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) = 0;
     153                 :            : 
     154                 :            :     protected:
     155                 :            :         /** update all our dispatches which are controlled by our dispatch interceptors
     156                 :            :         */
     157                 :            :         void    updateDispatches();
     158                 :            : 
     159                 :            :         /** connect to the dispatch interceptors
     160                 :            :         */
     161                 :            :         void    connectDispatchers();
     162                 :            : 
     163                 :            :         /** disconnect from the dispatch interceptors
     164                 :            :         */
     165                 :            :         void    disconnectDispatchers();
     166                 :            : 
     167                 :            :         /** queries the interceptor chain for a dispatcher for the given URL
     168                 :            :         */
     169                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
     170                 :            :                 queryDispatch( const ::com::sun::star::util::URL& _rURL );
     171                 :            : 
     172                 :            :         /** invalidates the set of supported features
     173                 :            : 
     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>
     178                 :            :         */
     179                 :            :         void    invalidateSupportedFeaturesSet();
     180                 :            : 
     181                 :            :     private:
     182                 :            :         /** initialize m_aSupportedFeatures, if necessary
     183                 :            :         */
     184                 :            :         void    initializeSupportedFeatures();
     185                 :            :     };
     186                 :            : 
     187                 :            :     //==================================================================
     188                 :            :     //= OFormNavigationMapper
     189                 :            :     //==================================================================
     190                 :            :     /** helper class mapping between feature ids and feature URLs
     191                 :            :     */
     192                 :            :     class OFormNavigationMapper
     193                 :            :     {
     194                 :            :     private:
     195                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     196                 :            :         ::std::auto_ptr< UrlTransformer >   m_pUrlTransformer;
     197                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
     198                 :            : 
     199                 :            :     public:
     200                 :            :         OFormNavigationMapper(
     201                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
     202                 :            :         );
     203                 :            :         ~OFormNavigationMapper( );
     204                 :            : 
     205                 :            :         /** retrieves the ASCII representation of a feature URL belonging to an id
     206                 :            : 
     207                 :            :             @complexity O(log n)
     208                 :            :             @return NULL if the given id is not a known feature id (which is a valid usage)
     209                 :            :         */
     210                 :            :         const char* getFeatureURLAscii( sal_Int16 _nFeatureId );
     211                 :            : 
     212                 :            :         /** retrieves the feature URL belonging to an feature id
     213                 :            : 
     214                 :            :             @complexity O(log n), with n being the number of all potentially known URLs
     215                 :            :             @return
     216                 :            :                 <TRUE/> if and only if the given id is a known feature id
     217                 :            :                 (which is a valid usage)
     218                 :            :         */
     219                 :            :         bool        getFeatureURL( sal_Int16 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL );
     220                 :            : 
     221                 :            :         /** retrieves the feature id belonging to an feature URL
     222                 :            : 
     223                 :            :             @complexity O(n), with n being the number of all potentially known URLs
     224                 :            :             @return
     225                 :            :                 the id of the feature URL, or -1 if the URl is not known
     226                 :            :                 (which is a valid usage)
     227                 :            :         */
     228                 :            :         sal_Int16   getFeatureId( const ::rtl::OUString& _rCompleteURL );
     229                 :            : 
     230                 :            :     private:
     231                 :            :         OFormNavigationMapper( );                                           // never implemented
     232                 :            :         OFormNavigationMapper( const OFormNavigationMapper& );              // never implemented
     233                 :            :         OFormNavigationMapper& operator=( const OFormNavigationMapper& );   // never implemented
     234                 :            :     };
     235                 :            : 
     236                 :            : //.........................................................................
     237                 :            : }   // namespace frm
     238                 :            : //.........................................................................
     239                 :            : 
     240                 :            : #endif // FORMS_FORM_NAVIGATION_HXX
     241                 :            : 
     242                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10