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

Generated by: LCOV version 1.10