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
10*d119d52dSAndrew Rist *
11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist *
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.
19*d119d52dSAndrew Rist *
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 <tools/stream.hxx>
27cdf0e10cSrcweir #include <rsc/rscsfx.hxx>
28cdf0e10cSrcweir #ifndef GCC
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir
31cdf0e10cSrcweir // wg. pSlotPool
32cdf0e10cSrcweir #include "appdata.hxx"
33cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
34cdf0e10cSrcweir #include <sfx2/minarray.hxx>
35cdf0e10cSrcweir #include <sfx2/msg.hxx>
36cdf0e10cSrcweir #include <sfx2/app.hxx>
37cdf0e10cSrcweir #include <sfx2/objface.hxx>
38cdf0e10cSrcweir #include "sfxtypes.hxx"
39cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
40cdf0e10cSrcweir #include "arrdecl.hxx"
41cdf0e10cSrcweir #include <sfx2/module.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir #include <sfx2/sfx.hrc>
44cdf0e10cSrcweir
45cdf0e10cSrcweir //====================================================================
46cdf0e10cSrcweir
47cdf0e10cSrcweir struct SfxSIDRegistration_Impl
48cdf0e10cSrcweir {
49cdf0e10cSrcweir String _aGroup;
50cdf0e10cSrcweir String _aName;
51cdf0e10cSrcweir sal_uInt16 _nSID;
52cdf0e10cSrcweir };
53cdf0e10cSrcweir
54cdf0e10cSrcweir struct SfxSlotType_Impl
55cdf0e10cSrcweir {
56cdf0e10cSrcweir sal_uInt16 nId;
57cdf0e10cSrcweir TypeId nType;
58cdf0e10cSrcweir
SfxSlotType_ImplSfxSlotType_Impl59cdf0e10cSrcweir SfxSlotType_Impl( sal_uInt16 nTheId, TypeId nTheType ):
60cdf0e10cSrcweir nId(nTheId), nType(nTheType)
61cdf0e10cSrcweir {}
62cdf0e10cSrcweir };
63cdf0e10cSrcweir
64cdf0e10cSrcweir DECL_2BYTEARRAY(SfxSlotGroupArr_Impl, sal_uInt16, 6, 4)
65cdf0e10cSrcweir DECL_PTRARRAY(SfxInterfaceArr_Impl, SfxInterface*, 6, 3)
66cdf0e10cSrcweir DECL_PTRARRAY(SfxSlotTypeArr_Impl, SfxSlotType_Impl*, 8, 8)
67cdf0e10cSrcweir
68cdf0e10cSrcweir
69cdf0e10cSrcweir //====================================================================
70cdf0e10cSrcweir
SfxSlotPool(SfxSlotPool * pParent,ResMgr * pResManager)71cdf0e10cSrcweir SfxSlotPool::SfxSlotPool( SfxSlotPool *pParent, ResMgr* pResManager )
72cdf0e10cSrcweir : _pGroups(0)
73cdf0e10cSrcweir , _pTypes(0)
74cdf0e10cSrcweir , _pParentPool( pParent )
75cdf0e10cSrcweir , _pResMgr( pResManager )
76cdf0e10cSrcweir , _pInterfaces(0)
77cdf0e10cSrcweir , _nCurGroup(0)
78cdf0e10cSrcweir , _nCurInterface(0)
79cdf0e10cSrcweir , _nCurMsg(0)
80cdf0e10cSrcweir , _pUnoSlots( 0 )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir if ( !_pResMgr )
83cdf0e10cSrcweir _pResMgr = SfxApplication::GetOrCreate()->GetOffResManager_Impl();
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir //====================================================================
87cdf0e10cSrcweir
~SfxSlotPool()88cdf0e10cSrcweir SfxSlotPool::~SfxSlotPool()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir _pParentPool = 0;
91cdf0e10cSrcweir for ( SfxInterface *pIF = FirstInterface(); pIF; pIF = FirstInterface() )
92cdf0e10cSrcweir delete pIF;
93cdf0e10cSrcweir delete _pInterfaces;
94cdf0e10cSrcweir delete _pGroups;
95cdf0e10cSrcweir if ( _pTypes )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir for ( sal_uInt16 n =_pTypes->Count(); n--; )
98cdf0e10cSrcweir delete _pTypes->GetObject(n);
99cdf0e10cSrcweir delete _pTypes;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir //====================================================================
104cdf0e10cSrcweir
105cdf0e10cSrcweir // registers the availability of the Interface of functions
106cdf0e10cSrcweir
RegisterInterface(SfxInterface & rInterface)107cdf0e10cSrcweir void SfxSlotPool::RegisterInterface( SfxInterface& rInterface )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir DBG_MEMTEST();
110cdf0e10cSrcweir
111cdf0e10cSrcweir // add to the list of SfxObjectInterface instances
112cdf0e10cSrcweir if ( _pInterfaces == 0 )
113cdf0e10cSrcweir _pInterfaces = new SfxInterfaceArr_Impl;
114cdf0e10cSrcweir _pInterfaces->Append(&rInterface);
115cdf0e10cSrcweir
116cdf0e10cSrcweir // bei einem (einzelnen) Null-Slot abbrechen (aus syntaktischen Gr"unden
117cdf0e10cSrcweir // enthalten interfaces immer mindestens einen Slot)
118cdf0e10cSrcweir if ( rInterface.Count() == 1 && !rInterface[0]->nSlotId )
119cdf0e10cSrcweir return;
120cdf0e10cSrcweir
121cdf0e10cSrcweir // possibly add Interface-id and group-ids of funcs to the list of groups
122cdf0e10cSrcweir if ( !_pGroups )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir _pGroups = new SfxSlotGroupArr_Impl;
125cdf0e10cSrcweir
126cdf0e10cSrcweir if ( _pParentPool )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir // Die Groups im parent Slotpool sind auch hier bekannt
129cdf0e10cSrcweir SfxSlotGroupArr_Impl& rGroups = *_pParentPool->_pGroups;
130cdf0e10cSrcweir for ( sal_uInt16 n=0; n<rGroups.Count(); n++ )
131cdf0e10cSrcweir _pGroups->Append( rGroups[n] );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir if ( !_pTypes )
136cdf0e10cSrcweir _pTypes = new SfxSlotTypeArr_Impl;
137cdf0e10cSrcweir for ( sal_uInt16 nFunc = 0; nFunc < rInterface.Count(); ++nFunc )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir SfxSlot *pDef = rInterface[nFunc];
140cdf0e10cSrcweir if ( pDef->GetGroupId() && /* pDef->GetGroupId() != GID_INTERN && */
141cdf0e10cSrcweir !_pGroups->Contains(pDef->GetGroupId()) )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir if (pDef->GetGroupId() == GID_INTERN)
144cdf0e10cSrcweir _pGroups->Insert(0, pDef->GetGroupId());
145cdf0e10cSrcweir else
146cdf0e10cSrcweir _pGroups->Append(pDef->GetGroupId());
147cdf0e10cSrcweir }
148cdf0e10cSrcweir #if 0
149cdf0e10cSrcweir const TypeId &rTypeId = pDef->GetType()->Type();
150cdf0e10cSrcweir if ( /*rTypeId != TYPE(SfxVoidItem) &&*/ rTypeId != 0 )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir sal_uInt16 nPos;
153cdf0e10cSrcweir for ( nPos = 0; nPos < _pTypes->Count(); ++nPos )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir if ( _pTypes->GetObject(nPos)->nId == pDef->GetSlotId() )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir DBG_ASSERT( rTypeId == _pTypes->GetObject(nPos)->nType,
158cdf0e10cSrcweir "same slot id with unequal item types" );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir else if ( _pTypes->GetObject(nPos)->nId > pDef->GetSlotId() )
161cdf0e10cSrcweir break;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir if ( nPos >= _pTypes->Count() ||
164cdf0e10cSrcweir _pTypes->GetObject(nPos)->nId > pDef->GetSlotId() )
165cdf0e10cSrcweir _pTypes->Append( new SfxSlotType_Impl( pDef->GetSlotId(), rTypeId ) );
166cdf0e10cSrcweir }
167cdf0e10cSrcweir #endif
168cdf0e10cSrcweir }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir
171cdf0e10cSrcweir //====================================================================
172cdf0e10cSrcweir
GetSlotType(sal_uInt16 nId) const173cdf0e10cSrcweir TypeId SfxSlotPool::GetSlotType( sal_uInt16 nId ) const
174cdf0e10cSrcweir {
175cdf0e10cSrcweir const SfxSlot* pSlot = (const_cast <SfxSlotPool*> (this))->GetSlot( nId );
176cdf0e10cSrcweir return pSlot ? pSlot->GetType()->Type() : 0;
177cdf0e10cSrcweir /*
178cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < _pTypes->Count(); ++nPos )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir if ( _pTypes->GetObject(nPos)->nId == nId )
181cdf0e10cSrcweir return _pTypes->GetObject(nPos)->nType;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir return _pParentPool ? _pParentPool->GetSlotType( nId ) : 0;
184cdf0e10cSrcweir */
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir //====================================================================
188cdf0e10cSrcweir
189cdf0e10cSrcweir // unregisters the availability of the Interface of functions
190cdf0e10cSrcweir
ReleaseInterface(SfxInterface & rInterface)191cdf0e10cSrcweir void SfxSlotPool::ReleaseInterface( SfxInterface& rInterface )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir DBG_MEMTEST();
194cdf0e10cSrcweir DBG_ASSERT( _pInterfaces, "releasing SfxInterface, but there are none" );
195cdf0e10cSrcweir // remove from the list of SfxInterface instances
196cdf0e10cSrcweir _pInterfaces->Remove(&rInterface);
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir //--------------------------------------------------------------------
200cdf0e10cSrcweir
201cdf0e10cSrcweir // get the first SfxMessage for a special Id (e.g. for getting check-mode)
202cdf0e10cSrcweir
GetSlot(sal_uInt16 nId)203cdf0e10cSrcweir const SfxSlot* SfxSlotPool::GetSlot( sal_uInt16 nId )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir DBG_MEMTEST();
206cdf0e10cSrcweir DBG_ASSERT( _pInterfaces != 0, "no Interfaces registered" );
207cdf0e10cSrcweir
208cdf0e10cSrcweir // Zun"achst die eigenen Interfaces absuchen
209cdf0e10cSrcweir for ( sal_uInt16 nInterf = 0; nInterf < _pInterfaces->Count(); ++nInterf )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir const SfxSlot *pDef = _pInterfaces->GetObject(nInterf)->GetSlot(nId);
212cdf0e10cSrcweir if ( pDef )
213cdf0e10cSrcweir return pDef;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir // Dann beim eventuell vorhandenen parent versuchen
217cdf0e10cSrcweir return _pParentPool ? _pParentPool->GetSlot( nId ) : 0;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir //--------------------------------------------------------------------
221cdf0e10cSrcweir
222cdf0e10cSrcweir // skips to the next group
223cdf0e10cSrcweir
SeekGroup(sal_uInt16 nNo)224cdf0e10cSrcweir String SfxSlotPool::SeekGroup( sal_uInt16 nNo )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir DBG_MEMTEST();
227cdf0e10cSrcweir DBG_ASSERT( _pInterfaces != 0, "no Interfaces registered" );
228cdf0e10cSrcweir
229cdf0e10cSrcweir // if the group exists, use it
230cdf0e10cSrcweir if ( _pGroups && nNo < _pGroups->Count() )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir _nCurGroup = nNo;
233cdf0e10cSrcweir if ( _pParentPool )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir // Meistens stimmt die Reihenfolge der Ids "uberein
236cdf0e10cSrcweir sal_uInt16 nParentCount = _pParentPool->_pGroups->Count();
237cdf0e10cSrcweir if ( nNo < nParentCount && (*_pGroups)[nNo] == (*_pParentPool->_pGroups)[nNo] )
238cdf0e10cSrcweir _pParentPool->_nCurGroup = nNo;
239cdf0e10cSrcweir else
240cdf0e10cSrcweir {
241cdf0e10cSrcweir // Ansonsten mu\s gesucht werden
242cdf0e10cSrcweir // Wenn die Gruppe im parent pool nicht gefunden wird, wird
243cdf0e10cSrcweir // _nCurGroup au\serhalb des g"ultigen Bereiches gesetzt
244cdf0e10cSrcweir sal_uInt16 i;
245cdf0e10cSrcweir for ( i=1; i<nParentCount; i++ )
246cdf0e10cSrcweir if ( (*_pGroups)[nNo] == (*_pParentPool->_pGroups)[i] )
247cdf0e10cSrcweir break;
248cdf0e10cSrcweir _pParentPool->_nCurGroup = i;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir SfxResId aResId( (*_pGroups)[_nCurGroup] );
253cdf0e10cSrcweir aResId.SetRT(RSC_STRING);
254cdf0e10cSrcweir if ( !aResId.GetResMgr()->IsAvailable(aResId) )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir DBG_ERROR( "GroupId-Name nicht im SFX definiert!" );
257cdf0e10cSrcweir return String();
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir return String( aResId );
261cdf0e10cSrcweir }
262cdf0e10cSrcweir
263cdf0e10cSrcweir return String();
264cdf0e10cSrcweir }
265cdf0e10cSrcweir
266cdf0e10cSrcweir
267cdf0e10cSrcweir //--------------------------------------------------------------------
268cdf0e10cSrcweir
GetGroupCount()269cdf0e10cSrcweir sal_uInt16 SfxSlotPool::GetGroupCount()
270cdf0e10cSrcweir {
271cdf0e10cSrcweir return _pGroups->Count();
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir
275cdf0e10cSrcweir //--------------------------------------------------------------------
276cdf0e10cSrcweir
277cdf0e10cSrcweir // internal search loop
278cdf0e10cSrcweir
SeekSlot(sal_uInt16 nStartInterface)279cdf0e10cSrcweir const SfxSlot* SfxSlotPool::SeekSlot( sal_uInt16 nStartInterface )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir DBG_MEMTEST();
282cdf0e10cSrcweir DBG_ASSERT( _pInterfaces != 0, "no Interfaces registered" );
283cdf0e10cSrcweir
284cdf0e10cSrcweir // Die Numerierung der interfaces startet beim parent pool
285cdf0e10cSrcweir sal_uInt16 nFirstInterface = _pParentPool ? _pParentPool->_pInterfaces->Count() : 0;
286cdf0e10cSrcweir
287cdf0e10cSrcweir // sind wir am Ende des Parent-Pools angekommen?
288cdf0e10cSrcweir if ( nStartInterface < nFirstInterface &&
289cdf0e10cSrcweir _pParentPool->_nCurGroup >= _pParentPool->_pGroups->Count() )
290cdf0e10cSrcweir nStartInterface = nFirstInterface;
291cdf0e10cSrcweir
292cdf0e10cSrcweir // liegt das Interface noch im Parent-Pool?
293cdf0e10cSrcweir if ( nStartInterface < nFirstInterface )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir DBG_ASSERT( _pParentPool, "Kein parent pool!" );
296cdf0e10cSrcweir _nCurInterface = nStartInterface;
297cdf0e10cSrcweir return _pParentPool->SeekSlot( nStartInterface );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir
300cdf0e10cSrcweir // find the first func-def with the current group id
301cdf0e10cSrcweir sal_uInt16 nCount = _pInterfaces->Count() + nFirstInterface;
302cdf0e10cSrcweir for ( _nCurInterface = nStartInterface;
303cdf0e10cSrcweir _nCurInterface < nCount;
304cdf0e10cSrcweir ++_nCurInterface )
305cdf0e10cSrcweir {
306cdf0e10cSrcweir SfxInterface* pInterface = (*_pInterfaces)[_nCurInterface-nFirstInterface];
307cdf0e10cSrcweir for ( _nCurMsg = 0;
308cdf0e10cSrcweir _nCurMsg < pInterface->Count();
309cdf0e10cSrcweir ++_nCurMsg )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir const SfxSlot* pMsg = (*pInterface)[_nCurMsg];
312cdf0e10cSrcweir if ( pMsg->GetGroupId() == _pGroups->GetObject(_nCurGroup) )
313cdf0e10cSrcweir return pMsg;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
317cdf0e10cSrcweir return 0;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir //--------------------------------------------------------------------
321cdf0e10cSrcweir
322cdf0e10cSrcweir // skips to the next func in the current group
323cdf0e10cSrcweir
NextSlot()324cdf0e10cSrcweir const SfxSlot* SfxSlotPool::NextSlot()
325cdf0e10cSrcweir {
326cdf0e10cSrcweir DBG_MEMTEST();
327cdf0e10cSrcweir DBG_ASSERT( _pInterfaces != 0, "no Interfaces registered" );
328cdf0e10cSrcweir
329cdf0e10cSrcweir // Die Numerierung der interfaces startet beim parent pool
330cdf0e10cSrcweir sal_uInt16 nFirstInterface = _pParentPool ? _pParentPool->_pInterfaces->Count() : 0;
331cdf0e10cSrcweir
332cdf0e10cSrcweir if ( _nCurInterface < nFirstInterface && _nCurGroup >= _pParentPool->_pGroups->Count() )
333cdf0e10cSrcweir _nCurInterface = nFirstInterface;
334cdf0e10cSrcweir
335cdf0e10cSrcweir if ( _nCurInterface < nFirstInterface )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir DBG_ASSERT( _pParentPool, "Kein parent pool!" );
338cdf0e10cSrcweir const SfxSlot *pSlot = _pParentPool->NextSlot();
339cdf0e10cSrcweir _nCurInterface = _pParentPool->_nCurInterface;
340cdf0e10cSrcweir if ( pSlot )
341cdf0e10cSrcweir return pSlot;
342cdf0e10cSrcweir if ( _nCurInterface == nFirstInterface )
343cdf0e10cSrcweir // parent pool ist fertig
344cdf0e10cSrcweir return SeekSlot( nFirstInterface );
345cdf0e10cSrcweir }
346cdf0e10cSrcweir
347cdf0e10cSrcweir sal_uInt16 nInterface = _nCurInterface - nFirstInterface;
348cdf0e10cSrcweir // possibly we are already at the end
349cdf0e10cSrcweir if ( nInterface >= _pInterfaces->Count() )
350cdf0e10cSrcweir return 0;
351cdf0e10cSrcweir
352cdf0e10cSrcweir // look for further matching func-defs within the same Interface
353cdf0e10cSrcweir SfxInterface* pInterface = (*_pInterfaces)[nInterface];
354cdf0e10cSrcweir while ( ++_nCurMsg < pInterface->Count() )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir SfxSlot* pMsg = (*pInterface)[_nCurMsg];
357cdf0e10cSrcweir if ( pMsg->GetGroupId() == _pGroups->GetObject(_nCurGroup) )
358cdf0e10cSrcweir return pMsg;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir return SeekSlot(++_nCurInterface );
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
364cdf0e10cSrcweir
365cdf0e10cSrcweir //--------------------------------------------------------------------
366cdf0e10cSrcweir
367cdf0e10cSrcweir // SlotName erfragen, gfs. mit HilfeText
368cdf0e10cSrcweir
369cdf0e10cSrcweir //--------------------------------------------------------------------
370cdf0e10cSrcweir
FirstInterface()371cdf0e10cSrcweir SfxInterface* SfxSlotPool::FirstInterface()
372cdf0e10cSrcweir {
373cdf0e10cSrcweir _nCurInterface = 0;
374cdf0e10cSrcweir if ( !_pInterfaces || !_pInterfaces->Count() )
375cdf0e10cSrcweir return 0;
376cdf0e10cSrcweir return _pParentPool ? _pParentPool->FirstInterface() : (*_pInterfaces)[0];
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
379cdf0e10cSrcweir
380cdf0e10cSrcweir //--------------------------------------------------------------------
381cdf0e10cSrcweir
NextInterface()382cdf0e10cSrcweir SfxInterface* SfxSlotPool::NextInterface()
383cdf0e10cSrcweir {
384cdf0e10cSrcweir _nCurInterface++;
385cdf0e10cSrcweir sal_uInt16 nFirstInterface = _pParentPool ? _pParentPool->_pInterfaces->Count() : 0;
386cdf0e10cSrcweir if ( _nCurInterface < nFirstInterface )
387cdf0e10cSrcweir return (*_pParentPool->_pInterfaces)[_nCurInterface];
388cdf0e10cSrcweir sal_uInt16 nInterface = _nCurInterface - nFirstInterface;
389cdf0e10cSrcweir return nInterface < _pInterfaces->Count() ? (*_pInterfaces)[nInterface] : 0;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
GetUnoSlot(const String & rName)392cdf0e10cSrcweir const SfxSlot* SfxSlotPool::GetUnoSlot( const String& rName )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir const SfxSlot *pSlot = NULL;
395cdf0e10cSrcweir for ( sal_uInt16 nInterface=0; nInterface<_pInterfaces->Count(); nInterface++ )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir pSlot = (*_pInterfaces)[nInterface]->GetSlot( rName );
398cdf0e10cSrcweir if ( pSlot )
399cdf0e10cSrcweir break;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir
402cdf0e10cSrcweir if ( !pSlot && _pParentPool )
403cdf0e10cSrcweir pSlot = _pParentPool->GetUnoSlot( rName );
404cdf0e10cSrcweir
405cdf0e10cSrcweir return pSlot;
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
GetSlotPool(SfxViewFrame * pFrame)408cdf0e10cSrcweir SfxSlotPool& SfxSlotPool::GetSlotPool( SfxViewFrame *pFrame )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir SfxModule *pMod = SfxModule::GetActiveModule( pFrame );
411cdf0e10cSrcweir if ( pMod && pMod->GetSlotPool() )
412cdf0e10cSrcweir return *pMod->GetSlotPool();
413cdf0e10cSrcweir else
414cdf0e10cSrcweir return *SFX_APP()->Get_Impl()->pSlotPool;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir
418