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