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