LCOV - code coverage report
Current view: top level - include/sfx2 - bindings.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 15 80.0 %
Date: 2015-06-13 12:38:46 Functions: 6 7 85.7 %
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_BINDINGS_HXX
      20             : #define INCLUDED_SFX2_BINDINGS_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : #include <sfx2/dllapi.h>
      24             : #include <sal/types.h>
      25             : #include <rtl/strbuf.hxx>
      26             : #include <tools/link.hxx>
      27             : #include <com/sun/star/frame/XFrame.hpp>
      28             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      29             : #include <com/sun/star/uno/Reference.h>
      30             : #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
      31             : 
      32             : //  some other includes
      33             : 
      34             : #include <sfx2/viewfrm.hxx>
      35             : 
      36             : //  forwards, typedefs, declarations
      37             : 
      38             : class SystemWindow;
      39             : class SfxSlot;
      40             : class SfxSlotServer;
      41             : class SfxControllerItem;
      42             : class SfxStateCache;
      43             : class SfxItemSet;
      44             : class SfxDispatcher;
      45             : class SfxBindings;
      46             : class SfxBindings_Impl;
      47             : class Timer;
      48             : class SfxWorkWindow;
      49             : class SfxUnoControllerItem;
      50             : struct SfxFoundCache_Impl;
      51             : class SfxFoundCacheArr_Impl;
      52             : class SfxUnoControllerArr_Impl;
      53             : 
      54             : enum class SfxCallMode : sal_uInt16
      55             : {
      56             :     SLOT      = 0x00,    // sync/async from Slot
      57             :     SYNCHRON  = 0x01,    // synchronously in the same Stackframe
      58             :     ASYNCHRON = 0x02,    // asynchronously via AppEvent
      59             :     RECORD    = 0x04,    // take into account while recording
      60             :     API       = 0x08,    // API call (silent)
      61             :     MODAL     = 0x10     // despite ModalMode
      62             : };
      63             : // make combining these type-safe
      64        1095 : inline SfxCallMode operator| (SfxCallMode lhs, SfxCallMode rhs)
      65             : {
      66        1095 :     return static_cast<SfxCallMode>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
      67             : }
      68        3152 : inline SfxCallMode operator& (SfxCallMode lhs, SfxCallMode rhs)
      69             : {
      70        3152 :     return static_cast<SfxCallMode>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
      71             : }
      72         382 : inline SfxCallMode operator~ (SfxCallMode rhs)
      73             : {
      74         382 :     return static_cast<SfxCallMode>(0x1f & ~(static_cast<sal_uInt16>(rhs)));
      75             : }
      76           0 : inline SfxCallMode& operator|= (SfxCallMode& lhs, SfxCallMode rhs)
      77             : {
      78           0 :     lhs = static_cast<SfxCallMode>(static_cast<sal_uInt16>(lhs) | static_cast<sal_uInt16>(rhs));
      79           0 :     return lhs;
      80             : }
      81         382 : inline SfxCallMode& operator&= (SfxCallMode& lhs, SfxCallMode rhs)
      82             : {
      83         382 :     lhs = static_cast<SfxCallMode>(static_cast<sal_uInt16>(lhs) & static_cast<sal_uInt16>(rhs));
      84         382 :     return lhs;
      85             : }
      86             : 
      87             : 
      88             : class SFX2_DLLPUBLIC SfxBindings: public SfxBroadcaster
      89             : 
      90             : /*  [Description]
      91             : 
      92             :     In each SFx application one instance of the SfxBindings-Class will
      93             :     exists from <SfxApplication::Init()> until <SfxApplication::Exit()>.
      94             :     This instance is automatically created and destroyed by SfxApplication.
      95             :     However these instances will be handled by the Macro <SFX_BINDINGS>
      96             :     or the associated <SfxViewFrame>.
      97             : 
      98             :     The SfxBindings manages all of its Slot-Ids bound by the registered
      99             :     controllers and keeps a cache of the <Slot-Server> respectively.
     100             :     (it is what we call the combination of SfxShell instance and SfxSlot).
     101             :     In the SfxBindings it is stored, if and in this case which controllers
     102             :     that are dirty and which Slot-Server-Caches are dirty respectively.
     103             :     It summarizes status queries (calls to the status methods specified
     104             :     in the IDL) that are served by the same state methods, and handles
     105             :     the simulation of <Pseudo-Slots>.
     106             : */
     107             : 
     108             : {
     109             : friend class SfxApplication;
     110             : friend class SfxShell;
     111             : friend class SfxBindings_Impl;
     112             : 
     113             :     SfxBindings_Impl*pImp;           // Data of the Bindings instance
     114             :     SfxDispatcher*   pDispatcher;    // Dispatcher, to be used
     115             :     sal_uInt16       nRegLevel;      // Lock-Level while Reconfig
     116             : 
     117             : private:
     118             :     SAL_DLLPRIVATE const SfxPoolItem*  Execute_Impl( sal_uInt16 nSlot, const SfxPoolItem **pArgs, sal_uInt16 nModi,
     119             :                                     SfxCallMode nCall, const SfxPoolItem **pInternalArgs, bool bGlobalOnly=false);
     120             :     SAL_DLLPRIVATE void SetSubBindings_Impl( SfxBindings* );
     121             :     SAL_DLLPRIVATE void UpdateSlotServer_Impl(); // Update SlotServer
     122             :     SAL_DLLPRIVATE SfxItemSet* CreateSet_Impl( SfxStateCache* &pCache,
     123             :                                     const SfxSlot* &pRealSlot,
     124             :                                     const SfxSlotServer**,
     125             :                                     SfxFoundCacheArr_Impl& );
     126             :     SAL_DLLPRIVATE sal_uInt16 GetSlotPos( sal_uInt16 nId, sal_uInt16 nStartSearchAt = 0 );
     127             :     SAL_DLLPRIVATE void Update_Impl( SfxStateCache* pCache );
     128             :     SAL_DLLPRIVATE void UpdateControllers_Impl(
     129             :                             const SfxInterface* pIF,
     130             :                             const SfxFoundCache_Impl& rFound,
     131             :                             const SfxPoolItem *pItem,
     132             :                             SfxItemState eItemState );
     133             :     SAL_DLLPRIVATE SfxStateCache* GetStateCache( sal_uInt16 nId, sal_uInt16 *pPos);
     134             :     DECL_DLLPRIVATE_LINK_TYPED( NextJob, Timer *, void );
     135             :     SAL_DLLPRIVATE bool NextJob_Impl(Timer * pTimer);
     136             : 
     137             : public:
     138             :                      SfxBindings();
     139             :                      virtual ~SfxBindings();
     140             : 
     141             :     void             HidePopups( bool bHide = true );
     142             :     SAL_DLLPRIVATE void HidePopupCtrls_Impl( bool bHide = true );
     143             : 
     144             :     void             SetDispatcher(SfxDispatcher *pDisp);
     145             : 
     146             :     void             Update( sal_uInt16 nId ); // For example, from  Menu::Activate
     147             :     void             Update();
     148             :     SAL_DLLPRIVATE void StartUpdate_Impl(bool bComplete=false);
     149             :     void             Invalidate( sal_uInt16 nId );
     150             :     void             Invalidate( const sal_uInt16* pIds );
     151             :     void             InvalidateShell( const SfxShell &rSh, bool bDeep = false );
     152             :     void             InvalidateAll( bool bWithMsg );
     153             :     void             SetState( const SfxItemSet &rSet );
     154             :     void             SetState( const SfxPoolItem &rItem );
     155             :     void             Invalidate( sal_uInt16 nId, bool bWithItem, bool bWithMsg=false);
     156             :     void             Invalidate( sal_uInt16 nId, bool bWithMsg);
     157             :     bool             IsInUpdate() const;
     158             :     void             SetVisibleState( sal_uInt16 nId, bool bShow );
     159             : 
     160             :     bool             IsBound( sal_uInt16 nMsgId, sal_uInt16 nStartSearchAt = 0 );
     161             : 
     162             :     SfxStateCache*   GetStateCache( sal_uInt16 nId);
     163             :     SAL_DLLPRIVATE SfxStateCache* GetAnyStateCache_Impl( sal_uInt16 nId );
     164             :     /**
     165             :      * @param rpState the caller has to delete the pointer
     166             :      */
     167             :     SfxItemState     QueryState( sal_uInt16 nSID, SfxPoolItem* &rpState );
     168             : 
     169             :     const SfxPoolItem*  ExecuteSynchron( sal_uInt16 nSlot,
     170             :                                  const SfxPoolItem **pArgs = 0,
     171             :                                  sal_uInt16 nModi = 0,
     172             :                                  const SfxPoolItem **pInternalArgs = 0);
     173             :     bool             Execute( sal_uInt16 nSlot,
     174             :                                  const SfxPoolItem **pArgs = 0,
     175             :                                  sal_uInt16 nModi = 0,
     176             :                                  SfxCallMode nCall = SfxCallMode::SLOT,
     177             :                                  const SfxPoolItem **pInternalArgs = 0);
     178             : 
     179             :     SAL_DLLPRIVATE void SetDispatchProvider_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & rFrame );
     180             :     void             SetActiveFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame );
     181             :     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetActiveFrame() const;
     182             :                      // Reconfig
     183             :     bool             IsInRegistrations() const;
     184             :     sal_uInt16           EnterRegistrations(const char *pFile = 0, int nLine = 0);
     185             :     void             LeaveRegistrations( sal_uInt16 nLevel = USHRT_MAX, const char *pFile = 0, int nLine = 0 );
     186             :     void             Register( SfxControllerItem& rBinding );
     187             :     void             Release( SfxControllerItem& rBinding );
     188       58317 :     SfxDispatcher*   GetDispatcher() const
     189       58317 :                      { return pDispatcher; }
     190             :     com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > GetRecorder() const;
     191             :     com::sun::star::uno::Reference < com::sun::star::frame::XDispatch >
     192             :                     GetDispatch( const SfxSlot*, const com::sun::star::util::URL& aURL, bool bMasterCommand );
     193             :     SAL_DLLPRIVATE void ContextChanged_Impl();
     194             :     SAL_DLLPRIVATE void Execute_Impl( SfxRequest& rReq, const SfxSlot* pSlot, SfxShell* pShell );
     195             :     SAL_DLLPRIVATE void DeleteControllers_Impl();
     196      190037 :     SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl()  { return pDispatcher; }
     197             :     SAL_DLLPRIVATE void ClearCache_Impl( sal_uInt16 nSlotId );
     198             :     SAL_DLLPRIVATE bool IsInUpdate_Impl() const{ return IsInUpdate(); }
     199             :     SAL_DLLPRIVATE void RegisterInternal_Impl( SfxControllerItem& rBinding );
     200             :     SAL_DLLPRIVATE void Register_Impl( SfxControllerItem& rBinding, bool );
     201             :     SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl() const;
     202             :     SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* );
     203             :     SAL_DLLPRIVATE SfxBindings* GetSubBindings_Impl( bool bTop = false ) const;
     204             :     SAL_DLLPRIVATE void InvalidateUnoControllers_Impl();
     205             :     SAL_DLLPRIVATE void RegisterUnoController_Impl( SfxUnoControllerItem* );
     206             :     SAL_DLLPRIVATE void ReleaseUnoController_Impl( SfxUnoControllerItem* );
     207             :     SAL_DLLPRIVATE bool ExecuteCommand_Impl( const OUString& rCommand );
     208             :     SAL_DLLPRIVATE void SetRecorder_Impl( com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >& );
     209             :     SAL_DLLPRIVATE void InvalidateSlotsInMap_Impl();
     210             :     SAL_DLLPRIVATE void AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId );
     211             : };
     212             : 
     213             : #ifdef DBG_UTIL
     214             : #define ENTERREGISTRATIONS() EnterRegistrations(__FILE__, __LINE__)
     215             : #define LEAVEREGISTRATIONS() LeaveRegistrations(USHRT_MAX, __FILE__, __LINE__)
     216             : #define DENTERREGISTRATIONS() \
     217             :         EnterRegistrations( OStringBuffer(__FILE__).append('(').append(reinterpret_cast<sal_Int64>(this)).append(')').getStr(), __LINE__ )
     218             : #define DLEAVEREGISTRATIONS(  ) \
     219             :         LeaveRegistrations( USHRT_MAX, OStringBuffer(__FILE__).append('(').append(reinterpret_cast<sal_Int64>(this)).append(')').getStr(), __LINE__ )
     220             : #else
     221             : #define ENTERREGISTRATIONS() EnterRegistrations()
     222             : #define LEAVEREGISTRATIONS() LeaveRegistrations()
     223             : #define DENTERREGISTRATIONS() EnterRegistrations()
     224             : #define DLEAVEREGISTRATIONS() LeaveRegistrations()
     225             : #endif
     226             : 
     227             : 
     228             : 
     229             : inline bool SfxBindings::IsInRegistrations() const
     230             : 
     231             : /*  [Description]
     232             : 
     233             :     Determines whether the <SfxContollerItems> SfxBindings instance is
     234             :     registered or unregistered, i.e. <SfxBindings::EnterRegistrations()>
     235             :     calls that have not been closed by <SfxBindings::LeaveRegistrations()>.
     236             : 
     237             :     [Return value]
     238             : 
     239             :     int                 sal_True
     240             :                         The SfxBindings instance is currently in
     241             :                         Registration-Mode. No status updates .
     242             : 
     243             :     int sal_False
     244             :                         The SfxBindings instance is the normal mode.
     245             :                         Status updates can be done.
     246             : */
     247             : 
     248             : {
     249             :     return 0 != nRegLevel;
     250             : }
     251             : 
     252             : 
     253             : 
     254             : #endif
     255             : 
     256             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11