LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/sfx2 - shell.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 6 100.0 %
Date: 2012-12-27 Functions: 3 3 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             :     // TODO/CLEANUP: still needed?!
     177             :     virtual SvGlobalName        GetGlobalName() const;
     178             : 
     179             :     virtual SfxInterface*       GetInterface() const;
     180         160 :     static SfxInterface*        GetStaticInterface() { return 0; }
     181             : 
     182             :     void                        SetName( const String &rName );
     183             :     const String&               GetName() const;
     184             : 
     185             :     SfxViewShell*               GetViewShell() const;
     186             : 
     187             :     void                        CallExec( SfxExecFunc pFunc, SfxRequest &rReq )
     188             :                                 { (*pFunc)(this, rReq); }
     189             :     void                        CallState( SfxStateFunc pFunc, SfxItemSet &rSet )
     190             :                                 { (*pFunc)(this, rSet); }
     191             : 
     192             :     static void                 EmptyExecStub(SfxShell *pShell, SfxRequest &);
     193             :     static void                 EmptyStateStub(SfxShell *pShell, SfxItemSet &);
     194             : 
     195             :     const SfxPoolItem*          GetSlotState( sal_uInt16 nSlotId, const SfxInterface *pIF = 0, SfxItemSet *pStateSet = 0 );
     196             :     const SfxPoolItem*          ExecuteSlot( SfxRequest &rReq, const SfxInterface *pIF = 0 );
     197             :     const SfxPoolItem*          ExecuteSlot( SfxRequest &rReq, sal_Bool bAsync );
     198             :     sal_uIntPtr                       ExecuteSlot( sal_uInt16 nSlot, sal_uInt16 nMemberId, SbxVariable& rRet, SbxBase* pArgs = 0 );
     199             : 
     200             :     inline SfxItemPool&         GetPool() const;
     201             :     inline void                 SetPool( SfxItemPool *pNewPool ) ;
     202             : 
     203             :     virtual ::svl::IUndoManager*
     204             :                                 GetUndoManager();
     205             :     void                        SetUndoManager( ::svl::IUndoManager *pNewUndoMgr );
     206             : 
     207             :     SfxRepeatTarget*            GetRepeatTarget() const;
     208             :     void                        SetRepeatTarget( SfxRepeatTarget *pTarget );
     209             : 
     210             :     virtual void                Invalidate(sal_uInt16 nId = 0);
     211             : 
     212             :     sal_Bool                        IsActive() const;
     213             :     virtual void                Activate(sal_Bool bMDI);
     214             :     virtual void                Deactivate(sal_Bool bMDI);
     215             :     virtual void                ParentActivate();
     216             :     virtual void                ParentDeactivate();
     217             : 
     218             :     SfxDispatcher*              GetDispatcher() const;
     219             :     SfxViewFrame*               GetFrame() const;
     220             :     ResMgr*                     GetResMgr() const;
     221             :     virtual sal_Bool            HasUIFeature( sal_uInt32 nFeature );
     222             :     void                        UIFeatureChanged();
     223             : 
     224             :     // Items
     225             :     const SfxPoolItem*          GetItem( sal_uInt16 nSlotId ) const;
     226             :     void                        PutItem( const SfxPoolItem& rItem );
     227             : 
     228             :     // TODO/CLEANUP: still needed?!
     229             :     void SetVerbs(const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& aVerbs);
     230             :     const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& GetVerbs() const;
     231             :     void                        VerbExec (SfxRequest&);
     232             :     void                        VerbState (SfxItemSet&);
     233             :     SAL_DLLPRIVATE const SfxSlot* GetVerbSlot_Impl(sal_uInt16 nId) const;
     234             : 
     235             :     void                        SetHelpId(sal_uIntPtr nId);
     236             :     sal_uIntPtr                     GetHelpId() const;
     237             :     virtual SfxObjectShell*     GetObjectShell();
     238             :     void                        SetDisableFlags( sal_uIntPtr nFlags );
     239             :     sal_uIntPtr                     GetDisableFlags() const;
     240             : 
     241             :     virtual SfxItemSet*         CreateItemSet( sal_uInt16 nId );
     242             :     virtual void                ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
     243             : 
     244             : #ifndef _SFXSH_HXX
     245             :     SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot );
     246             :     SAL_DLLPRIVATE void DoActivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI);
     247             :     SAL_DLLPRIVATE void DoDeactivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI);
     248             : #endif
     249             : };
     250             : 
     251             : //--------------------------------------------------------------------
     252        1544 : SfxItemPool& SfxShell::GetPool() const
     253             : /*
     254             :     [Description]
     255             : 
     256             :     Each Subclass of SfxShell must reference a pool. This is partly set by
     257             :     SFx's own set of subclasses (eg <SfxViewShell>). In particular however
     258             :     this must be set directly from one derived SfxShell class and ny
     259             :     derivatives of SfxObjectShell.
     260             : 
     261             :     The SfxShell class itself does not have any SfxItemPool, therfore a
     262             :     null-pointer is returned.
     263             : */
     264             : 
     265             : {
     266             :     DBG_ASSERT( pPool, "no pool" );
     267        1544 :     return *pPool;
     268             : }
     269             : //-------------------------------------------------------------------
     270        1683 : inline void SfxShell::SetPool
     271             : (
     272             :     SfxItemPool*        pNewPool        // Pointer to the new Pool or null
     273             : )
     274             : 
     275             : /*  [Description]
     276             : 
     277             :     With this method, the subclasses register their special <SfxItemPool>
     278             :     in the SfxShell. Each SfxShell instance must have access to a SfxItemPool.
     279             :     Usually this is the SfxItemPool of the SfxDocumentShell. The SfxShell
     280             :     subclass does not take ownership of the orphaned pool. Before it is
     281             :     deleted it has to be deregisted with SetPool(0).
     282             : */
     283             : 
     284             : {
     285        1683 :     pPool = pNewPool;
     286        1683 : }
     287             : 
     288             : //=====================================================================
     289             : 
     290             : #define SFX_ARGUMENTMAP(ShellClass) static SfxFormalArgument a##ShellClass##Args_Impl[] =
     291             : 
     292             : #define SFX_SLOTMAP(ShellClass) static SfxFormalArgument a##ShellClass##Args_Impl[1]; \
     293             :                                 static SfxSlot a##ShellClass##Slots_Impl[] =
     294             : 
     295             : #define SFX_SLOTMAP_ARG(ShellClass) static SfxSlot a##ShellClass##Slots_Impl[] =
     296             : 
     297             : #define SFX_DECL_INTERFACE(nId)                                             \
     298             :             static SfxInterface*                pInterface;                 \
     299             :         private:                                                            \
     300             :             static void                         InitInterface_Impl();       \
     301             :         public:                                                             \
     302             :             static const SfxFormalArgument*     pSfxFormalArgs_Impl;        \
     303             :             static SfxInterface*                GetStaticInterface();       \
     304             :             static SfxInterfaceId               GetInterfaceId() {return SfxInterfaceId(nId);} \
     305             :             static void                         RegisterInterface(SfxModule* pMod=NULL); \
     306             :             virtual SfxInterface*       GetInterface() const;
     307             : 
     308             : #define SFX_IMPL_INTERFACE(Class,SuperClass,NameResId)                      \
     309             :                                                                             \
     310             :     SfxInterface* Class::pInterface = 0;                                    \
     311             :     const SfxFormalArgument* Class::pSfxFormalArgs_Impl = a##Class##Args_Impl;\
     312             :     SfxInterface* Class::GetStaticInterface()                      \
     313             :     {                                                                       \
     314             :         if ( !pInterface )                                                  \
     315             :         {                                                                   \
     316             :             pInterface =                                                    \
     317             :                 new SfxInterface(                                           \
     318             :             #Class, NameResId, GetInterfaceId(),                            \
     319             :             SuperClass::GetStaticInterface(),                               \
     320             :             a##Class##Slots_Impl[0],                                        \
     321             :             (sal_uInt16) (sizeof(a##Class##Slots_Impl) / sizeof(SfxSlot) ) );   \
     322             :             InitInterface_Impl();                                           \
     323             :         }                                                                   \
     324             :         return pInterface;                                                  \
     325             :     }                                                                       \
     326             :                                                                             \
     327             :     SfxInterface* Class::GetInterface() const                               \
     328             :     {                                                                       \
     329             :         return GetStaticInterface();                                        \
     330             :     }                                                                       \
     331             :                                                                             \
     332             :     void Class::RegisterInterface(SfxModule* pMod)                          \
     333             :     {                                                                       \
     334             :         GetStaticInterface()->Register(pMod);                               \
     335             :     }                                                                       \
     336             :                                                                             \
     337             :     void Class::InitInterface_Impl()
     338             : 
     339             : #define SFX_POSITION_MASK               0x000F
     340             : #define SFX_VISIBILITY_MASK             0xFFF0
     341             : #define SFX_VISIBILITY_UNVISIBLE        0x0000  // Never visible
     342             : #define SFX_VISIBILITY_PLUGSERVER       0x0010
     343             : #define SFX_VISIBILITY_PLUGCLIENT       0x0020
     344             : #define SFX_VISIBILITY_VIEWER           0x0040
     345             :                                                 // One is still free!
     346             : #define SFX_VISIBILITY_RECORDING        0x0200
     347             : #define SFX_VISIBILITY_READONLYDOC      0x0400
     348             : #define SFX_VISIBILITY_DESKTOP          0x0800
     349             : #define SFX_VISIBILITY_STANDARD         0x1000
     350             : #define SFX_VISIBILITY_FULLSCREEN       0x2000
     351             : #define SFX_VISIBILITY_CLIENT           0x4000
     352             : #define SFX_VISIBILITY_SERVER           0x8000
     353             : #define SFX_VISIBILITY_NOCONTEXT        0xFFFF  // Always visable
     354             : 
     355             : #define SFX_OBJECTBAR_REGISTRATION(nPos,rResId) \
     356             :         GetStaticInterface()->RegisterObjectBar( nPos, rResId )
     357             : 
     358             : #define SFX_FEATURED_OBJECTBAR_REGISTRATION(nPos,rResId,nFeature) \
     359             :         GetStaticInterface()->RegisterObjectBar( nPos, rResId, nFeature )
     360             : 
     361             : #define SFX_CHILDWINDOW_REGISTRATION(nId) \
     362             :         GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_False )
     363             : 
     364             : #define SFX_FEATURED_CHILDWINDOW_REGISTRATION(nId,nFeature) \
     365             :         GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_False, nFeature )
     366             : 
     367             : #define SFX_CHILDWINDOW_CONTEXT_REGISTRATION(nId) \
     368             :         GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_True )
     369             : 
     370             : #define SFX_POPUPMENU_REGISTRATION(rResId) \
     371             :         GetStaticInterface()->RegisterPopupMenu( rResId )
     372             : 
     373             : #define SFX_STATUSBAR_REGISTRATION(rResId) \
     374             :         GetStaticInterface()->RegisterStatusBar( rResId )
     375             : 
     376             : #endif
     377             : 
     378             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10