From be6d65ae721090df56376ac75946f8645815a8ff Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 27 Aug 2010 13:21:36 +0200 Subject: sw34bf01: SFX_ASSERT: do not use DbgOut directly --- svl/source/items/whassert.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svl') diff --git a/svl/source/items/whassert.hxx b/svl/source/items/whassert.hxx index 9933294b4d86..237cf73f6c7f 100644 --- a/svl/source/items/whassert.hxx +++ b/svl/source/items/whassert.hxx @@ -42,7 +42,7 @@ ByteString aMsg( sMessage ); \ aMsg.Append(RTL_CONSTASCII_STRINGPARAM("\nwith Id/Pos: ")); \ aMsg += ByteString::CreateFromInt32( nId ); \ - DbgOut( aMsg.GetBuffer(), DBG_OUT_ERROR, __FILE__, __LINE__); \ + DbgError( aMsg.GetBuffer(), __FILE__, __LINE__); \ } \ } \ } -- cgit From b1fb8ecaafaeeb353b53f07c03aaf7dc58dccd96 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Fri, 17 Sep 2010 19:06:31 +0200 Subject: svarray --- svl/inc/poolcach.hxx | 13 ++- svl/inc/svl/svarray.hxx | 189 ------------------------------------------ svl/source/inc/poolio.hxx | 5 +- svl/source/items/itempool.cxx | 19 ++--- svl/source/items/poolcach.cxx | 20 +---- svl/source/items/poolio.cxx | 32 +++---- 6 files changed, 42 insertions(+), 236 deletions(-) (limited to 'svl') diff --git a/svl/inc/poolcach.hxx b/svl/inc/poolcach.hxx index 949c0aee5bad..78bdca8177e6 100644 --- a/svl/inc/poolcach.hxx +++ b/svl/inc/poolcach.hxx @@ -29,13 +29,24 @@ #include "svl/svldllapi.h" #include +#include + +//------------------------------------------------------------------------ -class SfxItemModifyArr_Impl; class SfxItemPool; class SfxItemSet; class SfxPoolItem; class SfxSetItem; +struct SfxItemModifyImpl +{ + const SfxSetItem *pOrigItem; + SfxSetItem *pPoolItem; +}; + +typedef std::vector SfxItemModifyArr_Impl; + + class SVL_DLLPUBLIC SfxItemPoolCache { SfxItemPool *pPool; diff --git a/svl/inc/svl/svarray.hxx b/svl/inc/svl/svarray.hxx index 99b2901b95f9..c16f251402a7 100644 --- a/svl/inc/svl/svarray.hxx +++ b/svl/inc/svl/svarray.hxx @@ -39,12 +39,6 @@ * enthaelt. (Sie werden im Speicher verschoben, koennen also * z.B. keine String sein) * -* SV_DECL_OBJARR(nm, AE, IS, GS) -* SV_IMPL_OBJARR( nm, AE ) -* definiere/implementiere ein Array das Objecte enthaelt. -* (Hier koennen es auch Strings sein) -* -* * SV_DECL_PTRARR(nm, AE, IS, GS) * SV_IMPL_PTRARR(nm, AE) * definiere/implementiere ein Array das Pointer haelt. Diese @@ -332,189 +326,6 @@ SV_IMPL_VARARR_GEN( nm, AE, AE & ) #define SV_IMPL_VARARR_PLAIN( nm, AE ) \ SV_IMPL_VARARR_GEN( nm, AE, AE ) -#if defined(PRODUCT) - -#define _SVOBJARR_DEF_GET_OP_INLINE( nm,ArrElem )\ -ArrElem& operator[](USHORT nP) const { return *(pData+nP); }\ -\ -void Insert( const nm *pI, USHORT nP,\ - USHORT nS = 0, USHORT nE = USHRT_MAX )\ -{\ - if( USHRT_MAX == nE ) \ - nE = pI->nA; \ - if( nS < nE ) \ - Insert( (const ArrElem*)pI->pData+nS, (USHORT)nE-nS, nP );\ -} - -#define _SVOBJARR_IMPL_GET_OP_INLINE( nm, ArrElem ) - -#else - -#define _SVOBJARR_DEF_GET_OP_INLINE( nm,ArrElem ) \ -ArrElem& operator[](USHORT nP) const;\ -void Insert( const nm *pI, USHORT nP,\ - USHORT nS = 0, USHORT nE = USHRT_MAX ); - -#define _SVOBJARR_IMPL_GET_OP_INLINE( nm, ArrElem )\ -ArrElem& nm::operator[](USHORT nP) const\ -{\ - DBG_ASSERT( pData && nP < nA,"Op[]");\ - return *(pData+nP);\ -}\ -void nm::Insert( const nm *pI, USHORT nP, USHORT nStt, USHORT nE )\ -{\ - DBG_ASSERT( nP <= nA,"Ins,Ar[Start.End]");\ - if( USHRT_MAX == nE ) \ - nE = pI->nA; \ - if( nStt < nE ) \ - Insert( (const ArrElem*)pI->pData+nStt, (USHORT)nE-nStt, nP );\ -} - -#endif - -#define _SV_DECL_OBJARR(nm, AE, IS, GS)\ -typedef BOOL (*FnForEach_##nm)( const AE&, void* );\ -class nm\ -{\ -protected:\ - AE *pData;\ - USHORT nFree;\ - USHORT nA;\ -\ - void _resize(size_t n);\ - void _destroy();\ -\ -public:\ - nm( USHORT= IS, BYTE= GS );\ - ~nm() { _destroy(); }\ -\ - _SVOBJARR_DEF_GET_OP_INLINE(nm,AE)\ - AE& GetObject(USHORT nP) const { return (*this)[nP]; } \ -\ - void Insert( const AE &aE, USHORT nP );\ - void Insert( const AE *pE, USHORT nL, USHORT nP );\ - void Remove( USHORT nP, USHORT nL = 1 );\ - USHORT Count() const { return nA; }\ - const AE* GetData() const { return (const AE*)pData; }\ -\ - void ForEach( CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\ - {\ - _ForEach( 0, nA, fnForEach, pArgs );\ - }\ - void ForEach( USHORT nS, USHORT nE, \ - CONCAT( FnForEach_, nm ) fnForEach, void* pArgs = 0 )\ - {\ - _ForEach( nS, nE, fnForEach, pArgs );\ - }\ -\ - void _ForEach( USHORT nStt, USHORT nE, \ - CONCAT( FnForEach_, nm ) fnCall, void* pArgs = 0 );\ -\ - -#define SV_DECL_OBJARR(nm, AE, IS, GS)\ -_SV_DECL_OBJARR(nm, AE, IS, GS)\ -private:\ -nm( const nm& );\ -nm& operator=( const nm& );\ -}; - -#define SV_IMPL_OBJARR( nm, AE )\ -nm::nm( USHORT nInit, BYTE )\ - : pData (0),\ - nFree (nInit),\ - nA (0)\ -{\ - if( nInit )\ - {\ - pData = (AE*)(rtl_allocateMemory(sizeof(AE) * nInit));\ - DBG_ASSERT( pData, "CTOR, allocate");\ - }\ -}\ -\ -void nm::_destroy()\ -{\ - if(pData)\ - {\ - AE* pTmp=pData;\ - for(USHORT n=0; n < nA; n++,pTmp++ )\ - {\ - pTmp->~AE();\ - }\ - rtl_freeMemory(pData);\ - pData = 0;\ - }\ -}\ -\ -void nm::_resize (size_t n)\ -{\ - USHORT nL = ((n < USHRT_MAX) ? USHORT(n) : USHRT_MAX);\ - AE* pE = (AE*)(rtl_reallocateMemory (pData, sizeof(AE) * nL));\ - if ((pE != 0) || (nL == 0))\ - {\ - pData = pE;\ - nFree = nL - nA;\ - }\ -}\ -\ -void nm::Insert( const AE &aE, USHORT nP )\ -{\ - DBG_ASSERT( nP <= nA && nA < USHRT_MAX,"Ins 1");\ - if (nFree < 1)\ - _resize (nA + ((nA > 1) ? nA : 1));\ - if( pData && nP < nA )\ - memmove( pData+nP+1, pData+nP, (nA-nP) * sizeof( AE ));\ - AE* pTmp = pData+nP;\ - new( (DummyType*) pTmp ) AE( (AE&)aE );\ - ++nA; --nFree;\ -}\ -\ -void nm::Insert( const AE* pE, USHORT nL, USHORT nP )\ -{\ - DBG_ASSERT(nP<=nA && ((long)nA+nL) < USHRT_MAX, "Ins n");\ - if (nFree < nL)\ - _resize (nA + ((nA > nL) ? nA : nL));\ - if( pData && nP < nA )\ - memmove( pData+nP+nL, pData+nP, (nA-nP) * sizeof( AE ));\ - if( pE )\ - {\ - AE* pTmp = pData+nP;\ - for( USHORT n = 0; n < nL; n++, pTmp++, pE++)\ - {\ - new( (DummyType*) pTmp ) AE( (AE&)*pE );\ - }\ - }\ - nA = nA + nL; nFree = nFree - nL;\ -}\ -\ -void nm::Remove( USHORT nP, USHORT nL )\ -{\ - if( !nL )\ - return;\ - DBG_ASSERT( nP < nA && nP + nL <= nA,"Del");\ - AE* pTmp=pData+nP;\ - USHORT nCtr = nP;\ - for(USHORT n=0; n < nL; n++,pTmp++,nCtr++)\ - {\ - if( nCtr < nA )\ - pTmp->~AE();\ - }\ - if( pData && nP+1 < nA )\ - memmove( pData+nP, pData+nP+nL, (nA-nP-nL) * sizeof( AE ));\ - nA = nA - nL; nFree = nFree + nL;\ - if (nFree > nA) \ - _resize (nA);\ -}\ -\ -void nm::_ForEach( USHORT nStt, USHORT nE, \ - CONCAT( FnForEach_, nm ) fnCall, void* pArgs )\ -{\ - if( nStt >= nE || nE > nA )\ - return;\ - for( ; nStt < nE && (*fnCall)( *(pData+nStt), pArgs ); nStt++)\ - ;\ -}\ -\ -_SVOBJARR_IMPL_GET_OP_INLINE(nm, AE)\ #define _SV_DECL_PTRARR_DEF_GEN( nm, AE, IS, GS, AERef, vis )\ _SV_DECL_VARARR_GEN( nm, AE, IS, GS, AERef, vis)\ diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index 70122a5b1998..10a1f1939238 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -25,6 +25,7 @@ * ************************************************************************/ #include +#include #ifndef DELETEZ @@ -54,7 +55,9 @@ struct SfxPoolVersion_Impl }; SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl, SfxPoolItem*, 0, 5 ) -SV_DECL_PTRARR_DEL( SfxPoolVersionArr_Impl, SfxPoolVersion_Impl*, 0, 2 ) + +typedef boost::shared_ptr< SfxPoolVersion_Impl > SfxPoolVersion_ImplPtr; +typedef std::vector< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl; struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl { diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 5c5f106a1c36..63b5c710202c 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -39,13 +39,7 @@ #include #include "poolio.hxx" #include - -// STATIC DATA ----------------------------------------------------------- - - -//======================================================================== - -SV_IMPL_PTRARR( SfxPoolVersionArr_Impl, SfxPoolVersion_Impl* ); +#include //======================================================================== @@ -275,13 +269,12 @@ SfxItemPool::SfxItemPool (*( ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT ); } - // Version-Map kopieren - USHORT nVerCount = rPool.pImp->aVersions.Count(); - for ( USHORT nVer = 0; nVer < nVerCount; ++nVer ) + // Copy Version-Map + for ( size_t nVer = 0; nVer < rPool.pImp->aVersions.size(); ++nVer ) { - const SfxPoolVersion_Impl *pOld = rPool.pImp->aVersions.GetObject(nVer); - const SfxPoolVersion_Impl *pNew = new SfxPoolVersion_Impl( *pOld ); - pImp->aVersions.Insert( pNew, nVer ); + const SfxPoolVersion_ImplPtr pOld = rPool.pImp->aVersions[nVer]; + SfxPoolVersion_ImplPtr pNew = SfxPoolVersion_ImplPtr( new SfxPoolVersion_Impl( *pOld ) ); + pImp->aVersions.push_back( pNew ); } // Verkettung wiederherstellen diff --git a/svl/source/items/poolcach.cxx b/svl/source/items/poolcach.cxx index b918add10f0f..fee18724bcc2 100644 --- a/svl/source/items/poolcach.cxx +++ b/svl/source/items/poolcach.cxx @@ -41,18 +41,6 @@ DBG_NAME(SfxItemPoolCache) - -//------------------------------------------------------------------------ - -struct SfxItemModifyImpl -{ - const SfxSetItem *pOrigItem; - SfxSetItem *pPoolItem; -}; - -SV_DECL_VARARR( SfxItemModifyArr_Impl, SfxItemModifyImpl, 8, 8 ) -SV_IMPL_VARARR( SfxItemModifyArr_Impl, SfxItemModifyImpl); - //------------------------------------------------------------------------ SfxItemPoolCache::SfxItemPoolCache( SfxItemPool *pItemPool, @@ -84,7 +72,7 @@ SfxItemPoolCache::SfxItemPoolCache( SfxItemPool *pItemPool, SfxItemPoolCache::~SfxItemPoolCache() { DBG_DTOR(SfxItemPoolCache, 0); - for ( USHORT nPos = 0; nPos < pCache->Count(); ++nPos ) { + for ( size_t nPos = 0; nPos < pCache->size(); ++nPos ) { pPool->Remove( *(*pCache)[nPos].pPoolItem ); pPool->Remove( *(*pCache)[nPos].pOrigItem ); } @@ -103,8 +91,8 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, BOOL b DBG_ASSERT( IsDefaultItem( &rOrigItem ) || IsPooledItem( &rOrigItem ), "original not in pool" ); - // Suchen, ob diese Transformations schon einmal vorkam - for ( USHORT nPos = 0; nPos < pCache->Count(); ++nPos ) + // Find whether this Transformations ever occurred + for ( size_t nPos = 0; nPos < pCache->size(); ++nPos ) { SfxItemModifyImpl &rMapEntry = (*pCache)[nPos]; if ( rMapEntry.pOrigItem == &rOrigItem ) @@ -143,7 +131,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, BOOL b SfxItemModifyImpl aModify; aModify.pOrigItem = &rOrigItem; aModify.pPoolItem = (SfxSetItem*) pNewPoolItem; - pCache->Insert( aModify, pCache->Count() ); + pCache->push_back( aModify ); DBG_ASSERT( !pItemToPut || &pNewPoolItem->GetItemSet().Get( pItemToPut->Which() ) == pItemToPut, diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index 6aeb64d76d1a..332d5e01da9c 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -178,10 +178,10 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const // Version-Maps { SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP, 0 ); - for ( USHORT nVerNo = 0; nVerNo < pImp->aVersions.Count(); ++nVerNo ) + for ( size_t nVerNo = 0; nVerNo < pImp->aVersions.size(); ++nVerNo ) { aVerRec.NewContent(); - SfxPoolVersion_Impl *pVer = pImp->aVersions[nVerNo]; + SfxPoolVersion_ImplPtr pVer = pImp->aVersions[nVerNo]; rStream << pVer->_nVer << pVer->_nStart << pVer->_nEnd; USHORT nCount = pVer->_nEnd - pVer->_nStart + 1; USHORT nNewWhich = 0; @@ -611,10 +611,10 @@ SvStream &SfxItemPool::Load(SvStream &rStream) rStream >> nVersion >> nHStart >> nHEnd; USHORT nCount = nHEnd - nHStart + 1; - // Version neuer als bekannt? - if ( nVerNo >= pImp->aVersions.Count() ) + // Is new version is known? + if ( nVerNo >= pImp->aVersions.size() ) { - // neue Version hinzufuegen + // Add new Version USHORT *pMap = new USHORT[nCount]; for ( USHORT n = 0; n < nCount; ++n ) rStream >> pMap[n]; @@ -799,10 +799,10 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) USHORT nCount = nHEnd - nHStart + 1; USHORT nBytes = (nCount)*sizeof(USHORT); - // Version neuer als bekannt? - if ( nVerNo >= pImp->aVersions.Count() ) + // Is new version is known? + if ( nVerNo >= pImp->aVersions.size() ) { - // neue Version hinzufuegen + // Add new Version USHORT *pMap = new USHORT[nCount]; for ( USHORT n = 0; n < nCount; ++n ) rStream >> pMap[n]; @@ -1326,10 +1326,10 @@ void SfxItemPool::SetVersionMap */ { - // neuen Map-Eintrag erzeugen und einf"ugen - const SfxPoolVersion_Impl *pVerMap = new SfxPoolVersion_Impl( - nVer, nOldStart, nOldEnd, pOldWhichIdTab ); - pImp->aVersions.Insert( pVerMap, pImp->aVersions.Count() ); + // create new map entry to insert + const SfxPoolVersion_ImplPtr pVerMap = SfxPoolVersion_ImplPtr( new SfxPoolVersion_Impl( + nVer, nOldStart, nOldEnd, pOldWhichIdTab ) ); + pImp->aVersions.push_back( pVerMap ); DBG_ASSERT( nVer > pImp->nVersion, "Versions not sorted" ); pImp->nVersion = nVer; @@ -1398,9 +1398,9 @@ USHORT SfxItemPool::GetNewWhich if ( nDiff > 0 ) { // von der Top-Version bis runter zur File-Version stufenweise mappen - for ( USHORT nMap = pImp->aVersions.Count(); nMap > 0; --nMap ) + for ( size_t nMap = pImp->aVersions.size(); nMap > 0; --nMap ) { - SfxPoolVersion_Impl *pVerInfo = pImp->aVersions[nMap-1]; + SfxPoolVersion_ImplPtr pVerInfo = pImp->aVersions[nMap-1]; if ( pVerInfo->_nVer > pImp->nVersion ) { USHORT nOfs; USHORT nCount = pVerInfo->_nEnd - pVerInfo->_nStart + 1; @@ -1424,9 +1424,9 @@ USHORT SfxItemPool::GetNewWhich else if ( nDiff < 0 ) { // von der File-Version bis zur aktuellen Version stufenweise mappen - for ( USHORT nMap = 0; nMap < pImp->aVersions.Count(); ++nMap ) + for ( size_t nMap = 0; nMap < pImp->aVersions.size(); ++nMap ) { - SfxPoolVersion_Impl *pVerInfo = pImp->aVersions[nMap]; + SfxPoolVersion_ImplPtr pVerInfo = pImp->aVersions[nMap]; if ( pVerInfo->_nVer > pImp->nLoadingVersion ) { DBG_ASSERT( nFileWhich >= pVerInfo->_nStart && -- cgit From f47066b0c1217b8b068eeb59a95c8f656a76d871 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Tue, 21 Sep 2010 22:45:53 +0200 Subject: svarray: #i112395#: replace SV_DECL_PTRARR_STACK with deque --- svl/inc/svl/svarray.hxx | 52 ------------------------------------------------- 1 file changed, 52 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/svarray.hxx b/svl/inc/svl/svarray.hxx index c16f251402a7..3c300ec75099 100644 --- a/svl/inc/svl/svarray.hxx +++ b/svl/inc/svl/svarray.hxx @@ -80,10 +80,6 @@ * Basiert auf einem VARARR. * Sortierung mit Hilfe der Object-operatoren "<" und "==" * -* JP 23.12.94 neu: -* SV_DECL_PTRARR_STACK(nm, AE, IS, GS) -* ein Stack mit einem PtrArray als Grundlage. -* * JP 09.10.96: vordefinierte Arrays: * VarArr: SvBools, SvULongs, SvUShorts, SvLongs, SvShorts * PtrArr: SvStrings, SvStringsDtor @@ -794,69 +790,21 @@ SV_IMPL_VARARR(nm##_SAR, AE)\ _SV_IMPL_SORTAR_ALG( nm,AE )\ _SV_SEEK_OBJECT( nm,AE ) -#define SV_DECL_PTRARR_STACK(nm, AE, IS, GS)\ -class nm: private SvPtrarr \ -{\ -public:\ - nm( USHORT nIni=IS, BYTE nG=GS )\ - : SvPtrarr(nIni,nG) {}\ - void Insert( const nm *pI, USHORT nP,\ - USHORT nS = 0, USHORT nE = USHRT_MAX ) {\ - SvPtrarr::Insert( pI, nP, nS, nE ); \ - }\ - void Remove( USHORT nP, USHORT nL = 1 ) {\ - SvPtrarr::Remove( nP, nL ); \ - }\ - void Push( const AE &aE ) {\ - SvPtrarr::Insert( (const VoidPtr &)aE, SvPtrarr::Count() );\ - }\ - USHORT Count() const { return SvPtrarr::Count(); }\ - AE operator[](USHORT nP) const {\ - return (AE)SvPtrarr::operator[]( nP );\ - }\ - AE GetObject(USHORT nP) const {\ - return (AE)SvPtrarr::GetObject( nP );\ - }\ - AE Pop(){\ - AE pRet = 0;\ - if( SvPtrarr::Count() ){\ - pRet = GetObject( SvPtrarr::Count()-1 );\ - SvPtrarr::Remove(Count()-1);\ - }\ - return pRet;\ - }\ - AE Top() const {\ - AE pRet = 0;\ - if( SvPtrarr::Count() )\ - pRet = GetObject( SvPtrarr::Count()-1 ); \ - return pRet;\ - }\ -}; - #if defined (C40) || defined (C41) || defined (C42) || defined(C50) || defined(C52) #define C40_INSERT( c, p, n) Insert( (c const *) p, n ) -#define C40_PUSH( c, p) Push( (c const *) p ) #define C40_PTR_INSERT( c, p) Insert( (c const *) p ) -#define C40_REMOVE( c, p ) Remove( (c const *) p ) #define C40_REPLACE( c, p, n) Replace( (c const *) p, n ) -#define C40_PTR_REPLACE( c, p) Replace( (c const *) p ) #define C40_GETPOS( c, r) GetPos( (c const *)r ) #else #if defined WTC || defined ICC || defined HPUX || (defined GCC && __GNUC__ >= 3) || (defined(WNT) && _MSC_VER >= 1400) #define C40_INSERT( c, p, n ) Insert( (c const *&) p, n ) -#define C40_PUSH( c, p) Push( (c const *&) p ) #define C40_PTR_INSERT( c, p ) Insert( (c const *&) p ) -#define C40_REMOVE( c, p ) Remove( (c const *&) p ) #define C40_REPLACE( c, p, n ) Replace( (c const *&) p, n ) -#define C40_PTR_REPLACE( c, p ) Replace( (c const *&) p ) #define C40_GETPOS( c, r) GetPos( (c const *&) r ) #else #define C40_INSERT( c, p, n ) Insert( p, n ) -#define C40_PUSH( c, p) Push( p ) #define C40_PTR_INSERT( c, p ) Insert( p ) -#define C40_REMOVE( c, p) Remove( p ) #define C40_REPLACE( c, p, n ) Replace( p, n ) -#define C40_PTR_REPLACE( c, p ) Replace( p ) #define C40_GETPOS( c, r) GetPos( r ) #endif #endif -- cgit From b8d9894086f74d4718d168d088a30e6f40e03ff0 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Wed, 29 Sep 2010 20:18:52 +0200 Subject: svarray: #i112395#: change vector to deque - possible memory bug (pointer address to vector could change) --- svl/source/inc/poolio.hxx | 4 ++-- svl/source/items/itempool.cxx | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'svl') diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index 10a1f1939238..e462356ae419 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -26,7 +26,7 @@ ************************************************************************/ #include #include - +#include #ifndef DELETEZ #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; } @@ -57,7 +57,7 @@ struct SfxPoolVersion_Impl SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl, SfxPoolItem*, 0, 5 ) typedef boost::shared_ptr< SfxPoolVersion_Impl > SfxPoolVersion_ImplPtr; -typedef std::vector< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl; +typedef std::deque< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl; struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl { diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 63b5c710202c..99b0fb40bbae 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -38,8 +38,6 @@ #include #include #include "poolio.hxx" -#include -#include //======================================================================== -- cgit From b91754736a40b1e3371725340e4249de28dd0415 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Thu, 30 Sep 2010 21:28:31 +0200 Subject: svarray: #i112395#: SvArray update --- svl/inc/svl/svstdarr.hxx | 8 ++------ svl/source/memtools/svarray.cxx | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index fa3c94034256..958f2feb3dc7 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -42,13 +42,9 @@ #include "svl/svldllapi.h" #include +#include -//#ifdef _SVSTDARR_BOOLS -#ifndef _SVSTDARR_BOOLS_DECL -SV_DECL_VARARR_VISIBILITY( SvBools, BOOL, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_BOOLS_DECL -#endif -//#endif +typedef std::vector< BOOL > SvBools; //#ifdef _SVSTDARR_BYTES #ifndef _SVSTDARR_BYTES_DECL diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index b2184442ea0e..b609bb297f2c 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -75,8 +75,6 @@ USHORT SvPtrarrPlain::GetPos( const VoidPtr aElement ) const return ( n >= nA ? USHRT_MAX : n ); } - -SV_IMPL_VARARR( SvBools, BOOL ) SV_IMPL_VARARR( SvBytes, BYTE ) SV_IMPL_VARARR( SvULongs, ULONG ) SV_IMPL_VARARR( SvUShorts, USHORT ) -- cgit From 74be8c4a86f5a4db86975c2dbd7211c5eee69659 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Thu, 30 Sep 2010 21:54:31 +0200 Subject: svarray: #i112395#: change SvBools from vector to deque --- svl/inc/svl/svstdarr.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svl') diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index 958f2feb3dc7..9e766167d9d9 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -44,7 +44,7 @@ #include #include -typedef std::vector< BOOL > SvBools; +typedef std::deque< BOOL > SvBools; //#ifdef _SVSTDARR_BYTES #ifndef _SVSTDARR_BYTES_DECL -- cgit From 3fa1828b93f714b5a030bc8eef1e0693e86dbcd0 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Thu, 30 Sep 2010 23:12:15 +0200 Subject: svarray: #i112395#: small fix --- svl/inc/svl/svstdarr.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'svl') diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index 9e766167d9d9..e4ed968caabc 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -42,7 +42,7 @@ #include "svl/svldllapi.h" #include -#include +#include typedef std::deque< BOOL > SvBools; -- cgit From 6d97433df43ec0dbd20c026f0b3701ff723ec973 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Mon, 4 Oct 2010 20:43:33 +0200 Subject: svarray: #i112395#: SvBytes replace with STL --- svl/inc/svl/svstdarr.hxx | 7 +------ svl/source/memtools/svarray.cxx | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index e4ed968caabc..bc3ef2834d82 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -46,12 +46,7 @@ typedef std::deque< BOOL > SvBools; -//#ifdef _SVSTDARR_BYTES -#ifndef _SVSTDARR_BYTES_DECL -SV_DECL_VARARR_VISIBILITY( SvBytes, BYTE, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_BYTES_DECL -#endif -//#endif +typedef std::deque< BYTE > SvBytes; //#ifdef _SVSTDARR_ULONGS #ifndef _SVSTDARR_ULONGS_DECL diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index b609bb297f2c..4a80ff743901 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -75,7 +75,6 @@ USHORT SvPtrarrPlain::GetPos( const VoidPtr aElement ) const return ( n >= nA ? USHRT_MAX : n ); } -SV_IMPL_VARARR( SvBytes, BYTE ) SV_IMPL_VARARR( SvULongs, ULONG ) SV_IMPL_VARARR( SvUShorts, USHORT ) SV_IMPL_VARARR( SvLongs, long) -- cgit From 3bb6145d76abd333753bce0d5be74e8dd2df13bc Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Tue, 5 Oct 2010 20:01:23 +0200 Subject: svarray: #i112395#: SvXub_StrLens --- svl/inc/svl/svstdarr.hxx | 7 +------ svl/source/memtools/svarray.cxx | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index bc3ef2834d82..a0f0151660a9 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -246,12 +246,7 @@ SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvByteStringsISortDtor, ByteStringPtr, 1, 1, #endif //#endif -//#ifdef _SVSTDARR_XUB_STRLEN -#ifndef _SVSTDARR_XUB_STRLEN_DECL -SV_DECL_VARARR_VISIBILITY( SvXub_StrLens, xub_StrLen, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_XUB_STRLEN_DECL -#endif -//#endif +typedef std::deque< xub_StrLen > SvXub_StrLens; //#ifdef _SVSTDARR_XUB_STRLENSORT #ifndef _SVSTDARR_XUB_STRLENSORT_DECL diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index 4a80ff743901..9eb9fbf237fb 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -84,8 +84,6 @@ SV_IMPL_VARARR_SORT( SvULongsSort, ULONG ) SV_IMPL_VARARR_SORT( SvLongsSort, long ) SV_IMPL_VARARR_SORT( SvXub_StrLensSort, xub_StrLen ) -SV_IMPL_VARARR( SvXub_StrLens, xub_StrLen ) - SV_IMPL_PTRARR( SvStrings, StringPtr ) SV_IMPL_PTRARR( SvStringsDtor, StringPtr ) SV_IMPL_OP_PTRARR_SORT( SvStringsSort, StringPtr ) -- cgit From b138d8d6ed6f8800d08ada0ce6f73fa162365ba1 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Tue, 5 Oct 2010 21:34:41 +0200 Subject: svarray: #i112395#: SvShorts --- svl/inc/svl/svstdarr.hxx | 7 +------ svl/source/memtools/svarray.cxx | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index a0f0151660a9..3cdff2fab196 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -130,12 +130,7 @@ SV_DECL_VARARR_SORT_VISIBILITY( SvLongsSort, long, 1, 1, SVL_DLLPUBLIC ) #endif //#endif -//#ifdef _SVSTDARR_SHORTS -#ifndef _SVSTDARR_SHORTS_DECL -SV_DECL_VARARR_VISIBILITY( SvShorts, short, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_SHORTS_DECL -#endif -//#endif +typedef std::deque< short > SvShorts; /* form here all Arrays for Strings, ByteString and then diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index 9eb9fbf237fb..8f8c563bc9b7 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -78,7 +78,6 @@ USHORT SvPtrarrPlain::GetPos( const VoidPtr aElement ) const SV_IMPL_VARARR( SvULongs, ULONG ) SV_IMPL_VARARR( SvUShorts, USHORT ) SV_IMPL_VARARR( SvLongs, long) -SV_IMPL_VARARR( SvShorts, short ) SV_IMPL_VARARR_SORT( SvULongsSort, ULONG ) SV_IMPL_VARARR_SORT( SvLongsSort, long ) -- cgit From 707cfea59b2950d79abe93550b7bd5f520f28ae8 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Thu, 7 Oct 2010 20:14:31 +0200 Subject: svarray: #i112395#: fix bug, remove SvXub_StrLensSort and plains --- svl/inc/svl/svarray.hxx | 23 ----------------------- svl/inc/svl/svstdarr.hxx | 7 ------- svl/source/memtools/svarray.cxx | 8 -------- 3 files changed, 38 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/svarray.hxx b/svl/inc/svl/svarray.hxx index 3c300ec75099..d48998247eeb 100644 --- a/svl/inc/svl/svarray.hxx +++ b/svl/inc/svl/svarray.hxx @@ -197,8 +197,6 @@ public:\ #define _SV_DECL_VARARR(nm, AE, IS, GS ) \ _SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE & ) -#define _SV_DECL_VARARR_PLAIN(nm, AE, IS, GS ) \ -_SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE ) #define SV_DECL_VARARR_GEN(nm, AE, IS, GS, AERef, vis )\ _SV_DECL_VARARR_GEN(nm, AE, IS, GS, AERef, vis )\ @@ -209,15 +207,10 @@ nm& operator=( const nm& );\ #define SV_DECL_VARARR(nm, AE, IS, GS ) \ SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE &, ) -#define SV_DECL_VARARR_PLAIN(nm, AE, IS, GS ) \ -SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE, ) #define SV_DECL_VARARR_VISIBILITY(nm, AE, IS, GS, vis ) \ SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE &, vis ) -#define SV_DECL_VARARR_PLAIN_VISIBILITY(nm, AE, IS, GS, vis ) \ -SV_DECL_VARARR_GEN(nm, AE, IS, GS, AE, vis ) - #define SV_IMPL_VARARR_GEN( nm, AE, AERef )\ nm::nm( USHORT nInit, BYTE )\ : pData (0),\ @@ -319,9 +312,6 @@ _SVVARARR_IMPL_GET_OP_INLINE(nm, AE )\ #define SV_IMPL_VARARR( nm, AE ) \ SV_IMPL_VARARR_GEN( nm, AE, AE & ) -#define SV_IMPL_VARARR_PLAIN( nm, AE ) \ -SV_IMPL_VARARR_GEN( nm, AE, AE ) - #define _SV_DECL_PTRARR_DEF_GEN( nm, AE, IS, GS, AERef, vis )\ _SV_DECL_VARARR_GEN( nm, AE, IS, GS, AERef, vis)\ @@ -330,8 +320,6 @@ USHORT GetPos( const AERef aE ) const;\ #define _SV_DECL_PTRARR_DEF( nm, AE, IS, GS, vis )\ _SV_DECL_PTRARR_DEF_GEN( nm, AE, IS, GS, AE &, vis ) -#define _SV_DECL_PTRARR_DEF_PLAIN( nm, AE, IS, GS, vis )\ -_SV_DECL_PTRARR_DEF_GEN( nm, AE, IS, GS, AE, vis ) #define SV_DECL_PTRARR_GEN(nm, AE, IS, GS, Base, AERef, VPRef, vis )\ typedef BOOL (*FnForEach_##nm)( const AERef, void* );\ @@ -387,13 +375,9 @@ private:\ #define SV_DECL_PTRARR(nm, AE, IS, GS )\ SV_DECL_PTRARR_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, ) -#define SV_DECL_PTRARR_PLAIN(nm, AE, IS, GS )\ -SV_DECL_PTRARR_GEN(nm, AE, IS, GS, SvPtrarrPlain, AE, VoidPtr, ) #define SV_DECL_PTRARR_VISIBILITY(nm, AE, IS, GS, vis )\ SV_DECL_PTRARR_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, vis ) -#define SV_DECL_PTRARR_PLAIN_VISIBILITY(nm, AE, IS, GS, vis )\ -SV_DECL_PTRARR_GEN(nm, AE, IS, GS, SvPtrarrPlain, AE, VoidPtr, vis ) #define SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, Base, AERef, VPRef, vis )\ typedef BOOL (*FnForEach_##nm)( const AERef, void* );\ @@ -450,13 +434,9 @@ private:\ #define SV_DECL_PTRARR_DEL(nm, AE, IS, GS )\ SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, ) -#define SV_DECL_PTRARR_DEL_PLAIN(nm, AE, IS, GS )\ -SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, SvPtrarrPlain, AE, VoidPtr, ) #define SV_DECL_PTRARR_DEL_VISIBILITY(nm, AE, IS, GS, vis )\ SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, SvPtrarr, AE &, VoidPtr &, vis) -#define SV_DECL_PTRARR_DEL_PLAIN_VISIBILITY(nm, AE, IS, GS, vis )\ -SV_DECL_PTRARR_DEL_GEN(nm, AE, IS, GS, SvPtrarrPlain, AE, VoidPtr, vis) #define SV_IMPL_PTRARR_GEN(nm, AE, Base)\ void nm::DeleteAndDestroy( USHORT nP, USHORT nL )\ @@ -471,12 +451,9 @@ void nm::DeleteAndDestroy( USHORT nP, USHORT nL )\ #define SV_IMPL_PTRARR(nm, AE )\ SV_IMPL_PTRARR_GEN(nm, AE, SvPtrarr ) -#define SV_IMPL_PTRARR_PLAIN(nm, AE )\ -SV_IMPL_PTRARR_GEN(nm, AE, SvPtrarrPlain ) typedef void* VoidPtr; _SV_DECL_PTRARR_DEF( SvPtrarr, VoidPtr, 0, 1, SVL_DLLPUBLIC ) -_SV_DECL_PTRARR_DEF_PLAIN( SvPtrarrPlain, VoidPtr, 0, 1, SVL_DLLPUBLIC ) // SORTARR - Begin diff --git a/svl/inc/svl/svstdarr.hxx b/svl/inc/svl/svstdarr.hxx index 3cdff2fab196..608705dca43d 100644 --- a/svl/inc/svl/svstdarr.hxx +++ b/svl/inc/svl/svstdarr.hxx @@ -243,10 +243,3 @@ SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvByteStringsISortDtor, ByteStringPtr, 1, 1, typedef std::deque< xub_StrLen > SvXub_StrLens; -//#ifdef _SVSTDARR_XUB_STRLENSORT -#ifndef _SVSTDARR_XUB_STRLENSORT_DECL -SV_DECL_VARARR_SORT_VISIBILITY( SvXub_StrLensSort, xub_StrLen, 1, 1, SVL_DLLPUBLIC ) -#define _SVSTDARR_XUB_STRLENSORT_DECL -#endif -//#endif - diff --git a/svl/source/memtools/svarray.cxx b/svl/source/memtools/svarray.cxx index 8f8c563bc9b7..622533dceae2 100644 --- a/svl/source/memtools/svarray.cxx +++ b/svl/source/memtools/svarray.cxx @@ -61,7 +61,6 @@ #include SV_IMPL_VARARR(SvPtrarr,VoidPtr) -SV_IMPL_VARARR_PLAIN(SvPtrarrPlain,VoidPtr) USHORT SvPtrarr::GetPos( const VoidPtr& aElement ) const { USHORT n; @@ -69,19 +68,12 @@ USHORT SvPtrarr::GetPos( const VoidPtr& aElement ) const return ( n >= nA ? USHRT_MAX : n ); } -USHORT SvPtrarrPlain::GetPos( const VoidPtr aElement ) const -{ USHORT n; - for( n=0; n < nA && *(GetData()+n) != aElement; ) n++; - return ( n >= nA ? USHRT_MAX : n ); -} - SV_IMPL_VARARR( SvULongs, ULONG ) SV_IMPL_VARARR( SvUShorts, USHORT ) SV_IMPL_VARARR( SvLongs, long) SV_IMPL_VARARR_SORT( SvULongsSort, ULONG ) SV_IMPL_VARARR_SORT( SvLongsSort, long ) -SV_IMPL_VARARR_SORT( SvXub_StrLensSort, xub_StrLen ) SV_IMPL_PTRARR( SvStrings, StringPtr ) SV_IMPL_PTRARR( SvStringsDtor, StringPtr ) -- cgit From 9821d2f0bc21a4c27905ee7ba3738a315f4ee811 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Tue, 12 Oct 2010 22:39:44 +0200 Subject: svarray: #i112395#: #i84159# SfxPoolItemArrayBase_Impl --- svl/inc/svl/itempool.hxx | 2 +- svl/source/inc/poolio.hxx | 12 ++++---- svl/source/items/itempool.cxx | 62 +++++++++++++++++++++-------------------- svl/source/items/poolio.cxx | 64 +++++++++++++++++++++---------------------- 4 files changed, 72 insertions(+), 68 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/itempool.hxx b/svl/inc/svl/itempool.hxx index cbc6b7c4dd11..b594cbda18b0 100644 --- a/svl/inc/svl/itempool.hxx +++ b/svl/inc/svl/itempool.hxx @@ -210,7 +210,7 @@ public: USHORT GetSurrogate(const SfxPoolItem *) const; const SfxPoolItem * GetItem(USHORT nWhich, USHORT nSurrogate) const; - USHORT GetItemCount(USHORT nWhich) const; + size_t GetItemCount(USHORT nWhich) const; const SfxPoolItem* LoadSurrogate(SvStream& rStream, USHORT &rWhich, USHORT nSlotId, const SfxItemPool* pRefPool = 0 ); diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index e462356ae419..79cbbc463700 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -54,18 +54,17 @@ struct SfxPoolVersion_Impl {} }; -SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl, SfxPoolItem*, 0, 5 ) +typedef std::deque SfxPoolItemArrayBase_Impl; typedef boost::shared_ptr< SfxPoolVersion_Impl > SfxPoolVersion_ImplPtr; typedef std::deque< SfxPoolVersion_ImplPtr > SfxPoolVersionArr_Impl; struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl { - USHORT nFirstFree; + size_t nFirstFree; - SfxPoolItemArray_Impl (USHORT nInitSize = 0) - : SfxPoolItemArrayBase_Impl( nInitSize ), - nFirstFree( 0 ) + SfxPoolItemArray_Impl () + : nFirstFree( 0 ) {} }; @@ -99,7 +98,8 @@ struct SfxItemPool_Impl void DeleteItems() { - delete[] ppPoolItems; ppPoolItems = 0; + delete[] ppPoolItems; + ppPoolItems = 0; } }; diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 99b0fb40bbae..90c2c2f847db 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -445,9 +445,8 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool ) pSecondary->pImp->ppPoolItems + n; if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = - (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT i = (*ppItemArr)->Count(); i; ++ppHtArr, --i ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for( size_t i = (*ppItemArr)->size(); i; ++ppHtArr, --i ) if ( !(*ppHtArr) ) { DBG_ERROR( "old secondary pool must be empty" ); @@ -573,8 +572,8 @@ void SfxItemPool::Delete() { if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -605,8 +604,8 @@ void SfxItemPool::Delete() { if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -654,8 +653,8 @@ void SfxItemPool::Cleanup() ((*ppDefaultItem && (*ppDefaultItem)->ISA(SfxSetItem)) || (*ppStaticDefaultItem)->ISA(SfxSetItem)) ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if ( *ppHtArr && !(*ppHtArr)->GetRefCount() ) { DELETEZ(*ppHtArr); @@ -672,8 +671,8 @@ void SfxItemPool::Cleanup() { if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if ( *ppHtArr && !(*ppHtArr)->GetRefCount() ) DELETEZ( *ppHtArr ); } @@ -773,15 +772,16 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, USHORT nWhich ) if( !*ppItemArr ) *ppItemArr = new SfxPoolItemArray_Impl; - SfxPoolItem **ppFree = 0; - SfxPoolItem** ppHtArray = (SfxPoolItem**)(*ppItemArr)->GetData(); + SfxPoolItemArrayBase_Impl::iterator ppFree; + BOOL ppFreeIsSet = FALSE; + SfxPoolItemArrayBase_Impl::iterator ppHtArray = (*ppItemArr)->begin(); if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) ) { // wenn es ueberhaupt gepoolt ist, koennte es schon drin sein if ( IsPooledItem(&rItem) ) { // 1. Schleife: teste ob der Pointer vorhanden ist. - for( USHORT n = (*ppItemArr)->Count(); n; ++ppHtArray, --n ) + for( size_t n = (*ppItemArr)->size(); n; ++ppHtArray, --n ) if( &rItem == (*ppHtArray) ) { AddRef( **ppHtArray ); @@ -790,8 +790,8 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, USHORT nWhich ) } // 2. Schleife: dann muessen eben die Attribute verglichen werden - USHORT n; - for ( n = (*ppItemArr)->Count(), ppHtArray = (SfxPoolItem**)(*ppItemArr)->GetData(); + size_t n; + for ( n = (*ppItemArr)->size(), ppHtArray = (*ppItemArr)->begin(); n; ++ppHtArray, --n ) { if ( *ppHtArray ) @@ -803,22 +803,26 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, USHORT nWhich ) } } else - if ( !ppFree ) + if ( ppFreeIsSet == FALSE ) + { ppFree = ppHtArray; + ppFreeIsSet = TRUE; + } } } else { // freien Platz suchen - SfxPoolItem** ppHtArr; - USHORT n, nCount = (*ppItemArr)->Count(); + SfxPoolItemArrayBase_Impl::iterator ppHtArr; + size_t n, nCount = (*ppItemArr)->size(); for ( n = (*ppItemArr)->nFirstFree, - ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData() + n; + ppHtArr = (*ppItemArr)->begin() + n; n < nCount; ++ppHtArr, ++n ) if ( !*ppHtArr ) { ppFree = ppHtArr; + ppFreeIsSet = TRUE; break; } @@ -844,9 +848,9 @@ const SfxPoolItem& SfxItemPool::Put( const SfxPoolItem& rItem, USHORT nWhich ) #endif #endif AddRef( *pNewItem, pImp->nInitRefCount ); - const SfxPoolItem* pTemp = pNewItem; - if ( !ppFree ) - (*ppItemArr)->Insert( pTemp, (*ppItemArr)->Count() ); + SfxPoolItem* pTemp = pNewItem; + if ( ppFreeIsSet == FALSE ) + (*ppItemArr)->push_back( pTemp ); else { DBG_ASSERT( *ppFree == 0, "using surrogate in use" ); @@ -906,8 +910,8 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) // Item im eigenen Pool suchen SfxPoolItemArray_Impl** ppItemArr = (pImp->ppPoolItems + nIndex); SFX_ASSERT( *ppItemArr, rItem.Which(), "removing Item not in Pool" ); - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT n = (*ppItemArr)->Count(); n; ++ppHtArr, --n ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for( size_t n = (*ppItemArr)->size(); n; ++ppHtArr, --n ) if( *ppHtArr == &rItem ) { if ( (*ppHtArr)->GetRefCount() ) //! @@ -919,7 +923,7 @@ void SfxItemPool::Remove( const SfxPoolItem& rItem ) } // ggf. kleinstmoegliche freie Position merken - USHORT nPos = (*ppItemArr)->Count() - n; + size_t nPos = (*ppItemArr)->size() - n; if ( (*ppItemArr)->nFirstFree > nPos ) (*ppItemArr)->nFirstFree = nPos; @@ -1017,7 +1021,7 @@ const SfxPoolItem *SfxItemPool::GetItem(USHORT nWhich, USHORT nOfst) const return *(ppStaticDefaults + GetIndex_Impl(nWhich)); SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); - if( pItemArr && nOfst < pItemArr->Count() ) + if( pItemArr && nOfst < pItemArr->size() ) return (*pItemArr)[nOfst]; return 0; @@ -1025,7 +1029,7 @@ const SfxPoolItem *SfxItemPool::GetItem(USHORT nWhich, USHORT nOfst) const // ----------------------------------------------------------------------- -USHORT SfxItemPool::GetItemCount(USHORT nWhich) const +size_t SfxItemPool::GetItemCount(USHORT nWhich) const { DBG_CHKTHIS(SfxItemPool, 0); @@ -1039,7 +1043,7 @@ USHORT SfxItemPool::GetItemCount(USHORT nWhich) const SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); if ( pItemArr ) - return pItemArr->Count(); + return pItemArr->size(); return 0; } diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index 332d5e01da9c..10590808db15 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -207,7 +207,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const SfxPoolItemArray_Impl **pArr = pImp->ppPoolItems; SfxPoolItem **ppDefItem = ppStaticDefaults; const USHORT nSize = GetSize_Impl(); - for ( USHORT i = 0; i < nSize && !rStream.GetError(); ++i, ++pArr, ++ppDefItem ) + for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++pArr, ++ppDefItem ) { // Version des Items feststellen USHORT nItemVersion = (*ppDefItem)->GetVersion( _nFileFormatVersion ); @@ -229,7 +229,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const aWhichIdsRec.NewContent(nSlotId, 0); rStream << (*ppDefItem)->Which(); rStream << nItemVersion; - const USHORT nCount = (*pArr)->Count(); + const USHORT nCount = (*pArr)->size(); DBG_ASSERT(nCount, "ItemArr ist leer"); rStream << nCount; @@ -238,7 +238,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const for ( USHORT j = 0; j < nCount; ++j ) { // Item selbst besorgen - const SfxPoolItem *pItem = (*pArr)->GetObject(j); + const SfxPoolItem *pItem = (*pArr)->operator[](j); if ( pItem && pItem->GetRefCount() ) //! siehe anderes MI-REF { aItemsRec.NewContent(j, 'X' ); @@ -353,8 +353,8 @@ void SfxItemPool::LoadCompleted() if ( *ppItemArr ) { // "uber alle Items mit dieser Which-Id iterieren - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -387,10 +387,10 @@ void SfxItemPool::readTheItems ( { SfxMultiRecordReader aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS ); - SfxPoolItemArray_Impl *pNewArr = new SfxPoolItemArray_Impl( nItemCount ); + SfxPoolItemArray_Impl *pNewArr = new SfxPoolItemArray_Impl(); SfxPoolItem *pItem = 0; - USHORT n, nLastSurrogate = USHORT(-1); + ULONG n, nLastSurrogate = ULONG(-1); while (aItemsRec.GetContent()) { // n"achstes Surrogat holen @@ -400,7 +400,7 @@ void SfxItemPool::readTheItems ( // fehlende auff"ullen for ( pItem = 0, n = nLastSurrogate+1; n < nSurrogate; ++n ) - pNewArr->C40_INSERT(SfxPoolItem, pItem, n); + pNewArr->push_back( (SfxPoolItem*) pItem ); nLastSurrogate = nSurrogate; // Ref-Count und Item laden @@ -408,7 +408,7 @@ void SfxItemPool::readTheItems ( rStream >> nRef; pItem = pDefItem->Create(rStream, nVersion); - pNewArr->C40_INSERT(SfxPoolItem, pItem, nSurrogate); + pNewArr->push_back( (SfxPoolItem*) pItem ); if ( !bPersistentRefCounts ) // bis festhalten @@ -424,7 +424,7 @@ void SfxItemPool::readTheItems ( // fehlende auff"ullen for ( pItem = 0, n = nLastSurrogate+1; n < nItemCount; ++n ) - pNewArr->C40_INSERT(SfxPoolItem, pItem, n); + pNewArr->push_back( (SfxPoolItem*) pItem ); SfxPoolItemArray_Impl *pOldArr = *ppArr; *ppArr = pNewArr; @@ -432,25 +432,25 @@ void SfxItemPool::readTheItems ( // die Items merken, die schon im Pool sind int bEmpty = TRUE; if ( 0 != pOldArr ) - for ( n = 0; bEmpty && n < pOldArr->Count(); ++n ) - bEmpty = pOldArr->GetObject(n) == 0; + for ( n = 0; bEmpty && n < pOldArr->size(); ++n ) + bEmpty = pOldArr->operator[](n) == 0; DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" ); if ( !bEmpty ) { // f"ur alle alten suchen, ob ein gleiches neues existiert - for ( USHORT nOld = 0; nOld < pOldArr->Count(); ++nOld ) + for ( size_t nOld = 0; nOld < pOldArr->size(); ++nOld ) { SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { USHORT nFree = USHRT_MAX; int bFound = FALSE; - USHORT nCount = (*ppArr)->Count(); + ULONG nCount = (*ppArr)->size(); for ( USHORT nNew = nCount; !bFound && nNew--; ) { // geladenes Item SfxPoolItem *&rpNewItem = - (SfxPoolItem*&)(*ppArr)->GetData()[nNew]; + (SfxPoolItem*&)(*ppArr)->operator[](nNew); // surrogat unbenutzt? if ( !rpNewItem ) @@ -472,9 +472,9 @@ void SfxItemPool::readTheItems ( if ( !bFound ) { if ( nFree != USHRT_MAX ) - (SfxPoolItem*&)(*ppArr)->GetData()[nFree] = pOldItem; + (SfxPoolItem*&)(*ppArr)->operator[](nFree) = pOldItem; else - (*ppArr)->C40_INSERT( SfxPoolItem, pOldItem, nCount ); + (*ppArr)->push_back( (SfxPoolItem*) pOldItem ); } } } @@ -495,14 +495,14 @@ SvStream &SfxItemPool::Load(SvStream &rStream) // "uber alle Which-Werte iterieren SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems; - for( USHORT nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr ) + for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr ) { // ist "uberhaupt ein Item mit dem Which-Wert da? if ( *ppItemArr ) { // "uber alle Items mit dieser Which-Id iterieren - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*ppItemArr)->begin(); + for( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -849,7 +849,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) USHORT nIndex = GetIndex_Impl(nWhich); ppArr = pImp->ppPoolItems + nIndex; - pNewArr = new SfxPoolItemArray_Impl( nCount ); + pNewArr = new SfxPoolItemArray_Impl(); pDefItem = *(ppStaticDefaults + nIndex); } @@ -897,8 +897,8 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) AddRef(*pItem, nRef); } } - - pNewArr->C40_INSERT( SfxPoolItem, pItem, j); + //pNewArr->insert( pItem, j ); + pNewArr->push_back( (SfxPoolItem*) pItem ); // restliche gespeicherte Laenge skippen (neueres Format) nLastPos = rStream.Tell(); @@ -924,24 +924,24 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) // die Items merken, die schon im Pool sind int bEmpty = TRUE; if ( 0 != pOldArr ) - for ( USHORT n = 0; bEmpty && n < pOldArr->Count(); ++n ) - bEmpty = pOldArr->GetObject(n) == 0; + for ( size_t n = 0; bEmpty && n < pOldArr->size(); ++n ) + bEmpty = pOldArr->operator[](n) == 0; DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" ); if ( !bEmpty ) { // f"ur alle alten suchen, ob ein gleiches neues existiert - for ( USHORT nOld = 0; nOld < pOldArr->Count(); ++nOld ) + for ( size_t nOld = 0; nOld < pOldArr->size(); ++nOld ) { SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { int bFound = FALSE; - for ( USHORT nNew = 0; - !bFound && nNew < (*ppArr)->Count(); + for ( size_t nNew = 0; + !bFound && nNew < (*ppArr)->size(); ++nNew ) { SfxPoolItem *&rpNewItem = - (SfxPoolItem*&)(*ppArr)->GetData()[nNew]; + (SfxPoolItem*&)(*ppArr)->operator[](nNew); if ( rpNewItem && *rpNewItem == *pOldItem ) { @@ -1120,7 +1120,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate SfxPoolItemArray_Impl* pItemArr = *(pTarget->pImp->ppPoolItems + pTarget->GetIndex_Impl(rWhich)); - pItem = pItemArr && nSurrogat < pItemArr->Count() + pItem = pItemArr && nSurrogat < pItemArr->size() ? (*pItemArr)[nSurrogat] : 0; if ( !pItem ) @@ -1214,8 +1214,8 @@ USHORT SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(pItem->Which())); DBG_ASSERT(pItemArr, "ItemArr nicht vorhanden"); - const USHORT nCount = pItemArr->Count(); - for ( USHORT i = 0; i < nCount; ++i ) + + for ( size_t i = 0; i < pItemArr->size(); ++i ) { const SfxPoolItem *p = (*pItemArr)[i]; if ( p == pItem ) -- cgit From fa565a01041d302fb0376fcafae69f2cbd0deb59 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Sat, 16 Oct 2010 21:21:14 +0200 Subject: svarray: #i112395# #i84159# handle 2^32 numbers --- svl/inc/svl/itempool.hxx | 8 +++---- svl/inc/svl/poolitem.hxx | 4 ++-- svl/source/items/itempool.cxx | 8 +++---- svl/source/items/poolio.cxx | 53 ++++++++++++++++++++++--------------------- 4 files changed, 37 insertions(+), 36 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/itempool.hxx b/svl/inc/svl/itempool.hxx index b594cbda18b0..0713a67a0a78 100644 --- a/svl/inc/svl/itempool.hxx +++ b/svl/inc/svl/itempool.hxx @@ -104,7 +104,7 @@ class SVL_DLLPUBLIC SfxItemPool */ { - SVL_DLLPRIVATE void readTheItems(SvStream & rStream, USHORT nCount, USHORT nVersion, + SVL_DLLPRIVATE void readTheItems(SvStream & rStream, sal_uInt32 nCount, USHORT nVersion, SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** pArr); UniString aName; @@ -208,9 +208,9 @@ public: const SfxPoolItem &rItem, FASTBOOL bDirect = FALSE ) const; - USHORT GetSurrogate(const SfxPoolItem *) const; - const SfxPoolItem * GetItem(USHORT nWhich, USHORT nSurrogate) const; - size_t GetItemCount(USHORT nWhich) const; + sal_uInt32 GetSurrogate(const SfxPoolItem *) const; + const SfxPoolItem * GetItem2(USHORT nWhich, sal_uInt32 nSurrogate) const; //this name will be changed to GetItem + sal_uInt32 GetItemCount2(USHORT nWhich) const; //this name will be changed to GetItemCount const SfxPoolItem* LoadSurrogate(SvStream& rStream, USHORT &rWhich, USHORT nSlotId, const SfxItemPool* pRefPool = 0 ); diff --git a/svl/inc/svl/poolitem.hxx b/svl/inc/svl/poolitem.hxx index c0cf53fb6ded..a64f1088aa87 100644 --- a/svl/inc/svl/poolitem.hxx +++ b/svl/inc/svl/poolitem.hxx @@ -50,8 +50,8 @@ class IntlWrapper; namespace com { namespace sun { namespace star { namespace uno { class Any; } } } } -#define SFX_ITEMS_DIRECT 0xffff -#define SFX_ITEMS_NULL 0xfff0 // anstelle StoreSurrogate +static const sal_uInt32 SFX_ITEMS_DIRECT= 0xffffffff; +static const sal_uInt32 SFX_ITEMS_NULL= 0xfffffff0; // instead StoreSurrogate #define SFX_ITEMS_POOLDEFAULT 0xffff #define SFX_ITEMS_STATICDEFAULT 0xfffe diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 90c2c2f847db..9759b4d38b4b 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -1004,14 +1004,14 @@ void SfxItemPool::FillItemIdRanges_Impl( USHORT*& pWhichRanges ) const // ----------------------------------------------------------------------- -const SfxPoolItem *SfxItemPool::GetItem(USHORT nWhich, USHORT nOfst) const +const SfxPoolItem *SfxItemPool::GetItem2(USHORT nWhich, sal_uInt32 nOfst) const { DBG_CHKTHIS(SfxItemPool, 0); if ( !IsInRange(nWhich) ) { if ( pSecondary ) - return pSecondary->GetItem( nWhich, nOfst ); + return pSecondary->GetItem2( nWhich, nOfst ); SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" ); return 0; } @@ -1029,14 +1029,14 @@ const SfxPoolItem *SfxItemPool::GetItem(USHORT nWhich, USHORT nOfst) const // ----------------------------------------------------------------------- -size_t SfxItemPool::GetItemCount(USHORT nWhich) const +sal_uInt32 SfxItemPool::GetItemCount2(USHORT nWhich) const { DBG_CHKTHIS(SfxItemPool, 0); if ( !IsInRange(nWhich) ) { if ( pSecondary ) - return pSecondary->GetItemCount( nWhich ); + return pSecondary->GetItemCount2( nWhich ); SFX_ASSERT( 0, nWhich, "unknown Which-Id - cannot resolve surrogate" ); return 0; } diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index 10590808db15..b974ea806261 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -229,13 +229,13 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const aWhichIdsRec.NewContent(nSlotId, 0); rStream << (*ppDefItem)->Which(); rStream << nItemVersion; - const USHORT nCount = (*pArr)->size(); - DBG_ASSERT(nCount, "ItemArr ist leer"); + const sal_uInt32 nCount = ::std::min( (*pArr)->size(), SAL_MAX_UINT32 ); + DBG_ASSERT(nCount, "ItemArr is empty"); rStream << nCount; // Items an sich schreiben SfxMultiMixRecordWriter aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS, 0 ); - for ( USHORT j = 0; j < nCount; ++j ) + for ( size_t j = 0; j < nCount; ++j ) { // Item selbst besorgen const SfxPoolItem *pItem = (*pArr)->operator[](j); @@ -382,7 +382,7 @@ void SfxItemPool::LoadCompleted() //============================================================================ // This had to be moved to a method of its own to keep Solaris GCC happy: void SfxItemPool::readTheItems ( - SvStream & rStream, USHORT nItemCount, USHORT nVersion, + SvStream & rStream, sal_uInt32 nItemCount, USHORT nVersion, SfxPoolItem * pDefItem, SfxPoolItemArray_Impl ** ppArr) { SfxMultiRecordReader aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS ); @@ -430,7 +430,7 @@ void SfxItemPool::readTheItems ( *ppArr = pNewArr; // die Items merken, die schon im Pool sind - int bEmpty = TRUE; + FASTBOOL bEmpty = TRUE; if ( 0 != pOldArr ) for ( n = 0; bEmpty && n < pOldArr->size(); ++n ) bEmpty = pOldArr->operator[](n) == 0; @@ -443,10 +443,9 @@ void SfxItemPool::readTheItems ( SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { - USHORT nFree = USHRT_MAX; - int bFound = FALSE; - ULONG nCount = (*ppArr)->size(); - for ( USHORT nNew = nCount; !bFound && nNew--; ) + sal_uInt32 nFree = SAL_MAX_UINT32; + FASTBOOL bFound = FALSE; + for ( size_t nNew = (*ppArr)->size(); nNew--; ) { // geladenes Item SfxPoolItem *&rpNewItem = @@ -465,13 +464,14 @@ void SfxItemPool::readTheItems ( delete rpNewItem; rpNewItem = pOldItem; bFound = TRUE; + break; } } // vorhervorhandene, nicht geladene uebernehmen if ( !bFound ) { - if ( nFree != USHRT_MAX ) + if ( nFree != SAL_MAX_UINT32 ) (SfxPoolItem*&)(*ppArr)->operator[](nFree) = pOldItem; else (*ppArr)->push_back( (SfxPoolItem*) pOldItem ); @@ -632,7 +632,8 @@ SvStream &SfxItemPool::Load(SvStream &rStream) while ( aWhichIdsRec.GetContent() ) { // SlotId, Which-Id und Item-Version besorgen - USHORT nCount, nVersion, nWhich; + sal_uInt32 nCount; + USHORT nVersion, nWhich; //!USHORT nSlotId = aWhichIdsRec.GetContentTag(); rStream >> nWhich; if ( pImp->nLoadingVersion != pImp->nVersion ) @@ -935,10 +936,9 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { - int bFound = FALSE; + FASTBOOL bFound = FALSE; for ( size_t nNew = 0; - !bFound && nNew < (*ppArr)->size(); - ++nNew ) + nNew < (*ppArr)->size(); ++nNew ) { SfxPoolItem *&rpNewItem = (SfxPoolItem*&)(*ppArr)->operator[](nNew); @@ -951,9 +951,9 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) rpNewItem = pOldItem; bFound = TRUE; SFX_TRACE( "reusing item", pOldItem ); + break; } } - //! DBG_ASSERT( bFound, "old-item not found in file" ); if ( !bFound ) { SFX_TRACE( "item not found: ", pOldItem ); @@ -1039,7 +1039,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate L"adt Surrogat aus 'rStream' und liefert das dadurch in 'rRefPool' repr"asentierte SfxPoolItem zu"ruck. Ist das im Stream befindliche Surrogat == SFX_ITEMS_DIRECT (!SFX_ITEM_POOLABLE) wird 0 zur"uckgegeben, - das Item ist direkt aus dem Stream zu laden. Bei 0xfff0 (SFX_ITEMS_NULL) + das Item ist direkt aus dem Stream zu laden. Bei 0xfffffff0 (SFX_ITEMS_NULL) wird auch 0 zurueckgegeben und rWhich auf 0 gesetzt, das Item ist nicht verfuegbar. @@ -1071,15 +1071,15 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate */ { - // erstmal das Surrogat lesen - USHORT nSurrogat; + // Read the first surrogate + sal_uInt32 nSurrogat; rStream >> nSurrogat; - // direkt gespeichertes Item? + // Is item stored directly? if ( SFX_ITEMS_DIRECT == nSurrogat ) return 0; - // nicht vorhandenes Item? + // Item does not exist? if ( SFX_ITEMS_NULL == nSurrogat ) { rWhich = 0; @@ -1184,17 +1184,17 @@ FASTBOOL SfxItemPool::StoreSurrogate FASTBOOL bRealSurrogate = IsItemFlag(*pItem, SFX_ITEM_POOLABLE); rStream << ( bRealSurrogate ? GetSurrogate( pItem ) - : (UINT16) SFX_ITEMS_DIRECT ); + : SFX_ITEMS_DIRECT ); return bRealSurrogate; } - rStream << (UINT16) SFX_ITEMS_NULL; + rStream << SFX_ITEMS_NULL; return TRUE; } // ----------------------------------------------------------------------- -USHORT SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const +sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const { DBG_CHKTHIS(SfxItemPool, 0); DBG_ASSERT( pItem, "no 0-Pointer Surrogate" ); @@ -1213,7 +1213,7 @@ USHORT SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const return SFX_ITEMS_STATICDEFAULT; SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(pItem->Which())); - DBG_ASSERT(pItemArr, "ItemArr nicht vorhanden"); + DBG_ASSERT(pItemArr, "ItemArr is not available"); for ( size_t i = 0; i < pItemArr->size(); ++i ) { @@ -1221,7 +1221,7 @@ USHORT SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const if ( p == pItem ) return i; } - SFX_ASSERT( 0, pItem->Which(), "Item nicht im Pool"); + SFX_ASSERT( 0, pItem->Which(), "Item not in the pool"); return SFX_ITEMS_NULL; } @@ -1637,7 +1637,8 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, FASTBOOL bDirect, else { // WID in der Version nicht vorhanden => ueberspringen - USHORT nSurro, nVersion, nLen; + sal_uInt32 nSurro; + USHORT nVersion, nLen; rStream >> nSurro; if ( SFX_ITEMS_DIRECT == nSurro ) { -- cgit From 20b24c6bc448de513dc8adb4b5c1de6c8e4f0cfd Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Mon, 18 Oct 2010 22:00:21 +0200 Subject: svarray: #i112395# #i84159# increase max number of pools to 2^32 --- svl/inc/svl/itempool.hxx | 4 ++-- svl/inc/svl/poolitem.hxx | 2 +- svl/source/items/poolio.cxx | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/itempool.hxx b/svl/inc/svl/itempool.hxx index 0713a67a0a78..daaa2b481ba3 100644 --- a/svl/inc/svl/itempool.hxx +++ b/svl/inc/svl/itempool.hxx @@ -209,8 +209,8 @@ public: FASTBOOL bDirect = FALSE ) const; sal_uInt32 GetSurrogate(const SfxPoolItem *) const; - const SfxPoolItem * GetItem2(USHORT nWhich, sal_uInt32 nSurrogate) const; //this name will be changed to GetItem - sal_uInt32 GetItemCount2(USHORT nWhich) const; //this name will be changed to GetItemCount + const SfxPoolItem * GetItem2(USHORT nWhich, sal_uInt32 nSurrogate) const; + sal_uInt32 GetItemCount2(USHORT nWhich) const; const SfxPoolItem* LoadSurrogate(SvStream& rStream, USHORT &rWhich, USHORT nSlotId, const SfxItemPool* pRefPool = 0 ); diff --git a/svl/inc/svl/poolitem.hxx b/svl/inc/svl/poolitem.hxx index a64f1088aa87..fdff1255184c 100644 --- a/svl/inc/svl/poolitem.hxx +++ b/svl/inc/svl/poolitem.hxx @@ -54,7 +54,7 @@ static const sal_uInt32 SFX_ITEMS_DIRECT= 0xffffffff; static const sal_uInt32 SFX_ITEMS_NULL= 0xfffffff0; // instead StoreSurrogate #define SFX_ITEMS_POOLDEFAULT 0xffff -#define SFX_ITEMS_STATICDEFAULT 0xfffe +#define SFX_ITEMS_STATICDEFAULT 0xfffe //FIXME It is used in sc/source/ui/unoobj/defltuno.cxx (Should be changed to sal_uInt32 ?) #define SFX_ITEMS_DELETEONIDLE 0xfffd #define SFX_ITEMS_OLD_MAXREF 0xffef diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index b974ea806261..a49f90ecde38 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -430,7 +430,7 @@ void SfxItemPool::readTheItems ( *ppArr = pNewArr; // die Items merken, die schon im Pool sind - FASTBOOL bEmpty = TRUE; + bool bEmpty = true; if ( 0 != pOldArr ) for ( n = 0; bEmpty && n < pOldArr->size(); ++n ) bEmpty = pOldArr->operator[](n) == 0; @@ -444,7 +444,7 @@ void SfxItemPool::readTheItems ( if ( pOldItem ) { sal_uInt32 nFree = SAL_MAX_UINT32; - FASTBOOL bFound = FALSE; + bool bFound = false; for ( size_t nNew = (*ppArr)->size(); nNew--; ) { // geladenes Item @@ -463,7 +463,7 @@ void SfxItemPool::readTheItems ( SetRefCount( *rpNewItem, 0 ); delete rpNewItem; rpNewItem = pOldItem; - bFound = TRUE; + bFound = true; break; } } @@ -936,7 +936,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { - FASTBOOL bFound = FALSE; + bool bFound = false; for ( size_t nNew = 0; nNew < (*ppArr)->size(); ++nNew ) { @@ -949,7 +949,7 @@ SvStream &SfxItemPool::Load1_Impl(SvStream &rStream) SetRefCount( *rpNewItem, 0 ); delete rpNewItem; rpNewItem = pOldItem; - bFound = TRUE; + bFound = true; SFX_TRACE( "reusing item", pOldItem ); break; } -- cgit From a1936ae4d72cd8695c0424a289ca9b91c363cbcf Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Tue, 19 Oct 2010 20:40:04 +0200 Subject: svarray: #i112395#: #i84159# new const: SFX_ITEMS_DEFAULT --- svl/inc/svl/poolitem.hxx | 3 ++- svl/source/items/itempool.cxx | 2 +- svl/source/items/poolio.cxx | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'svl') diff --git a/svl/inc/svl/poolitem.hxx b/svl/inc/svl/poolitem.hxx index fdff1255184c..d78e32877440 100644 --- a/svl/inc/svl/poolitem.hxx +++ b/svl/inc/svl/poolitem.hxx @@ -52,9 +52,10 @@ namespace com { namespace sun { namespace star { namespace uno { class Any; } } static const sal_uInt32 SFX_ITEMS_DIRECT= 0xffffffff; static const sal_uInt32 SFX_ITEMS_NULL= 0xfffffff0; // instead StoreSurrogate +static const sal_uInt32 SFX_ITEMS_DEFAULT= 0xfffffffe; #define SFX_ITEMS_POOLDEFAULT 0xffff -#define SFX_ITEMS_STATICDEFAULT 0xfffe //FIXME It is used in sc/source/ui/unoobj/defltuno.cxx (Should be changed to sal_uInt32 ?) +#define SFX_ITEMS_STATICDEFAULT 0xfffe #define SFX_ITEMS_DELETEONIDLE 0xfffd #define SFX_ITEMS_OLD_MAXREF 0xffef diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 9759b4d38b4b..d8bdeb330776 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -1017,7 +1017,7 @@ const SfxPoolItem *SfxItemPool::GetItem2(USHORT nWhich, sal_uInt32 nOfst) const } // dflt-Attribut? - if ( nOfst == SFX_ITEMS_STATICDEFAULT ) + if ( nOfst == SFX_ITEMS_DEFAULT ) return *(ppStaticDefaults + GetIndex_Impl(nWhich)); SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index a49f90ecde38..8bf8f2b2434b 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -1114,7 +1114,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate if ( pTarget->IsInRange(rWhich) ) { // dflt-Attribut? - if ( SFX_ITEMS_STATICDEFAULT == nSurrogat ) + if ( SFX_ITEMS_DEFAULT == nSurrogat ) return *(pTarget->ppStaticDefaults + pTarget->GetIndex_Impl(rWhich)); @@ -1210,7 +1210,7 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const // Pointer auf static- oder pool-dflt-Attribut? if( IsStaticDefaultItem(pItem) || IsPoolDefaultItem(pItem) ) - return SFX_ITEMS_STATICDEFAULT; + return SFX_ITEMS_DEFAULT; SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(pItem->Which())); DBG_ASSERT(pItemArr, "ItemArr is not available"); -- cgit