Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / include / sfx2 / dispatch.hxx
blob97f5dae19ecf4b7f67e498ad045ce9b1fbc83b07
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 INCLUDED_SFX2_DISPATCH_HXX
20 #define INCLUDED_SFX2_DISPATCH_HXX
22 #include <memory>
23 #include <sal/config.h>
24 #include <sfx2/dllapi.h>
25 #include <sfx2/toolbarids.hxx>
26 #include <sal/types.h>
28 #include <sfx2/bindings.hxx>
29 #include <o3tl/typed_flags_set.hxx>
30 #include <o3tl/span.hxx>
32 #include <initializer_list>
34 class SfxSlotServer;
35 class SfxRequest;
36 class SfxViewFrame;
37 class SfxItemSet;
38 class SfxModule;
39 class Point;
40 struct SfxDispatcher_Impl;
42 namespace vcl { class Window; }
44 enum class SfxDispatcherPopFlags
46 NONE = 0,
47 POP_UNTIL = 4,
48 POP_DELETE = 2,
49 PUSH = 1,
51 namespace o3tl
53 template<> struct typed_flags<SfxDispatcherPopFlags> : is_typed_flags<SfxDispatcherPopFlags, 0x07> {};
56 enum class SfxSlotFilterState
58 DISABLED,
59 ENABLED,
60 // enabled even if ReadOnlyDoc
61 ENABLED_READONLY,
65 class SFX2_DLLPUBLIC SfxDispatcher final
67 std::unique_ptr<SfxDispatcher_Impl> xImp;
69 // Search for temporary evaluated Todos
70 SAL_DLLPRIVATE bool CheckVirtualStack( const SfxShell& rShell );
72 friend class SfxApplication;
73 friend class SfxViewFrame;
74 friend class SfxBindings;
75 friend class SfxStateCache;
76 friend class SfxPopupMenuManager;
77 friend class SfxHelp;
79 DECL_DLLPRIVATE_LINK( EventHdl_Impl, Timer *, void );
80 void PostMsgHandler(std::unique_ptr<SfxRequest>);
82 SAL_DLLPRIVATE void Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, bool bRecord );
83 SAL_DLLPRIVATE void Update_Impl_( bool,bool,bool,SfxWorkWindow*);
86 bool FindServer_( sal_uInt16 nId, SfxSlotServer &rServer );
87 bool FillState_( const SfxSlotServer &rServer,
88 SfxItemSet &rState, const SfxSlot *pRealSlot );
89 void Execute_( SfxShell &rShell, const SfxSlot &rSlot,
90 SfxRequest &rReq,
91 SfxCallMode eCall);
93 void FlushImpl();
95 public:
96 SfxDispatcher();
97 SfxDispatcher( SfxViewFrame *pFrame );
99 SAL_DLLPRIVATE void Construct_Impl();
101 ~SfxDispatcher();
103 const SfxPoolItem* Execute( sal_uInt16 nSlot,
104 SfxCallMode nCall = SfxCallMode::SLOT,
105 const SfxPoolItem **pArgs = nullptr,
106 sal_uInt16 nModi = 0,
107 const SfxPoolItem **pInternalArgs = nullptr);
109 const SfxPoolItem* Execute(sal_uInt16 nSlot,
110 SfxCallMode nCall,
111 SfxItemSet const * pArgs,
112 SfxItemSet const * pInternalArgs,
113 sal_uInt16 nModi);
115 const SfxPoolItem* ExecuteList(sal_uInt16 nSlot,
116 SfxCallMode nCall,
117 std::initializer_list<SfxPoolItem const*> args,
118 std::initializer_list<SfxPoolItem const*> internalargs = std::initializer_list<SfxPoolItem const*>());
120 const SfxPoolItem* Execute( sal_uInt16 nSlot,
121 SfxCallMode nCall,
122 const SfxItemSet &rArgs );
124 const SfxSlot* GetSlot( const OUString& rCommand );
126 bool IsActive( const SfxShell& rShell );
127 sal_uInt16 GetShellLevel( const SfxShell &rShell );
128 SfxBindings* GetBindings() const;
130 void Push( SfxShell& rShell );
131 void Pop( SfxShell& rShell, SfxDispatcherPopFlags nMode = SfxDispatcherPopFlags::NONE );
133 SfxShell* GetShell(sal_uInt16 nIdx) const;
134 SfxViewFrame* GetFrame() const;
135 SfxModule* GetModule() const;
137 void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr );
138 static void ExecutePopup( vcl::Window *pWin = nullptr, const Point *pPosPixel = nullptr );
140 bool IsAppDispatcher() const;
141 bool IsFlushed() const;
142 void Flush();
143 void Lock( bool bLock );
144 bool IsLocked() const;
145 void SetSlotFilter( SfxSlotFilterState nEnable = SfxSlotFilterState::DISABLED,
146 o3tl::span<sal_uInt16 const> pSIDs = o3tl::span<sal_uInt16 const>());
148 void HideUI( bool bHide = true );
149 ToolbarId GetObjectBarId( sal_uInt16 nPos ) const;
151 SfxItemState QueryState( sal_uInt16 nSID, const SfxPoolItem* &rpState );
152 SfxItemState QueryState( sal_uInt16 nSID, css::uno::Any& rAny );
154 void SetDisableFlags( SfxDisableFlags nFlags );
155 SfxDisableFlags GetDisableFlags() const;
157 SAL_DLLPRIVATE void SetMenu_Impl();
158 SAL_DLLPRIVATE void Update_Impl( bool bForce = false ); // ObjectBars etc.
159 SAL_DLLPRIVATE bool IsUpdated_Impl() const;
160 SAL_DLLPRIVATE bool GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot,
161 bool bOwnShellsOnly, bool bRealSlot );
162 SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn );
163 SAL_DLLPRIVATE bool GetReadOnly_Impl() const;
164 SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
165 SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn );
166 SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
167 SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
168 SAL_DLLPRIVATE void DoActivate_Impl( bool bMDI );
169 SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame const * pNew );
170 SAL_DLLPRIVATE void InvalidateBindings_Impl(bool);
173 #endif
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */