Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <stdlib.h>
22 : : #include <tools/rcid.h>
23 : : #include <tools/stream.hxx>
24 : :
25 : : #include <sfx2/module.hxx>
26 : : #include <sfx2/objface.hxx>
27 : : #include <sfx2/msg.hxx>
28 : : #include <sfx2/app.hxx>
29 : : #include <sfx2/msgpool.hxx>
30 : : #include "sfx2/sfxresid.hxx"
31 : : #include <sfx2/minarray.hxx>
32 : : #include <sfx2/objsh.hxx>
33 : : #include <rtl/strbuf.hxx>
34 : :
35 : : DBG_NAME(SfxInterface)
36 : :
37 : : //====================================================================
38 : :
39 : : EXTERN_C
40 : : #ifdef WNT
41 : : int _cdecl
42 : : #else
43 : : int
44 : : #endif
45 : :
46 : 50582538 : SfxCompareSlots_Impl( const void* pSmaller, const void* pBigger )
47 : : {
48 : 50582538 : return ( (int) ((SfxSlot*)pSmaller)->GetSlotId() ) -
49 : 50582538 : ( (int) ((SfxSlot*)pBigger)->GetSlotId() );
50 : : }
51 : :
52 : : //=========================================================================
53 : :
54 : : struct SfxObjectUI_Impl
55 : : {
56 : : sal_uInt16 nPos;
57 : : ResId aResId;
58 : : sal_Bool bVisible;
59 : : sal_Bool bContext;
60 : : String* pName;
61 : : sal_uInt32 nFeature;
62 : :
63 : 12210 : SfxObjectUI_Impl(sal_uInt16 n, const ResId& rResId, sal_Bool bVis, sal_uInt32 nFeat) :
64 : : nPos(n),
65 : 12210 : aResId(rResId.GetId(), *rResId.GetResMgr()),
66 : : bVisible(bVis),
67 : : bContext(sal_False),
68 : : pName(0),
69 : 12210 : nFeature(nFeat)
70 : : {
71 : 12210 : aResId.SetRT(rResId.GetRT());
72 : 12210 : }
73 : :
74 : 6610 : ~SfxObjectUI_Impl()
75 : : {
76 [ + + ]: 6610 : delete pName;
77 : 6610 : }
78 : : };
79 : :
80 : 696166 : DECL_PTRARRAY(SfxObjectUIArr_Impl, SfxObjectUI_Impl*, 2, 2)
81 : :
82 : : struct SfxInterface_Impl
83 : : {
84 : : SfxObjectUIArr_Impl* pObjectBars; // registered ObjectBars
85 : : SfxObjectUIArr_Impl* pChildWindows; // registered ChildWindows
86 : : ResId aPopupRes; // registered PopupMenu
87 : : ResId aStatBarRes; // registered StatusBar
88 : : SfxModule* pModule;
89 : : sal_Bool bRegistered;
90 : :
91 : 5187 : SfxInterface_Impl() :
92 : 5187 : aPopupRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager()),
93 : 5187 : aStatBarRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager())
94 : 10374 : , bRegistered(sal_False)
95 : : {
96 [ + - ]: 5187 : pObjectBars = new SfxObjectUIArr_Impl;
97 [ + - ]: 5187 : pChildWindows = new SfxObjectUIArr_Impl;
98 : 5187 : }
99 : :
100 : 2800 : ~SfxInterface_Impl()
101 : : {
102 : : sal_uInt16 n;
103 [ + + ]: 4872 : for (n=0; n<pObjectBars->Count(); n++)
104 [ + - ]: 2072 : delete (*pObjectBars)[n];
105 [ + - ]: 2800 : delete pObjectBars;
106 : :
107 [ + + ]: 7338 : for (n=0; n<pChildWindows->Count(); n++)
108 [ + - ]: 4538 : delete (*pChildWindows)[n];
109 [ + - ]: 2800 : delete pChildWindows;
110 : 2800 : }
111 : : };
112 : :
113 : : static SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr );
114 : :
115 : : //====================================================================
116 : :
117 : : //====================================================================
118 : : // constuctor, registeres a new unit
119 : :
120 : 5187 : SfxInterface::SfxInterface( const char *pClassName,
121 : : const ResId& rNameResId,
122 : : SfxInterfaceId nId,
123 : : const SfxInterface* pParent,
124 : : SfxSlot &rSlotMap, sal_uInt16 nSlotCount ):
125 : : pName(pClassName),
126 : : pGenoType(pParent),
127 : : nClassId(nId),
128 : 5187 : aNameResId(rNameResId.GetId(),*rNameResId.GetResMgr()),
129 : 5187 : pImpData(0)
130 : : {
131 [ + - ]: 5187 : pImpData = new SfxInterface_Impl;
132 : 5187 : SetSlotMap( rSlotMap, nSlotCount );
133 : 5187 : }
134 : :
135 : 5155 : void SfxInterface::Register( SfxModule* pMod )
136 : : {
137 : 5155 : pImpData->bRegistered = sal_True;
138 : 5155 : pImpData->pModule = pMod;
139 [ + + ]: 5155 : if ( pMod )
140 : 3585 : pMod->GetSlotPool()->RegisterInterface(*this);
141 : : else
142 : 1570 : SFX_APP()->GetAppSlotPool_Impl().RegisterInterface(*this);
143 : 5155 : }
144 : :
145 : 5187 : void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount )
146 : : {
147 : 5187 : pSlots = &rSlotMap;
148 : 5187 : nCount = nSlotCount;
149 : 5187 : SfxSlot* pIter = pSlots;
150 [ + + ][ + + ]: 5187 : if ( 1 == nCount && !pIter->pNextSlot )
151 : 910 : pIter->pNextSlot = pIter;
152 : :
153 [ - + ]: 5187 : if ( !pIter->pNextSlot )
154 : : {
155 : : // sort the SfxSlots by id
156 : 0 : qsort( pSlots, nCount, sizeof(SfxSlot), SfxCompareSlots_Impl );
157 : :
158 : : // link masters and slaves
159 : 0 : sal_uInt16 nIter = 1;
160 [ # # ]: 0 : for ( pIter = pSlots; nIter <= nCount; ++pIter, ++nIter )
161 : : {
162 : :
163 : : DBG_ASSERT( nIter == nCount ||
164 : : pIter->GetSlotId() != (pIter+1)->GetSlotId(),
165 : : "doppelte SID" );
166 : :
167 : : // every master refers to his first slave (ENUM),
168 : : // all slaves refer to their master.
169 : : // Slaves refer in a circle to the other slaves with the same master
170 [ # # ]: 0 : if ( pIter->GetKind() == SFX_KIND_ENUM )
171 : : {
172 : 0 : pIter->pLinkedSlot = GetSlot( pIter->nMasterSlotId );
173 : : DBG_ASSERT( pIter->pLinkedSlot, "slave without master" );
174 [ # # ]: 0 : if ( !pIter->pLinkedSlot->pLinkedSlot )
175 : 0 : ( (SfxSlot*) pIter->pLinkedSlot)->pLinkedSlot = pIter;
176 : :
177 [ # # ]: 0 : if ( 0 == pIter->GetNextSlot() )
178 : : {
179 : 0 : SfxSlot *pLastSlot = pIter;
180 [ # # ]: 0 : for ( sal_uInt16 n = nIter; n < Count(); ++n )
181 : : {
182 : 0 : SfxSlot *pCurSlot = (pSlots+n);
183 [ # # ]: 0 : if ( pCurSlot->nMasterSlotId == pIter->nMasterSlotId )
184 : : {
185 : 0 : pLastSlot->pNextSlot = pCurSlot;
186 : 0 : pLastSlot = pCurSlot;
187 : : }
188 : : }
189 : 0 : pLastSlot->pNextSlot = pIter;
190 : : }
191 : : }
192 [ # # ]: 0 : else if ( 0 == pIter->GetNextSlot() )
193 : : {
194 : : // Slots refering in circle to the next with the same
195 : : // Status method.
196 : 0 : SfxSlot *pLastSlot = pIter;
197 [ # # ]: 0 : for ( sal_uInt16 n = nIter; n < Count(); ++n )
198 : : {
199 : 0 : SfxSlot *pCurSlot = (pSlots+n);
200 [ # # ]: 0 : if ( pCurSlot->GetStateFnc() == pIter->GetStateFnc() )
201 : : {
202 : 0 : pLastSlot->pNextSlot = pCurSlot;
203 : 0 : pLastSlot = pCurSlot;
204 : : }
205 : : }
206 : 0 : pLastSlot->pNextSlot = pIter;
207 : : }
208 : : }
209 : : }
210 : : #ifdef DBG_UTIL
211 : : else
212 : : {
213 : : sal_uInt16 nIter = 1;
214 : : for ( SfxSlot *pNext = pIter+1; nIter < nCount; ++pNext, ++nIter )
215 : : {
216 : :
217 : : if ( pNext->GetSlotId() <= pIter->GetSlotId() )
218 : : OSL_FAIL("Wrong order!");
219 : :
220 : : if ( pIter->GetKind() == SFX_KIND_ENUM )
221 : : {
222 : : const SfxSlot *pMasterSlot = GetSlot(pIter->nMasterSlotId);
223 : : const SfxSlot *pFirstSlave = pMasterSlot->pLinkedSlot;
224 : : const SfxSlot *pSlave = pFirstSlave;
225 : : do
226 : : {
227 : : if ( pSlave->pLinkedSlot != pMasterSlot )
228 : : {
229 : : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
230 : : "Wrong Master/Slave- link: "));
231 : : aStr.append(static_cast<sal_Int32>(
232 : : pMasterSlot->GetSlotId()));
233 : : aStr.append(RTL_CONSTASCII_STRINGPARAM(" , "));
234 : : aStr.append(static_cast<sal_Int32>(
235 : : pSlave->GetSlotId()));
236 : : OSL_FAIL(aStr.getStr());
237 : : }
238 : :
239 : : if ( pSlave->nMasterSlotId != pMasterSlot->GetSlotId() )
240 : : {
241 : : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
242 : : "Wrong Master/Slave-Ids: "));
243 : : aStr.append(static_cast<sal_Int32>(
244 : : pMasterSlot->GetSlotId()));
245 : : aStr.append(RTL_CONSTASCII_STRINGPARAM(" , "));
246 : : aStr.append(static_cast<sal_Int32>(
247 : : pSlave->GetSlotId()));
248 : : OSL_FAIL(aStr.getStr());
249 : : }
250 : :
251 : : pSlave = pSlave->pNextSlot;
252 : : }
253 : : while ( pSlave != pFirstSlave );
254 : : }
255 : : else
256 : : {
257 : : if ( pIter->pLinkedSlot )
258 : : {
259 : : if ( pIter->pLinkedSlot->GetKind() != SFX_KIND_ENUM )
260 : : {
261 : : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
262 : : "Slave is no enum: "));
263 : : aStr.append(static_cast<sal_Int32>(pIter->GetSlotId()));
264 : : aStr.append(RTL_CONSTASCII_STRINGPARAM(" , "));
265 : : aStr.append(static_cast<sal_Int32>(
266 : : pIter->pLinkedSlot->GetSlotId()));
267 : : OSL_FAIL(aStr.getStr());
268 : : }
269 : : }
270 : :
271 : : const SfxSlot *pCurSlot = pIter;
272 : : do
273 : : {
274 : : pCurSlot = pCurSlot->pNextSlot;
275 : : if ( pCurSlot->GetStateFnc() != pIter->GetStateFnc() )
276 : : {
277 : : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM(
278 : : "Linked Slots with different State Methods : "));
279 : : aStr.append(static_cast<sal_Int32>(
280 : : pCurSlot->GetSlotId()));
281 : : aStr.append(RTL_CONSTASCII_STRINGPARAM(" , "));
282 : : aStr.append(static_cast<sal_Int32>(pIter->GetSlotId()));
283 : : OSL_FAIL(aStr.getStr());
284 : : }
285 : : }
286 : : while ( pCurSlot != pIter );
287 : : }
288 : :
289 : : pIter = pNext;
290 : : }
291 : : }
292 : : #endif
293 : 5187 : }
294 : :
295 : : //--------------------------------------------------------------------
296 : :
297 : 5600 : SfxInterface::~SfxInterface()
298 : : {
299 : 2800 : SfxModule *pMod = pImpData->pModule;
300 : 2800 : sal_Bool bRegistered = pImpData->bRegistered;
301 [ + - ]: 2800 : delete pImpData;
302 : : DBG_ASSERT( bRegistered, "Interface not registered!" );
303 [ + - ]: 2800 : if ( bRegistered )
304 : : {
305 [ + + ]: 2800 : if ( pMod )
306 : 1830 : pMod->GetSlotPool()->ReleaseInterface(*this);
307 : : else
308 : 970 : SFX_APP()->GetAppSlotPool_Impl().ReleaseInterface(*this);
309 : : }
310 [ - + ]: 5600 : }
311 : :
312 : : //--------------------------------------------------------------------
313 : :
314 : : // searches for the specified func
315 : :
316 : 10387500 : const SfxSlot* SfxInterface::GetSlot( sal_uInt16 nFuncId ) const
317 : : {
318 : : DBG_CHKTHIS(SfxInterface, 0);
319 : : DBG_ASSERT( this && pSlots && nCount, "" );
320 : :
321 : : // find the id using binary search
322 : : void* p = bsearch( &nFuncId, pSlots, nCount, sizeof(SfxSlot),
323 : 10387500 : SfxCompareSlots_Impl );
324 [ + + ][ + + ]: 10387500 : if ( !p && pGenoType )
325 : 5160787 : return pGenoType->GetSlot( nFuncId );
326 : :
327 : 10387500 : return p ? (const SfxSlot*)p : 0;
328 : : }
329 : :
330 : 7627866 : const SfxSlot* SfxInterface::GetSlot( const String& rCommand ) const
331 : : {
332 : : static const char UNO_COMMAND[] = ".uno:";
333 : :
334 [ + - ]: 7627866 : String aCommand( rCommand );
335 [ + - ][ + + ]: 7627866 : if ( aCommand.SearchAscii( UNO_COMMAND ) == 0 )
336 [ + - ]: 3774 : aCommand.Erase( 0, sizeof( UNO_COMMAND )-1 );
337 : :
338 [ + + ]: 314658827 : for ( sal_uInt16 n=0; n<nCount; n++ )
339 : : {
340 [ + + ][ + + ]: 614874292 : if ( (pSlots+n)->pUnoName &&
[ + + ]
341 [ + - ]: 307429793 : aCommand.CompareIgnoreCaseToAscii( (pSlots+n)->GetUnoName() ) == COMPARE_EQUAL )
342 : 413538 : return pSlots+n;
343 : : }
344 : :
345 [ + + ][ + - ]: 7627866 : return pGenoType ? pGenoType->GetSlot( aCommand ) : NULL;
[ + - ]
346 : : }
347 : :
348 : : //--------------------------------------------------------------------
349 : :
350 : 0 : const SfxSlot* SfxInterface::GetRealSlot( const SfxSlot *pSlot ) const
351 : : {
352 : : DBG_CHKTHIS(SfxInterface, 0);
353 : : DBG_ASSERT( this && pSlots && nCount, "" );
354 : :
355 [ # # ]: 0 : if ( !ContainsSlot_Impl(pSlot) )
356 : : {
357 [ # # ]: 0 : if(pGenoType)
358 : 0 : return pGenoType->GetRealSlot(pSlot);
359 : : OSL_FAIL("unknown Slot");
360 : 0 : return 0;
361 : : }
362 : :
363 : 0 : return pSlot->pLinkedSlot;
364 : : }
365 : :
366 : : //--------------------------------------------------------------------
367 : :
368 : 0 : const SfxSlot* SfxInterface::GetRealSlot( sal_uInt16 nSlotId ) const
369 : : {
370 : : DBG_CHKTHIS(SfxInterface, 0);
371 : : DBG_ASSERT( this && pSlots && nCount, "" );
372 : :
373 : 0 : const SfxSlot *pSlot = GetSlot(nSlotId);
374 [ # # ]: 0 : if ( !pSlot )
375 : : {
376 [ # # ]: 0 : if(pGenoType)
377 : 0 : return pGenoType->GetRealSlot(nSlotId);
378 : : OSL_FAIL("unkonown Slot");
379 : 0 : return 0;
380 : : }
381 : :
382 : 0 : return pSlot->pLinkedSlot;
383 : : }
384 : :
385 : : //--------------------------------------------------------------------
386 : :
387 : 2195 : void SfxInterface::RegisterPopupMenu( const ResId& rResId )
388 : : {
389 : : DBG_CHKTHIS(SfxInterface, 0);
390 : 2195 : pImpData->aPopupRes = rResId;
391 : 2195 : }
392 : :
393 : : //--------------------------------------------------------------------
394 : :
395 : 3260 : void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId,
396 : : const String *pStr )
397 : : {
398 : 3260 : RegisterObjectBar( nPos, rResId, 0UL, pStr );
399 : 3260 : }
400 : :
401 : :
402 : 4070 : void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr )
403 : : {
404 : 4070 : SfxObjectUI_Impl* pUI = CreateObjectBarUI_Impl( nPos, rResId, nFeature, pStr );
405 [ + - ]: 4070 : if ( pUI )
406 : 4070 : pImpData->pObjectBars->Append(pUI);
407 : 4070 : }
408 : :
409 : 4070 : SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr )
410 : : {
411 [ + + ]: 4070 : if ((nPos & SFX_VISIBILITY_MASK) == 0)
412 : 1708 : nPos |= SFX_VISIBILITY_STANDARD;
413 : :
414 : 4070 : SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(nPos, rResId, sal_True, nFeature);
415 : :
416 [ + - ]: 4070 : if (pStr == 0)
417 : : {
418 : 4070 : ResId aResId(rResId);
419 : 4070 : aResId.SetRT(RSC_STRING);
420 : 4070 : aResId.SetResMgr(rResId.GetResMgr());
421 [ - + ]: 4070 : if( ! aResId.GetResMgr() )
422 [ # # ][ # # ]: 0 : aResId.SetResMgr( SfxApplication::GetOrCreate()->GetOffResManager_Impl() );
423 [ + - ][ + - ]: 4070 : if ( !aResId.GetResMgr() || !aResId.GetResMgr()->IsAvailable(aResId) )
[ + + ][ + + ]
424 [ + - ][ + - ]: 1240 : pUI->pName = new String (DEFINE_CONST_UNICODE("NoName"));
425 : : else
426 [ + - ][ + - ]: 4070 : pUI->pName = new String(aResId.toString());
[ + - ]
427 : : }
428 : : else
429 [ # # ]: 0 : pUI->pName = new String(*pStr);
430 : :
431 : 4070 : return pUI;
432 : : }
433 : :
434 : 26099 : const ResId& SfxInterface::GetObjectBarResId( sal_uInt16 nNo ) const
435 : : {
436 [ + + ][ + + ]: 26099 : sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
437 [ + + ]: 26099 : if ( bGenoType )
438 : : {
439 : : // Are there toolbars in the super class?
440 : 6636 : sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
441 [ - + ]: 6636 : if ( nNo < nBaseCount )
442 : : // The Super class comes first
443 : 0 : return pGenoType->GetObjectBarResId( nNo );
444 : : else
445 : 6636 : nNo = nNo - nBaseCount;
446 : : }
447 : :
448 : : #ifdef DBG_UTIL
449 : : sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
450 : : DBG_ASSERT( nNo<nObjBarCount,"Objectbar is unknown!" );
451 : : #endif
452 : 26099 : return (*pImpData->pObjectBars)[nNo]->aResId;
453 : : }
454 : :
455 : : //--------------------------------------------------------------------
456 : :
457 : :
458 : 40123 : sal_uInt16 SfxInterface::GetObjectBarPos( sal_uInt16 nNo ) const
459 : : {
460 [ + + ][ + + ]: 40123 : sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
461 [ + + ]: 40123 : if ( bGenoType )
462 : : {
463 : : // Are there toolbars in the super class?
464 : 10361 : sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
465 [ - + ]: 10361 : if ( nNo < nBaseCount )
466 : : // The Super class comes first
467 : 0 : return pGenoType->GetObjectBarPos( nNo );
468 : : else
469 : 10361 : nNo = nNo - nBaseCount;
470 : : }
471 : :
472 : : #ifdef DBG_UTIL
473 : : sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
474 : : DBG_ASSERT( nNo<nObjBarCount,"Objectbar is unknown!" );
475 : : #endif
476 : 40123 : return (*pImpData->pObjectBars)[nNo]->nPos;
477 : : }
478 : :
479 : : //--------------------------------------------------------------------
480 : :
481 : :
482 : 142090 : sal_uInt16 SfxInterface::GetObjectBarCount() const
483 : : {
484 [ + + ][ + + ]: 142090 : if (pGenoType && ! pGenoType->HasName())
[ + + ]
485 : 28604 : return pImpData->pObjectBars->Count() + pGenoType->GetObjectBarCount();
486 : : else
487 : 142090 : return pImpData->pObjectBars->Count();
488 : : }
489 : :
490 : : //--------------------------------------------------------------------
491 : 7319 : void SfxInterface::RegisterChildWindow(sal_uInt16 nId, sal_Bool bContext, const String* pChildWinName)
492 : : {
493 : 7319 : RegisterChildWindow( nId, bContext, 0UL, pChildWinName );
494 : 7319 : }
495 : :
496 : 8140 : void SfxInterface::RegisterChildWindow(sal_uInt16 nId, sal_Bool bContext, sal_uInt32 nFeature, const String*)
497 : : {
498 [ + - ]: 8140 : SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(0, ResId(nId, *SfxApplication::GetOrCreate()->GetOffResManager_Impl()), sal_True, nFeature);
499 : 8140 : pUI->bContext = bContext;
500 : 8140 : pImpData->pChildWindows->Append(pUI);
501 : 8140 : }
502 : :
503 : 392 : void SfxInterface::RegisterStatusBar(const ResId& rResId)
504 : : {
505 : 392 : pImpData->aStatBarRes = rResId;
506 : 392 : }
507 : :
508 : :
509 : 182184 : sal_uInt32 SfxInterface::GetChildWindowId (sal_uInt16 nNo) const
510 : : {
511 [ + + ]: 182184 : if ( pGenoType )
512 : : {
513 : : // Are there ChildWindows in der Superklasse?
514 : 90404 : sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
515 [ + + ]: 90404 : if ( nNo < nBaseCount )
516 : : // The Super class comes first
517 : 14441 : return pGenoType->GetChildWindowId( nNo );
518 : : else
519 : 75963 : nNo = nNo - nBaseCount;
520 : : }
521 : :
522 : : #ifdef DBG_UTIL
523 : : sal_uInt16 nCWCount = pImpData->pChildWindows->Count();
524 : : DBG_ASSERT( nNo<nCWCount,"ChildWindow is unknown!" );
525 : : #endif
526 : 167743 : sal_uInt32 nRet = (*pImpData->pChildWindows)[nNo]->aResId.GetId();
527 [ + + ]: 167743 : if ( (*pImpData->pChildWindows)[nNo]->bContext )
528 : 4549 : nRet += sal_uInt32( nClassId ) << 16;
529 : 182184 : return nRet;
530 : : }
531 : :
532 : 181802 : sal_uInt32 SfxInterface::GetChildWindowFeature (sal_uInt16 nNo) const
533 : : {
534 [ + + ]: 181802 : if ( pGenoType )
535 : : {
536 : : // Are there ChildWindows in der Superklasse?
537 : 90134 : sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
538 [ + + ]: 90134 : if ( nNo < nBaseCount )
539 : : // The Super class comes first
540 : 14377 : return pGenoType->GetChildWindowFeature( nNo );
541 : : else
542 : 75757 : nNo = nNo - nBaseCount;
543 : : }
544 : :
545 : : #ifdef DBG_UTIL
546 : : sal_uInt16 nCWCount = pImpData->pChildWindows->Count();
547 : : DBG_ASSERT( nNo<nCWCount,"ChildWindow is unknown!" );
548 : : #endif
549 : 181802 : return (*pImpData->pChildWindows)[nNo]->nFeature;
550 : : }
551 : :
552 : : //--------------------------------------------------------------------
553 : :
554 : :
555 : 490519 : sal_uInt16 SfxInterface::GetChildWindowCount() const
556 : : {
557 [ + + ]: 490519 : if (pGenoType)
558 : 109471 : return pImpData->pChildWindows->Count() + pGenoType->GetChildWindowCount();
559 : : else
560 : 490519 : return pImpData->pChildWindows->Count();
561 : : }
562 : :
563 : :
564 : 0 : const ResId& SfxInterface::GetPopupMenuResId() const
565 : : {
566 : 0 : return pImpData->aPopupRes;
567 : : }
568 : :
569 : :
570 : 47341 : const ResId& SfxInterface::GetStatusBarResId() const
571 : : {
572 [ + + ][ + + ]: 47341 : if (pImpData->aStatBarRes.GetId() == 0 && pGenoType)
[ + + ]
573 : 14574 : return pGenoType->GetStatusBarResId();
574 : : else
575 : 47341 : return pImpData->aStatBarRes;
576 : : }
577 : :
578 : :
579 : :
580 : 26099 : const String* SfxInterface::GetObjectBarName ( sal_uInt16 nNo ) const
581 : : {
582 [ + + ][ + + ]: 26099 : sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
583 [ + + ]: 26099 : if ( bGenoType )
584 : : {
585 : : // Are there toolbars in the super class?
586 : 6636 : sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
587 [ - + ]: 6636 : if ( nNo < nBaseCount )
588 : : // The Super class comes first
589 : 0 : return pGenoType->GetObjectBarName( nNo );
590 : : else
591 : 6636 : nNo = nNo - nBaseCount;
592 : : }
593 : :
594 : : #ifdef DBG_UTIL
595 : : sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
596 : : DBG_ASSERT( nNo<nObjBarCount,"Objectbar is unknown!" );
597 : : #endif
598 : 26099 : return (*pImpData->pObjectBars)[nNo]->pName;
599 : : }
600 : :
601 : 40041 : sal_uInt32 SfxInterface::GetObjectBarFeature ( sal_uInt16 nNo ) const
602 : : {
603 [ + + ][ + + ]: 40041 : sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
604 [ + + ]: 40041 : if ( bGenoType )
605 : : {
606 : : // Are there toolbars in the super class?
607 : 10327 : sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
608 [ - + ]: 10327 : if ( nNo < nBaseCount )
609 : : // The Super class comes first
610 : 0 : return pGenoType->GetObjectBarFeature( nNo );
611 : : else
612 : 10327 : nNo = nNo - nBaseCount;
613 : : }
614 : :
615 : : #ifdef DBG_UTIL
616 : : sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
617 : : DBG_ASSERT( nNo<nObjBarCount,"Objectbar is unknown!" );
618 : : #endif
619 : 40041 : return (*pImpData->pObjectBars)[nNo]->nFeature;
620 : : }
621 : :
622 : 26099 : sal_Bool SfxInterface::IsObjectBarVisible(sal_uInt16 nNo) const
623 : : {
624 [ + + ][ + + ]: 26099 : sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
625 [ + + ]: 26099 : if ( bGenoType )
626 : : {
627 : : // Are there toolbars in the super class?
628 : 6636 : sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
629 [ - + ]: 6636 : if ( nNo < nBaseCount )
630 : : // The Super class comes first
631 : 0 : return pGenoType->IsObjectBarVisible( nNo );
632 : : else
633 : 6636 : nNo = nNo - nBaseCount;
634 : : }
635 : :
636 : : #ifdef DBG_UTIL
637 : : sal_uInt16 nObjBarCount = pImpData->pObjectBars->Count();
638 : : DBG_ASSERT( nNo<nObjBarCount,"Objectbar is unknown!" );
639 : : #endif
640 : 26099 : return (*pImpData->pObjectBars)[nNo]->bVisible;
641 : : }
642 : :
643 : 33892 : const SfxInterface* SfxInterface::GetRealInterfaceForSlot( const SfxSlot *pRealSlot ) const
644 : : {
645 : : DBG_ASSERT( pImpData->bRegistered, "Interface not registered!" );
646 : 33892 : const SfxInterface* pInterface = this;
647 : :
648 : : // The slot could also originate from the interface of a shell base class.
649 [ + - ]: 10522 : do
650 : : {
651 : 44414 : const SfxSlot *pLastSlot = (*pInterface)[pInterface->Count()-1];
652 : 44414 : const SfxSlot *pFirstSlot = (*pInterface)[0];
653 : :
654 : : // Is pInterface the Owner of pRealSlot ?
655 [ + + ][ + + ]: 44414 : if ( pFirstSlot <= pRealSlot && pRealSlot <= pLastSlot )
656 : 33892 : break;
657 : :
658 : : // Otherwise try the Interface of Super class
659 : 10522 : pInterface = pInterface->pGenoType;
660 : : }
661 : : while ( pInterface );
662 : :
663 : 33892 : return pInterface;
664 : : }
665 : :
666 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|