LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/sfx2 - dispatch.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 16 100.0 %
Date: 2013-07-09 Functions: 6 6 100.0 %
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 _SFXDISPATCH_HXX
      20             : #define _SFXDISPATCH_HXX
      21             : 
      22             : #include "sal/config.h"
      23             : #include "sfx2/dllapi.h"
      24             : #include "sal/types.h"
      25             : 
      26             : #include <stdarg.h>
      27             : 
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <map>
      31             : #include <vector>
      32             : 
      33             : class SfxSlotServer;
      34             : class SfxShell;
      35             : class SfxRequest;
      36             : class SfxHintPoster;
      37             : class SfxViewFrame;
      38             : class SfxBindings;
      39             : class SfxItemSet;
      40             : class SfxPopupMenuManager;
      41             : class SfxModule;
      42             : struct SfxDispatcher_Impl;
      43             : 
      44             : typedef std::vector<SfxShell*> SfxShellStack_Impl;
      45             : 
      46             : namespace com
      47             : {
      48             :     namespace sun
      49             :     {
      50             :         namespace star
      51             :         {
      52             :             namespace frame
      53             :             {
      54             :                 class XDispatch;
      55             :             }
      56             :         }
      57             :     }
      58             : }
      59             : 
      60             : //=========================================================================
      61             : 
      62             : #define SFX_SHELL_POP_UNTIL     4
      63             : #define SFX_SHELL_POP_DELETE    2
      64             : #define SFX_SHELL_PUSH          1
      65             : 
      66             : //=========================================================================
      67             : 
      68             : // Maps the Which() field to a pointer to a SfxPoolItem
      69        7292 : class SfxItemPtrMap : public std::map<sal_uInt16, SfxPoolItem*>
      70             : {
      71             : public:
      72        6936 :     ~SfxItemPtrMap()
      73        6936 :     {
      74       16133 :         for(iterator it = begin(); it != end(); ++it)
      75        9197 :             delete it->second;
      76        6936 :     }
      77             : };
      78             : 
      79             : class SFX2_DLLPUBLIC SfxDispatcher
      80             : {
      81             :     SfxDispatcher_Impl*             pImp;
      82             :     sal_Bool                            bFlushed;
      83             : 
      84             : private:
      85             :     // Search for temporary evaluated Todos
      86             :     SAL_DLLPRIVATE sal_Bool CheckVirtualStack( const SfxShell& rShell, sal_Bool bDeep );
      87             : 
      88             : #ifndef _SFX_HXX
      89             : 
      90             : friend class SfxApplication;
      91             : friend class SfxViewFrame;
      92             : 
      93             :     DECL_DLLPRIVATE_LINK( EventHdl_Impl, void * );
      94             :     DECL_DLLPRIVATE_LINK( PostMsgHandler, SfxRequest * );
      95             : 
      96             :     SAL_DLLPRIVATE int Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, sal_Bool bRecord );
      97             :     SAL_DLLPRIVATE void _Update_Impl( sal_Bool,sal_Bool,sal_Bool,SfxWorkWindow*);
      98             :     SAL_DLLPRIVATE void CollectTools_Impl(SfxWorkWindow*);
      99             : 
     100             : protected:
     101             : friend class SfxBindings;
     102             : friend class SfxStateCache;
     103             : friend class SfxPopupMenuManager;
     104             : friend class SfxHelp;
     105             :                         // For bindings: Finding the Message;
     106             :                         // level for re-access
     107             :     SAL_DLLPRIVATE sal_Bool _TryIntercept_Impl( sal_uInt16 nId, SfxSlotServer &rServer, sal_Bool bModal );
     108             :     sal_Bool                _FindServer( sal_uInt16 nId, SfxSlotServer &rServer, sal_Bool bModal );
     109             :     sal_Bool                _FillState( const SfxSlotServer &rServer,
     110             :                                     SfxItemSet &rState, const SfxSlot *pRealSlot );
     111             :     void                _Execute( SfxShell &rShell, const SfxSlot &rSlot,
     112             :                                   SfxRequest &rReq,
     113             :                                   SfxCallMode eCall = SFX_CALLMODE_STANDARD);
     114             : #endif
     115             : protected:
     116             :     void FlushImpl();
     117             : 
     118             : public:
     119             :                         SfxDispatcher( SfxDispatcher* pParent );
     120             :                         SfxDispatcher( SfxViewFrame *pFrame = 0 );
     121             : 
     122             :     SAL_DLLPRIVATE void Construct_Impl( SfxDispatcher* pParent );
     123             : 
     124             :     virtual             ~SfxDispatcher();
     125             : 
     126             :     const SfxPoolItem*  Execute( sal_uInt16 nSlot,
     127             :                                  SfxCallMode nCall = SFX_CALLMODE_SLOT,
     128             :                                  const SfxPoolItem **pArgs = 0,
     129             :                                  sal_uInt16 nModi = 0,
     130             :                                  const SfxPoolItem **pInternalArgs = 0);
     131             : 
     132             :     const SfxPoolItem*  Execute( sal_uInt16 nSlot,
     133             :                                  SfxCallMode nCall,
     134             :                                  SfxItemSet* pArgs,
     135             :                                  SfxItemSet* pInternalArgs,
     136             :                                  sal_uInt16 nModi = 0);
     137             : 
     138             :     const SfxPoolItem*  Execute( sal_uInt16 nSlot,
     139             :                                  SfxCallMode nCall,
     140             :                                  const SfxPoolItem *pArg1, ... );
     141             : 
     142             :     const SfxPoolItem*  Execute( sal_uInt16 nSlot,
     143             :                                  SfxCallMode nCall,
     144             :                                  const SfxItemSet &rArgs );
     145             : 
     146             :     const SfxPoolItem*  Execute( sal_uInt16 nSlot,
     147             :                                  SfxCallMode nCall,
     148             :                                  sal_uInt16 nModi,
     149             :                                  const SfxItemSet &rArgs );
     150             : 
     151             :     const SfxSlot*      GetSlot( const String& rCommand );
     152             : 
     153             :     sal_Bool                IsActive( const SfxShell& rShell );
     154             :     sal_Bool                IsOnTop( const SfxShell& rShell );
     155             :     sal_uInt16              GetShellLevel( const SfxShell &rShell );
     156             :     SfxBindings*        GetBindings() const;
     157             : 
     158             :     void                Push( SfxShell& rShell );
     159             :     void                Pop( SfxShell& rShell, sal_uInt16 nMode = 0 );
     160             : 
     161             :     SfxShell*           GetShell(sal_uInt16 nIdx) const;
     162             :     SfxViewFrame*       GetFrame() const;
     163             :     SfxModule*      GetModule() const;
     164             :     // caller has to clean up the Manager on his own
     165             :     static SfxPopupMenuManager* Popup( sal_uInt16 nConfigId,Window *pWin, const Point *pPos );
     166             : 
     167             :     void                ExecutePopup( const ResId &rId,
     168             :                               Window *pWin = 0, const Point *pPosPixel = 0 );
     169             :     static void         ExecutePopup( sal_uInt16 nConfigId = 0,
     170             :                               Window *pWin = 0, const Point *pPosPixel = 0 );
     171             : 
     172             :     sal_Bool            IsAppDispatcher() const;
     173             :     sal_Bool            IsFlushed() const;
     174             :     void                Flush();
     175             :     void                Lock( sal_Bool bLock );
     176             :     sal_Bool                IsLocked( sal_uInt16 nSID = 0 ) const;
     177             :     void                SetSlotFilter( sal_Bool bEnable = sal_False,
     178             :                                        sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = 0 );
     179             : 
     180             :     void                HideUI( sal_Bool bHide = sal_True );
     181             :     void                ShowObjectBar(sal_uInt16 nId, SfxShell *pShell=0) const;
     182             :     sal_uInt32          GetObjectBarId( sal_uInt16 nPos ) const;
     183             : 
     184             :     SfxItemState        QueryState( sal_uInt16 nSID, const SfxPoolItem* &rpState );
     185             :     SfxItemState        QueryState( sal_uInt16 nSID, ::com::sun::star::uno::Any& rAny );
     186             : 
     187             :     ::com::sun::star::frame::XDispatch*          GetDispatchInterface( const String& );
     188             :     void                SetDisableFlags( sal_uInt32 nFlags );
     189             :     sal_uInt32              GetDisableFlags() const;
     190             : 
     191             :     SAL_DLLPRIVATE void SetMenu_Impl();
     192             :     SAL_DLLPRIVATE void Update_Impl( sal_Bool bForce = sal_False ); // ObjectBars etc.
     193             :     SAL_DLLPRIVATE sal_Bool IsUpdated_Impl() const;
     194             :     SAL_DLLPRIVATE int GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot,
     195             :                                               sal_Bool bOwnShellsOnly, sal_Bool bModal, sal_Bool bRealSlot=sal_True );
     196             :     SAL_DLLPRIVATE void SetReadOnly_Impl( sal_Bool  bOn );
     197             :     SAL_DLLPRIVATE sal_Bool GetReadOnly_Impl() const;
     198             :     SAL_DLLPRIVATE sal_Bool IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
     199             :     SAL_DLLPRIVATE void SetQuietMode_Impl( sal_Bool bOn );
     200             :     SAL_DLLPRIVATE sal_Bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
     201             :     SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
     202             :     SAL_DLLPRIVATE void DoParentActivate_Impl();
     203             :     SAL_DLLPRIVATE void DoParentDeactivate_Impl();
     204             :     SAL_DLLPRIVATE void DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* pOld );
     205             :     SAL_DLLPRIVATE void DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew );
     206             :     SAL_DLLPRIVATE void InvalidateBindings_Impl(sal_Bool);
     207             :     SAL_DLLPRIVATE sal_uInt16 GetNextToolBox_Impl( sal_uInt16 nPos, sal_uInt16 nType, String *pStr );
     208             : };
     209             : 
     210             : //--------------------------------------------------------------------
     211             : 
     212        2616 : inline sal_Bool SfxDispatcher::IsFlushed() const
     213             : 
     214             : /*  [Description]
     215             : 
     216             :     This method checks if the stack of the SfxDispatchers is flushed, or if
     217             :     push- or pop- commands are pending.
     218             : */
     219             : 
     220             : {
     221        2616 :      return bFlushed;
     222             : }
     223             : 
     224             : //--------------------------------------------------------------------
     225             : 
     226      197864 : inline void SfxDispatcher::Flush()
     227             : 
     228             : /*  [Description]
     229             : 
     230             :     This method performs outstanding push- and pop- commands. For <SfxShell>s,
     231             :     which are new on the stack, the <SfxShell::Activate(sal_Bool)> is invoked with
     232             :     bMDI == sal_True, for SfxShells that are removed from the stack, the
     233             :     <SfxShell::Deactivate(sal_Bool)> is invoked with bMDI == sal_True
     234             : */
     235             : 
     236             : {
     237      197864 :     if ( !bFlushed ) FlushImpl();
     238      197864 : }
     239             : 
     240             : //--------------------------------------------------------------------
     241             : 
     242        8866 : inline void SfxDispatcher::Push( SfxShell& rShell )
     243             : 
     244             : /*  [Description]
     245             : 
     246             :     With this method, a <SfxShell> pushed on to the SfxDispatcher.
     247             :     The SfxShell is first marked for push and a timer is set up.
     248             :     First when the timer has couted down to zero the push
     249             :     ( <SfxDispatcher::Flush()> ) is actually performed and the
     250             :     <SfxBindings> is invalidated. While the timer is counting down
     251             :     the opposing push and pop commands on the same SfxShell are
     252             :     leveled out.
     253             : */
     254             : 
     255             : {
     256        8866 :     Pop( rShell, SFX_SHELL_PUSH );
     257        8866 : }
     258             : 
     259             : //--------------------------------------------------------------------
     260             : 
     261        1792 : inline sal_Bool SfxDispatcher::IsActive( const SfxShell& rShell )
     262             : 
     263             : /*  [Description]
     264             : 
     265             :     This method checks whether a particular <SfxShell> instance is
     266             :     on the SfxDispatcher.
     267             : 
     268             :     [Return value]
     269             : 
     270             :     sal_Bool                sal_True
     271             :                         The SfxShell instance is on the SfxDispatcher.
     272             : 
     273             :                         sal_False
     274             :                         The SfxShell instance is not on the SfxDispatcher.
     275             : */
     276             : 
     277             : {
     278        1792 :     return CheckVirtualStack( rShell, sal_True );
     279             : }
     280             : //--------------------------------------------------------------------
     281             : 
     282             : inline sal_Bool SfxDispatcher::IsOnTop( const SfxShell& rShell )
     283             : 
     284             : /*  [Description]
     285             : 
     286             :     This method checks whether a particular <SfxShell> instance is on
     287             :     top of the SfxDispatcher.
     288             : 
     289             :     [Return value]
     290             : 
     291             :     sal_Bool                sal_True
     292             :                         The SfxShell instance is on the top of
     293             :                         the SfxDispatcher.
     294             : 
     295             :                         sal_False
     296             :                         The SfxShell instance is not on the top of
     297             :                         the SfxDispatcher.
     298             : */
     299             : 
     300             : {
     301             :     return CheckVirtualStack( rShell, sal_False );
     302             : }
     303             : 
     304             : //--------------------------------------------------------------------
     305             : 
     306             : #endif
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10