Branch data Line data Source code
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 _SFXDISPATCH_HXX
20 : : #define _SFXDISPATCH_HXX
21 : :
22 : : #include "sal/config.h"
23 : : #include "sfx2/dllapi.h"
24 : : #include "sal/types.h"
25 : :
26 : : #include <stdarg.h>
27 : :
28 : : #include <sfx2/bindings.hxx>
29 : : #include <sfx2/viewfrm.hxx>
30 : : #include <map>
31 : :
32 : : class SfxSlotServer;
33 : : class SfxShell;
34 : : class SfxRequest;
35 : : class SfxShellStack_Impl;
36 : : class SfxHintPoster;
37 : : class SfxViewFrame;
38 : : class SfxBindings;
39 : : class SfxItemSet;
40 : : class SfxPopupMenuManager;
41 : : class SfxModule;
42 : : struct SfxDispatcher_Impl;
43 : :
44 : : namespace com
45 : : {
46 : : namespace sun
47 : : {
48 : : namespace star
49 : : {
50 : : namespace frame
51 : : {
52 : : class XDispatch;
53 : : }
54 : : }
55 : : }
56 : : }
57 : :
58 : : //=========================================================================
59 : :
60 : : #define SFX_SHELL_POP_UNTIL 4
61 : : #define SFX_SHELL_POP_DELETE 2
62 : : #define SFX_SHELL_PUSH 1
63 : :
64 : : //=========================================================================
65 : :
66 : : // Maps the Which() field to a pointer to a SfxPoolItem
67 : 11881 : class SfxItemPtrMap : public std::map<sal_uInt16, SfxPoolItem*>
68 : : {
69 : : public:
70 : 10795 : ~SfxItemPtrMap()
71 : 10795 : {
72 [ + - ][ + - ]: 24989 : for(iterator it = begin(); it != end(); ++it)
[ + + ]
73 [ + - ][ + - ]: 14194 : delete it->second;
[ + - ]
74 : 10795 : }
75 : : };
76 : :
77 : : class SFX2_DLLPUBLIC SfxDispatcher
78 : : {
79 : : SfxDispatcher_Impl* pImp;
80 : : sal_Bool bFlushed;
81 : :
82 : : private:
83 : : // Search for temporary evaluated Todos
84 : : SAL_DLLPRIVATE sal_Bool CheckVirtualStack( const SfxShell& rShell, sal_Bool bDeep );
85 : :
86 : : #ifndef _SFX_HXX
87 : :
88 : : friend class SfxApplication;
89 : : friend class SfxViewFrame;
90 : :
91 : : DECL_DLLPRIVATE_LINK( EventHdl_Impl, void * );
92 : : DECL_DLLPRIVATE_LINK( PostMsgHandler, SfxRequest * );
93 : :
94 : : SAL_DLLPRIVATE int Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, sal_Bool bRecord );
95 : : SAL_DLLPRIVATE void _Update_Impl( sal_Bool,sal_Bool,sal_Bool,SfxWorkWindow*);
96 : : SAL_DLLPRIVATE void CollectTools_Impl(SfxWorkWindow*);
97 : :
98 : : protected:
99 : : friend class SfxBindings;
100 : : friend class SfxStateCache;
101 : : friend class SfxPopupMenuManager;
102 : : friend class SfxHelp;
103 : : // For bindings: Finding the Message;
104 : : // level for re-access
105 : : SAL_DLLPRIVATE sal_Bool _TryIntercept_Impl( sal_uInt16 nId, SfxSlotServer &rServer, sal_Bool bModal );
106 : : sal_Bool _FindServer( sal_uInt16 nId, SfxSlotServer &rServer, sal_Bool bModal );
107 : : sal_Bool _FillState( const SfxSlotServer &rServer,
108 : : SfxItemSet &rState, const SfxSlot *pRealSlot );
109 : : void _Execute( SfxShell &rShell, const SfxSlot &rSlot,
110 : : SfxRequest &rReq,
111 : : SfxCallMode eCall = SFX_CALLMODE_STANDARD);
112 : : #endif
113 : : protected:
114 : : void FlushImpl();
115 : :
116 : : public:
117 : : SfxDispatcher( SfxDispatcher* pParent );
118 : : SfxDispatcher( SfxViewFrame *pFrame = 0 );
119 : :
120 : : SAL_DLLPRIVATE void Construct_Impl( SfxDispatcher* pParent );
121 : :
122 : : virtual ~SfxDispatcher();
123 : :
124 : : virtual void SetExecuteMode( sal_uInt16 );
125 : :
126 : : const SfxPoolItem* Execute( sal_uInt16 nSlot,
127 : : SfxCallMode nCall = SFX_CALLMODE_SLOT,
128 : : const SfxPoolItem **pArgs = 0,
129 : : sal_uInt16 nModi = 0,
130 : : const SfxPoolItem **pInternalArgs = 0);
131 : :
132 : : const SfxPoolItem* Execute( sal_uInt16 nSlot,
133 : : SfxCallMode nCall,
134 : : SfxItemSet* pArgs,
135 : : SfxItemSet* pInternalArgs,
136 : : sal_uInt16 nModi = 0);
137 : :
138 : : const SfxPoolItem* Execute( sal_uInt16 nSlot,
139 : : SfxCallMode nCall,
140 : : const SfxPoolItem *pArg1, ... );
141 : :
142 : : const SfxPoolItem* Execute( sal_uInt16 nSlot,
143 : : SfxCallMode nCall,
144 : : const SfxItemSet &rArgs );
145 : :
146 : : const SfxPoolItem* Execute( sal_uInt16 nSlot,
147 : : SfxCallMode nCall,
148 : : sal_uInt16 nModi,
149 : : const SfxItemSet &rArgs );
150 : :
151 : : const SfxSlot* GetSlot( const String& rCommand );
152 : :
153 : : sal_Bool IsActive( const SfxShell& rShell );
154 : : sal_Bool IsOnTop( const SfxShell& rShell );
155 : : sal_uInt16 GetShellLevel( const SfxShell &rShell );
156 : : SfxBindings* GetBindings() const;
157 : :
158 : : void Push( SfxShell& rShell );
159 : : void Pop( SfxShell& rShell, sal_uInt16 nMode = 0 );
160 : :
161 : : SfxShell* GetShell(sal_uInt16 nIdx) const;
162 : : SfxViewFrame* GetFrame() const;
163 : : SfxModule* GetModule() const;
164 : : // caller has to clean up the Manager on his own
165 : : static SfxPopupMenuManager* Popup( sal_uInt16 nConfigId,Window *pWin, const Point *pPos );
166 : :
167 : : void ExecutePopup( const ResId &rId,
168 : : Window *pWin = 0, const Point *pPosPixel = 0 );
169 : : static void ExecutePopup( sal_uInt16 nConfigId = 0,
170 : : Window *pWin = 0, const Point *pPosPixel = 0 );
171 : :
172 : : sal_Bool IsAppDispatcher() const;
173 : : sal_Bool IsFlushed() const;
174 : : void Flush();
175 : : void Lock( sal_Bool bLock );
176 : : sal_Bool IsLocked( sal_uInt16 nSID = 0 ) const;
177 : : void SetSlotFilter( sal_Bool bEnable = sal_False,
178 : : sal_uInt16 nCount = 0, const sal_uInt16 *pSIDs = 0 );
179 : :
180 : : void HideUI( sal_Bool bHide = sal_True );
181 : : void ShowObjectBar(sal_uInt16 nId, SfxShell *pShell=0) const;
182 : : sal_uInt32 GetObjectBarId( sal_uInt16 nPos ) const;
183 : :
184 : : SfxItemState QueryState( sal_uInt16 nSID, const SfxPoolItem* &rpState );
185 : : SfxItemState QueryState( sal_uInt16 nSID, ::com::sun::star::uno::Any& rAny );
186 : :
187 : : sal_Bool IsAllowed( sal_uInt16 nSlot ) const;
188 : : ::com::sun::star::frame::XDispatch* GetDispatchInterface( const String& );
189 : : void SetDisableFlags( sal_uInt32 nFlags );
190 : : sal_uInt32 GetDisableFlags() const;
191 : :
192 : : SAL_DLLPRIVATE void SetMenu_Impl();
193 : : SAL_DLLPRIVATE void Update_Impl( sal_Bool bForce = sal_False ); // ObjectBars etc.
194 : : SAL_DLLPRIVATE sal_Bool IsUpdated_Impl() const;
195 : : SAL_DLLPRIVATE int GetShellAndSlot_Impl( sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot,
196 : : sal_Bool bOwnShellsOnly, sal_Bool bModal, sal_Bool bRealSlot=sal_True );
197 : : SAL_DLLPRIVATE void SetReadOnly_Impl( sal_Bool bOn );
198 : : SAL_DLLPRIVATE sal_Bool GetReadOnly_Impl() const;
199 : : SAL_DLLPRIVATE sal_Bool IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const;
200 : : SAL_DLLPRIVATE void SetQuietMode_Impl( sal_Bool bOn );
201 : : SAL_DLLPRIVATE sal_Bool IsReadOnlyShell_Impl( sal_uInt16 nShell ) const;
202 : : SAL_DLLPRIVATE void RemoveShell_Impl( SfxShell& rShell );
203 : : SAL_DLLPRIVATE void DoParentActivate_Impl();
204 : : SAL_DLLPRIVATE void DoParentDeactivate_Impl();
205 : : SAL_DLLPRIVATE void DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* pOld );
206 : : SAL_DLLPRIVATE void DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew );
207 : : SAL_DLLPRIVATE void InvalidateBindings_Impl(sal_Bool);
208 : : SAL_DLLPRIVATE sal_uInt16 GetNextToolBox_Impl( sal_uInt16 nPos, sal_uInt16 nType, String *pStr );
209 : : };
210 : :
211 : : //--------------------------------------------------------------------
212 : :
213 : 5760 : inline sal_Bool SfxDispatcher::IsFlushed() const
214 : :
215 : : /* [Description]
216 : :
217 : : This method checks if the stack of the SfxDispatchers is flushed, or if
218 : : push- or pop- commands are pending.
219 : : */
220 : :
221 : : {
222 : 5760 : return bFlushed;
223 : : }
224 : :
225 : : //--------------------------------------------------------------------
226 : :
227 : 354205 : inline void SfxDispatcher::Flush()
228 : :
229 : : /* [Description]
230 : :
231 : : This method performs outstanding push- and pop- commands. For <SfxShell>s,
232 : : which are new on the stack, the <SfxShell::Activate(sal_Bool)> is invoked with
233 : : bMDI == sal_True, for SfxShells that are removed from the stack, the
234 : : <SfxShell::Deactivate(sal_Bool)> is invoked with bMDI == sal_True
235 : : */
236 : :
237 : : {
238 [ + + ]: 354205 : if ( !bFlushed ) FlushImpl();
239 : 354205 : }
240 : :
241 : : //--------------------------------------------------------------------
242 : :
243 : 10160 : inline void SfxDispatcher::Push( SfxShell& rShell )
244 : :
245 : : /* [Description]
246 : :
247 : : With this method, a <SfxShell> pushed on to the SfxDispatcher.
248 : : The SfxShell is first marked for push and a timer is set up.
249 : : First when the timer has couted down to zero the push
250 : : ( <SfxDispatcher::Flush()> ) is actually performed and the
251 : : <SfxBindings> is invalidated. While the timer is counting down
252 : : the opposing push and pop commands on the same SfxShell are
253 : : leveled out.
254 : : */
255 : :
256 : : {
257 : 10160 : Pop( rShell, SFX_SHELL_PUSH );
258 : 10160 : }
259 : :
260 : : //--------------------------------------------------------------------
261 : :
262 : 2995 : inline sal_Bool SfxDispatcher::IsActive( const SfxShell& rShell )
263 : :
264 : : /* [Description]
265 : :
266 : : This method checks whether a particular <SfxShell> instance is
267 : : on the SfxDispatcher.
268 : :
269 : : [Return value]
270 : :
271 : : sal_Bool sal_True
272 : : The SfxShell instance is on the SfxDispatcher.
273 : :
274 : : sal_False
275 : : The SfxShell instance is not on the SfxDispatcher.
276 : : */
277 : :
278 : : {
279 : 2995 : return CheckVirtualStack( rShell, sal_True );
280 : : }
281 : : //--------------------------------------------------------------------
282 : :
283 : : inline sal_Bool SfxDispatcher::IsOnTop( const SfxShell& rShell )
284 : :
285 : : /* [Description]
286 : :
287 : : This method checks whether a particular <SfxShell> instance is on
288 : : top of the SfxDispatcher.
289 : :
290 : : [Return value]
291 : :
292 : : sal_Bool sal_True
293 : : The SfxShell instance is on the top of
294 : : the SfxDispatcher.
295 : :
296 : : sal_False
297 : : The SfxShell instance is not on the top of
298 : : the SfxDispatcher.
299 : : */
300 : :
301 : : {
302 : : return CheckVirtualStack( rShell, sal_False );
303 : : }
304 : :
305 : : //--------------------------------------------------------------------
306 : :
307 : : #endif
308 : :
309 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|