xref: /aoo42x/main/sfx2/source/control/dispatch.cxx (revision 940681c7)
1d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5d119d52dSAndrew Rist  * distributed with this work for additional information
6d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10d119d52dSAndrew Rist  *
11d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12d119d52dSAndrew Rist  *
13d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17d119d52dSAndrew Rist  * specific language governing permissions and limitations
18d119d52dSAndrew Rist  * under the License.
19d119d52dSAndrew Rist  *
20d119d52dSAndrew Rist  *************************************************************/
21d119d52dSAndrew Rist 
22d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
27cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
28cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
29cdf0e10cSrcweir #include <svl/itempool.hxx>
30cdf0e10cSrcweir #include <svl/itemiter.hxx>
31cdf0e10cSrcweir #include <svl/whiter.hxx>
32cdf0e10cSrcweir #include <svl/intitem.hxx>
33cdf0e10cSrcweir #ifndef _SFXEITEM_HXX //autogen
34cdf0e10cSrcweir #include <svl/eitem.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <svl/undo.hxx>
37cdf0e10cSrcweir #ifndef _WRKWIN_HXX //autogen
38cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <svtools/ttprops.hxx>
41cdf0e10cSrcweir #include <stdio.h>
42cdf0e10cSrcweir #include <stdarg.h>
43cdf0e10cSrcweir #include <stdlib.h>				// wg. bsearch
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #define _SVSTDARR_ULONGS
46cdf0e10cSrcweir #include <svl/svstdarr.hxx>
47cdf0e10cSrcweir #include <svtools/helpopt.hxx>
48cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
49cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #ifndef GCC
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // wg. nAutoPageID
55cdf0e10cSrcweir #include "appdata.hxx"
56cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx"
57cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
58cdf0e10cSrcweir #include <sfx2/minstack.hxx>
59cdf0e10cSrcweir #include <sfx2/msg.hxx>
60cdf0e10cSrcweir #include <sfx2/objface.hxx>
61cdf0e10cSrcweir #include <sfx2/bindings.hxx>
62cdf0e10cSrcweir #include <sfx2/request.hxx>
63cdf0e10cSrcweir #include <sfx2/app.hxx>
64cdf0e10cSrcweir #include <sfx2/hintpost.hxx>
65cdf0e10cSrcweir #include "slotserv.hxx"
66cdf0e10cSrcweir #include <sfx2/ipclient.hxx>
67cdf0e10cSrcweir #include "sfxtypes.hxx"
68cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
69cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
70cdf0e10cSrcweir #include <sfx2/childwin.hxx>
71cdf0e10cSrcweir #include <sfx2/docfac.hxx>
72cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
73cdf0e10cSrcweir #include <sfx2/module.hxx>
74cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
75cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
76cdf0e10cSrcweir #include <sfx2/docfile.hxx>
77cdf0e10cSrcweir #include <sfx2/mnumgr.hxx>
78cdf0e10cSrcweir #include "workwin.hxx"
79cdf0e10cSrcweir 
80cdf0e10cSrcweir namespace css = ::com::sun::star;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //==================================================================
83cdf0e10cSrcweir DBG_NAME(SfxDispatcherFlush)
84cdf0e10cSrcweir DBG_NAME(SfxDispatcherFillState)
85cdf0e10cSrcweir 
86cdf0e10cSrcweir //==================================================================
87cdf0e10cSrcweir typedef SfxRequest* SfxRequestPtr;
88cdf0e10cSrcweir SV_IMPL_PTRARR( SfxItemPtrArray, SfxPoolItemPtr );
89cdf0e10cSrcweir SV_DECL_PTRARR_DEL( SfxRequestPtrArray, SfxRequestPtr, 4, 4 )
90cdf0e10cSrcweir SV_IMPL_PTRARR( SfxRequestPtrArray, SfxRequestPtr );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir DECL_PTRSTACK(SfxShellStack_Impl, SfxShell*, 8, 4 );
93cdf0e10cSrcweir //==================================================================
94cdf0e10cSrcweir 
95cdf0e10cSrcweir struct SfxToDo_Impl
96cdf0e10cSrcweir {
97cdf0e10cSrcweir 	SfxShell*			pCluster;
98cdf0e10cSrcweir 	bool               	bPush;
99cdf0e10cSrcweir 	bool    			bDelete;
100cdf0e10cSrcweir 	bool    			bUntil;
101cdf0e10cSrcweir 
SfxToDo_ImplSfxToDo_Impl102cdf0e10cSrcweir 	SfxToDo_Impl()
103cdf0e10cSrcweir 		: pCluster(0)
104cdf0e10cSrcweir 		, bPush(false)
105cdf0e10cSrcweir 		, bDelete(false)
106cdf0e10cSrcweir 		, bUntil(false)
107cdf0e10cSrcweir 				{}
SfxToDo_ImplSfxToDo_Impl108cdf0e10cSrcweir 	SfxToDo_Impl( bool bOpPush, bool bOpDelete, bool bOpUntil, SfxShell& rCluster )
109cdf0e10cSrcweir 		: pCluster(&rCluster)
110cdf0e10cSrcweir 		, bPush(bOpPush)
111cdf0e10cSrcweir 		, bDelete(bOpDelete)
112cdf0e10cSrcweir 		, bUntil(bOpUntil)
113cdf0e10cSrcweir 				{}
~SfxToDo_ImplSfxToDo_Impl114cdf0e10cSrcweir 	~SfxToDo_Impl(){}
115cdf0e10cSrcweir 
operator ==SfxToDo_Impl116cdf0e10cSrcweir 	bool operator==( const SfxToDo_Impl& rWith ) const
117cdf0e10cSrcweir 	{ return pCluster==rWith.pCluster && bPush==rWith.bPush; }
118cdf0e10cSrcweir };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir DECL_OBJSTACK(SfxToDoStack_Impl, SfxToDo_Impl, 8, 4);
121cdf0e10cSrcweir IMPL_OBJSTACK(SfxToDoStack_Impl, SfxToDo_Impl);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir struct SfxObjectBars_Impl
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	sal_uInt32          nResId;	// Resource - und ConfigId der Toolbox
126cdf0e10cSrcweir 	sal_uInt16          nMode;	// spezielle Sichtbarkeitsflags
127cdf0e10cSrcweir 	String   			aName;
128cdf0e10cSrcweir 	SfxInterface*		pIFace;
129cdf0e10cSrcweir 
SfxObjectBars_ImplSfxObjectBars_Impl130cdf0e10cSrcweir 	SfxObjectBars_Impl() :
131cdf0e10cSrcweir 		nResId( 0 )
132cdf0e10cSrcweir 	{}
133cdf0e10cSrcweir };
134cdf0e10cSrcweir 
135cdf0e10cSrcweir //------------------------------------------------------------------
136cdf0e10cSrcweir 
137cdf0e10cSrcweir struct SfxDispatcher_Impl
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     SfxRequestPtrArray      aReqArr;
140cdf0e10cSrcweir 	const SfxSlotServer* pCachedServ1;		 // zuletzt gerufene Message
141cdf0e10cSrcweir 	const SfxSlotServer* pCachedServ2;		 // vorletzt gerufene Message
142cdf0e10cSrcweir 	SfxShellStack_Impl		aStack; 			// aktive Funktionalitaet
143cdf0e10cSrcweir 	Timer					aTimer; 			// fuers flushen
144cdf0e10cSrcweir 	SfxToDoStack_Impl		aToDoStack; 		// nicht abgearb. Push/Pop
145cdf0e10cSrcweir 	SfxViewFrame*           pFrame;         	// 0 oder zugeh"or. Frame
146cdf0e10cSrcweir 	SfxDispatcher*			pParent;			// z.B. AppDispatcher, ggf. 0
147cdf0e10cSrcweir 	SfxHintPosterRef		xPoster;			// asynchrones Execute
148cdf0e10cSrcweir 	sal_Bool                    bFlushing;      	// sal_True waehrend Flush //?
149cdf0e10cSrcweir 	sal_Bool					bUpdated;			// Update_Impl gelaufen
150cdf0e10cSrcweir 	sal_Bool                    bLocked;        	// kein Execute
151cdf0e10cSrcweir 	sal_Bool					bInvalidateOnUnlock;// da fragte jemand
152cdf0e10cSrcweir 	sal_Bool					bActive;			// nicht verwechseln mit gesetzt!
153cdf0e10cSrcweir 	sal_Bool*   				pInCallAliveFlag;   // dem Stack den Dtor anzeigen
154cdf0e10cSrcweir 	SfxObjectBars_Impl		aObjBars[SFX_OBJECTBAR_MAX];
155cdf0e10cSrcweir 	SfxObjectBars_Impl		aFixedObjBars[SFX_OBJECTBAR_MAX];
156cdf0e10cSrcweir 	SvULongs				aChildWins;
157cdf0e10cSrcweir 	sal_uInt32					nEventId;			// EventId UserEvent
158cdf0e10cSrcweir 	sal_Bool					bUILocked;			// Update abgeklemmt (!zappeln)
159cdf0e10cSrcweir 	sal_Bool					bNoUI;				// UI nur vom Parent Dispatcher
160cdf0e10cSrcweir 	sal_Bool					bReadOnly;			// Dokument ist ReadOnly
161cdf0e10cSrcweir 	sal_Bool					bQuiet;             // nur parent dispatcher verwenden
162cdf0e10cSrcweir 	sal_Bool					bModal;             // nur Slots vom Parent-Dispatcher
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	sal_Bool					bFilterEnabling;	// sal_True=filter enabled slots, 2==ReadOnlyDoc uebersteuert
165cdf0e10cSrcweir 	sal_uInt16					nFilterCount;		// Anzahl der SIDs in pFilterSIDs
166cdf0e10cSrcweir 	const sal_uInt16*			pFilterSIDs;		// sortiertes Array von SIDs
167cdf0e10cSrcweir 	sal_uInt16					nStandardMode;		// ExecuteMode f. PlugInDispatcher
168cdf0e10cSrcweir 	SvUShorts*				pDisableList;
169cdf0e10cSrcweir 	sal_uInt32					nDisableFlags;
170cdf0e10cSrcweir };
171cdf0e10cSrcweir 
172cdf0e10cSrcweir #define NO_OBJECTBAR	0
173cdf0e10cSrcweir #define OWN_OBJECTBAR	1
174cdf0e10cSrcweir #define OTHER_OBJECTBAR 2
175cdf0e10cSrcweir 
176cdf0e10cSrcweir //------------------------------------------------------------------
177cdf0e10cSrcweir 
178cdf0e10cSrcweir #define SFX_FLUSH_TIMEOUT    50
179cdf0e10cSrcweir 
180cdf0e10cSrcweir //====================================================================
IsLocked(sal_uInt16) const181cdf0e10cSrcweir sal_Bool SfxDispatcher::IsLocked( sal_uInt16 ) const
182cdf0e10cSrcweir 
183cdf0e10cSrcweir /*  [Beschreibung]
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	Mit dieser Methode kann festgestellt werden, ob der SfxDispatcher
186cdf0e10cSrcweir 	gesperrt oder freigegeben ist. Ein gesperrter SfxDispatcher
187cdf0e10cSrcweir 	f"uhrt keine <SfxRequest>s mehr aus und liefert keine
188cdf0e10cSrcweir 	Status-Informationen mehr. Er verh"alt sich so als w"aren alle
189cdf0e10cSrcweir 	Slots disabled.
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	Der Dispatcher gilt auch als gesperrt, wenn alle Dispatcher
192cdf0e10cSrcweir 	gelockt sind (<SfxApplication::LockDispatcher()>) oder der zugeh"orige
193cdf0e10cSrcweir 	Top-Frame im modal-mode ist und der angegebene Slot Frame-spezifisch
194cdf0e10cSrcweir 	(also nicht von der Application) bedient wird.
195cdf0e10cSrcweir */
196cdf0e10cSrcweir 
197cdf0e10cSrcweir {
198cdf0e10cSrcweir     return pImp->bLocked;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //--------------------------------------------------------------------
IsAppDispatcher() const202cdf0e10cSrcweir sal_Bool SfxDispatcher::IsAppDispatcher() const
203cdf0e10cSrcweir 
204cdf0e10cSrcweir /*	[Beschreibung]
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 	Mit dieser Methode l"a\st sich festellen, ob der SfxDispacher der
207cdf0e10cSrcweir 	Applikations-Dispatcher ist.
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	[R"uckgabewert]
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 	sal_Bool				sal_True
213cdf0e10cSrcweir 						Es ist der Applikations-Dispatcher.
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 						sal_False
216cdf0e10cSrcweir 						Es ist ein Dispatcher eines SfxViewFrame.
217cdf0e10cSrcweir */
218cdf0e10cSrcweir 
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     return !pImp->pFrame;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir //--------------------------------------------------------------------
Call_Impl(SfxShell & rShell,const SfxSlot & rSlot,SfxRequest & rReq,sal_Bool bRecord)224cdf0e10cSrcweir int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, sal_Bool bRecord )
225cdf0e10cSrcweir 
226cdf0e10cSrcweir /*	[Beschreibung]
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	Hilfsfunktion zum pr"ufen, ob ein Slot executed werden darf und
229cdf0e10cSrcweir 	der Execution selbst.
230cdf0e10cSrcweir */
231cdf0e10cSrcweir 
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::Call_Impl);
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	// darf der Slot gerufen werden (i.S.v. enabled)
236cdf0e10cSrcweir 	if ( rSlot.IsMode(SFX_SLOT_FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) )
237cdf0e10cSrcweir 	{
238cdf0e10cSrcweir         if ( GetFrame() )
239cdf0e10cSrcweir         {
240cdf0e10cSrcweir             // ggf. Recording anwerfen
241cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
242cdf0e10cSrcweir                     GetFrame()->GetFrame().GetFrameInterface(),
243cdf0e10cSrcweir                     com::sun::star::uno::UNO_QUERY);
244cdf0e10cSrcweir 
245cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
246cdf0e10cSrcweir                     xFrame,
247cdf0e10cSrcweir                     com::sun::star::uno::UNO_QUERY);
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 			if ( xSet.is() )
250cdf0e10cSrcweir 			{
251cdf0e10cSrcweir 				com::sun::star::uno::Any aProp = xSet->getPropertyValue(::rtl::OUString::createFromAscii("DispatchRecorderSupplier"));
252cdf0e10cSrcweir 	            com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
253cdf0e10cSrcweir 	            com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
254cdf0e10cSrcweir 	            aProp >>= xSupplier;
255cdf0e10cSrcweir 	            if(xSupplier.is())
256cdf0e10cSrcweir 	                xRecorder = xSupplier->getDispatchRecorder();
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	            if ( bRecord && xRecorder.is() && !rSlot.IsMode(SFX_SLOT_NORECORD) )
259cdf0e10cSrcweir 	                rReq.Record_Impl( rShell, rSlot, xRecorder, GetFrame() );
260cdf0e10cSrcweir 			}
261cdf0e10cSrcweir         }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 		// Alles holen, was gebraucht wird, da der Slot den Execute evtl. nicht
264cdf0e10cSrcweir 		// "uberlebt, falls es ein 'Pseudoslot' f"ur Macros oder Verben ist
265cdf0e10cSrcweir 		sal_Bool bAutoUpdate = rSlot.IsMode(SFX_SLOT_AUTOUPDATE);
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 		// API-Call-Klammerung und Document-Lock w"ahrend des Calls
268cdf0e10cSrcweir 		{
269cdf0e10cSrcweir 			// 'this' mu\s im Dtor bescheid sagen
270cdf0e10cSrcweir 			sal_Bool bThisDispatcherAlive = sal_True;
271cdf0e10cSrcweir 			sal_Bool *pOldInCallAliveFlag = pImp->pInCallAliveFlag;
272cdf0e10cSrcweir 			pImp->pInCallAliveFlag = &bThisDispatcherAlive;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir             SfxViewFrame* pView = GetFrame();
275cdf0e10cSrcweir             if ( !pView )
276cdf0e10cSrcweir                 pView = SfxViewFrame::Current();
277cdf0e10cSrcweir             if ( pView )
278cdf0e10cSrcweir             {
279cdf0e10cSrcweir                 rtl::OString aCmd(".uno:");
280cdf0e10cSrcweir                 aCmd += rSlot.GetUnoName();
281cdf0e10cSrcweir                 SfxHelp::OpenHelpAgent( &pView->GetFrame(), aCmd );
282cdf0e10cSrcweir             }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir             SfxExecFunc pFunc = rSlot.GetExecFnc();
285cdf0e10cSrcweir             rShell.CallExec( pFunc, rReq );
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 			// falls 'this' noch lebt
288cdf0e10cSrcweir 			if ( bThisDispatcherAlive )
289cdf0e10cSrcweir 				pImp->pInCallAliveFlag = pOldInCallAliveFlag;
290cdf0e10cSrcweir 			else
291cdf0e10cSrcweir             {
292cdf0e10cSrcweir                 if ( pOldInCallAliveFlag )
293cdf0e10cSrcweir                 {
294cdf0e10cSrcweir                     // auch verschachtelte Stack-Frames sch"utzen
295cdf0e10cSrcweir                     *pOldInCallAliveFlag = sal_False;
296cdf0e10cSrcweir                 }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir                 // do nothing after this object is dead
299cdf0e10cSrcweir                 return rReq.IsDone();
300cdf0e10cSrcweir             }
301cdf0e10cSrcweir 		}
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 		if ( rReq.IsDone() )
304cdf0e10cSrcweir 		{
305cdf0e10cSrcweir             SfxBindings *pBindings = GetBindings();
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 			// bei AutoUpdate sofort updaten; "Pseudoslots" d"urfen nicht
308cdf0e10cSrcweir 			// Autoupdate sein!
309cdf0e10cSrcweir             if ( bAutoUpdate && pBindings )
310cdf0e10cSrcweir 			{
311cdf0e10cSrcweir 				const SfxSlot* pSlave = rSlot.GetLinkedSlot();
312cdf0e10cSrcweir 				if (pSlave)
313cdf0e10cSrcweir 				{
314cdf0e10cSrcweir 					// bei Enum-Slots irgendeinen gebundenen Slave-Slot nehmen
315cdf0e10cSrcweir 					while (!pBindings->IsBound(pSlave->GetSlotId()) && pSlave != &rSlot )
316cdf0e10cSrcweir 						pSlave = pSlave->GetLinkedSlot();
317cdf0e10cSrcweir 					pBindings->Invalidate(pSlave->GetSlotId());
318cdf0e10cSrcweir 					pBindings->Update(pSlave->GetSlotId());
319cdf0e10cSrcweir 				}
320cdf0e10cSrcweir 				else
321cdf0e10cSrcweir 				{
322cdf0e10cSrcweir 					pBindings->Invalidate(rSlot.GetSlotId());
323cdf0e10cSrcweir 					pBindings->Update(rSlot.GetSlotId());
324cdf0e10cSrcweir 				}
325cdf0e10cSrcweir 			}
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 			return sal_True;
328cdf0e10cSrcweir 		}
329cdf0e10cSrcweir 	}
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	return sal_False;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir //====================================================================
Construct_Impl(SfxDispatcher * pParent)335cdf0e10cSrcweir void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	pImp = new SfxDispatcher_Impl;
338cdf0e10cSrcweir 	bFlushed = sal_True;
339cdf0e10cSrcweir 	SfxApplication *pSfxApp = SFX_APP();
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 	pImp->pCachedServ1 = 0;
342cdf0e10cSrcweir 	pImp->pCachedServ2 = 0;
343cdf0e10cSrcweir 	pImp->bFlushing = sal_False;
344cdf0e10cSrcweir 	pImp->bUpdated = sal_False;
345cdf0e10cSrcweir 	pImp->bLocked = sal_False;
346cdf0e10cSrcweir 	pImp->bActive = sal_False;
347cdf0e10cSrcweir 	pImp->pParent = NULL;
348cdf0e10cSrcweir 	pImp->bUILocked = sal_False;
349cdf0e10cSrcweir 	pImp->bNoUI = sal_False;
350cdf0e10cSrcweir 	pImp->bReadOnly = sal_False;
351cdf0e10cSrcweir 	pImp->bQuiet = sal_False;
352cdf0e10cSrcweir 	pImp->bModal = sal_False;
353cdf0e10cSrcweir 	pImp->pInCallAliveFlag = 0;
354cdf0e10cSrcweir 	pImp->bFilterEnabling = sal_False;
355cdf0e10cSrcweir 	pImp->nFilterCount = 0;
356cdf0e10cSrcweir 	pImp->pFilterSIDs = 0;
357cdf0e10cSrcweir 	pImp->nStandardMode = 0;
358cdf0e10cSrcweir 	pImp->pDisableList = pSfxApp->GetDisabledSlotList_Impl();
359cdf0e10cSrcweir 	pImp->nDisableFlags = 0;
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 	pImp->pParent = pParent;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	pImp->bInvalidateOnUnlock = sal_False;
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
366cdf0e10cSrcweir 		pImp->aObjBars[n].nResId = 0;
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	GenLink aGenLink( LINK(this, SfxDispatcher, PostMsgHandler) );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	pImp->xPoster = new SfxHintPoster(aGenLink);
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
373cdf0e10cSrcweir 	pImp->aTimer.SetTimeoutHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
SfxDispatcher(SfxDispatcher * pParent)376cdf0e10cSrcweir SfxDispatcher::SfxDispatcher( SfxDispatcher* pParent )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir 	Construct_Impl( pParent );
379cdf0e10cSrcweir 	pImp->pFrame = 0;
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
SfxDispatcher(SfxViewFrame * pViewFrame)382cdf0e10cSrcweir SfxDispatcher::SfxDispatcher( SfxViewFrame *pViewFrame )
383cdf0e10cSrcweir 
384cdf0e10cSrcweir /*	[Beschreibung]
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 	Der Konstruktor der Klasse SfxDispatcher legt einen leeren Stack
387cdf0e10cSrcweir 	von <SfxShell>-Pointern an. Er ist initial nicht gelockt und gilt als
388cdf0e10cSrcweir 	geflusht.
389cdf0e10cSrcweir */
390cdf0e10cSrcweir 
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	if ( pViewFrame )
393cdf0e10cSrcweir 	{
394cdf0e10cSrcweir 		SfxViewFrame *pFrame = pViewFrame->GetParentViewFrame();
395cdf0e10cSrcweir 		if ( pFrame )
396cdf0e10cSrcweir 			Construct_Impl(  pFrame->GetDispatcher() );
397cdf0e10cSrcweir         else
398cdf0e10cSrcweir             Construct_Impl( 0 );
399cdf0e10cSrcweir 	}
400cdf0e10cSrcweir 	else
401cdf0e10cSrcweir 		Construct_Impl( 0 );
402cdf0e10cSrcweir 	pImp->pFrame = pViewFrame;
403cdf0e10cSrcweir }
404cdf0e10cSrcweir 
405cdf0e10cSrcweir //====================================================================
~SfxDispatcher()406cdf0e10cSrcweir SfxDispatcher::~SfxDispatcher()
407cdf0e10cSrcweir 
408cdf0e10cSrcweir /*	[Beschreibung]
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	Der Destruktor der Klasse SfxDispatcher darf nicht gerufen werden,
411cdf0e10cSrcweir 	wenn die SfxDispatcher-Instanz aktiv ist. Es d"urfen sich allerdings
412cdf0e10cSrcweir 	noch <SfxShell>-Pointer auf dem Stack befinden.
413cdf0e10cSrcweir */
414cdf0e10cSrcweir 
415cdf0e10cSrcweir {
416cdf0e10cSrcweir #ifdef DBG_UTIL
417cdf0e10cSrcweir 	ByteString sTemp( "Delete Dispatcher " );
418cdf0e10cSrcweir 	sTemp += ByteString::CreateFromInt64( (sal_uIntPtr)this );
419cdf0e10cSrcweir 	DBG_TRACE( sTemp.GetBuffer() );
420cdf0e10cSrcweir 	DBG_ASSERT( !pImp->bActive, "deleting active Dispatcher" );
421cdf0e10cSrcweir #endif
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	// Damit in LeaveRegistrations kein Timer per Reschedule in PlugComm
424cdf0e10cSrcweir 	// zuschlaegt
425cdf0e10cSrcweir 	pImp->aTimer.Stop();
426cdf0e10cSrcweir 	pImp->xPoster->SetEventHdl( Link() );
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	// die Stack-Varialblem in Call_Impl benachrichtigen
429cdf0e10cSrcweir 	if ( pImp->pInCallAliveFlag )
430cdf0e10cSrcweir 		*pImp->pInCallAliveFlag = sal_False;
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 	// Bindings und App besorgen
433cdf0e10cSrcweir 	SfxApplication *pSfxApp = SFX_APP();
434cdf0e10cSrcweir     SfxBindings* pBindings = GetBindings();
435cdf0e10cSrcweir 
436cdf0e10cSrcweir //	if (pImp->nEventId)
437cdf0e10cSrcweir //		pSfxApp->RemoveEventHdl(pImp->nEventId);
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	// wenn noch nicht flushed, die Bindings wiederbeleben
440cdf0e10cSrcweir     if ( pBindings && !pSfxApp->IsDowning() && !bFlushed )
441cdf0e10cSrcweir         pBindings->DLEAVEREGISTRATIONS();
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	// ggf. bei den Bindings abmelden
444cdf0e10cSrcweir     while ( pBindings )
445cdf0e10cSrcweir 	{
446cdf0e10cSrcweir         if ( pBindings->GetDispatcher_Impl() == this)
447cdf0e10cSrcweir             pBindings->SetDispatcher(0);
448cdf0e10cSrcweir         pBindings = pBindings->GetSubBindings_Impl();
449cdf0e10cSrcweir 	}
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	delete pImp;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir //====================================================================
Pop(SfxShell & rShell,sal_uInt16 nMode)455cdf0e10cSrcweir void SfxDispatcher::Pop
456cdf0e10cSrcweir (
457cdf0e10cSrcweir 	SfxShell&   rShell,     /*  Die vom Stack zu nehmende SfxShell-Instanz. */
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	sal_uInt16      nMode       /*  SFX_SHELL_POP_UNTIL
460cdf0e10cSrcweir 								Es werden auch alle "uber 'rShell' liegenenden
461cdf0e10cSrcweir 								SfxShell's vom Stack genommen.
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 								SFX_SHELL_POP_DELETE
464cdf0e10cSrcweir 								Alle tats"achlich vom Stack genommenen
465cdf0e10cSrcweir 								SfxShells werden gel"oscht.
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 								SFX_SHELL_PUSH (InPlace use only)
468cdf0e10cSrcweir 								Die Shell wird gepusht. */
469cdf0e10cSrcweir )
470cdf0e10cSrcweir /*  [Beschreibung]
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 	Mit dieser Methode wird eine oder mehrere <SfxShell> vom SfxDispatcher
473cdf0e10cSrcweir 	gepoppt. Die SfxShell wird zun"achst zum poppen vermerkt und
474cdf0e10cSrcweir 	es wird ein Timer aufgesetzt. Erst bei Ablauf des Timers wird
475cdf0e10cSrcweir 	tats"achlich gepoppt (<SfxDispatcher::Flush()>) und die <SfxBindings>
476cdf0e10cSrcweir 	werden invalidiert. W"ahrend der Timer l"auft gleichen sich
477cdf0e10cSrcweir 	entgegengesetzte Push und Pop Befehle mit derselben SfxShell aus.
478cdf0e10cSrcweir */
479cdf0e10cSrcweir 
480cdf0e10cSrcweir {
481cdf0e10cSrcweir 	DBG_MEMTEST();
482cdf0e10cSrcweir 	DBG_ASSERT( rShell.GetInterface(),
483cdf0e10cSrcweir 				"pushing SfxShell without previous RegisterInterface()" );
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	bool bDelete = (nMode & SFX_SHELL_POP_DELETE) == SFX_SHELL_POP_DELETE;
486cdf0e10cSrcweir 	bool bUntil = (nMode & SFX_SHELL_POP_UNTIL) == SFX_SHELL_POP_UNTIL;
487cdf0e10cSrcweir 	bool bPush = (nMode & SFX_SHELL_PUSH) == SFX_SHELL_PUSH;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 	SfxApplication *pSfxApp = SFX_APP();
490cdf0e10cSrcweir 
491cdf0e10cSrcweir #ifdef DBG_UTIL
492cdf0e10cSrcweir 	ByteString aMsg( "-SfxDispatcher(" );
493cdf0e10cSrcweir 	aMsg += ByteString::CreateFromInt64( (sal_uIntPtr) this );
494cdf0e10cSrcweir 	aMsg += bPush ? ")::Push(" : ")::Pop(";
495cdf0e10cSrcweir 	if ( rShell.GetInterface() )
496cdf0e10cSrcweir 		aMsg += rShell.GetInterface()->GetClassName();
497cdf0e10cSrcweir 	else
498cdf0e10cSrcweir 		aMsg += ByteString::CreateFromInt64( (sal_uIntPtr) &rShell );
499cdf0e10cSrcweir 	aMsg += bDelete ? ") with delete" : ")";
500cdf0e10cSrcweir     if ( bUntil ) aMsg += " (up to)";
501cdf0e10cSrcweir 	DbgTrace( aMsg.GetBuffer() );
502cdf0e10cSrcweir #endif
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	// gleiche Shell wie on-Top des ToDo-Stacks?
505cdf0e10cSrcweir 	if ( pImp->aToDoStack.Count() && pImp->aToDoStack.Top().pCluster == &rShell )
506cdf0e10cSrcweir 	{
507cdf0e10cSrcweir 		// inverse Actions heben sich auf
508cdf0e10cSrcweir 		if ( pImp->aToDoStack.Top().bPush != bPush )
509cdf0e10cSrcweir 			pImp->aToDoStack.Pop();
510cdf0e10cSrcweir 		else
511cdf0e10cSrcweir 		{
512cdf0e10cSrcweir 			DBG_ASSERT( bPush, "SfxInterface pushed more than once" );
513cdf0e10cSrcweir 			DBG_ASSERT( !bPush, "SfxInterface popped more than once" );
514cdf0e10cSrcweir 		}
515cdf0e10cSrcweir 	}
516cdf0e10cSrcweir 	else
517cdf0e10cSrcweir 	{
518cdf0e10cSrcweir 		// ::com::sun::star::chaos::Action merken
519cdf0e10cSrcweir 		pImp->aToDoStack.Push( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
520cdf0e10cSrcweir 		if ( bFlushed )
521cdf0e10cSrcweir 		{
522cdf0e10cSrcweir 			DBG_TRACE("Unflushed dispatcher!");
523cdf0e10cSrcweir 			bFlushed = sal_False;
524cdf0e10cSrcweir 			pImp->bUpdated = sal_False;
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 			// Bindings schlafen legen
527cdf0e10cSrcweir             SfxBindings* pBindings = GetBindings();
528cdf0e10cSrcweir             if ( pBindings )
529cdf0e10cSrcweir                 pBindings->DENTERREGISTRATIONS();
530cdf0e10cSrcweir 		}
531cdf0e10cSrcweir 	}
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 	if ( !pSfxApp->IsDowning() && pImp->aToDoStack.Count() )
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		//! if (SFX_APP()->AnyInput(INPUT_KEYBOARD | INPUT_MOUSE) )
536cdf0e10cSrcweir 		//! AnyInput haut nicht hin; hier muss noch ein Kriterium gefunden
537cdf0e10cSrcweir 		//! werden. Solange wieder immer mit Timer.
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 		if (sal_True)
540cdf0e10cSrcweir 		{
541cdf0e10cSrcweir 			// Kein sofortiges Update gewuenscht
542cdf0e10cSrcweir 			pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
543cdf0e10cSrcweir 			pImp->aTimer.SetTimeoutHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
544cdf0e10cSrcweir 			pImp->aTimer.Start();
545cdf0e10cSrcweir 		}
546cdf0e10cSrcweir 		else
547cdf0e10cSrcweir 		{
548cdf0e10cSrcweir 			// Schnellstmoegliches Update (sollte Normalfall sein)
549cdf0e10cSrcweir 			pImp->aTimer.Stop();
550cdf0e10cSrcweir 			GetpApp()->PostUserEvent(pImp->nEventId, (void*)0);
551cdf0e10cSrcweir 		}
552cdf0e10cSrcweir 	}
553cdf0e10cSrcweir 	else
554cdf0e10cSrcweir 	{
555cdf0e10cSrcweir 		// doch nichts zu tun
556cdf0e10cSrcweir 		pImp->aTimer.Stop();
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 		// ggf. Bindings wieder aufwecken
559cdf0e10cSrcweir 		if ( !pImp->aToDoStack.Count() )
560cdf0e10cSrcweir 		{
561cdf0e10cSrcweir             SfxBindings* pBindings = GetBindings();
562cdf0e10cSrcweir             if ( pBindings )
563cdf0e10cSrcweir                 pBindings->DLEAVEREGISTRATIONS();
564cdf0e10cSrcweir 		}
565cdf0e10cSrcweir 	}
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir //--------------------------------------------------------------------
569cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(SfxDispatcher,EventHdl_Impl,void *,pvoid)570cdf0e10cSrcweir IMPL_LINK_INLINE_START( SfxDispatcher, EventHdl_Impl, void *, pvoid )
571cdf0e10cSrcweir 
572cdf0e10cSrcweir /*	[Beschreibung]
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 	Dieser Handler wird nach <SfxDispatcher::Invalidate()> oder Bewegungen
575cdf0e10cSrcweir 	auf dem Stack (<SfxDispatcher::Push()> und <SfxDispatcher::Pop()) gerufen.
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 	Er flusht den Stack, falls er dirty ist, f"uhrt also die ausstehenden
578cdf0e10cSrcweir 	Push und Pop Befehle tats"achlich aus.
579cdf0e10cSrcweir */
580cdf0e10cSrcweir 
581cdf0e10cSrcweir {
582cdf0e10cSrcweir     (void)pvoid; // unused
583cdf0e10cSrcweir     DBG_MEMTEST();
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 	Flush();
586cdf0e10cSrcweir 	Update_Impl();
587cdf0e10cSrcweir     SfxBindings* pBindings = GetBindings();
588cdf0e10cSrcweir     if ( pBindings )
589cdf0e10cSrcweir         pBindings->StartUpdate_Impl(sal_False);
590cdf0e10cSrcweir 	return 0;
591cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SfxDispatcher,EventHdl_Impl,void *,pvoid)592cdf0e10cSrcweir IMPL_LINK_INLINE_END( SfxDispatcher, EventHdl_Impl, void *, pvoid )
593cdf0e10cSrcweir 
594cdf0e10cSrcweir //--------------------------------------------------------------------
595cdf0e10cSrcweir sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDeep )
596cdf0e10cSrcweir 
597cdf0e10cSrcweir /*	[Beschreibung]
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 	Mit dieser Methode kann gepr"uft werden, ob sich die <SfxShell> rShell
600cdf0e10cSrcweir 	auf dem Stack befindet, wenn er geflusht w"are. Dabei wird der
601cdf0e10cSrcweir 	SfxDispatcher jedoch nicht tats"achlich geflusht.
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 	Diese Methode ist u.a. dazu gedacht, Assertions zu erm"oglichen, ohne
604cdf0e10cSrcweir 	als Seiteneffekt den SfxDispathcer flushen zu m"ussen.
605cdf0e10cSrcweir */
606cdf0e10cSrcweir 
607cdf0e10cSrcweir {
608cdf0e10cSrcweir 	DBG_MEMTEST();
609cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::CheckVirtualStack);
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 	SfxShellStack_Impl aStack( pImp->aStack );
612cdf0e10cSrcweir 	for ( short nToDo = pImp->aToDoStack.Count()-1; nToDo >= 0; --nToDo )
613cdf0e10cSrcweir 	{
614cdf0e10cSrcweir 		SfxToDo_Impl aToDo( pImp->aToDoStack.Top(nToDo) );
615cdf0e10cSrcweir 		if ( aToDo.bPush )
616cdf0e10cSrcweir 			aStack.Push( (SfxShell*) aToDo.pCluster );
617cdf0e10cSrcweir 		else
618cdf0e10cSrcweir 		{
619cdf0e10cSrcweir 			SfxShell* pPopped = 0;
620cdf0e10cSrcweir 			do
621cdf0e10cSrcweir 			{
622cdf0e10cSrcweir 				DBG_ASSERT( aStack.Count(), "popping from empty stack" );
623cdf0e10cSrcweir 				pPopped = aStack.Pop();
624cdf0e10cSrcweir 			}
625cdf0e10cSrcweir 			while ( aToDo.bUntil && pPopped != aToDo.pCluster );
626cdf0e10cSrcweir 			DBG_ASSERT( pPopped == aToDo.pCluster, "popping unpushed SfxInterface" );
627cdf0e10cSrcweir 		}
628cdf0e10cSrcweir 	}
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 	sal_Bool bReturn;
631cdf0e10cSrcweir 	if ( bDeep )
632cdf0e10cSrcweir 		bReturn = aStack.Contains(&rShell);
633cdf0e10cSrcweir 	else
634cdf0e10cSrcweir 		bReturn = aStack.Top() == &rShell;
635cdf0e10cSrcweir 	return bReturn;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
638cdf0e10cSrcweir //--------------------------------------------------------------------
GetShellLevel(const SfxShell & rShell)639cdf0e10cSrcweir sal_uInt16 SfxDispatcher::GetShellLevel( const SfxShell& rShell )
640cdf0e10cSrcweir 
641cdf0e10cSrcweir /*	[Beschreibung]
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 	Ermittelt die Position einer SfxShell im Stack des Dispatchers.
644cdf0e10cSrcweir 	Dazu wird dieser ggf. zuvor geflusht.
645cdf0e10cSrcweir 
646cdf0e10cSrcweir 
647cdf0e10cSrcweir     [Rueckgabewert]
648cdf0e10cSrcweir 
649cdf0e10cSrcweir 	sal_uInt16						== USRT_MAX
650cdf0e10cSrcweir 								Die SfxShell befindet sich nicht auf
651cdf0e10cSrcweir 								diesem SfxDispatcher.
652cdf0e10cSrcweir 
653cdf0e10cSrcweir 								< USHRT_MAX
654cdf0e10cSrcweir 								Position der SfxShell auf dem Dispatcher
655cdf0e10cSrcweir 								von oben mit 0 beginnend gez"ahlt.
656cdf0e10cSrcweir */
657cdf0e10cSrcweir 
658cdf0e10cSrcweir {
659cdf0e10cSrcweir 	DBG_MEMTEST();
660cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::GetShellLevel);
661cdf0e10cSrcweir 	Flush();
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 	for ( sal_uInt16 n = 0; n < pImp->aStack.Count(); ++n )
664cdf0e10cSrcweir 		if ( pImp->aStack.Top( n ) == &rShell )
665cdf0e10cSrcweir 			return n;
666cdf0e10cSrcweir 	if ( pImp->pParent )
667cdf0e10cSrcweir     {
668cdf0e10cSrcweir         sal_uInt16 nRet = pImp->pParent->GetShellLevel(rShell);
669cdf0e10cSrcweir         if ( nRet == USHRT_MAX )
670cdf0e10cSrcweir             return nRet;
671cdf0e10cSrcweir         return  nRet + pImp->aStack.Count();
672cdf0e10cSrcweir     }
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	return USHRT_MAX;
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir //--------------------------------------------------------------------
GetShell(sal_uInt16 nIdx) const678cdf0e10cSrcweir SfxShell *SfxDispatcher::GetShell(sal_uInt16 nIdx) const
679cdf0e10cSrcweir 
680cdf0e10cSrcweir /*	[Beschreibung]
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 	Liefert einen Pointer auf die <SfxShell>, welche sich an der Position
683cdf0e10cSrcweir 	nIdx (von oben, letzt-gepushte liegt bei 0) auf dem Stack befindet.
684cdf0e10cSrcweir 
685cdf0e10cSrcweir 	Dabei wird der SfxDispatcher nicht geflusht.
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 	Ist der Stack nicht tief genug, wird ein 0-Pointer zur"uckgegeben.
688cdf0e10cSrcweir */
689cdf0e10cSrcweir 
690cdf0e10cSrcweir {
691cdf0e10cSrcweir 	DBG_MEMTEST();
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	sal_uInt16 nShellCount = pImp->aStack.Count();
694cdf0e10cSrcweir 	if ( nIdx < nShellCount )
695cdf0e10cSrcweir 		return pImp->aStack.Top(nIdx);
696cdf0e10cSrcweir 	else if ( pImp->pParent )
697cdf0e10cSrcweir 		return pImp->pParent->GetShell(	nIdx - nShellCount );
698cdf0e10cSrcweir 	return 0;
699cdf0e10cSrcweir }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir //--------------------------------------------------------------------
GetBindings() const702cdf0e10cSrcweir SfxBindings* SfxDispatcher::GetBindings() const
703cdf0e10cSrcweir 
704cdf0e10cSrcweir /*	[Beschreibung]
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 	Diese Methode liefert einen Pointer auf die <SfxBindings> Instanz
707cdf0e10cSrcweir 	zur"uck, an die der SfxDispatcher gerade gebunden ist. Ein SfxDispatcher
708cdf0e10cSrcweir 	ist nur dann an SfxBindings gebunden, wenn er <UI-aktiv> ist. Ist
709cdf0e10cSrcweir 	er nicht UI-aktiv, wird ein 0-Pointer zur"uckgegeben.
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 	Der zur"uckgegebene Pointer ist nur im <unmittelbaren Kontext> des
712cdf0e10cSrcweir 	Methodenaufrufs g"ultig.
713cdf0e10cSrcweir */
714cdf0e10cSrcweir 
715cdf0e10cSrcweir {
716cdf0e10cSrcweir 	if ( pImp->pFrame )
717cdf0e10cSrcweir 		return &pImp->pFrame->GetBindings();
718cdf0e10cSrcweir     else
719cdf0e10cSrcweir         return NULL;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir 
722cdf0e10cSrcweir //--------------------------------------------------------------------
GetFrame() const723cdf0e10cSrcweir SfxViewFrame* SfxDispatcher::GetFrame() const
724cdf0e10cSrcweir 
725cdf0e10cSrcweir /*	[Beschreibung]
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	Liefert einen Pointer auf die <SfxViewFrame> Instanz, der dieser
728cdf0e10cSrcweir 	SfxDispatcher geh"ort. Falls es sich um den Applikations-Dispatcher
729cdf0e10cSrcweir 	handelt, wird ein 0-Pointer zur"uckgegeben.
730cdf0e10cSrcweir */
731cdf0e10cSrcweir 
732cdf0e10cSrcweir {
733cdf0e10cSrcweir 	DBG_MEMTEST();
734cdf0e10cSrcweir 	return pImp->pFrame;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir 
737cdf0e10cSrcweir //--------------------------------------------------------------------
DoActivate_Impl(sal_Bool bMDI,SfxViewFrame *)738cdf0e10cSrcweir void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ )
739cdf0e10cSrcweir 
740cdf0e10cSrcweir /*	[Beschreibung]
741cdf0e10cSrcweir 
742cdf0e10cSrcweir 	Diese Methode steuert das Aktivieren eines Dispatchers.
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 	Da der Applikations-Dispatcher immer aktiv ist, entweder als
745cdf0e10cSrcweir 	Unterdispatcher des <SfxViewFrame>-Dispatchers oder selbst, wird
746cdf0e10cSrcweir 	er nie als ganzes Aktiviert, sondern nur seine einzelnen <SfxShell>s
747cdf0e10cSrcweir 	bei <SfxDispatcher::Push(SfxShell&)>.
748cdf0e10cSrcweir 
749cdf0e10cSrcweir 	Beim Aktivieren eines SfxDispatchers wird an allen auf seinem
750cdf0e10cSrcweir 	Stack befindlichen SfxShells, beginnend mit der untersten, der Handler
751cdf0e10cSrcweir 	<SfxShell::Activate(sal_Bool)> gerufen.
752cdf0e10cSrcweir */
753cdf0e10cSrcweir 
754cdf0e10cSrcweir {
755cdf0e10cSrcweir 	DBG_MEMTEST();
756cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::DoActivate);
757cdf0e10cSrcweir 	if ( bMDI )
758cdf0e10cSrcweir 	{
759cdf0e10cSrcweir 		#ifdef DBG_UTIL
760cdf0e10cSrcweir 		ByteString sTemp("Activate Dispatcher ");
761cdf0e10cSrcweir 		sTemp += ByteString::CreateFromInt64( (sal_uIntPtr) this );
762cdf0e10cSrcweir 		DBG_TRACE(sTemp.GetBuffer());
763cdf0e10cSrcweir 		DBG_ASSERT( !pImp->bActive, "Activate-Fehler" );
764cdf0e10cSrcweir 		#endif
765cdf0e10cSrcweir 		pImp->bActive = sal_True;
766cdf0e10cSrcweir 		pImp->bUpdated = sal_False;
767cdf0e10cSrcweir         SfxBindings* pBindings = GetBindings();
768cdf0e10cSrcweir         if ( pBindings )
769cdf0e10cSrcweir         {
770cdf0e10cSrcweir             pBindings->SetDispatcher(this);
771cdf0e10cSrcweir             pBindings->SetActiveFrame( pImp->pFrame->GetFrame().GetFrameInterface() );
772cdf0e10cSrcweir         }
773cdf0e10cSrcweir 	}
774cdf0e10cSrcweir 	else
775cdf0e10cSrcweir 	{
776cdf0e10cSrcweir 		#ifdef DBG_UTIL
777cdf0e10cSrcweir 		ByteString sTemp("Non-MDI-Activate Dispatcher");
778cdf0e10cSrcweir 		sTemp += ByteString::CreateFromInt64( (sal_uIntPtr) this );
779cdf0e10cSrcweir 		DBG_TRACE( sTemp.GetBuffer() );
780cdf0e10cSrcweir 		#endif
781cdf0e10cSrcweir 	}
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 	if ( IsAppDispatcher() )
784cdf0e10cSrcweir 		return;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 	for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
787cdf0e10cSrcweir 		pImp->aStack.Top( (sal_uInt16) i )->DoActivate_Impl(pImp->pFrame, bMDI);
788cdf0e10cSrcweir 
789cdf0e10cSrcweir     if ( bMDI && pImp->pFrame )
790cdf0e10cSrcweir     {
791cdf0e10cSrcweir         //SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
792cdf0e10cSrcweir         SfxBindings *pBind = GetBindings();
793cdf0e10cSrcweir         while ( pBind )
794cdf0e10cSrcweir         {
795cdf0e10cSrcweir             pBind->HidePopupCtrls_Impl( sal_False );
796cdf0e10cSrcweir             pBind = pBind->GetSubBindings_Impl();
797cdf0e10cSrcweir         }
798cdf0e10cSrcweir 
799cdf0e10cSrcweir         pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( sal_False, sal_False, 1 );
800cdf0e10cSrcweir     }
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 	if ( pImp->aToDoStack.Count() )
803cdf0e10cSrcweir 	{
804cdf0e10cSrcweir 		if (sal_True)
805cdf0e10cSrcweir 		{
806cdf0e10cSrcweir 			// Kein sofortiges Update gewuenscht
807cdf0e10cSrcweir 			pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
808cdf0e10cSrcweir 			pImp->aTimer.SetTimeoutHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
809cdf0e10cSrcweir 			pImp->aTimer.Start();
810cdf0e10cSrcweir 		}
811cdf0e10cSrcweir 		else
812cdf0e10cSrcweir 		{
813cdf0e10cSrcweir 			// Schnellstmoegliches Update (sollte Normalfall sein)
814cdf0e10cSrcweir 			pImp->aTimer.Stop();
815cdf0e10cSrcweir 			GetpApp()->PostUserEvent(pImp->nEventId, (void*)0);
816cdf0e10cSrcweir 		}
817cdf0e10cSrcweir 	}
818cdf0e10cSrcweir }
819cdf0e10cSrcweir 
DoParentActivate_Impl()820cdf0e10cSrcweir void SfxDispatcher::DoParentActivate_Impl()
821cdf0e10cSrcweir {
822cdf0e10cSrcweir 	for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
823cdf0e10cSrcweir 		pImp->aStack.Top( (sal_uInt16) i )->ParentActivate();
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
826cdf0e10cSrcweir //--------------------------------------------------------------------
DoDeactivate_Impl(sal_Bool bMDI,SfxViewFrame * pNew)827cdf0e10cSrcweir void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew )
828cdf0e10cSrcweir 
829cdf0e10cSrcweir /*  [Beschreibung]
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 	Diese Methode steuert das Deaktivieren eines Dispatchers.
832cdf0e10cSrcweir 
833cdf0e10cSrcweir 	Da der Applikations-Dispatcher immer aktiv ist, entweder als
834cdf0e10cSrcweir 	Unterdispatcher des <SfxViewFrame>-Dispatchers oder selbst, wird
835cdf0e10cSrcweir 	er nie als ganzes Deaktiviert, sondern nur seine einzelnen <SfxShell>s
836cdf0e10cSrcweir 	bei <SfxDispatcher::Pop(SfxShell&)>.
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 	Beim Deaktivieren eines SfxDispatchers wird an allen auf seinem
839cdf0e10cSrcweir 	Stack befindlichen SfxShells, beginnend mit der obersten, der Handler
840cdf0e10cSrcweir 	<SfxShell::Deactivate(sal_Bool)> gerufen.
841cdf0e10cSrcweir */
842cdf0e10cSrcweir 
843cdf0e10cSrcweir {
844cdf0e10cSrcweir 	DBG_MEMTEST();
845cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::DoDeactivate);
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 	SfxApplication *pSfxApp = SFX_APP();
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 	if ( bMDI )
850cdf0e10cSrcweir 	{
851cdf0e10cSrcweir 		DBG_TRACE(ByteString("Deactivate Dispatcher ").Append(ByteString::CreateFromInt64( (sal_uIntPtr) this )).GetBuffer());
852cdf0e10cSrcweir 		DBG_ASSERT( pImp->bActive, "Deactivate-Fehler" );
853cdf0e10cSrcweir 		pImp->bActive = sal_False;
854cdf0e10cSrcweir 
855cdf0e10cSrcweir         if ( pImp->pFrame && !(pImp->pFrame->GetObjectShell()->IsInPlaceActive() ) )
856cdf0e10cSrcweir 		{
857cdf0e10cSrcweir             SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
858cdf0e10cSrcweir             if ( pWorkWin )
859cdf0e10cSrcweir             {
860cdf0e10cSrcweir                 for (sal_uInt16 n=0; n<pImp->aChildWins.Count();)
861cdf0e10cSrcweir                 {
862cdf0e10cSrcweir                     SfxChildWindow *pWin = pWorkWin->GetChildWindow_Impl( (sal_uInt16) ( pImp->aChildWins[n] & 0xFFFF ) );
863cdf0e10cSrcweir                     if (!pWin || (pWin && pWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT))
864cdf0e10cSrcweir                         pImp->aChildWins.Remove(n);
865cdf0e10cSrcweir                     else
866cdf0e10cSrcweir                         n++;
867cdf0e10cSrcweir                 }
868cdf0e10cSrcweir             }
869cdf0e10cSrcweir 		}
870cdf0e10cSrcweir 	}
871cdf0e10cSrcweir 	else {
872cdf0e10cSrcweir 		DBG_TRACE( ByteString ("Non-MDI-DeActivate Dispatcher").Append(ByteString::CreateFromInt64( (sal_uIntPtr) this )).GetBuffer() );
873cdf0e10cSrcweir     }
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 	if ( IsAppDispatcher() && !pSfxApp->IsDowning() )
876cdf0e10cSrcweir 		return;
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < pImp->aStack.Count(); ++i )
879cdf0e10cSrcweir 		pImp->aStack.Top(i)->DoDeactivate_Impl(pImp->pFrame, bMDI);
880cdf0e10cSrcweir 
881cdf0e10cSrcweir     sal_Bool bHidePopups = bMDI && pImp->pFrame;
882cdf0e10cSrcweir     if ( pNew && pImp->pFrame )
883cdf0e10cSrcweir     {
884cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xOldFrame(
885cdf0e10cSrcweir             pNew->GetFrame().GetFrameInterface()->getCreator(), com::sun::star::uno::UNO_QUERY );
886cdf0e10cSrcweir 
887cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xMyFrame(
888cdf0e10cSrcweir             GetFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
889cdf0e10cSrcweir 
890cdf0e10cSrcweir         if ( xOldFrame == xMyFrame )
891cdf0e10cSrcweir             bHidePopups = sal_False;
892cdf0e10cSrcweir     }
893cdf0e10cSrcweir 
894cdf0e10cSrcweir     if ( bHidePopups )
895cdf0e10cSrcweir     {
896cdf0e10cSrcweir         //SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
897cdf0e10cSrcweir         SfxBindings *pBind = GetBindings();
898cdf0e10cSrcweir         while ( pBind )
899cdf0e10cSrcweir         {
900cdf0e10cSrcweir             pBind->HidePopupCtrls_Impl( sal_True );
901cdf0e10cSrcweir             pBind = pBind->GetSubBindings_Impl();
902cdf0e10cSrcweir         }
903cdf0e10cSrcweir 
904cdf0e10cSrcweir         pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( sal_True, sal_False, 1 );
905cdf0e10cSrcweir     }
906cdf0e10cSrcweir 
907cdf0e10cSrcweir 	Flush();
908cdf0e10cSrcweir }
909cdf0e10cSrcweir 
DoParentDeactivate_Impl()910cdf0e10cSrcweir void SfxDispatcher::DoParentDeactivate_Impl()
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
913cdf0e10cSrcweir 		pImp->aStack.Top( (sal_uInt16) i )->ParentDeactivate();
914cdf0e10cSrcweir }
915cdf0e10cSrcweir 
916cdf0e10cSrcweir //--------------------------------------------------------------------
GetShellAndSlot_Impl(sal_uInt16 nSlot,SfxShell ** ppShell,const SfxSlot ** ppSlot,sal_Bool bOwnShellsOnly,sal_Bool bModal,sal_Bool bRealSlot)917cdf0e10cSrcweir int SfxDispatcher::GetShellAndSlot_Impl
918cdf0e10cSrcweir (
919cdf0e10cSrcweir 	sal_uInt16			nSlot,		// die zu suchende Slot-Id
920cdf0e10cSrcweir 	SfxShell**		ppShell,	// die SfxShell, welche nSlot z.Zt. bedient
921cdf0e10cSrcweir 	const SfxSlot** ppSlot, 	// der SfxSlot, welcher nSlot z.Zt. bedient
922cdf0e10cSrcweir 	sal_Bool			bOwnShellsOnly,
923cdf0e10cSrcweir 	sal_Bool			bModal,		// trotz ModalMode
924cdf0e10cSrcweir 	sal_Bool		bRealSlot
925cdf0e10cSrcweir )
926cdf0e10cSrcweir 
927cdf0e10cSrcweir /*	[Beschreibung]
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 	Diese Methode sucht im SfxDispatcher nach der <SfxShell>, von der
930cdf0e10cSrcweir 	die Slot-Id nSlot zur Zeit bedient wird. Dazu wird der Dispatcher
931cdf0e10cSrcweir 	zuvor geflusht.
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 	[R"uckgabewert]
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 	int 				sal_True
937cdf0e10cSrcweir 						Die SfxShell wurde gefunden, ppShell und ppSlot
938cdf0e10cSrcweir 						sind g"ultig.
939cdf0e10cSrcweir 
940cdf0e10cSrcweir 						sal_True
941cdf0e10cSrcweir 						Die SfxShell wurde nicht gefunden, ppShell und ppSlot
942cdf0e10cSrcweir 						sind ung"ultig.
943cdf0e10cSrcweir */
944cdf0e10cSrcweir 
945cdf0e10cSrcweir {
946cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::GetShellAndSlot_Impl);
947cdf0e10cSrcweir 
948cdf0e10cSrcweir 	Flush();
949cdf0e10cSrcweir 	SfxSlotServer aSvr;
950cdf0e10cSrcweir 	if ( _FindServer(nSlot, aSvr, bModal) )
951cdf0e10cSrcweir 	{
952cdf0e10cSrcweir 		if ( bOwnShellsOnly && aSvr.GetShellLevel() >= pImp->aStack.Count() )
953cdf0e10cSrcweir 			return sal_False;
954cdf0e10cSrcweir 
955cdf0e10cSrcweir 		*ppShell = GetShell(aSvr.GetShellLevel());
956cdf0e10cSrcweir 		*ppSlot = aSvr.GetSlot();
957cdf0e10cSrcweir 		if ( 0 == (*ppSlot)->GetExecFnc() && bRealSlot )
958cdf0e10cSrcweir 			*ppSlot = (*ppShell)->GetInterface()->GetRealSlot(*ppSlot);
959cdf0e10cSrcweir 		// Check only real slots as enum slots don't have an execute function!
960cdf0e10cSrcweir         if ( bRealSlot && ((0 == *ppSlot) || (0 == (*ppSlot)->GetExecFnc()) ))
961cdf0e10cSrcweir 			return sal_False;
962cdf0e10cSrcweir 
963cdf0e10cSrcweir #ifdef DBG_UTILx
964cdf0e10cSrcweir 		ByteString aMsg( nSlot );
965cdf0e10cSrcweir 		aMsg += " found in ";
966cdf0e10cSrcweir 		aMsg += (*ppShell)->GetInterface()->GetClassName();
967cdf0e10cSrcweir 		DbgTrace( aMsg.GetBuffer() );
968cdf0e10cSrcweir #endif
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 		return sal_True;
971cdf0e10cSrcweir 	}
972cdf0e10cSrcweir 
973cdf0e10cSrcweir #ifdef DBG_UTILx
974cdf0e10cSrcweir 	ByteString aMsg( nSlot );
975cdf0e10cSrcweir 	aMsg += " not found";
976cdf0e10cSrcweir 	DbgTrace( aMsg.GetBuffer() );
977cdf0e10cSrcweir #endif
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 	return sal_False;
980cdf0e10cSrcweir }
981cdf0e10cSrcweir 
982cdf0e10cSrcweir /*
983cdf0e10cSrcweir struct Executer : public SfxHint
984cdf0e10cSrcweir {
985cdf0e10cSrcweir     SfxRequest *pRequest;
986cdf0e10cSrcweir     const SfxSlot* pSlot;
987cdf0e10cSrcweir     sal_uInt16 nLevel;
988cdf0e10cSrcweir 
989cdf0e10cSrcweir     Executer( SfxRequest* pReq, const SfxSlot* p, sal_uInt16 n )
990cdf0e10cSrcweir         :  pRequest( pReq )
991cdf0e10cSrcweir         , pSlot(p)
992cdf0e10cSrcweir         , nLevel(n)
993cdf0e10cSrcweir         {}
994cdf0e10cSrcweir     ~Executer()
995cdf0e10cSrcweir     {delete pRequest;}
996cdf0e10cSrcweir };
997cdf0e10cSrcweir */
998cdf0e10cSrcweir 
999cdf0e10cSrcweir //--------------------------------------------------------------------
_Execute(SfxShell & rShell,const SfxSlot & rSlot,SfxRequest & rReq,SfxCallMode eCallMode)1000cdf0e10cSrcweir void SfxDispatcher::_Execute
1001cdf0e10cSrcweir (
1002cdf0e10cSrcweir 	SfxShell&		rShell,		// zu rufende <SfxShell>
1003cdf0e10cSrcweir 	const SfxSlot&	rSlot,		// zu rufender <SfxSlot>
1004cdf0e10cSrcweir 	SfxRequest&		rReq,		// auszuf"uhrende Funktion (Id und optional Parameter)
1005cdf0e10cSrcweir 	SfxCallMode 	eCallMode	// synchron, asynchron oder wie beim Slot angegeben
1006cdf0e10cSrcweir )
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir /*	[Beschreibung]
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir 	Diese Methode f"uhrt einen Request "uber einen gecachten <Slot-Server>
1011cdf0e10cSrcweir 	aus.
1012cdf0e10cSrcweir */
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir 	DBG_MEMTEST();
1016cdf0e10cSrcweir 	DBG_ASSERT( !pImp->bFlushing, "recursive call to dispatcher" );
1017cdf0e10cSrcweir 	DBG_ASSERT( !pImp->aToDoStack.Count(), "unprepared InPlace _Execute" );
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir 	if ( IsLocked( rSlot.GetSlotId() ) )
1020cdf0e10cSrcweir 		return;
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir 	if ( (eCallMode & SFX_CALLMODE_ASYNCHRON) ||
1023cdf0e10cSrcweir 		 ( !(eCallMode & SFX_CALLMODE_SYNCHRON) &&
1024cdf0e10cSrcweir 		   rSlot.IsMode(SFX_SLOT_ASYNCHRON) ) )
1025cdf0e10cSrcweir 	{
1026cdf0e10cSrcweir 		SfxDispatcher *pDispat = this;
1027cdf0e10cSrcweir 		while ( pDispat )
1028cdf0e10cSrcweir 		{
1029cdf0e10cSrcweir 			sal_uInt16 nShellCount = pDispat->pImp->aStack.Count();
1030cdf0e10cSrcweir 			for ( sal_uInt16 n=0; n<nShellCount; n++ )
1031cdf0e10cSrcweir 			{
1032cdf0e10cSrcweir 				if ( &rShell == pDispat->pImp->aStack.Top(n) )
1033cdf0e10cSrcweir 				{
1034cdf0e10cSrcweir                     if ( eCallMode & SFX_CALLMODE_RECORD )
1035cdf0e10cSrcweir                         rReq.AllowRecording( sal_True );
1036cdf0e10cSrcweir                     pDispat->pImp->xPoster->Post(new SfxRequest(rReq));
1037cdf0e10cSrcweir //                    pDispat->pImp->xPoster->Post(new Executer(new SfxRequest(rReq), &rSlot, n ));
1038cdf0e10cSrcweir 					return;
1039cdf0e10cSrcweir 				}
1040cdf0e10cSrcweir 			}
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir 			pDispat = pDispat->pImp->pParent;
1043cdf0e10cSrcweir 		}
1044cdf0e10cSrcweir 	}
1045cdf0e10cSrcweir 	else
1046cdf0e10cSrcweir 		Call_Impl( rShell, rSlot, rReq, SFX_CALLMODE_RECORD==(eCallMode&SFX_CALLMODE_RECORD) );
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir //--------------------------------------------------------------------
MappedPut_Impl(SfxAllItemSet & rSet,const SfxPoolItem & rItem)1050cdf0e10cSrcweir void MappedPut_Impl( SfxAllItemSet &rSet, const SfxPoolItem &rItem )
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir /*	[Beschreibung]
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 	Hilfsfunktion zum putten von rItem unter der im Pool des Item-Sets
1055cdf0e10cSrcweir 	rSet geltenden Which-Id.
1056cdf0e10cSrcweir */
1057cdf0e10cSrcweir 
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir 	// mit ggf. gemappter Which-Id putten
1060cdf0e10cSrcweir 	const SfxItemPool *pPool = rSet.GetPool();
1061cdf0e10cSrcweir 	sal_uInt16 nWhich = rItem.Which();
1062cdf0e10cSrcweir #ifdef TF_POOLABLE
1063cdf0e10cSrcweir 	if ( pPool->IsSlot(nWhich) )
1064cdf0e10cSrcweir #else
1065cdf0e10cSrcweir 	if ( pPool->HasMap() && pPool->IsSlot(nWhich) )
1066cdf0e10cSrcweir #endif
1067cdf0e10cSrcweir 		nWhich = pPool->GetWhich(nWhich);
1068cdf0e10cSrcweir 	rSet.Put( rItem, nWhich );
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir //--------------------------------------------------------------------
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir #ifndef SFX_USE_BINDINGS
1074cdf0e10cSrcweir #define SFX_USE_BINDINGS 0x8000
1075cdf0e10cSrcweir #endif
1076cdf0e10cSrcweir 
ExecuteFunction(sal_uInt16 nSlot,SfxPoolItem ** pArgs,sal_uInt16 nMode)1077cdf0e10cSrcweir sal_uInt16 SfxDispatcher::ExecuteFunction( sal_uInt16 nSlot, SfxPoolItem **pArgs,
1078cdf0e10cSrcweir 									   sal_uInt16 nMode )
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir 	if ( !nMode )
1081cdf0e10cSrcweir 		nMode = pImp->nStandardMode;
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 	// via Bindings/Interceptor? (dann ist der Returnwert nicht exakt)
1084cdf0e10cSrcweir 	sal_Bool bViaBindings = SFX_USE_BINDINGS == ( nMode & SFX_USE_BINDINGS );
1085cdf0e10cSrcweir 	nMode &= ~sal_uInt16(SFX_USE_BINDINGS);
1086cdf0e10cSrcweir     if ( bViaBindings && GetBindings() )
1087cdf0e10cSrcweir 		return GetBindings()->Execute( nSlot, (const SfxPoolItem **) pArgs, nMode )
1088cdf0e10cSrcweir 				? EXECUTE_POSSIBLE
1089cdf0e10cSrcweir 				: EXECUTE_NO;
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 	// sonst via Dispatcher
1092cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1093cdf0e10cSrcweir 		return 0;
1094cdf0e10cSrcweir 	SfxShell *pShell = 0;
1095cdf0e10cSrcweir 	SfxCallMode eCall = SFX_CALLMODE_SYNCHRON;
1096cdf0e10cSrcweir 	sal_uInt16 nRet = EXECUTE_NO;
1097cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1098cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False, sal_False ) )
1099cdf0e10cSrcweir 	{
1100cdf0e10cSrcweir 		// Ausf"uhrbarkeit vorher testen
1101cdf0e10cSrcweir 		if ( pSlot->IsMode( SFX_SLOT_FASTCALL ) ||
1102cdf0e10cSrcweir 			pShell->CanExecuteSlot_Impl( *pSlot ) )
1103cdf0e10cSrcweir 				nRet = EXECUTE_POSSIBLE;
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 		if ( nMode == EXECUTEMODE_ASYNCHRON )
1106cdf0e10cSrcweir 			eCall = SFX_CALLMODE_ASYNCHRON;
1107cdf0e10cSrcweir 		else if ( nMode == EXECUTEMODE_DIALOGASYNCHRON && pSlot->IsMode( SFX_SLOT_HASDIALOG ) )
1108cdf0e10cSrcweir 			eCall = SFX_CALLMODE_ASYNCHRON;
1109cdf0e10cSrcweir 		else if ( pSlot->GetMode() & SFX_SLOT_ASYNCHRON )
1110cdf0e10cSrcweir 			eCall = SFX_CALLMODE_ASYNCHRON;
1111cdf0e10cSrcweir 		sal_Bool bDone = sal_False;
1112cdf0e10cSrcweir 		if ( pArgs && *pArgs )
1113cdf0e10cSrcweir 		{
1114cdf0e10cSrcweir 			SfxAllItemSet aSet( pShell->GetPool() );
1115cdf0e10cSrcweir 			for ( SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
1116cdf0e10cSrcweir 				MappedPut_Impl( aSet, **pArg );
1117cdf0e10cSrcweir 			SfxRequest aReq( nSlot, eCall, aSet );
1118cdf0e10cSrcweir 			_Execute( *pShell, *pSlot, aReq, eCall );
1119cdf0e10cSrcweir 			bDone = aReq.IsDone();
1120cdf0e10cSrcweir 		}
1121cdf0e10cSrcweir 		else
1122cdf0e10cSrcweir 		{
1123cdf0e10cSrcweir 			SfxRequest aReq( nSlot, eCall, pShell->GetPool() );
1124cdf0e10cSrcweir 			_Execute( *pShell, *pSlot, aReq, eCall );
1125cdf0e10cSrcweir 			bDone = aReq.IsDone();
1126cdf0e10cSrcweir 		}
1127cdf0e10cSrcweir 	}
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 	return nRet;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
ExecuteFunction(sal_uInt16 nSlot,const SfxItemSet & rArgs,sal_uInt16 nMode)1132cdf0e10cSrcweir sal_uInt16 SfxDispatcher::ExecuteFunction( sal_uInt16 nSlot, const SfxItemSet& rArgs,
1133cdf0e10cSrcweir 									   sal_uInt16 nMode )
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir 	if ( !nMode )
1136cdf0e10cSrcweir 		nMode = pImp->nStandardMode;
1137cdf0e10cSrcweir 
1138cdf0e10cSrcweir /*
1139cdf0e10cSrcweir     // at the moment not implemented
1140cdf0e10cSrcweir     // via Bindings/Interceptor? (dann ist der Returnwert nicht exakt)
1141cdf0e10cSrcweir 	sal_Bool bViaBindings = SFX_USE_BINDINGS == ( nMode & SFX_USE_BINDINGS );
1142cdf0e10cSrcweir 	nMode &= ~sal_uInt16(SFX_USE_BINDINGS);
1143cdf0e10cSrcweir     if ( bViaBindings && GetBindings() )
1144cdf0e10cSrcweir         return GetBindings()->Execute( nSlot, rArgs, nMode )
1145cdf0e10cSrcweir 				? EXECUTE_POSSIBLE
1146cdf0e10cSrcweir 				: EXECUTE_NO;
1147cdf0e10cSrcweir */
1148cdf0e10cSrcweir 	// sonst via Dispatcher
1149cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1150cdf0e10cSrcweir 		return 0;
1151cdf0e10cSrcweir 	SfxShell *pShell = 0;
1152cdf0e10cSrcweir 	SfxCallMode eCall = SFX_CALLMODE_SYNCHRON;
1153cdf0e10cSrcweir 	sal_uInt16 nRet = EXECUTE_NO;
1154cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1155cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False, sal_False ) )
1156cdf0e10cSrcweir 	{
1157cdf0e10cSrcweir 		// Ausf"uhrbarkeit vorher testen
1158cdf0e10cSrcweir 		if ( pSlot->IsMode( SFX_SLOT_FASTCALL ) ||
1159cdf0e10cSrcweir 			pShell->CanExecuteSlot_Impl( *pSlot ) )
1160cdf0e10cSrcweir 				nRet = EXECUTE_POSSIBLE;
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir 		if ( nMode == EXECUTEMODE_ASYNCHRON )
1163cdf0e10cSrcweir 			eCall = SFX_CALLMODE_ASYNCHRON;
1164cdf0e10cSrcweir 		else if ( nMode == EXECUTEMODE_DIALOGASYNCHRON && pSlot->IsMode( SFX_SLOT_HASDIALOG ) )
1165cdf0e10cSrcweir 			eCall = SFX_CALLMODE_ASYNCHRON;
1166cdf0e10cSrcweir 		else if ( pSlot->GetMode() & SFX_SLOT_ASYNCHRON )
1167cdf0e10cSrcweir 			eCall = SFX_CALLMODE_ASYNCHRON;
1168cdf0e10cSrcweir 		sal_Bool bDone = sal_False;
1169cdf0e10cSrcweir             SfxRequest aReq( nSlot, eCall, rArgs );
1170cdf0e10cSrcweir 			_Execute( *pShell, *pSlot, aReq, eCall );
1171cdf0e10cSrcweir 			bDone = aReq.IsDone();
1172cdf0e10cSrcweir 	}
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	return nRet;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir 
GetSlotId(const String & rCommand)1177cdf0e10cSrcweir sal_uInt16 SfxDispatcher::GetSlotId( const String& rCommand )
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir     const SfxSlot *pSlot = GetSlot( rCommand );
1180cdf0e10cSrcweir     if ( pSlot )
1181cdf0e10cSrcweir         return pSlot->GetSlotId();
1182cdf0e10cSrcweir 	return 0;
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir 
GetSlot(const String & rCommand)1185cdf0e10cSrcweir const SfxSlot* SfxDispatcher::GetSlot( const String& rCommand )
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir 	// Anzahl der Shells auf den verkettenten Dispatchern z"ahlen
1188cdf0e10cSrcweir 	Flush();
1189cdf0e10cSrcweir 	sal_uInt16 nTotCount = pImp->aStack.Count();
1190cdf0e10cSrcweir 	if ( pImp->pParent )
1191cdf0e10cSrcweir 	{
1192cdf0e10cSrcweir 		SfxDispatcher *pParent = pImp->pParent;
1193cdf0e10cSrcweir 		while ( pParent )
1194cdf0e10cSrcweir 		{
1195cdf0e10cSrcweir 			nTotCount = nTotCount + pParent->pImp->aStack.Count();
1196cdf0e10cSrcweir 			pParent = pParent->pImp->pParent;
1197cdf0e10cSrcweir 		}
1198cdf0e10cSrcweir 	}
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 	const SfxSlot *pSlot=NULL;
1201cdf0e10cSrcweir 	sal_uInt16 nFirstShell = 0;
1202cdf0e10cSrcweir 	for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i )
1203cdf0e10cSrcweir 	{
1204cdf0e10cSrcweir 		SfxShell *pObjShell = GetShell(i);
1205cdf0e10cSrcweir 		SfxInterface *pIFace = pObjShell->GetInterface();
1206cdf0e10cSrcweir 		pSlot = pIFace->GetSlot( rCommand );
1207cdf0e10cSrcweir         if ( pSlot )
1208cdf0e10cSrcweir             return pSlot;
1209cdf0e10cSrcweir 	}
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 	return 0;
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir //--------------------------------------------------------------------
operator ==(const SfxPoolItem & rItem) const1215cdf0e10cSrcweir int SfxExecuteItem::operator==( const SfxPoolItem& rItem ) const
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir 	SfxExecuteItem& rArg = (SfxExecuteItem& )rItem;
1218cdf0e10cSrcweir 	sal_uInt16 nCount = Count();
1219cdf0e10cSrcweir 	if( nCount != rArg.Count() )
1220cdf0e10cSrcweir 		return sal_False;
1221cdf0e10cSrcweir 	while( nCount -- )
1222cdf0e10cSrcweir 		if( *GetObject( nCount ) != *rArg.GetObject( nCount ) )
1223cdf0e10cSrcweir 			return sal_False;
1224cdf0e10cSrcweir 	return  eCall == rArg.eCall;
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir //--------------------------------------------------------------------
Clone(SfxItemPool *) const1228cdf0e10cSrcweir SfxPoolItem* SfxExecuteItem::Clone( SfxItemPool* ) const
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir 	return new SfxExecuteItem( *this );
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir //--------------------------------------------------------------------
SfxExecuteItem(const SfxExecuteItem & rArg)1234cdf0e10cSrcweir SfxExecuteItem::SfxExecuteItem( const SfxExecuteItem& rArg )
1235cdf0e10cSrcweir 	: SfxItemPtrArray(), SfxPoolItem( rArg ), nModifier( 0 )
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir 	eCall = rArg.eCall;
1238cdf0e10cSrcweir 	nSlot = rArg.nSlot;
1239cdf0e10cSrcweir 	sal_uInt16 nCount = rArg.Count();
1240cdf0e10cSrcweir 	for( sal_uInt16 nPos = 0; nPos < nCount; nPos++ )
1241cdf0e10cSrcweir 		Insert( rArg[ nPos ]->Clone(), nPos );
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir //--------------------------------------------------------------------
SfxExecuteItem(sal_uInt16 nWhichId,sal_uInt16 nSlotP,SfxCallMode eModeP,const SfxPoolItem * pArg1,...)1245cdf0e10cSrcweir SfxExecuteItem::SfxExecuteItem(
1246cdf0e10cSrcweir 	sal_uInt16 nWhichId, sal_uInt16 nSlotP, SfxCallMode eModeP,
1247cdf0e10cSrcweir 	const SfxPoolItem*	pArg1, ... ) :
1248cdf0e10cSrcweir 	SfxPoolItem( nWhichId ), nSlot( nSlotP ), eCall( eModeP ), nModifier( 0 )
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir 	va_list pVarArgs;
1251cdf0e10cSrcweir 	va_start( pVarArgs, pArg1 );
1252cdf0e10cSrcweir 	for ( const SfxPoolItem *pArg = pArg1; pArg;
1253cdf0e10cSrcweir 		  pArg = va_arg( pVarArgs, const SfxPoolItem* ) )
1254cdf0e10cSrcweir 		Insert( pArg->Clone(), Count() );
1255cdf0e10cSrcweir 	va_end(pVarArgs);
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir //--------------------------------------------------------------------
SfxExecuteItem(sal_uInt16 nWhichId,sal_uInt16 nSlotP,SfxCallMode eModeP)1259cdf0e10cSrcweir SfxExecuteItem::SfxExecuteItem(
1260cdf0e10cSrcweir 	sal_uInt16 nWhichId, sal_uInt16 nSlotP, SfxCallMode eModeP )
1261cdf0e10cSrcweir 	: SfxPoolItem( nWhichId ), nSlot( nSlotP ), eCall( eModeP ), nModifier( 0 )
1262cdf0e10cSrcweir {
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir //--------------------------------------------------------------------
Execute(const SfxExecuteItem & rItem)1266cdf0e10cSrcweir const SfxPoolItem* SfxDispatcher::Execute( const SfxExecuteItem& rItem )
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir 	const SfxPoolItem** pPtr = new const SfxPoolItem*[ rItem.Count() + 1 ];
1269cdf0e10cSrcweir 	for( sal_uInt16 nPos = rItem.Count(); nPos--; )
1270cdf0e10cSrcweir 		pPtr[ nPos ] = rItem.GetObject( nPos );
1271cdf0e10cSrcweir 	pPtr[ rItem.Count() ] = 0;
1272cdf0e10cSrcweir 	const SfxPoolItem* pRet = Execute(
1273cdf0e10cSrcweir 		rItem.GetSlot(), rItem.GetCallMode(), pPtr, rItem.GetModifier() );
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir 	delete [] (SfxPoolItem**)pPtr;
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir 	return pRet;
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir //--------------------------------------------------------------------
Execute(sal_uInt16 nSlot,SfxCallMode nCall,SfxItemSet * pArgs,SfxItemSet * pInternalArgs,sal_uInt16 nModi)1281cdf0e10cSrcweir const SfxPoolItem*	SfxDispatcher::Execute(
1282cdf0e10cSrcweir     sal_uInt16 nSlot,
1283cdf0e10cSrcweir     SfxCallMode nCall,
1284cdf0e10cSrcweir     SfxItemSet* pArgs,
1285cdf0e10cSrcweir     SfxItemSet* pInternalArgs,
1286cdf0e10cSrcweir     sal_uInt16 nModi)
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1289cdf0e10cSrcweir 		return 0;
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir 	SfxShell *pShell = 0;
1292cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1293cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, sal_False,
1294cdf0e10cSrcweir 							   SFX_CALLMODE_MODAL==(nCall&SFX_CALLMODE_MODAL) ) )
1295cdf0e10cSrcweir 	{
1296cdf0e10cSrcweir 		SfxAllItemSet aSet( pShell->GetPool() );
1297cdf0e10cSrcweir 		if ( pArgs )
1298cdf0e10cSrcweir 		{
1299cdf0e10cSrcweir 		    SfxItemIter aIter(*pArgs);
1300cdf0e10cSrcweir 		    for ( const SfxPoolItem *pArg = aIter.FirstItem();
1301cdf0e10cSrcweir 			    pArg;
1302cdf0e10cSrcweir 			    pArg = aIter.NextItem() )
1303cdf0e10cSrcweir 			    MappedPut_Impl( aSet, *pArg );
1304cdf0e10cSrcweir 		}
1305cdf0e10cSrcweir 		SfxRequest aReq( nSlot, nCall, aSet );
1306cdf0e10cSrcweir         if (pInternalArgs)
1307cdf0e10cSrcweir     		aReq.SetInternalArgs_Impl( *pInternalArgs );
1308cdf0e10cSrcweir         aReq.SetModifier( nModi );
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir 		_Execute( *pShell, *pSlot, aReq, nCall );
1311cdf0e10cSrcweir 		return aReq.GetReturnValue();
1312cdf0e10cSrcweir 	}
1313cdf0e10cSrcweir 	return 0;
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir //--------------------------------------------------------------------
Execute(sal_uInt16 nSlot,SfxCallMode eCall,const SfxPoolItem ** pArgs,sal_uInt16 nModi,const SfxPoolItem ** pInternalArgs)1317cdf0e10cSrcweir const SfxPoolItem* SfxDispatcher::Execute
1318cdf0e10cSrcweir (
1319cdf0e10cSrcweir 	sal_uInt16 nSlot,				// die Id der auszufuehrenden Funktion
1320cdf0e10cSrcweir 	SfxCallMode eCall,			// SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON oder ..._SLOT
1321cdf0e10cSrcweir 	const SfxPoolItem **pArgs,	// 0-terminiertes C-Array von Parametern
1322cdf0e10cSrcweir 	sal_uInt16 nModi,
1323cdf0e10cSrcweir 	const SfxPoolItem **pInternalArgs // 0-terminiertes C-Array von Parametern
1324cdf0e10cSrcweir )
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir /*  [Beschreibung]
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir 	Methode zum Ausf"uhren eines <SfxSlot>s "uber die Slot-Id.
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir 	[R"uckgabewert]
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir 	const SfxPoolItem*		Pointer auf ein bis zum n"achsten Durchlauf
1334cdf0e10cSrcweir 							der Message-Loop g"ultiges SfxPoolItem,
1335cdf0e10cSrcweir 							welches den R"uckgabewert enth"alt.
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir 							Oder ein 0-Pointer, wenn die Funktion nicht
1338cdf0e10cSrcweir 							ausgef"uhrt wurde (z.B. Abbruch durch den
1339cdf0e10cSrcweir 							Benutzer).
1340cdf0e10cSrcweir */
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1344cdf0e10cSrcweir 		return 0;
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 	SfxShell *pShell = 0;
1347cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1348cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, sal_False,
1349cdf0e10cSrcweir 							   SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
1350cdf0e10cSrcweir 	{
1351cdf0e10cSrcweir 		SfxRequest* pReq;
1352cdf0e10cSrcweir 		if ( pArgs && *pArgs )
1353cdf0e10cSrcweir 		{
1354cdf0e10cSrcweir 			SfxAllItemSet aSet( pShell->GetPool() );
1355cdf0e10cSrcweir 			for ( const SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
1356cdf0e10cSrcweir 				MappedPut_Impl( aSet, **pArg );
1357cdf0e10cSrcweir 			pReq = new SfxRequest( nSlot, eCall, aSet );
1358cdf0e10cSrcweir 		}
1359cdf0e10cSrcweir 		else
1360cdf0e10cSrcweir 			pReq =  new SfxRequest( nSlot, eCall, pShell->GetPool() );
1361cdf0e10cSrcweir 		pReq->SetModifier( nModi );
1362cdf0e10cSrcweir 		if( pInternalArgs && *pInternalArgs)
1363cdf0e10cSrcweir 		{
1364cdf0e10cSrcweir 			SfxAllItemSet aSet( SFX_APP()->GetPool() );
1365cdf0e10cSrcweir 			for ( const SfxPoolItem **pArg = pInternalArgs; *pArg; ++pArg )
1366cdf0e10cSrcweir 				aSet.Put( **pArg );
1367cdf0e10cSrcweir 			pReq->SetInternalArgs_Impl( aSet );
1368cdf0e10cSrcweir 		}
1369cdf0e10cSrcweir 		_Execute( *pShell, *pSlot, *pReq, eCall );
1370cdf0e10cSrcweir 		const SfxPoolItem* pRet = pReq->GetReturnValue();
1371cdf0e10cSrcweir 		delete pReq; return pRet;
1372cdf0e10cSrcweir 	}
1373cdf0e10cSrcweir 	return 0;
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir //--------------------------------------------------------------------
Execute(sal_uInt16 nSlot,SfxCallMode eCall,const SfxItemSet & rArgs)1377cdf0e10cSrcweir const SfxPoolItem* SfxDispatcher::Execute
1378cdf0e10cSrcweir (
1379cdf0e10cSrcweir 	sal_uInt16 nSlot,				// die Id der auszufuehrenden Funktion
1380cdf0e10cSrcweir 	SfxCallMode eCall,			// SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON oder ..._SLOT
1381cdf0e10cSrcweir 	const SfxItemSet &rArgs	    // <SfxItemSet> mit Parametern
1382cdf0e10cSrcweir )
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir /*  [Beschreibung]
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 	Methode zum Ausf"uhren eines <SfxSlot>s "uber die Slot-Id.
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir 	[R"uckgabewert]
1390cdf0e10cSrcweir 
1391cdf0e10cSrcweir 	const SfxPoolItem*		Pointer auf ein bis zum n"achsten Durchlauf
1392cdf0e10cSrcweir 							der Message-Loop g"ultiges SfxPoolItem,
1393cdf0e10cSrcweir 							welches den R"uckgabewert enth"alt.
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 							Oder ein 0-Pointer, wenn die Funktion nicht
1396cdf0e10cSrcweir 							ausgef"uhrt wurde (z.B. Abbruch durch den
1397cdf0e10cSrcweir 							Benutzer).
1398cdf0e10cSrcweir */
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir {
1401cdf0e10cSrcweir     return Execute( nSlot, eCall, 0, rArgs );
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir //--------------------------------------------------------------------
Execute(sal_uInt16 nSlot,SfxCallMode eCall,sal_uInt16 nModi,const SfxItemSet & rArgs)1405cdf0e10cSrcweir const SfxPoolItem*  SfxDispatcher::Execute
1406cdf0e10cSrcweir (
1407cdf0e10cSrcweir     sal_uInt16 nSlot,
1408cdf0e10cSrcweir     SfxCallMode eCall,
1409cdf0e10cSrcweir     sal_uInt16 nModi,
1410cdf0e10cSrcweir     const SfxItemSet &rArgs
1411cdf0e10cSrcweir )
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1414cdf0e10cSrcweir 		return 0;
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 	SfxShell *pShell = 0;
1417cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1418cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, sal_False,
1419cdf0e10cSrcweir 							   SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
1420cdf0e10cSrcweir 	{
1421cdf0e10cSrcweir 		SfxAllItemSet aSet( pShell->GetPool() );
1422cdf0e10cSrcweir 		SfxItemIter aIter(rArgs);
1423cdf0e10cSrcweir 		for ( const SfxPoolItem *pArg = aIter.FirstItem();
1424cdf0e10cSrcweir 			  pArg;
1425cdf0e10cSrcweir 			  pArg = aIter.NextItem() )
1426cdf0e10cSrcweir 			MappedPut_Impl( aSet, *pArg );
1427cdf0e10cSrcweir 		SfxRequest aReq( nSlot, eCall, aSet );
1428cdf0e10cSrcweir         aReq.SetModifier( nModi );
1429cdf0e10cSrcweir 		_Execute( *pShell, *pSlot, aReq, eCall );
1430cdf0e10cSrcweir 		return aReq.GetReturnValue();
1431cdf0e10cSrcweir 	}
1432cdf0e10cSrcweir 	return 0;
1433cdf0e10cSrcweir }
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir //--------------------------------------------------------------------
_Execute(sal_uInt16 nSlot,SfxCallMode eCall,va_list pVarArgs,const SfxPoolItem * pArg1)1436cdf0e10cSrcweir const SfxPoolItem* SfxDispatcher::_Execute
1437cdf0e10cSrcweir (
1438cdf0e10cSrcweir 	sal_uInt16				nSlot,		// die Id der auszufuehrenden Funktion
1439cdf0e10cSrcweir 	SfxCallMode 		eCall,		// SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON oder ..._SLOT
1440cdf0e10cSrcweir 	va_list 			pVarArgs,	// Parameterliste ab 2. Parameter
1441cdf0e10cSrcweir 	const SfxPoolItem*	pArg1   	// erster Parameter
1442cdf0e10cSrcweir )
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir /*  [Beschreibung]
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir 	Methode zum Ausf"uhren eines <SfxSlot>s "uber die Slot-Id.
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 	[R"uckgabewert]
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir 	const SfxPoolItem*		Pointer auf ein bis zum n"achsten Durchlauf
1452cdf0e10cSrcweir 							der Message-Loop g"ultiges SfxPoolItem,
1453cdf0e10cSrcweir 							welches den R"uckgabewert enth"alt.
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir 							Oder ein 0-Pointer, wenn die Funktion nicht
1456cdf0e10cSrcweir 							ausgef"uhrt wurde (z.B. Abbruch durch den
1457cdf0e10cSrcweir 							Benutzer).
1458cdf0e10cSrcweir */
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir {
1461cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1462cdf0e10cSrcweir 		return 0;
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir 	SfxShell *pShell = 0;
1465cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1466cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False,
1467cdf0e10cSrcweir 							   SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
1468cdf0e10cSrcweir 	{
1469cdf0e10cSrcweir 	   SfxAllItemSet aSet( pShell->GetPool() );
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir 	   for ( const SfxPoolItem *pArg = pArg1;
1472cdf0e10cSrcweir 			 pArg;
1473cdf0e10cSrcweir 			 pArg = va_arg( pVarArgs, const SfxPoolItem* ) )
1474cdf0e10cSrcweir 		   MappedPut_Impl( aSet, *pArg );
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir 	   SfxRequest aReq( nSlot, eCall, aSet );
1477cdf0e10cSrcweir 	   _Execute( *pShell, *pSlot, aReq, eCall );
1478cdf0e10cSrcweir 	   return aReq.GetReturnValue();
1479cdf0e10cSrcweir 	}
1480cdf0e10cSrcweir 	return 0;
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir //--------------------------------------------------------------------
Execute(sal_uInt16 nSlot,SfxCallMode eCall,const SfxPoolItem * pArg1,...)1484cdf0e10cSrcweir const SfxPoolItem* SfxDispatcher::Execute
1485cdf0e10cSrcweir (
1486cdf0e10cSrcweir 	sal_uInt16				nSlot,		// die Id der auszufuehrenden Funktion
1487cdf0e10cSrcweir 	SfxCallMode 		eCall,		// SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON oder ..._SLOT
1488cdf0e10cSrcweir 	const SfxPoolItem*	pArg1,		// erster Parameter
1489cdf0e10cSrcweir 	... 							// 0-terminiertes Liste Parametern
1490cdf0e10cSrcweir )
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir /*  [Beschreibung]
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir 	Methode zum Ausf"uhren eines <SfxSlot>s "uber die Slot-Id.
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir 	[Anmerkung]
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir 	Die Parameter werden kopiert, k"onnen daher als Adresse von
1500cdf0e10cSrcweir 	Stack-Objekten "ubergeben werden.
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir 	[R"uckgabewert]
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir 	const SfxPoolItem*		Pointer auf ein bis zum n"achsten Durchlauf
1506cdf0e10cSrcweir 							der Message-Loop g"ultiges SfxPoolItem,
1507cdf0e10cSrcweir 							welches den R"uckgabewert enth"alt.
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir 							Oder ein 0-Pointer, wenn die Funktion nicht
1510cdf0e10cSrcweir 							ausgef"uhrt wurde (z.B. Abbruch durch den
1511cdf0e10cSrcweir 							Benutzer).
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir 	[Beispiel]
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir     pDispatcher->Execute( SID_OPENDOCUMENT, SFX_CALLMODE_SYNCHRON,
1517cdf0e10cSrcweir 		&SfxStringItem( SID_FILE_NAME, "\\tmp\\temp.sdd" ),
1518cdf0e10cSrcweir 		&SfxStringItem( SID_FILTER_NAME, "StarDraw Presentation" ),
1519cdf0e10cSrcweir 		&SfxBoolItem( SID_DOC_READONLY, sal_False ),
1520cdf0e10cSrcweir 		0L );
1521cdf0e10cSrcweir */
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
1525cdf0e10cSrcweir 		return 0;
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir 	SfxShell *pShell = 0;
1528cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
1529cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False,
1530cdf0e10cSrcweir 							   SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
1531cdf0e10cSrcweir 	{
1532cdf0e10cSrcweir 	   SfxAllItemSet aSet( pShell->GetPool() );
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 	   va_list pVarArgs;
1535cdf0e10cSrcweir 	   va_start( pVarArgs, pArg1 );
1536cdf0e10cSrcweir 	   for ( const SfxPoolItem *pArg = pArg1;
1537cdf0e10cSrcweir 			 pArg;
1538cdf0e10cSrcweir 			 pArg = va_arg( pVarArgs, const SfxPoolItem* ) )
1539cdf0e10cSrcweir 		   MappedPut_Impl( aSet, *pArg );
1540cdf0e10cSrcweir 	   va_end(pVarArgs);
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir 	   SfxRequest aReq( nSlot, eCall, aSet );
1543cdf0e10cSrcweir 	   _Execute( *pShell, *pSlot, aReq, eCall );
1544cdf0e10cSrcweir 	   return aReq.GetReturnValue();
1545cdf0e10cSrcweir 	}
1546cdf0e10cSrcweir 	return 0;
1547cdf0e10cSrcweir }
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir //--------------------------------------------------------------------
1550cdf0e10cSrcweir 
IMPL_LINK(SfxDispatcher,PostMsgHandler,SfxRequest *,pReq)1551cdf0e10cSrcweir IMPL_LINK( SfxDispatcher, PostMsgHandler, SfxRequest*, pReq )
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir /*	[Beschreibung]
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir 	Hilfsmethode zum Empfangen der asynchron auszuf"uhrenden <SfxRequest>s.
1556cdf0e10cSrcweir */
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir {
1559cdf0e10cSrcweir 	DBG_MEMTEST();
1560cdf0e10cSrcweir 	DBG_ASSERT( !pImp->bFlushing, "recursive call to dispatcher" );
1561cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::PostMsgHandler);
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir 	// ist auch der Pool noch nicht gestorben?
1564cdf0e10cSrcweir //    SfxRequest* pReq = pExec->pRequest;
1565cdf0e10cSrcweir 	if ( !pReq->IsCancelled() )
1566cdf0e10cSrcweir 	{
1567cdf0e10cSrcweir 		if ( !IsLocked(pReq->GetSlot()) )
1568cdf0e10cSrcweir 		{
1569cdf0e10cSrcweir 			Flush();
1570cdf0e10cSrcweir             SfxSlotServer aSvr;
1571cdf0e10cSrcweir             if ( _FindServer(pReq->GetSlot(), aSvr, HACK(x) sal_True ) )
1572cdf0e10cSrcweir //            SfxShell *pShell = GetShell(pExec->nLevel);
1573cdf0e10cSrcweir //            if ( pShell && pShell->GetInterface()->GetSlot( pExec->pSlot->GetSlotId() ) )
1574cdf0e10cSrcweir 			{
1575cdf0e10cSrcweir                 const SfxSlot *pSlot = aSvr.GetSlot();
1576cdf0e10cSrcweir                 SfxShell *pSh = GetShell(aSvr.GetShellLevel());
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir 				DBG( SfxApplication *pSfxApp = SFX_APP() );
1579cdf0e10cSrcweir 				DBG( pSfxApp->EnterAsynchronCall_Impl() );
1580cdf0e10cSrcweir 
1581cdf0e10cSrcweir 				// Wenn pSlot ein "Pseudoslot" f"ur Macros oder Verben ist, kann
1582cdf0e10cSrcweir 				// er im Call_Impl zerst"ort werden, also nicht mehr benutzen!
1583cdf0e10cSrcweir 				pReq->SetSynchronCall( sal_False );
1584cdf0e10cSrcweir                 Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! woher bRecord?
1585cdf0e10cSrcweir //                Call_Impl( *pShell, *pExec->pSlot, *pReq, sal_True ); //! woher bRecord?
1586cdf0e10cSrcweir 				DBG( pSfxApp->LeaveAsynchronCall_Impl() );
1587cdf0e10cSrcweir 			}
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir //            delete pExec;
1590cdf0e10cSrcweir 		}
1591cdf0e10cSrcweir 		else
1592cdf0e10cSrcweir 		{
1593cdf0e10cSrcweir //            pImp->xPoster->Post(pExec);
1594cdf0e10cSrcweir             if ( pImp->bLocked )
1595cdf0e10cSrcweir                 pImp->aReqArr.Insert( new SfxRequest(*pReq), pImp->aReqArr.Count() );
1596cdf0e10cSrcweir             else
1597cdf0e10cSrcweir                 pImp->xPoster->Post(new SfxRequest(*pReq));
1598cdf0e10cSrcweir 		}
1599cdf0e10cSrcweir 	}
1600cdf0e10cSrcweir //    else
1601cdf0e10cSrcweir //        delete pExec;
1602cdf0e10cSrcweir 
1603cdf0e10cSrcweir     delete pReq;
1604cdf0e10cSrcweir 	return 0;
1605cdf0e10cSrcweir }
1606cdf0e10cSrcweir //--------------------------------------------------------------------
SetMenu_Impl()1607cdf0e10cSrcweir void SfxDispatcher::SetMenu_Impl()
1608cdf0e10cSrcweir {
1609cdf0e10cSrcweir 	if ( pImp->pFrame )
1610cdf0e10cSrcweir 	{
1611cdf0e10cSrcweir         SfxViewFrame* pTop = pImp->pFrame->GetTopViewFrame();
1612cdf0e10cSrcweir         if ( pTop && pTop->GetBindings().GetDispatcher() == this )
1613cdf0e10cSrcweir         {
1614cdf0e10cSrcweir 			SfxFrame& rFrame = pTop->GetFrame();
1615cdf0e10cSrcweir             if ( rFrame.IsMenuBarOn_Impl() )
1616cdf0e10cSrcweir             {
1617cdf0e10cSrcweir                 com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
1618cdf0e10cSrcweir                 if ( xPropSet.is() )
1619cdf0e10cSrcweir                 {
1620cdf0e10cSrcweir                     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1621cdf0e10cSrcweir                     com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
1622cdf0e10cSrcweir                     aValue >>= xLayoutManager;
1623cdf0e10cSrcweir                     if ( xLayoutManager.is() )
1624cdf0e10cSrcweir                     {
1625cdf0e10cSrcweir                         rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ));
1626cdf0e10cSrcweir 						if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
1627cdf0e10cSrcweir                         	xLayoutManager->createElement( aMenuBarURL );
1628cdf0e10cSrcweir                     }
1629cdf0e10cSrcweir                 }
1630cdf0e10cSrcweir             }
1631cdf0e10cSrcweir         }
1632cdf0e10cSrcweir     }
1633cdf0e10cSrcweir }
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir //--------------------------------------------------------------------
Update_Impl(sal_Bool bForce)1636cdf0e10cSrcweir void SfxDispatcher::Update_Impl( sal_Bool bForce )
1637cdf0e10cSrcweir {
1638cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::Update_Impl);
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir 	Flush();
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir     if ( !pImp->pFrame || pImp->bUILocked )
1643cdf0e10cSrcweir 		return;
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir 	SFX_APP();  // -Wall is this required???
1646cdf0e10cSrcweir 	SfxDispatcher *pDisp = this;
1647cdf0e10cSrcweir 	sal_Bool bUpdate = bForce;
1648cdf0e10cSrcweir     while ( pDisp && pDisp->pImp->pFrame )
1649cdf0e10cSrcweir 	{
1650cdf0e10cSrcweir         SfxWorkWindow *pWork = pDisp->pImp->pFrame->GetFrame().GetWorkWindow_Impl();
1651cdf0e10cSrcweir 		SfxDispatcher *pAct = pWork->GetBindings().GetDispatcher_Impl();
1652cdf0e10cSrcweir 		if ( pAct == pDisp || pAct == this )
1653cdf0e10cSrcweir 		{
1654cdf0e10cSrcweir 			if ( !bUpdate )
1655cdf0e10cSrcweir 				bUpdate = !pDisp->pImp->bUpdated;
1656cdf0e10cSrcweir 			pDisp->pImp->bUpdated = sal_True;
1657cdf0e10cSrcweir 		}
1658cdf0e10cSrcweir 		else
1659cdf0e10cSrcweir 			break;
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir 		pDisp = pDisp->pImp->pParent;
1662cdf0e10cSrcweir 	}
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir     if ( !bUpdate || pImp->pFrame->GetFrame().IsClosing_Impl() )
1665cdf0e10cSrcweir 		return;
1666cdf0e10cSrcweir 
1667cdf0e10cSrcweir     SfxViewFrame* pTop = pImp->pFrame ? pImp->pFrame->GetTopViewFrame() : NULL;
1668cdf0e10cSrcweir     sal_Bool bUIActive = pTop && pTop->GetBindings().GetDispatcher() == this;
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir     if ( !bUIActive && pTop && GetBindings() == &pTop->GetBindings() )
1671cdf0e10cSrcweir         // keep own tools internally for collecting
1672cdf0e10cSrcweir         GetBindings()->GetDispatcher()->pImp->bUpdated = sal_False;
1673cdf0e10cSrcweir 
1674cdf0e10cSrcweir     SfxBindings* pBindings = GetBindings();
1675cdf0e10cSrcweir     if ( pBindings )
1676cdf0e10cSrcweir         pBindings->DENTERREGISTRATIONS();
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame = pBindings->GetActiveFrame();
1679cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, com::sun::star::uno::UNO_QUERY );
1680cdf0e10cSrcweir     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1681cdf0e10cSrcweir     if ( xPropSet.is() )
1682cdf0e10cSrcweir     {
1683cdf0e10cSrcweir         try
1684cdf0e10cSrcweir         {
1685cdf0e10cSrcweir             com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )) );
1686cdf0e10cSrcweir 	        aValue >>= xLayoutManager;
1687cdf0e10cSrcweir         }
1688cdf0e10cSrcweir         catch ( com::sun::star::uno::Exception& )
1689cdf0e10cSrcweir         {
1690cdf0e10cSrcweir         }
1691cdf0e10cSrcweir     }
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir     if ( xLayoutManager.is() )
1694cdf0e10cSrcweir         xLayoutManager->lock();
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir     sal_Bool bIsIPActive = pImp->pFrame && pImp->pFrame->GetObjectShell()->IsInPlaceActive();
1697cdf0e10cSrcweir     SfxInPlaceClient *pClient = pImp->pFrame ? pImp->pFrame->GetViewShell()->GetUIActiveClient() : NULL;
1698cdf0e10cSrcweir     if ( bUIActive && /* !bIsIPActive && */ ( !pClient || !pClient->IsObjectUIActive() ) )
1699cdf0e10cSrcweir 		SetMenu_Impl();
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir     SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
1702cdf0e10cSrcweir     SfxWorkWindow *pTaskWin = pImp->pFrame->GetTopFrame().GetWorkWindow_Impl();
1703cdf0e10cSrcweir     pTaskWin->ResetStatusBar_Impl();
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir 	SfxDispatcher *pDispat = this;
1706cdf0e10cSrcweir 	while ( pDispat )
1707cdf0e10cSrcweir 	{
1708cdf0e10cSrcweir         SfxWorkWindow *pWork = pDispat->pImp->pFrame->GetFrame().GetWorkWindow_Impl();
1709cdf0e10cSrcweir 		SfxDispatcher *pAct = pWork->GetBindings().GetDispatcher_Impl();
1710cdf0e10cSrcweir 		if ( pAct == pDispat || pAct == this )
1711cdf0e10cSrcweir 		{
1712cdf0e10cSrcweir 			pWork->ResetObjectBars_Impl();
1713cdf0e10cSrcweir 			pWork->ResetChildWindows_Impl();
1714cdf0e10cSrcweir 		}
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir 		pDispat = pDispat->pImp->pParent;
1717cdf0e10cSrcweir 	}
1718cdf0e10cSrcweir 
1719cdf0e10cSrcweir 	sal_Bool bIsActive = sal_False;
1720cdf0e10cSrcweir 	SfxDispatcher *pActDispat = pWorkWin->GetBindings().GetDispatcher_Impl();
1721cdf0e10cSrcweir 	pDispat = this;
1722cdf0e10cSrcweir 	while ( pActDispat && !bIsActive )
1723cdf0e10cSrcweir 	{
1724cdf0e10cSrcweir 		if ( pDispat == pActDispat )
1725cdf0e10cSrcweir 			bIsActive = sal_True;
1726cdf0e10cSrcweir 		pActDispat = pActDispat->pImp->pParent;
1727cdf0e10cSrcweir 	}
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir     _Update_Impl( bUIActive, !bIsIPActive, bIsIPActive, pTaskWin );
1730cdf0e10cSrcweir 	if ( bUIActive || bIsActive )
1731cdf0e10cSrcweir 		pWorkWin->UpdateObjectBars_Impl();
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir     if ( pBindings )
1734cdf0e10cSrcweir         pBindings->DLEAVEREGISTRATIONS();
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir     if ( xLayoutManager.is() )
1737cdf0e10cSrcweir         xLayoutManager->unlock();
1738cdf0e10cSrcweir 
1739cdf0e10cSrcweir     return;
1740cdf0e10cSrcweir }
1741cdf0e10cSrcweir 
_Update_Impl(sal_Bool bUIActive,sal_Bool bIsMDIApp,sal_Bool bIsIPOwner,SfxWorkWindow * pTaskWin)1742cdf0e10cSrcweir void SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, sal_Bool bIsIPOwner, SfxWorkWindow *pTaskWin )
1743cdf0e10cSrcweir {
1744cdf0e10cSrcweir 	SFX_APP();
1745cdf0e10cSrcweir     SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
1746cdf0e10cSrcweir 	sal_Bool bIsActive = sal_False;
1747cdf0e10cSrcweir 	sal_Bool bIsTaskActive = sal_False;
1748cdf0e10cSrcweir 	SfxDispatcher *pActDispat = pWorkWin->GetBindings().GetDispatcher_Impl();
1749cdf0e10cSrcweir 	SfxDispatcher *pDispat = this;
1750cdf0e10cSrcweir 	while ( pActDispat && !bIsActive )
1751cdf0e10cSrcweir 	{
1752cdf0e10cSrcweir 		if ( pDispat == pActDispat )
1753cdf0e10cSrcweir 			bIsActive = sal_True;
1754cdf0e10cSrcweir 		pActDispat = pActDispat->pImp->pParent;
1755cdf0e10cSrcweir 	}
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir     if ( pImp->pParent && !pImp->bQuiet /* && bUIActive */ )
1758cdf0e10cSrcweir         pImp->pParent->_Update_Impl( bUIActive, bIsMDIApp, bIsIPOwner, pTaskWin );
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir 	for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
1761cdf0e10cSrcweir 		pImp->aObjBars[n].nResId = 0;
1762cdf0e10cSrcweir 	pImp->aChildWins.Remove(0, pImp->aChildWins.Count());
1763cdf0e10cSrcweir 
1764cdf0e10cSrcweir     // bQuiet : own shells aren't considered for UI and SlotServer
1765cdf0e10cSrcweir     // bNoUI: own Shells aren't considered fors UI
1766cdf0e10cSrcweir     if ( pImp->bQuiet || pImp->bNoUI || (pImp->pFrame && pImp->pFrame->GetObjectShell()->IsPreview()) )
1767cdf0e10cSrcweir 		return;
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir 	sal_uInt32 nStatBarId=0;
1770cdf0e10cSrcweir 	SfxShell *pStatusBarShell = NULL;
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir     SfxSlotPool* pSlotPool = &SfxSlotPool::GetSlotPool( GetFrame() );
1773cdf0e10cSrcweir 	sal_uInt16 nTotCount = pImp->aStack.Count();
1774cdf0e10cSrcweir 	for ( sal_uInt16 nShell = nTotCount; nShell > 0; --nShell )
1775cdf0e10cSrcweir 	{
1776cdf0e10cSrcweir 		SfxShell *pShell = GetShell( nShell-1 );
1777cdf0e10cSrcweir 		SfxInterface *pIFace = pShell->GetInterface();
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir         // don't consider shells if "Hidden" oder "Quiet"
1780cdf0e10cSrcweir 		sal_Bool bReadOnlyShell = IsReadOnlyShell_Impl( nShell-1 );
1781cdf0e10cSrcweir 		sal_uInt16 nNo;
1782cdf0e10cSrcweir 		for ( nNo = 0; pIFace && nNo<pIFace->GetObjectBarCount(); ++nNo )
1783cdf0e10cSrcweir 		{
1784cdf0e10cSrcweir 			sal_uInt16 nPos = pIFace->GetObjectBarPos(nNo);
1785cdf0e10cSrcweir 			if ( bReadOnlyShell && !( nPos & SFX_VISIBILITY_READONLYDOC ) )
1786cdf0e10cSrcweir 				continue;
1787cdf0e10cSrcweir 
1788*940681c7SMatthias Seidel             // check whether toolbar needs activation of a special feature
1789cdf0e10cSrcweir             sal_uInt32 nFeature = pIFace->GetObjectBarFeature(nNo);
1790cdf0e10cSrcweir 			if ( nFeature && !pShell->HasUIFeature( nFeature ) )
1791cdf0e10cSrcweir 				continue;
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir 			// check for toolboxes that are exclusively for a viewer
1794cdf0e10cSrcweir 			if ( pImp->pFrame)
1795cdf0e10cSrcweir 			{
1796cdf0e10cSrcweir 				sal_Bool bViewerTbx = SFX_VISIBILITY_VIEWER == ( nPos & SFX_VISIBILITY_VIEWER );
1797cdf0e10cSrcweir 				SfxObjectShell* pSh = pImp->pFrame->GetObjectShell();
1798cdf0e10cSrcweir 				SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
1799cdf0e10cSrcweir 				sal_Bool bIsViewer = pItem && pItem->GetValue();
1800cdf0e10cSrcweir 				if ( bIsViewer != bViewerTbx )
1801cdf0e10cSrcweir 					continue;
1802cdf0e10cSrcweir 			}
1803cdf0e10cSrcweir 
1804cdf0e10cSrcweir             // always register toolbars, allows to switch them on
1805cdf0e10cSrcweir             sal_Bool bVisible = pIFace->IsObjectBarVisible(nNo);
1806cdf0e10cSrcweir 			if ( !bVisible )
1807cdf0e10cSrcweir 				nPos &= SFX_POSITION_MASK;
1808cdf0e10cSrcweir 
1809cdf0e10cSrcweir 			SfxObjectBars_Impl& rBar = pImp->aObjBars[nPos & SFX_POSITION_MASK];
1810cdf0e10cSrcweir 			rBar.nMode = nPos;
1811cdf0e10cSrcweir 			rBar.nResId = pIFace->GetObjectBarResId(nNo).GetId();
1812cdf0e10cSrcweir 			const String *pName = pIFace->GetObjectBarName(nNo);
1813cdf0e10cSrcweir 			if ( pName )
1814cdf0e10cSrcweir 				rBar.aName = *pName;
1815cdf0e10cSrcweir 			else
1816cdf0e10cSrcweir 				rBar.aName.Erase();
1817cdf0e10cSrcweir 			rBar.pIFace = pIFace;
1818cdf0e10cSrcweir 
1819cdf0e10cSrcweir 			if ( bUIActive || bIsActive )
1820cdf0e10cSrcweir 			{
1821cdf0e10cSrcweir 				pWorkWin->SetObjectBar_Impl(
1822cdf0e10cSrcweir 					nPos, rBar.nResId, rBar.pIFace, &rBar.aName );
1823cdf0e10cSrcweir 			}
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir 			if ( !bVisible )
1826cdf0e10cSrcweir 				rBar.nResId = 0;
1827cdf0e10cSrcweir 		}
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir 		for ( nNo=0; pIFace && nNo<pIFace->GetChildWindowCount(); nNo++ )
1830cdf0e10cSrcweir 		{
1831cdf0e10cSrcweir 			sal_uInt32 nId = pIFace->GetChildWindowId(nNo);
1832cdf0e10cSrcweir             const SfxSlot *pSlot = pSlotPool->GetSlot( (sal_uInt16) nId );
1833cdf0e10cSrcweir             DBG_ASSERT( pSlot, "Childwindow slot missing!");
1834cdf0e10cSrcweir 			if ( bReadOnlyShell )
1835cdf0e10cSrcweir 			{
1836cdf0e10cSrcweir                 // only show ChildWindows if their slot is allowed for readonly documents
1837cdf0e10cSrcweir                 if ( pSlot && !pSlot->IsMode( SFX_SLOT_READONLYDOC ) )
1838cdf0e10cSrcweir 					continue;
1839cdf0e10cSrcweir 			}
1840cdf0e10cSrcweir 
1841cdf0e10cSrcweir 			sal_uInt32 nFeature = pIFace->GetChildWindowFeature(nNo);
1842cdf0e10cSrcweir 			if ( nFeature && !pShell->HasUIFeature( nFeature ) )
1843cdf0e10cSrcweir 				continue;
1844cdf0e10cSrcweir 
1845*940681c7SMatthias Seidel             // slot decides whether a ChildWindow is shown when document is OLE server or OLE client
1846cdf0e10cSrcweir             sal_uInt16 nMode = SFX_VISIBILITY_STANDARD;
1847cdf0e10cSrcweir 			if( pSlot )
1848cdf0e10cSrcweir 			{
1849cdf0e10cSrcweir                 if ( pSlot->IsMode(SFX_SLOT_CONTAINER) )
1850cdf0e10cSrcweir 				{
1851cdf0e10cSrcweir                     if ( pWorkWin->IsVisible_Impl( SFX_VISIBILITY_CLIENT ) )
1852cdf0e10cSrcweir                         nMode |= SFX_VISIBILITY_CLIENT;
1853cdf0e10cSrcweir 				}
1854cdf0e10cSrcweir 				else
1855cdf0e10cSrcweir 				{
1856cdf0e10cSrcweir                     if ( pWorkWin->IsVisible_Impl( SFX_VISIBILITY_SERVER ) )
1857cdf0e10cSrcweir                         nMode |= SFX_VISIBILITY_SERVER;
1858cdf0e10cSrcweir 				}
1859cdf0e10cSrcweir 			}
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir 			if ( bUIActive || bIsActive )
1862cdf0e10cSrcweir 				pWorkWin->SetChildWindowVisible_Impl( nId, sal_True, nMode );
1863cdf0e10cSrcweir 			if ( bUIActive || bIsActive || !pWorkWin->IsFloating( (sal_uInt16) ( nId & 0xFFFF ) ) )
1864cdf0e10cSrcweir 				pImp->aChildWins.Insert( nId, pImp->aChildWins.Count());
1865cdf0e10cSrcweir 		}
1866cdf0e10cSrcweir 
1867cdf0e10cSrcweir 		if ( bIsMDIApp || bIsIPOwner )
1868cdf0e10cSrcweir 		{
1869cdf0e10cSrcweir 			sal_uInt32 nId = pIFace->GetStatusBarResId().GetId();
1870cdf0e10cSrcweir 			if ( nId )
1871cdf0e10cSrcweir 			{
1872cdf0e10cSrcweir 				nStatBarId = nId;
1873cdf0e10cSrcweir 				pStatusBarShell =  pShell;
1874cdf0e10cSrcweir 			}
1875cdf0e10cSrcweir 		}
1876cdf0e10cSrcweir 	}
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos<SFX_OBJECTBAR_MAX; nPos++ )
1879cdf0e10cSrcweir 	{
1880cdf0e10cSrcweir 		SfxObjectBars_Impl& rFixed = pImp->aFixedObjBars[nPos];
1881cdf0e10cSrcweir 		if ( rFixed.nResId )
1882cdf0e10cSrcweir 		{
1883cdf0e10cSrcweir 			SfxObjectBars_Impl& rBar = pImp->aObjBars[nPos];
1884cdf0e10cSrcweir 			rBar = rFixed;
1885cdf0e10cSrcweir 			pWorkWin->SetObjectBar_Impl( rFixed.nMode,
1886cdf0e10cSrcweir 				rFixed.nResId, rFixed.pIFace, &rFixed.aName );
1887cdf0e10cSrcweir 		}
1888cdf0e10cSrcweir 	}
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir 	if ( pTaskWin && ( bIsMDIApp || bIsIPOwner ) )
1891cdf0e10cSrcweir 	{
1892cdf0e10cSrcweir 		SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl();
1893cdf0e10cSrcweir 		SfxDispatcher *pDispatcher = this;
1894cdf0e10cSrcweir 		while ( pActDispatcher && !bIsTaskActive )
1895cdf0e10cSrcweir 		{
1896cdf0e10cSrcweir 			if ( pDispatcher == pActDispatcher )
1897cdf0e10cSrcweir 				bIsTaskActive = sal_True;
1898cdf0e10cSrcweir 			pActDispatcher = pActDispatcher->pImp->pParent;
1899cdf0e10cSrcweir 		}
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir         if ( bIsTaskActive && nStatBarId && pImp->pFrame )
1902cdf0e10cSrcweir 		{
1903cdf0e10cSrcweir             // internal frames also may control statusbar
1904cdf0e10cSrcweir             SfxBindings& rBindings = pImp->pFrame->GetBindings();
1905cdf0e10cSrcweir             pImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl( nStatBarId, pStatusBarShell, rBindings );
1906cdf0e10cSrcweir 		}
1907cdf0e10cSrcweir 	}
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir 
1910cdf0e10cSrcweir //--------------------------------------------------------------------
FlushImpl()1911cdf0e10cSrcweir void SfxDispatcher::FlushImpl()
1912cdf0e10cSrcweir 
1913cdf0e10cSrcweir /*	[Beschreibung]
1914cdf0e10cSrcweir 
1915cdf0e10cSrcweir 	Hilfsmethode zum Ausf"uhren der ausstehenden Push- und Pop-Befehle.
1916cdf0e10cSrcweir */
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir 	DBG_PROFSTART(SfxDispatcherFlush);
1920cdf0e10cSrcweir 	DBG_MEMTEST();
1921cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::FlushImpl);
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir 	DBG_TRACE("Flushing dispatcher!");
1924cdf0e10cSrcweir 
1925cdf0e10cSrcweir #ifdef DBG_UTIL
1926cdf0e10cSrcweir 	ByteString aMsg( "SfxDispatcher(" );
1927cdf0e10cSrcweir 	aMsg += ByteString::CreateFromInt64( (sal_uIntPtr) this );
1928cdf0e10cSrcweir 	aMsg += ")::Flush()";
1929cdf0e10cSrcweir #endif
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir 	pImp->aTimer.Stop();
1932cdf0e10cSrcweir 
1933cdf0e10cSrcweir 	if ( pImp->pParent )
1934cdf0e10cSrcweir 		pImp->pParent->Flush();
1935cdf0e10cSrcweir 
1936cdf0e10cSrcweir //	if ( pImp->bQuiet )
1937cdf0e10cSrcweir //		return;
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir 	pImp->bFlushing = !pImp->bFlushing;
1940cdf0e10cSrcweir 	if ( !pImp->bFlushing )
1941cdf0e10cSrcweir 	{
1942cdf0e10cSrcweir 		pImp->bFlushing = sal_True;
1943cdf0e10cSrcweir 		DBG_PROFSTOP(SfxDispatcherFlush);
1944cdf0e10cSrcweir //!
1945cdf0e10cSrcweir #ifdef DBG_UTIL_MESSEHACK_AUSKOMMENT
1946cdf0e10cSrcweir 		DBG_ERROR( "reentering SfxDispatcher::Flush()" );
1947cdf0e10cSrcweir 		aMsg += " reentering, aborted";
1948cdf0e10cSrcweir 		DbgTrace( aMsg.GetBuffer() );
1949cdf0e10cSrcweir #endif
1950cdf0e10cSrcweir 		return;
1951cdf0e10cSrcweir 	}
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir 	SfxApplication *pSfxApp = SFX_APP();
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir 	// in der 1. Runde den echten Stack 'um'bauen
1956cdf0e10cSrcweir 	SfxToDoStack_Impl aToDoCopy;
1957cdf0e10cSrcweir 	sal_Bool bModify = sal_False;
1958cdf0e10cSrcweir 	short nToDo;
1959cdf0e10cSrcweir 	for ( nToDo = pImp->aToDoStack.Count()-1; nToDo >= 0; --nToDo )
1960cdf0e10cSrcweir 	{
1961cdf0e10cSrcweir 		bModify = sal_True;
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir 		SfxToDo_Impl aToDo( pImp->aToDoStack.Top(nToDo) );
1964cdf0e10cSrcweir 		if ( aToDo.bPush )
1965cdf0e10cSrcweir 		{
1966cdf0e10cSrcweir 			// tats"aechlich pushen
1967cdf0e10cSrcweir 			DBG_ASSERT( !pImp->aStack.Contains( aToDo.pCluster ),
1968cdf0e10cSrcweir 						"pushed SfxShell already on stack" );
1969cdf0e10cSrcweir 			pImp->aStack.Push( aToDo.pCluster );
1970cdf0e10cSrcweir 			aToDo.pCluster->SetDisableFlags( pImp->nDisableFlags );
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir 			// die bewegte Shell merken
1973cdf0e10cSrcweir 			aToDoCopy.Push( aToDo );
1974cdf0e10cSrcweir 		}
1975cdf0e10cSrcweir 		else
1976cdf0e10cSrcweir 		{
1977cdf0e10cSrcweir 			// tats"aechlich poppen
1978cdf0e10cSrcweir 			SfxShell* pPopped = 0;
1979cdf0e10cSrcweir 			bool bFound = sal_False;
1980cdf0e10cSrcweir 			do
1981cdf0e10cSrcweir 			{
1982cdf0e10cSrcweir 				DBG_ASSERT( pImp->aStack.Count(), "popping from empty stack" );
1983cdf0e10cSrcweir 				pPopped = pImp->aStack.Pop();
1984cdf0e10cSrcweir 				pPopped->SetDisableFlags( 0 );
1985cdf0e10cSrcweir 				bFound = pPopped == aToDo.pCluster;
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir 				// die bewegte Shell merken
1988cdf0e10cSrcweir 				aToDoCopy.Push( SfxToDo_Impl( sal_False, aToDo.bDelete, sal_False, *pPopped) );
1989cdf0e10cSrcweir 			}
1990cdf0e10cSrcweir 			while ( aToDo.bUntil && !bFound );
1991cdf0e10cSrcweir 			DBG_ASSERT( bFound, "wrong SfxShell popped" );
1992cdf0e10cSrcweir 		}
1993cdf0e10cSrcweir 
1994cdf0e10cSrcweir 		if ( nToDo == 0 )
1995cdf0e10cSrcweir 			pImp->aToDoStack.Clear();
1996cdf0e10cSrcweir 	}
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir 	// ggf. Bindings invalidieren
1999cdf0e10cSrcweir 	if ( !pSfxApp->IsDowning() )
2000cdf0e10cSrcweir 	{
2001cdf0e10cSrcweir 		if ( bModify )
2002cdf0e10cSrcweir 		{
2003cdf0e10cSrcweir 			pImp->pCachedServ1 = 0;
2004cdf0e10cSrcweir 			pImp->pCachedServ2 = 0;
2005cdf0e10cSrcweir 		}
2006cdf0e10cSrcweir 
2007cdf0e10cSrcweir 		InvalidateBindings_Impl( bModify );
2008cdf0e10cSrcweir 	}
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir 	pImp->bFlushing = sal_False;
2011cdf0e10cSrcweir 	pImp->bUpdated = sal_False; // nicht nur bei bModify, falls Doc/Template-Config
2012cdf0e10cSrcweir 	bFlushed = sal_True;
2013cdf0e10cSrcweir 	DBG_TRACE("Successfully flushed dispatcher!");
2014cdf0e10cSrcweir 
2015cdf0e10cSrcweir 	// in der 2. Runde die Shells aktivieren und ggf. l"oschen
2016cdf0e10cSrcweir 	for ( nToDo = aToDoCopy.Count()-1; nToDo >= 0; --nToDo )
2017cdf0e10cSrcweir 	{
2018cdf0e10cSrcweir 		SfxToDo_Impl aToDo( aToDoCopy.Top(nToDo) );
2019cdf0e10cSrcweir 		if ( aToDo.bPush )
2020cdf0e10cSrcweir 		{
2021cdf0e10cSrcweir 			if ( pImp->bActive )
2022cdf0e10cSrcweir 				aToDo.pCluster->DoActivate_Impl(pImp->pFrame, sal_True);
2023cdf0e10cSrcweir 		}
2024cdf0e10cSrcweir 		else
2025cdf0e10cSrcweir 			if ( pImp->bActive )
2026cdf0e10cSrcweir 				aToDo.pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
2027cdf0e10cSrcweir 	}
2028cdf0e10cSrcweir 	for ( nToDo = aToDoCopy.Count()-1; nToDo >= 0; --nToDo )
2029cdf0e10cSrcweir 	{
2030cdf0e10cSrcweir 		SfxToDo_Impl aToDo( aToDoCopy.Top(nToDo) );
2031cdf0e10cSrcweir 		if ( aToDo.bDelete ) delete aToDo.pCluster;
2032cdf0e10cSrcweir 	}
2033cdf0e10cSrcweir 	sal_Bool bAwakeBindings = aToDoCopy.Count() != 0;
2034cdf0e10cSrcweir 	if( bAwakeBindings )
2035cdf0e10cSrcweir 		aToDoCopy.Clear();
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir 	// Wenn bei Activate/Deactivate/Delete weitere Stackbewegungen erfolgt sind :
2038cdf0e10cSrcweir 	if (!bFlushed)
2039cdf0e10cSrcweir 		// falls jemand Push/Pop gerufen hat, wurde auch EnterReg gerufen!
2040cdf0e10cSrcweir 		FlushImpl();
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir     if( bAwakeBindings && GetBindings() )
2043cdf0e10cSrcweir 		GetBindings()->DLEAVEREGISTRATIONS();
2044cdf0e10cSrcweir 	DBG_PROFSTOP(SfxDispatcherFlush);
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir 	for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
2047cdf0e10cSrcweir 		pImp->aFixedObjBars[n].nResId = 0;
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir #ifdef DBG_UTIL
2050cdf0e10cSrcweir 	aMsg += " done";
2051cdf0e10cSrcweir 	DbgTrace( aMsg.GetBuffer() );
2052cdf0e10cSrcweir #endif
2053cdf0e10cSrcweir }
2054cdf0e10cSrcweir 
2055cdf0e10cSrcweir //--------------------------------------------------------------------
SetSlotFilter(HACK (hier muss mal ein enum rein)sal_Bool bEnable,sal_uInt16 nCount,const sal_uInt16 * pSIDs)2056cdf0e10cSrcweir void SfxDispatcher::SetSlotFilter
2057cdf0e10cSrcweir (
2058cdf0e10cSrcweir 	HACK(hier muss mal ein enum rein)
2059cdf0e10cSrcweir 	sal_Bool 			bEnable,	/*	sal_True:
2060cdf0e10cSrcweir 									nur angegebene Slots enablen,
2061cdf0e10cSrcweir 									alle anderen disablen
2062cdf0e10cSrcweir 
2063cdf0e10cSrcweir 									sal_False:
2064cdf0e10cSrcweir 									die angegebenen Slots disablen,
2065cdf0e10cSrcweir 									alle anderen zun"achst enablen
2066cdf0e10cSrcweir 								*/
2067cdf0e10cSrcweir 	sal_uInt16 			nCount, 	// 	Anzahl der SIDs im folgenden Array
2068cdf0e10cSrcweir 	const sal_uInt16*	pSIDs		// 	sortiertes Array von 'nCount' SIDs
2069cdf0e10cSrcweir )
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir /*	[Beschreibung]
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir 	Mit dieser Methode wird ein Filter gesetzt, mit dem gezielt Slots
2074cdf0e10cSrcweir 	enabled bzw. disabled werden k"onnen. Das "ubergebene Array mu\s
2075cdf0e10cSrcweir 	bis zum Dtor bzw. n"achsten <SetSlotFilter()> erhalten bleiben, es
2076cdf0e10cSrcweir 	wird nicht vom Dispatcher gel"oscht, es kann daher static sein.
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir 	In ReadOnly-Dokumenten kann man mit 'bEnable==2' quasi das ReadOnlyDoc
2079cdf0e10cSrcweir 	Flag von Slots "ubersteuern, dieser werden also wieder gefunden. Auf
2080cdf0e10cSrcweir 	andere Slots hat das dann keine Auswirkung.
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir 	[Beispiel]
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir 	gezieltes disablen der Slots 1, 2 und 3:
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir 		static sal_uInt16 __READONLY_DATA pSIDs[] = { 1, 2, 3 };
2088cdf0e10cSrcweir 		pDisp->SetSlotFilter( sal_False, sizeof(pSIDs)/sizeof(sal_uInt16), pSIDs );
2089cdf0e10cSrcweir 
2090cdf0e10cSrcweir 	nur die Slots 5, 6 und 7 zulassen:
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir 		static sal_uInt16 __READONLY_DATA pSIDs[] = { 5, 6, 7 };
2093cdf0e10cSrcweir 		pDisp->SetSlotFilter( sal_True, sizeof(pSIDs)/sizeof(sal_uInt16), pSIDs );
2094cdf0e10cSrcweir 
2095cdf0e10cSrcweir 	Filter ausschalten:
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir 		pDisp->SetSlotFilter();
2098cdf0e10cSrcweir */
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir {
2101cdf0e10cSrcweir #ifdef DBG_UTIL
2102cdf0e10cSrcweir 	// Array "uberpr"ufen
2103cdf0e10cSrcweir 	for ( sal_uInt16 n = 1; n < nCount; ++n )
2104cdf0e10cSrcweir 		DBG_ASSERT( pSIDs[n] > pSIDs[n-1], "SetSlotFilter: SIDs not sortet" );
2105cdf0e10cSrcweir #endif
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir 	if ( pImp->pFilterSIDs )
2108cdf0e10cSrcweir 		pImp->pFilterSIDs = 0;
2109cdf0e10cSrcweir 
2110cdf0e10cSrcweir 	pImp->bFilterEnabling = bEnable;
2111cdf0e10cSrcweir 	pImp->nFilterCount = nCount;
2112cdf0e10cSrcweir 	pImp->pFilterSIDs = pSIDs;
2113cdf0e10cSrcweir 
2114cdf0e10cSrcweir 	GetBindings()->InvalidateAll(sal_True);
2115cdf0e10cSrcweir }
2116cdf0e10cSrcweir 
2117cdf0e10cSrcweir //--------------------------------------------------------------------
2118cdf0e10cSrcweir EXTERN_C
2119cdf0e10cSrcweir #if defined( PM2 ) && (!defined( CSET ) && !defined ( MTW ) && !defined( WTC ))
2120cdf0e10cSrcweir int _stdcall
2121cdf0e10cSrcweir #else
2122cdf0e10cSrcweir #ifdef WNT
2123cdf0e10cSrcweir int _cdecl
2124cdf0e10cSrcweir #else
2125cdf0e10cSrcweir int
2126cdf0e10cSrcweir #endif
2127cdf0e10cSrcweir #endif
2128cdf0e10cSrcweir 
SfxCompareSIDs_Impl(const void * pSmaller,const void * pBigger)2129cdf0e10cSrcweir SfxCompareSIDs_Impl( const void* pSmaller, const void* pBigger )
2130cdf0e10cSrcweir {
2131cdf0e10cSrcweir 	DBG_MEMTEST();
2132cdf0e10cSrcweir 	return ( (long) *((sal_uInt16*)pSmaller) ) - ( (long) *((sal_uInt16*)pBigger) );
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir 
2135cdf0e10cSrcweir //--------------------------------------------------------------------
IsSlotEnabledByFilter_Impl(sal_uInt16 nSID) const2136cdf0e10cSrcweir sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir /*	[Beschreibung]
2139cdf0e10cSrcweir 
2140cdf0e10cSrcweir 	Sucht 'nSID' in dem mit <SetSlotFilter()> gesetzten Filter und
2141cdf0e10cSrcweir 	liefert sal_True, falls die SID erlaubt ist, bzw. sal_False, falls sie
2142cdf0e10cSrcweir 	durch den Filter disabled ist.
2143cdf0e10cSrcweir 
2144cdf0e10cSrcweir 	[R"uckgabewert]
2145cdf0e10cSrcweir 	sal_Bool				0	=>	disabled
2146cdf0e10cSrcweir 						1	=> 	enabled
2147cdf0e10cSrcweir 						2	=>	enabled even if ReadOnlyDoc
2148cdf0e10cSrcweir */
2149cdf0e10cSrcweir 
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir 	// kein Filter?
2152cdf0e10cSrcweir 	if ( 0 == pImp->nFilterCount )
2153cdf0e10cSrcweir 		// => alle SIDs erlaubt
2154cdf0e10cSrcweir 		return sal_True;
2155cdf0e10cSrcweir 
2156cdf0e10cSrcweir 	// suchen
2157cdf0e10cSrcweir 	sal_Bool bFound = 0 != bsearch( &nSID, pImp->pFilterSIDs, pImp->nFilterCount,
2158cdf0e10cSrcweir 								sizeof(sal_uInt16), SfxCompareSIDs_Impl );
2159cdf0e10cSrcweir 
2160cdf0e10cSrcweir 	// even if ReadOnlyDoc
2161cdf0e10cSrcweir 	if ( 2 == pImp->bFilterEnabling )
2162cdf0e10cSrcweir 		return bFound ? 2 : 1;
2163cdf0e10cSrcweir 	// sonst je nach Negativ/Positiv Filter
2164cdf0e10cSrcweir 	return pImp->bFilterEnabling ? bFound : !bFound;
2165cdf0e10cSrcweir }
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir //--------------------------------------------------------------------
_TryIntercept_Impl(sal_uInt16 nSlot,SfxSlotServer & rServer,sal_Bool bSelf)2168cdf0e10cSrcweir sal_Bool SfxDispatcher::_TryIntercept_Impl
2169cdf0e10cSrcweir (
2170cdf0e10cSrcweir 	sal_uInt16				nSlot,		// zu suchende Slot-Id
2171cdf0e10cSrcweir 	SfxSlotServer&	 	rServer,	// zu f"uellende <SfxSlotServer>-Instanz
2172cdf0e10cSrcweir 	sal_Bool				bSelf
2173cdf0e10cSrcweir )
2174cdf0e10cSrcweir {
2175cdf0e10cSrcweir 	// Eventuell geh"ort der parent auch zu einer Komponente
2176cdf0e10cSrcweir 	SfxDispatcher *pParent = pImp->pParent;
2177cdf0e10cSrcweir 	sal_uInt16 nLevels = pImp->aStack.Count();
2178cdf0e10cSrcweir 	while ( pParent && pParent->pImp->pFrame )
2179cdf0e10cSrcweir 	{
2180cdf0e10cSrcweir 		if ( pParent->pImp->pFrame->GetFrame().HasComponent() )
2181cdf0e10cSrcweir 		{
2182cdf0e10cSrcweir 			// Components d"urfen intercepten
2183cdf0e10cSrcweir 			if ( pParent->_TryIntercept_Impl( nSlot, rServer, sal_True ) )
2184cdf0e10cSrcweir 			{
2185cdf0e10cSrcweir 				// Die eigenen Shells zum Shelllevel hinzuz"ahlen
2186cdf0e10cSrcweir 				rServer.SetShellLevel( rServer.GetShellLevel() + nLevels );
2187cdf0e10cSrcweir 				return sal_True;
2188cdf0e10cSrcweir 			}
2189cdf0e10cSrcweir 			else
2190cdf0e10cSrcweir 				// Keine weitere Interception
2191cdf0e10cSrcweir 				break;
2192cdf0e10cSrcweir 		}
2193cdf0e10cSrcweir 		else
2194cdf0e10cSrcweir 			nLevels = nLevels + pParent->pImp->aStack.Count();
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir 		pParent = pParent->pImp->pParent;
2197cdf0e10cSrcweir 	}
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir 	if ( bSelf )
2200cdf0e10cSrcweir 	{
2201cdf0e10cSrcweir 		// Die ComponentViewShell befragen
2202cdf0e10cSrcweir 		Flush();
2203cdf0e10cSrcweir 		SfxShell *pObjShell = GetShell(0);
2204cdf0e10cSrcweir 		SfxInterface *pIFace = pObjShell->GetInterface();
2205cdf0e10cSrcweir 		const SfxSlot *pSlot = pIFace->GetSlot(nSlot);
2206cdf0e10cSrcweir 
2207cdf0e10cSrcweir 		if ( pSlot )
2208cdf0e10cSrcweir 		{
2209cdf0e10cSrcweir 			rServer.SetSlot(pSlot);
2210cdf0e10cSrcweir 			rServer.SetShellLevel(0);
2211cdf0e10cSrcweir #ifdef DBG_UTILx
2212cdf0e10cSrcweir 			String aMsg( nSlot );
2213cdf0e10cSrcweir 			aMsg += " intercepted";
2214cdf0e10cSrcweir 			DbgTrace( aMsg.GetBuffer() );
2215cdf0e10cSrcweir #endif
2216cdf0e10cSrcweir 			return sal_True;
2217cdf0e10cSrcweir 		}
2218cdf0e10cSrcweir 	}
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir 	return sal_False;
2221cdf0e10cSrcweir }
2222cdf0e10cSrcweir 
_FindServer(sal_uInt16 nSlot,SfxSlotServer & rServer,sal_Bool bModal)2223cdf0e10cSrcweir sal_Bool SfxDispatcher::_FindServer
2224cdf0e10cSrcweir (
2225cdf0e10cSrcweir 	sal_uInt16				nSlot,		// zu suchende Slot-Id
2226cdf0e10cSrcweir 	SfxSlotServer&	 rServer,	 // zu f"uellnde <SfxSlotServer>-Instanz
2227cdf0e10cSrcweir 	sal_Bool				bModal		// trotz ModalMode
2228cdf0e10cSrcweir )
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir /*	[Beschreibung]
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir 	Diese Hilfsmethode sucht den <Slot-Server>, der nSlot zur Zeit bedient.
2233cdf0e10cSrcweir 	Als Ergebnis wird rServer entsprechend gef"ullt.
2234cdf0e10cSrcweir 
2235cdf0e10cSrcweir 	Falls bekannt, kann das SfxInterface mitgegeben werden, von welchem
2236cdf0e10cSrcweir 	nSlot momentan bedient wird.
2237cdf0e10cSrcweir 
2238cdf0e10cSrcweir 	Vor der Suche nach nSlot wird der SfxDispatcher geflusht.
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir 
2241cdf0e10cSrcweir 	[R"uckgabewert]
2242cdf0e10cSrcweir 
2243cdf0e10cSrcweir 	sal_Bool				sal_True
2244cdf0e10cSrcweir 						Der Slot wurde gefunden, rServer ist g"ultig.
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir 						sal_False
2247cdf0e10cSrcweir 						Der Slot wird momentan nicht bedient, rServer
2248cdf0e10cSrcweir 						ist ung"ultig.
2249cdf0e10cSrcweir */
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir {
2252cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::_FindServer);
2253cdf0e10cSrcweir 
2254cdf0e10cSrcweir 	// Dispatcher gelockt? (SID_HELP_PI trotzdem durchlassen)
2255cdf0e10cSrcweir 	if ( IsLocked(nSlot) )
2256cdf0e10cSrcweir 	{
2257cdf0e10cSrcweir 		pImp->bInvalidateOnUnlock = sal_True;
2258cdf0e10cSrcweir 		return sal_False;
2259cdf0e10cSrcweir 	}
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir 	// Anzahl der Shells auf den verkettenten Dispatchern z"ahlen
2262cdf0e10cSrcweir 	Flush();
2263cdf0e10cSrcweir 	sal_uInt16 nTotCount = pImp->aStack.Count();
2264cdf0e10cSrcweir 	if ( pImp->pParent )
2265cdf0e10cSrcweir 	{
2266cdf0e10cSrcweir 		SfxDispatcher *pParent = pImp->pParent;
2267cdf0e10cSrcweir 		while ( pParent )
2268cdf0e10cSrcweir 		{
2269cdf0e10cSrcweir 			nTotCount = nTotCount + pParent->pImp->aStack.Count();
2270cdf0e10cSrcweir 			pParent = pParent->pImp->pParent;
2271cdf0e10cSrcweir 		}
2272cdf0e10cSrcweir 	}
2273cdf0e10cSrcweir 
2274cdf0e10cSrcweir 	// Verb-Slot?
2275cdf0e10cSrcweir 	if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END)
2276cdf0e10cSrcweir 	{
2277cdf0e10cSrcweir 		for ( sal_uInt16 nShell = 0;; ++nShell )
2278cdf0e10cSrcweir 		{
2279cdf0e10cSrcweir             SfxShell *pSh = GetShell(nShell);
2280cdf0e10cSrcweir             if ( pSh == NULL )
2281cdf0e10cSrcweir                 return false;
2282cdf0e10cSrcweir 			if ( pSh->ISA(SfxViewShell) )
2283cdf0e10cSrcweir 			{
2284cdf0e10cSrcweir                 const SfxSlot* pSlot = pSh->GetVerbSlot_Impl(nSlot);
2285cdf0e10cSrcweir                 if ( pSlot )
2286cdf0e10cSrcweir                 {
2287cdf0e10cSrcweir                     rServer.SetShellLevel(nShell);
2288cdf0e10cSrcweir                     rServer.SetSlot( pSlot );
2289cdf0e10cSrcweir                     return true;
2290cdf0e10cSrcweir                 }
2291cdf0e10cSrcweir 			}
2292cdf0e10cSrcweir 		}
2293cdf0e10cSrcweir 	}
2294cdf0e10cSrcweir 
2295cdf0e10cSrcweir 	// SID gegen gesetzten Filter pr"ufen
2296cdf0e10cSrcweir 	sal_uInt16 nSlotEnableMode=0;
2297cdf0e10cSrcweir 	if ( pImp->pFrame )
2298cdf0e10cSrcweir 	{
2299cdf0e10cSrcweir 		nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot );
2300cdf0e10cSrcweir 		if ( 0 == nSlotEnableMode )
2301cdf0e10cSrcweir 			return sal_False;
2302cdf0e10cSrcweir 	}
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir 	// im Quiet-Mode nur Parent-Dispatcher
2305cdf0e10cSrcweir 	if ( pImp->bQuiet )
2306cdf0e10cSrcweir 	{
2307cdf0e10cSrcweir 		if ( pImp->pParent )
2308cdf0e10cSrcweir 		{
2309cdf0e10cSrcweir 			sal_Bool bRet = pImp->pParent->_FindServer( nSlot, rServer, bModal );
2310cdf0e10cSrcweir 			rServer.SetShellLevel
2311cdf0e10cSrcweir 				( rServer.GetShellLevel() + pImp->aStack.Count() );
2312cdf0e10cSrcweir 			return bRet;
2313cdf0e10cSrcweir 		}
2314cdf0e10cSrcweir 		else
2315cdf0e10cSrcweir 			return sal_False;
2316cdf0e10cSrcweir 	}
2317cdf0e10cSrcweir 
2318cdf0e10cSrcweir 	sal_Bool bReadOnly = ( 2 != nSlotEnableMode && pImp->bReadOnly );
2319cdf0e10cSrcweir //				( pImp->pFrame && pImp->pFrame->GetObjectShell() );
2320cdf0e10cSrcweir //				  pImp->pFrame->GetObjectShell()->IsLoading() );
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir 	// durch alle Shells der verketteten Dispatchern von oben nach unten suchen
2323cdf0e10cSrcweir #ifdef DBG_UTILx
2324cdf0e10cSrcweir 	String aStack( "Stack:" );
2325cdf0e10cSrcweir #endif
2326cdf0e10cSrcweir 	sal_uInt16 nFirstShell = pImp->bModal && !bModal ? pImp->aStack.Count() : 0;
2327cdf0e10cSrcweir 	for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i )
2328cdf0e10cSrcweir 	{
2329cdf0e10cSrcweir 		SfxShell *pObjShell = GetShell(i);
2330cdf0e10cSrcweir 		SfxInterface *pIFace = pObjShell->GetInterface();
2331cdf0e10cSrcweir 		const SfxSlot *pSlot = pIFace->GetSlot(nSlot);
2332cdf0e10cSrcweir 
2333cdf0e10cSrcweir 		if ( pSlot && pSlot->nDisableFlags && ( pSlot->nDisableFlags & pObjShell->GetDisableFlags() ) != 0 )
2334cdf0e10cSrcweir 			return sal_False;
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir 		if ( pSlot && !( pSlot->nFlags & SFX_SLOT_READONLYDOC ) && bReadOnly )
2337cdf0e10cSrcweir 			return sal_False;
2338cdf0e10cSrcweir 
2339cdf0e10cSrcweir 		if ( pSlot )
2340cdf0e10cSrcweir 		{
2341cdf0e10cSrcweir 			// Slot geh"ort zum Container?
2342cdf0e10cSrcweir 			bool bIsContainerSlot = pSlot->IsMode(SFX_SLOT_CONTAINER);
2343cdf0e10cSrcweir             bool bIsInPlace = pImp->pFrame && pImp->pFrame->GetObjectShell()->IsInPlaceActive();
2344cdf0e10cSrcweir 
2345cdf0e10cSrcweir 			// Shell geh"ort zum Server?
2346cdf0e10cSrcweir 			// AppDispatcher oder IPFrame-Dispatcher
2347cdf0e10cSrcweir 			bool bIsServerShell = !pImp->pFrame || bIsInPlace;
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir 			// Nat"urlich sind ServerShell-Slots auch ausf"uhrbar, wenn sie auf
2350cdf0e10cSrcweir 			// einem Container-Dispatcher ohne IPClient ausgef"uhrt werden sollen.
2351cdf0e10cSrcweir 			if ( !bIsServerShell )
2352cdf0e10cSrcweir 			{
2353cdf0e10cSrcweir 				SfxViewShell *pViewSh = pImp->pFrame->GetViewShell();
2354cdf0e10cSrcweir                 bIsServerShell = !pViewSh || !pViewSh->GetUIActiveClient();
2355cdf0e10cSrcweir 			}
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir 			// Shell geh"ort zum Container?
2358cdf0e10cSrcweir 			// AppDispatcher oder kein IPFrameDispatcher
2359cdf0e10cSrcweir 			bool bIsContainerShell = !pImp->pFrame || !bIsInPlace;
2360cdf0e10cSrcweir 			// Shell und Slot passen zusammen
2361cdf0e10cSrcweir 			if ( !( ( bIsContainerSlot && bIsContainerShell ) ||
2362cdf0e10cSrcweir 					( !bIsContainerSlot && bIsServerShell ) ) )
2363cdf0e10cSrcweir 				pSlot = 0;
2364cdf0e10cSrcweir 		}
2365cdf0e10cSrcweir 
2366cdf0e10cSrcweir #ifdef DBG_UTILx
2367cdf0e10cSrcweir 		if ( pSlot )
2368cdf0e10cSrcweir 		{
2369cdf0e10cSrcweir 			String aMsg( nSlot );
2370cdf0e10cSrcweir 			aMsg += " found in ";
2371cdf0e10cSrcweir 			aMsg += pObjShell->GetInterface()->GetClassName();
2372cdf0e10cSrcweir 			DbgTrace( aMsg.GetBuffer() );
2373cdf0e10cSrcweir 		}
2374cdf0e10cSrcweir 		else
2375cdf0e10cSrcweir 		{
2376cdf0e10cSrcweir 			aStack += " ";
2377cdf0e10cSrcweir 			aStack += pObjShell->GetInterface()->GetClassName();
2378cdf0e10cSrcweir 		}
2379cdf0e10cSrcweir #endif
2380cdf0e10cSrcweir 		if ( pSlot && !IsAllowed( nSlot ) )
2381cdf0e10cSrcweir 		{
2382cdf0e10cSrcweir 			pSlot = NULL;
2383cdf0e10cSrcweir 		}
2384cdf0e10cSrcweir 
2385cdf0e10cSrcweir 		if ( pSlot )
2386cdf0e10cSrcweir 		{
2387cdf0e10cSrcweir 			rServer.SetSlot(pSlot);
2388cdf0e10cSrcweir 			rServer.SetShellLevel(i);
2389cdf0e10cSrcweir 			return sal_True;
2390cdf0e10cSrcweir 		}
2391cdf0e10cSrcweir 	}
2392cdf0e10cSrcweir 
2393cdf0e10cSrcweir #ifdef DBG_UTILx
2394cdf0e10cSrcweir 	String aMsg( nSlot );
2395cdf0e10cSrcweir 	aMsg += " not found in ";
2396cdf0e10cSrcweir 	aMsg += aStack;
2397cdf0e10cSrcweir 	DbgTrace( aMsg.GetBuffer() );
2398cdf0e10cSrcweir #endif
2399cdf0e10cSrcweir 	return sal_False;
2400cdf0e10cSrcweir }
2401cdf0e10cSrcweir 
HasSlot_Impl(sal_uInt16 nSlot)2402cdf0e10cSrcweir sal_Bool SfxDispatcher::HasSlot_Impl( sal_uInt16 nSlot )
2403cdf0e10cSrcweir {
2404cdf0e10cSrcweir 	Flush();
2405cdf0e10cSrcweir 	sal_uInt16 nTotCount = pImp->aStack.Count();
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir     if ( pImp->pParent && !pImp->pParent->pImp->pFrame )
2408cdf0e10cSrcweir     {
2409cdf0e10cSrcweir         // the last frame also uses the AppDispatcher
2410cdf0e10cSrcweir         nTotCount = nTotCount + pImp->aStack.Count();
2411cdf0e10cSrcweir     }
2412cdf0e10cSrcweir 
2413cdf0e10cSrcweir 	if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END)
2414cdf0e10cSrcweir 	{
2415cdf0e10cSrcweir         // Verb-Slot?
2416cdf0e10cSrcweir 		for ( sal_uInt16 nShell = 0;; ++nShell )
2417cdf0e10cSrcweir 		{
2418cdf0e10cSrcweir             SfxShell *pSh = GetShell(nShell);
2419cdf0e10cSrcweir             if ( pSh == NULL )
2420cdf0e10cSrcweir                 return false;
2421cdf0e10cSrcweir 			if ( pSh->ISA(SfxViewShell) )
2422cdf0e10cSrcweir 				return true;
2423cdf0e10cSrcweir 		}
2424cdf0e10cSrcweir 	}
2425cdf0e10cSrcweir 
2426cdf0e10cSrcweir 	// SID gegen gesetzten Filter pr"ufen
2427cdf0e10cSrcweir 	sal_uInt16 nSlotEnableMode=0;
2428cdf0e10cSrcweir 	if ( pImp->pFrame )
2429cdf0e10cSrcweir 	{
2430cdf0e10cSrcweir 		nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot );
2431cdf0e10cSrcweir 		if ( 0 == nSlotEnableMode )
2432cdf0e10cSrcweir 			return sal_False;
2433cdf0e10cSrcweir 	}
2434cdf0e10cSrcweir 
2435cdf0e10cSrcweir 	// im Quiet-Mode nur Parent-Dispatcher
2436cdf0e10cSrcweir 	if ( pImp->bQuiet )
2437cdf0e10cSrcweir 		return sal_False;
2438cdf0e10cSrcweir 
2439cdf0e10cSrcweir 	sal_Bool bReadOnly = ( 2 != nSlotEnableMode && pImp->bReadOnly );
2440cdf0e10cSrcweir //				( pImp->pFrame && pImp->pFrame->GetObjectShell());
2441cdf0e10cSrcweir //				  pImp->pFrame->GetObjectShell()->IsLoading() );
2442cdf0e10cSrcweir 
2443cdf0e10cSrcweir 	for ( sal_uInt16 i=0 ; i < nTotCount; ++i )
2444cdf0e10cSrcweir 	{
2445cdf0e10cSrcweir 		SfxShell *pObjShell = GetShell(i);
2446cdf0e10cSrcweir 		SfxInterface *pIFace = pObjShell->GetInterface();
2447cdf0e10cSrcweir 		const SfxSlot *pSlot = pIFace->GetSlot(nSlot);
2448cdf0e10cSrcweir 		if ( pSlot && pSlot->nDisableFlags && ( pSlot->nDisableFlags & pObjShell->GetDisableFlags() ) != 0 )
2449cdf0e10cSrcweir 			return sal_False;
2450cdf0e10cSrcweir 
2451cdf0e10cSrcweir 		if ( pSlot && !( pSlot->nFlags & SFX_SLOT_READONLYDOC ) && bReadOnly )
2452cdf0e10cSrcweir 			return sal_False;
2453cdf0e10cSrcweir 
2454cdf0e10cSrcweir 		if ( pSlot )
2455cdf0e10cSrcweir 		{
2456cdf0e10cSrcweir 			// Slot geh"ort zum Container?
2457cdf0e10cSrcweir 			bool bIsContainerSlot = pSlot->IsMode(SFX_SLOT_CONTAINER);
2458cdf0e10cSrcweir             bool bIsInPlace = pImp->pFrame && pImp->pFrame->GetObjectShell()->IsInPlaceActive();
2459cdf0e10cSrcweir 
2460cdf0e10cSrcweir             // Shell geh"ort zum Server?
2461cdf0e10cSrcweir 			// AppDispatcher oder IPFrame-Dispatcher
2462cdf0e10cSrcweir 			bool bIsServerShell = !pImp->pFrame || bIsInPlace;
2463cdf0e10cSrcweir 
2464cdf0e10cSrcweir 			// Nat"urlich sind ServerShell-Slots auch ausf"uhrbar, wenn sie auf
2465cdf0e10cSrcweir 			// einem Container-Dispatcher ohne IPClient ausgef"uhrt werden sollen.
2466cdf0e10cSrcweir 			if ( !bIsServerShell )
2467cdf0e10cSrcweir 			{
2468cdf0e10cSrcweir 				SfxViewShell *pViewSh = pImp->pFrame->GetViewShell();
2469cdf0e10cSrcweir                 bIsServerShell = !pViewSh || !pViewSh->GetUIActiveClient();
2470cdf0e10cSrcweir 			}
2471cdf0e10cSrcweir 
2472cdf0e10cSrcweir 			// Shell geh"ort zum Container?
2473cdf0e10cSrcweir 			// AppDispatcher oder kein IPFrameDispatcher
2474cdf0e10cSrcweir 			bool bIsContainerShell = !pImp->pFrame || !bIsInPlace;
2475cdf0e10cSrcweir 
2476cdf0e10cSrcweir 			// Shell und Slot passen zusammen
2477cdf0e10cSrcweir 			if ( !( ( bIsContainerSlot && bIsContainerShell ) ||
2478cdf0e10cSrcweir 					( !bIsContainerSlot && bIsServerShell ) ) )
2479cdf0e10cSrcweir 				pSlot = 0;
2480cdf0e10cSrcweir 		}
2481cdf0e10cSrcweir 
2482cdf0e10cSrcweir 		if ( pSlot && !IsAllowed( nSlot ) )
2483cdf0e10cSrcweir 			pSlot = NULL;
2484cdf0e10cSrcweir 
2485cdf0e10cSrcweir 		if ( pSlot )
2486cdf0e10cSrcweir 			return sal_True;
2487cdf0e10cSrcweir 	}
2488cdf0e10cSrcweir 
2489cdf0e10cSrcweir 	return sal_False;
2490cdf0e10cSrcweir }
2491cdf0e10cSrcweir 
2492cdf0e10cSrcweir 
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir //--------------------------------------------------------------------
_FillState(const SfxSlotServer & rSvr,SfxItemSet & rState,const SfxSlot * pRealSlot)2495cdf0e10cSrcweir sal_Bool SfxDispatcher::_FillState
2496cdf0e10cSrcweir (
2497cdf0e10cSrcweir 	const SfxSlotServer& rSvr,		 // abzufragende <Slot-Server>
2498cdf0e10cSrcweir 	SfxItemSet& 			rState, 	// zu f"ullendes <SfxItemSet>
2499cdf0e10cSrcweir 	const SfxSlot*			pRealSlot	// ggf. der tats"achliche Slot
2500cdf0e10cSrcweir )
2501cdf0e10cSrcweir 
2502cdf0e10cSrcweir /*	[Beschreibung]
2503cdf0e10cSrcweir 
2504cdf0e10cSrcweir 	Hilfsmethode zum Abfragen des Status des <Slot-Server>s rSvr.
2505cdf0e10cSrcweir 	In rState m"ussen die gew"unschten Slots-Ids (teilweise in Which-Ids
2506cdf0e10cSrcweir 	des betreffenden Pools umgewandelt) vorhanden sein.
2507cdf0e10cSrcweir 
2508cdf0e10cSrcweir 	Der SfxDispatcher wird vor der Abfrage geflusht.
2509cdf0e10cSrcweir */
2510cdf0e10cSrcweir 
2511cdf0e10cSrcweir {
2512cdf0e10cSrcweir 	SFX_STACK(SfxDispatcher::_FillState);
2513cdf0e10cSrcweir 
2514cdf0e10cSrcweir 	DBG_PROFSTART(SfxDispatcherFillState);
2515cdf0e10cSrcweir 
2516cdf0e10cSrcweir 	const SfxSlot *pSlot = rSvr.GetSlot();
2517cdf0e10cSrcweir 	if ( pSlot && IsLocked( pSlot->GetSlotId() ) )
2518cdf0e10cSrcweir 	{
2519cdf0e10cSrcweir 		pImp->bInvalidateOnUnlock = sal_True;
2520cdf0e10cSrcweir 		DBG_PROFSTOP(SfxDispatcherFillState);
2521cdf0e10cSrcweir 		return sal_False;
2522cdf0e10cSrcweir 	}
2523cdf0e10cSrcweir 
2524cdf0e10cSrcweir 	if ( pSlot )
2525cdf0e10cSrcweir 	{
2526cdf0e10cSrcweir 		DBG_ASSERT(bFlushed, "Dispatcher not flushed after retrieving slot servers!");
2527cdf0e10cSrcweir         if ( !bFlushed )
2528cdf0e10cSrcweir             return sal_False;
2529cdf0e10cSrcweir 		// Flush();
2530cdf0e10cSrcweir 
2531cdf0e10cSrcweir 		// Objekt ermitteln und Message an diesem Objekt aufrufen
2532cdf0e10cSrcweir 		SfxShell *pSh = GetShell(rSvr.GetShellLevel());
2533cdf0e10cSrcweir 		DBG_ASSERT(pSh, "ObjektShell nicht gefunden");
2534cdf0e10cSrcweir 
2535cdf0e10cSrcweir 		SfxStateFunc pFunc;
2536cdf0e10cSrcweir 
2537cdf0e10cSrcweir 		if (pRealSlot)
2538cdf0e10cSrcweir 			pFunc = pRealSlot->GetStateFnc();
2539cdf0e10cSrcweir 		else
2540cdf0e10cSrcweir 			pFunc = pSlot->GetStateFnc();
2541cdf0e10cSrcweir 
2542cdf0e10cSrcweir 		pSh->CallState( pFunc, rState );
2543cdf0e10cSrcweir #ifdef DBG_UTIL
2544cdf0e10cSrcweir 		// pr"ufen, ob IDL (SlotMap) und aktuelle Items "ubereinstimmen
2545cdf0e10cSrcweir 		if ( DbgIsAssertWarning() && rState.Count() )
2546cdf0e10cSrcweir 		{
2547cdf0e10cSrcweir 			SfxInterface *pIF = pSh->GetInterface();
2548cdf0e10cSrcweir 			SfxItemIter aIter( rState );
2549cdf0e10cSrcweir 			for ( const SfxPoolItem *pItem = aIter.FirstItem();
2550cdf0e10cSrcweir 				  pItem;
2551cdf0e10cSrcweir 				  pItem = aIter.NextItem() )
2552cdf0e10cSrcweir 				if ( !IsInvalidItem(pItem) && !pItem->ISA(SfxVoidItem) )
2553cdf0e10cSrcweir 				{
2554cdf0e10cSrcweir 					sal_uInt16 nSlotId = rState.GetPool()->GetSlotId(pItem->Which());
2555cdf0e10cSrcweir 					if ( !pItem->IsA(pIF->GetSlot(nSlotId)->GetType()->Type()) )
2556cdf0e10cSrcweir 					{
2557cdf0e10cSrcweir 						ByteString aMsg( "item-type unequal to IDL (=> no BASIC)" );
2558cdf0e10cSrcweir 						aMsg += "\nwith SID: ";
2559cdf0e10cSrcweir 						aMsg += ByteString::CreateFromInt32( nSlotId );
2560cdf0e10cSrcweir 						aMsg += "\nin ";
2561cdf0e10cSrcweir 						aMsg += pIF->GetClassName();
2562cdf0e10cSrcweir 						DbgOut( aMsg.GetBuffer(), DBG_OUT_ERROR, __FILE__, __LINE__);
2563cdf0e10cSrcweir 					}
2564cdf0e10cSrcweir 				}
2565cdf0e10cSrcweir 		}
2566cdf0e10cSrcweir #endif
2567cdf0e10cSrcweir 
2568cdf0e10cSrcweir 		DBG_PROFSTOP(SfxDispatcherFillState);
2569cdf0e10cSrcweir 		return sal_True;
2570cdf0e10cSrcweir 	}
2571cdf0e10cSrcweir 
2572cdf0e10cSrcweir 	DBG_PROFSTOP(SfxDispatcherFillState);
2573cdf0e10cSrcweir 	return sal_False;
2574cdf0e10cSrcweir }
2575cdf0e10cSrcweir 
2576cdf0e10cSrcweir //--------------------------------------------------------------------
_Execute(const SfxSlotServer & rSvr)2577cdf0e10cSrcweir const SfxPoolItem* SfxDispatcher::_Execute( const SfxSlotServer &rSvr )
2578cdf0e10cSrcweir 
2579cdf0e10cSrcweir /*  [Beschreibung]
2580cdf0e10cSrcweir 
2581cdf0e10cSrcweir 	Diese Methode f"uhrt einen Request "uber einen gecachten <Slot-Server>
2582cdf0e10cSrcweir 	aus.
2583cdf0e10cSrcweir */
2584cdf0e10cSrcweir 
2585cdf0e10cSrcweir {
2586cdf0e10cSrcweir 	const SfxSlot *pSlot = rSvr.GetSlot();
2587cdf0e10cSrcweir 	if ( IsLocked( pSlot->GetSlotId() ) )
2588cdf0e10cSrcweir 		return 0;
2589cdf0e10cSrcweir 
2590cdf0e10cSrcweir 	if ( pSlot )
2591cdf0e10cSrcweir 	{
2592cdf0e10cSrcweir 		Flush();
2593cdf0e10cSrcweir 
2594cdf0e10cSrcweir 		if ( pSlot->IsMode(SFX_SLOT_ASYNCHRON) )
2595cdf0e10cSrcweir 			//! ignoriert rSvr
2596cdf0e10cSrcweir 		{
2597cdf0e10cSrcweir 			SfxShell *pShell = GetShell( rSvr.GetShellLevel() );
2598cdf0e10cSrcweir 			SfxDispatcher *pDispat = this;
2599cdf0e10cSrcweir 			while ( pDispat )
2600cdf0e10cSrcweir 			{
2601cdf0e10cSrcweir 				sal_uInt16 nShellCount = pDispat->pImp->aStack.Count();
2602cdf0e10cSrcweir 				for ( sal_uInt16 n=0; n<nShellCount; n++ )
2603cdf0e10cSrcweir 					if ( pShell == pDispat->pImp->aStack.Top(n) )
2604cdf0e10cSrcweir 					{
2605cdf0e10cSrcweir                         pDispat->pImp->xPoster->Post(
2606cdf0e10cSrcweir                             new SfxRequest( pSlot->GetSlotId(),
2607cdf0e10cSrcweir                                 SFX_CALLMODE_RECORD, pShell->GetPool() ) );
2608cdf0e10cSrcweir //                        pDispat->pImp->xPoster->Post(new Executer(
2609cdf0e10cSrcweir //                                new SfxRequest( pSlot->GetSlotId(),
2610cdf0e10cSrcweir //                                    SFX_CALLMODE_RECORD, pShell->GetPool() ),
2611cdf0e10cSrcweir //                                pSlot, n ));
2612cdf0e10cSrcweir 						return 0;
2613cdf0e10cSrcweir 					}
2614cdf0e10cSrcweir 			}
2615cdf0e10cSrcweir 		}
2616cdf0e10cSrcweir 		else
2617cdf0e10cSrcweir 		{
2618cdf0e10cSrcweir 			// Objekt ermitteln und Message an diesem Objekt aufrufen
2619cdf0e10cSrcweir 			SfxShell *pSh = GetShell(rSvr.GetShellLevel());
2620cdf0e10cSrcweir 			SfxRequest aReq( pSlot->GetSlotId(), SFX_CALLMODE_RECORD, pSh->GetPool() );
2621cdf0e10cSrcweir 			if ( Call_Impl( *pSh, *pSlot, aReq, sal_True ) ) // von Bindings immer recorden
2622cdf0e10cSrcweir 				return aReq.GetReturnValue();
2623cdf0e10cSrcweir 		}
2624cdf0e10cSrcweir 	}
2625cdf0e10cSrcweir 	return 0;
2626cdf0e10cSrcweir }
2627cdf0e10cSrcweir 
2628cdf0e10cSrcweir //----------------------------------------------------------------------
ExecutePopup(sal_uInt16 nConfigId,Window * pWin,const Point * pPos,const SfxPoolItem *,...)2629cdf0e10cSrcweir void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId,
2630cdf0e10cSrcweir 								  Window *pWin, const Point *pPos,
2631cdf0e10cSrcweir 								  const SfxPoolItem *, ... )
2632cdf0e10cSrcweir {
2633cdf0e10cSrcweir     ExecutePopup( nConfigId, pWin, pPos );
2634cdf0e10cSrcweir }
2635cdf0e10cSrcweir 
Popup(sal_uInt16 nConfigId,Window * pWin,const Point * pPos)2636cdf0e10cSrcweir SfxPopupMenuManager* SfxDispatcher::Popup( sal_uInt16 nConfigId,Window *pWin, const Point *pPos )
2637cdf0e10cSrcweir {
2638cdf0e10cSrcweir 	SfxDispatcher &rDisp = *SFX_APP()->GetDispatcher_Impl();
2639cdf0e10cSrcweir 	sal_uInt16 nShLevel = 0;
2640cdf0e10cSrcweir 	SfxShell *pSh;
2641cdf0e10cSrcweir 	nShLevel=0;
2642cdf0e10cSrcweir 
2643cdf0e10cSrcweir 	if ( rDisp.pImp->bQuiet )
2644cdf0e10cSrcweir 	{
2645cdf0e10cSrcweir 		nConfigId = 0;
2646cdf0e10cSrcweir 		nShLevel = rDisp.pImp->aStack.Count();
2647cdf0e10cSrcweir 	}
2648cdf0e10cSrcweir 
2649cdf0e10cSrcweir 	Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
2650cdf0e10cSrcweir     for ( pSh = rDisp.GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.GetShell(nShLevel) )
2651cdf0e10cSrcweir 	{
2652cdf0e10cSrcweir 		const ResId& rResId = pSh->GetInterface()->GetPopupMenuResId();
2653cdf0e10cSrcweir         if ( ( nConfigId == 0 && rResId.GetId() ) || ( nConfigId != 0 && rResId.GetId() == nConfigId ) )
2654cdf0e10cSrcweir 		{
2655cdf0e10cSrcweir                 return SfxPopupMenuManager::Popup( rResId, rDisp.GetFrame(), pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
2656cdf0e10cSrcweir 		}
2657cdf0e10cSrcweir 	}
2658cdf0e10cSrcweir 	return 0;
2659cdf0e10cSrcweir }
2660cdf0e10cSrcweir 
2661cdf0e10cSrcweir 
2662cdf0e10cSrcweir //----------------------------------------------------------------------
ExecutePopup(sal_uInt16 nConfigId,Window * pWin,const Point * pPos)2663cdf0e10cSrcweir void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId, Window *pWin, const Point *pPos )
2664cdf0e10cSrcweir {
2665cdf0e10cSrcweir     SfxDispatcher &rDisp = *SFX_APP()->GetDispatcher_Impl();
2666cdf0e10cSrcweir 	sal_uInt16 nShLevel = 0;
2667cdf0e10cSrcweir 	SfxShell *pSh;
2668cdf0e10cSrcweir /*
2669cdf0e10cSrcweir 	const SvVerbList *pVerbList = 0;
2670cdf0e10cSrcweir 	sal_uInt16 nMaxShellLevel = rDisp.pImp->aStack.Count();
2671cdf0e10cSrcweir 	for ( pSh = rDisp.GetShell(nShLevel);
2672cdf0e10cSrcweir 		  pSh && nShLevel < nMaxShellLevel ;
2673cdf0e10cSrcweir 		  ++nShLevel, pSh = rDisp.GetShell(nShLevel) )
2674cdf0e10cSrcweir 	{
2675cdf0e10cSrcweir         if ( pSh->GetVerbs() )
2676cdf0e10cSrcweir 		{
2677cdf0e10cSrcweir 			pVerbList = pSh->GetVerbs();
2678cdf0e10cSrcweir 			break;
2679cdf0e10cSrcweir 		}
2680cdf0e10cSrcweir     }
2681cdf0e10cSrcweir */
2682cdf0e10cSrcweir 	nShLevel=0;
2683cdf0e10cSrcweir 	if ( rDisp.pImp->bQuiet )
2684cdf0e10cSrcweir 	{
2685cdf0e10cSrcweir 		nConfigId = 0;
2686cdf0e10cSrcweir 		nShLevel = rDisp.pImp->aStack.Count();
2687cdf0e10cSrcweir 	}
2688cdf0e10cSrcweir 
2689cdf0e10cSrcweir     Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
2690cdf0e10cSrcweir     for ( pSh = rDisp.GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.GetShell(nShLevel) )
2691cdf0e10cSrcweir 	{
2692cdf0e10cSrcweir 		const ResId& rResId = pSh->GetInterface()->GetPopupMenuResId();
2693cdf0e10cSrcweir         if ( ( nConfigId == 0 && rResId.GetId() ) || ( nConfigId != 0 && rResId.GetId() == nConfigId ) )
2694cdf0e10cSrcweir 		{
2695cdf0e10cSrcweir             //SfxPopupMenuManager aPop( rResId.GetId(), *rDisp.GetBindings() );
2696cdf0e10cSrcweir             //aPop.SetResMgr(rResId.GetResMgr());
2697cdf0e10cSrcweir             //aPop.AddClipboardFunctions();
2698cdf0e10cSrcweir             //aPop.Initialize();
2699cdf0e10cSrcweir             //if ( pVerbList && pVerbList->Count() )
2700cdf0e10cSrcweir             //    aPop.InsertVerbs(pVerbList);
2701cdf0e10cSrcweir             //aPop.RemoveDisabledEntries();
2702cdf0e10cSrcweir             //aPop.Execute( pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
2703cdf0e10cSrcweir             SfxPopupMenuManager::ExecutePopup( rResId, rDisp.GetFrame(), pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
2704cdf0e10cSrcweir 			return;
2705cdf0e10cSrcweir 		}
2706cdf0e10cSrcweir 	}
2707cdf0e10cSrcweir }
2708cdf0e10cSrcweir 
2709cdf0e10cSrcweir //----------------------------------------------------------------------
ExecutePopup(const ResId & rId,Window * pWin,const Point * pPos)2710cdf0e10cSrcweir void SfxDispatcher::ExecutePopup( const ResId &rId, Window *pWin, const Point *pPos )
2711cdf0e10cSrcweir {
2712cdf0e10cSrcweir     Window *pWindow = pWin ? pWin : pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
2713cdf0e10cSrcweir /*
2714cdf0e10cSrcweir 	SfxPopupMenuManager aPop( rId, *GetBindings() );
2715cdf0e10cSrcweir 	aPop.AddClipboardFunctions();
2716cdf0e10cSrcweir 	aPop.Initialize();
2717cdf0e10cSrcweir 	aPop.RemoveDisabledEntries();
2718cdf0e10cSrcweir     aPop.Execute( pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
2719cdf0e10cSrcweir */
2720cdf0e10cSrcweir     SfxPopupMenuManager::ExecutePopup( rId, GetFrame(), pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
2721cdf0e10cSrcweir }
2722cdf0e10cSrcweir 
2723cdf0e10cSrcweir //--------------------------------------------------------------------
Lock(sal_Bool bLock)2724cdf0e10cSrcweir void SfxDispatcher::Lock( sal_Bool bLock )
2725cdf0e10cSrcweir 
2726cdf0e10cSrcweir /*  [Beschreibung]
2727cdf0e10cSrcweir 
2728cdf0e10cSrcweir 	Mit dieser Methode kann der SfxDispatcher gesperrt und freigegeben
2729cdf0e10cSrcweir 	werden. Ein gesperrter SfxDispatcher f"uhrt keine <SfxRequest>s mehr
2730cdf0e10cSrcweir 	aus und liefert keine Status-Informationen mehr. Er verh"alt sich
2731cdf0e10cSrcweir 	so als w"aren alle Slots disabled.
2732cdf0e10cSrcweir */
2733cdf0e10cSrcweir 
2734cdf0e10cSrcweir {
2735cdf0e10cSrcweir     SfxBindings* pBindings = GetBindings();
2736cdf0e10cSrcweir 	if ( !bLock && pImp->bLocked && pImp->bInvalidateOnUnlock )
2737cdf0e10cSrcweir 	{
2738cdf0e10cSrcweir         if ( pBindings )
2739cdf0e10cSrcweir             pBindings->InvalidateAll(sal_True);
2740cdf0e10cSrcweir 		pImp->bInvalidateOnUnlock = sal_False;
2741cdf0e10cSrcweir 	}
2742cdf0e10cSrcweir     else if ( pBindings )
2743cdf0e10cSrcweir         pBindings->InvalidateAll(sal_False);
2744cdf0e10cSrcweir 	pImp->bLocked = bLock;
2745cdf0e10cSrcweir     if ( !bLock )
2746cdf0e10cSrcweir     {
2747cdf0e10cSrcweir         sal_uInt16 nCount = pImp->aReqArr.Count();
2748cdf0e10cSrcweir         for ( sal_uInt16 i=0; i<nCount; i++ )
2749cdf0e10cSrcweir             pImp->xPoster->Post( pImp->aReqArr[i] );
2750cdf0e10cSrcweir         pImp->aReqArr.Remove( 0, nCount );
2751cdf0e10cSrcweir     }
2752cdf0e10cSrcweir }
2753cdf0e10cSrcweir 
GetObjectBarId(sal_uInt16 nPos) const2754cdf0e10cSrcweir sal_uInt32 SfxDispatcher::GetObjectBarId( sal_uInt16 nPos ) const
2755cdf0e10cSrcweir {
2756cdf0e10cSrcweir 	return pImp->aObjBars[nPos].nResId;
2757cdf0e10cSrcweir }
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir //--------------------------------------------------------------------
ResetObjectBars_Impl()2760cdf0e10cSrcweir void SfxDispatcher::ResetObjectBars_Impl()
2761cdf0e10cSrcweir 
2762cdf0e10cSrcweir /*  [Beschreibung]
2763cdf0e10cSrcweir 
2764cdf0e10cSrcweir 	Mit dieser Methode werden alle Objectbar-Anforderungen, die dieser
2765cdf0e10cSrcweir 	Dispatcher an das AppWindow hat, beseitigt.
2766cdf0e10cSrcweir */
2767cdf0e10cSrcweir {
2768cdf0e10cSrcweir 	for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
2769cdf0e10cSrcweir 		pImp->aObjBars[n].nResId = 0;
2770cdf0e10cSrcweir 	pImp->aChildWins.Remove(0, pImp->aChildWins.Count());
2771cdf0e10cSrcweir }
2772cdf0e10cSrcweir 
2773cdf0e10cSrcweir 
2774cdf0e10cSrcweir //--------------------------------------------------------------------
DebugOutput_Impl() const2775cdf0e10cSrcweir void SfxDispatcher::DebugOutput_Impl() const
2776cdf0e10cSrcweir {
2777cdf0e10cSrcweir #ifdef DBG_UTIL
2778cdf0e10cSrcweir 
2779cdf0e10cSrcweir 	sal_uInt16 nOld = (sal_uInt16) DbgGetData()->nTraceOut;
2780cdf0e10cSrcweir 	DbgGetData()->nTraceOut = DBG_OUT_FILE;
2781cdf0e10cSrcweir 
2782cdf0e10cSrcweir 	if (bFlushed)
2783cdf0e10cSrcweir 		DBG_TRACE("Flushed");
2784cdf0e10cSrcweir 	if (pImp->bUpdated)
2785cdf0e10cSrcweir 		DBG_TRACE("Updated");
2786cdf0e10cSrcweir 
2787cdf0e10cSrcweir 	for ( sal_uInt16 nShell = pImp->aStack.Count(); nShell > 0; --nShell )
2788cdf0e10cSrcweir 	{
2789cdf0e10cSrcweir 		SfxShell *pShell = GetShell(nShell-1);
2790cdf0e10cSrcweir 		const SfxInterface *pIFace = pShell->GetInterface();
2791cdf0e10cSrcweir 		DBG_TRACE (pIFace->GetClassName());
2792cdf0e10cSrcweir 	}
2793cdf0e10cSrcweir 
2794cdf0e10cSrcweir 	DbgGetData()->nTraceOut = nOld;
2795cdf0e10cSrcweir 
2796cdf0e10cSrcweir #endif
2797cdf0e10cSrcweir }
2798cdf0e10cSrcweir 
LockUI_Impl(sal_Bool bLock)2799cdf0e10cSrcweir void SfxDispatcher::LockUI_Impl( sal_Bool bLock )
2800cdf0e10cSrcweir {
2801cdf0e10cSrcweir 	sal_Bool bWasLocked = pImp->bUILocked;
2802cdf0e10cSrcweir 	pImp->bUILocked = bLock;
2803cdf0e10cSrcweir 	if ( !bLock && bWasLocked )
2804cdf0e10cSrcweir 		Update_Impl( sal_True );
2805cdf0e10cSrcweir }
2806cdf0e10cSrcweir 
2807cdf0e10cSrcweir //-------------------------------------------------------------------------
HideUI(sal_Bool bHide)2808cdf0e10cSrcweir void SfxDispatcher::HideUI( sal_Bool bHide )
2809cdf0e10cSrcweir {
2810cdf0e10cSrcweir //	if ( !bHide && pImp->bReadOnly )
2811cdf0e10cSrcweir //		bHide = sal_True;
2812cdf0e10cSrcweir 	sal_Bool bWasHidden = pImp->bNoUI;
2813cdf0e10cSrcweir 	pImp->bNoUI = bHide;
2814cdf0e10cSrcweir 	if ( pImp->pFrame )
2815cdf0e10cSrcweir 	{
2816cdf0e10cSrcweir         SfxViewFrame* pTop = pImp->pFrame->GetTopViewFrame();
2817cdf0e10cSrcweir         if ( pTop && pTop->GetBindings().GetDispatcher() == this )
2818cdf0e10cSrcweir         {
2819cdf0e10cSrcweir 			SfxFrame& rFrame = pTop->GetFrame();
2820cdf0e10cSrcweir             if ( rFrame.IsMenuBarOn_Impl() )
2821cdf0e10cSrcweir             {
2822cdf0e10cSrcweir                 com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
2823cdf0e10cSrcweir                 if ( xPropSet.is() )
2824cdf0e10cSrcweir                 {
2825cdf0e10cSrcweir                     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
2826cdf0e10cSrcweir                     com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
2827cdf0e10cSrcweir                     aValue >>= xLayoutManager;
2828cdf0e10cSrcweir                     if ( xLayoutManager.is() )
2829cdf0e10cSrcweir                         xLayoutManager->setVisible( !bHide );
2830cdf0e10cSrcweir                 }
2831cdf0e10cSrcweir             }
2832cdf0e10cSrcweir         }
2833cdf0e10cSrcweir     }
2834cdf0e10cSrcweir 
2835cdf0e10cSrcweir 	if ( bHide != bWasHidden )
2836cdf0e10cSrcweir 		Update_Impl( sal_True );
2837cdf0e10cSrcweir }
2838cdf0e10cSrcweir 
SetReadOnly_Impl(sal_Bool bOn)2839cdf0e10cSrcweir void SfxDispatcher::SetReadOnly_Impl( sal_Bool bOn )
2840cdf0e10cSrcweir {
2841cdf0e10cSrcweir 	pImp->bReadOnly = bOn;
2842cdf0e10cSrcweir //	pImp->bNoUI = bOn;
2843cdf0e10cSrcweir }
2844cdf0e10cSrcweir 
GetReadOnly_Impl() const2845cdf0e10cSrcweir sal_Bool SfxDispatcher::GetReadOnly_Impl() const
2846cdf0e10cSrcweir {
2847cdf0e10cSrcweir 	return pImp->bReadOnly;
2848cdf0e10cSrcweir }
2849cdf0e10cSrcweir 
2850cdf0e10cSrcweir //-------------------------------------------------------------------------
SetQuietMode_Impl(sal_Bool bOn)2851cdf0e10cSrcweir void SfxDispatcher::SetQuietMode_Impl( sal_Bool bOn )
2852cdf0e10cSrcweir 
2853cdf0e10cSrcweir /*	[Beschreibung]
2854cdf0e10cSrcweir 
2855cdf0e10cSrcweir 	Bei 'bOn' stellt sich dieser Dispatcher quasi tot und leitet alles
2856cdf0e10cSrcweir 	an den Parent-Dispatcher weiter.
2857cdf0e10cSrcweir */
2858cdf0e10cSrcweir 
2859cdf0e10cSrcweir {
2860cdf0e10cSrcweir 	pImp->bQuiet = bOn;
2861cdf0e10cSrcweir     SfxBindings* pBindings = GetBindings();
2862cdf0e10cSrcweir     if ( pBindings )
2863cdf0e10cSrcweir         pBindings->InvalidateAll(sal_True);
2864cdf0e10cSrcweir }
2865cdf0e10cSrcweir 
2866cdf0e10cSrcweir //-------------------------------------------------------------------------
SetModalMode_Impl(sal_Bool bOn)2867cdf0e10cSrcweir void SfxDispatcher::SetModalMode_Impl( sal_Bool bOn )
2868cdf0e10cSrcweir 
2869cdf0e10cSrcweir /*	[Beschreibung]
2870cdf0e10cSrcweir 
2871cdf0e10cSrcweir 	Bei 'bOn' werden nur noch Slots des Parent-Dispatchers gefunden.
2872cdf0e10cSrcweir */
2873cdf0e10cSrcweir 
2874cdf0e10cSrcweir {
2875cdf0e10cSrcweir 	pImp->bModal = bOn;
2876cdf0e10cSrcweir     SfxBindings* pBindings = GetBindings();
2877cdf0e10cSrcweir     if ( pBindings )
2878cdf0e10cSrcweir         pBindings->InvalidateAll(sal_True);
2879cdf0e10cSrcweir }
2880cdf0e10cSrcweir 
SetExecuteMode(sal_uInt16 nMode)2881cdf0e10cSrcweir void SfxDispatcher::SetExecuteMode( sal_uInt16 nMode )
2882cdf0e10cSrcweir {
2883cdf0e10cSrcweir 	pImp->nStandardMode = nMode;
2884cdf0e10cSrcweir }
2885cdf0e10cSrcweir 
QueryState(sal_uInt16 nSlot,const SfxPoolItem * & rpState)2886cdf0e10cSrcweir SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSlot, const SfxPoolItem* &rpState )
2887cdf0e10cSrcweir {
2888cdf0e10cSrcweir 	SfxShell *pShell = 0;
2889cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
2890cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False, sal_False ) )
2891cdf0e10cSrcweir 	{
2892cdf0e10cSrcweir 		rpState = pShell->GetSlotState(nSlot);
2893cdf0e10cSrcweir 		if ( !rpState )
2894cdf0e10cSrcweir 			return SFX_ITEM_DISABLED;
2895cdf0e10cSrcweir 		else
2896cdf0e10cSrcweir 			return SFX_ITEM_AVAILABLE;
2897cdf0e10cSrcweir 	}
2898cdf0e10cSrcweir 
2899cdf0e10cSrcweir 	return SFX_ITEM_DISABLED;
2900cdf0e10cSrcweir }
2901cdf0e10cSrcweir 
QueryState(sal_uInt16 nSID,::com::sun::star::uno::Any & rAny)2902cdf0e10cSrcweir SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, ::com::sun::star::uno::Any& rAny )
2903cdf0e10cSrcweir {
2904cdf0e10cSrcweir 	SfxShell *pShell = 0;
2905cdf0e10cSrcweir 	const SfxSlot *pSlot = 0;
2906cdf0e10cSrcweir 	if ( GetShellAndSlot_Impl( nSID, &pShell, &pSlot, sal_False, sal_False ) )
2907cdf0e10cSrcweir 	{
2908cdf0e10cSrcweir         const SfxPoolItem* pItem( 0 );
2909cdf0e10cSrcweir 
2910cdf0e10cSrcweir         pItem = pShell->GetSlotState( nSID );
2911cdf0e10cSrcweir 		if ( !pItem )
2912cdf0e10cSrcweir 			return SFX_ITEM_DISABLED;
2913cdf0e10cSrcweir         else
2914cdf0e10cSrcweir         {
2915cdf0e10cSrcweir             ::com::sun::star::uno::Any aState;
2916cdf0e10cSrcweir             if ( !pItem->ISA(SfxVoidItem) )
2917cdf0e10cSrcweir             {
2918cdf0e10cSrcweir                 sal_uInt16 nSubId( 0 );
2919cdf0e10cSrcweir                 SfxItemPool& rPool = pShell->GetPool();
2920cdf0e10cSrcweir                 sal_uInt16 nWhich = rPool.GetWhich( nSID );
2921cdf0e10cSrcweir                 if ( rPool.GetMetric( nWhich ) == SFX_MAPUNIT_TWIP )
2922cdf0e10cSrcweir                     nSubId |= CONVERT_TWIPS;
2923cdf0e10cSrcweir                 pItem->QueryValue( aState, (sal_uInt8)nSubId );
2924cdf0e10cSrcweir             }
2925cdf0e10cSrcweir             rAny = aState;
2926cdf0e10cSrcweir 
2927cdf0e10cSrcweir             return SFX_ITEM_AVAILABLE;
2928cdf0e10cSrcweir         }
2929cdf0e10cSrcweir 	}
2930cdf0e10cSrcweir 
2931cdf0e10cSrcweir 	return SFX_ITEM_DISABLED;
2932cdf0e10cSrcweir }
2933cdf0e10cSrcweir 
IsReadOnlyShell_Impl(sal_uInt16 nShell) const2934cdf0e10cSrcweir sal_Bool SfxDispatcher::IsReadOnlyShell_Impl( sal_uInt16 nShell ) const
2935cdf0e10cSrcweir {
2936cdf0e10cSrcweir 	sal_uInt16 nShellCount = pImp->aStack.Count();
2937cdf0e10cSrcweir 	if ( nShell < nShellCount )
2938cdf0e10cSrcweir 	{
2939cdf0e10cSrcweir         SfxShell* pShell = pImp->aStack.Top( nShell );
2940cdf0e10cSrcweir         if( pShell->ISA( SfxModule ) || pShell->ISA( SfxApplication ) || pShell->ISA( SfxViewFrame ) )
2941cdf0e10cSrcweir             return sal_False;
2942cdf0e10cSrcweir         else
2943cdf0e10cSrcweir             return pImp->bReadOnly;
2944cdf0e10cSrcweir 	}
2945cdf0e10cSrcweir 	else if ( pImp->pParent )
2946cdf0e10cSrcweir 		return pImp->pParent->IsReadOnlyShell_Impl( nShell - nShellCount );
2947cdf0e10cSrcweir 	return sal_True;
2948cdf0e10cSrcweir }
2949cdf0e10cSrcweir 
2950cdf0e10cSrcweir // Ein dirty trick, um an die Methoden der private base class von
2951cdf0e10cSrcweir // SfxShellStack_Impl heranzukommen
2952cdf0e10cSrcweir class StackAccess_Impl : public SfxShellStack_Implarr_
2953cdf0e10cSrcweir {};
2954cdf0e10cSrcweir 
InsertShell_Impl(SfxShell & rShell,sal_uInt16 nPos)2955cdf0e10cSrcweir void SfxDispatcher::InsertShell_Impl( SfxShell& rShell, sal_uInt16 nPos )
2956cdf0e10cSrcweir {
2957cdf0e10cSrcweir 	Flush();
2958cdf0e10cSrcweir 
2959cdf0e10cSrcweir 	// Der cast geht, weil SfxShellStack_Impl keine eigenen member hat
2960cdf0e10cSrcweir 	((StackAccess_Impl*) (&pImp->aStack))->Insert( nPos, &rShell );
2961cdf0e10cSrcweir 	rShell.SetDisableFlags( pImp->nDisableFlags );
2962cdf0e10cSrcweir 	rShell.DoActivate_Impl(pImp->pFrame, sal_True);
2963cdf0e10cSrcweir 
2964cdf0e10cSrcweir 	if ( !SFX_APP()->IsDowning() )
2965cdf0e10cSrcweir 	{
2966cdf0e10cSrcweir 		pImp->bUpdated = sal_False;
2967cdf0e10cSrcweir 		pImp->pCachedServ1 = 0;
2968cdf0e10cSrcweir 		pImp->pCachedServ2 = 0;
2969cdf0e10cSrcweir 		InvalidateBindings_Impl(sal_True);
2970cdf0e10cSrcweir 	}
2971cdf0e10cSrcweir }
2972cdf0e10cSrcweir 
RemoveShell_Impl(SfxShell & rShell)2973cdf0e10cSrcweir void SfxDispatcher::RemoveShell_Impl( SfxShell& rShell )
2974cdf0e10cSrcweir {
2975cdf0e10cSrcweir 	Flush();
2976cdf0e10cSrcweir 
2977cdf0e10cSrcweir 	// Der cast geht, weil SfxShellStack_Impl keine eigenen member hat
2978cdf0e10cSrcweir 	StackAccess_Impl& rStack = *((StackAccess_Impl*) (&pImp->aStack));
2979cdf0e10cSrcweir 	sal_uInt16 nCount = rStack.Count();
2980cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<nCount; ++n )
2981cdf0e10cSrcweir 	{
2982cdf0e10cSrcweir 		if ( rStack[n] == &rShell )
2983cdf0e10cSrcweir 		{
2984cdf0e10cSrcweir 			rStack.Remove( n );
2985cdf0e10cSrcweir 			rShell.SetDisableFlags( 0 );
2986cdf0e10cSrcweir 			rShell.DoDeactivate_Impl(pImp->pFrame, sal_True);
2987cdf0e10cSrcweir 			break;
2988cdf0e10cSrcweir 		}
2989cdf0e10cSrcweir 	}
2990cdf0e10cSrcweir 
2991cdf0e10cSrcweir 	if ( !SFX_APP()->IsDowning() )
2992cdf0e10cSrcweir 	{
2993cdf0e10cSrcweir 		pImp->bUpdated = sal_False;
2994cdf0e10cSrcweir 		pImp->pCachedServ1 = 0;
2995cdf0e10cSrcweir 		pImp->pCachedServ2 = 0;
2996cdf0e10cSrcweir 		InvalidateBindings_Impl(sal_True);
2997cdf0e10cSrcweir 	}
2998cdf0e10cSrcweir }
2999cdf0e10cSrcweir 
IsAllowed(sal_uInt16 nSlot) const3000cdf0e10cSrcweir sal_Bool SfxDispatcher::IsAllowed
3001cdf0e10cSrcweir (
3002cdf0e10cSrcweir 	sal_uInt16 nSlot
3003cdf0e10cSrcweir ) const
3004cdf0e10cSrcweir /*
3005cdf0e10cSrcweir 	[Beschreibung]
3006cdf0e10cSrcweir 	Die Methode prueft, ob der Zugriff auf diese Schnittstelle erlaubt ist.
3007cdf0e10cSrcweir 	*/
3008cdf0e10cSrcweir {
3009cdf0e10cSrcweir 	if ( !pImp->pDisableList )
3010cdf0e10cSrcweir 	{
3011cdf0e10cSrcweir 		return sal_True;
3012cdf0e10cSrcweir 	}
3013cdf0e10cSrcweir 
3014cdf0e10cSrcweir 	// BinSearch in der DisableListe
3015cdf0e10cSrcweir 	SvUShorts& rList = *pImp->pDisableList;
3016cdf0e10cSrcweir 	sal_uInt16 nCount = rList.Count();
3017cdf0e10cSrcweir 	sal_uInt16 nLow = 0, nMid = 0, nHigh;
3018cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
3019cdf0e10cSrcweir 	nHigh = nCount - 1;
3020cdf0e10cSrcweir 
3021cdf0e10cSrcweir 	while ( !bFound && nLow <= nHigh )
3022cdf0e10cSrcweir 	{
3023cdf0e10cSrcweir 		nMid = (nLow + nHigh) >> 1;
3024cdf0e10cSrcweir 		DBG_ASSERT( nMid < nCount, "bsearch ist buggy" );
3025cdf0e10cSrcweir 
3026cdf0e10cSrcweir 		int nDiff = (int) nSlot - (int) rList[nMid];
3027cdf0e10cSrcweir 		if ( nDiff < 0)
3028cdf0e10cSrcweir 		{
3029cdf0e10cSrcweir 			if ( nMid == 0 )
3030cdf0e10cSrcweir 				break;
3031cdf0e10cSrcweir 			nHigh = nMid - 1;
3032cdf0e10cSrcweir 		}
3033cdf0e10cSrcweir 		else if ( nDiff > 0 )
3034cdf0e10cSrcweir 		{
3035cdf0e10cSrcweir 			nLow = nMid + 1;
3036cdf0e10cSrcweir 			if ( nLow == 0 )
3037cdf0e10cSrcweir 				break;
3038cdf0e10cSrcweir 		}
3039cdf0e10cSrcweir 		else
3040cdf0e10cSrcweir 			bFound = sal_True;
3041cdf0e10cSrcweir 	}
3042cdf0e10cSrcweir 
3043cdf0e10cSrcweir #ifdef _DEBUG
3044cdf0e10cSrcweir 	// Slot in der Liste gefunden ?
3045cdf0e10cSrcweir 	sal_uInt16 nPos = bFound ? nMid : nLow;
3046cdf0e10cSrcweir 
3047cdf0e10cSrcweir 	DBG_ASSERT( nPos <= nCount, "" );
3048cdf0e10cSrcweir 	DBG_ASSERT( nPos == nCount || nSlot <= rList[nPos], "" );
3049cdf0e10cSrcweir 	DBG_ASSERT( nPos == 0 || nSlot > rList[nPos-1], "" );
3050cdf0e10cSrcweir 	DBG_ASSERT( ( (nPos+1) >= nCount ) || nSlot < rList[nPos+1], "" );
3051cdf0e10cSrcweir #endif
3052cdf0e10cSrcweir 
3053cdf0e10cSrcweir 	return !bFound;
3054cdf0e10cSrcweir }
3055cdf0e10cSrcweir 
InvalidateBindings_Impl(sal_Bool bModify)3056cdf0e10cSrcweir void SfxDispatcher::InvalidateBindings_Impl( sal_Bool bModify )
3057cdf0e10cSrcweir {
3058cdf0e10cSrcweir 	// App-Dispatcher?
3059cdf0e10cSrcweir 	if ( IsAppDispatcher() )
3060cdf0e10cSrcweir 	{
3061cdf0e10cSrcweir 		for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst();
3062cdf0e10cSrcweir 				pFrame;
3063cdf0e10cSrcweir 				pFrame = SfxViewFrame::GetNext( *pFrame ) )
3064cdf0e10cSrcweir 			pFrame->GetBindings().InvalidateAll(bModify);
3065cdf0e10cSrcweir 	}
3066cdf0e10cSrcweir 	else
3067cdf0e10cSrcweir 	{
3068cdf0e10cSrcweir 		SfxDispatcher *pDisp = GetBindings()->GetDispatcher_Impl();
3069cdf0e10cSrcweir 		while ( pDisp )
3070cdf0e10cSrcweir 		{
3071cdf0e10cSrcweir 			if ( pDisp == this )
3072cdf0e10cSrcweir 			{
3073cdf0e10cSrcweir 				GetBindings()->InvalidateAll( bModify );
3074cdf0e10cSrcweir 				break;
3075cdf0e10cSrcweir 			}
3076cdf0e10cSrcweir 
3077cdf0e10cSrcweir 			pDisp = pDisp->pImp->pParent;
3078cdf0e10cSrcweir 		}
3079cdf0e10cSrcweir 	}
3080cdf0e10cSrcweir }
3081cdf0e10cSrcweir 
IsUpdated_Impl() const3082cdf0e10cSrcweir sal_Bool SfxDispatcher::IsUpdated_Impl() const
3083cdf0e10cSrcweir {
3084cdf0e10cSrcweir 	return pImp->bUpdated;
3085cdf0e10cSrcweir }
3086cdf0e10cSrcweir 
SetDisableFlags(sal_uInt32 nFlags)3087cdf0e10cSrcweir void SfxDispatcher::SetDisableFlags( sal_uInt32 nFlags )
3088cdf0e10cSrcweir {
3089cdf0e10cSrcweir 	pImp->nDisableFlags = nFlags;
3090cdf0e10cSrcweir 	for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
3091cdf0e10cSrcweir 		pImp->aStack.Top( (sal_uInt16) i )->SetDisableFlags( nFlags );
3092cdf0e10cSrcweir }
3093cdf0e10cSrcweir 
GetDisableFlags() const3094cdf0e10cSrcweir sal_uInt32 SfxDispatcher::GetDisableFlags() const
3095cdf0e10cSrcweir {
3096cdf0e10cSrcweir 	return pImp->nDisableFlags;
3097cdf0e10cSrcweir }
3098cdf0e10cSrcweir 
GetModule() const3099cdf0e10cSrcweir SfxModule* SfxDispatcher::GetModule() const
3100cdf0e10cSrcweir {
3101cdf0e10cSrcweir 	for ( sal_uInt16 nShell = 0;; ++nShell )
3102cdf0e10cSrcweir 	{
3103cdf0e10cSrcweir         SfxShell *pSh = GetShell(nShell);
3104cdf0e10cSrcweir         if ( pSh == NULL )
3105cdf0e10cSrcweir             return 0;
3106cdf0e10cSrcweir 		if ( pSh->ISA(SfxModule) )
3107cdf0e10cSrcweir 			return (SfxModule*) pSh;
3108cdf0e10cSrcweir 	}
3109cdf0e10cSrcweir }
3110