LibreOffice Module sfx2 (master) 1
shell.hxx
Go to the documentation of this file.
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 <memory>
23#include <rtl/ustring.hxx>
24#include <sal/config.h>
25#include <sal/types.h>
26#include <svl/typedwhich.hxx>
27#include <sfx2/dllapi.h>
30#include <o3tl/strong_int.hxx>
31#include <optional>
32
33namespace com::sun::star::embed { struct VerbDescriptor; }
34namespace com::sun::star::uno { template <class E> class Sequence; }
35
36class SfxItemPool;
37class SfxPoolItem;
38class SfxRequest;
39class SfxItemSet;
40class SfxInterface;
41class SfxViewShell;
42class SfxObjectShell;
43
44class SfxShell;
45struct SfxShell_Impl;
46class SfxDispatcher;
47class SfxViewFrame;
48class SfxSlot;
49class SfxRepeatTarget;
50class SfxBindings;
51class SfxModule;
52class SfxUndoManager;
53
59
72
74{
75 NONE = 0x0000,
76 // Writer only, class SwView
77 SwChildWindowLabel = 0x0001,
78 // Basic only, class Shell
79 BasicShowBrowser = 0x0004,
80 // Forms only, class FmFormShell
81 FormShowDatabaseBar = 0x0008,
82 FormShowField = 0x0010,
83 FormShowProperties = 0x0020,
84 FormShowExplorer = 0x0040,
85 FormShowFilterBar = 0x0080,
88 FormTBControls = 0x0400,
89 FormTBDesign = 0x1000,
90 FormShowDataNavigator = 0x2000,
91 // masks to make sure modules don't use flags from another
92 SwMask = 0x0001,
93 BasicMask = 0x0004,
94 FormMask = 0x3ff8
95};
96namespace o3tl
97{
98 template<> struct typed_flags<SfxShellFeature> : is_typed_flags<SfxShellFeature, 0x37fd> {};
99}
100
101/* Flags that are being used in the slot definitions for the disable-features */
102enum class SfxDisableFlags {
103 NONE,
104 SwOnProtectedCursor = 0x0001,
105 SwOnMailboxEditor = 0x0002,
106};
107namespace o3tl {
108 template<> struct typed_flags<SfxDisableFlags> : is_typed_flags<SfxDisableFlags, 0x0003> {};
109}
110
111typedef void (*SfxExecFunc)(SfxShell *, SfxRequest &rReq);
113
128{
129 friend class SfxObjectItem;
130
131 std::unique_ptr< SfxShell_Impl > pImpl;
134
135private:
136 SfxShell( const SfxShell & ) = delete;
137 SfxShell& operator = ( const SfxShell & ) = delete;
138
139protected:
145 SfxShell();
146
152 SfxShell( SfxViewShell *pViewSh );
153
154 void SetViewShell_Impl( SfxViewShell* pView );
155 SAL_DLLPRIVATE void Invalidate_Impl( SfxBindings& rBindings, sal_uInt16 nId );
156 static void HandleOpenXmlFilterSettings(SfxRequest &);
157
158public:
159
165 virtual ~SfxShell() override;
166
175 virtual SfxInterface* GetInterface() const;
176 static SfxInterface* GetStaticInterface() { return nullptr; }
177
182 void SetName( const OUString &rName );
183
188 const OUString& GetName() const;
189
195 SfxViewShell* GetViewShell() const;
196
197 static void EmptyExecStub(SfxShell *pShell, SfxRequest &);
198 static void EmptyStateStub(SfxShell *pShell, SfxItemSet &);
199
234 const SfxPoolItem* GetSlotState( sal_uInt16 nSlotId, const SfxInterface *pIF = nullptr, SfxItemSet *pStateSet = nullptr );
235
266 const SfxPoolItem* ExecuteSlot( SfxRequest &rReq, const SfxInterface *pIF = nullptr );
267
271 void ExecuteSlot( SfxRequest &rReq, bool bAsync );
272
273 inline SfxItemPool& GetPool() const;
274 inline void SetPool( SfxItemPool *pNewPool ) ;
275
283 virtual SfxUndoManager* GetUndoManager();
284
296 void SetUndoManager( SfxUndoManager *pNewUndoMgr );
297
309 SfxRepeatTarget* GetRepeatTarget() const;
310
323 void SetRepeatTarget( SfxRepeatTarget *pTarget );
324
335 virtual void Invalidate(sal_uInt16 nId = 0);
336
337 virtual bool IsDesignMode() const { return false; };
338
339 bool IsActive() const;
340
350 virtual void Activate(bool bMDI);
351
360 virtual void Deactivate(bool bMDI);
361
370
390 SfxViewFrame* GetFrame() const;
391
392 virtual bool HasUIFeature(SfxShellFeature nFeature) const;
393 void UIFeatureChanged();
394
395 // Items
409 const SfxPoolItem* GetItem( sal_uInt16 nSlotId ) const;
410 template<class T> const T* GetItem( TypedWhichId<T> nWhich ) const
411 {
412 return static_cast<const T*>(GetItem(sal_uInt16(nWhich)));
413 }
414
428 void PutItem( const SfxPoolItem& rItem );
429
430 // TODO/CLEANUP: still needed?!
431 void SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& aVerbs);
432 const css::uno::Sequence < css::embed::VerbDescriptor >& GetVerbs() const;
433 void VerbExec (SfxRequest&);
434 static void VerbState (SfxItemSet&);
435 SAL_DLLPRIVATE const SfxSlot* GetVerbSlot_Impl(sal_uInt16 nId) const;
436
437 virtual SfxObjectShell* GetObjectShell();
438 void SetDisableFlags( SfxDisableFlags nFlags );
439 SfxDisableFlags GetDisableFlags() const;
440
441 virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId );
442 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet );
443
447 void SetContextName (const OUString& rsContextName);
448
457 void BroadcastContextForActivation (const bool bIsActivated);
458
461 bool SetContextBroadcasterEnabled (const bool bIsEnabled);
462
468 SAL_DLLPRIVATE bool CanExecuteSlot_Impl( const SfxSlot &rSlot );
469
476 virtual bool IsConditionalFastCall( const SfxRequest &rReq );
477
488 SAL_DLLPRIVATE void DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI);
489
499 SAL_DLLPRIVATE void DoDeactivate_Impl( SfxViewFrame const *pFrame, bool bMDI);
500};
501
512{
513 assert(pPool && "no pool");
514 return *pPool;
515}
516
525(
526 SfxItemPool* pNewPool // Pointer to the new Pool or null
527)
528{
529 pPool = pNewPool;
530}
531
532#define SFX_DECL_INTERFACE(nId) \
533 static SfxInterface* s_pInterface; \
534 static SfxInterface* GetStaticInterface(); \
535 static SfxInterfaceId GetInterfaceId() {return nId;} \
536 static void RegisterInterface(const SfxModule* pMod=nullptr); \
537 virtual SfxInterface* GetInterface() const override;
538
539#define SFX_TMPL_INTERFACE(Class,SuperClass,Abstract) \
540 \
541 SfxInterface* Class::s_pInterface = nullptr; \
542 SfxInterface* Class::GetStaticInterface() \
543 { \
544 if ( !s_pInterface ) \
545 { \
546 s_pInterface = \
547 new SfxInterface( \
548 #Class, Abstract, GetInterfaceId(), \
549 SuperClass::GetStaticInterface(), \
550 a##Class##Slots_Impl[0], \
551 sal_uInt16(sizeof(a##Class##Slots_Impl) / sizeof(SfxSlot) ) ); \
552 InitInterface_Impl(); \
553 } \
554 return s_pInterface; \
555 } \
556 \
557 SfxInterface* Class::GetInterface() const \
558 { \
559 return GetStaticInterface(); \
560 } \
561 \
562 void Class::RegisterInterface(const SfxModule* pMod) \
563 { \
564 GetStaticInterface()->Register(pMod); \
565 }
566
567#define SFX_IMPL_INTERFACE(Class,SuperClass) \
568SFX_TMPL_INTERFACE(Class,SuperClass,false) \
569
570#define SFX_IMPL_SUPERCLASS_INTERFACE(Class,SuperClass) \
571SFX_TMPL_INTERFACE(Class,SuperClass,true) \
572
574 Invisible = 0x0000, // Never visible
575 Viewer = 0x0040,
576 ReadonlyDoc = 0x0400,
577 Standard = 0x1000,
578 FullScreen = 0x2000,
579 Client = 0x4000,
580 Server = 0x8000,
581};
582namespace o3tl {
583 template<> struct typed_flags<SfxVisibilityFlags> : is_typed_flags<SfxVisibilityFlags, 0xf440> {};
584}
585#endif
586
587/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
Definition: shell.hxx:511
SfxUndoManager * pUndoMgr
Definition: shell.hxx:133
SfxItemPool * pPool
Definition: shell.hxx:132
std::unique_ptr< SfxShell_Impl > pImpl
Definition: shell.hxx:131
static SfxInterface * GetStaticInterface()
Definition: shell.hxx:176
virtual bool IsDesignMode() const
Definition: shell.hxx:337
const T * GetItem(TypedWhichId< T > nWhich) const
Definition: shell.hxx:410
void SetPool(SfxItemPool *pNewPool)
With this method, the subclasses register their special <SfxItemPool> in the SfxShell.
Definition: shell.hxx:525
SfxShell(const SfxShell &)=delete
Definition: msg.hxx:184
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
virtual OUString GetName() const override
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
NONE
SfxDispatcher * GetDispatcher()
Implementation of the interface com.sun.star.rdf.XDocumentMetadataAccess.
Invisible
static SfxItemSet & rSet
Definition: shell.cxx:534
constexpr auto SFX_INTERFACE_SFXMODULE
Definition: shell.hxx:65
constexpr auto SFX_INTERFACE_IDE_END
Definition: shell.hxx:71
constexpr auto SFX_INTERFACE_SFXVIEWFRM
Definition: shell.hxx:64
constexpr auto SFX_INTERFACE_SFXVIEWSH
Definition: shell.hxx:63
constexpr auto SFX_INTERFACE_SMA_START
Definition: shell.hxx:69
SfxDisableFlags
Definition: shell.hxx:102
constexpr auto SFX_INTERFACE_SD_START
Definition: shell.hxx:67
SfxShellFeature
Definition: shell.hxx:74
void(* SfxExecFunc)(SfxShell *, SfxRequest &rReq)
Definition: shell.hxx:111
void(* SfxStateFunc)(SfxShell *, SfxItemSet &rSet)
Definition: shell.hxx:112
o3tl::strong_int< sal_uInt16, struct SfxInterfaceIdTag > SfxInterfaceId
Id for <SfxInterface>s, gives a quasi-static access to the interface through an array to <SfxApplicat...
Definition: shell.hxx:52
constexpr auto SFX_INTERFACE_NONE
Definition: shell.hxx:60
constexpr auto SFX_INTERFACE_SC_START
Definition: shell.hxx:66
constexpr auto SFX_INTERFACE_IDE_START
Definition: shell.hxx:70
constexpr auto SFX_INTERFACE_SW_START
Definition: shell.hxx:68
constexpr auto SFX_INTERFACE_SFXDOCSH
Definition: shell.hxx:62
constexpr auto SFX_INTERFACE_SFXAPP
Definition: shell.hxx:61
SfxVisibilityFlags
Definition: shell.hxx:573