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