Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / sfx2 / dispatch.hxx
blob02348685420191f8e8f6b1db63278ab780bee226
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 <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sal/types.h>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/viewfrm.hxx>
28 #include <o3tl/typed_flags_set.hxx>
30 #include <initializer_list>
32 class SfxSlotServer;
33 class SfxShell;
34 class SfxRequest;
35 class SfxHintPoster;
36 class SfxViewFrame;
37 class SfxBindings;
38 class SfxItemSet;
39 class SfxPopupMenuManager;
40 class SfxModule;
41 struct SfxDispatcher_Impl;
43 namespace com
45 namespace sun
47 namespace star
49 namespace frame
51 class XDispatch;
58 enum class SfxDispatcherPopFlags
60 NONE = 0,
61 POP_UNTIL = 4,
62 POP_DELETE = 2,
63 PUSH = 1,
65 namespace o3tl
67 template<> struct typed_flags<SfxDispatcherPopFlags> : is_typed_flags<SfxDispatcherPopFlags, 0x07> {};
70 enum class SfxSlotFilterState
72 DISABLED,
73 ENABLED,
74 // enabled even if ReadOnlyDoc
75 ENABLED_READONLY,
79 class SFX2_DLLPUBLIC SfxDispatcher
81 std::unique_ptr<SfxDispatcher_Impl> xImp;
83 private:
84 // Search for temporary evaluated Todos
85 SAL_DLLPRIVATE bool CheckVirtualStack( const SfxShell& rShell );
87 friend class SfxApplication;
88 friend class SfxViewFrame;
90 DECL_DLLPRIVATE_LINK_TYPED( EventHdl_Impl, Idle *, void );
91 DECL_DLLPRIVATE_LINK_TYPED( PostMsgHandler, SfxRequest *, void );
93 SAL_DLLPRIVATE void Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, bool bRecord );
94 SAL_DLLPRIVATE void Update_Impl_( bool,bool,bool,SfxWorkWindow*);
96 protected:
97 friend class SfxBindings;
98 friend class SfxStateCache;
99 friend class SfxPopupMenuManager;
100 friend class SfxHelp;
102 bool FindServer_( sal_uInt16 nId, SfxSlotServer &rServer, bool bModal );
103 bool FillState_( const SfxSlotServer &rServer,
104 SfxItemSet &rState, const SfxSlot *pRealSlot );
105 void Execute_( SfxShell &rShell, const SfxSlot &rSlot,
106 SfxRequest &rReq,
107 SfxCallMode eCall = SfxCallMode::RECORD);
109 protected:
110 void FlushImpl();
112 public:
113 SfxDispatcher( SfxDispatcher* pParent );
114 SfxDispatcher( SfxViewFrame *pFrame = nullptr );
116 SAL_DLLPRIVATE void Construct_Impl( SfxDispatcher* pParent );
118 virtual ~SfxDispatcher();
120 const SfxPoolItem* Execute( sal_uInt16 nSlot,
121 SfxCallMode nCall = SfxCallMode::SLOT,
122 const SfxPoolItem **pArgs = nullptr,
123 sal_uInt16 nModi = 0,
124 const SfxPoolItem **pInternalArgs = nullptr);
126 const SfxPoolItem* Execute( sal_uInt16 nSlot,
127 SfxCallMode nCall,
128 SfxItemSet* pArgs,
129 SfxItemSet* pInternalArgs,
130 sal_uInt16 nModi = 0);
132 const SfxPoolItem* ExecuteList( sal_uInt16 nSlot,
133 SfxCallMode nCall,
134 std::initializer_list<SfxPoolItem const*> args);
136 const SfxPoolItem* Execute( sal_uInt16 nSlot,
137 SfxCallMode nCall,
138 const SfxItemSet &rArgs );
140 const SfxSlot* GetSlot( const OUString& rCommand );
142 bool IsActive( const SfxShell& rShell );
143 sal_uInt16 GetShellLevel( const SfxShell &rShell );
144 SfxBindings* GetBindings() const;
146 void Push( SfxShell& rShell );
147 void Pop( SfxShell& rShell, SfxDispatcherPopFlags nMode = SfxDispatcherPopFlags::NONE );
149 SfxShell* GetShell(sal_uInt16 nIdx) const;
150 SfxViewFrame* GetFrame() const;
151 SfxModule* GetModule() const;
153 void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr );
154 static void ExecutePopup( vcl::Window *pWin = nullptr, const Point *pPosPixel = nullptr );
156 bool IsAppDispatcher() const;
157 bool IsFlushed() const;
158 void Flush();
159 void Lock( bool bLock );
160 bool IsLocked( sal_uInt16 nSID = 0 ) const;
161 void SetSlotFilter( SfxSlotFilterState nEnable = SfxSlotFilterState::DISABLED,
162 sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = nullptr );
164 void HideUI( bool bHide = true );
165 sal_uInt32 GetObjectBarId( sal_uInt16 nPos ) const;
167 SfxItemState QueryState( sal_uInt16 nSID, const SfxPoolItem* &rpState );
168 SfxItemState QueryState( sal_uInt16 nSID, css::uno::Any& rAny );
170 void SetDisableFlags( sal_uInt32 nFlags );
171 sal_uInt32 GetDisableFlags() const;
173 SAL_DLLPRIVATE void SetMenu_Impl();
174 SAL_DLLPRIVATE void Update_Impl( bool bForce = false ); // ObjectBars etc.
175 SAL_DLLPRIVATE bool IsUpdated_Impl() const;
176 SAL_DLLPRIVATE bool GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot,
177 bool bOwnShellsOnly, bool bModal, bool bRealSlot=true );
178 SAL_DLLPRIVATE void SetReadOnly_Impl( bool bOn );
179 SAL_DLLPRIVATE bool GetReadOnly_Impl() const;
180 SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
181 SAL_DLLPRIVATE void SetQuietMode_Impl( bool bOn );
182 SAL_DLLPRIVATE bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
183 SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
184 SAL_DLLPRIVATE void DoParentActivate_Impl();
185 SAL_DLLPRIVATE void DoParentDeactivate_Impl();
186 SAL_DLLPRIVATE void DoActivate_Impl( bool bMDI, SfxViewFrame* pOld );
187 SAL_DLLPRIVATE void DoDeactivate_Impl( bool bMDI, SfxViewFrame* pNew );
188 SAL_DLLPRIVATE void InvalidateBindings_Impl(bool);
191 #endif
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */