1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
28 #include <sfx2/bindings.hxx>
29 #include <sfx2/viewfrm.hxx>
41 class SfxPopupMenuManager
;
43 struct SfxDispatcher_Impl
;
45 typedef std::vector
<SfxShell
*> SfxShellStack_Impl
;
61 //=========================================================================
63 #define SFX_SHELL_POP_UNTIL 4
64 #define SFX_SHELL_POP_DELETE 2
65 #define SFX_SHELL_PUSH 1
67 //=========================================================================
69 // Maps the Which() field to a pointer to a SfxPoolItem
70 class SfxItemPtrMap
: public std::map
<sal_uInt16
, SfxPoolItem
*>
75 for(iterator it
= begin(); it
!= end(); ++it
)
95 SfxToDo_Impl( bool bOpPush
, bool bOpDelete
, bool bOpUntil
, SfxShell
& rCluster
)
103 bool operator==( const SfxToDo_Impl
& rWith
) const
104 { return pCluster
==rWith
.pCluster
&& bPush
==rWith
.bPush
; }
107 class SFX2_DLLPUBLIC SfxDispatcher
109 SfxDispatcher_Impl
* pImp
;
111 std::deque
< std::deque
<SfxToDo_Impl
> > aToDoCopyStack
;
114 // Search for temporary evaluated Todos
115 SAL_DLLPRIVATE sal_Bool
CheckVirtualStack( const SfxShell
& rShell
, sal_Bool bDeep
);
119 friend class SfxApplication
;
120 friend class SfxViewFrame
;
122 DECL_DLLPRIVATE_LINK( EventHdl_Impl
, void * );
123 DECL_DLLPRIVATE_LINK( PostMsgHandler
, SfxRequest
* );
125 SAL_DLLPRIVATE
int Call_Impl( SfxShell
& rShell
, const SfxSlot
&rSlot
, SfxRequest
&rReq
, sal_Bool bRecord
);
126 SAL_DLLPRIVATE
void _Update_Impl( sal_Bool
,sal_Bool
,sal_Bool
,SfxWorkWindow
*);
127 SAL_DLLPRIVATE
void CollectTools_Impl(SfxWorkWindow
*);
130 friend class SfxBindings
;
131 friend class SfxStateCache
;
132 friend class SfxPopupMenuManager
;
133 friend class SfxHelp
;
134 // For bindings: Finding the Message;
135 // level for re-access
136 SAL_DLLPRIVATE sal_Bool
_TryIntercept_Impl( sal_uInt16 nId
, SfxSlotServer
&rServer
, sal_Bool bModal
);
137 sal_Bool
_FindServer( sal_uInt16 nId
, SfxSlotServer
&rServer
, sal_Bool bModal
);
138 sal_Bool
_FillState( const SfxSlotServer
&rServer
,
139 SfxItemSet
&rState
, const SfxSlot
*pRealSlot
);
140 void _Execute( SfxShell
&rShell
, const SfxSlot
&rSlot
,
142 SfxCallMode eCall
= SFX_CALLMODE_STANDARD
);
148 SfxDispatcher( SfxDispatcher
* pParent
);
149 SfxDispatcher( SfxViewFrame
*pFrame
= 0 );
151 SAL_DLLPRIVATE
void Construct_Impl( SfxDispatcher
* pParent
);
153 virtual ~SfxDispatcher();
155 const SfxPoolItem
* Execute( sal_uInt16 nSlot
,
156 SfxCallMode nCall
= SFX_CALLMODE_SLOT
,
157 const SfxPoolItem
**pArgs
= 0,
158 sal_uInt16 nModi
= 0,
159 const SfxPoolItem
**pInternalArgs
= 0);
161 const SfxPoolItem
* Execute( sal_uInt16 nSlot
,
164 SfxItemSet
* pInternalArgs
,
165 sal_uInt16 nModi
= 0);
167 const SfxPoolItem
* Execute( sal_uInt16 nSlot
,
169 const SfxPoolItem
*pArg1
, ... );
171 const SfxPoolItem
* Execute( sal_uInt16 nSlot
,
173 const SfxItemSet
&rArgs
);
175 const SfxPoolItem
* Execute( sal_uInt16 nSlot
,
178 const SfxItemSet
&rArgs
);
180 const SfxSlot
* GetSlot( const OUString
& rCommand
);
182 sal_Bool
IsActive( const SfxShell
& rShell
);
183 sal_Bool
IsOnTop( const SfxShell
& rShell
);
184 sal_uInt16
GetShellLevel( const SfxShell
&rShell
);
185 SfxBindings
* GetBindings() const;
187 void Push( SfxShell
& rShell
);
188 void Pop( SfxShell
& rShell
, sal_uInt16 nMode
= 0 );
190 SfxShell
* GetShell(sal_uInt16 nIdx
) const;
191 SfxViewFrame
* GetFrame() const;
192 SfxModule
* GetModule() const;
193 // caller has to clean up the Manager on his own
194 static SfxPopupMenuManager
* Popup( sal_uInt16 nConfigId
,Window
*pWin
, const Point
*pPos
);
196 void ExecutePopup( const ResId
&rId
,
197 Window
*pWin
= 0, const Point
*pPosPixel
= 0 );
198 static void ExecutePopup( sal_uInt16 nConfigId
= 0,
199 Window
*pWin
= 0, const Point
*pPosPixel
= 0 );
201 sal_Bool
IsAppDispatcher() const;
202 sal_Bool
IsFlushed() const;
204 void Lock( sal_Bool bLock
);
205 sal_Bool
IsLocked( sal_uInt16 nSID
= 0 ) const;
206 void SetSlotFilter( sal_Bool bEnable
= sal_False
,
207 sal_uInt16 nCount
= 0, const sal_uInt16
*pSIDs
= 0 );
209 void HideUI( sal_Bool bHide
= sal_True
);
210 void ShowObjectBar(sal_uInt16 nId
, SfxShell
*pShell
=0) const;
211 sal_uInt32
GetObjectBarId( sal_uInt16 nPos
) const;
213 SfxItemState
QueryState( sal_uInt16 nSID
, const SfxPoolItem
* &rpState
);
214 SfxItemState
QueryState( sal_uInt16 nSID
, ::com::sun::star::uno::Any
& rAny
);
216 ::com::sun::star::frame::XDispatch
* GetDispatchInterface( const OUString
& );
217 void SetDisableFlags( sal_uInt32 nFlags
);
218 sal_uInt32
GetDisableFlags() const;
220 SAL_DLLPRIVATE
void SetMenu_Impl();
221 SAL_DLLPRIVATE
void Update_Impl( sal_Bool bForce
= sal_False
); // ObjectBars etc.
222 SAL_DLLPRIVATE sal_Bool
IsUpdated_Impl() const;
223 SAL_DLLPRIVATE
int GetShellAndSlot_Impl( sal_uInt16 nSlot
, SfxShell
**ppShell
, const SfxSlot
**ppSlot
,
224 sal_Bool bOwnShellsOnly
, sal_Bool bModal
, sal_Bool bRealSlot
=sal_True
);
225 SAL_DLLPRIVATE
void SetReadOnly_Impl( sal_Bool bOn
);
226 SAL_DLLPRIVATE sal_Bool
GetReadOnly_Impl() const;
227 SAL_DLLPRIVATE sal_Bool
IsSlotEnabledByFilter_Impl( sal_uInt16 nSID
) const;
228 SAL_DLLPRIVATE
void SetQuietMode_Impl( sal_Bool bOn
);
229 SAL_DLLPRIVATE sal_Bool
IsReadOnlyShell_Impl( sal_uInt16 nShell
) const;
230 SAL_DLLPRIVATE
void RemoveShell_Impl( SfxShell
& rShell
);
231 SAL_DLLPRIVATE
void DoParentActivate_Impl();
232 SAL_DLLPRIVATE
void DoParentDeactivate_Impl();
233 SAL_DLLPRIVATE
void DoActivate_Impl( sal_Bool bMDI
, SfxViewFrame
* pOld
);
234 SAL_DLLPRIVATE
void DoDeactivate_Impl( sal_Bool bMDI
, SfxViewFrame
* pNew
);
235 SAL_DLLPRIVATE
void InvalidateBindings_Impl(sal_Bool
);
236 SAL_DLLPRIVATE sal_uInt16
GetNextToolBox_Impl( sal_uInt16 nPos
, sal_uInt16 nType
, OUString
*pStr
);
239 //--------------------------------------------------------------------
241 inline sal_Bool
SfxDispatcher::IsFlushed() const
245 This method checks if the stack of the SfxDispatchers is flushed, or if
246 push- or pop- commands are pending.
253 //--------------------------------------------------------------------
255 inline void SfxDispatcher::Flush()
259 This method performs outstanding push- and pop- commands. For <SfxShell>s,
260 which are new on the stack, the <SfxShell::Activate(sal_Bool)> is invoked with
261 bMDI == sal_True, for SfxShells that are removed from the stack, the
262 <SfxShell::Deactivate(sal_Bool)> is invoked with bMDI == sal_True
266 if ( !bFlushed
) FlushImpl();
269 //--------------------------------------------------------------------
271 inline void SfxDispatcher::Push( SfxShell
& rShell
)
275 With this method, a <SfxShell> pushed on to the SfxDispatcher.
276 The SfxShell is first marked for push and a timer is set up.
277 First when the timer has couted down to zero the push
278 ( <SfxDispatcher::Flush()> ) is actually performed and the
279 <SfxBindings> is invalidated. While the timer is counting down
280 the opposing push and pop commands on the same SfxShell are
285 Pop( rShell
, SFX_SHELL_PUSH
);
288 //--------------------------------------------------------------------
290 inline sal_Bool
SfxDispatcher::IsActive( const SfxShell
& rShell
)
294 This method checks whether a particular <SfxShell> instance is
295 on the SfxDispatcher.
300 The SfxShell instance is on the SfxDispatcher.
303 The SfxShell instance is not on the SfxDispatcher.
307 return CheckVirtualStack( rShell
, sal_True
);
309 //--------------------------------------------------------------------
311 inline sal_Bool
SfxDispatcher::IsOnTop( const SfxShell
& rShell
)
315 This method checks whether a particular <SfxShell> instance is on
316 top of the SfxDispatcher.
321 The SfxShell instance is on the top of
325 The SfxShell instance is not on the top of
330 return CheckVirtualStack( rShell
, sal_False
);
333 //--------------------------------------------------------------------
337 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */