LCOV - code coverage report
Current view: top level - sfx2/source/inc - statcach.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 28 92.9 %
Date: 2015-06-13 12:38:46 Functions: 11 14 78.6 %
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             : #ifndef INCLUDED_SFX2_SOURCE_INC_STATCACH_HXX
      20             : #define INCLUDED_SFX2_SOURCE_INC_STATCACH_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/implbase1.hxx>
      32             : 
      33             : #include <sfx2/bindings.hxx>
      34             : 
      35             : #include "slotserv.hxx"
      36             : 
      37             : class SfxControllerItem;
      38             : class SfxDispatcher;
      39           0 : class BindDispatch_Impl :   public ::cppu::WeakImplHelper1< css::frame::XStatusListener >
      40             : {
      41             : friend class SfxStateCache;
      42             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >          xDisp;
      43             :     ::com::sun::star::util::URL                     aURL;
      44             :     ::com::sun::star::frame::FeatureStateEvent      aStatus;
      45             :     SfxStateCache*          pCache;
      46             :     const SfxSlot*          pSlot;
      47             : 
      48             : public:
      49             :                             BindDispatch_Impl(
      50             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > & rDisp,
      51             :                                 const ::com::sun::star::util::URL& rURL,
      52             :                                 SfxStateCache* pStateCache, const SfxSlot* pSlot );
      53             : 
      54             :     virtual void SAL_CALL           statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      55             :     virtual void SAL_CALL           disposing( const ::com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      56             : 
      57             :     void                    Release();
      58           0 :     const ::com::sun::star::frame::FeatureStateEvent& GetStatus() const { return aStatus;}
      59             :     void                    Dispatch( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& aProps, bool bForceSynchron = false );
      60             : };
      61             : 
      62             : class SfxStateCache
      63             : {
      64             : friend class BindDispatch_Impl;
      65             :     BindDispatch_Impl*      pDispatch;
      66             :     sal_uInt16              nId;           // Slot-Id
      67             :     SfxControllerItem*      pInternalController;
      68             :     com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xMyDispatch;
      69             :     SfxControllerItem*      pController;    // Pointer to first bound Controller (interlinked with each other)
      70             :     SfxSlotServer           aSlotServ;      // SlotServer, SlotPtr = 0 -> not on Stack
      71             :     SfxPoolItem*            pLastItem;      // Last sent Item, never -1
      72             :     SfxItemState            eLastState;     // Last sent State
      73             :     bool                bCtrlDirty:1;   // Update Controller?
      74             :     bool                bSlotDirty:1;   // Present Funktion, must be updated
      75             :     bool                bItemVisible:1; // item visibility
      76             :     bool                bItemDirty;     // Validity of pLastItem
      77             : 
      78             : private:
      79             :                             SfxStateCache( const SfxStateCache& rOrig ) SAL_DELETED_FUNCTION;
      80             :     void                    SetState_Impl( SfxItemState, const SfxPoolItem*, bool bMaybeDirty=false );
      81             : 
      82             : public:
      83             :                             SfxStateCache( sal_uInt16 nFuncId );
      84             :                             ~SfxStateCache();
      85             : 
      86             :     sal_uInt16                  GetId() const;
      87             : 
      88             :     const SfxSlotServer*    GetSlotServer( SfxDispatcher &rDispat, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & xProv );
      89        1364 :     const SfxSlotServer*    GetSlotServer( SfxDispatcher &rDispat )
      90        1364 :                             { return GetSlotServer( rDispat, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > () ); }
      91             :     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >          GetDispatch() const;
      92             :     void                    Dispatch( const SfxItemSet* pSet, bool bForceSynchron = false );
      93      273285 :     bool                    IsControllerDirty() const
      94      273285 :                             { return bCtrlDirty; }
      95             :     SfxPoolItem*            GetItem() const { return pLastItem; }
      96             :     void                    ClearCache();
      97             : 
      98             :     void                    SetState( SfxItemState, const SfxPoolItem*, bool bMaybeDirty=false );
      99             :     void                    SetCachedState(bool bAlways = false);
     100             :     void                    Invalidate( bool bWithSlot );
     101             :     void                    SetVisibleState( bool bShow=true );
     102             : 
     103             :     SfxControllerItem*      ChangeItemLink( SfxControllerItem* pNewBinding );
     104             :     SfxControllerItem*      GetItemLink() const;
     105       80218 :     void                    SetInternalController( SfxControllerItem* pCtrl )
     106       80218 :                             { DBG_ASSERT( !pInternalController, "Only one internal controller allowed!" ); pInternalController = pCtrl; }
     107       80183 :     void                    ReleaseInternalController() { pInternalController = 0; }
     108      528026 :     SfxControllerItem*      GetInternalController() const { return pInternalController; }
     109             :     com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >
     110      151534 :                             GetInternalDispatch() const
     111      151534 :                             { return xMyDispatch; }
     112       80218 :     void                    SetInternalDispatch( const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >& rDisp )
     113       80218 :                             { xMyDispatch = rDisp; }
     114             : };
     115             : 
     116             : 
     117             : 
     118             : // clears Cached-Item
     119             : 
     120           9 : inline void SfxStateCache::ClearCache()
     121             : {
     122           9 :     bItemDirty = true;
     123           9 : }
     124             : 
     125             : 
     126             : 
     127             : // registeres a item representing this function
     128             : 
     129      182514 : inline SfxControllerItem* SfxStateCache::ChangeItemLink( SfxControllerItem* pNewBinding )
     130             : {
     131      182514 :     SfxControllerItem* pOldBinding = pController;
     132      182514 :     pController = pNewBinding;
     133      182514 :     if ( pNewBinding )
     134             :     {
     135      119703 :         bCtrlDirty = true;
     136      119703 :         bItemDirty = true;
     137             :     }
     138      182514 :     return pOldBinding;
     139             : }
     140             : 
     141             : 
     142             : // returns the func binding which becomes called on spreading states
     143             : 
     144      424949 : inline SfxControllerItem* SfxStateCache::GetItemLink() const
     145             : {
     146      424949 :     return pController;
     147             : }
     148             : 
     149             : 
     150     8418302 : inline sal_uInt16 SfxStateCache::GetId() const
     151             : {
     152     8418302 :     return nId;
     153             : }
     154             : 
     155             : #endif
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11