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

Generated by: LCOV version 1.10