LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/sfx2 - shell.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 10 100.0 %
Date: 2013-07-09 Functions: 5 5 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 _SFX_SHELL_HXX
      20             : #define _SFX_SHELL_HXX
      21             : 
      22             : #include "sal/config.h"
      23             : #include "sfx2/dllapi.h"
      24             : #include "sal/types.h"
      25             : #include <com/sun/star/embed/VerbDescriptor.hpp>
      26             : #include <tools/debug.hxx>
      27             : #include <tools/rtti.hxx>
      28             : #include <svl/brdcst.hxx>
      29             : 
      30             : #include <tools/string.hxx>
      31             : 
      32             : #include <sfx2/sfxuno.hxx>
      33             : 
      34             : class ResMgr;
      35             : class Window;
      36             : class ToolBox;
      37             : class SfxItemPool;
      38             : class SfxPoolItem;
      39             : class SfxRequest;
      40             : class SfxItemSet;
      41             : struct SfxFormalArgument;
      42             : class StatusBar;
      43             : class SfxInterface;
      44             : class SfxViewShell;
      45             : class SfxObjectShell;
      46             : class SfxSlotPool;
      47             : class SvGlobalName;
      48             : 
      49             : class SfxShellObject;
      50             : class SfxShell;
      51             : struct SfxShell_Impl;
      52             : class SfxShellObject;
      53             : class SfxDispatcher;
      54             : class SfxViewFrame;
      55             : class SfxSlot;
      56             : class SfxRepeatTarget;
      57             : class SbxVariable;
      58             : class SbxBase;
      59             : class SfxBindings;
      60             : 
      61             : namespace svl
      62             : {
      63             :     class IUndoManager;
      64             : }
      65             : 
      66             : //====================================================================
      67             : 
      68             : enum SfxInterfaceId
      69             : 
      70             : /*  [Description]
      71             : 
      72             :     Id for <SfxInterface>s, gives a quasi-static access to the interface
      73             :     through an array to <SfxApplication>.
      74             : */
      75             : 
      76             : {
      77             :     SFX_INTERFACE_NONE,
      78             :     SFX_INTERFACE_SFXAPP,
      79             :     SFX_INTERFACE_SFXDOCSH,
      80             :     SFX_INTERFACE_SFXIPFRM,
      81             :     SFX_INTERFACE_SFXVIEWSH,
      82             :     SFX_INTERFACE_SFXVIEWFRM,
      83             :     SFX_INTERFACE_SFXPLUGINFRM,
      84             :     SFX_INTERFACE_SFXPLUGINOBJ,
      85             :     SFX_INTERFACE_SFXPLUGINVIEWSH,
      86             :     SFX_INTERFACE_SFXFRAMESETOBJ,
      87             :     SFX_INTERFACE_SFXFRAMESETVIEWSH,
      88             :     SFX_INTERFACE_SFXINTERNALFRM,
      89             :     SFX_INTERFACE_SFXCOMPONENTDOCSH,
      90             :     SFX_INTERFACE_SFXGENERICOBJ,
      91             :     SFX_INTERFACE_SFXGENERICVIEWSH,
      92             :     SFX_INTERFACE_SFXEXPLOBJ,
      93             :     SFX_INTERFACE_SFXEXPLVIEWSH,
      94             :     SFX_INTERFACE_SFXPLUGINVIEWSHDYNAMIC,
      95             :     SFX_INTERFACE_SFXEXTERNALVIEWFRM,
      96             :     SFX_INTERFACE_SFXMODULE,
      97             :     SFX_INTERFACE_SFXFRAMESETVIEW,
      98             :     SFX_INTERFACE_SFXFRAMESETSOURCEVIEW,
      99             :     SFX_INTERFACE_SFXHELP_DOCSH,
     100             :     SFX_INTERFACE_SFXHELP_VIEWSH,
     101             :     SFX_INTERFACE_SFXTASK,
     102             :     SFX_INTERFACE_OFA_START         =  100,
     103             :     SFX_INTERFACE_OFA_END           =  100,
     104             :     SFX_INTERFACE_SC_START          =  150,
     105             :     SFX_INTERFACE_SC_END            =  199,
     106             :     SFX_INTERFACE_SD_START          =  200,
     107             :     SFX_INTERFACE_SD_END            =  249,
     108             :     SFX_INTERFACE_SW_START          =  250,
     109             :     SFX_INTERFACE_SW_END            =  299,
     110             :     SFX_INTERFACE_SIM_START         =  300,
     111             :     SFX_INTERFACE_SIM_END           =  319,
     112             :     SFX_INTERFACE_SCH_START         =  320,
     113             :     SFX_INTERFACE_SCH_END           =  339,
     114             :     SFX_INTERFACE_SMA_START         =  340,
     115             :     SFX_INTERFACE_SMA_END           =  359,
     116             :     SFX_INTERFACE_SBA_START         =  360,
     117             :     SFX_INTERFACE_SBA_END           =  399,
     118             :     SFX_INTERFACE_IDE_START         =  400,
     119             :     SFX_INTERFACE_IDE_END           =  409,
     120             :     //-if one is still needed
     121             :     SFX_INTERFACE_APP               =  SFX_INTERFACE_SW_START,
     122             :     SFX_INTERFACE_LIB               =  450
     123             : };
     124             : 
     125             : //TODO/CLEANUP: replace by UNO constant
     126             : #define SVVERB_SHOW -1
     127             : 
     128             : //====================================================================
     129             : 
     130             : typedef void (*SfxExecFunc)(SfxShell *, SfxRequest &rReq);
     131             : typedef void (*SfxStateFunc)(SfxShell *, SfxItemSet &rSet);
     132             : 
     133             : class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster
     134             : 
     135             : /*  [Description]
     136             : 
     137             :     The class SfxShell is the base class for all classes, which provide
     138             :     the functionality of the form <Slot>s.
     139             : 
     140             :     Each instance has a reference to an interface description, which is
     141             :     obtainable through <SfxShell::GetInterface()const>. This interface
     142             :     provides the connection to specific methods and contains some other
     143             :     descriptive data for controllers like menus and toolboxes, but also
     144             :     for the various APIs. The main part of the interface description is in
     145             :     the form of a <Type-Library>, which is generated from an IDL-file by
     146             :     the <SVIDL-Compiler>. For each SfxShell Subclass-File there is one
     147             :     such IDL-file to write.
     148             : */
     149             : 
     150             : {
     151             :     friend class SfxObjectItem;
     152             : 
     153             :     SfxShell_Impl*              pImp;
     154             :     SfxItemPool*                pPool;
     155             :     ::svl::IUndoManager*        pUndoMgr;
     156             : 
     157             : private:
     158             :                                 SfxShell( const SfxShell & ); // internal
     159             :     SfxShell&                                   operator = ( const SfxShell & ); // internal
     160             : 
     161             : protected:
     162             :                                 SfxShell();
     163             :                                 SfxShell( SfxViewShell *pViewSh );
     164             : 
     165             : #ifndef _SFXSH_HXX
     166             :     SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell* pView );
     167             :     SAL_DLLPRIVATE void Invalidate_Impl( SfxBindings& rBindings, sal_uInt16 nId );
     168             :     SAL_DLLPRIVATE SfxShellObject* GetShellObj_Impl() const;
     169             :     SAL_DLLPRIVATE void SetShellObj_Impl( SfxShellObject* pObj );
     170             : #endif
     171             : 
     172             : public:
     173             :                                 TYPEINFO();
     174             :     virtual                     ~SfxShell();
     175             : 
     176             :     virtual SfxInterface*       GetInterface() const;
     177        1364 :     static SfxInterface*        GetStaticInterface() { return 0; }
     178             : 
     179             :     void                        SetName( const String &rName );
     180             :     const String&               GetName() const;
     181             : 
     182             :     SfxViewShell*               GetViewShell() const;
     183             : 
     184         846 :     void                        CallExec( SfxExecFunc pFunc, SfxRequest &rReq )
     185         846 :                                 { (*pFunc)(this, rReq); }
     186       73873 :     void                        CallState( SfxStateFunc pFunc, SfxItemSet &rSet )
     187       73873 :                                 { (*pFunc)(this, rSet); }
     188             : 
     189             :     static void                 EmptyExecStub(SfxShell *pShell, SfxRequest &);
     190             :     static void                 EmptyStateStub(SfxShell *pShell, SfxItemSet &);
     191             : 
     192             :     const SfxPoolItem*          GetSlotState( sal_uInt16 nSlotId, const SfxInterface *pIF = 0, SfxItemSet *pStateSet = 0 );
     193             :     const SfxPoolItem*          ExecuteSlot( SfxRequest &rReq, const SfxInterface *pIF = 0 );
     194             :     const SfxPoolItem*          ExecuteSlot( SfxRequest &rReq, sal_Bool bAsync );
     195             :     sal_uIntPtr                       ExecuteSlot( sal_uInt16 nSlot, sal_uInt16 nMemberId, SbxVariable& rRet, SbxBase* pArgs = 0 );
     196             : 
     197             :     inline SfxItemPool&         GetPool() const;
     198             :     inline void                 SetPool( SfxItemPool *pNewPool ) ;
     199             : 
     200             :     virtual ::svl::IUndoManager*
     201             :                                 GetUndoManager();
     202             :     void                        SetUndoManager( ::svl::IUndoManager *pNewUndoMgr );
     203             : 
     204             :     SfxRepeatTarget*            GetRepeatTarget() const;
     205             :     void                        SetRepeatTarget( SfxRepeatTarget *pTarget );
     206             : 
     207             :     virtual void                Invalidate(sal_uInt16 nId = 0);
     208             : 
     209             :     sal_Bool                        IsActive() const;
     210             :     virtual void                Activate(sal_Bool bMDI);
     211             :     virtual void                Deactivate(sal_Bool bMDI);
     212             :     virtual void                ParentActivate();
     213             :     virtual void                ParentDeactivate();
     214             : 
     215             :     SfxDispatcher*              GetDispatcher() const;
     216             :     SfxViewFrame*               GetFrame() const;
     217             :     ResMgr*                     GetResMgr() const;
     218             :     virtual sal_Bool            HasUIFeature( sal_uInt32 nFeature );
     219             :     void                        UIFeatureChanged();
     220             : 
     221             :     // Items
     222             :     const SfxPoolItem*          GetItem( sal_uInt16 nSlotId ) const;
     223             :     void                        PutItem( const SfxPoolItem& rItem );
     224             : 
     225             :     // TODO/CLEANUP: still needed?!
     226             :     void SetVerbs(const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& aVerbs);
     227             :     const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& GetVerbs() const;
     228             :     void                        VerbExec (SfxRequest&);
     229             :     void                        VerbState (SfxItemSet&);
     230             :     SAL_DLLPRIVATE const SfxSlot* GetVerbSlot_Impl(sal_uInt16 nId) const;
     231             : 
     232             :     void                        SetHelpId(sal_uIntPtr nId);
     233             :     sal_uIntPtr                     GetHelpId() const;
     234             :     virtual SfxObjectShell*     GetObjectShell();
     235             :     void                        SetDisableFlags( sal_uIntPtr nFlags );
     236             :     sal_uIntPtr                     GetDisableFlags() const;
     237             : 
     238             :     virtual SfxItemSet*         CreateItemSet( sal_uInt16 nId );
     239             :     virtual void                ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
     240             : 
     241             :     /** Set the name of the sidebar context that is broadcast on calls
     242             :         to Activation().
     243             :     */
     244             :     void SetContextName (const ::rtl::OUString& rsContextName);
     245             : 
     246             :     /** Broadcast a sidebar context change.
     247             :         This method is typically called from Activate() or
     248             :         Deactivate().
     249             :         @param bIsActivated
     250             :             When <TRUE/> then broadcast the context name that was
     251             :             defined with an earlier call to SetContextName().
     252             :             When <FALSE/> then broadcast the 'default' context.
     253             :     */
     254             :     void BroadcastContextForActivation (const bool bIsActivated);
     255             : 
     256             : #ifndef _SFXSH_HXX
     257             :     SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot );
     258             :     SAL_DLLPRIVATE void DoActivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI);
     259             :     SAL_DLLPRIVATE void DoDeactivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI);
     260             : #endif
     261             : };
     262             : 
     263             : //--------------------------------------------------------------------
     264      154049 : SfxItemPool& SfxShell::GetPool() const
     265             : /*
     266             :     [Description]
     267             : 
     268             :     Each Subclass of SfxShell must reference a pool. This is partly set by
     269             :     SFx's own set of subclasses (eg <SfxViewShell>). In particular however
     270             :     this must be set directly from one derived SfxShell class and ny
     271             :     derivatives of SfxObjectShell.
     272             : 
     273             :     The SfxShell class itself does not have any SfxItemPool, therfore a
     274             :     null-pointer is returned.
     275             : */
     276             : 
     277             : {
     278             :     DBG_ASSERT( pPool, "no pool" );
     279      154049 :     return *pPool;
     280             : }
     281             : //-------------------------------------------------------------------
     282        8419 : inline void SfxShell::SetPool
     283             : (
     284             :     SfxItemPool*        pNewPool        // Pointer to the new Pool or null
     285             : )
     286             : 
     287             : /*  [Description]
     288             : 
     289             :     With this method, the subclasses register their special <SfxItemPool>
     290             :     in the SfxShell. Each SfxShell instance must have access to a SfxItemPool.
     291             :     Usually this is the SfxItemPool of the SfxDocumentShell. The SfxShell
     292             :     subclass does not take ownership of the orphaned pool. Before it is
     293             :     deleted it has to be deregisted with SetPool(0).
     294             : */
     295             : 
     296             : {
     297        8419 :     pPool = pNewPool;
     298        8419 : }
     299             : 
     300             : //=====================================================================
     301             : 
     302             : #define SFX_ARGUMENTMAP(ShellClass) static SfxFormalArgument a##ShellClass##Args_Impl[] =
     303             : 
     304             : #define SFX_SLOTMAP(ShellClass) static SfxFormalArgument a##ShellClass##Args_Impl[1]; \
     305             :                                 static SfxSlot a##ShellClass##Slots_Impl[] =
     306             : 
     307             : #define SFX_SLOTMAP_ARG(ShellClass) static SfxSlot a##ShellClass##Slots_Impl[] =
     308             : 
     309             : #define SFX_DECL_INTERFACE(nId)                                             \
     310             :             static SfxInterface*                pInterface;                 \
     311             :         private:                                                            \
     312             :             static void                         InitInterface_Impl();       \
     313             :         public:                                                             \
     314             :             static const SfxFormalArgument*     pSfxFormalArgs_Impl;        \
     315             :             static SfxInterface*                GetStaticInterface();       \
     316             :             static SfxInterfaceId               GetInterfaceId() {return SfxInterfaceId(nId);} \
     317             :             static void                         RegisterInterface(SfxModule* pMod=NULL); \
     318             :             virtual SfxInterface*       GetInterface() const;
     319             : 
     320             : #define SFX_IMPL_INTERFACE(Class,SuperClass,NameResId)                      \
     321             :                                                                             \
     322             :     SfxInterface* Class::pInterface = 0;                                    \
     323             :     const SfxFormalArgument* Class::pSfxFormalArgs_Impl = a##Class##Args_Impl;\
     324             :     SfxInterface* Class::GetStaticInterface()                      \
     325             :     {                                                                       \
     326             :         if ( !pInterface )                                                  \
     327             :         {                                                                   \
     328             :             pInterface =                                                    \
     329             :                 new SfxInterface(                                           \
     330             :             #Class, NameResId, GetInterfaceId(),                            \
     331             :             SuperClass::GetStaticInterface(),                               \
     332             :             a##Class##Slots_Impl[0],                                        \
     333             :             (sal_uInt16) (sizeof(a##Class##Slots_Impl) / sizeof(SfxSlot) ) );   \
     334             :             InitInterface_Impl();                                           \
     335             :         }                                                                   \
     336             :         return pInterface;                                                  \
     337             :     }                                                                       \
     338             :                                                                             \
     339             :     SfxInterface* Class::GetInterface() const                               \
     340             :     {                                                                       \
     341             :         return GetStaticInterface();                                        \
     342             :     }                                                                       \
     343             :                                                                             \
     344             :     void Class::RegisterInterface(SfxModule* pMod)                          \
     345             :     {                                                                       \
     346             :         GetStaticInterface()->Register(pMod);                               \
     347             :     }                                                                       \
     348             :                                                                             \
     349             :     void Class::InitInterface_Impl()
     350             : 
     351             : #define SFX_POSITION_MASK               0x000F
     352             : #define SFX_VISIBILITY_MASK             0xFFF0
     353             : #define SFX_VISIBILITY_UNVISIBLE        0x0000  // Never visible
     354             : #define SFX_VISIBILITY_VIEWER           0x0040
     355             : #define SFX_VISIBILITY_READONLYDOC      0x0400
     356             : #define SFX_VISIBILITY_DESKTOP          0x0800
     357             : #define SFX_VISIBILITY_STANDARD         0x1000
     358             : #define SFX_VISIBILITY_FULLSCREEN       0x2000
     359             : #define SFX_VISIBILITY_CLIENT           0x4000
     360             : #define SFX_VISIBILITY_SERVER           0x8000
     361             : #define SFX_VISIBILITY_NOCONTEXT        0xFFFF  // Always visable
     362             : 
     363             : #define SFX_OBJECTBAR_REGISTRATION(nPos,rResId) \
     364             :         GetStaticInterface()->RegisterObjectBar( nPos, rResId )
     365             : 
     366             : #define SFX_FEATURED_OBJECTBAR_REGISTRATION(nPos,rResId,nFeature) \
     367             :         GetStaticInterface()->RegisterObjectBar( nPos, rResId, nFeature )
     368             : 
     369             : #define SFX_CHILDWINDOW_REGISTRATION(nId) \
     370             :         GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_False )
     371             : 
     372             : #define SFX_FEATURED_CHILDWINDOW_REGISTRATION(nId,nFeature) \
     373             :         GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_False, nFeature )
     374             : 
     375             : #define SFX_CHILDWINDOW_CONTEXT_REGISTRATION(nId) \
     376             :         GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_True )
     377             : 
     378             : #define SFX_POPUPMENU_REGISTRATION(rResId) \
     379             :         GetStaticInterface()->RegisterPopupMenu( rResId )
     380             : 
     381             : #define SFX_STATUSBAR_REGISTRATION(rResId) \
     382             :         GetStaticInterface()->RegisterStatusBar( rResId )
     383             : 
     384             : #endif
     385             : 
     386             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10