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