fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / shell.hxx
blobddeb677e3127515f5c916d5f5f8fc1112b63d3fa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SFX_SHELL_HXX
20 #define _SFX_SHELL_HXX
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>
30 #include <tools/string.hxx>
32 #include <sfx2/sfxuno.hxx>
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;
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;
61 namespace svl
63 class IUndoManager;
66 //====================================================================
68 enum SfxInterfaceId
70 /* [Description]
72 Id for <SfxInterface>s, gives a quasi-static access to the interface
73 through an array to <SfxApplication>.
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
125 //TODO/CLEANUP: replace by UNO constant
126 #define SVVERB_SHOW -1
128 //====================================================================
130 typedef void (*SfxExecFunc)(SfxShell *, SfxRequest &rReq);
131 typedef void (*SfxStateFunc)(SfxShell *, SfxItemSet &rSet);
133 class SFX2_DLLPUBLIC SfxShell: public SfxBroadcaster
135 /* [Description]
137 The class SfxShell is the base class for all classes, which provide
138 the functionality of the form <Slot>s.
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.
151 friend class SfxObjectItem;
153 SfxShell_Impl* pImp;
154 SfxItemPool* pPool;
155 ::svl::IUndoManager* pUndoMgr;
157 private:
158 SfxShell( const SfxShell & ); // internal
159 SfxShell& operator = ( const SfxShell & ); // internal
161 protected:
162 SfxShell();
163 SfxShell( SfxViewShell *pViewSh );
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
172 public:
173 TYPEINFO();
174 virtual ~SfxShell();
176 virtual SfxInterface* GetInterface() const;
177 static SfxInterface* GetStaticInterface() { return 0; }
179 void SetName( const String &rName );
180 const String& GetName() const;
182 SfxViewShell* GetViewShell() const;
184 void CallExec( SfxExecFunc pFunc, SfxRequest &rReq )
185 { (*pFunc)(this, rReq); }
186 void CallState( SfxStateFunc pFunc, SfxItemSet &rSet )
187 { (*pFunc)(this, rSet); }
189 static void EmptyExecStub(SfxShell *pShell, SfxRequest &);
190 static void EmptyStateStub(SfxShell *pShell, SfxItemSet &);
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 );
197 inline SfxItemPool& GetPool() const;
198 inline void SetPool( SfxItemPool *pNewPool ) ;
200 virtual ::svl::IUndoManager*
201 GetUndoManager();
202 void SetUndoManager( ::svl::IUndoManager *pNewUndoMgr );
204 SfxRepeatTarget* GetRepeatTarget() const;
205 void SetRepeatTarget( SfxRepeatTarget *pTarget );
207 virtual void Invalidate(sal_uInt16 nId = 0);
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();
215 SfxDispatcher* GetDispatcher() const;
216 SfxViewFrame* GetFrame() const;
217 ResMgr* GetResMgr() const;
218 virtual sal_Bool HasUIFeature( sal_uInt32 nFeature );
219 void UIFeatureChanged();
221 // Items
222 const SfxPoolItem* GetItem( sal_uInt16 nSlotId ) const;
223 void PutItem( const SfxPoolItem& rItem );
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;
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;
238 virtual SfxItemSet* CreateItemSet( sal_uInt16 nId );
239 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
241 /** Set the name of the sidebar context that is broadcast on calls
242 to Activation().
244 void SetContextName (const ::rtl::OUString& rsContextName);
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.
254 void BroadcastContextForActivation (const bool bIsActivated);
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
263 //--------------------------------------------------------------------
264 SfxItemPool& SfxShell::GetPool() const
266 [Description]
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.
273 The SfxShell class itself does not have any SfxItemPool, therfore a
274 null-pointer is returned.
278 DBG_ASSERT( pPool, "no pool" );
279 return *pPool;
281 //-------------------------------------------------------------------
282 inline void SfxShell::SetPool
284 SfxItemPool* pNewPool // Pointer to the new Pool or null
287 /* [Description]
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).
297 pPool = pNewPool;
300 //=====================================================================
302 #define SFX_ARGUMENTMAP(ShellClass) static SfxFormalArgument a##ShellClass##Args_Impl[] =
304 #define SFX_SLOTMAP(ShellClass) static SfxFormalArgument a##ShellClass##Args_Impl[1]; \
305 static SfxSlot a##ShellClass##Slots_Impl[] =
307 #define SFX_SLOTMAP_ARG(ShellClass) static SfxSlot a##ShellClass##Slots_Impl[] =
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;
320 #define SFX_IMPL_INTERFACE(Class,SuperClass,NameResId) \
322 SfxInterface* Class::pInterface = 0; \
323 const SfxFormalArgument* Class::pSfxFormalArgs_Impl = a##Class##Args_Impl;\
324 SfxInterface* Class::GetStaticInterface() \
326 if ( !pInterface ) \
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(); \
336 return pInterface; \
339 SfxInterface* Class::GetInterface() const \
341 return GetStaticInterface(); \
344 void Class::RegisterInterface(SfxModule* pMod) \
346 GetStaticInterface()->Register(pMod); \
349 void Class::InitInterface_Impl()
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
363 #define SFX_OBJECTBAR_REGISTRATION(nPos,rResId) \
364 GetStaticInterface()->RegisterObjectBar( nPos, rResId )
366 #define SFX_FEATURED_OBJECTBAR_REGISTRATION(nPos,rResId,nFeature) \
367 GetStaticInterface()->RegisterObjectBar( nPos, rResId, nFeature )
369 #define SFX_CHILDWINDOW_REGISTRATION(nId) \
370 GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_False )
372 #define SFX_FEATURED_CHILDWINDOW_REGISTRATION(nId,nFeature) \
373 GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_False, nFeature )
375 #define SFX_CHILDWINDOW_CONTEXT_REGISTRATION(nId) \
376 GetStaticInterface()->RegisterChildWindow( nId, (sal_Bool) sal_True )
378 #define SFX_POPUPMENU_REGISTRATION(rResId) \
379 GetStaticInterface()->RegisterPopupMenu( rResId )
381 #define SFX_STATUSBAR_REGISTRATION(rResId) \
382 GetStaticInterface()->RegisterStatusBar( rResId )
384 #endif
386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */