xref: /aoo42x/main/sfx2/source/control/objface.cxx (revision d119d52d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sfx2.hxx"
26 
27 #include <stdlib.h>
28 #include <tools/rcid.h>
29 #ifndef GCC
30 #endif
31 #include <tools/stream.hxx>
32 
33 #include <sfx2/module.hxx>
34 #include <sfx2/objface.hxx>
35 #include <sfx2/msg.hxx>
36 #include <sfx2/app.hxx>
37 #include <sfx2/msgpool.hxx>
38 #include "sfx2/sfxresid.hxx"
39 #include <sfx2/minarray.hxx>
40 #include <sfx2/objsh.hxx>
41 
DBG_NAME(SfxInterface)42 DBG_NAME(SfxInterface)
43 
44 //====================================================================
45 
46 EXTERN_C
47 #if defined( PM2 ) && (!defined( CSET ) && !defined ( MTW ) && !defined( WTC ))
48 int _stdcall
49 #else
50 #ifdef WNT
51 int _cdecl
52 #else
53 int
54 #endif
55 #endif
56 
57 SfxCompareSlots_Impl( const void* pSmaller, const void* pBigger )
58 {
59 	DBG_MEMTEST();
60 	return ( (int) ((SfxSlot*)pSmaller)->GetSlotId() ) -
61 		   ( (int) ((SfxSlot*)pBigger)->GetSlotId() );
62 }
63 
64 //=========================================================================
65 
66 struct SfxObjectUI_Impl
67 {
68 	sal_uInt16	nPos;
69 	ResId	aResId;
70 	sal_Bool	bVisible;
71 	sal_Bool	bContext;
72 	String* pName;
73 	sal_uInt32	nFeature;
74 
SfxObjectUI_ImplSfxObjectUI_Impl75 	SfxObjectUI_Impl(sal_uInt16 n, const ResId& rResId, sal_Bool bVis, sal_uInt32 nFeat) :
76 		nPos(n),
77 		aResId(rResId.GetId(), *rResId.GetResMgr()),
78 		bVisible(bVis),
79 		bContext(sal_False),
80 		pName(0),
81 		nFeature(nFeat)
82 	{
83 		aResId.SetRT(rResId.GetRT());
84 	}
85 
~SfxObjectUI_ImplSfxObjectUI_Impl86 	~SfxObjectUI_Impl()
87 	{
88 		delete pName;
89 	}
90 };
91 
92 DECL_PTRARRAY(SfxObjectUIArr_Impl, SfxObjectUI_Impl*, 2, 2)
93 
94 struct SfxInterface_Impl
95 {
96 	SfxObjectUIArr_Impl*	pObjectBars;	// registered ObjectBars
97 	SfxObjectUIArr_Impl*	pChildWindows;	// registered ChildWindows
98 	ResId					aPopupRes;		// registered PopupMenu
99 	ResId					aStatBarRes;	// registered StatusBar
100 	SfxModule*				pModule;
101     sal_Bool                    bRegistered;
102 
SfxInterface_ImplSfxInterface_Impl103 	SfxInterface_Impl() :
104 		aPopupRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager()),
105 		aStatBarRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager())
106     , bRegistered(sal_False)
107 	{
108 		pObjectBars   = new SfxObjectUIArr_Impl;
109 		pChildWindows = new SfxObjectUIArr_Impl;
110 	}
111 
~SfxInterface_ImplSfxInterface_Impl112 	~SfxInterface_Impl()
113 	{
114 		sal_uInt16 n;
115 		for (n=0; n<pObjectBars->Count(); n++)
116 			delete (*pObjectBars)[n];
117 		delete pObjectBars;
118 
119 		for (n=0; n<pChildWindows->Count(); n++)
120 			delete (*pChildWindows)[n];
121 		delete pChildWindows;
122 	}
123 };
124 
125 static SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr );
126 
127 //====================================================================
128 
129 //====================================================================
130 // ctor, registeres a new unit
131 
SfxInterface(const char * pClassName,const ResId & rNameResId,SfxInterfaceId nId,const SfxInterface * pParent,SfxSlot & rSlotMap,sal_uInt16 nSlotCount)132 SfxInterface::SfxInterface( const char *pClassName,
133 							const ResId& rNameResId,
134 							SfxInterfaceId nId,
135 							const SfxInterface* pParent,
136 							SfxSlot &rSlotMap, sal_uInt16 nSlotCount ):
137 	pName(pClassName),
138 	pGenoType(pParent),
139 	nClassId(nId),
140 	aNameResId(rNameResId.GetId(),*rNameResId.GetResMgr()),
141 	pImpData(0)
142 {
143 	pImpData = new SfxInterface_Impl;
144 	SetSlotMap( rSlotMap, nSlotCount );
145 }
146 
Register(SfxModule * pMod)147 void SfxInterface::Register( SfxModule* pMod )
148 {
149     pImpData->bRegistered = sal_True;
150 	pImpData->pModule = pMod;
151     if ( pMod )
152 		pMod->GetSlotPool()->RegisterInterface(*this);
153 	else
154         SFX_APP()->GetAppSlotPool_Impl().RegisterInterface(*this);
155 }
156 
SetSlotMap(SfxSlot & rSlotMap,sal_uInt16 nSlotCount)157 void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount )
158 {
159 	pSlots = &rSlotMap;
160 	nCount = nSlotCount;
161 	SfxSlot* pIter = pSlots;
162 	if ( 1 == nCount && !pIter->pNextSlot )
163 		pIter->pNextSlot = pIter;
164 
165 	if ( !pIter->pNextSlot )
166 	{
167 		// sort the SfxSlots by id
168 		qsort( pSlots, nCount, sizeof(SfxSlot), SfxCompareSlots_Impl );
169 
170 		// link masters and slaves
171 		sal_uInt16 nIter = 1;
172 		for ( pIter = pSlots; nIter <= nCount; ++pIter, ++nIter )
173 		{
174 			//! hier bitte sinnvoll pruefen
175 			//! DBG_ASSERT(!(pIter->IsMode(SFX_SLOT_CACHABLE) &&
176 			//!                 pIter->IsMode(SFX_SLOT_VOLATILE)),
177 			//!             "invalid Flags" );
178 			DBG_ASSERT( nIter == nCount ||
179 						pIter->GetSlotId() != (pIter+1)->GetSlotId(),
180 						"doppelte SID" );
181 
182 			// jeder Master verweist auf seinen ersten Slave (ENUM), alle
183 			// Slaves auf ihren Master.
184 			// Slaves verweisen im Ring auf die anderen mit gleichem Master
185 			if ( pIter->GetKind() == SFX_KIND_ENUM )
186 			{
187 				pIter->pLinkedSlot = GetSlot( pIter->nMasterSlotId );
188 				DBG_ASSERT( pIter->pLinkedSlot, "slave without master" );
189 				if ( !pIter->pLinkedSlot->pLinkedSlot )
190 					( (SfxSlot*) pIter->pLinkedSlot)->pLinkedSlot = pIter;
191 
192 				if ( 0 == pIter->GetNextSlot() )
193 				{
194 					SfxSlot *pLastSlot = pIter;
195 					for ( sal_uInt16 n = nIter; n < Count(); ++n )
196 					{
197 						SfxSlot *pCurSlot = (pSlots+n);
198 						if ( pCurSlot->nMasterSlotId == pIter->nMasterSlotId )
199 						{
200 							pLastSlot->pNextSlot = pCurSlot;
201 							pLastSlot = pCurSlot;
202 						}
203 					}
204 					pLastSlot->pNextSlot = pIter;
205 				}
206 			}
207 			else if ( 0 == pIter->GetNextSlot() )
208 			{
209 				// Slots verweisen im Ring auf den n"achten mit derselben Statusmethode
210 				SfxSlot *pLastSlot = pIter;
211 				for ( sal_uInt16 n = nIter; n < Count(); ++n )
212 				{
213 					SfxSlot *pCurSlot = (pSlots+n);
214 					if ( pCurSlot->GetStateFnc() == pIter->GetStateFnc() )
215 					{
216 						pLastSlot->pNextSlot = pCurSlot;
217 						pLastSlot = pCurSlot;
218 					}
219 				}
220 				pLastSlot->pNextSlot = pIter;
221 			}
222 		}
223 	}
224 #ifdef DBG_UTIL
225 	else
226 	{
227 		sal_uInt16 nIter = 1;
228 		for ( SfxSlot *pNext = pIter+1; nIter < nCount; ++pNext, ++nIter )
229 		{
230 
231 			if ( pNext->GetSlotId() <= pIter->GetSlotId() )
232 				DBG_ERROR ("Falsche Reihenfolge!");
233 
234 			if ( pIter->GetKind() == SFX_KIND_ENUM )
235 			{
236 				const SfxSlot *pMasterSlot = GetSlot(pIter->nMasterSlotId);
237 				const SfxSlot *pFirstSlave = pMasterSlot->pLinkedSlot;
238 				const SfxSlot *pSlave = pFirstSlave;
239 				do
240 				{
241 					if ( pSlave->pLinkedSlot != pMasterSlot )
242 					{
243 						ByteString aStr("Falsche Master/Slave-Verkettung : ");
244 						aStr += ByteString::CreateFromInt32(pMasterSlot->GetSlotId());
245 						aStr += " , ";
246 						aStr += ByteString::CreateFromInt32(pSlave->GetSlotId());
247 						DBG_ERROR(aStr.GetBuffer());
248 					}
249 
250 					if ( pSlave->nMasterSlotId != pMasterSlot->GetSlotId() )
251 					{
252 						ByteString aStr("Falsche Master/Slave-Ids : ");
253 						aStr += ByteString::CreateFromInt32(pMasterSlot->GetSlotId());
254 						aStr += " , ";
255 						aStr += ByteString::CreateFromInt32(pSlave->GetSlotId());
256 						DBG_ERROR(aStr.GetBuffer());
257 					}
258 
259 					pSlave = pSlave->pNextSlot;
260 				}
261 				while ( pSlave != pFirstSlave );
262 			}
263 			else
264 			{
265 				if ( pIter->pLinkedSlot )
266 				{
267 					if ( pIter->pLinkedSlot->GetKind() != SFX_KIND_ENUM )
268 					{
269 						ByteString aStr("Slave ist kein enum : ");
270 						aStr += ByteString::CreateFromInt32(pIter->GetSlotId());
271 						aStr += " , ";
272 						aStr += ByteString::CreateFromInt32(pIter->pLinkedSlot->GetSlotId());
273 						DBG_ERROR(aStr.GetBuffer());
274 					}
275 				}
276 
277 				const SfxSlot *pCurSlot = pIter;
278 				do
279 				{
280 					pCurSlot = pCurSlot->pNextSlot;
281 					if ( pCurSlot->GetStateFnc() != pIter->GetStateFnc() )
282 					{
283 						ByteString aStr("Verkettete Slots mit verschiedenen StateMethods : ");
284 						aStr += ByteString::CreateFromInt32(pCurSlot->GetSlotId());
285 						aStr += " , ";
286 						aStr += ByteString::CreateFromInt32(pIter->GetSlotId());
287 						DBG_ERROR(aStr.GetBuffer());
288 					}
289 				}
290 				while ( pCurSlot != pIter );
291 			}
292 
293 			pIter = pNext;
294 		}
295 	}
296 #endif
297 }
298 
299 
300 //--------------------------------------------------------------------
301 
302 
303 
~SfxInterface()304 SfxInterface::~SfxInterface()
305 {
306 	SfxModule *pMod = pImpData->pModule;
307     sal_Bool bRegistered = pImpData->bRegistered;
308 	delete pImpData;
309     DBG_ASSERT( bRegistered, "Interface not registered!" );
310     if ( bRegistered )
311 	{
312 		if ( pMod )
313 			pMod->GetSlotPool()->ReleaseInterface(*this);
314 		else
315 			SFX_APP()->GetAppSlotPool_Impl().ReleaseInterface(*this);
316 	}
317 }
318 
319 //--------------------------------------------------------------------
320 
321 // searches for the specified func
322 
323 
GetSlot(sal_uInt16 nFuncId) const324 const SfxSlot* SfxInterface::GetSlot( sal_uInt16 nFuncId ) const
325 {
326 	DBG_MEMTEST();
327 	DBG_CHKTHIS(SfxInterface, 0);
328 	DBG_ASSERT( this && pSlots && nCount, "" );
329 
330 	// find the id using binary search
331 	void* p = bsearch( &nFuncId, pSlots, nCount, sizeof(SfxSlot),
332 					   SfxCompareSlots_Impl );
333 	if ( !p && pGenoType )
334 		return pGenoType->GetSlot( nFuncId );
335 
336 	return p ? (const SfxSlot*)p : 0;
337 }
338 
GetSlot(const String & rCommand) const339 const SfxSlot* SfxInterface::GetSlot( const String& rCommand ) const
340 {
341     static const char UNO_COMMAND[] = ".uno:";
342 
343     String aCommand( rCommand );
344     if ( aCommand.SearchAscii( UNO_COMMAND ) == 0 )
345          aCommand.Erase( 0, sizeof( UNO_COMMAND )-1 );
346 
347     for ( sal_uInt16 n=0; n<nCount; n++ )
348     {
349         if ( (pSlots+n)->pUnoName &&
350              aCommand.CompareIgnoreCaseToAscii( (pSlots+n)->GetUnoName() ) == COMPARE_EQUAL )
351             return pSlots+n;
352     }
353 
354     return pGenoType ? pGenoType->GetSlot( aCommand ) : NULL;
355 }
356 
357 //--------------------------------------------------------------------
358 
359 
GetRealSlot(const SfxSlot * pSlot) const360 const SfxSlot* SfxInterface::GetRealSlot( const SfxSlot *pSlot ) const
361 {
362 	DBG_MEMTEST();
363 	DBG_CHKTHIS(SfxInterface, 0);
364 	DBG_ASSERT( this && pSlots && nCount, "" );
365 
366 	if ( !ContainsSlot_Impl(pSlot) )
367 	{
368 		if(pGenoType)
369 			return pGenoType->GetRealSlot(pSlot);
370 		DBG_ERROR("fremder Slot");
371 		return 0;
372 	}
373 
374 	return pSlot->pLinkedSlot;
375 }
376 
377 //--------------------------------------------------------------------
378 
379 
GetRealSlot(sal_uInt16 nSlotId) const380 const SfxSlot* SfxInterface::GetRealSlot( sal_uInt16 nSlotId ) const
381 {
382 	DBG_MEMTEST();
383 	DBG_CHKTHIS(SfxInterface, 0);
384 	DBG_ASSERT( this && pSlots && nCount, "" );
385 
386 	const SfxSlot *pSlot = GetSlot(nSlotId);
387 	if ( !pSlot )
388 	{
389 		if(pGenoType)
390 			return pGenoType->GetRealSlot(nSlotId);
391 		DBG_ERROR("fremder Slot");
392 		return 0;
393 	}
394 
395 	return pSlot->pLinkedSlot;
396 }
397 
398 //--------------------------------------------------------------------
399 
400 
RegisterPopupMenu(const ResId & rResId)401 void SfxInterface::RegisterPopupMenu( const ResId& rResId )
402 {
403 	DBG_CHKTHIS(SfxInterface, 0);
404 	pImpData->aPopupRes = rResId;
405 }
406 
407 //--------------------------------------------------------------------
408 
RegisterObjectBar(sal_uInt16 nPos,const ResId & rResId,const String * pStr)409 void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId,
410 		const String *pStr )
411 {
412 	RegisterObjectBar( nPos, rResId, 0UL, pStr );
413 }
414 
415 
RegisterObjectBar(sal_uInt16 nPos,const ResId & rResId,sal_uInt32 nFeature,const String * pStr)416 void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr )
417 {
418     SfxObjectUI_Impl* pUI = CreateObjectBarUI_Impl( nPos, rResId, nFeature, pStr );
419     if ( pUI )
420         pImpData->pObjectBars->Append(pUI);
421 }
422 
CreateObjectBarUI_Impl(sal_uInt16 nPos,const ResId & rResId,sal_uInt32 nFeature,const String * pStr)423 SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr )
424 {
425 	if ((nPos & SFX_VISIBILITY_MASK) == 0)
426         nPos |= SFX_VISIBILITY_STANDARD;
427 
428 	SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(nPos, rResId, sal_True, nFeature);
429 
430 	if (pStr == 0)
431 	{
432 		ResId aResId(rResId);
433 		aResId.SetRT(RSC_STRING);
434 		aResId.SetResMgr(rResId.GetResMgr());
435         if( ! aResId.GetResMgr() )
436             aResId.SetResMgr( SfxApplication::GetOrCreate()->GetOffResManager_Impl() );
437 		if ( !aResId.GetResMgr()->IsAvailable(aResId) )
438 			pUI->pName = new String (DEFINE_CONST_UNICODE("NoName"));
439 		else
440 			pUI->pName = new String(aResId);
441 	}
442 	else
443 		pUI->pName = new String(*pStr);
444 
445     return pUI;
446 }
447 
GetObjectBarResId(sal_uInt16 nNo) const448 const ResId& SfxInterface::GetObjectBarResId( sal_uInt16 nNo ) const
449 {
450 	sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
451 	if ( bGenoType )
452 	{
453 		// Gibt es Toolbars in der Superklasse ?
454 		sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
455 		if ( nNo < nBaseCount )
456 			// Die der Superklasse kommen zuerst
457 			return pGenoType->GetObjectBarResId( nNo );
458 		else
459 			nNo = nNo - nBaseCount;
460 	}
461 
462 #ifdef DBG_UTIL
463 	sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
464 	DBG_ASSERT( nNo<nObjBarCount,"Objectbar ist unbekannt!" );
465 #endif
466 	return (*pImpData->pObjectBars)[nNo]->aResId;
467 }
468 
469 //--------------------------------------------------------------------
470 
471 
GetObjectBarPos(sal_uInt16 nNo) const472 sal_uInt16 SfxInterface::GetObjectBarPos( sal_uInt16 nNo ) const
473 {
474 	sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
475 	if ( bGenoType )
476 	{
477 		// Gibt es Toolbars in der Superklasse ?
478 		sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
479 		if ( nNo < nBaseCount )
480 			// Die der Superklasse kommen zuerst
481 			return pGenoType->GetObjectBarPos( nNo );
482 		else
483 			nNo = nNo - nBaseCount;
484 	}
485 
486 #ifdef DBG_UTIL
487 	sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
488 	DBG_ASSERT( nNo<nObjBarCount,"Objectbar ist unbekannt!" );
489 #endif
490 	return (*pImpData->pObjectBars)[nNo]->nPos;
491 }
492 
493 //--------------------------------------------------------------------
494 
495 
GetObjectBarCount() const496 sal_uInt16 SfxInterface::GetObjectBarCount() const
497 {
498 	if (pGenoType && ! pGenoType->HasName())
499 		return pImpData->pObjectBars->Count() + pGenoType->GetObjectBarCount();
500 	else
501 		return pImpData->pObjectBars->Count();
502 }
503 
504 //--------------------------------------------------------------------
RegisterChildWindow(sal_uInt16 nId,sal_Bool bContext,const String * pChildWinName)505 void SfxInterface::RegisterChildWindow(sal_uInt16 nId, sal_Bool bContext, const String* pChildWinName)
506 {
507 	RegisterChildWindow( nId, bContext, 0UL, pChildWinName );
508 }
509 
RegisterChildWindow(sal_uInt16 nId,sal_Bool bContext,sal_uInt32 nFeature,const String *)510 void SfxInterface::RegisterChildWindow(sal_uInt16 nId, sal_Bool bContext, sal_uInt32 nFeature, const String*)
511 {
512 	SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(0, ResId(nId, *SfxApplication::GetOrCreate()->GetOffResManager_Impl()), sal_True, nFeature);
513 	pUI->bContext = bContext;
514 	pImpData->pChildWindows->Append(pUI);
515 }
516 
RegisterStatusBar(const ResId & rResId)517 void SfxInterface::RegisterStatusBar(const ResId& rResId)
518 {
519 	pImpData->aStatBarRes = rResId;
520 }
521 
522 
GetChildWindowId(sal_uInt16 nNo) const523 sal_uInt32 SfxInterface::GetChildWindowId (sal_uInt16 nNo) const
524 {
525 	if ( pGenoType )
526 	{
527 		// Gibt es ChildWindows in der Superklasse ?
528 		sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
529 		if ( nNo < nBaseCount )
530 			// Die der Superklasse kommen zuerst
531 			return pGenoType->GetChildWindowId( nNo );
532 		else
533 			nNo = nNo - nBaseCount;
534 	}
535 
536 #ifdef DBG_UTIL
537 	sal_uInt16 nCWCount = pImpData->pChildWindows->Count();
538 	DBG_ASSERT( nNo<nCWCount,"ChildWindow ist unbekannt!" );
539 #endif
540 	sal_uInt32 nRet = (*pImpData->pChildWindows)[nNo]->aResId.GetId();
541 	if ( (*pImpData->pChildWindows)[nNo]->bContext )
542 		nRet += sal_uInt32( nClassId ) << 16;
543 	return nRet;
544 }
545 
GetChildWindowFeature(sal_uInt16 nNo) const546 sal_uInt32 SfxInterface::GetChildWindowFeature (sal_uInt16 nNo) const
547 {
548 	if ( pGenoType )
549 	{
550 		// Gibt es ChildWindows in der Superklasse ?
551 		sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
552 		if ( nNo < nBaseCount )
553 			// Die der Superklasse kommen zuerst
554 			return pGenoType->GetChildWindowFeature( nNo );
555 		else
556 			nNo = nNo - nBaseCount;
557 	}
558 
559 #ifdef DBG_UTIL
560 	sal_uInt16 nCWCount = pImpData->pChildWindows->Count();
561 	DBG_ASSERT( nNo<nCWCount,"ChildWindow ist unbekannt!" );
562 #endif
563 	return (*pImpData->pChildWindows)[nNo]->nFeature;
564 }
565 
566 //--------------------------------------------------------------------
567 
568 
GetChildWindowCount() const569 sal_uInt16 SfxInterface::GetChildWindowCount() const
570 {
571 	if (pGenoType)
572 		return pImpData->pChildWindows->Count() + pGenoType->GetChildWindowCount();
573 	else
574 		return pImpData->pChildWindows->Count();
575 }
576 
577 
GetPopupMenuResId() const578 const ResId& SfxInterface::GetPopupMenuResId() const
579 {
580 	return pImpData->aPopupRes;
581 }
582 
583 
GetStatusBarResId() const584 const ResId& SfxInterface::GetStatusBarResId() const
585 {
586 	if (pImpData->aStatBarRes.GetId() == 0 && pGenoType)
587 		return pGenoType->GetStatusBarResId();
588 	else
589 		return pImpData->aStatBarRes;
590 }
591 
592 
593 
GetObjectBarName(sal_uInt16 nNo) const594 const String* SfxInterface::GetObjectBarName ( sal_uInt16 nNo ) const
595 {
596 	sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
597 	if ( bGenoType )
598 	{
599 		// Gibt es Toolbars in der Superklasse ?
600 		sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
601 		if ( nNo < nBaseCount )
602 			// Die der Superklasse kommen zuerst
603 			return pGenoType->GetObjectBarName( nNo );
604 		else
605 			nNo = nNo - nBaseCount;
606 	}
607 
608 #ifdef DBG_UTIL
609 	sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
610 	DBG_ASSERT( nNo<nObjBarCount,"Objectbar ist unbekannt!" );
611 #endif
612 	return (*pImpData->pObjectBars)[nNo]->pName;
613 }
614 
GetObjectBarFeature(sal_uInt16 nNo) const615 sal_uInt32 SfxInterface::GetObjectBarFeature ( sal_uInt16 nNo ) const
616 {
617 	sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
618 	if ( bGenoType )
619 	{
620 		// Gibt es Toolbars in der Superklasse ?
621 		sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
622 		if ( nNo < nBaseCount )
623 			// Die der Superklasse kommen zuerst
624 			return pGenoType->GetObjectBarFeature( nNo );
625 		else
626 			nNo = nNo - nBaseCount;
627 	}
628 
629 #ifdef DBG_UTIL
630 	sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
631 	DBG_ASSERT( nNo<nObjBarCount,"Objectbar ist unbekannt!" );
632 #endif
633 	return (*pImpData->pObjectBars)[nNo]->nFeature;
634 }
635 
IsObjectBarVisible(sal_uInt16 nNo) const636 sal_Bool SfxInterface::IsObjectBarVisible(sal_uInt16 nNo) const
637 {
638 	sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
639 	if ( bGenoType )
640 	{
641 		// Gibt es Toolbars in der Superklasse ?
642 		sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
643 		if ( nNo < nBaseCount )
644 			// Die der Superklasse kommen zuerst
645 			return pGenoType->IsObjectBarVisible( nNo );
646 		else
647 			nNo = nNo - nBaseCount;
648 	}
649 
650 #ifdef DBG_UTIL
651 	sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
652 	DBG_ASSERT( nNo<nObjBarCount,"Objectbar ist unbekannt!" );
653 #endif
654 	return (*pImpData->pObjectBars)[nNo]->bVisible;
655 }
656 
GetRealInterfaceForSlot(const SfxSlot * pRealSlot) const657 const SfxInterface* SfxInterface::GetRealInterfaceForSlot( const SfxSlot *pRealSlot ) const
658 {
659     DBG_ASSERT( pImpData->bRegistered, "Interface not registered!" );
660 	const SfxInterface* pInterface = this;
661 
662 	// Der Slot k"onnte auch aus dem Interface einer Shell-Basisklasse stammen
663 	do
664 	{
665 		const SfxSlot *pLastSlot  = (*pInterface)[pInterface->Count()-1];
666 		const SfxSlot *pFirstSlot = (*pInterface)[0];
667 
668 		// Ist pInterface der Owner von pRealSlot ?
669 		if ( pFirstSlot <= pRealSlot && pRealSlot <= pLastSlot )
670 			break;
671 
672 		// Sonst Interface der Superklasse probieren
673 		pInterface = pInterface->pGenoType;
674 	}
675 	while ( pInterface );
676 
677 	return pInterface;
678 }
679 
680 
681 
682