workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / sfx2 / dispatch.hxx
blob17d2fa464e3bce35b5dcdb13ff677403171d8728
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 <span>
24 #include <sal/config.h>
25 #include <rtl/ref.hxx>
26 #include <sfx2/dllapi.h>
27 #include <sfx2/toolbarids.hxx>
28 #include <sal/types.h>
30 #include <sfx2/bindings.hxx>
31 #include <o3tl/typed_flags_set.hxx>
33 #include <boost/property_tree/ptree_fwd.hpp>
34 #include <initializer_list>
36 class SfxSlotServer;
37 class SfxRequest;
38 class SfxViewFrame;
39 class SfxItemSet;
40 class SfxModule;
41 class Point;
42 struct SfxDispatcher_Impl;
43 class VCLXPopupMenu;
44 class SfxPoolItemHolder;
46 namespace com::sun::star::awt { class XPopupMenu; }
47 namespace vcl { class Window; }
49 enum class SfxDispatcherPopFlags
51 NONE = 0,
52 POP_UNTIL = 4,
53 POP_DELETE = 2,
54 PUSH = 1,
56 namespace o3tl
58 template<> struct typed_flags<SfxDispatcherPopFlags> : is_typed_flags<SfxDispatcherPopFlags, 0x07> {};
61 enum class SfxSlotFilterState
63 DISABLED,
64 ENABLED,
65 // enabled even if ReadOnlyDoc
66 ENABLED_READONLY,
70 class SFX2_DLLPUBLIC SfxDispatcher final
72 std::unique_ptr<SfxDispatcher_Impl> xImp;
74 // Search for temporary evaluated Todos
75 SAL_DLLPRIVATE bool CheckVirtualStack( const SfxShell& rShell );
77 friend class SfxApplication;
78 friend class SfxViewFrame;
79 friend class SfxBindings;
80 friend class SfxStateCache;
81 friend class SfxPopupMenuManager;
82 friend class SfxHelp;
83 friend class SfxHintPoster;
85 DECL_DLLPRIVATE_LINK( EventHdl_Impl, Timer *, void );
86 void PostMsgHandler(std::unique_ptr<SfxRequest>);
88 SAL_DLLPRIVATE void Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, bool bRecord );
89 SAL_DLLPRIVATE void Update_Impl_( bool,bool,bool,SfxWorkWindow*);
92 bool FindServer_( sal_uInt16 nId, SfxSlotServer &rServer );
93 static bool IsCommandAllowedInLokReadOnlyViewMode (OUString commandName);
94 bool FillState_( const SfxSlotServer &rServer,
95 SfxItemSet &rState, const SfxSlot *pRealSlot );
96 void Execute_( SfxShell &rShell, const SfxSlot &rSlot,
97 SfxRequest &rReq,
98 SfxCallMode eCall);
100 void FlushImpl();
102 public:
103 SfxDispatcher();
104 SfxDispatcher( SfxViewFrame *pFrame );
106 SAL_DLLPRIVATE void Construct_Impl();
108 ~SfxDispatcher();
110 SfxPoolItemHolder Execute( sal_uInt16 nSlot,
111 SfxCallMode nCall = SfxCallMode::SLOT,
112 const SfxPoolItem **pArgs = nullptr,
113 sal_uInt16 nModi = 0,
114 const SfxPoolItem **pInternalArgs = nullptr);
116 SfxPoolItemHolder Execute(sal_uInt16 nSlot,
117 SfxCallMode nCall,
118 SfxItemSet const * pArgs,
119 SfxItemSet const * pInternalArgs,
120 sal_uInt16 nModi);
122 SfxPoolItemHolder ExecuteList(sal_uInt16 nSlot,
123 SfxCallMode nCall,
124 std::initializer_list<SfxPoolItem const*> args,
125 std::initializer_list<SfxPoolItem const*> internalargs = std::initializer_list<SfxPoolItem const*>());
127 SfxPoolItemHolder Execute( sal_uInt16 nSlot,
128 SfxCallMode nCall,
129 const SfxItemSet &rArgs );
131 const SfxSlot* GetSlot( const OUString& rCommand );
133 bool IsActive( const SfxShell& rShell );
134 sal_uInt16 GetShellLevel( const SfxShell &rShell );
135 SAL_RET_MAYBENULL SfxBindings* GetBindings() const;
137 void Push( SfxShell& rShell );
138 void Pop( SfxShell& rShell, SfxDispatcherPopFlags nMode = SfxDispatcherPopFlags::NONE );
140 SAL_RET_MAYBENULL SfxShell* GetShell(sal_uInt16 nIdx) const;
141 SfxViewFrame* GetFrame() const;
142 SfxModule* GetModule() const;
144 void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr );
145 static void ExecutePopup( vcl::Window *pWin = nullptr, const Point *pPosPixel = nullptr );
147 bool IsAppDispatcher() const;
148 bool IsFlushed() const;
149 void Flush();
150 void Lock( bool bLock );
151 bool IsLocked() const;
152 void SetSlotFilter( SfxSlotFilterState nEnable = SfxSlotFilterState::DISABLED,
153 std::span<sal_uInt16 const> pSIDs = std::span<sal_uInt16 const>());
155 void HideUI( bool bHide = true );
156 ToolbarId GetObjectBarId( sal_uInt16 nPos ) const;
158 SfxItemState QueryState( sal_uInt16 nSID, SfxPoolItemHolder& rState );
159 SfxItemState QueryState( sal_uInt16 nSID, css::uno::Any& rAny );
161 void SetDisableFlags( SfxDisableFlags nFlags );
162 SfxDisableFlags GetDisableFlags() const;
164 SAL_DLLPRIVATE void SetMenu_Impl();
165 SAL_DLLPRIVATE void Update_Impl( bool bForce = false ); // ObjectBars etc.
166 SAL_DLLPRIVATE bool IsUpdated_Impl() const;
167 SAL_DLLPRIVATE bool GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot,
168 bool bOwnShellsOnly, bool bRealSlot );
169 SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn );
170 SAL_DLLPRIVATE bool GetReadOnly_Impl() const;
171 SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
172 SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn );
173 SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
174 SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
175 SAL_DLLPRIVATE void DoActivate_Impl( bool bMDI );
176 SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame const * pNew );
177 SAL_DLLPRIVATE void InvalidateBindings_Impl(bool);
179 static boost::property_tree::ptree fillPopupMenu(const rtl::Reference<VCLXPopupMenu>& rMenu);
182 #endif
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */