LCOV - code coverage report
Current view: top level - sfx2/source/inc - statcach.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 25 96.0 %
Date: 2012-08-25 Functions: 10 12 83.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 8 25.0 %

           Branch data     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                 :            : #ifndef _SFXSTATCACH_HXX
      20                 :            : #define _SFXSTATCACH_HXX
      21                 :            : 
      22                 :            : #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
      23                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      24                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      25                 :            : #include <com/sun/star/frame/XStatusListener.hpp>
      26                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      27                 :            : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      28                 :            : #include <com/sun/star/frame/FeatureStateEvent.hpp>
      29                 :            : #include <com/sun/star/frame/DispatchDescriptor.hpp>
      30                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      31                 :            : #include <cppuhelper/weak.hxx>
      32                 :            : 
      33                 :            : #include <sfx2/bindings.hxx>
      34                 :            : 
      35                 :            : #include "slotserv.hxx"
      36                 :            : 
      37                 :            : #include <sfx2/sfxuno.hxx>
      38                 :            : 
      39                 :            : class SfxControllerItem;
      40                 :            : class SfxDispatcher;
      41 [ #  # ][ #  # ]:          0 : class BindDispatch_Impl :   public ::com::sun::star::frame::XStatusListener ,
                 [ #  # ]
      42                 :            :                             public ::com::sun::star::lang::XTypeProvider    ,
      43                 :            :                             public ::cppu::OWeakObject
      44                 :            : {
      45                 :            : friend class SfxStateCache;
      46                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >          xDisp;
      47                 :            :     ::com::sun::star::util::URL                     aURL;
      48                 :            :     ::com::sun::star::frame::FeatureStateEvent      aStatus;
      49                 :            :     SfxStateCache*          pCache;
      50                 :            :     const SfxSlot*          pSlot;
      51                 :            : 
      52                 :            : public:
      53                 :            :                             BindDispatch_Impl(
      54                 :            :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > & rDisp,
      55                 :            :                                 const ::com::sun::star::util::URL& rURL,
      56                 :            :                                 SfxStateCache* pStateCache, const SfxSlot* pSlot );
      57                 :            : 
      58                 :            :     SFX_DECL_XINTERFACE_XTYPEPROVIDER
      59                 :            : 
      60                 :            :     virtual void SAL_CALL           statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
      61                 :            :     virtual void SAL_CALL           disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
      62                 :            : 
      63                 :            :     void                    Release();
      64                 :            :     const ::com::sun::star::frame::FeatureStateEvent& GetStatus() const;
      65                 :            :     void                    Dispatch( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aProps, sal_Bool bForceSynchron = sal_False );
      66                 :            : };
      67                 :            : 
      68                 :            : class SfxStateCache
      69                 :            : {
      70                 :            : friend class BindDispatch_Impl;
      71                 :            :     BindDispatch_Impl*      pDispatch;
      72                 :            :     sal_uInt16              nId;           // Slot-Id
      73                 :            :     SfxControllerItem*      pInternalController;
      74                 :            :     com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xMyDispatch;
      75                 :            :     SfxControllerItem*      pController;    // Pointer to first bound Controller (interlinked with each other)
      76                 :            :     SfxSlotServer           aSlotServ;      // SlotServer, SlotPtr = 0 -> not on Stack
      77                 :            :     SfxPoolItem*            pLastItem;      // Last sent Item, never -1
      78                 :            :     SfxItemState            eLastState;     // Last sent State
      79                 :            :     sal_Bool                bCtrlDirty:1;   // Update Controller?
      80                 :            :     sal_Bool                bSlotDirty:1;   // Present Funktion, must be updated
      81                 :            :     sal_Bool                bItemVisible:1; // item visibility
      82                 :            :     sal_Bool                bItemDirty;     // Validity of pLastItem
      83                 :            : 
      84                 :            : private:
      85                 :            :                             SfxStateCache( const SfxStateCache& rOrig ); // inward
      86                 :            :     void                    SetState_Impl( SfxItemState, const SfxPoolItem*, sal_Bool bMaybeDirty=sal_False );
      87                 :            : 
      88                 :            : public:
      89                 :            :                             SfxStateCache( sal_uInt16 nFuncId );
      90                 :            :                             ~SfxStateCache();
      91                 :            : 
      92                 :            :     sal_uInt16                  GetId() const;
      93                 :            : 
      94                 :            :     const SfxSlotServer*    GetSlotServer( SfxDispatcher &rDispat, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & xProv );
      95                 :            :     const SfxSlotServer*    GetSlotServer( SfxDispatcher &rDispat )
      96                 :            :                             { return GetSlotServer( rDispat, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > () ); }
      97                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >          GetDispatch() const;
      98                 :            :     void                    Dispatch( const SfxItemSet* pSet, sal_Bool bForceSynchron = sal_False );
      99                 :     313842 :     sal_Bool                    IsControllerDirty() const
     100                 :     313842 :                             { return bCtrlDirty ? sal_True : sal_False; }
     101                 :            :     SfxPoolItem*            GetItem() const { return pLastItem; }
     102                 :            :     void                    ClearCache();
     103                 :            : 
     104                 :            :     void                    SetState( SfxItemState, const SfxPoolItem*, sal_Bool bMaybeDirty=sal_False );
     105                 :            :     void                    SetCachedState(sal_Bool bAlways = sal_False);
     106                 :            :     void                    DeleteFloatingWindows();
     107                 :            :     void                    Invalidate( sal_Bool bWithSlot );
     108                 :            :     void                    SetVisibleState( sal_Bool bShow=sal_True );
     109                 :            : 
     110                 :            :     SfxControllerItem*      ChangeItemLink( SfxControllerItem* pNewBinding );
     111                 :            :     SfxControllerItem*      GetItemLink() const;
     112                 :     102819 :     void                    SetInternalController( SfxControllerItem* pCtrl )
     113                 :     102819 :                             { DBG_ASSERT( !pInternalController, "Only one internal controller allowed!" ); pInternalController = pCtrl; }
     114                 :     101619 :     void                    ReleaseInternalController() { pInternalController = 0; }
     115                 :     546573 :     SfxControllerItem*      GetInternalController() const { return pInternalController; }
     116                 :            :     com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >
     117                 :     183805 :                             GetInternalDispatch() const
     118                 :     183805 :                             { return xMyDispatch; }
     119                 :     102819 :     void                    SetInternalDispatch( const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >& rDisp )
     120                 :     102819 :                             { xMyDispatch = rDisp; }
     121                 :            : };
     122                 :            : 
     123                 :            : //--------------------------------------------------------------------
     124                 :            : 
     125                 :            : // clears Cached-Item
     126                 :            : 
     127                 :       1223 : inline void SfxStateCache::ClearCache()
     128                 :            : {
     129                 :       1223 :     bItemDirty = sal_True;
     130                 :       1223 : }
     131                 :            : 
     132                 :            : //--------------------------------------------------------------------
     133                 :            : 
     134                 :            : // registeres a item representing this function
     135                 :            : 
     136                 :     101158 : inline SfxControllerItem* SfxStateCache::ChangeItemLink( SfxControllerItem* pNewBinding )
     137                 :            : {
     138                 :     101158 :     SfxControllerItem* pOldBinding = pController;
     139                 :     101158 :     pController = pNewBinding;
     140         [ +  + ]:     101158 :     if ( pNewBinding )
     141                 :            :     {
     142                 :      58122 :         bCtrlDirty = sal_True;
     143                 :      58122 :         bItemDirty = sal_True;
     144                 :            :     }
     145                 :     101158 :     return pOldBinding;
     146                 :            : }
     147                 :            : //--------------------------------------------------------------------
     148                 :            : 
     149                 :            : // returns the func binding which becomes called on spreading states
     150                 :            : 
     151                 :     359015 : inline SfxControllerItem* SfxStateCache::GetItemLink() const
     152                 :            : {
     153                 :     359015 :     return pController;
     154                 :            : }
     155                 :            : //--------------------------------------------------------------------
     156                 :            : 
     157                 :   10313222 : inline sal_uInt16 SfxStateCache::GetId() const
     158                 :            : {
     159                 :   10313222 :     return nId;
     160                 :            : }
     161                 :            : 
     162                 :            : #endif
     163                 :            : 
     164                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10