LCOV - code coverage report
Current view: top level - sfx2/source/control - objface.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 175 220 79.5 %
Date: 2014-04-11 Functions: 30 33 90.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             : #include <assert.h>
      21             : #include <stdlib.h>
      22             : 
      23             : #include <sal/log.hxx>
      24             : 
      25             : #include <tools/rcid.h>
      26             : #include <tools/stream.hxx>
      27             : #include "tools/resmgr.hxx"
      28             : 
      29             : #include <sfx2/module.hxx>
      30             : #include <sfx2/objface.hxx>
      31             : #include <sfx2/msg.hxx>
      32             : #include <sfx2/app.hxx>
      33             : #include <sfx2/msgpool.hxx>
      34             : #include <sfx2/sfxresid.hxx>
      35             : #include <sfx2/objsh.hxx>
      36             : #include <rtl/strbuf.hxx>
      37             : 
      38             : extern "C"
      39             : #ifdef WNT
      40             : int _cdecl
      41             : #else
      42             : int
      43             : #endif
      44             : 
      45    45041972 : SfxCompareSlots_Impl( const void* pSmaller, const void* pBigger )
      46             : {
      47    90083944 :     return ( (int) ((SfxSlot*)pSmaller)->GetSlotId() ) -
      48    90083944 :            ( (int) ((SfxSlot*)pBigger)->GetSlotId() );
      49             : }
      50             : 
      51             : 
      52             : 
      53             : struct SfxObjectUI_Impl
      54             : {
      55             :     sal_uInt16  nPos;
      56             :     ResId       aResId;
      57             :     bool        bVisible;
      58             :     bool        bContext;
      59             :     OUString*   pName;
      60             :     sal_uInt32  nFeature;
      61             : 
      62        7512 :     SfxObjectUI_Impl(sal_uInt16 n, const ResId& rResId, bool bVis, sal_uInt32 nFeat) :
      63             :         nPos(n),
      64        7512 :         aResId(rResId.GetId(), *rResId.GetResMgr()),
      65             :         bVisible(bVis),
      66             :         bContext(false),
      67             :         pName(0),
      68       15024 :         nFeature(nFeat)
      69             :     {
      70        7512 :         aResId.SetRT(rResId.GetRT());
      71        7512 :     }
      72             : 
      73        3484 :     ~SfxObjectUI_Impl()
      74             :     {
      75        3484 :         delete pName;
      76        3484 :     }
      77             : };
      78             : 
      79             : typedef std::vector<SfxObjectUI_Impl*> SfxObjectUIArr_Impl;
      80             : 
      81             : struct SfxInterface_Impl
      82             : {
      83             :     SfxObjectUIArr_Impl     aObjectBars;    // registered ObjectBars
      84             :     SfxObjectUIArr_Impl     aChildWindows;  // registered ChildWindows
      85             :     ResId                   aPopupRes;      // registered PopupMenu
      86             :     ResId                   aStatBarRes;    // registered StatusBar
      87             :     SfxModule*              pModule;
      88             :     bool                    bRegistered;
      89             : 
      90        2928 :     SfxInterface_Impl() :
      91        2928 :         aPopupRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager()),
      92        2928 :         aStatBarRes(0,*SfxApplication::GetOrCreate()->GetSfxResManager())
      93             :     , pModule(NULL)
      94        8784 :     , bRegistered(false)
      95             :     {
      96        2928 :     }
      97             : 
      98        1376 :     ~SfxInterface_Impl()
      99        1376 :     {
     100        2390 :         for (SfxObjectUIArr_Impl::const_iterator it = aObjectBars.begin(); it != aObjectBars.end(); ++it)
     101        1014 :             delete *it;
     102             : 
     103        3846 :         for (SfxObjectUIArr_Impl::const_iterator it = aChildWindows.begin(); it != aChildWindows.end(); ++it)
     104        2470 :             delete *it;
     105        1376 :     }
     106             : };
     107             : 
     108             : static SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const OUString *pStr );
     109             : 
     110             : 
     111             : 
     112             : 
     113             : // constuctor, registeres a new unit
     114             : 
     115        2928 : SfxInterface::SfxInterface( const char *pClassName,
     116             :                             const ResId& rNameResId,
     117             :                             SfxInterfaceId nId,
     118             :                             const SfxInterface* pParent,
     119             :                             SfxSlot &rSlotMap, sal_uInt16 nSlotCount ):
     120             :     pName(pClassName),
     121             :     pGenoType(pParent),
     122             :     nClassId(nId),
     123        2928 :     aNameResId(rNameResId.GetId(),*rNameResId.GetResMgr()),
     124        5856 :     pImpData(0)
     125             : {
     126        2928 :     pImpData = new SfxInterface_Impl;
     127        2928 :     SetSlotMap( rSlotMap, nSlotCount );
     128        2928 : }
     129             : 
     130        2913 : void SfxInterface::Register( SfxModule* pMod )
     131             : {
     132        2913 :     pImpData->bRegistered = true;
     133        2913 :     pImpData->pModule = pMod;
     134        2913 :     if ( pMod )
     135        1976 :         pMod->GetSlotPool()->RegisterInterface(*this);
     136             :     else
     137         937 :         SFX_APP()->GetAppSlotPool_Impl().RegisterInterface(*this);
     138        2913 : }
     139             : 
     140        2928 : void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount )
     141             : {
     142        2928 :     pSlots = &rSlotMap;
     143        2928 :     nCount = nSlotCount;
     144        2928 :     SfxSlot* pIter = pSlots;
     145        2928 :     if ( 1 == nCount && !pIter->pNextSlot )
     146         482 :         pIter->pNextSlot = pIter;
     147             : 
     148        2928 :     if ( !pIter->pNextSlot )
     149             :     {
     150             :         // sort the SfxSlots by id
     151           0 :         qsort( pSlots, nCount, sizeof(SfxSlot), SfxCompareSlots_Impl );
     152             : 
     153             :         // link masters and slaves
     154           0 :         sal_uInt16 nIter = 1;
     155           0 :         for ( pIter = pSlots; nIter <= nCount; ++pIter, ++nIter )
     156             :         {
     157             : 
     158             :             assert( nIter == nCount ||
     159             :                     pIter->GetSlotId() != (pIter+1)->GetSlotId() );
     160             : 
     161             :             // every master refers to his first slave (ENUM),
     162             :             // all slaves refer to their master.
     163             :             // Slaves refer in a circle to the other slaves with the same master
     164           0 :             if ( pIter->GetKind() == SFX_KIND_ENUM )
     165             :             {
     166           0 :                 pIter->pLinkedSlot = GetSlot( pIter->nMasterSlotId );
     167             :                 assert( pIter->pLinkedSlot );
     168           0 :                 if ( !pIter->pLinkedSlot->pLinkedSlot )
     169           0 :                     ( (SfxSlot*) pIter->pLinkedSlot)->pLinkedSlot = pIter;
     170             : 
     171           0 :                 if ( 0 == pIter->GetNextSlot() )
     172             :                 {
     173           0 :                     SfxSlot *pLastSlot = pIter;
     174           0 :                     for ( sal_uInt16 n = nIter; n < Count(); ++n )
     175             :                     {
     176           0 :                         SfxSlot *pCurSlot = (pSlots+n);
     177           0 :                         if ( pCurSlot->nMasterSlotId == pIter->nMasterSlotId )
     178             :                         {
     179           0 :                             pLastSlot->pNextSlot = pCurSlot;
     180           0 :                             pLastSlot = pCurSlot;
     181             :                         }
     182             :                     }
     183           0 :                     pLastSlot->pNextSlot = pIter;
     184             :                 }
     185             :             }
     186           0 :             else if ( 0 == pIter->GetNextSlot() )
     187             :             {
     188             :                 // Slots refering in circle to the next with the same
     189             :                 // Status method.
     190           0 :                 SfxSlot *pLastSlot = pIter;
     191           0 :                 for ( sal_uInt16 n = nIter; n < Count(); ++n )
     192             :                 {
     193           0 :                     SfxSlot *pCurSlot = (pSlots+n);
     194           0 :                     if ( pCurSlot->GetStateFnc() == pIter->GetStateFnc() )
     195             :                     {
     196           0 :                         pLastSlot->pNextSlot = pCurSlot;
     197           0 :                         pLastSlot = pCurSlot;
     198             :                     }
     199             :                 }
     200           0 :                 pLastSlot->pNextSlot = pIter;
     201             :             }
     202             :         }
     203             :     }
     204             : #ifdef DBG_UTIL
     205             :     else
     206             :     {
     207             :         sal_uInt16 nIter = 1;
     208             :         for ( SfxSlot *pNext = pIter+1; nIter < nCount; ++pNext, ++nIter )
     209             :         {
     210             : 
     211             :             if ( pNext->GetSlotId() <= pIter->GetSlotId() )
     212             :                 SAL_WARN( "sfx.control", "Wrong order" );
     213             : 
     214             :             if ( pIter->GetKind() == SFX_KIND_ENUM )
     215             :             {
     216             :                 const SfxSlot *pMasterSlot = GetSlot(pIter->nMasterSlotId);
     217             :                 const SfxSlot *pFirstSlave = pMasterSlot->pLinkedSlot;
     218             :                 const SfxSlot *pSlave = pFirstSlave;
     219             :                 do
     220             :                 {
     221             :                     if ( pSlave->pLinkedSlot != pMasterSlot )
     222             :                     {
     223             :                         OStringBuffer aStr("Wrong Master/Slave- link: ");
     224             :                         aStr.append(static_cast<sal_Int32>(
     225             :                             pMasterSlot->GetSlotId()));
     226             :                         aStr.append(" , ");
     227             :                         aStr.append(static_cast<sal_Int32>(
     228             :                             pSlave->GetSlotId()));
     229             :                         SAL_WARN("sfx.control", aStr.getStr());
     230             :                     }
     231             : 
     232             :                     if ( pSlave->nMasterSlotId != pMasterSlot->GetSlotId() )
     233             :                     {
     234             :                         OStringBuffer aStr("Wrong Master/Slave-Ids: ");
     235             :                         aStr.append(static_cast<sal_Int32>(
     236             :                             pMasterSlot->GetSlotId()));
     237             :                         aStr.append(" , ");
     238             :                         aStr.append(static_cast<sal_Int32>(
     239             :                             pSlave->GetSlotId()));
     240             :                         SAL_WARN("sfx.control", aStr.getStr());
     241             :                     }
     242             : 
     243             :                     pSlave = pSlave->pNextSlot;
     244             :                 }
     245             :                 while ( pSlave != pFirstSlave );
     246             :             }
     247             :             else
     248             :             {
     249             :                 if ( pIter->pLinkedSlot )
     250             :                 {
     251             :                     if ( pIter->pLinkedSlot->GetKind() != SFX_KIND_ENUM )
     252             :                     {
     253             :                         OStringBuffer aStr("Slave is no enum: ");
     254             :                         aStr.append(static_cast<sal_Int32>(pIter->GetSlotId()));
     255             :                         aStr.append(" , ");
     256             :                         aStr.append(static_cast<sal_Int32>(
     257             :                             pIter->pLinkedSlot->GetSlotId()));
     258             :                         SAL_WARN("sfx.control", aStr.getStr());
     259             :                     }
     260             :                 }
     261             : 
     262             :                 const SfxSlot *pCurSlot = pIter;
     263             :                 do
     264             :                 {
     265             :                     pCurSlot = pCurSlot->pNextSlot;
     266             :                     if ( pCurSlot->GetStateFnc() != pIter->GetStateFnc() )
     267             :                     {
     268             :                         OStringBuffer aStr("Linked Slots with different State Methods : ");
     269             :                         aStr.append(static_cast<sal_Int32>(
     270             :                             pCurSlot->GetSlotId()));
     271             :                         aStr.append(" , ");
     272             :                         aStr.append(static_cast<sal_Int32>(pIter->GetSlotId()));
     273             :                         SAL_WARN("sfx.control", aStr.getStr());
     274             :                     }
     275             :                 }
     276             :                 while ( pCurSlot != pIter );
     277             :             }
     278             : 
     279             :             pIter = pNext;
     280             :         }
     281             :     }
     282             : #endif
     283        2928 : }
     284             : 
     285             : 
     286             : 
     287        2752 : SfxInterface::~SfxInterface()
     288             : {
     289        1376 :     SfxModule *pMod = pImpData->pModule;
     290        1376 :     bool bRegistered = pImpData->bRegistered;
     291        1376 :     delete pImpData;
     292             :     assert( bRegistered );
     293        1376 :     if ( bRegistered )
     294             :     {
     295        1376 :         if ( pMod )
     296         871 :             pMod->GetSlotPool()->ReleaseInterface(*this);
     297             :         else
     298         505 :             SFX_APP()->GetAppSlotPool_Impl().ReleaseInterface(*this);
     299             :     }
     300        2752 : }
     301             : 
     302             : 
     303             : 
     304             : // searches for the specified func
     305             : 
     306     9244233 : const SfxSlot* SfxInterface::GetSlot( sal_uInt16 nFuncId ) const
     307             : {
     308             : 
     309             :     assert( pSlots );
     310             :     assert( nCount );
     311             : 
     312             :     // find the id using binary search
     313             :     void* p = bsearch( &nFuncId, pSlots, nCount, sizeof(SfxSlot),
     314     9244233 :                        SfxCompareSlots_Impl );
     315     9244233 :     if ( !p && pGenoType )
     316     4669671 :         return pGenoType->GetSlot( nFuncId );
     317             : 
     318     4574562 :     return p ? (const SfxSlot*)p : 0;
     319             : }
     320             : 
     321     4071441 : const SfxSlot* SfxInterface::GetSlot( const OUString& rCommand ) const
     322             : {
     323             :     static const char UNO_COMMAND[] = ".uno:";
     324             : 
     325     4071441 :     OUString aCommand( rCommand );
     326     4071441 :     if ( aCommand.startsWith( UNO_COMMAND ) )
     327        2243 :          aCommand = aCommand.copy( sizeof( UNO_COMMAND )-1 );
     328             : 
     329   179837699 :     for ( sal_uInt16 n=0; n<nCount; n++ )
     330             :     {
     331   351989732 :         if ( (pSlots+n)->pUnoName &&
     332   175990326 :              aCommand.compareToIgnoreAsciiCaseAscii( (pSlots+n)->GetUnoName() ) == 0 )
     333      233148 :             return pSlots+n;
     334             :     }
     335             : 
     336     3838293 :     return pGenoType ? pGenoType->GetSlot( aCommand ) : NULL;
     337             : }
     338             : 
     339             : 
     340             : 
     341           0 : const SfxSlot* SfxInterface::GetRealSlot( const SfxSlot *pSlot ) const
     342             : {
     343             : 
     344             :     assert( pSlots );
     345             :     assert( nCount );
     346             : 
     347           0 :     if ( !ContainsSlot_Impl(pSlot) )
     348             :     {
     349           0 :         if(pGenoType)
     350           0 :             return pGenoType->GetRealSlot(pSlot);
     351             :         SAL_WARN( "sfx.control", "unknown Slot" );
     352           0 :         return 0;
     353             :     }
     354             : 
     355           0 :     return pSlot->pLinkedSlot;
     356             : }
     357             : 
     358             : 
     359             : 
     360           0 : const SfxSlot* SfxInterface::GetRealSlot( sal_uInt16 nSlotId ) const
     361             : {
     362             : 
     363             :     assert( pSlots );
     364             :     assert( nCount );
     365             : 
     366           0 :     const SfxSlot *pSlot = GetSlot(nSlotId);
     367           0 :     if ( !pSlot )
     368             :     {
     369           0 :         if(pGenoType)
     370           0 :             return pGenoType->GetRealSlot(nSlotId);
     371             :         SAL_WARN( "sfx.control", "unknown Slot" );
     372           0 :         return 0;
     373             :     }
     374             : 
     375           0 :     return pSlot->pLinkedSlot;
     376             : }
     377             : 
     378             : 
     379             : 
     380        1211 : void SfxInterface::RegisterPopupMenu( const ResId& rResId )
     381             : {
     382             : 
     383        1211 :     pImpData->aPopupRes = rResId;
     384        1211 : }
     385             : 
     386             : 
     387             : 
     388        1835 : void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId,
     389             :         const OUString *pStr )
     390             : {
     391        1835 :     RegisterObjectBar( nPos, rResId, 0UL, pStr );
     392        1835 : }
     393             : 
     394             : 
     395        2279 : void SfxInterface::RegisterObjectBar( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const OUString *pStr )
     396             : {
     397        2279 :     SfxObjectUI_Impl* pUI = CreateObjectBarUI_Impl( nPos, rResId, nFeature, pStr );
     398        2279 :     if ( pUI )
     399        2279 :         pImpData->aObjectBars.push_back(pUI);
     400        2279 : }
     401             : 
     402        2279 : SfxObjectUI_Impl* CreateObjectBarUI_Impl( sal_uInt16 nPos, const ResId& rResId, sal_uInt32 nFeature, const OUString *pStr )
     403             : {
     404        2279 :     if ((nPos & SFX_VISIBILITY_MASK) == 0)
     405         885 :         nPos |= SFX_VISIBILITY_STANDARD;
     406             : 
     407        2279 :     SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(nPos, rResId, true, nFeature);
     408             : 
     409        2279 :     if (pStr == 0)
     410             :     {
     411        2279 :         ResId aResId(rResId);
     412        2279 :         aResId.SetRT(RSC_STRING);
     413        2279 :         aResId.SetResMgr(rResId.GetResMgr());
     414        2279 :         if( ! aResId.GetResMgr() )
     415           0 :             aResId.SetResMgr( SfxApplication::GetOrCreate()->GetOffResManager_Impl() );
     416        2279 :         if ( !aResId.GetResMgr() || !aResId.GetResMgr()->IsAvailable(aResId) )
     417         719 :             pUI->pName = new OUString ("NoName");
     418             :         else
     419        1560 :             pUI->pName = new OUString(aResId.toString());
     420             :     }
     421             :     else
     422           0 :         pUI->pName = new OUString(*pStr);
     423             : 
     424        2279 :     return pUI;
     425             : }
     426             : 
     427       25159 : const ResId& SfxInterface::GetObjectBarResId( sal_uInt16 nNo ) const
     428             : {
     429       25159 :     bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     430       25159 :     if ( bGenoType )
     431             :     {
     432             :         // Are there toolbars in the super class?
     433        6828 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     434        6828 :         if ( nNo < nBaseCount )
     435             :             // The Super class comes first
     436           0 :             return pGenoType->GetObjectBarResId( nNo );
     437             :         else
     438        6828 :             nNo = nNo - nBaseCount;
     439             :     }
     440             : 
     441             :     assert( nNo<pImpData->aObjectBars.size() );
     442             : 
     443       25159 :     return pImpData->aObjectBars[nNo]->aResId;
     444             : }
     445             : 
     446             : 
     447             : 
     448             : 
     449       38205 : sal_uInt16 SfxInterface::GetObjectBarPos( sal_uInt16 nNo ) const
     450             : {
     451       38205 :     bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     452       38205 :     if ( bGenoType )
     453             :     {
     454             :         // Are there toolbars in the super class?
     455       10752 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     456       10752 :         if ( nNo < nBaseCount )
     457             :             // The Super class comes first
     458           0 :             return pGenoType->GetObjectBarPos( nNo );
     459             :         else
     460       10752 :             nNo = nNo - nBaseCount;
     461             :     }
     462             : 
     463             :     assert( nNo<pImpData->aObjectBars.size() );
     464             : 
     465       38205 :     return pImpData->aObjectBars[nNo]->nPos;
     466             : }
     467             : 
     468             : 
     469             : 
     470             : 
     471      140574 : sal_uInt16 SfxInterface::GetObjectBarCount() const
     472             : {
     473      140574 :     if (pGenoType && ! pGenoType->HasName())
     474       28813 :         return pImpData->aObjectBars.size() + pGenoType->GetObjectBarCount();
     475             :     else
     476      111761 :         return pImpData->aObjectBars.size();
     477             : }
     478             : 
     479             : 
     480        4789 : void SfxInterface::RegisterChildWindow(sal_uInt16 nId, bool bContext, const OUString* pChildWinName)
     481             : {
     482        4789 :     RegisterChildWindow( nId, bContext, 0UL, pChildWinName );
     483        4789 : }
     484             : 
     485        5233 : void SfxInterface::RegisterChildWindow(sal_uInt16 nId, bool bContext, sal_uInt32 nFeature, const OUString*)
     486             : {
     487        5233 :     SfxObjectUI_Impl* pUI = new SfxObjectUI_Impl(0, ResId(nId, *SfxApplication::GetOrCreate()->GetOffResManager_Impl()), true, nFeature);
     488        5233 :     pUI->bContext = bContext;
     489        5233 :     pImpData->aChildWindows.push_back(pUI);
     490        5233 : }
     491             : 
     492         239 : void SfxInterface::RegisterStatusBar(const ResId& rResId)
     493             : {
     494         239 :     pImpData->aStatBarRes = rResId;
     495         239 : }
     496             : 
     497             : 
     498      177619 : sal_uInt32 SfxInterface::GetChildWindowId (sal_uInt16 nNo) const
     499             : {
     500      177619 :     if ( pGenoType )
     501             :     {
     502             :         // Are there ChildWindows in der Superklasse?
     503       95392 :         sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
     504       95392 :         if ( nNo < nBaseCount )
     505             :             // The Super class comes first
     506        9404 :             return pGenoType->GetChildWindowId( nNo );
     507             :         else
     508       85988 :             nNo = nNo - nBaseCount;
     509             :     }
     510             : 
     511             :     assert( nNo<pImpData->aChildWindows.size() );
     512             : 
     513      168215 :     sal_uInt32 nRet = pImpData->aChildWindows[nNo]->aResId.GetId();
     514      168215 :     if ( pImpData->aChildWindows[nNo]->bContext )
     515        4568 :         nRet += sal_uInt32( nClassId ) << 16;
     516      168215 :     return nRet;
     517             : }
     518             : 
     519      177520 : sal_uInt32 SfxInterface::GetChildWindowFeature (sal_uInt16 nNo) const
     520             : {
     521      177520 :     if ( pGenoType )
     522             :     {
     523             :         // Are there ChildWindows in der Superklasse?
     524       95321 :         sal_uInt16 nBaseCount = pGenoType->GetChildWindowCount();
     525       95321 :         if ( nNo < nBaseCount )
     526             :             // The Super class comes first
     527        9388 :             return pGenoType->GetChildWindowFeature( nNo );
     528             :         else
     529       85933 :             nNo = nNo - nBaseCount;
     530             :     }
     531             : 
     532             :     assert( nNo<pImpData->aChildWindows.size() );
     533             : 
     534      168132 :     return pImpData->aChildWindows[nNo]->nFeature;
     535             : }
     536             : 
     537             : 
     538             : 
     539             : 
     540      504600 : sal_uInt16 SfxInterface::GetChildWindowCount() const
     541             : {
     542      504600 :     if (pGenoType)
     543      114095 :         return pImpData->aChildWindows.size() + pGenoType->GetChildWindowCount();
     544             :     else
     545      390505 :         return pImpData->aChildWindows.size();
     546             : }
     547             : 
     548             : 
     549           0 : const ResId& SfxInterface::GetPopupMenuResId() const
     550             : {
     551           0 :     return pImpData->aPopupRes;
     552             : }
     553             : 
     554             : 
     555       45932 : const ResId& SfxInterface::GetStatusBarResId() const
     556             : {
     557       45932 :     if (pImpData->aStatBarRes.GetId() == 0 && pGenoType)
     558       14355 :         return pGenoType->GetStatusBarResId();
     559             :     else
     560       31577 :         return pImpData->aStatBarRes;
     561             : }
     562             : 
     563             : 
     564             : 
     565       25159 : const OUString* SfxInterface::GetObjectBarName ( sal_uInt16 nNo ) const
     566             : {
     567       25159 :     bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     568       25159 :     if ( bGenoType )
     569             :     {
     570             :         // Are there toolbars in the super class?
     571        6828 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     572        6828 :         if ( nNo < nBaseCount )
     573             :             // The Super class comes first
     574           0 :             return pGenoType->GetObjectBarName( nNo );
     575             :         else
     576        6828 :             nNo = nNo - nBaseCount;
     577             :     }
     578             : 
     579             :     assert( nNo<pImpData->aObjectBars.size() );
     580             : 
     581       25159 :     return pImpData->aObjectBars[nNo]->pName;
     582             : }
     583             : 
     584       38184 : sal_uInt32 SfxInterface::GetObjectBarFeature ( sal_uInt16 nNo ) const
     585             : {
     586       38184 :     bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     587       38184 :     if ( bGenoType )
     588             :     {
     589             :         // Are there toolbars in the super class?
     590       10743 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     591       10743 :         if ( nNo < nBaseCount )
     592             :             // The Super class comes first
     593           0 :             return pGenoType->GetObjectBarFeature( nNo );
     594             :         else
     595       10743 :             nNo = nNo - nBaseCount;
     596             :     }
     597             : 
     598             :     assert( nNo<pImpData->aObjectBars.size() );
     599             : 
     600       38184 :     return pImpData->aObjectBars[nNo]->nFeature;
     601             : }
     602             : 
     603       25159 : bool SfxInterface::IsObjectBarVisible(sal_uInt16 nNo) const
     604             : {
     605       25159 :     bool bGenoType = (pGenoType != 0 && !pGenoType->HasName());
     606       25159 :     if ( bGenoType )
     607             :     {
     608             :         // Are there toolbars in the super class?
     609        6828 :         sal_uInt16 nBaseCount = pGenoType->GetObjectBarCount();
     610        6828 :         if ( nNo < nBaseCount )
     611             :             // The Super class comes first
     612           0 :             return pGenoType->IsObjectBarVisible( nNo );
     613             :         else
     614        6828 :             nNo = nNo - nBaseCount;
     615             :     }
     616             : 
     617             :     assert( nNo<pImpData->aObjectBars.size() );
     618             : 
     619       25159 :     return pImpData->aObjectBars[nNo]->bVisible;
     620             : }
     621             : 
     622       14925 : const SfxInterface* SfxInterface::GetRealInterfaceForSlot( const SfxSlot *pRealSlot ) const
     623             : {
     624             :     SAL_WARN_IF( !pImpData->bRegistered, "sfx.control", "Interface not registered" );
     625             : 
     626       14925 :     const SfxInterface* pInterface = this;
     627             : 
     628             :     // The slot could also originate from the interface of a shell base class.
     629        4471 :     do
     630             :     {
     631       19396 :         const SfxSlot *pLastSlot  = (*pInterface)[pInterface->Count()-1];
     632       19396 :         const SfxSlot *pFirstSlot = (*pInterface)[0];
     633             : 
     634             :         // Is pInterface the Owner of pRealSlot ?
     635       19396 :         if ( pFirstSlot <= pRealSlot && pRealSlot <= pLastSlot )
     636       14925 :             break;
     637             : 
     638             :         // Otherwise try the Interface of Super class
     639        4471 :         pInterface = pInterface->pGenoType;
     640             :     }
     641             :     while ( pInterface );
     642             : 
     643       14925 :     return pInterface;
     644             : }
     645             : 
     646             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10