1*40df464eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*40df464eSAndrew Rist * distributed with this work for additional information 6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance 9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*40df464eSAndrew Rist * software distributed under the License is distributed on an 15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the 17*40df464eSAndrew Rist * specific language governing permissions and limitations 18*40df464eSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*40df464eSAndrew Rist *************************************************************/ 21*40df464eSAndrew Rist 22*40df464eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <string.h> 28cdf0e10cSrcweir #include <stdio.h> 29cdf0e10cSrcweir #ifndef GCC 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <svl/itempool.hxx> 33cdf0e10cSrcweir #include "whassert.hxx" 34cdf0e10cSrcweir #include <svl/brdcst.hxx> 35cdf0e10cSrcweir #include <svl/smplhint.hxx> 36cdf0e10cSrcweir #include "poolio.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir //======================================================================== 39cdf0e10cSrcweir 40cdf0e10cSrcweir 41cdf0e10cSrcweir void SfxItemPool::AddSfxItemPoolUser(SfxItemPoolUser& rNewUser) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir maSfxItemPoolUsers.push_back(&rNewUser); 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir void SfxItemPool::RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir const SfxItemPoolUserVector::iterator aFindResult = ::std::find(maSfxItemPoolUsers.begin(), maSfxItemPoolUsers.end(), &rOldUser); 49cdf0e10cSrcweir if(aFindResult != maSfxItemPoolUsers.end()) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir maSfxItemPoolUsers.erase(aFindResult); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir const SfxPoolItem* SfxItemPool::GetPoolDefaultItem( sal_uInt16 nWhich ) const 56cdf0e10cSrcweir { 57cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 58cdf0e10cSrcweir const SfxPoolItem* pRet; 59cdf0e10cSrcweir if( IsInRange( nWhich ) ) 60cdf0e10cSrcweir pRet = *(ppPoolDefaults + GetIndex_Impl( nWhich )); 61cdf0e10cSrcweir else if( pSecondary ) 62cdf0e10cSrcweir pRet = pSecondary->GetPoolDefaultItem( nWhich ); 63cdf0e10cSrcweir else 64cdf0e10cSrcweir { 65cdf0e10cSrcweir SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get pool default" ); 66cdf0e10cSrcweir pRet = 0; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir return pRet; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir // ----------------------------------------------------------------------- 72cdf0e10cSrcweir 73cdf0e10cSrcweir inline FASTBOOL SfxItemPool::IsItemFlag_Impl( sal_uInt16 nPos, sal_uInt16 nFlag ) const 74cdf0e10cSrcweir { 75cdf0e10cSrcweir sal_uInt16 nItemFlag = pItemInfos[nPos]._nFlags; 76cdf0e10cSrcweir return nFlag == (nItemFlag & nFlag); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir // ----------------------------------------------------------------------- 80cdf0e10cSrcweir 81cdf0e10cSrcweir FASTBOOL SfxItemPool::IsItemFlag( sal_uInt16 nWhich, sal_uInt16 nFlag ) const 82cdf0e10cSrcweir { 83cdf0e10cSrcweir for ( const SfxItemPool *pPool = this; pPool; pPool = pPool->pSecondary ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir if ( pPool->IsInRange(nWhich) ) 86cdf0e10cSrcweir return pPool->IsItemFlag_Impl( pPool->GetIndex_Impl(nWhich), nFlag); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir DBG_ASSERT( !IsWhich(nWhich), "unknown which-id" ); 89cdf0e10cSrcweir return sal_False; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir // ----------------------------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir SfxBroadcaster& SfxItemPool::BC() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir return pImp->aBC; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir // ----------------------------------------------------------------------- 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir SfxItemPool::SfxItemPool 103cdf0e10cSrcweir ( 104cdf0e10cSrcweir UniString const & rName, /* Name des Pools zur Idetifikation 105cdf0e10cSrcweir im File-Format */ 106cdf0e10cSrcweir sal_uInt16 nStartWhich, /* erste Which-Id des Pools */ 107cdf0e10cSrcweir sal_uInt16 nEndWhich, /* letzte Which-Id des Pools */ 108cdf0e10cSrcweir #ifdef TF_POOLABLE 109cdf0e10cSrcweir const SfxItemInfo* pInfos, /* SID-Map und Item-Flags */ 110cdf0e10cSrcweir #endif 111cdf0e10cSrcweir SfxPoolItem** pDefaults, /* Pointer auf statische Defaults, 112cdf0e10cSrcweir wird direkt vom Pool referenziert, 113cdf0e10cSrcweir jedoch kein Eigent"umer"ubergang */ 114cdf0e10cSrcweir #ifndef TF_POOLABLE 115cdf0e10cSrcweir sal_uInt16* pSlotIdArray, /* Zuordnung von Slot-Ids zu Which-Ids */ 116cdf0e10cSrcweir #endif 117cdf0e10cSrcweir FASTBOOL bLoadRefCounts /* Ref-Counts mitladen oder auf 1 setzen */ 118cdf0e10cSrcweir ) 119cdf0e10cSrcweir 120cdf0e10cSrcweir /* [Beschreibung] 121cdf0e10cSrcweir 122cdf0e10cSrcweir Der im Normalfall verwendete Konstruktor der Klasse SfxItemPool. Es 123cdf0e10cSrcweir wird eine SfxItemPool-Instanz initialisiert, die Items im b"undigen 124cdf0e10cSrcweir Which-Bereich von 'nStartWhich' bis 'nEndWhich' verwalten kann. 125cdf0e10cSrcweir 126cdf0e10cSrcweir F"ur jede dieser Which-Ids mu\s ein statischer Default im Array 'pDefaults' 127cdf0e10cSrcweir vorhanden sein, die dort beginnend mit einem <SfxPoolItem> mit der 128cdf0e10cSrcweir Which-Id 'nStartWhich' nach Which-Ids sortiert aufeinanderfolgend 129cdf0e10cSrcweir eingetragen sein m"ussen. 130cdf0e10cSrcweir 131cdf0e10cSrcweir 'pItemInfos' ist ein identisch angeordnetes Array von USHORTs, die 132cdf0e10cSrcweir Slot-Ids darstellen und Flags. Die Slot-Ids k"onnen 0 sein, wenn die 133cdf0e10cSrcweir betreffenden Items ausschlie\slich in der Core verwendet werden. 134cdf0e10cSrcweir "Uber die Flags kann z.B. bestimmt werden, ob Value-Sharing 135cdf0e10cSrcweir (SFX_ITEM_POOLABLE) stattfinden soll. 136cdf0e10cSrcweir 137cdf0e10cSrcweir [Anmerkung] 138cdf0e10cSrcweir 139cdf0e10cSrcweir Wenn der Pool <SfxSetItem>s enthalten soll, k"onnen im Konstruktor noch 140cdf0e10cSrcweir keine static-Defaults angegeben werden. Dies mu\s dann nachtr"aglich 141cdf0e10cSrcweir mit <SfxItemPool::SetDefaults(SfxItemPool**)> geschehen. 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144cdf0e10cSrcweir [Querverweise] 145cdf0e10cSrcweir 146cdf0e10cSrcweir <SfxItemPool::SetDefaults(SfxItemPool**)> 147cdf0e10cSrcweir <SfxItemPool::ReleaseDefaults(SfxPoolItem**,sal_uInt16,sal_Bool)> 148cdf0e10cSrcweir <SfxItemPool::ReldaseDefaults(sal_Bool)> 149cdf0e10cSrcweir */ 150cdf0e10cSrcweir 151cdf0e10cSrcweir : aName(rName), 152cdf0e10cSrcweir nStart(nStartWhich), 153cdf0e10cSrcweir nEnd(nEndWhich), 154cdf0e10cSrcweir #ifdef TF_POOLABLE 155cdf0e10cSrcweir pItemInfos(pInfos), 156cdf0e10cSrcweir #else 157cdf0e10cSrcweir pSlotIds(pSlotIdArray), 158cdf0e10cSrcweir #endif 159cdf0e10cSrcweir pImp( new SfxItemPool_Impl( nStart, nEnd ) ), 160cdf0e10cSrcweir ppStaticDefaults(0), 161cdf0e10cSrcweir ppPoolDefaults(new SfxPoolItem* [ nEndWhich - nStartWhich + 1]), 162cdf0e10cSrcweir pSecondary(0), 163cdf0e10cSrcweir pMaster(this), 164cdf0e10cSrcweir _pPoolRanges( 0 ), 165cdf0e10cSrcweir bPersistentRefCounts(bLoadRefCounts), 166cdf0e10cSrcweir maSfxItemPoolUsers() 167cdf0e10cSrcweir { 168cdf0e10cSrcweir DBG_CTOR(SfxItemPool, 0); 169cdf0e10cSrcweir DBG_ASSERT(nStart, "Start-Which-Id must be greater 0" ); 170cdf0e10cSrcweir 171cdf0e10cSrcweir pImp->eDefMetric = SFX_MAPUNIT_TWIP; 172cdf0e10cSrcweir pImp->nVersion = 0; 173cdf0e10cSrcweir pImp->bStreaming = sal_False; 174cdf0e10cSrcweir pImp->nLoadingVersion = 0; 175cdf0e10cSrcweir pImp->nInitRefCount = 1; 176cdf0e10cSrcweir pImp->nVerStart = nStart; 177cdf0e10cSrcweir pImp->nVerEnd = nEnd; 178cdf0e10cSrcweir pImp->bInSetItem = sal_False; 179cdf0e10cSrcweir pImp->nStoringStart = nStartWhich; 180cdf0e10cSrcweir pImp->nStoringEnd = nEndWhich; 181cdf0e10cSrcweir 182cdf0e10cSrcweir memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1)); 183cdf0e10cSrcweir 184cdf0e10cSrcweir if ( pDefaults ) 185cdf0e10cSrcweir SetDefaults(pDefaults); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir // ----------------------------------------------------------------------- 189cdf0e10cSrcweir 190cdf0e10cSrcweir 191cdf0e10cSrcweir SfxItemPool::SfxItemPool 192cdf0e10cSrcweir ( 193cdf0e10cSrcweir const SfxItemPool& rPool, // von dieser Instanz kopieren 194cdf0e10cSrcweir sal_Bool bCloneStaticDefaults /* sal_True 195cdf0e10cSrcweir statische Defaults kopieren 196cdf0e10cSrcweir 197cdf0e10cSrcweir sal_False 198cdf0e10cSrcweir statische Defaults 199cdf0e10cSrcweir "ubernehehmen */ 200cdf0e10cSrcweir ) 201cdf0e10cSrcweir 202cdf0e10cSrcweir /* [Beschreibung] 203cdf0e10cSrcweir 204cdf0e10cSrcweir Copy-Konstruktor der Klasse SfxItemPool. 205cdf0e10cSrcweir 206cdf0e10cSrcweir 207cdf0e10cSrcweir [Querverweise] 208cdf0e10cSrcweir 209cdf0e10cSrcweir <SfxItemPool::Clone()const> 210cdf0e10cSrcweir */ 211cdf0e10cSrcweir 212cdf0e10cSrcweir : aName(rPool.aName), 213cdf0e10cSrcweir nStart(rPool.nStart), 214cdf0e10cSrcweir nEnd(rPool.nEnd), 215cdf0e10cSrcweir #ifdef TF_POOLABLE 216cdf0e10cSrcweir pItemInfos(rPool.pItemInfos), 217cdf0e10cSrcweir #else 218cdf0e10cSrcweir pSlotIds(rPool.pSlotIds), 219cdf0e10cSrcweir #endif 220cdf0e10cSrcweir pImp( new SfxItemPool_Impl( nStart, nEnd ) ), 221cdf0e10cSrcweir ppStaticDefaults(0), 222cdf0e10cSrcweir ppPoolDefaults(new SfxPoolItem* [ nEnd - nStart + 1]), 223cdf0e10cSrcweir pSecondary(0), 224cdf0e10cSrcweir pMaster(this), 225cdf0e10cSrcweir _pPoolRanges( 0 ), 226cdf0e10cSrcweir bPersistentRefCounts(rPool.bPersistentRefCounts ), 227cdf0e10cSrcweir maSfxItemPoolUsers() 228cdf0e10cSrcweir { 229cdf0e10cSrcweir DBG_CTOR(SfxItemPool, 0); 230cdf0e10cSrcweir pImp->eDefMetric = rPool.pImp->eDefMetric; 231cdf0e10cSrcweir pImp->nVersion = rPool.pImp->nVersion; 232cdf0e10cSrcweir pImp->bStreaming = sal_False; 233cdf0e10cSrcweir pImp->nLoadingVersion = 0; 234cdf0e10cSrcweir pImp->nInitRefCount = 1; 235cdf0e10cSrcweir pImp->nVerStart = rPool.pImp->nVerStart; 236cdf0e10cSrcweir pImp->nVerEnd = rPool.pImp->nVerEnd; 237cdf0e10cSrcweir pImp->bInSetItem = sal_False; 238cdf0e10cSrcweir pImp->nStoringStart = nStart; 239cdf0e10cSrcweir pImp->nStoringEnd = nEnd; 240cdf0e10cSrcweir 241cdf0e10cSrcweir memset( ppPoolDefaults, 0, sizeof( SfxPoolItem* ) * (nEnd - nStart + 1)); 242cdf0e10cSrcweir 243cdf0e10cSrcweir // Static Defaults "ubernehmen 244cdf0e10cSrcweir if ( bCloneStaticDefaults ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir SfxPoolItem **ppDefaults = new SfxPoolItem*[nEnd-nStart+1]; 247cdf0e10cSrcweir for ( sal_uInt16 n = 0; n <= nEnd - nStart; ++n ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir (*( ppDefaults + n )) = (*( rPool.ppStaticDefaults + n ))->Clone(this); 250cdf0e10cSrcweir (*( ppDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT ); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir SetDefaults( ppDefaults ); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir else 256cdf0e10cSrcweir SetDefaults( rPool.ppStaticDefaults ); 257cdf0e10cSrcweir 258cdf0e10cSrcweir // Pool Defaults kopieren 259cdf0e10cSrcweir for ( sal_uInt16 n = 0; n <= nEnd - nStart; ++n ) 260cdf0e10cSrcweir if ( (*( rPool.ppPoolDefaults + n )) ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir (*( ppPoolDefaults + n )) = (*( rPool.ppPoolDefaults + n ))->Clone(this); 263cdf0e10cSrcweir (*( ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT ); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir // Copy Version-Map 267cdf0e10cSrcweir for ( size_t nVer = 0; nVer < rPool.pImp->aVersions.size(); ++nVer ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir const SfxPoolVersion_ImplPtr pOld = rPool.pImp->aVersions[nVer]; 270cdf0e10cSrcweir SfxPoolVersion_ImplPtr pNew = SfxPoolVersion_ImplPtr( new SfxPoolVersion_Impl( *pOld ) ); 271cdf0e10cSrcweir pImp->aVersions.push_back( pNew ); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir // Verkettung wiederherstellen 275cdf0e10cSrcweir if ( rPool.pSecondary ) 276cdf0e10cSrcweir SetSecondaryPool( rPool.pSecondary->Clone() ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir // ----------------------------------------------------------------------- 280cdf0e10cSrcweir 281cdf0e10cSrcweir void SfxItemPool::SetDefaults( SfxPoolItem **pDefaults ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 284cdf0e10cSrcweir DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." ); 285cdf0e10cSrcweir DBG_ASSERT( !ppStaticDefaults, "habe schon defaults" ); 286cdf0e10cSrcweir 287cdf0e10cSrcweir ppStaticDefaults = pDefaults; 288cdf0e10cSrcweir //! if ( (*ppStaticDefaults)->GetKind() != SFX_ITEMS_STATICDEFAULT ) 289cdf0e10cSrcweir //! geht wohl nicht im Zshg mit SetItems, die hinten stehen 290cdf0e10cSrcweir { 291cdf0e10cSrcweir DBG_ASSERT( (*ppStaticDefaults)->GetRefCount() == 0 || 292cdf0e10cSrcweir IsDefaultItem( (*ppStaticDefaults) ), 293cdf0e10cSrcweir "das sind keine statics" ); 294cdf0e10cSrcweir for ( sal_uInt16 n = 0; n <= nEnd - nStart; ++n ) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir SFX_ASSERT( (*( ppStaticDefaults + n ))->Which() == n + nStart, 297cdf0e10cSrcweir n + nStart, "static defaults not sorted" ); 298cdf0e10cSrcweir (*( ppStaticDefaults + n ))->SetKind( SFX_ITEMS_STATICDEFAULT ); 299cdf0e10cSrcweir DBG_ASSERT( !(pImp->ppPoolItems[n]), "defaults with setitems with items?!" ); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir // ----------------------------------------------------------------------- 305cdf0e10cSrcweir 306cdf0e10cSrcweir void SfxItemPool::ReleaseDefaults 307cdf0e10cSrcweir ( 308cdf0e10cSrcweir sal_Bool bDelete /* sal_True 309cdf0e10cSrcweir l"oscht sowohl das Array als auch die einzelnen 310cdf0e10cSrcweir statischen Defaults 311cdf0e10cSrcweir 312cdf0e10cSrcweir sal_False 313cdf0e10cSrcweir l"oscht weder das Array noch die einzelnen 314cdf0e10cSrcweir statischen Defaults */ 315cdf0e10cSrcweir ) 316cdf0e10cSrcweir 317cdf0e10cSrcweir /* [Beschreibung] 318cdf0e10cSrcweir 319cdf0e10cSrcweir Gibt die statischen Defaults der betreffenden SfxItemPool-Instanz frei 320cdf0e10cSrcweir und l"oscht ggf. die statischen Defaults. 321cdf0e10cSrcweir 322cdf0e10cSrcweir Nach Aufruf dieser Methode darf die SfxItemPool-Instanz nicht mehr 323cdf0e10cSrcweir verwendet werden, einzig ist der Aufruf des Destruktors zu"lassig. 324cdf0e10cSrcweir */ 325cdf0e10cSrcweir 326cdf0e10cSrcweir { 327cdf0e10cSrcweir DBG_ASSERT( ppStaticDefaults, "keine Arme keine Kekse" ); 328cdf0e10cSrcweir ReleaseDefaults( ppStaticDefaults, nEnd - nStart + 1, bDelete ); 329cdf0e10cSrcweir 330cdf0e10cSrcweir // KSO (22.10.98): ppStaticDefaults zeigt auf geloeschten Speicher, 331cdf0e10cSrcweir // wenn bDelete == sal_True. 332cdf0e10cSrcweir if ( bDelete ) 333cdf0e10cSrcweir ppStaticDefaults = 0; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir 336cdf0e10cSrcweir // ----------------------------------------------------------------------- 337cdf0e10cSrcweir 338cdf0e10cSrcweir void SfxItemPool::ReleaseDefaults 339cdf0e10cSrcweir ( 340cdf0e10cSrcweir SfxPoolItem** pDefaults, /* freizugebende statische Defaults */ 341cdf0e10cSrcweir 342cdf0e10cSrcweir sal_uInt16 nCount, /* Anzahl der statischen Defaults */ 343cdf0e10cSrcweir 344cdf0e10cSrcweir sal_Bool bDelete /* sal_True 345cdf0e10cSrcweir l"oscht sowohl das Array als auch die 346cdf0e10cSrcweir einzelnen statischen Defaults 347cdf0e10cSrcweir 348cdf0e10cSrcweir sal_False 349cdf0e10cSrcweir l"oscht weder das Array noch die 350cdf0e10cSrcweir einzelnen statischen Defaults */ 351cdf0e10cSrcweir ) 352cdf0e10cSrcweir 353cdf0e10cSrcweir /* [Beschreibung] 354cdf0e10cSrcweir 355cdf0e10cSrcweir Gibt die angegebenen statischen Defaults frei und l"oscht ggf. 356cdf0e10cSrcweir die statischen Defaults. 357cdf0e10cSrcweir 358cdf0e10cSrcweir Diese Methode darf erst nach Zerst"orung aller SfxItemPool-Instanzen, 359cdf0e10cSrcweir welche die angegebenen statischen Defaults 'pDefault' verwenden, 360cdf0e10cSrcweir aufgerufen werden. 361cdf0e10cSrcweir */ 362cdf0e10cSrcweir 363cdf0e10cSrcweir { 364cdf0e10cSrcweir DBG_ASSERT( pDefaults, "erst wollen, dann nichts geben..." ); 365cdf0e10cSrcweir 366cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nCount; ++n ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir SFX_ASSERT( IsStaticDefaultItem( *(pDefaults+n) ), 369cdf0e10cSrcweir n, "das ist kein static-default" ); 370cdf0e10cSrcweir (*( pDefaults + n ))->SetRefCount( 0 ); 371cdf0e10cSrcweir if ( bDelete ) 372cdf0e10cSrcweir { delete *( pDefaults + n ); *(pDefaults + n) = 0; } 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir if ( bDelete ) 376cdf0e10cSrcweir { delete[] pDefaults; pDefaults = 0; } 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir // ----------------------------------------------------------------------- 380cdf0e10cSrcweir 381cdf0e10cSrcweir SfxItemPool::~SfxItemPool() 382cdf0e10cSrcweir { 383cdf0e10cSrcweir DBG_DTOR(SfxItemPool, 0); 384cdf0e10cSrcweir DBG_ASSERT( pMaster == this, "destroying active Secondary-Pool" ); 385cdf0e10cSrcweir 386cdf0e10cSrcweir if ( pImp->ppPoolItems && ppPoolDefaults ) 387cdf0e10cSrcweir Delete(); 388cdf0e10cSrcweir delete[] _pPoolRanges; 389cdf0e10cSrcweir delete pImp; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir void SfxItemPool::Free(SfxItemPool* pPool) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir if(pPool) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir // tell all the registered SfxItemPoolUsers that the pool is in destruction 397cdf0e10cSrcweir SfxItemPoolUserVector aListCopy(pPool->maSfxItemPoolUsers.begin(), pPool->maSfxItemPoolUsers.end()); 398cdf0e10cSrcweir for(SfxItemPoolUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); aIterator++) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir SfxItemPoolUser* pSfxItemPoolUser = *aIterator; 401cdf0e10cSrcweir DBG_ASSERT(pSfxItemPoolUser, "corrupt SfxItemPoolUser list (!)"); 402cdf0e10cSrcweir pSfxItemPoolUser->ObjectInDestruction(*pPool); 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir // Clear the vector. This means that user do not need to call RemoveSfxItemPoolUser() 406cdf0e10cSrcweir // when they get called from ObjectInDestruction(). 407cdf0e10cSrcweir pPool->maSfxItemPoolUsers.clear(); 408cdf0e10cSrcweir 409cdf0e10cSrcweir // delete pool 410cdf0e10cSrcweir delete pPool; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir // ----------------------------------------------------------------------- 415cdf0e10cSrcweir 416cdf0e10cSrcweir 417cdf0e10cSrcweir void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir // ggf. an abgeh"angten Pools den Master zur"ucksetzen 420cdf0e10cSrcweir if ( pSecondary ) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir #ifdef DBG_UTIL 423cdf0e10cSrcweir HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" ) 424cdf0e10cSrcweir if ( ppStaticDefaults ) 425cdf0e10cSrcweir { 426cdf0e10cSrcweir // Delete() ist noch nicht gelaufen? 427cdf0e10cSrcweir if ( pImp->ppPoolItems && pSecondary->pImp->ppPoolItems ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir // hat der master SetItems? 430cdf0e10cSrcweir sal_Bool bHasSetItems = sal_False; 431cdf0e10cSrcweir for ( sal_uInt16 i = 0; !bHasSetItems && i < nEnd-nStart; ++i ) 432cdf0e10cSrcweir bHasSetItems = ppStaticDefaults[i]->ISA(SfxSetItem); 433cdf0e10cSrcweir 434cdf0e10cSrcweir // abgehaengte Pools muessen leer sein 435cdf0e10cSrcweir sal_Bool bOK = bHasSetItems; 436cdf0e10cSrcweir for ( sal_uInt16 n = 0; 437cdf0e10cSrcweir bOK && n <= pSecondary->nEnd - pSecondary->nStart; 438cdf0e10cSrcweir ++n ) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir SfxPoolItemArray_Impl** ppItemArr = 441cdf0e10cSrcweir pSecondary->pImp->ppPoolItems + n; 442cdf0e10cSrcweir if ( *ppItemArr ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); 445cdf0e10cSrcweir for( size_t i = (*ppItemArr)->size(); i; ++ppHtArr, --i ) 446cdf0e10cSrcweir if ( !(*ppHtArr) ) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir DBG_ERROR( "old secondary pool must be empty" ); 449cdf0e10cSrcweir bOK = sal_False; 450cdf0e10cSrcweir break; 451cdf0e10cSrcweir } 452cdf0e10cSrcweir } 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir } 456cdf0e10cSrcweir #endif 457cdf0e10cSrcweir 458cdf0e10cSrcweir pSecondary->pMaster = pSecondary; 459cdf0e10cSrcweir for ( SfxItemPool *p = pSecondary->pSecondary; p; p = p->pSecondary ) 460cdf0e10cSrcweir p->pMaster = pSecondary; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir // ggf. den Master der neuen Secondary-Pools setzen 464cdf0e10cSrcweir DBG_ASSERT( !pPool || pPool->pMaster == pPool, "Secondary tanzt auf zwei Hochzeiten " ); 465cdf0e10cSrcweir SfxItemPool *pNewMaster = pMaster ? pMaster : this; 466cdf0e10cSrcweir for ( SfxItemPool *p = pPool; p; p = p->pSecondary ) 467cdf0e10cSrcweir p->pMaster = pNewMaster; 468cdf0e10cSrcweir 469cdf0e10cSrcweir // neuen Secondary-Pool merken 470cdf0e10cSrcweir pSecondary = pPool; 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir // ----------------------------------------------------------------------- 474cdf0e10cSrcweir 475cdf0e10cSrcweir SfxMapUnit SfxItemPool::GetMetric( sal_uInt16 ) const 476cdf0e10cSrcweir { 477cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 478cdf0e10cSrcweir 479cdf0e10cSrcweir return pImp->eDefMetric; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir // ----------------------------------------------------------------------- 483cdf0e10cSrcweir 484cdf0e10cSrcweir void SfxItemPool::SetDefaultMetric( SfxMapUnit eNewMetric ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 487cdf0e10cSrcweir 488cdf0e10cSrcweir pImp->eDefMetric = eNewMetric; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir // ----------------------------------------------------------------------- 492cdf0e10cSrcweir 493cdf0e10cSrcweir SfxItemPresentation SfxItemPool::GetPresentation 494cdf0e10cSrcweir ( 495cdf0e10cSrcweir const SfxPoolItem& rItem, /* IN: <SfxPoolItem>, dessen textuelle 496cdf0e10cSrcweir Wert-Darstellung geliefert werden 497cdf0e10cSrcweir soll */ 498cdf0e10cSrcweir SfxItemPresentation ePresent, /* IN: gew"unschte Art der Darstellung; 499cdf0e10cSrcweir siehe <SfxItemPresentation> */ 500cdf0e10cSrcweir SfxMapUnit eMetric, /* IN: gew"unschte Ma\seinheit der Darstellung */ 501cdf0e10cSrcweir XubString& rText, /* OUT: textuelle Darstellung von 'rItem' */ 502cdf0e10cSrcweir const IntlWrapper * pIntlWrapper 503cdf0e10cSrcweir ) const 504cdf0e10cSrcweir 505cdf0e10cSrcweir /* [Beschreibung] 506cdf0e10cSrcweir 507cdf0e10cSrcweir "Uber diese virtuelle Methode k"onnen textuelle Darstellungen der 508cdf0e10cSrcweir von der jeweilige SfxItemPool-Subklasse verwalteten SfxPoolItems 509cdf0e10cSrcweir angefordert werden. 510cdf0e10cSrcweir 511cdf0e10cSrcweir In Ableitungen sollte diese Methode "uberladen werden und auf 512cdf0e10cSrcweir SfxPoolItems reagiert werden, die bei <SfxPoolItem::GetPresentation()const> 513cdf0e10cSrcweir keine vollst"andige Information liefern k"onnen. 514cdf0e10cSrcweir 515cdf0e10cSrcweir Die Basisklasse liefert die unver"anderte Presentation von 'rItem'. 516cdf0e10cSrcweir */ 517cdf0e10cSrcweir 518cdf0e10cSrcweir { 519cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 520cdf0e10cSrcweir return rItem.GetPresentation( 521cdf0e10cSrcweir ePresent, GetMetric(rItem.Which()), eMetric, rText, pIntlWrapper ); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir 524cdf0e10cSrcweir 525cdf0e10cSrcweir // ----------------------------------------------------------------------- 526cdf0e10cSrcweir 527cdf0e10cSrcweir SfxItemPool* SfxItemPool::Clone() const 528cdf0e10cSrcweir { 529cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 530cdf0e10cSrcweir 531cdf0e10cSrcweir SfxItemPool *pPool = new SfxItemPool( *this ); 532cdf0e10cSrcweir return pPool; 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir // ---------------------------------------------------------------------- 536cdf0e10cSrcweir 537cdf0e10cSrcweir void SfxItemPool::Delete() 538cdf0e10cSrcweir { 539cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 540cdf0e10cSrcweir 541cdf0e10cSrcweir // schon deleted? 542cdf0e10cSrcweir if ( !pImp->ppPoolItems || !ppPoolDefaults ) 543cdf0e10cSrcweir return; 544cdf0e10cSrcweir 545cdf0e10cSrcweir // z.B. laufenden Requests bescheidsagen 546cdf0e10cSrcweir pImp->aBC.Broadcast( SfxSimpleHint( SFX_HINT_DYING ) ); 547cdf0e10cSrcweir 548cdf0e10cSrcweir //MA 16. Apr. 97: Zweimal durchlaufen, in der ersten Runde fuer die SetItems. 549cdf0e10cSrcweir //Der Klarheit halber wird das jetzt in zwei besser lesbare Schleifen aufgeteilt. 550cdf0e10cSrcweir 551cdf0e10cSrcweir SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems; 552cdf0e10cSrcweir SfxPoolItem** ppDefaultItem = ppPoolDefaults; 553cdf0e10cSrcweir SfxPoolItem** ppStaticDefaultItem = ppStaticDefaults; 554cdf0e10cSrcweir sal_uInt16 nArrCnt; 555cdf0e10cSrcweir 556cdf0e10cSrcweir //Erst die SetItems abraeumen 557cdf0e10cSrcweir HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" ) 558cdf0e10cSrcweir if ( ppStaticDefaults ) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir for ( nArrCnt = GetSize_Impl(); 561cdf0e10cSrcweir nArrCnt; 562cdf0e10cSrcweir --nArrCnt, ++ppItemArr, ++ppDefaultItem, ++ppStaticDefaultItem ) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir // KSO (22.10.98): *ppStaticDefaultItem kann im dtor einer 565cdf0e10cSrcweir // von SfxItemPool abgeleiteten Klasse bereits geloescht worden 566cdf0e10cSrcweir // sein! -> CHAOS Itempool 567cdf0e10cSrcweir if ( *ppStaticDefaultItem && (*ppStaticDefaultItem)->ISA(SfxSetItem) ) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir if ( *ppItemArr ) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); 572cdf0e10cSrcweir for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) 573cdf0e10cSrcweir if (*ppHtArr) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir #ifdef DBG_UTIL 576cdf0e10cSrcweir ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() ); 577cdf0e10cSrcweir #endif 578cdf0e10cSrcweir delete *ppHtArr; 579cdf0e10cSrcweir } 580cdf0e10cSrcweir DELETEZ( *ppItemArr ); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir if ( *ppDefaultItem ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir #ifdef DBG_UTIL 585cdf0e10cSrcweir SetRefCount( **ppDefaultItem, 0 ); 586cdf0e10cSrcweir #endif 587cdf0e10cSrcweir DELETEZ( *ppDefaultItem ); 588cdf0e10cSrcweir } 589cdf0e10cSrcweir } 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir ppItemArr = pImp->ppPoolItems; 594cdf0e10cSrcweir ppDefaultItem = ppPoolDefaults; 595cdf0e10cSrcweir 596cdf0e10cSrcweir //Jetzt die 'einfachen' Items 597cdf0e10cSrcweir for ( nArrCnt = GetSize_Impl(); 598cdf0e10cSrcweir nArrCnt; 599cdf0e10cSrcweir --nArrCnt, ++ppItemArr, ++ppDefaultItem ) 600cdf0e10cSrcweir { 601cdf0e10cSrcweir if ( *ppItemArr ) 602cdf0e10cSrcweir { 603cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); 604cdf0e10cSrcweir for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) 605cdf0e10cSrcweir if (*ppHtArr) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir #ifdef DBG_UTIL 608cdf0e10cSrcweir ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() ); 609cdf0e10cSrcweir #endif 610cdf0e10cSrcweir delete *ppHtArr; 611cdf0e10cSrcweir } 612cdf0e10cSrcweir delete *ppItemArr; 613cdf0e10cSrcweir } 614cdf0e10cSrcweir if ( *ppDefaultItem ) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir #ifdef DBG_UTIL 617cdf0e10cSrcweir SetRefCount( **ppDefaultItem, 0 ); 618cdf0e10cSrcweir #endif 619cdf0e10cSrcweir delete *ppDefaultItem; 620cdf0e10cSrcweir } 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir pImp->DeleteItems(); 624cdf0e10cSrcweir delete[] ppPoolDefaults; ppPoolDefaults = 0; 625cdf0e10cSrcweir } 626cdf0e10cSrcweir 627cdf0e10cSrcweir // ---------------------------------------------------------------------- 628cdf0e10cSrcweir 629cdf0e10cSrcweir void SfxItemPool::Cleanup() 630cdf0e10cSrcweir { 631cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 632cdf0e10cSrcweir 633cdf0e10cSrcweir //MA 16. Apr. 97: siehe ::Delete() 634cdf0e10cSrcweir 635cdf0e10cSrcweir SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems; 636cdf0e10cSrcweir SfxPoolItem** ppDefaultItem = ppPoolDefaults; 637cdf0e10cSrcweir SfxPoolItem** ppStaticDefaultItem = ppStaticDefaults; 638cdf0e10cSrcweir sal_uInt16 nArrCnt; 639cdf0e10cSrcweir 640cdf0e10cSrcweir HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" ) 641cdf0e10cSrcweir if ( ppStaticDefaults ) //HACK fuer Image, dort gibt es keine Statics!! 642cdf0e10cSrcweir { 643cdf0e10cSrcweir for ( nArrCnt = GetSize_Impl(); 644cdf0e10cSrcweir nArrCnt; 645cdf0e10cSrcweir --nArrCnt, ++ppItemArr, ++ppDefaultItem, ++ppStaticDefaultItem ) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir //Fuer jedes Item gibt es entweder ein Default oder ein static Default! 648cdf0e10cSrcweir if ( *ppItemArr && 649cdf0e10cSrcweir ((*ppDefaultItem && (*ppDefaultItem)->ISA(SfxSetItem)) || 650cdf0e10cSrcweir (*ppStaticDefaultItem)->ISA(SfxSetItem)) ) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); 653cdf0e10cSrcweir for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) 654cdf0e10cSrcweir if ( *ppHtArr && !(*ppHtArr)->GetRefCount() ) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir DELETEZ(*ppHtArr); 657cdf0e10cSrcweir } 658cdf0e10cSrcweir } 659cdf0e10cSrcweir } 660cdf0e10cSrcweir } 661cdf0e10cSrcweir 662cdf0e10cSrcweir ppItemArr = pImp->ppPoolItems; 663cdf0e10cSrcweir 664cdf0e10cSrcweir for ( nArrCnt = GetSize_Impl(); 665cdf0e10cSrcweir nArrCnt; 666cdf0e10cSrcweir --nArrCnt, ++ppItemArr ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir if ( *ppItemArr ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); 671cdf0e10cSrcweir for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) 672cdf0e10cSrcweir if ( *ppHtArr && !(*ppHtArr)->GetRefCount() ) 673cdf0e10cSrcweir DELETEZ( *ppHtArr ); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir } 676cdf0e10cSrcweir } 677cdf0e10cSrcweir 678cdf0e10cSrcweir // ---------------------------------------------------------------------- 679cdf0e10cSrcweir 680cdf0e10cSrcweir void SfxItemPool::SetPoolDefaultItem(const SfxPoolItem &rItem) 681cdf0e10cSrcweir { 682cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 683cdf0e10cSrcweir if ( IsInRange(rItem.Which()) ) 684cdf0e10cSrcweir { 685cdf0e10cSrcweir SfxPoolItem **ppOldDefault = 686cdf0e10cSrcweir ppPoolDefaults + GetIndex_Impl(rItem.Which()); 687cdf0e10cSrcweir SfxPoolItem *pNewDefault = rItem.Clone(this); 688cdf0e10cSrcweir pNewDefault->SetKind(SFX_ITEMS_POOLDEFAULT); 689cdf0e10cSrcweir if ( *ppOldDefault ) 690cdf0e10cSrcweir { 691cdf0e10cSrcweir (*ppOldDefault)->SetRefCount(0); 692cdf0e10cSrcweir DELETEZ( *ppOldDefault ); 693cdf0e10cSrcweir } 694cdf0e10cSrcweir *ppOldDefault = pNewDefault; 695cdf0e10cSrcweir } 696cdf0e10cSrcweir else if ( pSecondary ) 697cdf0e10cSrcweir pSecondary->SetPoolDefaultItem(rItem); 698cdf0e10cSrcweir else 699cdf0e10cSrcweir { 700cdf0e10cSrcweir SFX_ASSERT( 0, rItem.Which(), "unknown Which-Id - cannot set pool default" ); 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir /* 705cdf0e10cSrcweir * Resets the default of the given <Which-Id> back to the static default. 706cdf0e10cSrcweir * If a pool default exists it is removed. 707cdf0e10cSrcweir */ 708cdf0e10cSrcweir void SfxItemPool::ResetPoolDefaultItem( sal_uInt16 nWhichId ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 711cdf0e10cSrcweir if ( IsInRange(nWhichId) ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir SfxPoolItem **ppOldDefault = 714cdf0e10cSrcweir ppPoolDefaults + GetIndex_Impl( nWhichId ); 715cdf0e10cSrcweir if ( *ppOldDefault ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir (*ppOldDefault)->SetRefCount(0); 718cdf0e10cSrcweir DELETEZ( *ppOldDefault ); 719cdf0e10cSrcweir } 720cdf0e10cSrcweir } 721cdf0e10cSrcweir else if ( pSecondary ) 722cdf0e10cSrcweir pSecondary->ResetPoolDefaultItem(nWhichId); 723cdf0e10cSrcweir else 724cdf0e10cSrcweir { 725cdf0e10cSrcweir SFX_ASSERT( 0, nWhichId, "unknown Which-Id - cannot set pool default" ); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir } 728cdf0e10cSrcweir 729cdf0e10cSrcweir // ----------------------------------------------------------------------- 730cdf0e10cSrcweir 731cdf0e10cSrcweir const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich ) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir DBG_ASSERT( !rItem.ISA(SfxSetItem) || 734cdf0e10cSrcweir 0 != &((const SfxSetItem&)rItem).GetItemSet(), 735cdf0e10cSrcweir "SetItem without ItemSet" ); 736cdf0e10cSrcweir 737cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 738cdf0e10cSrcweir if ( 0 == nWhich ) 739cdf0e10cSrcweir nWhich = rItem.Which(); 740cdf0e10cSrcweir 741cdf0e10cSrcweir // richtigen Secondary-Pool finden 742cdf0e10cSrcweir sal_Bool bSID = nWhich > SFX_WHICH_MAX; 743cdf0e10cSrcweir if ( !bSID && !IsInRange(nWhich) ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir if ( pSecondary ) 746cdf0e10cSrcweir return pSecondary->Put( rItem, nWhich ); 747cdf0e10cSrcweir DBG_ERROR( "unknown Which-Id - cannot put item" ); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir // SID oder nicht poolable (neue Definition)? 751cdf0e10cSrcweir sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich); 752cdf0e10cSrcweir if ( USHRT_MAX == nIndex || 753cdf0e10cSrcweir IsItemFlag_Impl( nIndex, SFX_ITEM_NOT_POOLABLE ) ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir SFX_ASSERT( USHRT_MAX != nIndex || rItem.Which() != nWhich || 756cdf0e10cSrcweir !IsDefaultItem(&rItem) || rItem.GetKind() == SFX_ITEMS_DELETEONIDLE, 757cdf0e10cSrcweir nWhich, "ein nicht Pool-Item ist Default?!" ); 758cdf0e10cSrcweir SfxPoolItem *pPoolItem = rItem.Clone(pMaster); 759cdf0e10cSrcweir pPoolItem->SetWhich(nWhich); 760cdf0e10cSrcweir AddRef( *pPoolItem ); 761cdf0e10cSrcweir return *pPoolItem; 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir SFX_ASSERT( rItem.IsA(GetDefaultItem(nWhich).Type()), nWhich, 765cdf0e10cSrcweir "SFxItemPool: wrong item type in Put" ); 766cdf0e10cSrcweir 767cdf0e10cSrcweir SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems + nIndex; 768cdf0e10cSrcweir if( !*ppItemArr ) 769cdf0e10cSrcweir *ppItemArr = new SfxPoolItemArray_Impl; 770cdf0e10cSrcweir 771cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppFree; 772cdf0e10cSrcweir sal_Bool ppFreeIsSet = sal_False; 773cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArray = (*ppItemArr)->begin(); 774cdf0e10cSrcweir if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) ) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir // wenn es ueberhaupt gepoolt ist, koennte es schon drin sein 777cdf0e10cSrcweir if ( IsPooledItem(&rItem) ) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir // 1. Schleife: teste ob der Pointer vorhanden ist. 780cdf0e10cSrcweir for( size_t n = (*ppItemArr)->size(); n; ++ppHtArray, --n ) 781cdf0e10cSrcweir if( &rItem == (*ppHtArray) ) 782cdf0e10cSrcweir { 783cdf0e10cSrcweir AddRef( **ppHtArray ); 784cdf0e10cSrcweir return **ppHtArray; 785cdf0e10cSrcweir } 786cdf0e10cSrcweir } 787cdf0e10cSrcweir 788cdf0e10cSrcweir // 2. Schleife: dann muessen eben die Attribute verglichen werden 789cdf0e10cSrcweir size_t n; 790cdf0e10cSrcweir for ( n = (*ppItemArr)->size(), ppHtArray = (*ppItemArr)->begin(); 791cdf0e10cSrcweir n; ++ppHtArray, --n ) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir if ( *ppHtArray ) 794cdf0e10cSrcweir { 795cdf0e10cSrcweir if( **ppHtArray == rItem ) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir AddRef( **ppHtArray ); 798cdf0e10cSrcweir return **ppHtArray; 799cdf0e10cSrcweir } 800cdf0e10cSrcweir } 801cdf0e10cSrcweir else 802cdf0e10cSrcweir if ( ppFreeIsSet == sal_False ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir ppFree = ppHtArray; 805cdf0e10cSrcweir ppFreeIsSet = sal_True; 806cdf0e10cSrcweir } 807cdf0e10cSrcweir } 808cdf0e10cSrcweir } 809cdf0e10cSrcweir else 810cdf0e10cSrcweir { 811cdf0e10cSrcweir // freien Platz suchen 812cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr; 813cdf0e10cSrcweir size_t n, nCount = (*ppItemArr)->size(); 814cdf0e10cSrcweir for ( n = (*ppItemArr)->nFirstFree, 815cdf0e10cSrcweir ppHtArr = (*ppItemArr)->begin() + n; 816cdf0e10cSrcweir n < nCount; 817cdf0e10cSrcweir ++ppHtArr, ++n ) 818cdf0e10cSrcweir if ( !*ppHtArr ) 819cdf0e10cSrcweir { 820cdf0e10cSrcweir ppFree = ppHtArr; 821cdf0e10cSrcweir ppFreeIsSet = sal_True; 822cdf0e10cSrcweir break; 823cdf0e10cSrcweir } 824cdf0e10cSrcweir 825cdf0e10cSrcweir // naechstmoeglichen freien Platz merken 826cdf0e10cSrcweir (*ppItemArr)->nFirstFree = n; 827cdf0e10cSrcweir } 828cdf0e10cSrcweir 829cdf0e10cSrcweir // nicht vorhanden, also im PtrArray eintragen 830cdf0e10cSrcweir SfxPoolItem* pNewItem = rItem.Clone(pMaster); 831cdf0e10cSrcweir pNewItem->SetWhich(nWhich); 832cdf0e10cSrcweir #ifdef DBG_UTIL 833cdf0e10cSrcweir SFX_ASSERT( rItem.Type() == pNewItem->Type(), nWhich, "unequal types in Put(): no Clone()?" ) 834cdf0e10cSrcweir #ifdef TF_POOLABLE 835cdf0e10cSrcweir if ( !rItem.ISA(SfxSetItem) ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir SFX_ASSERT( !IsItemFlag(nWhich, SFX_ITEM_POOLABLE) || 838cdf0e10cSrcweir rItem == *pNewItem, 839cdf0e10cSrcweir nWhich, "unequal items in Put(): no operator==?" ); 840cdf0e10cSrcweir SFX_ASSERT( !IsItemFlag(*pNewItem, SFX_ITEM_POOLABLE) || 841cdf0e10cSrcweir *pNewItem == rItem, 842cdf0e10cSrcweir nWhich, "unequal items in Put(): no operator==?" ); 843cdf0e10cSrcweir } 844cdf0e10cSrcweir #endif 845cdf0e10cSrcweir #endif 846cdf0e10cSrcweir AddRef( *pNewItem, pImp->nInitRefCount ); 847cdf0e10cSrcweir SfxPoolItem* pTemp = pNewItem; 848cdf0e10cSrcweir if ( ppFreeIsSet == sal_False ) 849cdf0e10cSrcweir (*ppItemArr)->push_back( pTemp ); 850cdf0e10cSrcweir else 851cdf0e10cSrcweir { 852cdf0e10cSrcweir DBG_ASSERT( *ppFree == 0, "using surrogate in use" ); 853cdf0e10cSrcweir *ppFree = pNewItem; 854cdf0e10cSrcweir } 855cdf0e10cSrcweir return *pNewItem; 856cdf0e10cSrcweir } 857cdf0e10cSrcweir 858cdf0e10cSrcweir // ----------------------------------------------------------------------- 859cdf0e10cSrcweir 860cdf0e10cSrcweir void SfxItemPool::Remove( const SfxPoolItem& rItem ) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 863cdf0e10cSrcweir 864cdf0e10cSrcweir DBG_ASSERT( !rItem.ISA(SfxSetItem) || 865cdf0e10cSrcweir 0 != &((const SfxSetItem&)rItem).GetItemSet(), 866cdf0e10cSrcweir "SetItem without ItemSet" ); 867cdf0e10cSrcweir 868cdf0e10cSrcweir SFX_ASSERT( !IsPoolDefaultItem(&rItem), rItem.Which(), 869cdf0e10cSrcweir "wo kommt denn hier ein Pool-Default her" ); 870cdf0e10cSrcweir 871cdf0e10cSrcweir // richtigen Secondary-Pool finden 872cdf0e10cSrcweir const sal_uInt16 nWhich = rItem.Which(); 873cdf0e10cSrcweir sal_Bool bSID = nWhich > SFX_WHICH_MAX; 874cdf0e10cSrcweir if ( !bSID && !IsInRange(nWhich) ) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir if ( pSecondary ) 877cdf0e10cSrcweir { 878cdf0e10cSrcweir pSecondary->Remove( rItem ); 879cdf0e10cSrcweir return; 880cdf0e10cSrcweir } 881cdf0e10cSrcweir DBG_ERROR( "unknown Which-Id - cannot remove item" ); 882cdf0e10cSrcweir } 883cdf0e10cSrcweir 884cdf0e10cSrcweir // SID oder nicht poolable (neue Definition)? 885cdf0e10cSrcweir sal_uInt16 nIndex = bSID ? USHRT_MAX : GetIndex_Impl(nWhich); 886cdf0e10cSrcweir if ( bSID || IsItemFlag_Impl( nIndex, SFX_ITEM_NOT_POOLABLE ) ) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir SFX_ASSERT( USHRT_MAX != nIndex || 889cdf0e10cSrcweir !IsDefaultItem(&rItem), rItem.Which(), 890cdf0e10cSrcweir "ein nicht Pool-Item ist Default?!" ); 891cdf0e10cSrcweir if ( 0 == ReleaseRef(rItem) ) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir SfxPoolItem *pItem = &(SfxPoolItem &)rItem; 894cdf0e10cSrcweir delete pItem; 895cdf0e10cSrcweir } 896cdf0e10cSrcweir return; 897cdf0e10cSrcweir } 898cdf0e10cSrcweir 899cdf0e10cSrcweir SFX_ASSERT( rItem.GetRefCount(), rItem.Which(), "RefCount == 0, Remove unmoeglich" ); 900cdf0e10cSrcweir 901cdf0e10cSrcweir // statische Defaults sind eben einfach da 902cdf0e10cSrcweir if ( rItem.GetKind() == SFX_ITEMS_STATICDEFAULT && 903cdf0e10cSrcweir &rItem == *( ppStaticDefaults + GetIndex_Impl(nWhich) ) ) 904cdf0e10cSrcweir return; 905cdf0e10cSrcweir 906cdf0e10cSrcweir // Item im eigenen Pool suchen 907cdf0e10cSrcweir SfxPoolItemArray_Impl** ppItemArr = (pImp->ppPoolItems + nIndex); 908cdf0e10cSrcweir SFX_ASSERT( *ppItemArr, rItem.Which(), "removing Item not in Pool" ); 909cdf0e10cSrcweir SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); 910cdf0e10cSrcweir for( size_t n = (*ppItemArr)->size(); n; ++ppHtArr, --n ) 911cdf0e10cSrcweir if( *ppHtArr == &rItem ) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir if ( (*ppHtArr)->GetRefCount() ) //! 914cdf0e10cSrcweir ReleaseRef( **ppHtArr ); 915cdf0e10cSrcweir else 916cdf0e10cSrcweir { 917cdf0e10cSrcweir SFX_ASSERT( 0, rItem.Which(), "removing Item without ref" ); 918cdf0e10cSrcweir SFX_TRACE( "to be removed, but not no refs: ", *ppHtArr ); 919cdf0e10cSrcweir } 920cdf0e10cSrcweir 921cdf0e10cSrcweir // ggf. kleinstmoegliche freie Position merken 922cdf0e10cSrcweir size_t nPos = (*ppItemArr)->size() - n; 923cdf0e10cSrcweir if ( (*ppItemArr)->nFirstFree > nPos ) 924cdf0e10cSrcweir (*ppItemArr)->nFirstFree = nPos; 925cdf0e10cSrcweir 926cdf0e10cSrcweir //! MI: Hack, solange wir das Problem mit dem Outliner haben 927cdf0e10cSrcweir //! siehe anderes MI-REF 928cdf0e10cSrcweir if ( 0 == (*ppHtArr)->GetRefCount() && nWhich < 4000 ) 929cdf0e10cSrcweir DELETEZ(*ppHtArr); 930cdf0e10cSrcweir return; 931cdf0e10cSrcweir } 932cdf0e10cSrcweir 933cdf0e10cSrcweir // nicht vorhanden 934cdf0e10cSrcweir SFX_ASSERT( 0, rItem.Which(), "removing Item not in Pool" ); 935cdf0e10cSrcweir SFX_TRACE( "to be removed, but not in pool: ", &rItem ); 936cdf0e10cSrcweir } 937cdf0e10cSrcweir 938cdf0e10cSrcweir // ----------------------------------------------------------------------- 939cdf0e10cSrcweir 940cdf0e10cSrcweir const SfxPoolItem& SfxItemPool::GetDefaultItem( sal_uInt16 nWhich ) const 941cdf0e10cSrcweir { 942cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 943cdf0e10cSrcweir 944cdf0e10cSrcweir if ( !IsInRange(nWhich) ) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir if ( pSecondary ) 947cdf0e10cSrcweir return pSecondary->GetDefaultItem( nWhich ); 948cdf0e10cSrcweir SFX_ASSERT( 0, nWhich, "unknown which - dont ask me for defaults" ); 949cdf0e10cSrcweir } 950cdf0e10cSrcweir 951cdf0e10cSrcweir DBG_ASSERT( ppStaticDefaults, "no defaults known - dont ask me for defaults" ); 952cdf0e10cSrcweir sal_uInt16 nPos = GetIndex_Impl(nWhich); 953cdf0e10cSrcweir SfxPoolItem *pDefault = *(ppPoolDefaults + nPos); 954cdf0e10cSrcweir if ( pDefault ) 955cdf0e10cSrcweir return *pDefault; 956cdf0e10cSrcweir return **(ppStaticDefaults + nPos); 957cdf0e10cSrcweir } 958cdf0e10cSrcweir 959cdf0e10cSrcweir // ----------------------------------------------------------------------- 960cdf0e10cSrcweir 961cdf0e10cSrcweir 962cdf0e10cSrcweir void SfxItemPool::FreezeIdRanges() 963cdf0e10cSrcweir 964cdf0e10cSrcweir /* [Beschreibung] 965cdf0e10cSrcweir 966cdf0e10cSrcweir This method should be called at the master pool, when all secondary 967cdf0e10cSrcweir pools are appended to it. 968cdf0e10cSrcweir 969cdf0e10cSrcweir It calculates the ranges of 'which-ids' for fast construction of 970cdf0e10cSrcweir item-sets, which contains all 'which-ids'. 971cdf0e10cSrcweir */ 972cdf0e10cSrcweir 973cdf0e10cSrcweir { 974cdf0e10cSrcweir FillItemIdRanges_Impl( _pPoolRanges ); 975cdf0e10cSrcweir } 976cdf0e10cSrcweir 977cdf0e10cSrcweir 978cdf0e10cSrcweir // ----------------------------------------------------------------------- 979cdf0e10cSrcweir 980cdf0e10cSrcweir void SfxItemPool::FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const 981cdf0e10cSrcweir { 982cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 983cdf0e10cSrcweir DBG_ASSERT( !_pPoolRanges, "GetFrozenRanges() would be faster!" ); 984cdf0e10cSrcweir 985cdf0e10cSrcweir const SfxItemPool *pPool; 986cdf0e10cSrcweir sal_uInt16 nLevel = 0; 987cdf0e10cSrcweir for( pPool = this; pPool; pPool = pPool->pSecondary ) 988cdf0e10cSrcweir ++nLevel; 989cdf0e10cSrcweir 990cdf0e10cSrcweir pWhichRanges = new sal_uInt16[ 2*nLevel + 1 ]; 991cdf0e10cSrcweir 992cdf0e10cSrcweir nLevel = 0; 993cdf0e10cSrcweir for( pPool = this; pPool; pPool = pPool->pSecondary ) 994cdf0e10cSrcweir { 995cdf0e10cSrcweir *(pWhichRanges+(nLevel++)) = pPool->nStart; 996cdf0e10cSrcweir *(pWhichRanges+(nLevel++)) = pPool->nEnd; 997cdf0e10cSrcweir *(pWhichRanges+nLevel) = 0; 998cdf0e10cSrcweir } 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir 1001cdf0e10cSrcweir // ----------------------------------------------------------------------- 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) const 1004cdf0e10cSrcweir { 1005cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 1006cdf0e10cSrcweir 1007cdf0e10cSrcweir if ( !IsInRange(nWhich) ) 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir if ( pSecondary ) 1010cdf0e10cSrcweir return pSecondary->GetItem2( nWhich, nOfst ); 1011cdf0e10cSrcweir SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" ); 1012cdf0e10cSrcweir return 0; 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir // dflt-Attribut? 1016cdf0e10cSrcweir if ( nOfst == SFX_ITEMS_DEFAULT ) 1017cdf0e10cSrcweir return *(ppStaticDefaults + GetIndex_Impl(nWhich)); 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); 1020cdf0e10cSrcweir if( pItemArr && nOfst < pItemArr->size() ) 1021cdf0e10cSrcweir return (*pItemArr)[nOfst]; 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir return 0; 1024cdf0e10cSrcweir } 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir // ----------------------------------------------------------------------- 1027cdf0e10cSrcweir 1028cdf0e10cSrcweir sal_uInt32 SfxItemPool::GetItemCount2(sal_uInt16 nWhich) const 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir DBG_CHKTHIS(SfxItemPool, 0); 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir if ( !IsInRange(nWhich) ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir if ( pSecondary ) 1035cdf0e10cSrcweir return pSecondary->GetItemCount2( nWhich ); 1036cdf0e10cSrcweir SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" ); 1037cdf0e10cSrcweir return 0; 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); 1041cdf0e10cSrcweir if ( pItemArr ) 1042cdf0e10cSrcweir return pItemArr->size(); 1043cdf0e10cSrcweir return 0; 1044cdf0e10cSrcweir } 1045cdf0e10cSrcweir 1046cdf0e10cSrcweir // ----------------------------------------------------------------------- 1047cdf0e10cSrcweir 1048cdf0e10cSrcweir sal_uInt16 SfxItemPool::GetWhich( sal_uInt16 nSlotId, sal_Bool bDeep ) const 1049cdf0e10cSrcweir { 1050cdf0e10cSrcweir if ( !IsSlot(nSlotId) ) 1051cdf0e10cSrcweir return nSlotId; 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir #ifdef TF_POOLABLE 1054cdf0e10cSrcweir sal_uInt16 nCount = nEnd - nStart + 1; 1055cdf0e10cSrcweir for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs ) 1056cdf0e10cSrcweir if ( pItemInfos[nOfs]._nSID == nSlotId ) 1057cdf0e10cSrcweir return nOfs + nStart; 1058cdf0e10cSrcweir #else 1059cdf0e10cSrcweir if ( pSlotIds ) 1060cdf0e10cSrcweir { 1061cdf0e10cSrcweir sal_uInt16 nCount = nEnd - nStart + 1; 1062cdf0e10cSrcweir for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs ) 1063cdf0e10cSrcweir if ( pSlotIds[nOfs] == nSlotId ) 1064cdf0e10cSrcweir return nOfs + nStart; 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir #endif 1067cdf0e10cSrcweir if ( pSecondary && bDeep ) 1068cdf0e10cSrcweir return pSecondary->GetWhich(nSlotId); 1069cdf0e10cSrcweir return nSlotId; 1070cdf0e10cSrcweir } 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir // ----------------------------------------------------------------------- 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir sal_uInt16 SfxItemPool::GetSlotId( sal_uInt16 nWhich, sal_Bool bDeep ) const 1075cdf0e10cSrcweir { 1076cdf0e10cSrcweir if ( !IsWhich(nWhich) ) 1077cdf0e10cSrcweir return nWhich; 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir if ( !IsInRange( nWhich ) ) 1080cdf0e10cSrcweir { 1081cdf0e10cSrcweir if ( pSecondary && bDeep ) 1082cdf0e10cSrcweir return pSecondary->GetSlotId(nWhich); 1083cdf0e10cSrcweir SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get slot-id" ); 1084cdf0e10cSrcweir return 0; 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir #ifdef TF_POOLABLE 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir sal_uInt16 nSID = pItemInfos[nWhich - nStart]._nSID; 1089cdf0e10cSrcweir return nSID ? nSID : nWhich; 1090cdf0e10cSrcweir #else 1091cdf0e10cSrcweir else if ( pSlotIds ) 1092cdf0e10cSrcweir return pSlotIds[nWhich - nStart]; 1093cdf0e10cSrcweir return nWhich; 1094cdf0e10cSrcweir #endif 1095cdf0e10cSrcweir } 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir // ----------------------------------------------------------------------- 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir sal_uInt16 SfxItemPool::GetTrueWhich( sal_uInt16 nSlotId, sal_Bool bDeep ) const 1100cdf0e10cSrcweir { 1101cdf0e10cSrcweir if ( !IsSlot(nSlotId) ) 1102cdf0e10cSrcweir return 0; 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir #ifdef TF_POOLABLE 1105cdf0e10cSrcweir sal_uInt16 nCount = nEnd - nStart + 1; 1106cdf0e10cSrcweir for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs ) 1107cdf0e10cSrcweir if ( pItemInfos[nOfs]._nSID == nSlotId ) 1108cdf0e10cSrcweir return nOfs + nStart; 1109cdf0e10cSrcweir #else 1110cdf0e10cSrcweir if ( pSlotIds ) 1111cdf0e10cSrcweir { 1112cdf0e10cSrcweir sal_uInt16 nCount = nEnd - nStart + 1; 1113cdf0e10cSrcweir for ( sal_uInt16 nOfs = 0; nOfs < nCount; ++nOfs ) 1114cdf0e10cSrcweir if ( pSlotIds[nOfs] == nSlotId ) 1115cdf0e10cSrcweir return nOfs + nStart; 1116cdf0e10cSrcweir } 1117cdf0e10cSrcweir #endif 1118cdf0e10cSrcweir if ( pSecondary && bDeep ) 1119cdf0e10cSrcweir return pSecondary->GetTrueWhich(nSlotId); 1120cdf0e10cSrcweir return 0; 1121cdf0e10cSrcweir } 1122cdf0e10cSrcweir 1123cdf0e10cSrcweir // ----------------------------------------------------------------------- 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir sal_uInt16 SfxItemPool::GetTrueSlotId( sal_uInt16 nWhich, sal_Bool bDeep ) const 1126cdf0e10cSrcweir { 1127cdf0e10cSrcweir if ( !IsWhich(nWhich) ) 1128cdf0e10cSrcweir return 0; 1129cdf0e10cSrcweir 1130cdf0e10cSrcweir if ( !IsInRange( nWhich ) ) 1131cdf0e10cSrcweir { 1132cdf0e10cSrcweir if ( pSecondary && bDeep ) 1133cdf0e10cSrcweir return pSecondary->GetTrueSlotId(nWhich); 1134cdf0e10cSrcweir SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot get slot-id" ); 1135cdf0e10cSrcweir return 0; 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir #ifdef TF_POOLABLE 1138cdf0e10cSrcweir return pItemInfos[nWhich - nStart]._nSID; 1139cdf0e10cSrcweir #else 1140cdf0e10cSrcweir else if ( pSlotIds ) 1141cdf0e10cSrcweir return pSlotIds[nWhich - nStart]; 1142cdf0e10cSrcweir else 1143cdf0e10cSrcweir return 0; 1144cdf0e10cSrcweir #endif 1145cdf0e10cSrcweir } 1146cdf0e10cSrcweir // ----------------------------------------------------------------------- 1147cdf0e10cSrcweir void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion ) 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir /* [Description] 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir You must call this function to set the file format version after 1152cdf0e10cSrcweir concatenating your secondary-pools but before you store any 1153cdf0e10cSrcweir pool, itemset or item. Only set the version at the master pool, 1154cdf0e10cSrcweir never at any secondary pool. 1155cdf0e10cSrcweir */ 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir { 1158cdf0e10cSrcweir DBG_ASSERT( this == pMaster, 1159cdf0e10cSrcweir "SfxItemPool::SetFileFormatVersion() but not a master pool" ); 1160cdf0e10cSrcweir for ( SfxItemPool *pPool = this; pPool; pPool = pPool->pSecondary ) 1161cdf0e10cSrcweir pPool->_nFileFormatVersion = nFileFormatVersion; 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir 1165