LCOV - code coverage report
Current view: top level - svl/source/items - itempool.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 320 351 91.2 %
Date: 2014-04-11 Functions: 37 38 97.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 <string.h>
      22             : #include <stdio.h>
      23             : 
      24             : #include <svl/itempool.hxx>
      25             : #include "whassert.hxx"
      26             : #include <svl/brdcst.hxx>
      27             : #include <svl/smplhint.hxx>
      28             : #include "poolio.hxx"
      29             : 
      30             : 
      31             : #if OSL_DEBUG_LEVEL > 0
      32             : #include <map>
      33             : 
      34             : static void
      35             : lcl_CheckSlots2(std::map<sal_uInt16, sal_uInt16> & rSlotMap,
      36             :         SfxItemPool const& rPool, SfxItemInfo const* pInfos)
      37             : {
      38             :     if (!pInfos)
      39             :         return; // may not be initialized yet
      40             :     if (rPool.GetName() == "EditEngineItemPool")
      41             :         return; // HACK: this one has loads of duplicates already, ignore it :(
      42             :     sal_uInt16 const nFirst(rPool.GetFirstWhich());
      43             :     sal_uInt16 const nCount(rPool.GetLastWhich() - rPool.GetFirstWhich() + 1);
      44             :     for (sal_uInt16 n = 0; n < nCount; ++n)
      45             :     {
      46             :         sal_uInt16 const nSlotId(pInfos[n]._nSID);
      47             :         if (nSlotId != 0
      48             :             && nSlotId != 10883  // preexisting duplicate SID_ATTR_GRAF_CROP
      49             :             && nSlotId != 10024) // preexisting duplicate SID_ATTR_BORDER_OUTER
      50             :         {   // check for duplicate slot-id mapping
      51             :             std::map<sal_uInt16, sal_uInt16>::const_iterator const iter(
      52             :                 rSlotMap.find(nSlotId));
      53             :             sal_uInt16 const nWhich(nFirst + n);
      54             :             if (iter != rSlotMap.end())
      55             :             {
      56             :                 SAL_WARN("svl", "SfxItemPool: duplicate SlotId " << nSlotId
      57             :                         << " mapped to " << iter->second << " and " << nWhich);
      58             :                 assert(false);
      59             :             }
      60             :             rSlotMap.insert(std::make_pair(nSlotId, nWhich));
      61             :         }
      62             :     }
      63             : }
      64             : 
      65             : #define CHECK_SLOTS() \
      66             : do { \
      67             :     std::map<sal_uInt16, sal_uInt16> slotmap; \
      68             :     for (SfxItemPool * p = pImp->mpMaster; p; p = p->pImp->mpSecondary) \
      69             :     { \
      70             :         lcl_CheckSlots2(slotmap, *p, p->pItemInfos); \
      71             :     } \
      72             : } while (false)
      73             : 
      74             : #else
      75             : #define CHECK_SLOTS() do {} while (false)
      76             : #endif
      77             : 
      78             : 
      79      132083 : void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser)
      80             : {
      81      132083 :     pImp->maSfxItemPoolUsers.push_back(&rNewUser);
      82      132083 : }
      83             : 
      84      129848 : void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser)
      85             : {
      86             :     const std::vector<SfxItemPoolUser*>::iterator aFindResult = ::std::find(
      87      129848 :         pImp->maSfxItemPoolUsers.begin(), pImp->maSfxItemPoolUsers.end(), &rOldUser);
      88      129848 :     if(aFindResult != pImp->maSfxItemPoolUsers.end())
      89             :     {
      90      129848 :         pImp->maSfxItemPoolUsers.erase(aFindResult);
      91             :     }
      92      129848 : }
      93             : 
      94      189043 : const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const
      95             : {
      96             :     const SfxPoolItem* pRet;
      97      189043 :     if( IsInRange( nWhich ) )
      98      184522 :         pRet = *(pImp->ppPoolDefaults + GetIndex_Impl( nWhich ));
      99        4521 :     else if( pImp->mpSecondary )
     100        4521 :         pRet = pImp->mpSecondary->GetPoolDefaultItem( nWhich );
     101             :     else
     102             :     {
     103             :         SFX_ASSERT( false, nWhich, "unknown Which-Id - cannot get pool default" );
     104           0 :         pRet = 0;
     105             :     }
     106      189043 :     return pRet;
     107             : }
     108             : 
     109             : 
     110             : 
     111    43221908 : bool SfxItemPool::IsItemFlag_Impl( sal_uInt16 nPos, sal_uInt16 nFlag ) const
     112             : {
     113    43221908 :     sal_uInt16 nItemFlag = pItemInfos[nPos]._nFlags;
     114    43221908 :     return nFlag == (nItemFlag & nFlag);
     115             : }
     116             : 
     117             : 
     118             : 
     119     9058559 : bool SfxItemPool::IsItemFlag( sal_uInt16 nWhich, sal_uInt16 nFlag ) const
     120             : {
     121    14059114 :     for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
     122             :     {
     123    13512104 :         if ( pPool->IsInRange(nWhich) )
     124     8511549 :             return pPool->IsItemFlag_Impl( pPool->GetIndex_Impl(nWhich), nFlag);
     125             :     }
     126             :     DBG_ASSERT( !IsWhich(nWhich), "unknown which-id" );
     127      547010 :     return false;
     128             : }
     129             : 
     130             : 
     131             : 
     132        3664 : SfxBroadcaster& SfxItemPool::BC()
     133             : {
     134        3664 :     return pImp->aBC;
     135             : }
     136             : 
     137             : 
     138             : 
     139             : 
     140       39829 : SfxItemPool::SfxItemPool
     141             : (
     142             :     const OUString& rName,          /* Name des Pools zur Idetifikation
     143             :                                            im File-Format */
     144             :     sal_uInt16          nStartWhich,    /* erste Which-Id des Pools */
     145             :     sal_uInt16          nEndWhich,      /* letzte Which-Id des Pools */
     146             :     const SfxItemInfo*  pInfos,         /* SID-Map und Item-Flags */
     147             :     SfxPoolItem**       pDefaults,      /* Pointer auf statische Defaults,
     148             :                                            wird direkt vom Pool referenziert,
     149             :                                            jedoch kein Eigent"umer"ubergang */
     150             :     bool                bLoadRefCounts  /* Ref-Counts mitladen oder auf 1 setzen */
     151             : ) :
     152             : 
     153             : /*  [Beschreibung]
     154             : 
     155             :     Der im Normalfall verwendete Konstruktor der Klasse SfxItemPool. Es
     156             :     wird eine SfxItemPool-Instanz initialisiert, die Items im b"undigen
     157             :     Which-Bereich von 'nStartWhich' bis 'nEndWhich' verwalten kann.
     158             : 
     159             :     F"ur jede dieser Which-Ids mu\s ein statischer Default im Array 'pDefaults'
     160             :     vorhanden sein, die dort beginnend mit einem <SfxPoolItem> mit der
     161             :     Which-Id 'nStartWhich' nach Which-Ids sortiert aufeinanderfolgend
     162             :     eingetragen sein m"ussen.
     163             : 
     164             :     'pItemInfos' ist ein identisch angeordnetes Array von USHORTs, die
     165             :     Slot-Ids darstellen und Flags. Die Slot-Ids k"onnen 0 sein, wenn die
     166             :     betreffenden Items ausschlie\slich in der Core verwendet werden.
     167             :     "Uber die Flags kann z.B. bestimmt werden, ob Value-Sharing
     168             :     (SFX_ITEM_POOLABLE) stattfinden soll.
     169             : 
     170             :     [Anmerkung]
     171             : 
     172             :     Wenn der Pool <SfxSetItem>s enthalten soll, k"onnen im Konstruktor noch
     173             :     keine static-Defaults angegeben werden. Dies mu\s dann nachtr"aglich
     174             :     mit <SfxItemPool::SetDefaults(SfxItemPool**)> geschehen.
     175             : 
     176             : 
     177             :     [Querverweise]
     178             : 
     179             :     <SfxItemPool::SetDefaults(SfxItemPool**)>
     180             :     <SfxItemPool::ReleaseDefaults(SfxPoolItem**,sal_uInt16,sal_Bool)>
     181             :     <SfxItemPool::ReldaseDefaults(sal_Bool)>
     182             : */
     183             : 
     184             :     pItemInfos(pInfos),
     185       39829 :     pImp( new SfxItemPool_Impl( this, rName, nStartWhich, nEndWhich ) )
     186             : {
     187       39829 :     pImp->eDefMetric = SFX_MAPUNIT_TWIP;
     188       39829 :     pImp->nVersion = 0;
     189       39829 :     pImp->bStreaming = false;
     190       39829 :     pImp->nLoadingVersion = 0;
     191       39829 :     pImp->nInitRefCount = 1;
     192       39829 :     pImp->nVerStart = pImp->mnStart;
     193       39829 :     pImp->nVerEnd = pImp->mnEnd;
     194       39829 :     pImp->bInSetItem = false;
     195       39829 :     pImp->nStoringStart = nStartWhich;
     196       39829 :     pImp->nStoringEnd = nEndWhich;
     197       39829 :     pImp->mbPersistentRefCounts = bLoadRefCounts;
     198             : 
     199       39829 :     if ( pDefaults )
     200        1892 :         SetDefaults(pDefaults);
     201       39829 : }
     202             : 
     203             : 
     204             : 
     205             : 
     206          37 : SfxItemPool::SfxItemPool
     207             : (
     208             :     const SfxItemPool&  rPool,                  //  von dieser Instanz kopieren
     209             :     bool                bCloneStaticDefaults    /*  sal_True
     210             :                                                     statische Defaults kopieren
     211             : 
     212             :                                                     sal_False
     213             :                                                     statische Defaults
     214             :                                                     "ubernehehmen */
     215             : ) :
     216             : 
     217             : /*  [Beschreibung]
     218             : 
     219             :     Copy-Konstruktor der Klasse SfxItemPool.
     220             : 
     221             : 
     222             :     [Querverweise]
     223             : 
     224             :     <SfxItemPool::Clone()const>
     225             : */
     226             : 
     227             :     pItemInfos(rPool.pItemInfos),
     228          37 :     pImp( new SfxItemPool_Impl( this, rPool.pImp->aName, rPool.pImp->mnStart, rPool.pImp->mnEnd ) )
     229             : {
     230          37 :     pImp->eDefMetric = rPool.pImp->eDefMetric;
     231          37 :     pImp->nVersion = rPool.pImp->nVersion;
     232          37 :     pImp->bStreaming = false;
     233          37 :     pImp->nLoadingVersion = 0;
     234          37 :     pImp->nInitRefCount = 1;
     235          37 :     pImp->nVerStart = rPool.pImp->nVerStart;
     236          37 :     pImp->nVerEnd = rPool.pImp->nVerEnd;
     237          37 :     pImp->bInSetItem = false;
     238          37 :     pImp->nStoringStart = pImp->mnStart;
     239          37 :     pImp->nStoringEnd = pImp->mnEnd;
     240          37 :     pImp->mbPersistentRefCounts = rPool.pImp->mbPersistentRefCounts;
     241             : 
     242             :     // Static Defaults "ubernehmen
     243          37 :     if ( bCloneStaticDefaults )
     244             :     {
     245           0 :         SfxPoolItem **ppDefaults = new SfxPoolItem*[pImp->mnEnd-pImp->mnStart+1];
     246           0 :         for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n )
     247             :         {
     248           0 :             (*( ppDefaults + n )) = (*( rPool.pImp->ppStaticDefaults + n ))->Clone(this);
     249           0 :             (*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
     250             :         }
     251             : 
     252           0 :         SetDefaults( ppDefaults );
     253             :     }
     254             :     else
     255          37 :         SetDefaults( rPool.pImp->ppStaticDefaults );
     256             : 
     257             :     // Pool Defaults kopieren
     258        2035 :     for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n )
     259        1998 :         if ( (*( rPool.pImp->ppPoolDefaults + n )) )
     260             :         {
     261           0 :             (*( pImp->ppPoolDefaults + n )) = (*( rPool.pImp->ppPoolDefaults + n ))->Clone(this);
     262           0 :             (*( pImp->ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT );
     263             :         }
     264             : 
     265             :     // Copy Version-Map
     266         259 :     for ( size_t nVer = 0; nVer < rPool.pImp->aVersions.size(); ++nVer )
     267             :     {
     268         222 :         const SfxPoolVersion_ImplPtr pOld = rPool.pImp->aVersions[nVer];
     269         444 :         SfxPoolVersion_ImplPtr pNew = SfxPoolVersion_ImplPtr( new SfxPoolVersion_Impl( *pOld ) );
     270         222 :         pImp->aVersions.push_back( pNew );
     271         222 :     }
     272             : 
     273             :     // Verkettung wiederherstellen
     274          37 :     if ( rPool.pImp->mpSecondary )
     275           0 :         SetSecondaryPool( rPool.pImp->mpSecondary->Clone() );
     276          37 : }
     277             : 
     278             : 
     279             : 
     280       39866 : void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults )
     281             : {
     282             :     DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." );
     283             :     DBG_ASSERT( !pImp->ppStaticDefaults, "habe schon defaults" );
     284             : 
     285       39866 :     pImp->ppStaticDefaults = pDefaults;
     286             :     //! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT )
     287             :     //! geht wohl nicht im Zshg mit SetItems, die hinten stehen
     288             :     {
     289             :         DBG_ASSERT( (*pImp->ppStaticDefaults)->GetRefCount() == 0 ||
     290             :                     IsDefaultItem( (*pImp->ppStaticDefaults) ),
     291             :                     "das sind keine statics" );
     292     2929640 :         for ( sal_uInt16 n = 0; n <= pImp->mnEnd - pImp->mnStart; ++n )
     293             :         {
     294             :             SFX_ASSERT( (*( pImp->ppStaticDefaults + n ))->Which() == n + pImp->mnStart,
     295             :                         n + pImp->mnStart, "static defaults not sorted" );
     296     2889774 :             (*( pImp->ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT );
     297             :             DBG_ASSERT( !(pImp->maPoolItems[n]), "defaults with setitems with items?!" );
     298             :         }
     299             :     }
     300       39866 : }
     301             : 
     302             : 
     303             : 
     304          83 : void SfxItemPool::ReleaseDefaults
     305             : (
     306             :     bool    bDelete     /*  sal_True
     307             :                             l"oscht sowohl das Array als auch die einzelnen
     308             :                             statischen Defaults
     309             : 
     310             :                             sal_False
     311             :                             l"oscht weder das Array noch die einzelnen
     312             :                             statischen Defaults */
     313             : )
     314             : 
     315             : /*  [Beschreibung]
     316             : 
     317             :     Gibt die statischen Defaults der betreffenden SfxItemPool-Instanz frei
     318             :     und l"oscht ggf. die statischen Defaults.
     319             : 
     320             :     Nach Aufruf dieser Methode darf die SfxItemPool-Instanz nicht mehr
     321             :     verwendet werden, einzig ist der Aufruf des Destruktors zu"lassig.
     322             : */
     323             : 
     324             : {
     325             :     DBG_ASSERT( pImp->ppStaticDefaults, "keine Arme keine Kekse" );
     326          83 :     ReleaseDefaults( pImp->ppStaticDefaults, pImp->mnEnd - pImp->mnStart + 1, bDelete );
     327             : 
     328             :     // KSO (22.10.98): ppStaticDefaults zeigt auf geloeschten Speicher,
     329             :     // wenn bDelete == sal_True.
     330          83 :     if ( bDelete )
     331           0 :         pImp->ppStaticDefaults = 0;
     332          83 : }
     333             : 
     334             : 
     335             : 
     336         158 : void SfxItemPool::ReleaseDefaults
     337             : (
     338             :     SfxPoolItem**   pDefaults,  /*  freizugebende statische Defaults */
     339             : 
     340             :     sal_uInt16          nCount,     /*  Anzahl der statischen Defaults */
     341             : 
     342             :     bool            bDelete     /*  sal_True
     343             :                                     l"oscht sowohl das Array als auch die
     344             :                                     einzelnen statischen Defaults
     345             : 
     346             :                                     sal_False
     347             :                                     l"oscht weder das Array noch die
     348             :                                     einzelnen statischen Defaults */
     349             : )
     350             : 
     351             : /*  [Beschreibung]
     352             : 
     353             :     Gibt die angegebenen statischen Defaults frei und l"oscht ggf.
     354             :     die statischen Defaults.
     355             : 
     356             :     Diese Methode darf erst nach Zerst"orung aller SfxItemPool-Instanzen,
     357             :     welche die angegebenen statischen Defaults 'pDefault' verwenden,
     358             :     aufgerufen werden.
     359             : */
     360             : 
     361             : {
     362             :     DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." );
     363             : 
     364        4291 :     for ( sal_uInt16 n = 0; n < nCount; ++n )
     365             :     {
     366             :         SFX_ASSERT( IsStaticDefaultItem( *(pDefaults+n) ),
     367             :                     n, "das ist kein static-default" );
     368        4133 :         (*( pDefaults + n ))->SetRefCount( 0 );
     369        4133 :         if ( bDelete )
     370        4050 :             { delete *( pDefaults + n ); *(pDefaults + n) = 0; }
     371             :     }
     372             : 
     373         158 :     if ( bDelete )
     374          75 :         { delete[] pDefaults; pDefaults = 0; }
     375         158 : }
     376             : 
     377             : 
     378             : 
     379       38843 : SfxItemPool::~SfxItemPool()
     380             : {
     381       38806 :     if ( !pImp->maPoolItems.empty() && pImp->ppPoolDefaults )
     382       35260 :         Delete();
     383             : 
     384       38806 :     if (pImp->mpMaster != NULL && pImp->mpMaster != this)
     385             :     {
     386             :         // This condition indicates an error.  A
     387             :         // pImp->mpMaster->SetSecondaryPool(...) call should have been made
     388             :         // earlier to prevent this.  At this point we can only try to
     389             :         // prevent a crash later on.
     390             :         DBG_ASSERT( pImp->mpMaster == this, "destroying active Secondary-Pool" );
     391           0 :         if (pImp->mpMaster->pImp->mpSecondary == this)
     392           0 :             pImp->mpMaster->pImp->mpSecondary = NULL;
     393             :     }
     394             : 
     395       38806 :     delete pImp;
     396       38843 : }
     397             : 
     398       40760 : void SfxItemPool::Free(SfxItemPool* pPool)
     399             : {
     400       40760 :     if(pPool)
     401             :     {
     402             :         // tell all the registered SfxItemPoolUsers that the pool is in destruction
     403       38723 :         std::vector<SfxItemPoolUser*> aListCopy(pPool->pImp->maSfxItemPoolUsers.begin(), pPool->pImp->maSfxItemPoolUsers.end());
     404       38733 :         for(std::vector<SfxItemPoolUser*>::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); ++aIterator)
     405             :         {
     406          10 :             SfxItemPoolUser* pSfxItemPoolUser = *aIterator;
     407             :             DBG_ASSERT(pSfxItemPoolUser, "corrupt SfxItemPoolUser list (!)");
     408          10 :             pSfxItemPoolUser->ObjectInDestruction(*pPool);
     409             :         }
     410             : 
     411             :         // Clear the vector. This means that user do not need to call RemoveSfxItemPoolUser()
     412             :         // when they get called from ObjectInDestruction().
     413       38723 :         pPool->pImp->maSfxItemPoolUsers.clear();
     414             : 
     415             :         // delete pool
     416       38723 :         delete pPool;
     417             :     }
     418       40760 : }
     419             : 
     420             : 
     421             : 
     422             : 
     423       11490 : void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
     424             : {
     425             :     // ggf. an abgeh"angten Pools den Master zur"ucksetzen
     426       11490 :     if ( pImp->mpSecondary )
     427             :     {
     428             : #ifdef DBG_UTIL
     429             :         SAL_INFO( "svl.items", "fuer Image, dort gibt es derzeit keine Statics - Bug" );
     430             :         if ( pImp->ppStaticDefaults )
     431             :         {
     432             :             // Delete() ist noch nicht gelaufen?
     433             :             if ( !pImp->maPoolItems.empty() && !pImp->mpSecondary->pImp->maPoolItems.empty() )
     434             :             {
     435             :                 // hat der master SetItems?
     436             :                 bool bHasSetItems = false;
     437             :                 for ( sal_uInt16 i = 0; !bHasSetItems && i < pImp->mnEnd - pImp->mnStart; ++i )
     438             :                     bHasSetItems = pImp->ppStaticDefaults[i]->ISA(SfxSetItem);
     439             : 
     440             :                 // abgehaengte Pools muessen leer sein
     441             :                 bool bOK = bHasSetItems;
     442             :                 for ( sal_uInt16 n = 0;
     443             :                       bOK && n <= pImp->mpSecondary->pImp->mnEnd - pImp->mpSecondary->pImp->mnStart;
     444             :                       ++n )
     445             :                 {
     446             :                     SfxPoolItemArray_Impl* pItemArr = pImp->mpSecondary->pImp->maPoolItems[n];
     447             :                     if ( pItemArr )
     448             :                     {
     449             :                         SfxPoolItemArrayBase_Impl::iterator ppHtArr =   pItemArr->begin();
     450             :                         for( size_t i = pItemArr->size(); i; ++ppHtArr, --i )
     451             :                             if ( !(*ppHtArr) )
     452             :                             {
     453             :                                 OSL_FAIL( "old secondary pool must be empty" );
     454             :                                 bOK = false;
     455             :                                 break;
     456             :                             }
     457             :                     }
     458             :                 }
     459             :             }
     460             :         }
     461             : #endif
     462             : 
     463        4623 :         pImp->mpSecondary->pImp->mpMaster = pImp->mpSecondary;
     464        6508 :         for ( SfxItemPool *p = pImp->mpSecondary->pImp->mpSecondary; p; p = p->pImp->mpSecondary )
     465        1885 :             p->pImp->mpMaster = pImp->mpSecondary;
     466             :     }
     467             : 
     468             :     // ggf. den Master der neuen Secondary-Pools setzen
     469             :     DBG_ASSERT( !pPool || pPool->pImp->mpMaster == pPool, "Secondary tanzt auf zwei Hochzeiten " );
     470       11490 :     SfxItemPool *pNewMaster = pImp->mpMaster ? pImp->mpMaster : this;
     471       16472 :     for ( SfxItemPool *p = pPool; p; p = p->pImp->mpSecondary )
     472        4982 :         p->pImp->mpMaster = pNewMaster;
     473             : 
     474             :     // neuen Secondary-Pool merken
     475       11490 :     pImp->mpSecondary = pPool;
     476             : 
     477             :     CHECK_SLOTS();
     478       11490 : }
     479             : 
     480        3201 : void SfxItemPool::SetItemInfos(SfxItemInfo const*const pInfos)
     481             : {
     482        3201 :     pItemInfos = pInfos;
     483             :     CHECK_SLOTS();
     484        3201 : }
     485             : 
     486             : 
     487             : 
     488     2052466 : SfxMapUnit SfxItemPool::GetMetric( sal_uInt16 ) const
     489             : {
     490     2052466 :     return pImp->eDefMetric;
     491             : }
     492             : 
     493             : 
     494             : 
     495       30642 : void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric )
     496             : {
     497       30642 :     pImp->eDefMetric = eNewMetric;
     498       30642 : }
     499             : 
     500        2975 : const OUString& SfxItemPool::GetName() const
     501             : {
     502        2975 :     return pImp->aName;
     503             : }
     504             : 
     505             : 
     506             : 
     507           0 : SfxItemPresentation SfxItemPool::GetPresentation
     508             : (
     509             :     const SfxPoolItem&  rItem,
     510             :     SfxItemPresentation ePresent,
     511             :     SfxMapUnit          eMetric,
     512             :     OUString&           rText,
     513             :     const IntlWrapper * pIntlWrapper
     514             : )   const
     515             : {
     516             :     return rItem.GetPresentation(
     517           0 :         ePresent, GetMetric(rItem.Which()), eMetric, rText, pIntlWrapper );
     518             : }
     519             : 
     520             : 
     521             : 
     522             : 
     523          37 : SfxItemPool* SfxItemPool::Clone() const
     524             : {
     525          37 :     SfxItemPool *pPool = new SfxItemPool( *this );
     526          37 :     return pPool;
     527             : }
     528             : 
     529             : 
     530             : 
     531       43309 : void SfxItemPool::Delete()
     532             : {
     533             :     // schon deleted?
     534       43309 :     if ( pImp->maPoolItems.empty() || !pImp->ppPoolDefaults )
     535       47812 :         return;
     536             : 
     537             :     // z.B. laufenden Requests bescheidsagen
     538       38806 :     pImp->aBC.Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
     539             : 
     540             :     //MA 16. Apr. 97: Zweimal durchlaufen, in der ersten Runde fuer die SetItems.
     541             :     //Der Klarheit halber wird das jetzt in zwei besser lesbare Schleifen aufgeteilt.
     542             : 
     543       38806 :     std::vector<SfxPoolItemArray_Impl*>::iterator itrItemArr = pImp->maPoolItems.begin();
     544       38806 :     SfxPoolItem** ppDefaultItem = pImp->ppPoolDefaults;
     545       38806 :     SfxPoolItem** ppStaticDefaultItem = pImp->ppStaticDefaults;
     546             :     sal_uInt16 nArrCnt;
     547             : 
     548             :     //Erst die SetItems abraeumen
     549             :     SAL_INFO( "svl.items", "fuer Image, dort gibt es derzeit keine Statics - Bug" );
     550       38806 :     if ( pImp->ppStaticDefaults )
     551             :     {
     552     2822812 :         for ( nArrCnt = GetSize_Impl();
     553             :                 nArrCnt;
     554             :                 --nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
     555             :         {
     556             :             // KSO (22.10.98): *ppStaticDefaultItem kann im dtor einer
     557             :             // von SfxItemPool abgeleiteten Klasse bereits geloescht worden
     558             :             // sein! -> CHAOS Itempool
     559     2784006 :             if ( *ppStaticDefaultItem && (*ppStaticDefaultItem)->ISA(SfxSetItem) )
     560             :             {
     561        7663 :                 if ( *itrItemArr )
     562             :                 {
     563         951 :                     SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
     564        6268 :                     for ( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
     565        5317 :                         if (*ppHtArr)
     566             :                         {
     567             : #ifdef DBG_UTIL
     568             :                             ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() );
     569             : #endif
     570        1340 :                             delete *ppHtArr;
     571             :                         }
     572         951 :                     DELETEZ( *itrItemArr );
     573             :                 }
     574        7663 :                 if ( *ppDefaultItem )
     575             :                 {
     576             : #ifdef DBG_UTIL
     577             :                     SetRefCount( **ppDefaultItem, 0 );
     578             : #endif
     579           0 :                     DELETEZ( *ppDefaultItem );
     580             :                 }
     581             :             }
     582             :         }
     583             :     }
     584             : 
     585       38806 :     itrItemArr = pImp->maPoolItems.begin();
     586       38806 :     ppDefaultItem = pImp->ppPoolDefaults;
     587             : 
     588             :     //Jetzt die 'einfachen' Items
     589     2822812 :     for ( nArrCnt = GetSize_Impl();
     590             :             nArrCnt;
     591             :             --nArrCnt, ++itrItemArr, ++ppDefaultItem )
     592             :     {
     593     2784006 :         if ( *itrItemArr )
     594             :         {
     595      345002 :             SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
     596      881426 :             for ( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
     597      536424 :                 if (*ppHtArr)
     598             :                 {
     599             : #ifdef DBG_UTIL
     600             :                     ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() );
     601             : #endif
     602      239096 :                     delete *ppHtArr;
     603             :                 }
     604      345002 :             DELETEZ( *itrItemArr );
     605             :         }
     606     2784006 :         if ( *ppDefaultItem )
     607             :         {
     608             : #ifdef DBG_UTIL
     609             :             SetRefCount( **ppDefaultItem, 0 );
     610             : #endif
     611       85763 :             delete *ppDefaultItem;
     612             :         }
     613             :     }
     614             : 
     615       38806 :     pImp->DeleteItems();
     616             : }
     617             : 
     618             : 
     619             : 
     620      262805 : void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem)
     621             : {
     622      262805 :     if ( IsInRange(rItem.Which()) )
     623             :     {
     624             :         SfxPoolItem **ppOldDefault =
     625      159298 :             pImp->ppPoolDefaults + GetIndex_Impl(rItem.Which());
     626      159298 :         SfxPoolItem *pNewDefault = rItem.Clone(this);
     627      159298 :         pNewDefault->SetKind(SFX_ITEMS_POOLDEFAULT);
     628      159298 :         if ( *ppOldDefault )
     629             :         {
     630       70662 :             (*ppOldDefault)->SetRefCount(0);
     631       70662 :             DELETEZ( *ppOldDefault );
     632             :         }
     633      159298 :         *ppOldDefault = pNewDefault;
     634             :     }
     635      103507 :     else if ( pImp->mpSecondary )
     636      103507 :         pImp->mpSecondary->SetPoolDefaultItem(rItem);
     637             :     else
     638             :     {
     639             :         SFX_ASSERT( false, rItem.Which(), "unknown Which-Id - cannot set pool default" );
     640             :     }
     641      262805 : }
     642             : 
     643             : /*
     644             :  * Resets the default of the given <Which-Id> back to the static default.
     645             :  * If a pool default exists it is removed.
     646             :  */
     647         190 : void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId )
     648             : {
     649         190 :     if ( IsInRange(nWhichId) )
     650             :     {
     651             :         SfxPoolItem **ppOldDefault =
     652         190 :             pImp->ppPoolDefaults + GetIndex_Impl( nWhichId );
     653         190 :         if ( *ppOldDefault )
     654             :         {
     655          88 :             (*ppOldDefault)->SetRefCount(0);
     656          88 :             DELETEZ( *ppOldDefault );
     657             :         }
     658             :     }
     659           0 :     else if ( pImp->mpSecondary )
     660           0 :         pImp->mpSecondary->ResetPoolDefaultItem(nWhichId);
     661             :     else
     662             :     {
     663             :         SFX_ASSERT( false, nWhichId, "unknown Which-Id - cannot set pool default" );
     664             :     }
     665         190 : }
     666             : 
     667             : 
     668             : 
     669    22317478 : const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich )
     670             : {
     671             :     DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
     672             :                 0 != &((const SfxSetItem&)rItem).GetItemSet(),
     673             :                 "SetItem without ItemSet" );
     674             : 
     675    22317478 :     if ( 0 == nWhich )
     676     1434066 :         nWhich = rItem.Which();
     677             : 
     678             :     // richtigen Secondary-Pool finden
     679    22317478 :     bool bSID = nWhich > SFX_WHICH_MAX;
     680    22317478 :     if ( !bSID && !IsInRange(nWhich) )
     681             :     {
     682     6442743 :         if ( pImp->mpSecondary )
     683     6442743 :             return pImp->mpSecondary->Put( rItem, nWhich );
     684             :         OSL_FAIL( "unknown Which-Id - cannot put item" );
     685             :     }
     686             : 
     687             :     // SID oder nicht poolable (neue Definition)?
     688    15874735 :     sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich);
     689    30673607 :     if ( USHRT_MAX == nIndex ||
     690    14798872 :          IsItemFlag_Impl( nIndex, SFX_ITEM_NOT_POOLABLE ) )
     691             :     {
     692             :         SFX_ASSERT( USHRT_MAX != nIndex || rItem.Which() != nWhich ||
     693             :                     !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE,
     694             :                     nWhich, "ein nicht Pool-Item ist Default?!" );
     695     1075863 :         SfxPoolItem *pPoolItem = rItem.Clone(pImp->mpMaster);
     696     1075863 :         pPoolItem->SetWhich(nWhich);
     697     1075863 :         AddRef( *pPoolItem );
     698     1075863 :         return *pPoolItem;
     699             :     }
     700             : 
     701             :     SFX_ASSERT( rItem.IsA(GetDefaultItem(nWhich).Type()), nWhich,
     702             :                 "SFxItemPool: wrong item type in Put" );
     703             : 
     704    14798872 :     SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex];
     705    14798872 :     if (!pItemArr)
     706             :     {
     707      356648 :         pImp->maPoolItems[nIndex] = new SfxPoolItemArray_Impl;
     708      356648 :         pItemArr = pImp->maPoolItems[nIndex];
     709             :     }
     710             : 
     711    14798872 :     SfxPoolItemArrayBase_Impl::iterator ppFree;
     712    14798872 :     bool ppFreeIsSet = false;
     713    14798872 :     if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) )
     714             :     {
     715             :         // wenn es ueberhaupt gepoolt ist, koennte es schon drin sein
     716    14540015 :         if ( IsPooledItem(&rItem) )
     717             :         {
     718             :             // 1. Schleife: teste ob der Pointer vorhanden ist.
     719             :             SfxPoolItemArrayBase_Impl::iterator itr =
     720    11713439 :                 std::find(pItemArr->begin(), pItemArr->end(), &rItem);
     721    11713439 :             if (itr != pItemArr->end())
     722             :             {
     723    11323429 :                 AddRef(**itr);
     724    11323429 :                 return **itr;
     725             :             }
     726             :         }
     727             : 
     728             :         // 2. Schleife: dann muessen eben die Attribute verglichen werden
     729     3216586 :         SfxPoolItemArrayBase_Impl::iterator itr = pItemArr->begin();
     730    17358986 :         for (; itr != pItemArr->end(); ++itr)
     731             :         {
     732    16493777 :             if (*itr)
     733             :             {
     734    15934590 :                 if (**itr == rItem)
     735             :                 {
     736     2351377 :                     AddRef(**itr);
     737     2351377 :                     return **itr;
     738             :                 }
     739             :             }
     740             :             else
     741             :             {
     742      559187 :                 if (!ppFreeIsSet)
     743             :                 {
     744      404439 :                     ppFree = itr;
     745      404439 :                     ppFreeIsSet = true;
     746             :                 }
     747             :             }
     748             :         }
     749             :     }
     750             :     else
     751             :     {
     752             :         // freien Platz suchen
     753      258857 :         SfxPoolItemArrayBase_Impl::iterator itr = pItemArr->begin();
     754      258857 :         std::advance(itr, pItemArr->nFirstFree);
     755      839874 :         for (; itr != pItemArr->end(); ++itr)
     756             :         {
     757      774000 :             if (!*itr)
     758             :             {
     759      192983 :                 ppFree = itr;
     760      192983 :                 ppFreeIsSet = true;
     761      192983 :                 break;
     762             :             }
     763             :         }
     764             :         // naechstmoeglichen freien Platz merken
     765      258857 :         pItemArr->nFirstFree = std::distance(pItemArr->begin(), itr);
     766             :     }
     767             : 
     768             :     // nicht vorhanden, also im PtrArray eintragen
     769     1124066 :     SfxPoolItem* pNewItem = rItem.Clone(pImp->mpMaster);
     770     1124066 :     pNewItem->SetWhich(nWhich);
     771             : #ifdef DBG_UTIL
     772             :     SFX_ASSERT( rItem.Type() == pNewItem->Type(), nWhich, "unequal types in Put(): no Clone()?" )
     773             :     if ( !rItem.ISA(SfxSetItem) )
     774             :     {
     775             :         SFX_ASSERT( !IsItemFlag(nWhich, SFX_ITEM_POOLABLE) ||
     776             :                     rItem == *pNewItem,
     777             :                     nWhich, "unequal items in Put(): no operator==?" );
     778             :         SFX_ASSERT( !IsItemFlag(*pNewItem, SFX_ITEM_POOLABLE) ||
     779             :                     *pNewItem == rItem,
     780             :                     nWhich, "unequal items in Put(): no operator==?" );
     781             :     }
     782             : #endif
     783     1124066 :     AddRef( *pNewItem, pImp->nInitRefCount );
     784             : 
     785     1124066 :     if ( ppFreeIsSet == false )
     786      562601 :         pItemArr->push_back( pNewItem );
     787             :     else
     788             :     {
     789             :         DBG_ASSERT( *ppFree == 0, "using surrogate in use" );
     790      561465 :         *ppFree = pNewItem;
     791             :     }
     792     1124066 :     return *pNewItem;
     793             : }
     794             : 
     795             : 
     796             : 
     797     6878682 : void SfxItemPool::Remove( const SfxPoolItem& rItem )
     798             : {
     799             :     DBG_ASSERT( !rItem.ISA(SfxSetItem) ||
     800             :                 0 != &((const SfxSetItem&)rItem).GetItemSet(),
     801             :                 "SetItem without ItemSet" );
     802             : 
     803             :     SFX_ASSERT( !IsPoolDefaultItem(&rItem), rItem.Which(),
     804             :                 "wo kommt denn hier ein Pool-Default her" );
     805             : 
     806             :     // richtigen Secondary-Pool finden
     807     6878682 :     const sal_uInt16 nWhich = rItem.Which();
     808     6878682 :     bool bSID = nWhich > SFX_WHICH_MAX;
     809     6878682 :     if ( !bSID && !IsInRange(nWhich) )
     810             :     {
     811      690504 :         if ( pImp->mpSecondary )
     812             :         {
     813      690504 :             pImp->mpSecondary->Remove( rItem );
     814     7569186 :             return;
     815             :         }
     816             :         OSL_FAIL( "unknown Which-Id - cannot remove item" );
     817             :     }
     818             : 
     819             :     // SID oder nicht poolable (neue Definition)?
     820     6188178 :     sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich);
     821     6188178 :     if ( bSID || IsItemFlag_Impl( nIndex, SFX_ITEM_NOT_POOLABLE ) )
     822             :     {
     823             :         SFX_ASSERT( USHRT_MAX != nIndex ||
     824             :                     !IsDefaultItem(&rItem), rItem.Which(),
     825             :                     "ein nicht Pool-Item ist Default?!" );
     826     1075563 :         if ( 0 == ReleaseRef(rItem) )
     827             :         {
     828     1075563 :             SfxPoolItem *pItem = &(SfxPoolItem &)rItem;
     829     1075563 :             delete pItem;
     830             :         }
     831     1075563 :         return;
     832             :     }
     833             : 
     834             :     SFX_ASSERT( rItem.GetRefCount(), rItem.Which(), "RefCount == 0, Remove unmoeglich" );
     835             : 
     836             :     // statische Defaults sind eben einfach da
     837     7008989 :     if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT &&
     838     1896374 :          &rItem == *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
     839     1896374 :         return;
     840             : 
     841             :     // Item im eigenen Pool suchen
     842     3216241 :     SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[nIndex];
     843             :     SFX_ASSERT( pItemArr, rItem.Which(), "removing Item not in Pool" );
     844     3216241 :     SfxPoolItemArrayBase_Impl::iterator ppHtArrBeg = pItemArr->begin(), ppHtArrEnd = pItemArr->end();
     845    20470238 :     for (SfxPoolItemArrayBase_Impl::iterator ppHtArr = ppHtArrBeg; ppHtArr != ppHtArrEnd; ++ppHtArr)
     846             :     {
     847    20470238 :         SfxPoolItem*& p = *ppHtArr;
     848    20470238 :         if (p == &rItem)
     849             :         {
     850     3216241 :             if ( p->GetRefCount() ) //!
     851     3216241 :                 ReleaseRef( *p );
     852             :             else
     853             :             {
     854             :                 SFX_ASSERT( false, rItem.Which(), "removing Item without ref" );
     855             :             }
     856             : 
     857             :             // ggf. kleinstmoegliche freie Position merken
     858     3216241 :             size_t nPos = std::distance(ppHtArrBeg, ppHtArr);
     859     3216241 :             if ( pItemArr->nFirstFree > nPos )
     860      137662 :                 pItemArr->nFirstFree = nPos;
     861             : 
     862             :             //! MI: Hack, solange wir das Problem mit dem Outliner haben
     863             :             //! siehe anderes MI-REF
     864     3216241 :             if ( 0 == p->GetRefCount() && nWhich < 4000 )
     865      865533 :                 DELETEZ(p);
     866     6432482 :             return;
     867             :         }
     868             :     }
     869             : 
     870             :     // nicht vorhanden
     871             :     SFX_ASSERT( false, rItem.Which(), "removing Item not in Pool" );
     872             : }
     873             : 
     874             : 
     875             : 
     876    95018963 : const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const
     877             : {
     878    95018963 :     if ( !IsInRange(nWhich) )
     879             :     {
     880    20483020 :         if ( pImp->mpSecondary )
     881    20483020 :             return pImp->mpSecondary->GetDefaultItem( nWhich );
     882             :         SFX_ASSERT( false, nWhich, "unknown which - dont ask me for defaults" );
     883             :     }
     884             : 
     885             :     DBG_ASSERT( pImp->ppStaticDefaults, "no defaults known - dont ask me for defaults" );
     886    74535943 :     sal_uInt16 nPos = GetIndex_Impl(nWhich);
     887    74535943 :     SfxPoolItem *pDefault = *(pImp->ppPoolDefaults + nPos);
     888    74535943 :     if ( pDefault )
     889     7247472 :         return *pDefault;
     890    67288471 :     return **(pImp->ppStaticDefaults + nPos);
     891             : }
     892             : 
     893      185692 : SfxItemPool* SfxItemPool::GetSecondaryPool() const
     894             : {
     895      185692 :     return pImp->mpSecondary;
     896             : }
     897             : 
     898             : #ifdef DBG_UTIL
     899             : SfxItemPool* SfxItemPool::GetMasterPool() const
     900             : {
     901             :     return pImp->mpMaster;
     902             : }
     903             : #endif
     904             : 
     905        6102 : void SfxItemPool::FreezeIdRanges()
     906             : 
     907             : /*  [Beschreibung]
     908             : 
     909             :     This method should be called at the master pool, when all secondary
     910             :     pools are appended to it.
     911             : 
     912             :     It calculates the ranges of 'which-ids' for fast construction of
     913             :     item-sets, which contains all 'which-ids'.
     914             : */
     915             : 
     916             : {
     917        6102 :     FillItemIdRanges_Impl( pImp->mpPoolRanges );
     918        6102 : }
     919             : 
     920             : 
     921             : 
     922             : 
     923        6102 : void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const
     924             : {
     925             :     DBG_ASSERT( !pImp->mpPoolRanges, "GetFrozenRanges() would be faster!" );
     926             : 
     927             :     const SfxItemPool *pPool;
     928        6102 :     sal_uInt16 nLevel = 0;
     929       17186 :     for( pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
     930       11084 :         ++nLevel;
     931             : 
     932        6102 :     pWhichRanges = new sal_uInt16[ 2*nLevel + 1 ];
     933             : 
     934        6102 :     nLevel = 0;
     935       17186 :     for( pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
     936             :     {
     937       11084 :         *(pWhichRanges+(nLevel++)) = pPool->pImp->mnStart;
     938       11084 :         *(pWhichRanges+(nLevel++)) = pPool->pImp->mnEnd;
     939       11084 :         *(pWhichRanges+nLevel) = 0;
     940             :     }
     941        6102 : }
     942             : 
     943     6611892 : const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const
     944             : {
     945     6611892 :     return pImp->mpPoolRanges;
     946             : }
     947             : 
     948      135875 : const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) const
     949             : {
     950      135875 :     if ( !IsInRange(nWhich) )
     951             :     {
     952        2593 :         if ( pImp->mpSecondary )
     953        2593 :             return pImp->mpSecondary->GetItem2( nWhich, nOfst );
     954             :         SFX_ASSERT( false, nWhich, "unknown Which-Id - cannot resolve surrogate" );
     955           0 :         return 0;
     956             :     }
     957             : 
     958             :     // dflt-Attribut?
     959      133282 :     if ( nOfst == SFX_ITEMS_DEFAULT )
     960           0 :         return *(pImp->ppStaticDefaults + GetIndex_Impl(nWhich));
     961             : 
     962      133282 :     SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)];
     963      133282 :     if( pItemArr && nOfst < pItemArr->size() )
     964      133282 :         return (*pItemArr)[nOfst];
     965             : 
     966           0 :     return 0;
     967             : }
     968             : 
     969             : 
     970             : 
     971       57123 : sal_uInt32 SfxItemPool::GetItemCount2(sal_uInt16 nWhich) const
     972             : {
     973       57123 :     if ( !IsInRange(nWhich) )
     974             :     {
     975        2412 :         if ( pImp->mpSecondary )
     976        2412 :             return pImp->mpSecondary->GetItemCount2( nWhich );
     977             :         SFX_ASSERT( false, nWhich, "unknown Which-Id - cannot resolve surrogate" );
     978           0 :         return 0;
     979             :     }
     980             : 
     981       54711 :     SfxPoolItemArray_Impl* pItemArr = pImp->maPoolItems[GetIndex_Impl(nWhich)];
     982       54711 :     if  ( pItemArr )
     983       48452 :         return pItemArr->size();
     984        6259 :     return 0;
     985             : }
     986             : 
     987             : 
     988             : 
     989     2533716 : sal_uInt16 SfxItemPool::GetWhich( sal_uInt16 nSlotId, bool bDeep ) const
     990             : {
     991     2533716 :     if ( !IsSlot(nSlotId) )
     992       60382 :         return nSlotId;
     993             : 
     994     2473334 :     sal_uInt16 nCount = pImp->mnEnd - pImp->mnStart + 1;
     995   199005690 :     for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs )
     996   196636400 :         if ( pItemInfos[nOfs]._nSID == nSlotId )
     997      104044 :             return nOfs + pImp->mnStart;
     998     2369290 :     if ( pImp->mpSecondary && bDeep )
     999      914362 :         return pImp->mpSecondary->GetWhich(nSlotId);
    1000     1454928 :     return nSlotId;
    1001             : }
    1002             : 
    1003             : 
    1004             : 
    1005       98691 : sal_uInt16 SfxItemPool::GetSlotId( sal_uInt16 nWhich, bool bDeep ) const
    1006             : {
    1007       98691 :     if ( !IsWhich(nWhich) )
    1008           0 :         return nWhich;
    1009             : 
    1010       98691 :     if ( !IsInRange( nWhich ) )
    1011             :     {
    1012         933 :         if ( pImp->mpSecondary && bDeep )
    1013         933 :             return pImp->mpSecondary->GetSlotId(nWhich);
    1014             :         SFX_ASSERT( false, nWhich, "unknown Which-Id - cannot get slot-id" );
    1015           0 :         return 0;
    1016             :     }
    1017             : 
    1018       97758 :     sal_uInt16 nSID = pItemInfos[nWhich - pImp->mnStart]._nSID;
    1019       97758 :     return nSID ? nSID : nWhich;
    1020             : }
    1021             : 
    1022             : 
    1023             : 
    1024         368 : sal_uInt16 SfxItemPool::GetTrueWhich( sal_uInt16 nSlotId, bool bDeep ) const
    1025             : {
    1026         368 :     if ( !IsSlot(nSlotId) )
    1027           0 :         return 0;
    1028             : 
    1029         368 :     sal_uInt16 nCount = pImp->mnEnd - pImp->mnStart + 1;
    1030       12052 :     for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs )
    1031       12052 :         if ( pItemInfos[nOfs]._nSID == nSlotId )
    1032         368 :             return nOfs + pImp->mnStart;
    1033           0 :     if ( pImp->mpSecondary && bDeep )
    1034           0 :         return pImp->mpSecondary->GetTrueWhich(nSlotId);
    1035           0 :     return 0;
    1036             : }
    1037             : 
    1038             : 
    1039             : 
    1040         200 : sal_uInt16 SfxItemPool::GetTrueSlotId( sal_uInt16 nWhich, bool bDeep ) const
    1041             : {
    1042         200 :     if ( !IsWhich(nWhich) )
    1043           0 :         return 0;
    1044             : 
    1045         200 :     if ( !IsInRange( nWhich ) )
    1046             :     {
    1047           0 :         if ( pImp->mpSecondary && bDeep )
    1048           0 :             return pImp->mpSecondary->GetTrueSlotId(nWhich);
    1049             :         SFX_ASSERT( false, nWhich, "unknown Which-Id - cannot get slot-id" );
    1050           0 :         return 0;
    1051             :     }
    1052         200 :     return pItemInfos[nWhich - pImp->mnStart]._nSID;
    1053             : }
    1054             : 
    1055        3934 : void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion )
    1056             : 
    1057             : /*  [Description]
    1058             : 
    1059             :     You must call this function to set the file format version after
    1060             :     concatenating your secondary-pools but before you store any
    1061             :     pool, itemset or item. Only set the version at the master pool,
    1062             :     never at any secondary pool.
    1063             : */
    1064             : 
    1065             : {
    1066             :     DBG_ASSERT( this == pImp->mpMaster,
    1067             :                 "SfxItemPool::SetFileFormatVersion() but not a master pool" );
    1068        7868 :     for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pImp->mpSecondary )
    1069        3934 :         pPool->pImp->mnFileFormatVersion = nFileFormatVersion;
    1070        3934 : }
    1071             : 
    1072             : const SfxItemPool* SfxItemPool::pStoringPool_ = 0;
    1073             : 
    1074             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10