1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/embed/VerbDescriptor.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/embed/VerbAttributes.hpp> 32*cdf0e10cSrcweir #include <basic/sbstar.hxx> 33*cdf0e10cSrcweir #include <svl/itempool.hxx> 34*cdf0e10cSrcweir #include <svl/undo.hxx> 35*cdf0e10cSrcweir #include <svtools/itemdel.hxx> 36*cdf0e10cSrcweir #include <svtools/asynclink.hxx> 37*cdf0e10cSrcweir #include <basic/sbx.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <unotools/undoopt.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #ifndef GCC 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <sfx2/app.hxx> 45*cdf0e10cSrcweir #include <sfx2/shell.hxx> 46*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 47*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 48*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 49*cdf0e10cSrcweir #include <sfx2/objface.hxx> 50*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 51*cdf0e10cSrcweir #include <sfx2/viewsh.hxx> 52*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 53*cdf0e10cSrcweir #include "sfxtypes.hxx" 54*cdf0e10cSrcweir #include <sfx2/request.hxx> 55*cdf0e10cSrcweir #include <sfx2/mnumgr.hxx> 56*cdf0e10cSrcweir #include "statcach.hxx" 57*cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir //==================================================================== 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir DBG_NAME(SfxShell) 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir //==================================================================== 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir TYPEINIT0(SfxShell); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir //==================================================================== 68*cdf0e10cSrcweir typedef SfxSlot* SfxSlotPtr; 69*cdf0e10cSrcweir SV_DECL_PTRARR_DEL( SfxVerbSlotArr_Impl, SfxSlotPtr, 4, 4) 70*cdf0e10cSrcweir SV_IMPL_PTRARR( SfxVerbSlotArr_Impl, SfxSlotPtr); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir using namespace com::sun::star; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir //========================================================================= 75*cdf0e10cSrcweir // SfxShell_Impl 76*cdf0e10cSrcweir //========================================================================= 77*cdf0e10cSrcweir struct SfxShell_Impl: public SfxBroadcaster 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir String aObjectName;// Name des Sbx-Objects 80*cdf0e10cSrcweir SfxItemArray_Impl aItems; // Datenaustausch auf Item-Basis 81*cdf0e10cSrcweir SfxViewShell* pViewSh; // SfxViewShell falls Shell ViewFrame/ViewShell/SubShell ist 82*cdf0e10cSrcweir SfxViewFrame* pFrame; // Frame, falls <UI-aktiv> 83*cdf0e10cSrcweir SfxRepeatTarget* pRepeatTarget; 84*cdf0e10cSrcweir // SbxObjectRef xParent; 85*cdf0e10cSrcweir sal_Bool bInAppBASIC; 86*cdf0e10cSrcweir sal_Bool bActive; 87*cdf0e10cSrcweir sal_uIntPtr nDisableFlags; 88*cdf0e10cSrcweir sal_uIntPtr nHelpId; 89*cdf0e10cSrcweir svtools::AsynchronLink* pExecuter; 90*cdf0e10cSrcweir svtools::AsynchronLink* pUpdater; 91*cdf0e10cSrcweir SfxVerbSlotArr_Impl aSlotArr; 92*cdf0e10cSrcweir com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > aVerbList; 93*cdf0e10cSrcweir SfxShell_Impl() : pExecuter( 0 ), pUpdater( 0 ) {} 94*cdf0e10cSrcweir ~SfxShell_Impl() { delete pExecuter; delete pUpdater;} 95*cdf0e10cSrcweir }; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir //==================================================================== 98*cdf0e10cSrcweir #ifdef DBG_UTIL 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir String SfxShellIdent_Impl( const SfxShell *pSh ) 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /* [Beschreibung] 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir Interne Hilfesfunktion. Liefert einen die SfxShell 'pSh' beschreibenden 105*cdf0e10cSrcweir String zur"uck. Z.B.: SfxApplication[StarWriter] 106*cdf0e10cSrcweir */ 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir String aIdent( pSh->ISA(SfxApplication) ? DEFINE_CONST_UNICODE("SfxApplication") : 110*cdf0e10cSrcweir pSh->ISA(SfxViewFrame) ? DEFINE_CONST_UNICODE("SfxViewFrame") : 111*cdf0e10cSrcweir pSh->ISA(SfxViewShell) ? DEFINE_CONST_UNICODE("SfxViewShell") : 112*cdf0e10cSrcweir pSh->ISA(SfxObjectShell) ? DEFINE_CONST_UNICODE("SfxObjectShell") : DEFINE_CONST_UNICODE("SfxShell") ); 113*cdf0e10cSrcweir aIdent += '['; 114*cdf0e10cSrcweir aIdent += pSh->GetName(); 115*cdf0e10cSrcweir aIdent += ']'; 116*cdf0e10cSrcweir return aIdent; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir #endif 120*cdf0e10cSrcweir //==================================================================== 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir //========================================================================= 123*cdf0e10cSrcweir // SfxShell 124*cdf0e10cSrcweir //========================================================================= 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir void __EXPORT SfxShell::EmptyExecStub(SfxShell *, SfxRequest &) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir void __EXPORT SfxShell::EmptyStateStub(SfxShell *, SfxItemSet &) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir SfxShell::SfxShell() 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir /* [Beschreibung] 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir Der Konstruktor der Klasse SfxShell initialisierung nur einfache 139*cdf0e10cSrcweir Typen, das dazugeh"orige SbxObject wird erst on-demand erzeugt. 140*cdf0e10cSrcweir Daher ist das Anlegen einer SfxShell Instanz sehr billig. 141*cdf0e10cSrcweir */ 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir : pImp(0), 144*cdf0e10cSrcweir pPool(0), 145*cdf0e10cSrcweir pUndoMgr(0) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir DBG_CTOR(SfxShell, 0); 148*cdf0e10cSrcweir pImp = new SfxShell_Impl; 149*cdf0e10cSrcweir pImp->pViewSh = 0; 150*cdf0e10cSrcweir pImp->pFrame = 0; 151*cdf0e10cSrcweir pImp->pRepeatTarget = 0; 152*cdf0e10cSrcweir pImp->bInAppBASIC = sal_False; 153*cdf0e10cSrcweir pImp->nHelpId = 0L; 154*cdf0e10cSrcweir pImp->bActive = sal_False; 155*cdf0e10cSrcweir pImp->nDisableFlags = 0; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir //------------------------------------------------------------------------- 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir SfxShell::SfxShell( SfxViewShell *pViewSh ) 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir /* [Beschreibung] 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir Der Konstruktor der Klasse SfxShell initialisierung nur einfache 165*cdf0e10cSrcweir Typen, das dazugeh"orige SbxObject wird erst on-demand erzeugt. 166*cdf0e10cSrcweir Daher ist das Anlegen einer SfxShell Instanz sehr billig. 167*cdf0e10cSrcweir */ 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir : pImp(0), 170*cdf0e10cSrcweir pPool(0), 171*cdf0e10cSrcweir pUndoMgr(0) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir DBG_CTOR(SfxShell, 0); 174*cdf0e10cSrcweir pImp = new SfxShell_Impl; 175*cdf0e10cSrcweir pImp->pViewSh = pViewSh; 176*cdf0e10cSrcweir pImp->pFrame = 0; 177*cdf0e10cSrcweir pImp->pRepeatTarget = 0; 178*cdf0e10cSrcweir pImp->bInAppBASIC = sal_False; 179*cdf0e10cSrcweir pImp->nHelpId = 0L; 180*cdf0e10cSrcweir pImp->bActive = sal_False; 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir //-------------------------------------------------------------------- 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir SfxShell::~SfxShell() 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir /* [Beschreibung] 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir Die Verbindungs zu einem ggf. zugeh"origen SbxObject wird gel"ost. 190*cdf0e10cSrcweir Das SbxObject existiert ggf. weiter, kann aber keine Funktionen 191*cdf0e10cSrcweir mehr ausf"uhren und keine Properties mehr bereitstellen. 192*cdf0e10cSrcweir */ 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir DBG_DTOR(SfxShell, 0); 196*cdf0e10cSrcweir delete pImp; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir //-------------------------------------------------------------------- 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir void SfxShell::SetName( const String &rName ) 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir /* [Beschreibung] 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir Setzt den Namen des Shell-Objekts. Mit diesem Namen kann die 206*cdf0e10cSrcweir SfxShell-Instanz vom BASIC aus angesprochen werden. 207*cdf0e10cSrcweir */ 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir pImp->aObjectName = rName; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //-------------------------------------------------------------------- 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir const String& SfxShell::GetName() const 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir /* [Beschreibung] 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir Liefert den Namen des Shell-Objekts. Mit diesem Namen kann die 220*cdf0e10cSrcweir SfxShell-Instanz vom BASIC aus angesprochen werden. 221*cdf0e10cSrcweir */ 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir return pImp->aObjectName; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir //-------------------------------------------------------------------- 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir SvGlobalName SfxShell::GetGlobalName() const 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir /* [Beschreibung] 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir Liefert den Global Unique Identifier des Shell-Objekts. Mit diesem 234*cdf0e10cSrcweir Namen kann die SfxShell-Instanz z.B. via OLE Automation angesprochen 235*cdf0e10cSrcweir werden, bzw. in der Registration-Database gefunden werden. 236*cdf0e10cSrcweir */ 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir return SvGlobalName(); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir //-------------------------------------------------------------------- 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir SfxDispatcher* SfxShell::GetDispatcher() const 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir /* [Beschreibung] 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir Diese Methode liefert einen Pointer auf den <SfxDispatcher>, in 249*cdf0e10cSrcweir dem die SfxShell gerade <UI-aktiv> ist bzw. einen 0-Pointer, wenn 250*cdf0e10cSrcweir sie gerade nicht UI-aktiv ist. 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir Der zur"uckgegebene Pointer ist nur im unmittelbaren Kontext des 253*cdf0e10cSrcweir Methodenaufrufs g"ultig. 254*cdf0e10cSrcweir */ 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir return pImp->pFrame ? pImp->pFrame->GetDispatcher() : 0; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir //-------------------------------------------------------------------- 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir SfxViewShell* SfxShell::GetViewShell() const 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir /* [Beschreibung] 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir Liefert bei SubShells die SfxViewShell, in der sie liegen. Sonst und 267*cdf0e10cSrcweir falls nicht vom App-Entwickler angegeben liefert diese Methode 0. 268*cdf0e10cSrcweir */ 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir return pImp->pViewSh; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir //-------------------------------------------------------------------- 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir SfxViewFrame* SfxShell::GetFrame() const 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir /* [Beschreibung] 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir Diese Methode liefert einen Pointer auf den <SfxViewFrame>, dem diese 281*cdf0e10cSrcweir SfxShell-Instanz zugeordnet ist oder in dem sie zur Zeit <UI-aktiv> ist. 282*cdf0e10cSrcweir Ein 0-Pointer wird geliefert, wenn diese SfxShell-OInstanz gerade nicht 283*cdf0e10cSrcweir UI-aktiv ist und auch keinem SfxViewFrame fest zugeordnet ist. 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir Der zur"uckgegebene Pointer ist nur im unmittelbaren Kontext des 286*cdf0e10cSrcweir Methodenaufrufs g"ultig. 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir [Anmerkung] 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir Nur Instanzen von Subklasse von SfxApplication und SfxObjectShell sollten 292*cdf0e10cSrcweir hier einen 0-Pointer liefern. Ansonsten liegt ein Fehler im Anwendungs- 293*cdf0e10cSrcweir programm vor (falscher Ctor von SfxShell gerufen). 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir [Querverweise] 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir <SfxViewShell::GetViewFrame()const> 299*cdf0e10cSrcweir */ 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir if ( pImp->pFrame ) 303*cdf0e10cSrcweir return pImp->pFrame; 304*cdf0e10cSrcweir if ( pImp->pViewSh ) 305*cdf0e10cSrcweir return pImp->pViewSh->GetViewFrame(); 306*cdf0e10cSrcweir return 0; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir //-------------------------------------------------------------------- 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir const SfxPoolItem* SfxShell::GetItem 312*cdf0e10cSrcweir ( 313*cdf0e10cSrcweir sal_uInt16 nSlotId // Slot-Id des zu erfragenden <SfxPoolItem>s 314*cdf0e10cSrcweir ) const 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir /* [Beschreibung] 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir Mit dieser Methode kann auf beliebige Objekte von Subklassen von 319*cdf0e10cSrcweir <SfxPoolItem> zugegriffen werden. Diese Austauschtechnik wird ben"otigt, 320*cdf0e10cSrcweir wenn z.B. spezielle <SfxToolBoxControl> Subklassen Zugriff auf 321*cdf0e10cSrcweir bestimmte Daten z.B. der <SfxObjectShell> ben"otigen. 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir Die zur"uckgelieferte Instanz geh"ort der jeweilige SfxShell und 324*cdf0e10cSrcweir darf nur im unmittelbaren Kontext des Methodenaufrufs verwendet werden. 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir [Querverweise] 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir <SfxShell::PutItem(const SfxPoolItem&)> 330*cdf0e10cSrcweir <SfxShell::RemoveItem(sal_uInt16)> 331*cdf0e10cSrcweir */ 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pImp->aItems.Count(); ++nPos ) 335*cdf0e10cSrcweir if ( pImp->aItems.GetObject(nPos)->Which() == nSlotId ) 336*cdf0e10cSrcweir return pImp->aItems.GetObject(nPos); 337*cdf0e10cSrcweir return 0; 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir //-------------------------------------------------------------------- 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir void SfxShell::RemoveItem 343*cdf0e10cSrcweir ( 344*cdf0e10cSrcweir sal_uInt16 nSlotId // Slot-Id des zu l"oschenden <SfxPoolItem>s 345*cdf0e10cSrcweir ) 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir /* [Beschreibung] 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir Mit dieser Methode k"onnen die allgemein zur Verf"ugung gestellten 350*cdf0e10cSrcweir Instanzen von Subklassen von <SfxPoolItem> aus der SfxShell entfernt 351*cdf0e10cSrcweir werden. 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir Die gespeicherte Instanz wird gel"oscht. 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir [Querverweise] 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir <SfxShell::PutItem(const SfxPoolItem&)> 359*cdf0e10cSrcweir <SfxShell::GetItem(sal_uInt16)> 360*cdf0e10cSrcweir */ 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pImp->aItems.Count(); ++nPos ) 364*cdf0e10cSrcweir if ( pImp->aItems.GetObject(nPos)->Which() == nSlotId ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir // Item entfernen und l"oschen 367*cdf0e10cSrcweir SfxPoolItem *pItem = pImp->aItems.GetObject(nPos); 368*cdf0e10cSrcweir delete pItem; 369*cdf0e10cSrcweir pImp->aItems.Remove(nPos); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir // falls aktiv Bindings benachrichtigen 372*cdf0e10cSrcweir SfxDispatcher *pDispat = GetDispatcher(); 373*cdf0e10cSrcweir if ( pDispat ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir SfxVoidItem aVoid( nSlotId ); 376*cdf0e10cSrcweir pDispat->GetBindings()->Broadcast( SfxPoolItemHint( &aVoid ) ); 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir //-------------------------------------------------------------------- 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void SfxShell::PutItem 384*cdf0e10cSrcweir ( 385*cdf0e10cSrcweir const SfxPoolItem& rItem /* Instanz, von der eine Kopie erstellt wird, 386*cdf0e10cSrcweir die in der SfxShell in einer Liste 387*cdf0e10cSrcweir gespeichert wird. */ 388*cdf0e10cSrcweir ) 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir /* [Beschreibung] 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir Mit dieser Methode k"onnen beliebige Objekte von Subklassen von 393*cdf0e10cSrcweir <SfxPoolItem> zur Verf"ugung gestellt werden. Diese Austauschtechnik 394*cdf0e10cSrcweir wird ben"otigt, wenn z.B. spezielle <SfxToolBoxControl> Subklassen 395*cdf0e10cSrcweir Zugriff auf bestimmte Daten z.B. der <SfxObjectShell> ben"otigen. 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir Falls ein SfxPoolItem mit derselben Slot-Id exisitert, wird dieses 398*cdf0e10cSrcweir automatisch gel"oscht. 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir [Querverweise] 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir <SfxShell::RemoveItem(sal_uInt16)> 404*cdf0e10cSrcweir <SfxShell::GetItem(sal_uInt16)> 405*cdf0e10cSrcweir */ 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir DBG_ASSERT( !rItem.ISA(SfxSetItem), "SetItems aren't allowed here" ); 409*cdf0e10cSrcweir DBG_ASSERT( SfxItemPool::IsSlot( rItem.Which() ), 410*cdf0e10cSrcweir "items with Which-Ids aren't allowed here" ); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir // MSC auf WNT/W95 machte hier Mist, Vorsicht bei Umstellungen 413*cdf0e10cSrcweir const SfxPoolItem *pItem = rItem.Clone(); 414*cdf0e10cSrcweir SfxPoolItemHint aItemHint( (SfxPoolItem*) pItem ); 415*cdf0e10cSrcweir const sal_uInt16 nWhich = rItem.Which(); 416*cdf0e10cSrcweir SfxPoolItem **ppLoopItem = (SfxPoolItem**) pImp->aItems.GetData(); 417*cdf0e10cSrcweir sal_uInt16 nPos; 418*cdf0e10cSrcweir for ( nPos = 0; nPos < pImp->aItems.Count(); ++nPos, ++ppLoopItem ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir if ( (*ppLoopItem)->Which() == nWhich ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir // Item austauschen 423*cdf0e10cSrcweir delete *ppLoopItem; 424*cdf0e10cSrcweir pImp->aItems.Remove(nPos); 425*cdf0e10cSrcweir pImp->aItems.Insert( (SfxPoolItemPtr) pItem, nPos ); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // falls aktiv Bindings benachrichtigen 428*cdf0e10cSrcweir SfxDispatcher *pDispat = GetDispatcher(); 429*cdf0e10cSrcweir if ( pDispat ) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir SfxBindings* pBindings = pDispat->GetBindings(); 432*cdf0e10cSrcweir pBindings->Broadcast( aItemHint ); 433*cdf0e10cSrcweir sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId(); 434*cdf0e10cSrcweir SfxStateCache* pCache = pBindings->GetStateCache( nSlotId ); 435*cdf0e10cSrcweir if ( pCache ) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir pCache->SetState( SFX_ITEM_AVAILABLE, pItem->Clone(), sal_True ); 438*cdf0e10cSrcweir pCache->SetCachedState( sal_True ); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir return; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir Broadcast( aItemHint ); 446*cdf0e10cSrcweir pImp->aItems.Insert((SfxPoolItemPtr)pItem, nPos ); 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir //-------------------------------------------------------------------- 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir SfxInterface* SfxShell::GetInterface() const 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir /* [Beschreibung] 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir Mit dieser virtuellen Methode, die durch das Makro <SFX_DECL_INTERFACE> 456*cdf0e10cSrcweir von jeder Subclass mit eigenen Slots automatisch "uberladen wird, kann 457*cdf0e10cSrcweir auf die zu der Subklasse geh"orende <SfxInterface>-Instanz zugegriffen 458*cdf0e10cSrcweir werden. 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir Die Klasse SfxShell selbst hat noch kein eigenes SfxInterface 461*cdf0e10cSrcweir (keine Slots), daher wird ein 0-Pointer zur"uckgeliefert. 462*cdf0e10cSrcweir */ 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir return GetStaticInterface(); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir //-------------------------------------------------------------------- 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir SfxBroadcaster* SfxShell::GetBroadcaster() 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir /* [Beschreibung] 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir Liefert einen SfxBroadcaster f"ur diese SfxShell-Instanz bis die 475*cdf0e10cSrcweir Klasse SfxShell von SfxBroadcaster abgeleitet ist. 476*cdf0e10cSrcweir */ 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir return pImp; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir //-------------------------------------------------------------------- 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir ::svl::IUndoManager* SfxShell::GetUndoManager() 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir /* [Beschreibung] 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir Jede Subclass von SfxShell kann "uber einen <SfxUndoManager> verf"ugen. 489*cdf0e10cSrcweir Dieser kann in den abgeleiteten Klasse mit <SfxShell:SetUndoManager()> 490*cdf0e10cSrcweir gesetzt werden. 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir Die Klasse SfxShell selbst hat noch keinen SfxUndoManager, es wird 493*cdf0e10cSrcweir daher ein 0-Pointer zur"uckgeliefert. 494*cdf0e10cSrcweir */ 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir return pUndoMgr; 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir //-------------------------------------------------------------------- 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir void SfxShell::SetUndoManager( ::svl::IUndoManager *pNewUndoMgr ) 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir /* [Beschreibung] 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir Setzt einen <SfxUndoManager> f"ur diese <SfxShell> Instanz. F"ur das 507*cdf0e10cSrcweir Undo wird immer nur der Undo-Manager an der jeweils oben auf dem 508*cdf0e10cSrcweir Stack des <SfxDispatcher> liegenden SfxShell verwendet. 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir Am "ubergebenen <SfxUndoManager> wird automatisch die aktuelle 511*cdf0e10cSrcweir Max-Undo-Action-Count Einstellung aus den Optionen gesetzt. 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir 'pNewUndoMgr' mu\s bis zum Dtor dieser SfxShell-Instanz oder bis 514*cdf0e10cSrcweir zum n"achsten 'SetUndoManager()' existieren. 515*cdf0e10cSrcweir */ 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir OSL_ENSURE( ( pUndoMgr == NULL ) || ( pNewUndoMgr == NULL ) || ( pUndoMgr == pNewUndoMgr ), 519*cdf0e10cSrcweir "SfxShell::SetUndoManager: exchanging one non-NULL manager with another non-NULL manager? Suspicious!" ); 520*cdf0e10cSrcweir // there's at least one client of our UndoManager - the DocumentUndoManager at the SfxBaseModel - which 521*cdf0e10cSrcweir // caches the UndoManager, and registers itself as listener. If exchanging non-NULL UndoManagers is really 522*cdf0e10cSrcweir // a supported scenario (/me thinks it is not), then we would need to notify all such clients instances. 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir pUndoMgr = pNewUndoMgr; 525*cdf0e10cSrcweir if ( pUndoMgr ) 526*cdf0e10cSrcweir pUndoMgr->SetMaxUndoActionCount( (sal_uInt16) SvtUndoOptions().GetUndoCount() ); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir //-------------------------------------------------------------------- 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir SfxRepeatTarget* SfxShell::GetRepeatTarget() const 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir /* [Beschreibung] 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir Liefert einen Pointer auf die <SfxRepeatTarget>-Instanz, die 536*cdf0e10cSrcweir als RepeatTarget bei SID_REPEAT verwendet wird, wenn der 537*cdf0e10cSrcweir von dieser SfxShell gelieferte <SfxUndoManager> angesprochen wird. 538*cdf0e10cSrcweir Der R"uckgabewert kann 0 sein. 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir [Anmerkung] 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir Eine Ableitung von <SfxShell> oder einer ihrer Subklassen von 544*cdf0e10cSrcweir <SfxRepeatTarget> ist nicht zu empfehlen, da Compiler-Fehler 545*cdf0e10cSrcweir provoziert werden (wegen Call-to-Pointer-to-Member-Function to 546*cdf0e10cSrcweir subclass). 547*cdf0e10cSrcweir */ 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir return pImp->pRepeatTarget; 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir //-------------------------------------------------------------------- 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir void SfxShell::SetRepeatTarget( SfxRepeatTarget *pTarget ) 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir /* [Beschreibung] 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir Setzt den die <SfxRepeatTarget>-Instanz, die bei SID_REPEAT als 560*cdf0e10cSrcweir RepeatTarget verwendet wird, wenn der von dieser SfxShell gelieferte 561*cdf0e10cSrcweir <SfxUndoManager> angesprochen wird. Durch 'pTarget==0' wird SID_REPEAT 562*cdf0e10cSrcweir f"ur diese SfxShell disabled. Die Instanz '*pTarget' mu\s so lange 563*cdf0e10cSrcweir leben, wie sie angemeldet ist. 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir [Anmerkung] 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir Eine Ableitung von <SfxShell> oder einer ihrer Subklassen von 569*cdf0e10cSrcweir <SfxRepeatTarget> ist nicht zu empfehlen, da Compiler-Fehler 570*cdf0e10cSrcweir provoziert werden (wegen Call-to-Pointer-to-Member-Function to 571*cdf0e10cSrcweir subclass). 572*cdf0e10cSrcweir */ 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir pImp->pRepeatTarget = pTarget; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir //-------------------------------------------------------------------- 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir void SfxShell::Invalidate 581*cdf0e10cSrcweir ( 582*cdf0e10cSrcweir sal_uInt16 nId /* Zu invalidierende Slot-Id oder Which-Id. 583*cdf0e10cSrcweir Falls diese 0 ist (default), werden 584*cdf0e10cSrcweir alle z.Zt. von dieser Shell bedienten 585*cdf0e10cSrcweir Slot-Ids invalidiert. */ 586*cdf0e10cSrcweir ) 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir /* [Beschreibung] 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir Mit dieser Methode k"onnen Slots der Subclasses "uber die Slot-Id 591*cdf0e10cSrcweir oder alternativ "uber die Which-Id invalidiert werden. Slot-Ids, 592*cdf0e10cSrcweir die von der Subclass ererbt sind, werden ebenfalls invalidert. 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir [Querverweise] 595*cdf0e10cSrcweir <SfxBindings::Invalidate(sal_uInt16)> 596*cdf0e10cSrcweir <SfxBindings::InvalidateAll(sal_Bool)> 597*cdf0e10cSrcweir */ 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir if ( !GetViewShell() ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir DBG_ERROR( "wrong Invalidate method called!" ); 603*cdf0e10cSrcweir return; 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir Invalidate_Impl( GetViewShell()->GetViewFrame()->GetBindings(), nId ); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir void SfxShell::Invalidate_Impl( SfxBindings& rBindings, sal_uInt16 nId ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir if ( nId == 0 ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir rBindings.InvalidateShell( *this, sal_False ); 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir else 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir const SfxInterface *pIF = GetInterface(); 618*cdf0e10cSrcweir do 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir const SfxSlot *pSlot = pIF->GetSlot(nId); 621*cdf0e10cSrcweir if ( pSlot ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir // bei Enum-Slots ist der Master-Slot zu invalidieren 624*cdf0e10cSrcweir if ( SFX_KIND_ENUM == pSlot->GetKind() ) 625*cdf0e10cSrcweir pSlot = pSlot->GetLinkedSlot(); 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir // den Slot selbst und ggf. auch alle Slave-Slots invalidieren 628*cdf0e10cSrcweir rBindings.Invalidate( pSlot->GetSlotId() ); 629*cdf0e10cSrcweir for ( const SfxSlot *pSlave = pSlot->GetLinkedSlot(); 630*cdf0e10cSrcweir pSlave && pIF->ContainsSlot_Impl( pSlave ) && 631*cdf0e10cSrcweir pSlave->GetLinkedSlot() == pSlot; 632*cdf0e10cSrcweir ++pSlave ) 633*cdf0e10cSrcweir rBindings.Invalidate( pSlave->GetSlotId() ); 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir return; 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir pIF = pIF->GetGenoType(); 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir while ( pIF ); 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir DBG_WARNING( "W3: invalidating slot-id unknown in shell" ); 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir //-------------------------------------------------------------------- 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI ) 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir /* [Beschreibung] 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir Diese Methode steuert die Aktivierung der SfxShell-Instanz. Zun"achst 654*cdf0e10cSrcweir wird durch Aufruf der virtuellen Methode <SfxShell::Activate(sal_Bool)> 655*cdf0e10cSrcweir der Subclass die M"oglichkeit gegeben, auf das Event zu reagieren. 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir Bei bMDI == TRUE wird das zugeh"orige SbxObject 'scharfgeschaltet', 658*cdf0e10cSrcweir so da\s Methoden des Objekts unqualifiziert (ohne den Namen des Objekts) 659*cdf0e10cSrcweir vom BASIC gefunden werden. 660*cdf0e10cSrcweir */ 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir #ifdef DBG_UTIL 664*cdf0e10cSrcweir const SfxInterface *p_IF = GetInterface(); 665*cdf0e10cSrcweir if ( !p_IF ) 666*cdf0e10cSrcweir return; 667*cdf0e10cSrcweir #endif 668*cdf0e10cSrcweir #ifdef DBG_UTIL_VB 669*cdf0e10cSrcweir String aMsg("SfxShell::DoActivate() "); 670*cdf0e10cSrcweir aMsg += (long)this; 671*cdf0e10cSrcweir aMsg += " "; 672*cdf0e10cSrcweir aMsg += GetInterface()->GetName(); 673*cdf0e10cSrcweir aMsg += " bMDI "; 674*cdf0e10cSrcweir if ( bMDI ) aMsg += "MDI"; 675*cdf0e10cSrcweir DbgTrace( aMsg.GetBuffer() ); 676*cdf0e10cSrcweir #endif 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir if ( bMDI ) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir // Frame merken, in dem aktiviert wird 681*cdf0e10cSrcweir pImp->pFrame = pFrame; 682*cdf0e10cSrcweir pImp->bActive = sal_True; 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir // Subklasse benachrichtigen 686*cdf0e10cSrcweir Activate(bMDI); 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir //-------------------------------------------------------------------- 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, sal_Bool bMDI ) 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir /* [Beschreibung] 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir Diese Methode steuert die Deaktivierung der SfxShell-Instanz. Bei 696*cdf0e10cSrcweir bMDI == TRUE wird zun"achst das SbxObject in einen Status versetzt, 697*cdf0e10cSrcweir so da\s Methoden vom BASIC aus nur noch qualifiziert gerufen werden 698*cdf0e10cSrcweir k"onnen. 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir Dann erh"alt in jedem Fall die Subclass durch Aufruf der virtuellen 701*cdf0e10cSrcweir Methode <SfxShell::Deactivate(sal_Bool)> die M"oglichkeit auf das Event 702*cdf0e10cSrcweir zu reagieren. 703*cdf0e10cSrcweir */ 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir #ifdef DBG_UTIL 707*cdf0e10cSrcweir const SfxInterface *p_IF = GetInterface(); 708*cdf0e10cSrcweir if ( !p_IF ) 709*cdf0e10cSrcweir return; 710*cdf0e10cSrcweir #endif 711*cdf0e10cSrcweir #ifdef DBG_UTIL_VB 712*cdf0e10cSrcweir String aMsg("SfxShell::DoDeactivate()"); 713*cdf0e10cSrcweir aMsg += (long)this; 714*cdf0e10cSrcweir aMsg += " "; 715*cdf0e10cSrcweir aMsg += GetInterface()->GetName(); 716*cdf0e10cSrcweir aMsg += " bMDI "; 717*cdf0e10cSrcweir if ( bMDI ) aMsg += "MDI"; 718*cdf0e10cSrcweir DbgTrace( aMsg.GetBuffer() ); 719*cdf0e10cSrcweir #endif 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir // nur wenn er vom Frame kommt (nicht z.B. pop der BASIC-IDE vom AppDisp) 722*cdf0e10cSrcweir if ( bMDI && pImp->pFrame == pFrame ) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir // austragen 725*cdf0e10cSrcweir pImp->pFrame = 0; 726*cdf0e10cSrcweir pImp->bActive = sal_False; 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir // Subklasse benachrichtigen 730*cdf0e10cSrcweir Deactivate(bMDI); 731*cdf0e10cSrcweir } 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir //-------------------------------------------------------------------- 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir sal_Bool SfxShell::IsActive() const 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir return pImp->bActive; 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir //-------------------------------------------------------------------- 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir void SfxShell::Activate 743*cdf0e10cSrcweir ( 744*cdf0e10cSrcweir sal_Bool /*bMDI*/ /* TRUE 745*cdf0e10cSrcweir der <SfxDispatcher>, auf dem die SfxShell sich 746*cdf0e10cSrcweir befindet, ist aktiv geworden oder die SfxShell 747*cdf0e10cSrcweir Instanz wurde auf einen aktiven SfxDispatcher 748*cdf0e10cSrcweir gepusht. (vergl. SystemWindow::IsMDIActivate()) 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir FALSE 751*cdf0e10cSrcweir das zum <SfxViewFrame>, auf dessen SfxDispatcher 752*cdf0e10cSrcweir sich die SfxShell Instanz befindet, wurde 753*cdf0e10cSrcweir aktiviert. 754*cdf0e10cSrcweir (z.B. durch einen geschlossenen Dialog) */ 755*cdf0e10cSrcweir ) 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir /* [Beschreibung] 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir Virtuelle Methode, die beim Aktivieren der SfxShell Instanz gerufen 760*cdf0e10cSrcweir wird, um den Subclasses die Gelegenheit zu geben, auf das Aktivieren 761*cdf0e10cSrcweir zu reagieren. 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir Die Basisimplementation ist leer und braucht nicht gerufen zu werden. 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir [Querverweise] 767*cdf0e10cSrcweir StarView SystemWindow::Activate(sal_Bool) 768*cdf0e10cSrcweir */ 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir { 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir //-------------------------------------------------------------------- 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir void SfxShell::Deactivate 776*cdf0e10cSrcweir ( 777*cdf0e10cSrcweir sal_Bool /*bMDI*/ /* TRUE 778*cdf0e10cSrcweir der <SfxDispatcher>, auf dem die SfxShell sich 779*cdf0e10cSrcweir befindet, ist inaktiv geworden oder die SfxShell 780*cdf0e10cSrcweir Instanz wurde auf einen aktiven SfxDispatcher 781*cdf0e10cSrcweir gepoppt. (vergl. SystemWindow::IsMDIActivate()) 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir FALSE 784*cdf0e10cSrcweir das zum <SfxViewFrame>, auf dessen SfxDispatcher 785*cdf0e10cSrcweir sich die SfxShell Instanz befindet, wurde 786*cdf0e10cSrcweir deaktiviert. (z.B. durch einen Dialog) */ 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir ) 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir /* [Beschreibung] 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir Virtuelle Methode, die beim Deaktivieren der SfxShell Instanz gerufen 793*cdf0e10cSrcweir wird, um den Subclasses die Gelegenheit zu geben, auf das Deaktivieren 794*cdf0e10cSrcweir zu reagieren. 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir Die Basisimplementation ist leer und braucht nicht gerufen zu werden. 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir [Querverweise] 800*cdf0e10cSrcweir StarView SystemWindow::Dectivate(sal_Bool) 801*cdf0e10cSrcweir */ 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir void SfxShell::ParentActivate 807*cdf0e10cSrcweir ( 808*cdf0e10cSrcweir ) 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir /* [Beschreibung] 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir Ein Parent des <SfxDispatcher>, auf dem die SfxShell sich befindet, 813*cdf0e10cSrcweir ist aktiv geworden, oder die SfxShell Instanz wurde auf einen 814*cdf0e10cSrcweir <SfxDispatcher> gepusht, dessen parent aktiv ist. 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir Die Basisimplementation ist leer und braucht nicht gerufen zu werden. 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir [Querverweise] 819*cdf0e10cSrcweir SfxShell::Activate() 820*cdf0e10cSrcweir */ 821*cdf0e10cSrcweir { 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir //-------------------------------------------------------------------- 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir void SfxShell::ParentDeactivate 827*cdf0e10cSrcweir ( 828*cdf0e10cSrcweir ) 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir /* [Beschreibung] 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir Der aktive Parent des <SfxDispatcher>, auf dem die SfxShell sich befindet, 833*cdf0e10cSrcweir ist deaktiviert worden. 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir Die Basisimplementation ist leer und braucht nicht gerufen zu werden. 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir [Querverweise] 838*cdf0e10cSrcweir SfxShell::Deactivate() 839*cdf0e10cSrcweir */ 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir //-------------------------------------------------------------------- 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir ResMgr* SfxShell::GetResMgr() const 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir /* [Beschreibung] 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir Diese Methode liefert den ResMgr der <Resource-DLL>, die von der 850*cdf0e10cSrcweir SfxShell-Instanz verwendet wird. Ist dies ein 0-Pointer, so 851*cdf0e10cSrcweir ist der aktuelle Resource-Manager zu verwenden. 852*cdf0e10cSrcweir */ 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir return GetInterface()->GetResMgr(); 856*cdf0e10cSrcweir } 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir //-------------------------------------------------------------------- 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir bool SfxShell::CanExecuteSlot_Impl( const SfxSlot &rSlot ) 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir /* [Beschreibung] 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir Diese Methode stellt durch Aufruf der Statusfunktion fest, 865*cdf0e10cSrcweir ob 'rSlot' aktuell ausgef"uhrt werden kann. 866*cdf0e10cSrcweir */ 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir // Slot-Status holen 869*cdf0e10cSrcweir SfxItemPool &rPool = GetPool(); 870*cdf0e10cSrcweir const sal_uInt16 nId = rSlot.GetWhich( rPool ); 871*cdf0e10cSrcweir SfxItemSet aSet(rPool, nId, nId); 872*cdf0e10cSrcweir SfxStateFunc pFunc = rSlot.GetStateFnc(); 873*cdf0e10cSrcweir CallState( pFunc, aSet ); 874*cdf0e10cSrcweir return aSet.GetItemState(nId) != SFX_ITEM_DISABLED; 875*cdf0e10cSrcweir } 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir //-------------------------------------------------------------------- 878*cdf0e10cSrcweir 879*cdf0e10cSrcweir long ShellCall_Impl( void* pObj, void* pArg ) 880*cdf0e10cSrcweir { 881*cdf0e10cSrcweir ((SfxShell* )pObj)->ExecuteSlot( *(SfxRequest*)pArg, (SfxInterface*)0L ); 882*cdf0e10cSrcweir return 0; 883*cdf0e10cSrcweir } 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir /* [Beschreibung] 886*cdf0e10cSrcweir Asynchrones ExecuteSlot fuer das RELOAD 887*cdf0e10cSrcweir */ 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir //-------------------------------------------------------------------- 890*cdf0e10cSrcweir const SfxPoolItem* SfxShell::ExecuteSlot( SfxRequest& rReq, sal_Bool bAsync ) 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir if( !bAsync ) 893*cdf0e10cSrcweir return ExecuteSlot( rReq, (SfxInterface*)0L ); 894*cdf0e10cSrcweir else 895*cdf0e10cSrcweir { 896*cdf0e10cSrcweir if( !pImp->pExecuter ) 897*cdf0e10cSrcweir pImp->pExecuter = new svtools::AsynchronLink( 898*cdf0e10cSrcweir Link( this, ShellCall_Impl ) ); 899*cdf0e10cSrcweir pImp->pExecuter->Call( new SfxRequest( rReq ) ); 900*cdf0e10cSrcweir return 0; 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir } 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir const SfxPoolItem* SfxShell::ExecuteSlot 905*cdf0e10cSrcweir ( 906*cdf0e10cSrcweir SfxRequest &rReq, // der weiterzuleitende <SfxRequest> 907*cdf0e10cSrcweir const SfxInterface* pIF // default = 0 bedeutet virtuell besorgen 908*cdf0e10cSrcweir ) 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir /* [Beschreibung] 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir Diese Methode erm"oglicht das Weiterleiten eines <SfxRequest> an 913*cdf0e10cSrcweir die angegebene Basis-<SfxShell>. 914*cdf0e10cSrcweir 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir [Beispiel] 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir In einer von SfxViewShell abgeleiteten Klasse soll SID_PRINTDOCDIRECT 919*cdf0e10cSrcweir abgefangen werden. Unter bestimmten Umst"anden soll vor dem Drucken 920*cdf0e10cSrcweir eine Abfrage erscheinen, und der Request soll ggf. abgebrochen werden. 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir Dazu ist in der IDL dieser Subklasse der o.g. Slot einzutragen. Die 923*cdf0e10cSrcweir Execute-Methode enth"alt dann skizziert: 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir void SubViewShell::Exec( SfxRequest &rReq ) 926*cdf0e10cSrcweir { 927*cdf0e10cSrcweir if ( rReq.GetSlot() == SID_PRINTDOCDIRECT ) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir 'dialog' 930*cdf0e10cSrcweir if ( 'condition' ) 931*cdf0e10cSrcweir ExecuteSlot( rReq, SfxViewShell::GetInterface() ); 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir Es braucht i.d.R. kein rReq.Done() gerufen zu werden, da das bereits 936*cdf0e10cSrcweir die Implementierung der SfxViewShell erledigt bzw. abgebrochen wurde. 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir [Querverweise] 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir <SfxShell::GetSlotState(sal_uInt16,const SfxInterface*,SfxItemSet*)> 942*cdf0e10cSrcweir */ 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir if ( !pIF ) 946*cdf0e10cSrcweir pIF = GetInterface(); 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 949*cdf0e10cSrcweir const SfxSlot* pSlot = NULL; 950*cdf0e10cSrcweir if ( nSlot >= SID_VERB_START && nSlot <= SID_VERB_END ) 951*cdf0e10cSrcweir pSlot = GetVerbSlot_Impl(nSlot); 952*cdf0e10cSrcweir if ( !pSlot ) 953*cdf0e10cSrcweir pSlot = pIF->GetSlot(nSlot); 954*cdf0e10cSrcweir DBG_ASSERT( pSlot, "slot not supported" ); 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir SfxExecFunc pFunc = pSlot->GetExecFnc(); 957*cdf0e10cSrcweir if ( pFunc ) 958*cdf0e10cSrcweir CallExec( pFunc, rReq ); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir return rReq.GetReturnValue(); 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir //-------------------------------------------------------------------- 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir const SfxPoolItem* SfxShell::GetSlotState 966*cdf0e10cSrcweir ( 967*cdf0e10cSrcweir sal_uInt16 nSlotId, // Slot-Id des zu befragenden Slots 968*cdf0e10cSrcweir const SfxInterface* pIF, // default = 0 bedeutet virtuell besorgen 969*cdf0e10cSrcweir SfxItemSet* pStateSet // SfxItemSet der Slot-State-Methode 970*cdf0e10cSrcweir ) 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir /* [Beschreibung] 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir Diese Methode liefert den Status des Slots mit der angegebenen Slot-Id 975*cdf0e10cSrcweir "uber das angegebene Interface. 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir Ist der Slot disabled oder in dieser SfxShell (und deren Parent-Shells) 978*cdf0e10cSrcweir nicht bekannt, wird ein 0-Pointer zur"uckgeliefert. 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir Hat der Slot keinen Status, wird ein SfxVoidItem zur"uckgeliefert. 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir Der Status wird bei pStateSet != 0 gleich in diesem Set gesetzt, so 983*cdf0e10cSrcweir da\s <SfxShell>-Subklassen Slots-"uberladen und auch bei der 984*cdf0e10cSrcweir Status-Methode die Basis-Implementierung rufen k"onnen. 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir 987*cdf0e10cSrcweir [Beispiel] 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir In einer von SfxViewShell abgeleiteten Klasse soll SID_PRINTDOCDIRECT 990*cdf0e10cSrcweir abgefangen werden. Unter bestimmten Umst"anden soll vor dem Drucken 991*cdf0e10cSrcweir eine Abfrage erscheinen, und der Request soll ggf. abgebrochen werden. 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir Dazu ist in der IDL dieser Subklasse der o.g. Slot einzutragen. Die 994*cdf0e10cSrcweir Status-Methode enth"alt dann skizziert: 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir void SubViewShell::PrintState( SfxItemSet &rState ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir if ( rState.GetItemState( SID_PRINTDOCDIRECT ) != SFX_ITEM_UNKNOWN ) 999*cdf0e10cSrcweir GetSlotState( SID_PRINTDOCDIRECT, SfxViewShell::GetInterface(), 1000*cdf0e10cSrcweir &rState ); 1001*cdf0e10cSrcweir ... 1002*cdf0e10cSrcweir } 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir [Querverweise] 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir <SfxShell::ExecuteSlot(SfxRequest&)> 1008*cdf0e10cSrcweir */ 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir { 1011*cdf0e10cSrcweir // Slot am angegebenen Interface besorgen 1012*cdf0e10cSrcweir if ( !pIF ) 1013*cdf0e10cSrcweir pIF = GetInterface(); 1014*cdf0e10cSrcweir SfxItemState eState; 1015*cdf0e10cSrcweir SfxItemPool &rPool = GetPool(); 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir const SfxSlot* pSlot = NULL; 1018*cdf0e10cSrcweir if ( nSlotId >= SID_VERB_START && nSlotId <= SID_VERB_END ) 1019*cdf0e10cSrcweir pSlot = GetVerbSlot_Impl(nSlotId); 1020*cdf0e10cSrcweir if ( !pSlot ) 1021*cdf0e10cSrcweir pSlot = pIF->GetSlot(nSlotId); 1022*cdf0e10cSrcweir if ( pSlot ) 1023*cdf0e10cSrcweir // ggf. auf Which-Id mappen 1024*cdf0e10cSrcweir nSlotId = pSlot->GetWhich( rPool ); 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir // Item und Item-Status besorgen 1027*cdf0e10cSrcweir const SfxPoolItem *pItem = NULL; 1028*cdf0e10cSrcweir SfxItemSet aSet( rPool, nSlotId, nSlotId ); // pItem stirbt sonst zu fr"uh 1029*cdf0e10cSrcweir if ( pSlot ) 1030*cdf0e10cSrcweir { 1031*cdf0e10cSrcweir // Status-Methode rufen 1032*cdf0e10cSrcweir SfxStateFunc pFunc = pSlot->GetStateFnc(); 1033*cdf0e10cSrcweir if ( pFunc ) 1034*cdf0e10cSrcweir CallState( pFunc, aSet ); 1035*cdf0e10cSrcweir eState = aSet.GetItemState( nSlotId, sal_True, &pItem ); 1036*cdf0e10cSrcweir 1037*cdf0e10cSrcweir // ggf. Default-Item besorgen 1038*cdf0e10cSrcweir if ( eState == SFX_ITEM_DEFAULT ) 1039*cdf0e10cSrcweir { 1040*cdf0e10cSrcweir if ( SfxItemPool::IsWhich(nSlotId) ) 1041*cdf0e10cSrcweir pItem = &rPool.GetDefaultItem(nSlotId); 1042*cdf0e10cSrcweir else 1043*cdf0e10cSrcweir eState = SFX_ITEM_DONTCARE; 1044*cdf0e10cSrcweir } 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir else 1047*cdf0e10cSrcweir eState = SFX_ITEM_UNKNOWN; 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir // Item und Item-Status auswerten und ggf. in pStateSet mitpflegen 1050*cdf0e10cSrcweir SfxPoolItem *pRetItem = 0; 1051*cdf0e10cSrcweir if ( eState <= SFX_ITEM_DISABLED ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir if ( pStateSet ) 1054*cdf0e10cSrcweir pStateSet->DisableItem(nSlotId); 1055*cdf0e10cSrcweir return 0; 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir else if ( eState == SFX_ITEM_DONTCARE ) 1058*cdf0e10cSrcweir { 1059*cdf0e10cSrcweir if ( pStateSet ) 1060*cdf0e10cSrcweir pStateSet->ClearItem(nSlotId); 1061*cdf0e10cSrcweir pRetItem = new SfxVoidItem(0); 1062*cdf0e10cSrcweir } 1063*cdf0e10cSrcweir else 1064*cdf0e10cSrcweir { 1065*cdf0e10cSrcweir if ( pStateSet && pStateSet->Put( *pItem ) ) 1066*cdf0e10cSrcweir return &pStateSet->Get( pItem->Which() ); 1067*cdf0e10cSrcweir pRetItem = pItem->Clone(); 1068*cdf0e10cSrcweir } 1069*cdf0e10cSrcweir DeleteItemOnIdle(pRetItem); 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir return pRetItem; 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir //-------------------------------------------------------------------- 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir SFX_EXEC_STUB(SfxShell, VerbExec) 1077*cdf0e10cSrcweir SFX_STATE_STUB(SfxShell, VerbState) 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir void SfxShell::SetVerbs(const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& aVerbs) 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir SfxViewShell *pViewSh = PTR_CAST ( SfxViewShell, this); 1082*cdf0e10cSrcweir 1083*cdf0e10cSrcweir DBG_ASSERT(pViewSh, "SetVerbs nur an der ViewShell aufrufen!"); 1084*cdf0e10cSrcweir if ( !pViewSh ) 1085*cdf0e10cSrcweir return; 1086*cdf0e10cSrcweir 1087*cdf0e10cSrcweir // Zun"achst alle Statecaches dirty machen, damit keiner mehr versucht, 1088*cdf0e10cSrcweir // die Slots zu benutzen 1089*cdf0e10cSrcweir { 1090*cdf0e10cSrcweir SfxBindings *pBindings = 1091*cdf0e10cSrcweir pViewSh->GetViewFrame()->GetDispatcher()->GetBindings(); 1092*cdf0e10cSrcweir sal_uInt16 nCount = pImp->aSlotArr.Count(); 1093*cdf0e10cSrcweir for (sal_uInt16 n1=0; n1<nCount ; n1++) 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir sal_uInt16 nId = SID_VERB_START + n1; 1096*cdf0e10cSrcweir pBindings->Invalidate(nId, sal_False, sal_True); 1097*cdf0e10cSrcweir } 1098*cdf0e10cSrcweir } 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir sal_uInt16 nr=0; 1101*cdf0e10cSrcweir for (sal_Int32 n=0; n<aVerbs.getLength(); n++) 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir sal_uInt16 nSlotId = SID_VERB_START + nr++; 1104*cdf0e10cSrcweir DBG_ASSERT(nSlotId <= SID_VERB_END, "Zuviele Verben!"); 1105*cdf0e10cSrcweir if (nSlotId > SID_VERB_END) 1106*cdf0e10cSrcweir break; 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir SfxSlot *pNewSlot = new SfxSlot; 1109*cdf0e10cSrcweir pNewSlot->nSlotId = nSlotId; 1110*cdf0e10cSrcweir pNewSlot->nGroupId = 0; 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir // Verb-Slots m"ussen asynchron ausgef"uhrt werden, da sie w"ahrend 1113*cdf0e10cSrcweir // des Ausf"uhrens zerst"ort werden k"onnten 1114*cdf0e10cSrcweir pNewSlot->nFlags = SFX_SLOT_ASYNCHRON | SFX_SLOT_CONTAINER; 1115*cdf0e10cSrcweir pNewSlot->nMasterSlotId = 0; 1116*cdf0e10cSrcweir pNewSlot->nValue = 0; 1117*cdf0e10cSrcweir pNewSlot->fnExec = SFX_STUB_PTR(SfxShell,VerbExec); 1118*cdf0e10cSrcweir pNewSlot->fnState = SFX_STUB_PTR(SfxShell,VerbState); 1119*cdf0e10cSrcweir pNewSlot->pType = 0; HACK(SFX_TYPE(SfxVoidItem)) 1120*cdf0e10cSrcweir pNewSlot->pName = U2S(aVerbs[n].VerbName); 1121*cdf0e10cSrcweir pNewSlot->pLinkedSlot = 0; 1122*cdf0e10cSrcweir pNewSlot->nArgDefCount = 0; 1123*cdf0e10cSrcweir pNewSlot->pFirstArgDef = 0; 1124*cdf0e10cSrcweir pNewSlot->pUnoName = 0; 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir if (pImp->aSlotArr.Count()) 1127*cdf0e10cSrcweir { 1128*cdf0e10cSrcweir SfxSlot *pSlot = (pImp->aSlotArr)[0]; 1129*cdf0e10cSrcweir pNewSlot->pNextSlot = pSlot->pNextSlot; 1130*cdf0e10cSrcweir pSlot->pNextSlot = pNewSlot; 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir else 1133*cdf0e10cSrcweir pNewSlot->pNextSlot = pNewSlot; 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir pImp->aSlotArr.Insert(pNewSlot, (sal_uInt16) n); 1136*cdf0e10cSrcweir } 1137*cdf0e10cSrcweir 1138*cdf0e10cSrcweir pImp->aVerbList = aVerbs; 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir if (pViewSh) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir // Der Status von SID_OBJECT wird im Controller direkt an der Shell 1143*cdf0e10cSrcweir // abgeholt, es reicht also, ein neues StatusUpdate anzuregen 1144*cdf0e10cSrcweir SfxBindings *pBindings = pViewSh->GetViewFrame()->GetDispatcher()-> 1145*cdf0e10cSrcweir GetBindings(); 1146*cdf0e10cSrcweir pBindings->Invalidate( SID_OBJECT, sal_True, sal_True ); 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir 1150*cdf0e10cSrcweir //-------------------------------------------------------------------- 1151*cdf0e10cSrcweir 1152*cdf0e10cSrcweir const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& SfxShell::GetVerbs() const 1153*cdf0e10cSrcweir { 1154*cdf0e10cSrcweir return pImp->aVerbList; 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir //-------------------------------------------------------------------- 1158*cdf0e10cSrcweir 1159*cdf0e10cSrcweir void SfxShell::VerbExec(SfxRequest& rReq) 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir sal_uInt16 nId = rReq.GetSlot(); 1162*cdf0e10cSrcweir SfxViewShell *pViewShell = GetViewShell(); 1163*cdf0e10cSrcweir if ( pViewShell ) 1164*cdf0e10cSrcweir { 1165*cdf0e10cSrcweir sal_Bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly(); 1166*cdf0e10cSrcweir com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > aList = pViewShell->GetVerbs(); 1167*cdf0e10cSrcweir for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++) 1168*cdf0e10cSrcweir { 1169*cdf0e10cSrcweir // check for ReadOnly verbs 1170*cdf0e10cSrcweir if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) ) 1171*cdf0e10cSrcweir continue; 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir // check for verbs that shouldn't appear in the menu 1174*cdf0e10cSrcweir if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) ) 1175*cdf0e10cSrcweir continue; 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir if (nId == SID_VERB_START + nVerb++) 1178*cdf0e10cSrcweir { 1179*cdf0e10cSrcweir pViewShell->DoVerb(aList[n].VerbID); 1180*cdf0e10cSrcweir rReq.Done(); 1181*cdf0e10cSrcweir return; 1182*cdf0e10cSrcweir } 1183*cdf0e10cSrcweir } 1184*cdf0e10cSrcweir } 1185*cdf0e10cSrcweir } 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir //-------------------------------------------------------------------- 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir void SfxShell::VerbState(SfxItemSet& ) 1190*cdf0e10cSrcweir { 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir //-------------------------------------------------------------------- 1194*cdf0e10cSrcweir 1195*cdf0e10cSrcweir const SfxSlot* SfxShell::GetVerbSlot_Impl(sal_uInt16 nId) const 1196*cdf0e10cSrcweir { 1197*cdf0e10cSrcweir com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > rList = pImp->aVerbList; 1198*cdf0e10cSrcweir 1199*cdf0e10cSrcweir DBG_ASSERT(nId >= SID_VERB_START && nId <= SID_VERB_END,"Falsche VerbId!"); 1200*cdf0e10cSrcweir sal_uInt16 nIndex = nId - SID_VERB_START; 1201*cdf0e10cSrcweir DBG_ASSERT(nIndex < rList.getLength(),"Falsche VerbId!"); 1202*cdf0e10cSrcweir 1203*cdf0e10cSrcweir if (nIndex < rList.getLength()) 1204*cdf0e10cSrcweir return pImp->aSlotArr[nIndex]; 1205*cdf0e10cSrcweir else 1206*cdf0e10cSrcweir return 0; 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir //-------------------------------------------------------------------- 1210*cdf0e10cSrcweir 1211*cdf0e10cSrcweir void SfxShell::SetHelpId(sal_uIntPtr nId) 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir pImp->nHelpId = nId; 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir //-------------------------------------------------------------------- 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir sal_uIntPtr SfxShell::GetHelpId() const 1219*cdf0e10cSrcweir { 1220*cdf0e10cSrcweir return pImp->nHelpId; 1221*cdf0e10cSrcweir } 1222*cdf0e10cSrcweir 1223*cdf0e10cSrcweir //-------------------------------------------------------------------- 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir SfxObjectShell* SfxShell::GetObjectShell() 1226*cdf0e10cSrcweir { 1227*cdf0e10cSrcweir if ( GetViewShell() ) 1228*cdf0e10cSrcweir return GetViewShell()->GetViewFrame()->GetObjectShell(); 1229*cdf0e10cSrcweir else 1230*cdf0e10cSrcweir return NULL; 1231*cdf0e10cSrcweir } 1232*cdf0e10cSrcweir 1233*cdf0e10cSrcweir //-------------------------------------------------------------------- 1234*cdf0e10cSrcweir 1235*cdf0e10cSrcweir sal_Bool SfxShell::HasUIFeature( sal_uInt32 ) 1236*cdf0e10cSrcweir { 1237*cdf0e10cSrcweir return sal_False; 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir 1240*cdf0e10cSrcweir long DispatcherUpdate_Impl( void*, void* pArg ) 1241*cdf0e10cSrcweir { 1242*cdf0e10cSrcweir ((SfxDispatcher*) pArg)->Update_Impl( sal_True ); 1243*cdf0e10cSrcweir ((SfxDispatcher*) pArg)->GetBindings()->InvalidateAll(sal_False); 1244*cdf0e10cSrcweir return 0; 1245*cdf0e10cSrcweir } 1246*cdf0e10cSrcweir 1247*cdf0e10cSrcweir void SfxShell::UIFeatureChanged() 1248*cdf0e10cSrcweir { 1249*cdf0e10cSrcweir SfxViewFrame *pFrame = GetFrame(); 1250*cdf0e10cSrcweir if ( pFrame && pFrame->IsVisible() ) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir // Auch dann Update erzwingen, wenn Dispatcher schon geupdated ist, 1253*cdf0e10cSrcweir // sonst bleibt evtl. irgendwas in den gebunkerten Tools stecken. 1254*cdf0e10cSrcweir // Asynchron aufrufen, um Rekursionen zu vermeiden 1255*cdf0e10cSrcweir if ( !pImp->pUpdater ) 1256*cdf0e10cSrcweir pImp->pUpdater = new svtools::AsynchronLink( Link( this, DispatcherUpdate_Impl ) ); 1257*cdf0e10cSrcweir 1258*cdf0e10cSrcweir // Mehrfachaufrufe gestattet 1259*cdf0e10cSrcweir pImp->pUpdater->Call( pFrame->GetDispatcher(), sal_True ); 1260*cdf0e10cSrcweir } 1261*cdf0e10cSrcweir } 1262*cdf0e10cSrcweir 1263*cdf0e10cSrcweir void SfxShell::SetDisableFlags( sal_uIntPtr nFlags ) 1264*cdf0e10cSrcweir { 1265*cdf0e10cSrcweir pImp->nDisableFlags = nFlags; 1266*cdf0e10cSrcweir } 1267*cdf0e10cSrcweir 1268*cdf0e10cSrcweir sal_uIntPtr SfxShell::GetDisableFlags() const 1269*cdf0e10cSrcweir { 1270*cdf0e10cSrcweir return pImp->nDisableFlags; 1271*cdf0e10cSrcweir } 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir SfxItemSet* SfxShell::CreateItemSet( sal_uInt16 ) 1274*cdf0e10cSrcweir { 1275*cdf0e10cSrcweir return NULL; 1276*cdf0e10cSrcweir } 1277*cdf0e10cSrcweir 1278*cdf0e10cSrcweir void SfxShell::ApplyItemSet( sal_uInt16, const SfxItemSet& ) 1279*cdf0e10cSrcweir { 1280*cdf0e10cSrcweir } 1281*cdf0e10cSrcweir 1282*cdf0e10cSrcweir void SfxShell::SetViewShell_Impl( SfxViewShell* pView ) 1283*cdf0e10cSrcweir { 1284*cdf0e10cSrcweir pImp->pViewSh = pView; 1285*cdf0e10cSrcweir } 1286*cdf0e10cSrcweir 1287*cdf0e10cSrcweir 1288*cdf0e10cSrcweir 1289