LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/control - objface.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 156 224 69.6 %
Date: 2012-12-27 Functions: 29 37 78.4 %
Legend: Lines: hit not hit

          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     6519284 : SfxCompareSlots_Impl( const void* pSmaller, const void* pBigger )
      47             : {
      48     6519284 :     return ( (int) ((SfxSlot*)pSmaller)->GetSlotId() ) -
      49     6519284 :            ( (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        1415 :     SfxObjectUI_Impl(sal_uInt16 n, const ResId& rResId, sal_Bool bVis, sal_uInt32 nFeat) :
      64             :         nPos(n),
      65        1415 :         aResId(rResId.GetId(), *rResId.GetResMgr()),
      66             :         bVisible(bVis),
      67             :         bContext(sal_False),
      68             :         pName(0),
      69        2830 :         nFeature(nFeat)
      70             :     {
      71        1415 :         aResId.SetRT(rResId.GetRT());
      72        1415 :     }
      73             : 
      74           0 :     ~SfxObjectUI_Impl()
      75             :     {
      76           0 :         delete pName;
      77           0 :     }
      78             : };
      79             : 
      80       86742 : 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         607 :     SfxInterface_Impl() :
      92         607 :         aPopupRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager()),
      93         607 :         aStatBarRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager())
      94        1214 :     , bRegistered(sal_False)
      95             :     {
      96         607 :         pObjectBars   = new SfxObjectUIArr_Impl;
      97         607 :         pChildWindows = new SfxObjectUIArr_Impl;
      98         607 :     }
      99             : 
     100           0 :     ~SfxInterface_Impl()
     101             :     {
     102             :         sal_uInt16 n;
     103           0 :         for (n=0; n<pObjectBars->Count(); n++)
     104           0 :             delete (*pObjectBars)[n];
     105           0 :         delete pObjectBars;
     106             : 
     107           0 :         for (n=0; n<pChildWindows->Count(); n++)
     108           0 :             delete (*pChildWindows)[n];
     109           0 :         delete pChildWindows;
     110           0 :     }
     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         607 : 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         607 :     aNameResId(rNameResId.GetId(),*rNameResId.GetResMgr()),
     129        1214 :     pImpData(0)
     130             : {
     131         607 :     pImpData = new SfxInterface_Impl;
     132         607 :     SetSlotMap( rSlotMap, nSlotCount );
     133         607 : }
     134             : 
     135         607 : void SfxInterface::Register( SfxModule* pMod )
     136             : {
     137         607 :     pImpData->bRegistered = sal_True;
     138         607 :     pImpData->pModule = pMod;
     139         607 :     if ( pMod )
     140         458 :         pMod->GetSlotPool()->RegisterInterface(*this);
     141             :     else
     142         149 :         SFX_APP()->GetAppSlotPool_Impl().RegisterInterface(*this);
     143         607 : }
     144             : 
     145         607 : void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount )
     146             : {
     147         607 :     pSlots = &rSlotMap;
     148         607 :     nCount = nSlotCount;
     149         607 :     SfxSlot* pIter = pSlots;
     150         607 :     if ( 1 == nCount && !pIter->pNextSlot )
     151          93 :         pIter->pNextSlot = pIter;
     152             : 
     153         607 :     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         607 : }
     294             : 
     295             : //--------------------------------------------------------------------
     296             : 
     297           0 : SfxInterface::~SfxInterface()
     298             : {
     299           0 :     SfxModule *pMod = pImpData->pModule;
     300           0 :     sal_Bool bRegistered = pImpData->bRegistered;
     301           0 :     delete pImpData;
     302             :     DBG_ASSERT( bRegistered, "Interface not registered!" );
     303           0 :     if ( bRegistered )
     304             :     {
     305           0 :         if ( pMod )
     306           0 :             pMod->GetSlotPool()->ReleaseInterface(*this);
     307             :         else
     308           0 :             SFX_APP()->GetAppSlotPool_Impl().ReleaseInterface(*this);
     309             :     }
     310           0 : }
     311             : 
     312             : //--------------------------------------------------------------------
     313             : 
     314             : // searches for the specified func
     315             : 
     316     1345970 : 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     1345970 :                        SfxCompareSlots_Impl );
     324     1345970 :     if ( !p && pGenoType )
     325      732911 :         return pGenoType->GetSlot( nFuncId );
     326             : 
     327      613059 :     return p ? (const SfxSlot*)p : 0;
     328             : }
     329             : 
     330       21255 : const SfxSlot* SfxInterface::GetSlot( const String& rCommand ) const
     331             : {
     332             :     static const char UNO_COMMAND[] = ".uno:";
     333             : 
     334       21255 :     String aCommand( rCommand );
     335       21255 :     if ( aCommand.SearchAscii( UNO_COMMAND ) == 0 )
     336           0 :          aCommand.Erase( 0, sizeof( UNO_COMMAND )-1 );
     337             : 
     338      485704 :     for ( sal_uInt16 n=0; n<nCount; n++ )
     339             :     {
     340      932168 :         if ( (pSlots+n)->pUnoName &&
     341      466084 :              aCommand.CompareIgnoreCaseToAscii( (pSlots+n)->GetUnoName() ) == COMPARE_EQUAL )
     342        1635 :             return pSlots+n;
     343             :     }
     344             : 
     345       19620 :     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         278 : void SfxInterface::RegisterPopupMenu( const ResId& rResId )
     388             : {
     389             :     DBG_CHKTHIS(SfxInterface, 0);
     390         278 :     pImpData->aPopupRes = rResId;
     391         278 : }
     392             : 
     393             : //--------------------------------------------------------------------
     394             : 
     395         396 : void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId,
     396             :         const String *pStr )
     397             : {
     398         396 :     RegisterObjectBar( nPos, rResId, 0UL, pStr );
     399         396 : }
     400             : 
     401             : 
     402         504 : void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr )
     403             : {
     404         504 :     SfxObjectUI_Impl* pUI = CreateObjectBarUI_Impl( nPos, rResId, nFeature, pStr );
     405         504 :     if ( pUI )
     406         504 :         pImpData->pObjectBars->Append(pUI);
     407         504 : }
     408             : 
     409         504 : SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const String *pStr )
     410             : {
     411         504 :     if ((nPos & SFX_VISIBILITY_MASK) == 0)
     412         231 :         nPos |= SFX_VISIBILITY_STANDARD;
     413             : 
     414         504 :     SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(nPos, rResId, sal_True, nFeature);
     415             : 
     416         504 :     if (pStr == 0)
     417             :     {
     418         504 :         ResId aResId(rResId);
     419         504 :         aResId.SetRT(RSC_STRING);
     420         504 :         aResId.SetResMgr(rResId.GetResMgr());
     421         504 :         if( ! aResId.GetResMgr() )
     422           0 :             aResId.SetResMgr( SfxApplication::GetOrCreate()->GetOffResManager_Impl() );
     423         504 :         if ( !aResId.GetResMgr() || !aResId.GetResMgr()->IsAvailable(aResId) )
     424         153 :             pUI->pName = new String (DEFINE_CONST_UNICODE("NoName"));
     425             :         else
     426         351 :             pUI->pName = new String(aResId.toString());
     427             :     }
     428             :     else
     429           0 :         pUI->pName = new String(*pStr);
     430             : 
     431         504 :     return pUI;
     432             : }
     433             : 
     434        3253 : const ResId& SfxInterface::GetObjectBarResId( sal_uInt16 nNo ) const
     435             : {
     436        3253 :     sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     437        3253 :     if ( bGenoType )
     438             :     {
     439             :         // Are there toolbars in the super class?
     440         985 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     441         985 :         if ( nNo < nBaseCount )
     442             :             // The Super class comes first
     443           0 :             return pGenoType->GetObjectBarResId( nNo );
     444             :         else
     445         985 :             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        3253 :     return (*pImpData->pObjectBars)[nNo]->aResId;
     453             : }
     454             : 
     455             : //--------------------------------------------------------------------
     456             : 
     457             : 
     458        4927 : sal_uInt16 SfxInterface::GetObjectBarPos( sal_uInt16 nNo ) const
     459             : {
     460        4927 :     sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     461        4927 :     if ( bGenoType )
     462             :     {
     463             :         // Are there toolbars in the super class?
     464        1579 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     465        1579 :         if ( nNo < nBaseCount )
     466             :             // The Super class comes first
     467           0 :             return pGenoType->GetObjectBarPos( nNo );
     468             :         else
     469        1579 :             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        4927 :     return (*pImpData->pObjectBars)[nNo]->nPos;
     477             : }
     478             : 
     479             : //--------------------------------------------------------------------
     480             : 
     481             : 
     482       19233 : sal_uInt16 SfxInterface::GetObjectBarCount() const
     483             : {
     484       19233 :     if (pGenoType && ! pGenoType->HasName())
     485        4112 :         return pImpData->pObjectBars->Count() + pGenoType->GetObjectBarCount();
     486             :     else
     487       15121 :         return pImpData->pObjectBars->Count();
     488             : }
     489             : 
     490             : //--------------------------------------------------------------------
     491         801 : void SfxInterface::RegisterChildWindow(sal_uInt16 nId, sal_Bool bContext, const String* pChildWinName)
     492             : {
     493         801 :     RegisterChildWindow( nId, bContext, 0UL, pChildWinName );
     494         801 : }
     495             : 
     496         911 : void SfxInterface::RegisterChildWindow(sal_uInt16 nId, sal_Bool bContext, sal_uInt32 nFeature, const String*)
     497             : {
     498         911 :     SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(0, ResId(nId, *SfxApplication::GetOrCreate()->GetOffResManager_Impl()), sal_True, nFeature);
     499         911 :     pUI->bContext = bContext;
     500         911 :     pImpData->pChildWindows->Append(pUI);
     501         911 : }
     502             : 
     503          41 : void SfxInterface::RegisterStatusBar(const ResId& rResId)
     504             : {
     505          41 :     pImpData->aStatBarRes = rResId;
     506          41 : }
     507             : 
     508             : 
     509       23596 : sal_uInt32 SfxInterface::GetChildWindowId (sal_uInt16 nNo) const
     510             : {
     511       23596 :     if ( pGenoType )
     512             :     {
     513             :         // Are there ChildWindows in der Superklasse?
     514       12572 :         sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
     515       12572 :         if ( nNo < nBaseCount )
     516             :             // The Super class comes first
     517        2096 :             return pGenoType->GetChildWindowId( nNo );
     518             :         else
     519       10476 :             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       21500 :     sal_uInt32 nRet = (*pImpData->pChildWindows)[nNo]->aResId.GetId();
     527       21500 :     if ( (*pImpData->pChildWindows)[nNo]->bContext )
     528         594 :         nRet += sal_uInt32( nClassId ) << 16;
     529       21500 :     return nRet;
     530             : }
     531             : 
     532       23596 : sal_uInt32 SfxInterface::GetChildWindowFeature (sal_uInt16 nNo) const
     533             : {
     534       23596 :     if ( pGenoType )
     535             :     {
     536             :         // Are there ChildWindows in der Superklasse?
     537       12572 :         sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
     538       12572 :         if ( nNo < nBaseCount )
     539             :             // The Super class comes first
     540        2096 :             return pGenoType->GetChildWindowFeature( nNo );
     541             :         else
     542       10476 :             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       21500 :     return (*pImpData->pChildWindows)[nNo]->nFeature;
     550             : }
     551             : 
     552             : //--------------------------------------------------------------------
     553             : 
     554             : 
     555       65830 : sal_uInt16 SfxInterface::GetChildWindowCount() const
     556             : {
     557       65830 :     if (pGenoType)
     558       15105 :         return pImpData->pChildWindows->Count() + pGenoType->GetChildWindowCount();
     559             :     else
     560       50725 :         return pImpData->pChildWindows->Count();
     561             : }
     562             : 
     563             : 
     564           0 : const ResId& SfxInterface::GetPopupMenuResId() const
     565             : {
     566           0 :     return pImpData->aPopupRes;
     567             : }
     568             : 
     569             : 
     570        6020 : const ResId& SfxInterface::GetStatusBarResId() const
     571             : {
     572        6020 :     if (pImpData->aStatBarRes.GetId() == 0 && pGenoType)
     573        1939 :         return pGenoType->GetStatusBarResId();
     574             :     else
     575        4081 :         return pImpData->aStatBarRes;
     576             : }
     577             : 
     578             : 
     579             : 
     580        3253 : const String* SfxInterface::GetObjectBarName ( sal_uInt16 nNo ) const
     581             : {
     582        3253 :     sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     583        3253 :     if ( bGenoType )
     584             :     {
     585             :         // Are there toolbars in the super class?
     586         985 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     587         985 :         if ( nNo < nBaseCount )
     588             :             // The Super class comes first
     589           0 :             return pGenoType->GetObjectBarName( nNo );
     590             :         else
     591         985 :             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        3253 :     return (*pImpData->pObjectBars)[nNo]->pName;
     599             : }
     600             : 
     601        4927 : sal_uInt32 SfxInterface::GetObjectBarFeature ( sal_uInt16 nNo ) const
     602             : {
     603        4927 :     sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     604        4927 :     if ( bGenoType )
     605             :     {
     606             :         // Are there toolbars in the super class?
     607        1579 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     608        1579 :         if ( nNo < nBaseCount )
     609             :             // The Super class comes first
     610           0 :             return pGenoType->GetObjectBarFeature( nNo );
     611             :         else
     612        1579 :             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        4927 :     return (*pImpData->pObjectBars)[nNo]->nFeature;
     620             : }
     621             : 
     622        3253 : sal_Bool SfxInterface::IsObjectBarVisible(sal_uInt16 nNo) const
     623             : {
     624        3253 :     sal_Bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     625        3253 :     if ( bGenoType )
     626             :     {
     627             :         // Are there toolbars in the super class?
     628         985 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     629         985 :         if ( nNo < nBaseCount )
     630             :             // The Super class comes first
     631           0 :             return pGenoType->IsObjectBarVisible( nNo );
     632             :         else
     633         985 :             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        3253 :     return (*pImpData->pObjectBars)[nNo]->bVisible;
     641             : }
     642             : 
     643         104 : const SfxInterface* SfxInterface::GetRealInterfaceForSlot( const SfxSlot *pRealSlot ) const
     644             : {
     645             :     DBG_ASSERT( pImpData->bRegistered, "Interface not registered!" );
     646         104 :     const SfxInterface* pInterface = this;
     647             : 
     648             :     // The slot could also originate from the interface of a shell base class.
     649           0 :     do
     650             :     {
     651         104 :         const SfxSlot *pLastSlot  = (*pInterface)[pInterface->Count()-1];
     652         104 :         const SfxSlot *pFirstSlot = (*pInterface)[0];
     653             : 
     654             :         // Is pInterface the Owner of pRealSlot ?
     655         104 :         if ( pFirstSlot <= pRealSlot && pRealSlot <= pLastSlot )
     656         104 :             break;
     657             : 
     658             :         // Otherwise try the Interface of Super class
     659           0 :         pInterface = pInterface->pGenoType;
     660             :     }
     661             :     while ( pInterface );
     662             : 
     663         104 :     return pInterface;
     664             : }
     665             : 
     666             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10