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 31*cdf0e10cSrcweir #include <hash_map> 32*cdf0e10cSrcweir #include <svl/itempool.hxx> 33*cdf0e10cSrcweir #include <svl/itemiter.hxx> 34*cdf0e10cSrcweir #include <svl/eitem.hxx> 35*cdf0e10cSrcweir #include <svl/aeitem.hxx> 36*cdf0e10cSrcweir #include <svl/intitem.hxx> 37*cdf0e10cSrcweir #include <svl/stritem.hxx> 38*cdf0e10cSrcweir #include <svl/visitem.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterception.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/frame/FeatureStateEvent.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/frame/DispatchDescriptor.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 49*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 50*cdf0e10cSrcweir #include <svtools/itemdel.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #ifndef GCC 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // wg. nInReschedule 56*cdf0e10cSrcweir #include "appdata.hxx" 57*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 58*cdf0e10cSrcweir #include <sfx2/msg.hxx> 59*cdf0e10cSrcweir #include "statcach.hxx" 60*cdf0e10cSrcweir #include <sfx2/ctrlitem.hxx> 61*cdf0e10cSrcweir #include <sfx2/app.hxx> 62*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 63*cdf0e10cSrcweir #include <sfx2/request.hxx> 64*cdf0e10cSrcweir #include <sfx2/objface.hxx> 65*cdf0e10cSrcweir #include "sfxtypes.hxx" 66*cdf0e10cSrcweir #include "workwin.hxx" 67*cdf0e10cSrcweir #include <sfx2/unoctitm.hxx> 68*cdf0e10cSrcweir #include <sfx2/sfx.hrc> 69*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx> 70*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 71*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 72*cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir #include <comphelper/uieventslogger.hxx> 75*cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp> 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir using namespace ::com::sun::star; 79*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 80*cdf0e10cSrcweir using namespace ::com::sun::star::util; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir DBG_NAME(SfxBindingsMsgPos) 83*cdf0e10cSrcweir DBG_NAME(SfxBindingsUpdateServers) 84*cdf0e10cSrcweir DBG_NAME(SfxBindingsCreateSet) 85*cdf0e10cSrcweir DBG_NAME(SfxBindingsUpdateCtrl1) 86*cdf0e10cSrcweir DBG_NAME(SfxBindingsUpdateCtrl2) 87*cdf0e10cSrcweir DBG_NAME(SfxBindingsNextJob_Impl0) 88*cdf0e10cSrcweir DBG_NAME(SfxBindingsNextJob_Impl) 89*cdf0e10cSrcweir DBG_NAME(SfxBindingsUpdate_Impl) 90*cdf0e10cSrcweir DBG_NAME(SfxBindingsInvalidateAll) 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir //==================================================================== 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir static sal_uInt16 nTimeOut = 300; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir #define TIMEOUT_FIRST nTimeOut 97*cdf0e10cSrcweir #define TIMEOUT_UPDATING 20 98*cdf0e10cSrcweir #define TIMEOUT_IDLE 2500 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir static sal_uInt32 nCache1 = 0; 101*cdf0e10cSrcweir static sal_uInt32 nCache2 = 0; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir typedef std::hash_map< sal_uInt16, bool > InvalidateSlotMap; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir //==================================================================== 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir DECL_PTRARRAY(SfxStateCacheArr_Impl, SfxStateCache*, 32, 16) 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir //==================================================================== 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir class SfxAsyncExec_Impl 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir ::com::sun::star::util::URL aCommand; 114*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp; 115*cdf0e10cSrcweir Timer aTimer; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir public: 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir SfxAsyncExec_Impl( const ::com::sun::star::util::URL& rCmd, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDisp ) 120*cdf0e10cSrcweir : aCommand( rCmd ) 121*cdf0e10cSrcweir , xDisp( rDisp ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir aTimer.SetTimeoutHdl( LINK(this, SfxAsyncExec_Impl, TimerHdl) ); 124*cdf0e10cSrcweir aTimer.SetTimeout( 0 ); 125*cdf0e10cSrcweir aTimer.Start(); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir DECL_LINK( TimerHdl, Timer*); 129*cdf0e10cSrcweir }; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir IMPL_LINK(SfxAsyncExec_Impl, TimerHdl, Timer*, pTimer) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir (void)pTimer; // unused 134*cdf0e10cSrcweir aTimer.Stop(); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir Sequence<beans::PropertyValue> aSeq; 137*cdf0e10cSrcweir xDisp->dispatch( aCommand, aSeq ); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir delete this; 140*cdf0e10cSrcweir return 0L; 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir class SfxBindings_Impl 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir public: 146*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchRecorder > xRecorder; 147*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xProv; 148*cdf0e10cSrcweir SfxUnoControllerArr_Impl* 149*cdf0e10cSrcweir pUnoCtrlArr; 150*cdf0e10cSrcweir SfxWorkWindow* pWorkWin; 151*cdf0e10cSrcweir SfxBindings* pSubBindings; 152*cdf0e10cSrcweir SfxBindings* pSuperBindings; 153*cdf0e10cSrcweir SfxStateCacheArr_Impl* pCaches; // je ein cache fuer jede gebundene 154*cdf0e10cSrcweir sal_uInt16 nCachedFunc1; // index der zuletzt gerufenen 155*cdf0e10cSrcweir sal_uInt16 nCachedFunc2; // index der vorletzt gerufenen 156*cdf0e10cSrcweir sal_uInt16 nMsgPos; // Message-Position, ab der zu aktualisieren ist 157*cdf0e10cSrcweir SfxPopupAction ePopupAction; // in DeleteFloatinWindow() abgefragt 158*cdf0e10cSrcweir sal_Bool bContextChanged; 159*cdf0e10cSrcweir sal_Bool bMsgDirty; // wurde ein MessageServer invalidiert? 160*cdf0e10cSrcweir sal_Bool bAllMsgDirty; // wurden die MessageServer invalidiert? 161*cdf0e10cSrcweir sal_Bool bAllDirty; // nach InvalidateAll 162*cdf0e10cSrcweir sal_Bool bCtrlReleased; // waehrend EnterRegistrations 163*cdf0e10cSrcweir AutoTimer aTimer; // fuer volatile Slots 164*cdf0e10cSrcweir sal_Bool bInUpdate; // fuer Assertions 165*cdf0e10cSrcweir sal_Bool bInNextJob; // fuer Assertions 166*cdf0e10cSrcweir sal_Bool bFirstRound; // Erste Runde im Update 167*cdf0e10cSrcweir sal_uInt16 nFirstShell; // Shell, die in erster Runde bevorzugt wird 168*cdf0e10cSrcweir sal_uInt16 nOwnRegLevel; // z"ahlt die echten Locks, ohne die der SuperBindings 169*cdf0e10cSrcweir InvalidateSlotMap m_aInvalidateSlots; // store slots which are invalidated while in update 170*cdf0e10cSrcweir }; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir //-------------------------------------------------------------------- 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir struct SfxFoundCache_Impl 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir sal_uInt16 nSlotId; // die Slot-Id 177*cdf0e10cSrcweir sal_uInt16 nWhichId; // falls verf"ugbar die Which-Id, sonst nSlotId 178*cdf0e10cSrcweir const SfxSlot* pSlot; // Pointer auf den <Master-Slot> 179*cdf0e10cSrcweir SfxStateCache* pCache; // Pointer auf den StatusCache, ggf. 0 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir SfxFoundCache_Impl(): 182*cdf0e10cSrcweir nSlotId(0), 183*cdf0e10cSrcweir nWhichId(0), 184*cdf0e10cSrcweir pSlot(0), 185*cdf0e10cSrcweir pCache(0) 186*cdf0e10cSrcweir {} 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir SfxFoundCache_Impl(SfxFoundCache_Impl&r): 189*cdf0e10cSrcweir nSlotId(r.nSlotId), 190*cdf0e10cSrcweir nWhichId(r.nWhichId), 191*cdf0e10cSrcweir pSlot(r.pSlot), 192*cdf0e10cSrcweir pCache(r.pCache) 193*cdf0e10cSrcweir {} 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir SfxFoundCache_Impl(sal_uInt16 nS, sal_uInt16 nW, const SfxSlot *pS, SfxStateCache *pC ): 196*cdf0e10cSrcweir nSlotId(nS), 197*cdf0e10cSrcweir nWhichId(nW), 198*cdf0e10cSrcweir pSlot(pS), 199*cdf0e10cSrcweir pCache(pC) 200*cdf0e10cSrcweir {} 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir int operator<( const SfxFoundCache_Impl &r ) const 203*cdf0e10cSrcweir { return nWhichId < r.nWhichId; } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir int operator==( const SfxFoundCache_Impl &r ) const 206*cdf0e10cSrcweir { return nWhichId== r.nWhichId; } 207*cdf0e10cSrcweir }; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir //-------------------------------------------------------------------------- 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir SV_DECL_PTRARR_SORT_DEL(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*, 16, 16 ) 212*cdf0e10cSrcweir SV_IMPL_OP_PTRARR_SORT(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir //========================================================================== 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir SfxBindings::SfxBindings() 217*cdf0e10cSrcweir : pImp(new SfxBindings_Impl), 218*cdf0e10cSrcweir pDispatcher(0), 219*cdf0e10cSrcweir nRegLevel(1) // geht erst auf 0, wenn Dispatcher gesetzt 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir pImp->nMsgPos = 0; 222*cdf0e10cSrcweir pImp->bAllMsgDirty = sal_True; 223*cdf0e10cSrcweir pImp->bContextChanged = sal_False; 224*cdf0e10cSrcweir pImp->bMsgDirty = sal_True; 225*cdf0e10cSrcweir pImp->bAllDirty = sal_True; 226*cdf0e10cSrcweir pImp->ePopupAction = SFX_POPUP_DELETE; 227*cdf0e10cSrcweir pImp->nCachedFunc1 = 0; 228*cdf0e10cSrcweir pImp->nCachedFunc2 = 0; 229*cdf0e10cSrcweir pImp->bCtrlReleased = sal_False; 230*cdf0e10cSrcweir pImp->bFirstRound = sal_False; 231*cdf0e10cSrcweir pImp->bInNextJob = sal_False; 232*cdf0e10cSrcweir pImp->bInUpdate = sal_False; 233*cdf0e10cSrcweir pImp->pSubBindings = NULL; 234*cdf0e10cSrcweir pImp->pSuperBindings = NULL; 235*cdf0e10cSrcweir pImp->pWorkWin = NULL; 236*cdf0e10cSrcweir pImp->pUnoCtrlArr = NULL; 237*cdf0e10cSrcweir pImp->nOwnRegLevel = nRegLevel; 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir // all caches are valid (no pending invalidate-job) 240*cdf0e10cSrcweir // create the list of caches 241*cdf0e10cSrcweir pImp->pCaches = new SfxStateCacheArr_Impl; 242*cdf0e10cSrcweir pImp->aTimer.SetTimeoutHdl( LINK(this, SfxBindings, NextJob_Impl) ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir //==================================================================== 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir SfxBindings::~SfxBindings() 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir /* [Beschreibung] 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir Destruktor der Klasse SfxBindings. Die eine, f"ur jede <SfxApplication> 252*cdf0e10cSrcweir existierende Instanz wird von der <SfxApplication> nach Ausf"urhung 253*cdf0e10cSrcweir von <SfxApplication::Exit()> automatisch zerst"ort. 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir Noch existierende <SfxControllerItem> Instanzen, die bei dieser 256*cdf0e10cSrcweir SfxBindings Instanz angemeldet sind, werden im Destruktor 257*cdf0e10cSrcweir automatisch zerst"ort. Dies sind i.d.R. Floating-Toolboxen, Value-Sets 258*cdf0e10cSrcweir etc. Arrays von SfxControllerItems d"urfen zu diesem Zeitpunkt nicht 259*cdf0e10cSrcweir mehr exisitieren. 260*cdf0e10cSrcweir */ 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir // Die SubBindings sollen ja nicht gelocked werden ! 264*cdf0e10cSrcweir pImp->pSubBindings = NULL; 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir ENTERREGISTRATIONS(); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir pImp->aTimer.Stop(); 269*cdf0e10cSrcweir DeleteControllers_Impl(); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir // Caches selbst l"oschen 272*cdf0e10cSrcweir sal_uInt16 nCount = pImp->pCaches->Count(); 273*cdf0e10cSrcweir for ( sal_uInt16 nCache = 0; nCache < nCount; ++nCache ) 274*cdf0e10cSrcweir delete pImp->pCaches->GetObject(nCache); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir DELETEZ( pImp->pWorkWin ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir delete pImp->pCaches; 279*cdf0e10cSrcweir delete pImp; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir //-------------------------------------------------------------------- 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir void SfxBindings::DeleteControllers_Impl() 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir // in der ersten Runde den SfxPopupWindows l"oschen 287*cdf0e10cSrcweir sal_uInt16 nCount = pImp->pCaches->Count(); 288*cdf0e10cSrcweir sal_uInt16 nCache; 289*cdf0e10cSrcweir for ( nCache = 0; nCache < nCount; ++nCache ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir // merken wo man ist 292*cdf0e10cSrcweir SfxStateCache *pCache = pImp->pCaches->GetObject(nCache); 293*cdf0e10cSrcweir sal_uInt16 nSlotId = pCache->GetId(); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir // SfxPopupWindow l"oschen lassen 296*cdf0e10cSrcweir pCache->DeleteFloatingWindows(); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir // da der Cache verkleinert worden sein kann, wiederaufsetzen 299*cdf0e10cSrcweir sal_uInt16 nNewCount = pImp->pCaches->Count(); 300*cdf0e10cSrcweir if ( nNewCount < nCount ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir nCache = GetSlotPos(nSlotId); 303*cdf0e10cSrcweir if ( nCache >= nNewCount || 304*cdf0e10cSrcweir nSlotId != pImp->pCaches->GetObject(nCache)->GetId() ) 305*cdf0e10cSrcweir --nCache; 306*cdf0e10cSrcweir nCount = nNewCount; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir // alle Caches l"oschen 311*cdf0e10cSrcweir for ( nCache = pImp->pCaches->Count(); nCache > 0; --nCache ) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir // Cache via ::com::sun::star::sdbcx::Index besorgen 314*cdf0e10cSrcweir SfxStateCache *pCache = pImp->pCaches->GetObject(nCache-1); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir // alle Controller in dem Cache unbinden 317*cdf0e10cSrcweir SfxControllerItem *pNext; 318*cdf0e10cSrcweir for ( SfxControllerItem *pCtrl = pCache->GetItemLink(); 319*cdf0e10cSrcweir pCtrl; pCtrl = pNext ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir pNext = pCtrl->GetItemLink(); 322*cdf0e10cSrcweir pCtrl->UnBind(); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir if ( pCache->GetInternalController() ) 326*cdf0e10cSrcweir pCache->GetInternalController()->UnBind(); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir // Cache l"oschen 329*cdf0e10cSrcweir if( nCache-1 < pImp->pCaches->Count() ) 330*cdf0e10cSrcweir delete (*pImp->pCaches)[nCache-1]; 331*cdf0e10cSrcweir pImp->pCaches->Remove(nCache-1, 1); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if( pImp->pUnoCtrlArr ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir sal_uInt16 nCtrlCount = pImp->pUnoCtrlArr->Count(); 337*cdf0e10cSrcweir for ( sal_uInt16 n=nCtrlCount; n>0; n-- ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir SfxUnoControllerItem *pCtrl = (*pImp->pUnoCtrlArr)[n-1]; 340*cdf0e10cSrcweir pCtrl->ReleaseBindings(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir DBG_ASSERT( !pImp->pUnoCtrlArr->Count(), "UnoControllerItems nicht entfernt!" ); 344*cdf0e10cSrcweir DELETEZ( pImp->pUnoCtrlArr ); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir //-------------------------------------------------------------------- 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir SfxPopupAction SfxBindings::GetPopupAction_Impl() const 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir return pImp->ePopupAction; 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir //-------------------------------------------------------------------- 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir void SfxBindings::HidePopups( bool bHide ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir // SfxPopupWindows hiden 361*cdf0e10cSrcweir HidePopupCtrls_Impl( bHide ); 362*cdf0e10cSrcweir SfxBindings *pSub = pImp->pSubBindings; 363*cdf0e10cSrcweir while ( pSub ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir pImp->pSubBindings->HidePopupCtrls_Impl( bHide ); 366*cdf0e10cSrcweir pSub = pSub->pImp->pSubBindings; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir // SfxChildWindows hiden 370*cdf0e10cSrcweir DBG_ASSERT( pDispatcher, "HidePopups not allowed without dispatcher" ); 371*cdf0e10cSrcweir if ( pImp->pWorkWin ) 372*cdf0e10cSrcweir pImp->pWorkWin->HidePopups_Impl( bHide, sal_True ); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir void SfxBindings::HidePopupCtrls_Impl( FASTBOOL bHide ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir if ( bHide ) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir // SfxPopupWindows hiden 380*cdf0e10cSrcweir pImp->ePopupAction = SFX_POPUP_HIDE; 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir else 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir // SfxPopupWindows showen 385*cdf0e10cSrcweir pImp->ePopupAction = SFX_POPUP_SHOW; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir for ( sal_uInt16 nCache = 0; nCache < pImp->pCaches->Count(); ++nCache ) 389*cdf0e10cSrcweir pImp->pCaches->GetObject(nCache)->DeleteFloatingWindows(); 390*cdf0e10cSrcweir pImp->ePopupAction = SFX_POPUP_DELETE; 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir //-------------------------------------------------------------------- 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir void SfxBindings::Update_Impl 396*cdf0e10cSrcweir ( 397*cdf0e10cSrcweir SfxStateCache* pCache // der upzudatende SfxStatusCache 398*cdf0e10cSrcweir ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir if( pCache->GetDispatch().is() && pCache->GetItemLink() ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir pCache->SetCachedState(sal_True); 403*cdf0e10cSrcweir if ( !pCache->GetInternalController() ) 404*cdf0e10cSrcweir return; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir if ( !pDispatcher ) 408*cdf0e10cSrcweir return; 409*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsUpdate_Impl); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir // alle mit derselben Statusmethode zusammensammeln, die dirty sind 412*cdf0e10cSrcweir SfxDispatcher &rDispat = *pDispatcher; 413*cdf0e10cSrcweir const SfxSlot *pRealSlot = 0; 414*cdf0e10cSrcweir const SfxSlotServer* pMsgServer = 0; 415*cdf0e10cSrcweir SfxFoundCacheArr_Impl aFound; 416*cdf0e10cSrcweir SfxItemSet *pSet = CreateSet_Impl( pCache, pRealSlot, &pMsgServer, aFound ); 417*cdf0e10cSrcweir sal_Bool bUpdated = sal_False; 418*cdf0e10cSrcweir if ( pSet ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir // Status erfragen 421*cdf0e10cSrcweir if ( rDispat._FillState( *pMsgServer, *pSet, pRealSlot ) ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir // Status posten 424*cdf0e10cSrcweir const SfxInterface *pInterface = 425*cdf0e10cSrcweir rDispat.GetShell(pMsgServer->GetShellLevel())->GetInterface(); 426*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < aFound.Count(); ++nPos ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir const SfxFoundCache_Impl *pFound = aFound[nPos]; 429*cdf0e10cSrcweir sal_uInt16 nWhich = pFound->nWhichId; 430*cdf0e10cSrcweir const SfxPoolItem *pItem = 0; 431*cdf0e10cSrcweir SfxItemState eState = pSet->GetItemState(nWhich, sal_True, &pItem); 432*cdf0e10cSrcweir if ( eState == SFX_ITEM_DEFAULT && SfxItemPool::IsWhich(nWhich) ) 433*cdf0e10cSrcweir pItem = &pSet->Get(nWhich); 434*cdf0e10cSrcweir UpdateControllers_Impl( pInterface, aFound[nPos], pItem, eState ); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir bUpdated = sal_True; 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir delete pSet; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir if ( !bUpdated && pCache ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir // Wenn pCache == NULL und kein SlotServer ( z.B. weil Dispatcher gelockt! ), 445*cdf0e10cSrcweir // darf nat"urlich kein Update versucht werden 446*cdf0e10cSrcweir SfxFoundCache_Impl aFoundCache( 447*cdf0e10cSrcweir pCache->GetId(), 0, 448*cdf0e10cSrcweir pRealSlot, pCache ); 449*cdf0e10cSrcweir UpdateControllers_Impl( 0, &aFoundCache, 0, SFX_ITEM_DISABLED); 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsUpdate_Impl); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir //-------------------------------------------------------------------- 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir void SfxBindings::InvalidateSlotsInMap_Impl() 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir InvalidateSlotMap::const_iterator pIter = pImp->m_aInvalidateSlots.begin(); 460*cdf0e10cSrcweir while ( pIter != pImp->m_aInvalidateSlots.end() ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir Invalidate( pIter->first ); 463*cdf0e10cSrcweir ++pIter; 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir pImp->m_aInvalidateSlots.clear(); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir //-------------------------------------------------------------------- 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir void SfxBindings::AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir pImp->m_aInvalidateSlots[nId] = sal_True; 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir //-------------------------------------------------------------------- 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir void SfxBindings::Update 478*cdf0e10cSrcweir ( 479*cdf0e10cSrcweir sal_uInt16 nId // die gebundene und upzudatende Slot-Id 480*cdf0e10cSrcweir ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir DBG_MEMTEST(); 483*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir //!!TLX: Fuehrte zu Vorlagenkatalogstillstand 486*cdf0e10cSrcweir // if ( nRegLevel ) 487*cdf0e10cSrcweir // return; 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir if ( pDispatcher ) 490*cdf0e10cSrcweir pDispatcher->Flush(); 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir if ( pImp->pSubBindings ) 493*cdf0e10cSrcweir pImp->pSubBindings->Update( nId ); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache( nId ); 496*cdf0e10cSrcweir if ( pCache ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir pImp->bInUpdate = sal_True; 499*cdf0e10cSrcweir if ( pImp->bMsgDirty ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir UpdateSlotServer_Impl(); 502*cdf0e10cSrcweir pCache = GetStateCache( nId ); 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir if (pCache) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir sal_Bool bInternalUpdate = sal_True; 508*cdf0e10cSrcweir if( pCache->GetDispatch().is() && pCache->GetItemLink() ) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir pCache->SetCachedState(sal_True); 511*cdf0e10cSrcweir bInternalUpdate = ( pCache->GetInternalController() != 0 ); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir if ( bInternalUpdate ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir // Status erfragen 517*cdf0e10cSrcweir const SfxSlotServer* pMsgServer = pCache->GetSlotServer(*pDispatcher, pImp->xProv); 518*cdf0e10cSrcweir if ( !pCache->IsControllerDirty() && 519*cdf0e10cSrcweir ( !pMsgServer || 520*cdf0e10cSrcweir !pMsgServer->GetSlot()->IsMode(SFX_SLOT_VOLATILE) ) ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir pImp->bInUpdate = sal_False; 523*cdf0e10cSrcweir InvalidateSlotsInMap_Impl(); 524*cdf0e10cSrcweir return; 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir if (!pMsgServer) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir pCache->SetState(SFX_ITEM_DISABLED, 0); 529*cdf0e10cSrcweir pImp->bInUpdate = sal_False; 530*cdf0e10cSrcweir InvalidateSlotsInMap_Impl(); 531*cdf0e10cSrcweir return; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir Update_Impl(pCache); 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir pImp->bAllDirty = sal_False; 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir pImp->bInUpdate = sal_False; 541*cdf0e10cSrcweir InvalidateSlotsInMap_Impl(); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir //-------------------------------------------------------------------- 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir void SfxBindings::Update() 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir DBG_MEMTEST(); 550*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir if ( pImp->pSubBindings ) 553*cdf0e10cSrcweir pImp->pSubBindings->Update(); 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir if ( pDispatcher ) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir if ( nRegLevel ) 558*cdf0e10cSrcweir return; 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir pImp->bInUpdate = sal_True; 561*cdf0e10cSrcweir pDispatcher->Flush(); 562*cdf0e10cSrcweir pDispatcher->Update_Impl(); 563*cdf0e10cSrcweir while ( !NextJob_Impl(0) ) 564*cdf0e10cSrcweir ; // loop 565*cdf0e10cSrcweir pImp->bInUpdate = sal_False; 566*cdf0e10cSrcweir InvalidateSlotsInMap_Impl(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir //-------------------------------------------------------------------- 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir void SfxBindings::SetState 573*cdf0e10cSrcweir ( 574*cdf0e10cSrcweir const SfxItemSet& rSet // zu setzende Status-Werte 575*cdf0e10cSrcweir ) 576*cdf0e10cSrcweir { 577*cdf0e10cSrcweir // wenn gelockt, dann nur invalidieren 578*cdf0e10cSrcweir if ( nRegLevel ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir SfxItemIter aIter(rSet); 581*cdf0e10cSrcweir for ( const SfxPoolItem *pItem = aIter.FirstItem(); 582*cdf0e10cSrcweir pItem; 583*cdf0e10cSrcweir pItem = aIter.NextItem() ) 584*cdf0e10cSrcweir Invalidate( pItem->Which() ); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir else 587*cdf0e10cSrcweir { 588*cdf0e10cSrcweir // Status d"urfen nur angenommen werden, wenn alle Slot-Pointer gesetzt sind 589*cdf0e10cSrcweir if ( pImp->bMsgDirty ) 590*cdf0e10cSrcweir UpdateSlotServer_Impl(); 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir // "uber das ItemSet iterieren, falls Slot gebunden, updaten 593*cdf0e10cSrcweir //! Bug: WhichIter verwenden und ggf. VoidItems hochschicken 594*cdf0e10cSrcweir SfxItemIter aIter(rSet); 595*cdf0e10cSrcweir for ( const SfxPoolItem *pItem = aIter.FirstItem(); 596*cdf0e10cSrcweir pItem; 597*cdf0e10cSrcweir pItem = aIter.NextItem() ) 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir SfxStateCache* pCache = 600*cdf0e10cSrcweir GetStateCache( rSet.GetPool()->GetSlotId(pItem->Which()) ); 601*cdf0e10cSrcweir if ( pCache ) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir // Status updaten 604*cdf0e10cSrcweir if ( !pCache->IsControllerDirty() ) 605*cdf0e10cSrcweir pCache->Invalidate(sal_False); 606*cdf0e10cSrcweir pCache->SetState( SFX_ITEM_AVAILABLE, pItem ); 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir //! nicht implementiert: Updates von EnumSlots via MasterSlots 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir //-------------------------------------------------------------------- 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir void SfxBindings::SetState 617*cdf0e10cSrcweir ( 618*cdf0e10cSrcweir const SfxPoolItem& rItem // zu setzender Status-Wert 619*cdf0e10cSrcweir ) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir if ( nRegLevel ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir Invalidate( rItem.Which() ); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir else 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir // Status d"urfen nur angenommen werden, wenn alle Slot-Pointer gesetzt sind 628*cdf0e10cSrcweir if ( pImp->bMsgDirty ) 629*cdf0e10cSrcweir UpdateSlotServer_Impl(); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir // falls der Slot gebunden ist, updaten 632*cdf0e10cSrcweir DBG_ASSERT( SfxItemPool::IsSlot( rItem.Which() ), 633*cdf0e10cSrcweir "cannot set items with which-id" ); 634*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache( rItem.Which() ); 635*cdf0e10cSrcweir if ( pCache ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir // Status updaten 638*cdf0e10cSrcweir if ( !pCache->IsControllerDirty() ) 639*cdf0e10cSrcweir pCache->Invalidate(sal_False); 640*cdf0e10cSrcweir pCache->SetState( SFX_ITEM_AVAILABLE, &rItem ); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir //! nicht implementiert: Updates von EnumSlots via MasterSlots 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir //-------------------------------------------------------------------- 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir SfxStateCache* SfxBindings::GetAnyStateCache_Impl( sal_uInt16 nId ) 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache( nId ); 653*cdf0e10cSrcweir if ( !pCache && pImp->pSubBindings ) 654*cdf0e10cSrcweir return pImp->pSubBindings->GetAnyStateCache_Impl( nId ); 655*cdf0e10cSrcweir return pCache; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir SfxStateCache* SfxBindings::GetStateCache 659*cdf0e10cSrcweir ( 660*cdf0e10cSrcweir sal_uInt16 nId /* Slot-Id, deren SfxStatusCache gefunden 661*cdf0e10cSrcweir werden soll */, 662*cdf0e10cSrcweir sal_uInt16* pPos /* 0 bzw. Position, ab der die Bindings 663*cdf0e10cSrcweir bin"ar durchsucht werden sollen. Liefert 664*cdf0e10cSrcweir die Position zur"uck, an der nId gefunden 665*cdf0e10cSrcweir wurde, bzw. an der es einfef"ugt werden 666*cdf0e10cSrcweir w"urde. */ 667*cdf0e10cSrcweir ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir DBG_MEMTEST(); 670*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 671*cdf0e10cSrcweir // is the specified function bound? 672*cdf0e10cSrcweir const sal_uInt16 nStart = ( pPos ? *pPos : 0 ); 673*cdf0e10cSrcweir const sal_uInt16 nPos = GetSlotPos( nId, nStart ); 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir if ( nPos < pImp->pCaches->Count() && 676*cdf0e10cSrcweir (*pImp->pCaches)[nPos]->GetId() == nId ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir if ( pPos ) 679*cdf0e10cSrcweir *pPos = nPos; 680*cdf0e10cSrcweir return (*pImp->pCaches)[nPos]; 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir return 0; 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir //-------------------------------------------------------------------- 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir void SfxBindings::InvalidateAll 688*cdf0e10cSrcweir ( 689*cdf0e10cSrcweir sal_Bool bWithMsg /* sal_True 690*cdf0e10cSrcweir Slot-Server als ung"ultig markieren 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir sal_False 693*cdf0e10cSrcweir Slot-Server bleiben g"ultig */ 694*cdf0e10cSrcweir ) 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsInvalidateAll); 697*cdf0e10cSrcweir DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir DBG_MEMTEST(); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir if ( pImp->pSubBindings ) 702*cdf0e10cSrcweir pImp->pSubBindings->InvalidateAll( bWithMsg ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir // ist schon alles dirty gesetzt oder downing => nicht zu tun 705*cdf0e10cSrcweir if ( !pDispatcher || 706*cdf0e10cSrcweir ( pImp->bAllDirty && ( !bWithMsg || pImp->bAllMsgDirty ) ) || 707*cdf0e10cSrcweir SFX_APP()->IsDowning() ) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsInvalidateAll); 710*cdf0e10cSrcweir return; 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir pImp->bAllMsgDirty = pImp->bAllMsgDirty || bWithMsg; 714*cdf0e10cSrcweir pImp->bMsgDirty = pImp->bMsgDirty || pImp->bAllMsgDirty || bWithMsg; 715*cdf0e10cSrcweir pImp->bAllDirty = sal_True; 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < pImp->pCaches->Count(); ++n ) 718*cdf0e10cSrcweir pImp->pCaches->GetObject(n)->Invalidate(bWithMsg); 719*cdf0e10cSrcweir /* 720*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame 721*cdf0e10cSrcweir ( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir if ( bWithMsg && xFrame.is() ) 724*cdf0e10cSrcweir xFrame->contextChanged(); 725*cdf0e10cSrcweir */ 726*cdf0e10cSrcweir pImp->nMsgPos = 0; 727*cdf0e10cSrcweir if ( !nRegLevel ) 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir pImp->aTimer.Stop(); 730*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_FIRST); 731*cdf0e10cSrcweir pImp->aTimer.Start(); 732*cdf0e10cSrcweir // pImp->bFirstRound = sal_True; 733*cdf0e10cSrcweir // pImp->nFirstShell = 0; 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsInvalidateAll); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir //-------------------------------------------------------------------- 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir void SfxBindings::Invalidate 742*cdf0e10cSrcweir ( 743*cdf0e10cSrcweir const sal_uInt16* pIds /* numerisch sortiertes 0-terminiertes Array 744*cdf0e10cSrcweir von Slot-Ids (einzel, nicht als Paare!) */ 745*cdf0e10cSrcweir ) 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsInvalidateAll); 748*cdf0e10cSrcweir // DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir DBG_MEMTEST(); 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir if ( pImp->bInUpdate ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir sal_Int32 i = 0; 755*cdf0e10cSrcweir while ( pIds[i] != 0 ) 756*cdf0e10cSrcweir AddSlotToInvalidateSlotsMap_Impl( pIds[i++] ); 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir if ( pImp->pSubBindings ) 759*cdf0e10cSrcweir pImp->pSubBindings->Invalidate( pIds ); 760*cdf0e10cSrcweir return; 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir if ( pImp->pSubBindings ) 764*cdf0e10cSrcweir pImp->pSubBindings->Invalidate( pIds ); 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir // ist schon alles dirty gesetzt oder downing => nicht zu tun 767*cdf0e10cSrcweir if ( !pDispatcher || pImp->bAllDirty || SFX_APP()->IsDowning() ) 768*cdf0e10cSrcweir return; 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir // in immer kleiner werdenden Berichen bin"ar suchen 771*cdf0e10cSrcweir for ( sal_uInt16 n = GetSlotPos(*pIds); 772*cdf0e10cSrcweir *pIds && n < pImp->pCaches->Count(); 773*cdf0e10cSrcweir n = GetSlotPos(*pIds, n) ) 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir // falls SID "uberhaupt gebunden ist, den Cache invalidieren 776*cdf0e10cSrcweir SfxStateCache *pCache = pImp->pCaches->GetObject(n); 777*cdf0e10cSrcweir if ( pCache->GetId() == *pIds ) 778*cdf0e10cSrcweir pCache->Invalidate(sal_False); 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir // n"achste SID 781*cdf0e10cSrcweir if ( !*++pIds ) 782*cdf0e10cSrcweir break; 783*cdf0e10cSrcweir DBG_ASSERT( *pIds > *(pIds-1), "pIds unsorted" ); 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir // falls nicht gelockt, Update-Timer starten 787*cdf0e10cSrcweir pImp->nMsgPos = 0; 788*cdf0e10cSrcweir if ( !nRegLevel ) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir pImp->aTimer.Stop(); 791*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_FIRST); 792*cdf0e10cSrcweir pImp->aTimer.Start(); 793*cdf0e10cSrcweir // pImp->bFirstRound = sal_True; 794*cdf0e10cSrcweir // pImp->nFirstShell = 0; 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsInvalidateAll); 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir //-------------------------------------------------------------------- 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir void SfxBindings::InvalidateShell 803*cdf0e10cSrcweir ( 804*cdf0e10cSrcweir const SfxShell& rSh /* Die <SfxShell>, deren Slot-Ids 805*cdf0e10cSrcweir invalidiert werden sollen. */, 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir sal_Bool bDeep /* sal_True 808*cdf0e10cSrcweir auch die, von der SfxShell 809*cdf0e10cSrcweir ererbten Slot-Ids werden invalidert 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir sal_False 812*cdf0e10cSrcweir die ererbten und nicht "uberladenen 813*cdf0e10cSrcweir Slot-Ids werden invalidiert */ 814*cdf0e10cSrcweir //! MI: z. Zt. immer bDeep 815*cdf0e10cSrcweir ) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir if ( pImp->pSubBindings ) 820*cdf0e10cSrcweir pImp->pSubBindings->InvalidateShell( rSh, bDeep ); 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir if ( !pDispatcher || pImp->bAllDirty || SFX_APP()->IsDowning() ) 823*cdf0e10cSrcweir return; 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsInvalidateAll); 826*cdf0e10cSrcweir DBG_MEMTEST(); 827*cdf0e10cSrcweir 828*cdf0e10cSrcweir // Jetzt schon flushen, wird in GetShellLevel(rSh) sowieso gemacht; wichtig, 829*cdf0e10cSrcweir // damit pImp->bAll(Msg)Dirty korrekt gesetzt ist 830*cdf0e10cSrcweir pDispatcher->Flush(); 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir if ( !pDispatcher || 833*cdf0e10cSrcweir ( pImp->bAllDirty && pImp->bAllMsgDirty ) || 834*cdf0e10cSrcweir SFX_APP()->IsDowning() ) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir // Wenn sowieso demn"achst alle Server geholt werden 837*cdf0e10cSrcweir return; 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir // Level finden 841*cdf0e10cSrcweir sal_uInt16 nLevel = pDispatcher->GetShellLevel(rSh); 842*cdf0e10cSrcweir if ( nLevel != USHRT_MAX ) 843*cdf0e10cSrcweir { 844*cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < pImp->pCaches->Count(); ++n ) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir SfxStateCache *pCache = pImp->pCaches->GetObject(n); 847*cdf0e10cSrcweir const SfxSlotServer *pMsgServer = 848*cdf0e10cSrcweir pCache->GetSlotServer(*pDispatcher, pImp->xProv); 849*cdf0e10cSrcweir if ( pMsgServer && pMsgServer->GetShellLevel() == nLevel ) 850*cdf0e10cSrcweir pCache->Invalidate(sal_False); 851*cdf0e10cSrcweir } 852*cdf0e10cSrcweir pImp->nMsgPos = 0; 853*cdf0e10cSrcweir if ( !nRegLevel ) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir pImp->aTimer.Stop(); 856*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_FIRST); 857*cdf0e10cSrcweir pImp->aTimer.Start(); 858*cdf0e10cSrcweir pImp->bFirstRound = sal_True; 859*cdf0e10cSrcweir pImp->nFirstShell = nLevel; 860*cdf0e10cSrcweir } 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsInvalidateAll); 864*cdf0e10cSrcweir } 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir //-------------------------------------------------------------------- 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir void SfxBindings::Invalidate 869*cdf0e10cSrcweir ( 870*cdf0e10cSrcweir sal_uInt16 nId // zu invalidierende Slot-Id 871*cdf0e10cSrcweir ) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir DBG_MEMTEST(); 874*cdf0e10cSrcweir // DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir if ( pImp->bInUpdate ) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir AddSlotToInvalidateSlotsMap_Impl( nId ); 879*cdf0e10cSrcweir if ( pImp->pSubBindings ) 880*cdf0e10cSrcweir pImp->pSubBindings->Invalidate( nId ); 881*cdf0e10cSrcweir return; 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir if ( pImp->pSubBindings ) 885*cdf0e10cSrcweir pImp->pSubBindings->Invalidate( nId ); 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir if ( !pDispatcher || pImp->bAllDirty || SFX_APP()->IsDowning() ) 888*cdf0e10cSrcweir return; 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache(nId); 891*cdf0e10cSrcweir if ( pCache ) 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir pCache->Invalidate(sal_False); 894*cdf0e10cSrcweir pImp->nMsgPos = Min(GetSlotPos(nId), pImp->nMsgPos); 895*cdf0e10cSrcweir if ( !nRegLevel ) 896*cdf0e10cSrcweir { 897*cdf0e10cSrcweir pImp->aTimer.Stop(); 898*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_FIRST); 899*cdf0e10cSrcweir pImp->aTimer.Start(); 900*cdf0e10cSrcweir } 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir //-------------------------------------------------------------------- 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir void SfxBindings::Invalidate 907*cdf0e10cSrcweir ( 908*cdf0e10cSrcweir sal_uInt16 nId, // zu invalidierende Slot-Id 909*cdf0e10cSrcweir sal_Bool bWithItem, // StateCache clearen ? 910*cdf0e10cSrcweir sal_Bool bWithMsg // SlotServer neu holen ? 911*cdf0e10cSrcweir ) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir DBG_MEMTEST(); 914*cdf0e10cSrcweir DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" ); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir if ( pImp->pSubBindings ) 917*cdf0e10cSrcweir pImp->pSubBindings->Invalidate( nId, bWithItem, bWithMsg ); 918*cdf0e10cSrcweir 919*cdf0e10cSrcweir if ( SFX_APP()->IsDowning() ) 920*cdf0e10cSrcweir return; 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache(nId); 923*cdf0e10cSrcweir if ( pCache ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir if ( bWithItem ) 926*cdf0e10cSrcweir pCache->ClearCache(); 927*cdf0e10cSrcweir pCache->Invalidate(bWithMsg); 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir if ( !pDispatcher || pImp->bAllDirty ) 930*cdf0e10cSrcweir return; 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir pImp->nMsgPos = Min(GetSlotPos(nId), pImp->nMsgPos); 933*cdf0e10cSrcweir if ( !nRegLevel ) 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir pImp->aTimer.Stop(); 936*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_FIRST); 937*cdf0e10cSrcweir pImp->aTimer.Start(); 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir } 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir //-------------------------------------------------------------------- 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir sal_Bool SfxBindings::IsBound( sal_uInt16 nSlotId, sal_uInt16 nStartSearchAt ) 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir DBG_MEMTEST(); 947*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 948*cdf0e10cSrcweir return GetStateCache(nSlotId, &nStartSearchAt ) != 0; 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir //-------------------------------------------------------------------- 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir sal_uInt16 SfxBindings::GetSlotPos( sal_uInt16 nId, sal_uInt16 nStartSearchAt ) 954*cdf0e10cSrcweir { 955*cdf0e10cSrcweir DBG_MEMTEST(); 956*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 957*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsMsgPos); 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir // answer immediately if a function-seek comes repeated 960*cdf0e10cSrcweir if ( pImp->nCachedFunc1 < pImp->pCaches->Count() && 961*cdf0e10cSrcweir (*pImp->pCaches)[pImp->nCachedFunc1]->GetId() == nId ) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir ++nCache1; 964*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsMsgPos); 965*cdf0e10cSrcweir return pImp->nCachedFunc1; 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir if ( pImp->nCachedFunc2 < pImp->pCaches->Count() && 968*cdf0e10cSrcweir (*pImp->pCaches)[pImp->nCachedFunc2]->GetId() == nId ) 969*cdf0e10cSrcweir { 970*cdf0e10cSrcweir ++nCache2; 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir // swap the caches 973*cdf0e10cSrcweir sal_uInt16 nTemp = pImp->nCachedFunc1; 974*cdf0e10cSrcweir pImp->nCachedFunc1 = pImp->nCachedFunc2; 975*cdf0e10cSrcweir pImp->nCachedFunc2 = nTemp; 976*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsMsgPos); 977*cdf0e10cSrcweir return pImp->nCachedFunc1; 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir // binary search, if not found, seek to target-position 981*cdf0e10cSrcweir if ( pImp->pCaches->Count() <= nStartSearchAt ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsMsgPos); 984*cdf0e10cSrcweir return 0; 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir if ( pImp->pCaches->Count() == (nStartSearchAt+1) ) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsMsgPos); 989*cdf0e10cSrcweir return (*pImp->pCaches)[nStartSearchAt]->GetId() >= nId ? 0 : 1; 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir sal_uInt16 nLow = nStartSearchAt; 992*cdf0e10cSrcweir sal_uInt16 nMid = 0; 993*cdf0e10cSrcweir sal_uInt16 nHigh = 0; 994*cdf0e10cSrcweir sal_Bool bFound = sal_False; 995*cdf0e10cSrcweir nHigh = pImp->pCaches->Count() - 1; 996*cdf0e10cSrcweir while ( !bFound && nLow <= nHigh ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir nMid = (nLow + nHigh) >> 1; 999*cdf0e10cSrcweir DBG_ASSERT( nMid < pImp->pCaches->Count(), "bsearch ist buggy" ); 1000*cdf0e10cSrcweir int nDiff = (int) nId - (int) ( ((*pImp->pCaches)[nMid])->GetId() ); 1001*cdf0e10cSrcweir if ( nDiff < 0) 1002*cdf0e10cSrcweir { if ( nMid == 0 ) 1003*cdf0e10cSrcweir break; 1004*cdf0e10cSrcweir nHigh = nMid - 1; 1005*cdf0e10cSrcweir } 1006*cdf0e10cSrcweir else if ( nDiff > 0 ) 1007*cdf0e10cSrcweir { nLow = nMid + 1; 1008*cdf0e10cSrcweir if ( nLow == 0 ) 1009*cdf0e10cSrcweir break; 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir else 1012*cdf0e10cSrcweir bFound = sal_True; 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir sal_uInt16 nPos = bFound ? nMid : nLow; 1015*cdf0e10cSrcweir DBG_ASSERT( nPos <= pImp->pCaches->Count(), "" ); 1016*cdf0e10cSrcweir DBG_ASSERT( nPos == pImp->pCaches->Count() || 1017*cdf0e10cSrcweir nId <= (*pImp->pCaches)[nPos]->GetId(), "" ); 1018*cdf0e10cSrcweir DBG_ASSERT( nPos == nStartSearchAt || 1019*cdf0e10cSrcweir nId > (*pImp->pCaches)[nPos-1]->GetId(), "" ); 1020*cdf0e10cSrcweir DBG_ASSERT( ( (nPos+1) >= pImp->pCaches->Count() ) || 1021*cdf0e10cSrcweir nId < (*pImp->pCaches)[nPos+1]->GetId(), "" ); 1022*cdf0e10cSrcweir pImp->nCachedFunc2 = pImp->nCachedFunc1; 1023*cdf0e10cSrcweir pImp->nCachedFunc1 = nPos; 1024*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsMsgPos); 1025*cdf0e10cSrcweir return nPos; 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir //-------------------------------------------------------------------- 1028*cdf0e10cSrcweir void SfxBindings::RegisterInternal_Impl( SfxControllerItem& rItem ) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir Register_Impl( rItem, sal_True ); 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir } 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir void SfxBindings::Register( SfxControllerItem& rItem ) 1035*cdf0e10cSrcweir { 1036*cdf0e10cSrcweir Register_Impl( rItem, sal_False ); 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir 1039*cdf0e10cSrcweir void SfxBindings::Register_Impl( SfxControllerItem& rItem, sal_Bool bInternal ) 1040*cdf0e10cSrcweir { 1041*cdf0e10cSrcweir DBG_MEMTEST(); 1042*cdf0e10cSrcweir DBG_ASSERT( nRegLevel > 0, "registration without EnterRegistrations" ); 1043*cdf0e10cSrcweir DBG_ASSERT( !pImp->bInNextJob, "SfxBindings::Register while status-updating" ); 1044*cdf0e10cSrcweir 1045*cdf0e10cSrcweir // insert new cache if it does not already exist 1046*cdf0e10cSrcweir sal_uInt16 nId = rItem.GetId(); 1047*cdf0e10cSrcweir sal_uInt16 nPos = GetSlotPos(nId); 1048*cdf0e10cSrcweir if ( nPos >= pImp->pCaches->Count() || 1049*cdf0e10cSrcweir (*pImp->pCaches)[nPos]->GetId() != nId ) 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir SfxStateCache* pCache = new SfxStateCache(nId); 1052*cdf0e10cSrcweir pImp->pCaches->Insert( nPos, pCache ); 1053*cdf0e10cSrcweir DBG_ASSERT( nPos == 0 || 1054*cdf0e10cSrcweir (*pImp->pCaches)[nPos]->GetId() > 1055*cdf0e10cSrcweir (*pImp->pCaches)[nPos-1]->GetId(), "" ); 1056*cdf0e10cSrcweir DBG_ASSERT( (nPos == pImp->pCaches->Count()-1) || 1057*cdf0e10cSrcweir (*pImp->pCaches)[nPos]->GetId() < 1058*cdf0e10cSrcweir (*pImp->pCaches)[nPos+1]->GetId(), "" ); 1059*cdf0e10cSrcweir pImp->bMsgDirty = sal_True; 1060*cdf0e10cSrcweir } 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir // enqueue the new binding 1063*cdf0e10cSrcweir if ( bInternal ) 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir (*pImp->pCaches)[nPos]->SetInternalController( &rItem ); 1066*cdf0e10cSrcweir } 1067*cdf0e10cSrcweir else 1068*cdf0e10cSrcweir { 1069*cdf0e10cSrcweir SfxControllerItem *pOldItem = (*pImp->pCaches)[nPos]->ChangeItemLink(&rItem); 1070*cdf0e10cSrcweir rItem.ChangeItemLink(pOldItem); 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir //-------------------------------------------------------------------- 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir void SfxBindings::Release( SfxControllerItem& rItem ) 1077*cdf0e10cSrcweir { 1078*cdf0e10cSrcweir DBG_MEMTEST(); 1079*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1080*cdf0e10cSrcweir //! DBG_ASSERT( nRegLevel > 0, "release without EnterRegistrations" ); 1081*cdf0e10cSrcweir DBG_ASSERT( !pImp->bInNextJob, "SfxBindings::Release while status-updating" ); 1082*cdf0e10cSrcweir ENTERREGISTRATIONS(); 1083*cdf0e10cSrcweir 1084*cdf0e10cSrcweir // find the bound function 1085*cdf0e10cSrcweir sal_uInt16 nId = rItem.GetId(); 1086*cdf0e10cSrcweir sal_uInt16 nPos = GetSlotPos(nId); 1087*cdf0e10cSrcweir SfxStateCache* pCache = (*pImp->pCaches)[nPos]; 1088*cdf0e10cSrcweir if ( pCache->GetId() == nId ) 1089*cdf0e10cSrcweir { 1090*cdf0e10cSrcweir if ( pCache->GetInternalController() == &rItem ) 1091*cdf0e10cSrcweir { 1092*cdf0e10cSrcweir pCache->ReleaseInternalController(); 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir else 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir // is this the first binding in the list? 1097*cdf0e10cSrcweir SfxControllerItem* pItem = pCache->GetItemLink(); 1098*cdf0e10cSrcweir if ( pItem == &rItem ) 1099*cdf0e10cSrcweir pCache->ChangeItemLink( rItem.GetItemLink() ); 1100*cdf0e10cSrcweir else 1101*cdf0e10cSrcweir { 1102*cdf0e10cSrcweir // search the binding in the list 1103*cdf0e10cSrcweir while ( pItem && pItem->GetItemLink() != &rItem ) 1104*cdf0e10cSrcweir pItem = pItem->GetItemLink(); 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir // unlink it if it was found 1107*cdf0e10cSrcweir if ( pItem ) 1108*cdf0e10cSrcweir pItem->ChangeItemLink( rItem.GetItemLink() ); 1109*cdf0e10cSrcweir } 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir // was this the last controller? 1113*cdf0e10cSrcweir if ( pCache->GetItemLink() == 0 && !pCache->GetInternalController() ) 1114*cdf0e10cSrcweir { 1115*cdf0e10cSrcweir #ifdef slow 1116*cdf0e10cSrcweir // remove the BoundFunc 1117*cdf0e10cSrcweir delete (*pImp->pCaches)[nPos]; 1118*cdf0e10cSrcweir pImp->pCaches->Remove(nPos, 1); 1119*cdf0e10cSrcweir #endif 1120*cdf0e10cSrcweir pImp->bCtrlReleased = sal_True; 1121*cdf0e10cSrcweir } 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir LEAVEREGISTRATIONS(); 1125*cdf0e10cSrcweir } 1126*cdf0e10cSrcweir 1127*cdf0e10cSrcweir //-------------------------------------------------------------------- 1128*cdf0e10cSrcweir const SfxPoolItem* SfxBindings::ExecuteSynchron( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, 1129*cdf0e10cSrcweir const SfxPoolItem **ppInternalArgs ) 1130*cdf0e10cSrcweir { 1131*cdf0e10cSrcweir DBG_MEMTEST(); 1132*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1133*cdf0e10cSrcweir 1134*cdf0e10cSrcweir if( !nId || !pDispatcher ) 1135*cdf0e10cSrcweir return NULL; 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir return Execute_Impl( nId, ppItems, nModi, SFX_CALLMODE_SYNCHRON, ppInternalArgs ); 1138*cdf0e10cSrcweir } 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir sal_Bool SfxBindings::Execute( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, SfxCallMode nCallMode, 1141*cdf0e10cSrcweir const SfxPoolItem **ppInternalArgs ) 1142*cdf0e10cSrcweir { 1143*cdf0e10cSrcweir DBG_MEMTEST(); 1144*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir if( !nId || !pDispatcher ) 1147*cdf0e10cSrcweir return sal_False; 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir const SfxPoolItem* pRet = Execute_Impl( nId, ppItems, nModi, nCallMode, ppInternalArgs ); 1150*cdf0e10cSrcweir return ( pRet != 0 ); 1151*cdf0e10cSrcweir } 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir void SfxBindings::ExecuteGlobal_Impl( sal_uInt16 nId ) 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir if( nId && pDispatcher ) 1156*cdf0e10cSrcweir Execute_Impl( nId, NULL, 0, SFX_CALLMODE_ASYNCHRON, NULL, sal_True ); 1157*cdf0e10cSrcweir } 1158*cdf0e10cSrcweir 1159*cdf0e10cSrcweir const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, SfxCallMode nCallMode, 1160*cdf0e10cSrcweir const SfxPoolItem **ppInternalArgs, sal_Bool bGlobalOnly ) 1161*cdf0e10cSrcweir { 1162*cdf0e10cSrcweir SfxStateCache *pCache = GetStateCache( nId ); 1163*cdf0e10cSrcweir if ( !pCache ) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir SfxBindings *pBind = pImp->pSubBindings; 1166*cdf0e10cSrcweir while ( pBind ) 1167*cdf0e10cSrcweir { 1168*cdf0e10cSrcweir if ( pBind->GetStateCache( nId ) ) 1169*cdf0e10cSrcweir return pBind->Execute_Impl( nId, ppItems, nModi, nCallMode, ppInternalArgs, bGlobalOnly ); 1170*cdf0e10cSrcweir pBind = pBind->pImp->pSubBindings; 1171*cdf0e10cSrcweir }; 1172*cdf0e10cSrcweir } 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir SfxDispatcher &rDispatcher = *pDispatcher; 1175*cdf0e10cSrcweir rDispatcher.Flush(); 1176*cdf0e10cSrcweir rDispatcher.GetFrame(); // -Wall is this required??? 1177*cdf0e10cSrcweir 1178*cdf0e10cSrcweir // get SlotServer (Slot+ShellLevel) and Shell from cache 1179*cdf0e10cSrcweir sal_Bool bDeleteCache = sal_False; 1180*cdf0e10cSrcweir if ( !pCache ) 1181*cdf0e10cSrcweir { 1182*cdf0e10cSrcweir // Execution of non cached slots (Accelerators don't use Controllers) 1183*cdf0e10cSrcweir // slot is uncached, use SlotCache to handle external dispatch providers 1184*cdf0e10cSrcweir pCache = new SfxStateCache( nId ); 1185*cdf0e10cSrcweir pCache->GetSlotServer( rDispatcher, pImp->xProv ); 1186*cdf0e10cSrcweir bDeleteCache = sal_True; 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir if ( pCache && pCache->GetDispatch().is() ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir DBG_ASSERT( !ppInternalArgs, "Internal args get lost when dispatched!" ); 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir SfxItemPool &rPool = GetDispatcher()->GetFrame()->GetObjectShell()->GetPool(); 1194*cdf0e10cSrcweir SfxRequest aReq( nId, nCallMode, rPool ); 1195*cdf0e10cSrcweir aReq.SetModifier( nModi ); 1196*cdf0e10cSrcweir if( ppItems ) 1197*cdf0e10cSrcweir while( *ppItems ) 1198*cdf0e10cSrcweir aReq.AppendItem( **ppItems++ ); 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir // cache binds to an external dispatch provider 1201*cdf0e10cSrcweir pCache->Dispatch( aReq.GetArgs(), nCallMode == SFX_CALLMODE_SYNCHRON ); 1202*cdf0e10cSrcweir if ( bDeleteCache ) 1203*cdf0e10cSrcweir DELETEZ( pCache ); 1204*cdf0e10cSrcweir SfxPoolItem *pVoid = new SfxVoidItem( nId ); 1205*cdf0e10cSrcweir DeleteItemOnIdle( pVoid ); 1206*cdf0e10cSrcweir return pVoid; 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir // slot is handled internally by SfxDispatcher 1210*cdf0e10cSrcweir if ( pImp->bMsgDirty ) 1211*cdf0e10cSrcweir UpdateSlotServer_Impl(); 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir SfxShell *pShell=0; 1214*cdf0e10cSrcweir const SfxSlot *pSlot=0; 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir // if slot was uncached, we should have created a cache in this method! 1217*cdf0e10cSrcweir DBG_ASSERT( pCache, "This code needs a cache!"); 1218*cdf0e10cSrcweir const SfxSlotServer* pServer = pCache ? pCache->GetSlotServer( rDispatcher, pImp->xProv ) : 0; 1219*cdf0e10cSrcweir if ( !pServer ) 1220*cdf0e10cSrcweir { 1221*cdf0e10cSrcweir return NULL; 1222*cdf0e10cSrcweir } 1223*cdf0e10cSrcweir else 1224*cdf0e10cSrcweir { 1225*cdf0e10cSrcweir pShell = rDispatcher.GetShell( pServer->GetShellLevel() ); 1226*cdf0e10cSrcweir pSlot = pServer->GetSlot(); 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir if ( bGlobalOnly ) 1230*cdf0e10cSrcweir if ( !pShell->ISA(SfxModule) && !pShell->ISA(SfxApplication) && !pShell->ISA(SfxViewFrame) ) 1231*cdf0e10cSrcweir return NULL; 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir SfxItemPool &rPool = pShell->GetPool(); 1234*cdf0e10cSrcweir SfxRequest aReq( nId, nCallMode, rPool ); 1235*cdf0e10cSrcweir aReq.SetModifier( nModi ); 1236*cdf0e10cSrcweir if( ppItems ) 1237*cdf0e10cSrcweir while( *ppItems ) 1238*cdf0e10cSrcweir aReq.AppendItem( **ppItems++ ); 1239*cdf0e10cSrcweir if ( ppInternalArgs ) 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir SfxAllItemSet aSet( rPool ); 1242*cdf0e10cSrcweir for ( const SfxPoolItem **pArg = ppInternalArgs; *pArg; ++pArg ) 1243*cdf0e10cSrcweir aSet.Put( **pArg ); 1244*cdf0e10cSrcweir aReq.SetInternalArgs_Impl( aSet ); 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir 1247*cdf0e10cSrcweir Execute_Impl( aReq, pSlot, pShell ); 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir const SfxPoolItem* pRet = aReq.GetReturnValue(); 1250*cdf0e10cSrcweir if ( !pRet ) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir SfxPoolItem *pVoid = new SfxVoidItem( nId ); 1253*cdf0e10cSrcweir DeleteItemOnIdle( pVoid ); 1254*cdf0e10cSrcweir pRet = pVoid; 1255*cdf0e10cSrcweir } 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir if ( bDeleteCache ) 1258*cdf0e10cSrcweir delete pCache; 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir return pRet; 1261*cdf0e10cSrcweir } 1262*cdf0e10cSrcweir 1263*cdf0e10cSrcweir void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell* pShell ) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir SfxItemPool &rPool = pShell->GetPool(); 1266*cdf0e10cSrcweir 1267*cdf0e10cSrcweir if ( SFX_KIND_ENUM == pSlot->GetKind() ) 1268*cdf0e10cSrcweir { 1269*cdf0e10cSrcweir // bei Enum-Slots muss der Master mit dem Wert des Enums executet werden 1270*cdf0e10cSrcweir const SfxSlot *pRealSlot = pShell->GetInterface()->GetRealSlot(pSlot); 1271*cdf0e10cSrcweir const sal_uInt16 nSlotId = pRealSlot->GetSlotId(); 1272*cdf0e10cSrcweir aReq.SetSlot( nSlotId ); 1273*cdf0e10cSrcweir aReq.AppendItem( SfxAllEnumItem( rPool.GetWhich(nSlotId), pSlot->GetValue() ) ); 1274*cdf0e10cSrcweir pDispatcher->_Execute( *pShell, *pRealSlot, aReq, aReq.GetCallMode() | SFX_CALLMODE_RECORD ); 1275*cdf0e10cSrcweir } 1276*cdf0e10cSrcweir else if ( SFX_KIND_ATTR == pSlot->GetKind() ) 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir // bei Attr-Slots muss der Which-Wert gemapped werden 1279*cdf0e10cSrcweir const sal_uInt16 nSlotId = pSlot->GetSlotId(); 1280*cdf0e10cSrcweir aReq.SetSlot( nSlotId ); 1281*cdf0e10cSrcweir if ( pSlot->IsMode(SFX_SLOT_TOGGLE) ) 1282*cdf0e10cSrcweir { 1283*cdf0e10cSrcweir // an togglebare-Attribs (Bools) wird der Wert angeheangt 1284*cdf0e10cSrcweir sal_uInt16 nWhich = pSlot->GetWhich(rPool); 1285*cdf0e10cSrcweir SfxItemSet aSet(rPool, nWhich, nWhich, 0); 1286*cdf0e10cSrcweir SfxStateFunc aFunc = pSlot->GetStateFnc(); 1287*cdf0e10cSrcweir pShell->CallState( aFunc, aSet ); 1288*cdf0e10cSrcweir const SfxPoolItem *pOldItem; 1289*cdf0e10cSrcweir SfxItemState eState = aSet.GetItemState(nWhich, sal_True, &pOldItem); 1290*cdf0e10cSrcweir if ( eState == SFX_ITEM_DISABLED ) 1291*cdf0e10cSrcweir return; 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir if ( SFX_ITEM_AVAILABLE == eState && SfxItemPool::IsWhich(nWhich) ) 1294*cdf0e10cSrcweir pOldItem = &aSet.Get(nWhich); 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir if ( SFX_ITEM_SET == eState || 1297*cdf0e10cSrcweir ( SFX_ITEM_AVAILABLE == eState && 1298*cdf0e10cSrcweir SfxItemPool::IsWhich(nWhich) && 1299*cdf0e10cSrcweir pOldItem ) ) 1300*cdf0e10cSrcweir { 1301*cdf0e10cSrcweir if ( pOldItem->ISA(SfxBoolItem) ) 1302*cdf0e10cSrcweir { 1303*cdf0e10cSrcweir // wir koennen Bools toggeln 1304*cdf0e10cSrcweir sal_Bool bOldValue = ((const SfxBoolItem *)pOldItem)->GetValue(); 1305*cdf0e10cSrcweir SfxBoolItem *pNewItem = (SfxBoolItem*) (pOldItem->Clone()); 1306*cdf0e10cSrcweir pNewItem->SetValue( !bOldValue ); 1307*cdf0e10cSrcweir aReq.AppendItem( *pNewItem ); 1308*cdf0e10cSrcweir delete pNewItem; 1309*cdf0e10cSrcweir } 1310*cdf0e10cSrcweir else if ( pOldItem->ISA(SfxEnumItemInterface) && 1311*cdf0e10cSrcweir ((SfxEnumItemInterface *)pOldItem)->HasBoolValue()) 1312*cdf0e10cSrcweir { 1313*cdf0e10cSrcweir // und Enums mit Bool-Interface 1314*cdf0e10cSrcweir SfxEnumItemInterface *pNewItem = 1315*cdf0e10cSrcweir (SfxEnumItemInterface*) (pOldItem->Clone()); 1316*cdf0e10cSrcweir pNewItem->SetBoolValue(!((SfxEnumItemInterface *)pOldItem)->GetBoolValue()); 1317*cdf0e10cSrcweir aReq.AppendItem( *pNewItem ); 1318*cdf0e10cSrcweir delete pNewItem; 1319*cdf0e10cSrcweir } 1320*cdf0e10cSrcweir else { 1321*cdf0e10cSrcweir DBG_ERROR( "Toggle only for Enums and Bools allowed" ); 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir } 1324*cdf0e10cSrcweir else if ( SFX_ITEM_DONTCARE == eState ) 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir // ein Status-Item per Factory erzeugen 1327*cdf0e10cSrcweir SfxPoolItem *pNewItem = pSlot->GetType()->CreateItem(); 1328*cdf0e10cSrcweir DBG_ASSERT( pNewItem, "Toggle an Slot ohne ItemFactory" ); 1329*cdf0e10cSrcweir pNewItem->SetWhich( nWhich ); 1330*cdf0e10cSrcweir 1331*cdf0e10cSrcweir if ( pNewItem->ISA(SfxBoolItem) ) 1332*cdf0e10cSrcweir { 1333*cdf0e10cSrcweir // wir koennen Bools toggeln 1334*cdf0e10cSrcweir ((SfxBoolItem*)pNewItem)->SetValue( sal_True ); 1335*cdf0e10cSrcweir aReq.AppendItem( *pNewItem ); 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir else if ( pNewItem->ISA(SfxEnumItemInterface) && 1338*cdf0e10cSrcweir ((SfxEnumItemInterface *)pNewItem)->HasBoolValue()) 1339*cdf0e10cSrcweir { 1340*cdf0e10cSrcweir // und Enums mit Bool-Interface 1341*cdf0e10cSrcweir ((SfxEnumItemInterface*)pNewItem)->SetBoolValue(sal_True); 1342*cdf0e10cSrcweir aReq.AppendItem( *pNewItem ); 1343*cdf0e10cSrcweir } 1344*cdf0e10cSrcweir else { 1345*cdf0e10cSrcweir DBG_ERROR( "Toggle only for Enums and Bools allowed" ); 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir delete pNewItem; 1348*cdf0e10cSrcweir } 1349*cdf0e10cSrcweir else { 1350*cdf0e10cSrcweir DBG_ERROR( "suspicious Toggle-Slot" ); 1351*cdf0e10cSrcweir } 1352*cdf0e10cSrcweir } 1353*cdf0e10cSrcweir 1354*cdf0e10cSrcweir pDispatcher->_Execute( *pShell, *pSlot, aReq, aReq.GetCallMode() | SFX_CALLMODE_RECORD ); 1355*cdf0e10cSrcweir } 1356*cdf0e10cSrcweir else 1357*cdf0e10cSrcweir pDispatcher->_Execute( *pShell, *pSlot, aReq, aReq.GetCallMode() | SFX_CALLMODE_RECORD ); 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir 1360*cdf0e10cSrcweir //-------------------------------------------------------------------- 1361*cdf0e10cSrcweir 1362*cdf0e10cSrcweir void SfxBindings::UpdateSlotServer_Impl() 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsUpdateServers); 1365*cdf0e10cSrcweir DBG_MEMTEST(); 1366*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1367*cdf0e10cSrcweir 1368*cdf0e10cSrcweir // synchronisieren 1369*cdf0e10cSrcweir pDispatcher->Flush(); 1370*cdf0e10cSrcweir // pDispatcher->Update_Impl(); 1371*cdf0e10cSrcweir 1372*cdf0e10cSrcweir if ( pImp->bAllMsgDirty ) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir if ( !nRegLevel ) 1375*cdf0e10cSrcweir { 1376*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame 1377*cdf0e10cSrcweir ( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); 1378*cdf0e10cSrcweir //if ( xFrame.is() ) 1379*cdf0e10cSrcweir // xFrame->contextChanged(); 1380*cdf0e10cSrcweir pImp->bContextChanged = sal_False; 1381*cdf0e10cSrcweir } 1382*cdf0e10cSrcweir else 1383*cdf0e10cSrcweir pImp->bContextChanged = sal_True; 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir 1386*cdf0e10cSrcweir const sal_uInt16 nCount = pImp->pCaches->Count(); 1387*cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nCount; ++i) 1388*cdf0e10cSrcweir { 1389*cdf0e10cSrcweir SfxStateCache *pCache = pImp->pCaches->GetObject(i); 1390*cdf0e10cSrcweir pCache->GetSlotServer(*pDispatcher, pImp->xProv); 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir pImp->bMsgDirty = pImp->bAllMsgDirty = sal_False; 1393*cdf0e10cSrcweir 1394*cdf0e10cSrcweir Broadcast( SfxSimpleHint(SFX_HINT_DOCCHANGED) ); 1395*cdf0e10cSrcweir 1396*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsUpdateServers); 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir 1399*cdf0e10cSrcweir //-------------------------------------------------------------------- 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir #ifdef WNT 1402*cdf0e10cSrcweir int __cdecl CmpUS_Impl(const void *p1, const void *p2) 1403*cdf0e10cSrcweir #else 1404*cdf0e10cSrcweir int CmpUS_Impl(const void *p1, const void *p2) 1405*cdf0e10cSrcweir #endif 1406*cdf0e10cSrcweir 1407*cdf0e10cSrcweir /* [Beschreibung] 1408*cdf0e10cSrcweir 1409*cdf0e10cSrcweir Interne Vergleichsfunktion fuer qsort. 1410*cdf0e10cSrcweir */ 1411*cdf0e10cSrcweir 1412*cdf0e10cSrcweir { 1413*cdf0e10cSrcweir return *(sal_uInt16 *)p1 - *(sal_uInt16 *)p2; 1414*cdf0e10cSrcweir } 1415*cdf0e10cSrcweir 1416*cdf0e10cSrcweir //-------------------------------------------------------------------- 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir SfxItemSet* SfxBindings::CreateSet_Impl 1419*cdf0e10cSrcweir ( 1420*cdf0e10cSrcweir SfxStateCache*& pCache, // in: Status-Cache von nId 1421*cdf0e10cSrcweir const SfxSlot*& pRealSlot, // out: RealSlot zu nId 1422*cdf0e10cSrcweir const SfxSlotServer** pMsgServer, // out: Slot-Server zu nId 1423*cdf0e10cSrcweir SfxFoundCacheArr_Impl& rFound // out: Liste der Caches der Siblings 1424*cdf0e10cSrcweir ) 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir DBG_MEMTEST(); 1427*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir DBG_ASSERT( !pImp->bMsgDirty, "CreateSet_Impl mit dirty MessageServer" ); 1430*cdf0e10cSrcweir 1431*cdf0e10cSrcweir const SfxSlotServer* pMsgSvr = pCache->GetSlotServer(*pDispatcher, pImp->xProv); 1432*cdf0e10cSrcweir if(!pMsgSvr || !pDispatcher) 1433*cdf0e10cSrcweir return 0; 1434*cdf0e10cSrcweir 1435*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsCreateSet); 1436*cdf0e10cSrcweir pRealSlot = 0; 1437*cdf0e10cSrcweir *pMsgServer = pMsgSvr; 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir sal_uInt16 nShellLevel = pMsgSvr->GetShellLevel(); 1440*cdf0e10cSrcweir SfxShell *pShell = pDispatcher->GetShell( nShellLevel ); 1441*cdf0e10cSrcweir if ( !pShell ) // seltener GPF beim Browsen durch Update aus Inet-Notify 1442*cdf0e10cSrcweir return 0; 1443*cdf0e10cSrcweir 1444*cdf0e10cSrcweir SfxItemPool &rPool = pShell->GetPool(); 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir // hole die Status-Methode, von der pCache bedient wird 1447*cdf0e10cSrcweir SfxStateFunc pFnc = 0; 1448*cdf0e10cSrcweir const SfxInterface *pInterface = pShell->GetInterface(); 1449*cdf0e10cSrcweir if ( SFX_KIND_ENUM == pMsgSvr->GetSlot()->GetKind() ) 1450*cdf0e10cSrcweir { 1451*cdf0e10cSrcweir pRealSlot = pInterface->GetRealSlot(pMsgSvr->GetSlot()); 1452*cdf0e10cSrcweir pCache = GetStateCache( pRealSlot->GetSlotId() ); 1453*cdf0e10cSrcweir // DBG_ASSERT( pCache, "Kein Slotcache fuer den Masterslot gefunden!" ); 1454*cdf0e10cSrcweir } 1455*cdf0e10cSrcweir else 1456*cdf0e10cSrcweir pRealSlot = pMsgSvr->GetSlot(); 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir // 1459*cdf0e10cSrcweir // Achtung: pCache darf auch NULL sein !!! 1460*cdf0e10cSrcweir // 1461*cdf0e10cSrcweir 1462*cdf0e10cSrcweir pFnc = pRealSlot->GetStateFnc(); 1463*cdf0e10cSrcweir 1464*cdf0e10cSrcweir // der RealSlot ist immer drin 1465*cdf0e10cSrcweir const SfxFoundCache_Impl *pFound = new SfxFoundCache_Impl( 1466*cdf0e10cSrcweir pRealSlot->GetSlotId(), pRealSlot->GetWhich(rPool), pRealSlot, pCache ); 1467*cdf0e10cSrcweir rFound.Insert( pFound ); 1468*cdf0e10cSrcweir 1469*cdf0e10cSrcweir sal_uInt16 nSlot = pRealSlot->GetSlotId(); 1470*cdf0e10cSrcweir if ( !(nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) ) 1471*cdf0e10cSrcweir { 1472*cdf0e10cSrcweir pInterface = pInterface->GetRealInterfaceForSlot( pRealSlot ); 1473*cdf0e10cSrcweir DBG_ASSERT (pInterface,"Slot in angegebener Shell nicht gefunden!"); 1474*cdf0e10cSrcweir } 1475*cdf0e10cSrcweir 1476*cdf0e10cSrcweir // Durchsuche die Bindings nach den von derselben Funktion bedienten Slots. 1477*cdf0e10cSrcweir // Daf"ur kommen nur Slots in Frage, die es im gefundenen Interface gibt. 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir // Die Position des Statecaches im StateCache-Array 1480*cdf0e10cSrcweir sal_uInt16 nCachePos = pImp->nMsgPos; 1481*cdf0e10cSrcweir const SfxSlot *pSibling = pRealSlot->GetNextSlot(); 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir // Die Slots eines Interfaces sind im Kreis verkettet 1484*cdf0e10cSrcweir while ( pSibling > pRealSlot ) 1485*cdf0e10cSrcweir { 1486*cdf0e10cSrcweir SfxStateFunc pSiblingFnc=0; 1487*cdf0e10cSrcweir SfxStateCache *pSiblingCache = 1488*cdf0e10cSrcweir GetStateCache( pSibling->GetSlotId(), &nCachePos ); 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir // Ist der Slot "uberhaupt gecached ? 1491*cdf0e10cSrcweir if ( pSiblingCache ) 1492*cdf0e10cSrcweir { 1493*cdf0e10cSrcweir const SfxSlotServer *pServ = pSiblingCache->GetSlotServer(*pDispatcher, pImp->xProv); 1494*cdf0e10cSrcweir if ( pServ && pServ->GetShellLevel() == nShellLevel ) 1495*cdf0e10cSrcweir pSiblingFnc = pServ->GetSlot()->GetStateFnc(); 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir // Mu\s der Slot "uberhaupt upgedatet werden ? 1499*cdf0e10cSrcweir bool bInsert = pSiblingCache && pSiblingCache->IsControllerDirty(); 1500*cdf0e10cSrcweir 1501*cdf0e10cSrcweir // Bugfix #26161#: Es reicht nicht, nach der selben Shell zu fragen !! 1502*cdf0e10cSrcweir bool bSameMethod = pSiblingCache && pFnc == pSiblingFnc; 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir // Wenn der Slot ein nicht-dirty MasterSlot ist, dann ist vielleicht 1505*cdf0e10cSrcweir // einer seiner Slaves dirty ? Dann wird der Masterslot doch eingef"ugt. 1506*cdf0e10cSrcweir if ( !bInsert && bSameMethod && pSibling->GetLinkedSlot() ) 1507*cdf0e10cSrcweir { 1508*cdf0e10cSrcweir // auch Slave-Slots auf Binding pru"fen 1509*cdf0e10cSrcweir const SfxSlot* pFirstSlave = pSibling->GetLinkedSlot(); 1510*cdf0e10cSrcweir for ( const SfxSlot *pSlaveSlot = pFirstSlave; 1511*cdf0e10cSrcweir !bInsert; 1512*cdf0e10cSrcweir pSlaveSlot = pSlaveSlot->GetNextSlot()) 1513*cdf0e10cSrcweir { 1514*cdf0e10cSrcweir // Die Slaves zeigen auf ihren Master 1515*cdf0e10cSrcweir DBG_ASSERT(pSlaveSlot->GetLinkedSlot() == pSibling, 1516*cdf0e10cSrcweir "Falsche Master/Slave-Beziehung!"); 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir sal_uInt16 nCurMsgPos = pImp->nMsgPos; 1519*cdf0e10cSrcweir const SfxStateCache *pSlaveCache = 1520*cdf0e10cSrcweir GetStateCache( pSlaveSlot->GetSlotId(), &nCurMsgPos ); 1521*cdf0e10cSrcweir 1522*cdf0e10cSrcweir // Ist der Slave-Slot gecached und dirty ? 1523*cdf0e10cSrcweir bInsert = pSlaveCache && pSlaveCache->IsControllerDirty(); 1524*cdf0e10cSrcweir 1525*cdf0e10cSrcweir // Slaves sind untereinander im Kreis verkettet 1526*cdf0e10cSrcweir if (pSlaveSlot->GetNextSlot() == pFirstSlave) 1527*cdf0e10cSrcweir break; 1528*cdf0e10cSrcweir } 1529*cdf0e10cSrcweir } 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir if ( bInsert && bSameMethod ) 1532*cdf0e10cSrcweir { 1533*cdf0e10cSrcweir const SfxFoundCache_Impl *pFoundCache = new SfxFoundCache_Impl( 1534*cdf0e10cSrcweir pSibling->GetSlotId(), pSibling->GetWhich(rPool), 1535*cdf0e10cSrcweir pSibling, pSiblingCache ); 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir rFound.Insert( pFoundCache ); 1538*cdf0e10cSrcweir } 1539*cdf0e10cSrcweir 1540*cdf0e10cSrcweir pSibling = pSibling->GetNextSlot(); 1541*cdf0e10cSrcweir } 1542*cdf0e10cSrcweir 1543*cdf0e10cSrcweir // aus den Ranges ein Set erzeugen 1544*cdf0e10cSrcweir sal_uInt16 *pRanges = new sal_uInt16[rFound.Count() * 2 + 1]; 1545*cdf0e10cSrcweir int j = 0; 1546*cdf0e10cSrcweir sal_uInt16 i = 0; 1547*cdf0e10cSrcweir while ( i < rFound.Count() ) 1548*cdf0e10cSrcweir { 1549*cdf0e10cSrcweir pRanges[j++] = rFound[i]->nWhichId; 1550*cdf0e10cSrcweir // aufeinanderfolgende Zahlen 1551*cdf0e10cSrcweir for ( ; i < rFound.Count()-1; ++i ) 1552*cdf0e10cSrcweir if ( rFound[i]->nWhichId+1 != rFound[i+1]->nWhichId ) 1553*cdf0e10cSrcweir break; 1554*cdf0e10cSrcweir pRanges[j++] = rFound[i++]->nWhichId; 1555*cdf0e10cSrcweir } 1556*cdf0e10cSrcweir pRanges[j] = 0; // terminierende NULL 1557*cdf0e10cSrcweir SfxItemSet *pSet = new SfxItemSet(rPool, pRanges); 1558*cdf0e10cSrcweir delete [] pRanges; 1559*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsCreateSet); 1560*cdf0e10cSrcweir return pSet; 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir 1563*cdf0e10cSrcweir //-------------------------------------------------------------------- 1564*cdf0e10cSrcweir 1565*cdf0e10cSrcweir void SfxBindings::UpdateControllers_Impl 1566*cdf0e10cSrcweir ( 1567*cdf0e10cSrcweir const SfxInterface* pIF, // das diese Id momentan bedienende Interface 1568*cdf0e10cSrcweir const SfxFoundCache_Impl* pFound, // Cache, Slot, Which etc. 1569*cdf0e10cSrcweir const SfxPoolItem* pItem, // item to send to controller 1570*cdf0e10cSrcweir SfxItemState eState // state of item 1571*cdf0e10cSrcweir ) 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir DBG_ASSERT( !pFound->pSlot || SFX_KIND_ENUM != pFound->pSlot->GetKind(), 1574*cdf0e10cSrcweir "direct update of enum slot isn't allowed" ); 1575*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsUpdateCtrl1); 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir SfxStateCache* pCache = pFound->pCache; 1578*cdf0e10cSrcweir const SfxSlot* pSlot = pFound->pSlot; 1579*cdf0e10cSrcweir DBG_ASSERT( !pCache || !pSlot || pCache->GetId() == pSlot->GetSlotId(), "SID mismatch" ); 1580*cdf0e10cSrcweir 1581*cdf0e10cSrcweir // insofern gebunden, die Controller f"uer den Slot selbst updaten 1582*cdf0e10cSrcweir if ( pCache && pCache->IsControllerDirty() ) 1583*cdf0e10cSrcweir { 1584*cdf0e10cSrcweir if ( SFX_ITEM_DONTCARE == eState ) 1585*cdf0e10cSrcweir { 1586*cdf0e10cSrcweir // uneindeuting 1587*cdf0e10cSrcweir pCache->SetState( SFX_ITEM_DONTCARE, (SfxPoolItem *)-1 ); 1588*cdf0e10cSrcweir } 1589*cdf0e10cSrcweir else if ( SFX_ITEM_DEFAULT == eState && 1590*cdf0e10cSrcweir pFound->nWhichId > SFX_WHICH_MAX ) 1591*cdf0e10cSrcweir { 1592*cdf0e10cSrcweir // kein Status oder Default aber ohne Pool 1593*cdf0e10cSrcweir SfxVoidItem aVoid(0); 1594*cdf0e10cSrcweir pCache->SetState( SFX_ITEM_UNKNOWN, &aVoid ); 1595*cdf0e10cSrcweir } 1596*cdf0e10cSrcweir else if ( SFX_ITEM_DISABLED == eState ) 1597*cdf0e10cSrcweir pCache->SetState(SFX_ITEM_DISABLED, 0); 1598*cdf0e10cSrcweir else 1599*cdf0e10cSrcweir pCache->SetState(SFX_ITEM_AVAILABLE, pItem); 1600*cdf0e10cSrcweir } 1601*cdf0e10cSrcweir 1602*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsUpdateCtrl1); 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir // insofern vorhanden und gebunden, die Controller f"uer Slave-Slots 1605*cdf0e10cSrcweir // (Enum-Werte) des Slots updaten 1606*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsUpdateCtrl2); 1607*cdf0e10cSrcweir DBG_ASSERT( !pSlot || 0 == pSlot->GetLinkedSlot() || !pItem || 1608*cdf0e10cSrcweir pItem->ISA(SfxEnumItemInterface), 1609*cdf0e10cSrcweir "master slot with non-enum-type found" ); 1610*cdf0e10cSrcweir const SfxSlot *pFirstSlave = pSlot ? pSlot->GetLinkedSlot() : 0; 1611*cdf0e10cSrcweir if ( pIF && pFirstSlave) 1612*cdf0e10cSrcweir { 1613*cdf0e10cSrcweir // Items auf EnumItem casten 1614*cdf0e10cSrcweir const SfxEnumItemInterface *pEnumItem = 1615*cdf0e10cSrcweir PTR_CAST(SfxEnumItemInterface,pItem); 1616*cdf0e10cSrcweir if ( eState == SFX_ITEM_AVAILABLE && !pEnumItem ) 1617*cdf0e10cSrcweir eState = SFX_ITEM_DONTCARE; 1618*cdf0e10cSrcweir else 1619*cdf0e10cSrcweir eState = SfxControllerItem::GetItemState( pEnumItem ); 1620*cdf0e10cSrcweir 1621*cdf0e10cSrcweir // "uber alle Slaves-Slots iterieren 1622*cdf0e10cSrcweir for ( const SfxSlot *pSlave = pFirstSlave; pSlave; pSlave = pSlave->GetNextSlot() ) 1623*cdf0e10cSrcweir { 1624*cdf0e10cSrcweir DBG_ASSERT(pSlave, "Falsche SlaveSlot-Verkettung!"); 1625*cdf0e10cSrcweir DBG_ASSERT(SFX_KIND_ENUM == pSlave->GetKind(),"non enum slaves aren't allowed"); 1626*cdf0e10cSrcweir DBG_ASSERT(pSlave->GetMasterSlotId() == pSlot->GetSlotId(),"falscher MasterSlot!"); 1627*cdf0e10cSrcweir 1628*cdf0e10cSrcweir // ist die Funktion gebunden? 1629*cdf0e10cSrcweir SfxStateCache *pEnumCache = GetStateCache( pSlave->GetSlotId() ); 1630*cdf0e10cSrcweir if ( pEnumCache ) 1631*cdf0e10cSrcweir { 1632*cdf0e10cSrcweir pEnumCache->Invalidate(sal_False); 1633*cdf0e10cSrcweir 1634*cdf0e10cSrcweir HACK(CONTROL/SELECT Kram) 1635*cdf0e10cSrcweir if ( eState == SFX_ITEM_DONTCARE && pFound->nWhichId == 10144 ) 1636*cdf0e10cSrcweir { 1637*cdf0e10cSrcweir SfxVoidItem aVoid(0); 1638*cdf0e10cSrcweir pEnumCache->SetState( SFX_ITEM_UNKNOWN, &aVoid ); 1639*cdf0e10cSrcweir 1640*cdf0e10cSrcweir if (pSlave->GetNextSlot() == pFirstSlave) 1641*cdf0e10cSrcweir break; 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir continue; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir 1646*cdf0e10cSrcweir if ( SFX_ITEM_DISABLED == eState || !pEnumItem->IsEnabled( pSlave->GetSlotId()) ) 1647*cdf0e10cSrcweir { 1648*cdf0e10cSrcweir // disabled 1649*cdf0e10cSrcweir pEnumCache->SetState(SFX_ITEM_DISABLED, 0); 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir else if ( SFX_ITEM_AVAILABLE == eState ) 1652*cdf0e10cSrcweir { 1653*cdf0e10cSrcweir // enum-Wert ermitteln 1654*cdf0e10cSrcweir sal_uInt16 nValue = pEnumItem->GetEnumValue(); 1655*cdf0e10cSrcweir SfxBoolItem aBool( pFound->nWhichId, pSlave->GetValue() == nValue ); 1656*cdf0e10cSrcweir pEnumCache->SetState(SFX_ITEM_AVAILABLE, &aBool); 1657*cdf0e10cSrcweir } 1658*cdf0e10cSrcweir else 1659*cdf0e10cSrcweir { 1660*cdf0e10cSrcweir // uneindeuting 1661*cdf0e10cSrcweir pEnumCache->SetState( SFX_ITEM_DONTCARE, (SfxPoolItem *)-1 ); 1662*cdf0e10cSrcweir } 1663*cdf0e10cSrcweir } 1664*cdf0e10cSrcweir 1665*cdf0e10cSrcweir if (pSlave->GetNextSlot() == pFirstSlave) 1666*cdf0e10cSrcweir break; 1667*cdf0e10cSrcweir } 1668*cdf0e10cSrcweir } 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsUpdateCtrl2); 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir //-------------------------------------------------------------------- 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir IMPL_LINK( SfxBindings, NextJob_Impl, Timer *, pTimer ) 1677*cdf0e10cSrcweir { 1678*cdf0e10cSrcweir #ifdef DBG_UTIL 1679*cdf0e10cSrcweir // on Windows very often C++ Exceptions (GPF etc.) are caught by MSVCRT or another MS library 1680*cdf0e10cSrcweir // try to get them here 1681*cdf0e10cSrcweir try 1682*cdf0e10cSrcweir { 1683*cdf0e10cSrcweir #endif 1684*cdf0e10cSrcweir const unsigned MAX_INPUT_DELAY = 200; 1685*cdf0e10cSrcweir 1686*cdf0e10cSrcweir DBG_MEMTEST(); 1687*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1688*cdf0e10cSrcweir 1689*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsNextJob_Impl0); 1690*cdf0e10cSrcweir 1691*cdf0e10cSrcweir if ( Application::GetLastInputInterval() < MAX_INPUT_DELAY && pTimer ) 1692*cdf0e10cSrcweir { 1693*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_UPDATING); 1694*cdf0e10cSrcweir return sal_True; 1695*cdf0e10cSrcweir } 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir SfxApplication *pSfxApp = SFX_APP(); 1698*cdf0e10cSrcweir 1699*cdf0e10cSrcweir if( pDispatcher ) 1700*cdf0e10cSrcweir pDispatcher->Update_Impl(); 1701*cdf0e10cSrcweir 1702*cdf0e10cSrcweir // modifying the SfxObjectInterface-stack without SfxBindings => nothing to do 1703*cdf0e10cSrcweir SfxViewFrame* pFrame = pDispatcher->GetFrame(); 1704*cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker 1705*cdf0e10cSrcweir //if ( (pFrame && pFrame->GetObjectShell()->IsInModalMode()) || pSfxApp->IsDowning() || !pImp->pCaches->Count() ) 1706*cdf0e10cSrcweir if ( (pFrame && !pFrame->GetObjectShell()->AcceptStateUpdate()) || pSfxApp->IsDowning() || !pImp->pCaches->Count() ) 1707*cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsNextJob_Impl0); 1710*cdf0e10cSrcweir return sal_True; 1711*cdf0e10cSrcweir } 1712*cdf0e10cSrcweir if ( !pDispatcher || !pDispatcher->IsFlushed() ) 1713*cdf0e10cSrcweir { 1714*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsNextJob_Impl0); 1715*cdf0e10cSrcweir return sal_True; 1716*cdf0e10cSrcweir } 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir // gfs. alle Server aktualisieren / geschieht in eigener Zeitscheibe 1719*cdf0e10cSrcweir if ( pImp->bMsgDirty ) 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir UpdateSlotServer_Impl(); 1722*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsNextJob_Impl0); 1723*cdf0e10cSrcweir return sal_False; 1724*cdf0e10cSrcweir } 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsNextJob_Impl0); 1727*cdf0e10cSrcweir DBG_PROFSTART(SfxBindingsNextJob_Impl); 1728*cdf0e10cSrcweir pImp->bAllDirty = sal_False; 1729*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_UPDATING); 1730*cdf0e10cSrcweir 1731*cdf0e10cSrcweir // at least 10 loops and further if more jobs are available but no input 1732*cdf0e10cSrcweir bool bPreEmptive = pTimer && !pSfxApp->Get_Impl()->nInReschedule; 1733*cdf0e10cSrcweir sal_uInt16 nLoops = 10; 1734*cdf0e10cSrcweir pImp->bInNextJob = sal_True; 1735*cdf0e10cSrcweir const sal_uInt16 nCount = pImp->pCaches->Count(); 1736*cdf0e10cSrcweir while ( pImp->nMsgPos < nCount ) 1737*cdf0e10cSrcweir { 1738*cdf0e10cSrcweir // iterate through the bound functions 1739*cdf0e10cSrcweir sal_Bool bJobDone = sal_False; 1740*cdf0e10cSrcweir while ( !bJobDone ) 1741*cdf0e10cSrcweir { 1742*cdf0e10cSrcweir SfxStateCache* pCache = (*pImp->pCaches)[pImp->nMsgPos]; 1743*cdf0e10cSrcweir DBG_ASSERT( pCache, "invalid SfxStateCache-position in job queue" ); 1744*cdf0e10cSrcweir sal_Bool bWasDirty = pCache->IsControllerDirty(); 1745*cdf0e10cSrcweir if ( bWasDirty ) 1746*cdf0e10cSrcweir { 1747*cdf0e10cSrcweir /* 1748*cdf0e10cSrcweir sal_Bool bSkip = sal_False; 1749*cdf0e10cSrcweir if ( pImp->bFirstRound ) 1750*cdf0e10cSrcweir { 1751*cdf0e10cSrcweir // Falls beim Update eine Shell vorgezogen werden soll, 1752*cdf0e10cSrcweir // kommt in einer ersten Update-Runde nur diese dran 1753*cdf0e10cSrcweir const SfxSlotServer *pMsgServer = 1754*cdf0e10cSrcweir pCache->GetSlotServer(*pDispatcher, pImp->xProv); 1755*cdf0e10cSrcweir if ( pMsgServer && 1756*cdf0e10cSrcweir pMsgServer->GetShellLevel() != pImp->nFirstShell ) 1757*cdf0e10cSrcweir bSkip = sal_True; 1758*cdf0e10cSrcweir } 1759*cdf0e10cSrcweir 1760*cdf0e10cSrcweir if ( !bSkip ) 1761*cdf0e10cSrcweir { 1762*cdf0e10cSrcweir */ 1763*cdf0e10cSrcweir Update_Impl( pCache ); 1764*cdf0e10cSrcweir DBG_ASSERT( nCount == pImp->pCaches->Count(), 1765*cdf0e10cSrcweir "Reschedule in StateChanged => buff" ); 1766*cdf0e10cSrcweir // } 1767*cdf0e10cSrcweir } 1768*cdf0e10cSrcweir 1769*cdf0e10cSrcweir // skip to next function binding 1770*cdf0e10cSrcweir ++pImp->nMsgPos; 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir // keep job if it is not completed, but any input is available 1773*cdf0e10cSrcweir bJobDone = pImp->nMsgPos >= nCount; 1774*cdf0e10cSrcweir if ( bJobDone && pImp->bFirstRound ) 1775*cdf0e10cSrcweir { 1776*cdf0e10cSrcweir // Update der bevorzugten Shell ist gelaufen, nun d"urfen 1777*cdf0e10cSrcweir // auch die anderen 1778*cdf0e10cSrcweir bJobDone = sal_False; 1779*cdf0e10cSrcweir pImp->bFirstRound = sal_False; 1780*cdf0e10cSrcweir pImp->nMsgPos = 0; 1781*cdf0e10cSrcweir } 1782*cdf0e10cSrcweir 1783*cdf0e10cSrcweir if ( bWasDirty && !bJobDone && bPreEmptive && (--nLoops == 0) ) 1784*cdf0e10cSrcweir { 1785*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsNextJob_Impl); 1786*cdf0e10cSrcweir pImp->bInNextJob = sal_False; 1787*cdf0e10cSrcweir return sal_False; 1788*cdf0e10cSrcweir } 1789*cdf0e10cSrcweir } 1790*cdf0e10cSrcweir } 1791*cdf0e10cSrcweir 1792*cdf0e10cSrcweir pImp->nMsgPos = 0; 1793*cdf0e10cSrcweir 1794*cdf0e10cSrcweir // check for volatile slots 1795*cdf0e10cSrcweir bool bVolatileSlotsPresent = false; 1796*cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nCount; ++n ) 1797*cdf0e10cSrcweir { 1798*cdf0e10cSrcweir SfxStateCache* pCache = (*pImp->pCaches)[n]; 1799*cdf0e10cSrcweir const SfxSlotServer *pSlotServer = pCache->GetSlotServer(*pDispatcher, pImp->xProv); 1800*cdf0e10cSrcweir if ( pSlotServer && pSlotServer->GetSlot()->IsMode(SFX_SLOT_VOLATILE) ) 1801*cdf0e10cSrcweir { 1802*cdf0e10cSrcweir pCache->Invalidate(sal_False); 1803*cdf0e10cSrcweir bVolatileSlotsPresent = true; 1804*cdf0e10cSrcweir } 1805*cdf0e10cSrcweir } 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir if (bVolatileSlotsPresent) 1808*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_IDLE); 1809*cdf0e10cSrcweir else 1810*cdf0e10cSrcweir pImp->aTimer.Stop(); 1811*cdf0e10cSrcweir 1812*cdf0e10cSrcweir // Update-Runde ist beendet 1813*cdf0e10cSrcweir pImp->bInNextJob = sal_False; 1814*cdf0e10cSrcweir Broadcast(SfxSimpleHint(SFX_HINT_UPDATEDONE)); 1815*cdf0e10cSrcweir DBG_PROFSTOP(SfxBindingsNextJob_Impl); 1816*cdf0e10cSrcweir return sal_True; 1817*cdf0e10cSrcweir #ifdef DBG_UTIL 1818*cdf0e10cSrcweir } 1819*cdf0e10cSrcweir catch (...) 1820*cdf0e10cSrcweir { 1821*cdf0e10cSrcweir DBG_ERROR("C++ exception caught!"); 1822*cdf0e10cSrcweir pImp->bInNextJob = sal_False; 1823*cdf0e10cSrcweir } 1824*cdf0e10cSrcweir 1825*cdf0e10cSrcweir return sal_False; 1826*cdf0e10cSrcweir #endif 1827*cdf0e10cSrcweir } 1828*cdf0e10cSrcweir 1829*cdf0e10cSrcweir //-------------------------------------------------------------------- 1830*cdf0e10cSrcweir 1831*cdf0e10cSrcweir sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine) 1832*cdf0e10cSrcweir { 1833*cdf0e10cSrcweir (void)pFile; 1834*cdf0e10cSrcweir (void)nLine; 1835*cdf0e10cSrcweir DBG_MEMTEST(); 1836*cdf0e10cSrcweir #ifdef DBG_UTIL 1837*cdf0e10cSrcweir ByteString aMsg; 1838*cdf0e10cSrcweir aMsg.Fill( Min(nRegLevel, sal_uInt16(8) ) ); 1839*cdf0e10cSrcweir aMsg += "this = "; 1840*cdf0e10cSrcweir aMsg += ByteString::CreateFromInt32((long)this); 1841*cdf0e10cSrcweir aMsg += " Level = "; 1842*cdf0e10cSrcweir aMsg += ByteString::CreateFromInt32(nRegLevel); 1843*cdf0e10cSrcweir aMsg += " SfxBindings::EnterRegistrations "; 1844*cdf0e10cSrcweir if(pFile) { 1845*cdf0e10cSrcweir aMsg += "File: "; 1846*cdf0e10cSrcweir aMsg += pFile; 1847*cdf0e10cSrcweir aMsg += " Line: "; 1848*cdf0e10cSrcweir aMsg += ByteString::CreateFromInt32(nLine); 1849*cdf0e10cSrcweir } 1850*cdf0e10cSrcweir // FILE* pLog = fopen( "c:\\bindings.log", "a+w" ); 1851*cdf0e10cSrcweir // fwrite( aMsg.GetBuffer(), 1, aMsg.Len(), pLog ); 1852*cdf0e10cSrcweir // fclose( pLog ); 1853*cdf0e10cSrcweir DbgTrace( aMsg.GetBuffer() ); 1854*cdf0e10cSrcweir #endif 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir // Wenn Bindings gelockt werden, auch SubBindings locken 1857*cdf0e10cSrcweir if ( pImp->pSubBindings ) 1858*cdf0e10cSrcweir { 1859*cdf0e10cSrcweir pImp->pSubBindings->ENTERREGISTRATIONS(); 1860*cdf0e10cSrcweir 1861*cdf0e10cSrcweir // Dieses EnterRegistrations ist f"ur die SubBindings kein "echtes" 1862*cdf0e10cSrcweir pImp->pSubBindings->pImp->nOwnRegLevel--; 1863*cdf0e10cSrcweir 1864*cdf0e10cSrcweir // Bindings synchronisieren 1865*cdf0e10cSrcweir pImp->pSubBindings->nRegLevel = nRegLevel + pImp->pSubBindings->pImp->nOwnRegLevel + 1; 1866*cdf0e10cSrcweir } 1867*cdf0e10cSrcweir 1868*cdf0e10cSrcweir pImp->nOwnRegLevel++; 1869*cdf0e10cSrcweir 1870*cdf0e10cSrcweir // check if this is the outer most level 1871*cdf0e10cSrcweir if ( ++nRegLevel == 1 ) 1872*cdf0e10cSrcweir { 1873*cdf0e10cSrcweir // stop background-processing 1874*cdf0e10cSrcweir pImp->aTimer.Stop(); 1875*cdf0e10cSrcweir 1876*cdf0e10cSrcweir // flush the cache 1877*cdf0e10cSrcweir pImp->nCachedFunc1 = 0; 1878*cdf0e10cSrcweir pImp->nCachedFunc2 = 0; 1879*cdf0e10cSrcweir 1880*cdf0e10cSrcweir // merken, ob ganze Caches verschwunden sind 1881*cdf0e10cSrcweir pImp->bCtrlReleased = sal_False; 1882*cdf0e10cSrcweir } 1883*cdf0e10cSrcweir 1884*cdf0e10cSrcweir return nRegLevel; 1885*cdf0e10cSrcweir } 1886*cdf0e10cSrcweir //-------------------------------------------------------------------- 1887*cdf0e10cSrcweir 1888*cdf0e10cSrcweir void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int nLine ) 1889*cdf0e10cSrcweir { 1890*cdf0e10cSrcweir (void)nLevel; // unused variable 1891*cdf0e10cSrcweir (void)pFile; 1892*cdf0e10cSrcweir (void)nLine; 1893*cdf0e10cSrcweir DBG_MEMTEST(); 1894*cdf0e10cSrcweir DBG_ASSERT( nRegLevel, "Leave without Enter" ); 1895*cdf0e10cSrcweir DBG_ASSERT( nLevel == USHRT_MAX || nLevel == nRegLevel, "wrong Leave" ); 1896*cdf0e10cSrcweir 1897*cdf0e10cSrcweir // Nur wenn die SubBindings noch von den SuperBindings gelockt sind, diesen Lock entfernen 1898*cdf0e10cSrcweir // ( d.h. wenn es mehr Locks als "echte" Locks dort gibt ) 1899*cdf0e10cSrcweir if ( pImp->pSubBindings && pImp->pSubBindings->nRegLevel > pImp->pSubBindings->pImp->nOwnRegLevel ) 1900*cdf0e10cSrcweir { 1901*cdf0e10cSrcweir // Bindings synchronisieren 1902*cdf0e10cSrcweir pImp->pSubBindings->nRegLevel = nRegLevel + pImp->pSubBindings->pImp->nOwnRegLevel; 1903*cdf0e10cSrcweir 1904*cdf0e10cSrcweir // Dieses LeaveRegistrations ist f"ur die SubBindings kein "echtes" 1905*cdf0e10cSrcweir pImp->pSubBindings->pImp->nOwnRegLevel++; 1906*cdf0e10cSrcweir pImp->pSubBindings->LEAVEREGISTRATIONS(); 1907*cdf0e10cSrcweir } 1908*cdf0e10cSrcweir 1909*cdf0e10cSrcweir pImp->nOwnRegLevel--; 1910*cdf0e10cSrcweir 1911*cdf0e10cSrcweir // check if this is the outer most level 1912*cdf0e10cSrcweir if ( --nRegLevel == 0 && !SFX_APP()->IsDowning() ) 1913*cdf0e10cSrcweir { 1914*cdf0e10cSrcweir if ( pImp->bContextChanged ) 1915*cdf0e10cSrcweir { 1916*cdf0e10cSrcweir pImp->bContextChanged = sal_False; 1917*cdf0e10cSrcweir /* 1918*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame 1919*cdf0e10cSrcweir ( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); 1920*cdf0e10cSrcweir if ( xFrame.is() ) 1921*cdf0e10cSrcweir xFrame->contextChanged();*/ 1922*cdf0e10cSrcweir } 1923*cdf0e10cSrcweir 1924*cdf0e10cSrcweir #ifndef slow 1925*cdf0e10cSrcweir SfxViewFrame* pFrame = pDispatcher->GetFrame(); 1926*cdf0e10cSrcweir 1927*cdf0e10cSrcweir // ggf unbenutzte Caches entfernen bzw. PlugInInfo aufbereiten 1928*cdf0e10cSrcweir if ( pImp->bCtrlReleased ) 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir for ( sal_uInt16 nCache = pImp->pCaches->Count(); nCache > 0; --nCache ) 1931*cdf0e10cSrcweir { 1932*cdf0e10cSrcweir // Cache via ::com::sun::star::sdbcx::Index besorgen 1933*cdf0e10cSrcweir SfxStateCache *pCache = pImp->pCaches->GetObject(nCache-1); 1934*cdf0e10cSrcweir 1935*cdf0e10cSrcweir // kein Controller mehr interessiert 1936*cdf0e10cSrcweir if ( pCache->GetItemLink() == 0 && !pCache->GetInternalController() ) 1937*cdf0e10cSrcweir { 1938*cdf0e10cSrcweir // Cache entfernen. Safety: first remove and then delete 1939*cdf0e10cSrcweir SfxStateCache* pSfxStateCache = (*pImp->pCaches)[nCache-1]; 1940*cdf0e10cSrcweir pImp->pCaches->Remove(nCache-1, 1); 1941*cdf0e10cSrcweir delete pSfxStateCache; 1942*cdf0e10cSrcweir } 1943*cdf0e10cSrcweir else 1944*cdf0e10cSrcweir { 1945*cdf0e10cSrcweir // neue Controller mit den alten Items benachrichtigen 1946*cdf0e10cSrcweir //!pCache->SetCachedState(); 1947*cdf0e10cSrcweir } 1948*cdf0e10cSrcweir } 1949*cdf0e10cSrcweir } 1950*cdf0e10cSrcweir #endif 1951*cdf0e10cSrcweir // restart background-processing 1952*cdf0e10cSrcweir pImp->nMsgPos = 0; 1953*cdf0e10cSrcweir if ( !pFrame || !pFrame->GetObjectShell() ) 1954*cdf0e10cSrcweir return; 1955*cdf0e10cSrcweir if ( pImp->pCaches && pImp->pCaches->Count() ) 1956*cdf0e10cSrcweir { 1957*cdf0e10cSrcweir pImp->aTimer.Stop(); 1958*cdf0e10cSrcweir pImp->aTimer.SetTimeout(TIMEOUT_FIRST); 1959*cdf0e10cSrcweir pImp->aTimer.Start(); 1960*cdf0e10cSrcweir // pImp->bFirstRound = sal_True; 1961*cdf0e10cSrcweir } 1962*cdf0e10cSrcweir } 1963*cdf0e10cSrcweir 1964*cdf0e10cSrcweir #ifdef DBG_UTIL 1965*cdf0e10cSrcweir ByteString aMsg; 1966*cdf0e10cSrcweir aMsg.Fill( Min(nRegLevel, sal_uInt16(8)) ); 1967*cdf0e10cSrcweir aMsg += "this = "; 1968*cdf0e10cSrcweir aMsg += ByteString::CreateFromInt32((long)this); 1969*cdf0e10cSrcweir aMsg += " Level = "; 1970*cdf0e10cSrcweir aMsg += ByteString::CreateFromInt32(nRegLevel); 1971*cdf0e10cSrcweir aMsg += " SfxBindings::LeaveRegistrations "; 1972*cdf0e10cSrcweir if(pFile) { 1973*cdf0e10cSrcweir aMsg += "File: "; 1974*cdf0e10cSrcweir aMsg += pFile; 1975*cdf0e10cSrcweir aMsg += " Line: "; 1976*cdf0e10cSrcweir aMsg += ByteString::CreateFromInt32(nLine); 1977*cdf0e10cSrcweir } 1978*cdf0e10cSrcweir // FILE* pLog = fopen( "c:\\bindings.log", "a+w" ); 1979*cdf0e10cSrcweir // fwrite( aMsg.GetBuffer(), 1, aMsg.Len(), pLog ); 1980*cdf0e10cSrcweir // fclose( pLog ); 1981*cdf0e10cSrcweir DbgTrace( aMsg.GetBuffer() ); 1982*cdf0e10cSrcweir #endif 1983*cdf0e10cSrcweir } 1984*cdf0e10cSrcweir 1985*cdf0e10cSrcweir //-------------------------------------------------------------------- 1986*cdf0e10cSrcweir 1987*cdf0e10cSrcweir const SfxSlot* SfxBindings::GetSlot(sal_uInt16 nSlotId) 1988*cdf0e10cSrcweir { 1989*cdf0e10cSrcweir DBG_MEMTEST(); 1990*cdf0e10cSrcweir DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" ); 1991*cdf0e10cSrcweir 1992*cdf0e10cSrcweir // syncronisieren 1993*cdf0e10cSrcweir pDispatcher->Flush(); 1994*cdf0e10cSrcweir if ( pImp->bMsgDirty ) 1995*cdf0e10cSrcweir UpdateSlotServer_Impl(); 1996*cdf0e10cSrcweir 1997*cdf0e10cSrcweir // get the cache for the specified function; return if not bound 1998*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache(nSlotId); 1999*cdf0e10cSrcweir return pCache && pCache->GetSlotServer(*pDispatcher, pImp->xProv)? 2000*cdf0e10cSrcweir pCache->GetSlotServer(*pDispatcher, pImp->xProv)->GetSlot(): 0; 2001*cdf0e10cSrcweir } 2002*cdf0e10cSrcweir 2003*cdf0e10cSrcweir //-------------------------------------------------------------------- 2004*cdf0e10cSrcweir 2005*cdf0e10cSrcweir void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) 2006*cdf0e10cSrcweir { 2007*cdf0e10cSrcweir SfxDispatcher *pOldDispat = pDispatcher; 2008*cdf0e10cSrcweir if ( pDisp != pDispatcher ) 2009*cdf0e10cSrcweir { 2010*cdf0e10cSrcweir if ( pOldDispat ) 2011*cdf0e10cSrcweir { 2012*cdf0e10cSrcweir SfxBindings* pBind = pOldDispat->GetBindings(); 2013*cdf0e10cSrcweir while ( pBind ) 2014*cdf0e10cSrcweir { 2015*cdf0e10cSrcweir if ( pBind->pImp->pSubBindings == this && pBind->pDispatcher != pDisp ) 2016*cdf0e10cSrcweir pBind->SetSubBindings_Impl( NULL ); 2017*cdf0e10cSrcweir pBind = pBind->pImp->pSubBindings; 2018*cdf0e10cSrcweir } 2019*cdf0e10cSrcweir } 2020*cdf0e10cSrcweir 2021*cdf0e10cSrcweir pDispatcher = pDisp; 2022*cdf0e10cSrcweir 2023*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > xProv; 2024*cdf0e10cSrcweir if ( pDisp ) 2025*cdf0e10cSrcweir xProv = ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > 2026*cdf0e10cSrcweir ( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); 2027*cdf0e10cSrcweir 2028*cdf0e10cSrcweir SetDispatchProvider_Impl( xProv ); 2029*cdf0e10cSrcweir InvalidateAll( sal_True ); 2030*cdf0e10cSrcweir InvalidateUnoControllers_Impl(); 2031*cdf0e10cSrcweir 2032*cdf0e10cSrcweir if ( pDispatcher && !pOldDispat ) 2033*cdf0e10cSrcweir { 2034*cdf0e10cSrcweir if ( pImp->pSubBindings && pImp->pSubBindings->pDispatcher != pOldDispat ) 2035*cdf0e10cSrcweir { 2036*cdf0e10cSrcweir DBG_ERROR( "SubBindings vor Aktivieren schon gesetzt!" ); 2037*cdf0e10cSrcweir pImp->pSubBindings->ENTERREGISTRATIONS(); 2038*cdf0e10cSrcweir } 2039*cdf0e10cSrcweir LEAVEREGISTRATIONS(); 2040*cdf0e10cSrcweir } 2041*cdf0e10cSrcweir else if( !pDispatcher ) 2042*cdf0e10cSrcweir { 2043*cdf0e10cSrcweir ENTERREGISTRATIONS(); 2044*cdf0e10cSrcweir if ( pImp->pSubBindings && pImp->pSubBindings->pDispatcher != pOldDispat ) 2045*cdf0e10cSrcweir { 2046*cdf0e10cSrcweir DBG_ERROR( "SubBindings im Deaktivieren immer noch gesetzt!" ); 2047*cdf0e10cSrcweir pImp->pSubBindings->LEAVEREGISTRATIONS(); 2048*cdf0e10cSrcweir } 2049*cdf0e10cSrcweir } 2050*cdf0e10cSrcweir 2051*cdf0e10cSrcweir Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 2052*cdf0e10cSrcweir 2053*cdf0e10cSrcweir if ( pDisp ) 2054*cdf0e10cSrcweir { 2055*cdf0e10cSrcweir SfxBindings* pBind = pDisp->GetBindings(); 2056*cdf0e10cSrcweir while ( pBind && pBind != this ) 2057*cdf0e10cSrcweir { 2058*cdf0e10cSrcweir if ( !pBind->pImp->pSubBindings ) 2059*cdf0e10cSrcweir { 2060*cdf0e10cSrcweir pBind->SetSubBindings_Impl( this ); 2061*cdf0e10cSrcweir break; 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir 2064*cdf0e10cSrcweir pBind = pBind->pImp->pSubBindings; 2065*cdf0e10cSrcweir } 2066*cdf0e10cSrcweir } 2067*cdf0e10cSrcweir } 2068*cdf0e10cSrcweir } 2069*cdf0e10cSrcweir 2070*cdf0e10cSrcweir //-------------------------------------------------------------------- 2071*cdf0e10cSrcweir 2072*cdf0e10cSrcweir void SfxBindings::ClearCache_Impl( sal_uInt16 nSlotId ) 2073*cdf0e10cSrcweir { 2074*cdf0e10cSrcweir GetStateCache(nSlotId)->ClearCache(); 2075*cdf0e10cSrcweir } 2076*cdf0e10cSrcweir 2077*cdf0e10cSrcweir //-------------------------------------------------------------------- 2078*cdf0e10cSrcweir void SfxBindings::StartUpdate_Impl( sal_Bool bComplete ) 2079*cdf0e10cSrcweir { 2080*cdf0e10cSrcweir if ( pImp->pSubBindings ) 2081*cdf0e10cSrcweir pImp->pSubBindings->StartUpdate_Impl( bComplete ); 2082*cdf0e10cSrcweir 2083*cdf0e10cSrcweir if ( !bComplete ) 2084*cdf0e10cSrcweir // Update darf unterbrochen werden 2085*cdf0e10cSrcweir NextJob_Impl(&pImp->aTimer); 2086*cdf0e10cSrcweir else 2087*cdf0e10cSrcweir // alle Slots am St"uck updaten 2088*cdf0e10cSrcweir NextJob_Impl(0); 2089*cdf0e10cSrcweir } 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir //------------------------------------------------------------------------- 2092*cdf0e10cSrcweir 2093*cdf0e10cSrcweir SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState ) 2094*cdf0e10cSrcweir { 2095*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp; 2096*cdf0e10cSrcweir SfxStateCache *pCache = GetStateCache( nSlot ); 2097*cdf0e10cSrcweir if ( pCache ) 2098*cdf0e10cSrcweir xDisp = pCache->GetDispatch(); 2099*cdf0e10cSrcweir if ( xDisp.is() || !pCache ) 2100*cdf0e10cSrcweir { 2101*cdf0e10cSrcweir const SfxSlot* pSlot = SfxSlotPool::GetSlotPool( pDispatcher->GetFrame() ).GetSlot( nSlot ); 2102*cdf0e10cSrcweir if ( !pSlot || !pSlot->pUnoName ) 2103*cdf0e10cSrcweir return SFX_ITEM_DISABLED; 2104*cdf0e10cSrcweir 2105*cdf0e10cSrcweir ::com::sun::star::util::URL aURL; 2106*cdf0e10cSrcweir ::rtl::OUString aCmd( DEFINE_CONST_UNICODE(".uno:")); 2107*cdf0e10cSrcweir aURL.Protocol = aCmd; 2108*cdf0e10cSrcweir aURL.Path = ::rtl::OUString::createFromAscii(pSlot->GetUnoName()); 2109*cdf0e10cSrcweir aCmd += aURL.Path; 2110*cdf0e10cSrcweir aURL.Complete = aCmd; 2111*cdf0e10cSrcweir aURL.Main = aCmd; 2112*cdf0e10cSrcweir 2113*cdf0e10cSrcweir if ( !xDisp.is() ) 2114*cdf0e10cSrcweir xDisp = pImp->xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); 2115*cdf0e10cSrcweir 2116*cdf0e10cSrcweir if ( xDisp.is() ) 2117*cdf0e10cSrcweir { 2118*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel( xDisp, ::com::sun::star::uno::UNO_QUERY ); 2119*cdf0e10cSrcweir SfxOfficeDispatch* pDisp = NULL; 2120*cdf0e10cSrcweir if ( xTunnel.is() ) 2121*cdf0e10cSrcweir { 2122*cdf0e10cSrcweir sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier()); 2123*cdf0e10cSrcweir pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation )); 2124*cdf0e10cSrcweir } 2125*cdf0e10cSrcweir 2126*cdf0e10cSrcweir if ( !pDisp ) 2127*cdf0e10cSrcweir { 2128*cdf0e10cSrcweir sal_Bool bDeleteCache = sal_False; 2129*cdf0e10cSrcweir if ( !pCache ) 2130*cdf0e10cSrcweir { 2131*cdf0e10cSrcweir pCache = new SfxStateCache( nSlot ); 2132*cdf0e10cSrcweir pCache->GetSlotServer( *GetDispatcher_Impl(), pImp->xProv ); 2133*cdf0e10cSrcweir bDeleteCache = sal_True; 2134*cdf0e10cSrcweir } 2135*cdf0e10cSrcweir 2136*cdf0e10cSrcweir SfxItemState eState = SFX_ITEM_SET; 2137*cdf0e10cSrcweir SfxPoolItem *pItem=NULL; 2138*cdf0e10cSrcweir BindDispatch_Impl *pBind = new BindDispatch_Impl( xDisp, aURL, pCache, pSlot ); 2139*cdf0e10cSrcweir pBind->acquire(); 2140*cdf0e10cSrcweir xDisp->addStatusListener( pBind, aURL ); 2141*cdf0e10cSrcweir if ( !pBind->GetStatus().IsEnabled ) 2142*cdf0e10cSrcweir { 2143*cdf0e10cSrcweir eState = SFX_ITEM_DISABLED; 2144*cdf0e10cSrcweir } 2145*cdf0e10cSrcweir else 2146*cdf0e10cSrcweir { 2147*cdf0e10cSrcweir ::com::sun::star::uno::Any aAny = pBind->GetStatus().State; 2148*cdf0e10cSrcweir ::com::sun::star::uno::Type pType = aAny.getValueType(); 2149*cdf0e10cSrcweir 2150*cdf0e10cSrcweir if ( pType == ::getBooleanCppuType() ) 2151*cdf0e10cSrcweir { 2152*cdf0e10cSrcweir sal_Bool bTemp = false; 2153*cdf0e10cSrcweir aAny >>= bTemp ; 2154*cdf0e10cSrcweir pItem = new SfxBoolItem( nSlot, bTemp ); 2155*cdf0e10cSrcweir } 2156*cdf0e10cSrcweir else if ( pType == ::getCppuType((const sal_uInt16*)0) ) 2157*cdf0e10cSrcweir { 2158*cdf0e10cSrcweir sal_uInt16 nTemp = 0; 2159*cdf0e10cSrcweir aAny >>= nTemp ; 2160*cdf0e10cSrcweir pItem = new SfxUInt16Item( nSlot, nTemp ); 2161*cdf0e10cSrcweir } 2162*cdf0e10cSrcweir else if ( pType == ::getCppuType((const sal_uInt32*)0) ) 2163*cdf0e10cSrcweir { 2164*cdf0e10cSrcweir sal_uInt32 nTemp = 0; 2165*cdf0e10cSrcweir aAny >>= nTemp ; 2166*cdf0e10cSrcweir pItem = new SfxUInt32Item( nSlot, nTemp ); 2167*cdf0e10cSrcweir } 2168*cdf0e10cSrcweir else if ( pType == ::getCppuType((const ::rtl::OUString*)0) ) 2169*cdf0e10cSrcweir { 2170*cdf0e10cSrcweir ::rtl::OUString sTemp ; 2171*cdf0e10cSrcweir aAny >>= sTemp ; 2172*cdf0e10cSrcweir pItem = new SfxStringItem( nSlot, sTemp ); 2173*cdf0e10cSrcweir } 2174*cdf0e10cSrcweir else 2175*cdf0e10cSrcweir pItem = new SfxVoidItem( nSlot ); 2176*cdf0e10cSrcweir } 2177*cdf0e10cSrcweir 2178*cdf0e10cSrcweir xDisp->removeStatusListener( pBind, aURL ); 2179*cdf0e10cSrcweir pBind->Release(); 2180*cdf0e10cSrcweir rpState = pItem; 2181*cdf0e10cSrcweir if ( bDeleteCache ) 2182*cdf0e10cSrcweir DELETEZ( pCache ); 2183*cdf0e10cSrcweir return eState; 2184*cdf0e10cSrcweir } 2185*cdf0e10cSrcweir } 2186*cdf0e10cSrcweir } 2187*cdf0e10cSrcweir 2188*cdf0e10cSrcweir // Dann am Dispatcher testen; da die von dort zur"uckgegebenen Items immer 2189*cdf0e10cSrcweir // DELETE_ON_IDLE sind, mu\s eine Kopie davon gezogen werden, um einen 2190*cdf0e10cSrcweir // Eigent"umer"ubergang zu erm"oglichen 2191*cdf0e10cSrcweir const SfxPoolItem *pItem = NULL; 2192*cdf0e10cSrcweir SfxItemState eState = pDispatcher->QueryState( nSlot, pItem ); 2193*cdf0e10cSrcweir if ( eState == SFX_ITEM_SET ) 2194*cdf0e10cSrcweir { 2195*cdf0e10cSrcweir DBG_ASSERT( pItem, "SFX_ITEM_SET aber kein Item!" ); 2196*cdf0e10cSrcweir if ( pItem ) 2197*cdf0e10cSrcweir rpState = pItem->Clone(); 2198*cdf0e10cSrcweir } 2199*cdf0e10cSrcweir else if ( eState == SFX_ITEM_AVAILABLE && pItem ) 2200*cdf0e10cSrcweir { 2201*cdf0e10cSrcweir rpState = pItem->Clone(); 2202*cdf0e10cSrcweir } 2203*cdf0e10cSrcweir 2204*cdf0e10cSrcweir return eState; 2205*cdf0e10cSrcweir } 2206*cdf0e10cSrcweir 2207*cdf0e10cSrcweir void SfxBindings::SetSubBindings_Impl( SfxBindings *pSub ) 2208*cdf0e10cSrcweir { 2209*cdf0e10cSrcweir if ( pImp->pSubBindings ) 2210*cdf0e10cSrcweir { 2211*cdf0e10cSrcweir pImp->pSubBindings->SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > () ); 2212*cdf0e10cSrcweir pImp->pSubBindings->pImp->pSuperBindings = NULL; 2213*cdf0e10cSrcweir } 2214*cdf0e10cSrcweir 2215*cdf0e10cSrcweir pImp->pSubBindings = pSub; 2216*cdf0e10cSrcweir 2217*cdf0e10cSrcweir if ( pSub ) 2218*cdf0e10cSrcweir { 2219*cdf0e10cSrcweir pImp->pSubBindings->SetDispatchProvider_Impl( pImp->xProv ); 2220*cdf0e10cSrcweir pSub->pImp->pSuperBindings = this; 2221*cdf0e10cSrcweir } 2222*cdf0e10cSrcweir } 2223*cdf0e10cSrcweir 2224*cdf0e10cSrcweir SfxBindings* SfxBindings::GetSubBindings_Impl( sal_Bool bTop ) const 2225*cdf0e10cSrcweir { 2226*cdf0e10cSrcweir SfxBindings *pRet = pImp->pSubBindings; 2227*cdf0e10cSrcweir if ( bTop ) 2228*cdf0e10cSrcweir { 2229*cdf0e10cSrcweir while ( pRet->pImp->pSubBindings ) 2230*cdf0e10cSrcweir pRet = pRet->pImp->pSubBindings; 2231*cdf0e10cSrcweir } 2232*cdf0e10cSrcweir 2233*cdf0e10cSrcweir return pRet; 2234*cdf0e10cSrcweir } 2235*cdf0e10cSrcweir 2236*cdf0e10cSrcweir void SfxBindings::SetWorkWindow_Impl( SfxWorkWindow* pWork ) 2237*cdf0e10cSrcweir { 2238*cdf0e10cSrcweir pImp->pWorkWin = pWork; 2239*cdf0e10cSrcweir } 2240*cdf0e10cSrcweir 2241*cdf0e10cSrcweir SfxWorkWindow* SfxBindings::GetWorkWindow_Impl() const 2242*cdf0e10cSrcweir { 2243*cdf0e10cSrcweir return pImp->pWorkWin; 2244*cdf0e10cSrcweir } 2245*cdf0e10cSrcweir 2246*cdf0e10cSrcweir void SfxBindings::RegisterUnoController_Impl( SfxUnoControllerItem* pControl ) 2247*cdf0e10cSrcweir { 2248*cdf0e10cSrcweir if ( !pImp->pUnoCtrlArr ) 2249*cdf0e10cSrcweir pImp->pUnoCtrlArr = new SfxUnoControllerArr_Impl; 2250*cdf0e10cSrcweir pImp->pUnoCtrlArr->Insert( pControl, pImp->pUnoCtrlArr->Count() ); 2251*cdf0e10cSrcweir } 2252*cdf0e10cSrcweir 2253*cdf0e10cSrcweir void SfxBindings::ReleaseUnoController_Impl( SfxUnoControllerItem* pControl ) 2254*cdf0e10cSrcweir { 2255*cdf0e10cSrcweir if ( pImp->pUnoCtrlArr ) 2256*cdf0e10cSrcweir { 2257*cdf0e10cSrcweir sal_uInt16 nPos = pImp->pUnoCtrlArr->GetPos( pControl ); 2258*cdf0e10cSrcweir if ( nPos != 0xFFFF ) 2259*cdf0e10cSrcweir { 2260*cdf0e10cSrcweir pImp->pUnoCtrlArr->Remove( nPos ); 2261*cdf0e10cSrcweir return; 2262*cdf0e10cSrcweir } 2263*cdf0e10cSrcweir } 2264*cdf0e10cSrcweir 2265*cdf0e10cSrcweir if ( pImp->pSubBindings ) 2266*cdf0e10cSrcweir pImp->pSubBindings->ReleaseUnoController_Impl( pControl ); 2267*cdf0e10cSrcweir } 2268*cdf0e10cSrcweir 2269*cdf0e10cSrcweir void SfxBindings::InvalidateUnoControllers_Impl() 2270*cdf0e10cSrcweir { 2271*cdf0e10cSrcweir if ( pImp->pUnoCtrlArr ) 2272*cdf0e10cSrcweir { 2273*cdf0e10cSrcweir sal_uInt16 nCount = pImp->pUnoCtrlArr->Count(); 2274*cdf0e10cSrcweir for ( sal_uInt16 n=nCount; n>0; n-- ) 2275*cdf0e10cSrcweir { 2276*cdf0e10cSrcweir SfxUnoControllerItem *pCtrl = (*pImp->pUnoCtrlArr)[n-1]; 2277*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xRef( (::cppu::OWeakObject*)pCtrl, ::com::sun::star::uno::UNO_QUERY ); 2278*cdf0e10cSrcweir pCtrl->ReleaseDispatch(); 2279*cdf0e10cSrcweir pCtrl->GetNewDispatch(); 2280*cdf0e10cSrcweir } 2281*cdf0e10cSrcweir } 2282*cdf0e10cSrcweir 2283*cdf0e10cSrcweir if ( pImp->pSubBindings ) 2284*cdf0e10cSrcweir pImp->pSubBindings->InvalidateUnoControllers_Impl(); 2285*cdf0e10cSrcweir } 2286*cdf0e10cSrcweir 2287*cdf0e10cSrcweir sal_Bool SfxBindings::IsInUpdate() const 2288*cdf0e10cSrcweir { 2289*cdf0e10cSrcweir sal_Bool bInUpdate = pImp->bInUpdate; 2290*cdf0e10cSrcweir if ( !bInUpdate && pImp->pSubBindings ) 2291*cdf0e10cSrcweir bInUpdate = pImp->pSubBindings->IsInUpdate(); 2292*cdf0e10cSrcweir return bInUpdate; 2293*cdf0e10cSrcweir } 2294*cdf0e10cSrcweir 2295*cdf0e10cSrcweir void SfxBindings::SetVisibleState( sal_uInt16 nId, sal_Bool bShow ) 2296*cdf0e10cSrcweir { 2297*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp; 2298*cdf0e10cSrcweir SfxStateCache *pCache = GetStateCache( nId ); 2299*cdf0e10cSrcweir if ( pCache ) 2300*cdf0e10cSrcweir pCache->SetVisibleState( bShow ); 2301*cdf0e10cSrcweir } 2302*cdf0e10cSrcweir 2303*cdf0e10cSrcweir void SfxBindings::SetActiveFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame ) 2304*cdf0e10cSrcweir { 2305*cdf0e10cSrcweir if ( rFrame.is() || !pDispatcher ) 2306*cdf0e10cSrcweir SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > ( rFrame, ::com::sun::star::uno::UNO_QUERY ) ); 2307*cdf0e10cSrcweir else 2308*cdf0e10cSrcweir SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > ( 2309*cdf0e10cSrcweir pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ) ); 2310*cdf0e10cSrcweir } 2311*cdf0e10cSrcweir 2312*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxBindings::GetActiveFrame() const 2313*cdf0e10cSrcweir { 2314*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( pImp->xProv, ::com::sun::star::uno::UNO_QUERY ); 2315*cdf0e10cSrcweir if ( xFrame.is() || !pDispatcher ) 2316*cdf0e10cSrcweir return xFrame; 2317*cdf0e10cSrcweir else 2318*cdf0e10cSrcweir return pDispatcher->GetFrame()->GetFrame().GetFrameInterface(); 2319*cdf0e10cSrcweir } 2320*cdf0e10cSrcweir 2321*cdf0e10cSrcweir void SfxBindings::SetDispatchProvider_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & rProv ) 2322*cdf0e10cSrcweir { 2323*cdf0e10cSrcweir sal_Bool bInvalidate = ( rProv != pImp->xProv ); 2324*cdf0e10cSrcweir if ( bInvalidate ) 2325*cdf0e10cSrcweir { 2326*cdf0e10cSrcweir pImp->xProv = rProv; 2327*cdf0e10cSrcweir InvalidateAll( sal_True ); 2328*cdf0e10cSrcweir InvalidateUnoControllers_Impl(); 2329*cdf0e10cSrcweir } 2330*cdf0e10cSrcweir 2331*cdf0e10cSrcweir if ( pImp->pSubBindings ) 2332*cdf0e10cSrcweir pImp->pSubBindings->SetDispatchProvider_Impl( pImp->xProv ); 2333*cdf0e10cSrcweir } 2334*cdf0e10cSrcweir 2335*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & SfxBindings::GetDispatchProvider_Impl() const 2336*cdf0e10cSrcweir { 2337*cdf0e10cSrcweir return pImp->xProv; 2338*cdf0e10cSrcweir } 2339*cdf0e10cSrcweir 2340*cdf0e10cSrcweir SystemWindow* SfxBindings::GetSystemWindow() const 2341*cdf0e10cSrcweir { 2342*cdf0e10cSrcweir SfxViewFrame *pFrame = pDispatcher->GetFrame(); 2343*cdf0e10cSrcweir while ( pFrame->GetParentViewFrame_Impl() ) 2344*cdf0e10cSrcweir pFrame = pFrame->GetParentViewFrame_Impl(); 2345*cdf0e10cSrcweir SfxViewFrame* pTop = pFrame->GetTopViewFrame(); 2346*cdf0e10cSrcweir return pTop->GetFrame().GetTopWindow_Impl(); 2347*cdf0e10cSrcweir } 2348*cdf0e10cSrcweir 2349*cdf0e10cSrcweir sal_Bool SfxBindings::ExecuteCommand_Impl( const String& rCommand ) 2350*cdf0e10cSrcweir { 2351*cdf0e10cSrcweir ::com::sun::star::util::URL aURL; 2352*cdf0e10cSrcweir aURL.Complete = rCommand; 2353*cdf0e10cSrcweir Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); 2354*cdf0e10cSrcweir xTrans->parseStrict( aURL ); 2355*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp = pImp->xProv->queryDispatch( aURL, ::rtl::OUString(), 0 ); 2356*cdf0e10cSrcweir if ( xDisp.is() ) 2357*cdf0e10cSrcweir { 2358*cdf0e10cSrcweir if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# 2359*cdf0e10cSrcweir { 2360*cdf0e10cSrcweir ::rtl::OUString sAppName; 2361*cdf0e10cSrcweir try 2362*cdf0e10cSrcweir { 2363*cdf0e10cSrcweir static ::rtl::OUString our_aModuleManagerName = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); 2364*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = 2365*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory(); 2366*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > xModuleManager( 2367*cdf0e10cSrcweir xServiceManager->createInstance(our_aModuleManagerName) 2368*cdf0e10cSrcweir , ::com::sun::star::uno::UNO_QUERY_THROW); 2369*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame( 2370*cdf0e10cSrcweir pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY_THROW); 2371*cdf0e10cSrcweir sAppName = xModuleManager->identify(xFrame); 2372*cdf0e10cSrcweir } catch(::com::sun::star::uno::Exception&) {} 2373*cdf0e10cSrcweir Sequence<beans::PropertyValue> source; 2374*cdf0e10cSrcweir ::comphelper::UiEventsLogger::appendDispatchOrigin(source, sAppName, ::rtl::OUString::createFromAscii("SfxAsyncExec")); 2375*cdf0e10cSrcweir ::comphelper::UiEventsLogger::logDispatch(aURL, source); 2376*cdf0e10cSrcweir } 2377*cdf0e10cSrcweir new SfxAsyncExec_Impl( aURL, xDisp ); 2378*cdf0e10cSrcweir return sal_True; 2379*cdf0e10cSrcweir } 2380*cdf0e10cSrcweir 2381*cdf0e10cSrcweir return sal_False; 2382*cdf0e10cSrcweir } 2383*cdf0e10cSrcweir 2384*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > SfxBindings::GetRecorder() const 2385*cdf0e10cSrcweir { 2386*cdf0e10cSrcweir return pImp->xRecorder; 2387*cdf0e10cSrcweir } 2388*cdf0e10cSrcweir 2389*cdf0e10cSrcweir void SfxBindings::SetRecorder_Impl( com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >& rRecorder ) 2390*cdf0e10cSrcweir { 2391*cdf0e10cSrcweir pImp->xRecorder = rRecorder; 2392*cdf0e10cSrcweir } 2393*cdf0e10cSrcweir 2394*cdf0e10cSrcweir void SfxBindings::ContextChanged_Impl() 2395*cdf0e10cSrcweir { 2396*cdf0e10cSrcweir if ( !pImp->bInUpdate && ( !pImp->bContextChanged || !pImp->bAllMsgDirty ) ) 2397*cdf0e10cSrcweir { 2398*cdf0e10cSrcweir InvalidateAll( sal_True ); 2399*cdf0e10cSrcweir } 2400*cdf0e10cSrcweir } 2401*cdf0e10cSrcweir 2402*cdf0e10cSrcweir uno::Reference < frame::XDispatch > SfxBindings::GetDispatch( const SfxSlot* pSlot, const util::URL& aURL, sal_Bool bMasterCommand ) 2403*cdf0e10cSrcweir { 2404*cdf0e10cSrcweir uno::Reference < frame::XDispatch > xRet; 2405*cdf0e10cSrcweir SfxStateCache* pCache = GetStateCache( pSlot->nSlotId ); 2406*cdf0e10cSrcweir if ( pCache && !bMasterCommand ) 2407*cdf0e10cSrcweir xRet = pCache->GetInternalDispatch(); 2408*cdf0e10cSrcweir if ( !xRet.is() ) 2409*cdf0e10cSrcweir { 2410*cdf0e10cSrcweir // dispatches for slaves are unbound, they don't have a state 2411*cdf0e10cSrcweir SfxOfficeDispatch* pDispatch = bMasterCommand ? 2412*cdf0e10cSrcweir new SfxOfficeDispatch( pDispatcher, pSlot, aURL ) : 2413*cdf0e10cSrcweir new SfxOfficeDispatch( *this, pDispatcher, pSlot, aURL ); 2414*cdf0e10cSrcweir 2415*cdf0e10cSrcweir pDispatch->SetMasterUnoCommand( bMasterCommand ); 2416*cdf0e10cSrcweir xRet = uno::Reference < frame::XDispatch >( pDispatch ); 2417*cdf0e10cSrcweir if ( !pCache ) 2418*cdf0e10cSrcweir pCache = GetStateCache( pSlot->nSlotId ); 2419*cdf0e10cSrcweir 2420*cdf0e10cSrcweir DBG_ASSERT( pCache, "No cache for OfficeDispatch!" ); 2421*cdf0e10cSrcweir if ( pCache && !bMasterCommand ) 2422*cdf0e10cSrcweir pCache->SetInternalDispatch( xRet ); 2423*cdf0e10cSrcweir } 2424*cdf0e10cSrcweir 2425*cdf0e10cSrcweir return xRet; 2426*cdf0e10cSrcweir } 2427