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

Generated by: LCOV version 1.10