diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2016-03-01 23:21:02 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2016-03-01 23:51:05 +0100 |
commit | f00967cf38ed0c2c197284391fc521825bb3c2ac (patch) | |
tree | d1505cfff1707c51a74ece3091dcc25afbc5d778 | |
parent | 4845155e0126571e4176819c5f27b76160146ce0 (diff) |
sal_uIntPtr/sal_uLong to Index (aka sal_uInt32) in UniqueIndex
Change-Id: I212cb3bb9d920741629fc4564bbd28b393e8fe00
-rw-r--r-- | include/tools/pstm.hxx | 16 | ||||
-rw-r--r-- | include/tools/unqidx.hxx | 47 | ||||
-rw-r--r-- | rsc/inc/rscdb.hxx | 6 | ||||
-rw-r--r-- | rsc/inc/rscdef.hxx | 27 | ||||
-rw-r--r-- | rsc/source/parser/rscdb.cxx | 24 | ||||
-rw-r--r-- | rsc/source/parser/rsclex.cxx | 2 | ||||
-rw-r--r-- | rsc/source/parser/rscyacc.y | 1 | ||||
-rw-r--r-- | rsc/source/rsc/rsc.cxx | 26 | ||||
-rw-r--r-- | rsc/source/tools/rscdef.cxx | 49 | ||||
-rw-r--r-- | tools/source/memtools/unqidx.cxx | 32 | ||||
-rw-r--r-- | tools/source/ref/pstm.cxx | 14 |
11 files changed, 128 insertions, 116 deletions
diff --git a/include/tools/pstm.hxx b/include/tools/pstm.hxx index 92b5349e493e..ab7541682340 100644 --- a/include/tools/pstm.hxx +++ b/include/tools/pstm.hxx @@ -91,8 +91,6 @@ public: SvPersistBase *& rpObj ); }; -typedef std::map<SvPersistBase*, sal_uIntPtr> PersistBaseMap; - class SvStream; /** Persistent Stream @@ -130,12 +128,18 @@ class SvStream; */ class TOOLS_DLLPUBLIC SvPersistStream : public SvStream { +public: + typedef UniqueIndex<SvPersistBase>::Index Index; + +private: + typedef std::map<SvPersistBase*, Index> PersistBaseMap; + SvClassManager & rClassMgr; SvStream * pStm; PersistBaseMap aPTable; // reversed pointer and key UniqueIndex<SvPersistBase> aPUIdx; - sal_uIntPtr nStartIdx; + Index nStartIdx; const SvPersistStream * pRefStm; virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize ) override; @@ -151,13 +155,13 @@ public: virtual void ResetError() override; SvPersistStream( SvClassManager &, SvStream * pStream, - sal_uInt32 nStartIdx = 1 ); + Index nStartIdx = 1 ); virtual ~SvPersistStream(); void SetStream( SvStream * pStream ); - SvPersistBase * GetObject( sal_uIntPtr nIdx ) const; - sal_uIntPtr GetIndex( SvPersistBase * ) const; + SvPersistBase * GetObject( Index nIdx ) const; + Index GetIndex( SvPersistBase * ) const; static void WriteCompressed( SvStream & rStm, sal_uInt32 nVal ); static sal_uInt32 ReadCompressed( SvStream & rStm ); diff --git a/include/tools/unqidx.hxx b/include/tools/unqidx.hxx index 03a30c6fe0f0..c783151c12b8 100644 --- a/include/tools/unqidx.hxx +++ b/include/tools/unqidx.hxx @@ -20,45 +20,52 @@ #define INCLUDED_TOOLS_UNQIDX_HXX #include <tools/toolsdllapi.h> -#include <tools/contnr.hxx> +#include <limits> #include <map> -#define UNIQUEINDEX_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND - class SAL_WARN_UNUSED TOOLS_DLLPUBLIC UniqueIndexImpl { +public: + typedef sal_uInt32 Index; + enum { + IndexNotFound = std::numeric_limits<Index>::max() + }; + private: - std::map<sal_uInt32, void*> maMap; - sal_uIntPtr nStartIndex; - sal_uIntPtr nUniqIndex; - sal_uIntPtr nCount; + std::map<Index, void*> maMap; + Index nStartIndex; + Index nUniqIndex; + Index nCount; public: - UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 ) + UniqueIndexImpl( Index _nStartIndex = 0 ) : maMap(), nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {} - sal_uIntPtr Insert( void* p ); + Index Insert( void* p ); // insert value with key, replacing existing entry if necessary - void* Remove( sal_uIntPtr aIndex ); - void* Get( sal_uIntPtr aIndex ) const; + void* Remove( Index aIndex ); + void* Get( Index aIndex ) const; - sal_uIntPtr GetIndexOf( void* p ) const; - sal_uIntPtr FirstIndex() const; - sal_uIntPtr LastIndex() const; - sal_uIntPtr NextIndex( sal_uIntPtr aCurrIndex ) const; + Index GetIndexOf( void* p ) const; + Index FirstIndex() const; + Index LastIndex() const; + Index NextIndex( Index aCurrIndex ) const; }; template<typename T> class UniqueIndex : private UniqueIndexImpl { public: - UniqueIndex<T>( sal_uIntPtr _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} + using UniqueIndexImpl::Index; + using UniqueIndexImpl::IndexNotFound; + + UniqueIndex<T>( Index _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} - sal_uIntPtr Insert(T* p) { return UniqueIndexImpl::Insert(p); } - T* Get(sal_uIntPtr idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } - T* Remove(sal_uIntPtr idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); } - sal_uIntPtr GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); } + Index Insert(T* p) { return UniqueIndexImpl::Insert(p); } + T* Get(Index idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } + T* Remove(Index idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); } + Index GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); } using UniqueIndexImpl::FirstIndex; using UniqueIndexImpl::LastIndex; diff --git a/rsc/inc/rscdb.hxx b/rsc/inc/rscdb.hxx index c7c49583aef4..9aadf3d8766b 100644 --- a/rsc/inc/rscdb.hxx +++ b/rsc/inc/rscdb.hxx @@ -223,7 +223,7 @@ class RscTypCont void InsWinBit( RscTop * pClass, const OString& rName, Atom nVal ); - void WriteInc( FILE * fOutput, sal_uLong lKey ); + void WriteInc( FILE * fOutput, RscFileTab::Index lKey ); public: RscBool aBool; @@ -274,13 +274,13 @@ public: } RscTop * SearchType( Atom nTypId ); // deletes all resource objects of this file - void Delete( sal_uLong lFileKey ); + void Delete( RscFileTab::Index lFileKey ); RscTop * GetRoot() { return pRoot; } sal_uInt32 PutSysName( sal_uInt32 nRscTyp, char * pName, sal_uInt32 nConst, sal_uInt32 nId, bool bFirst ); void ClearSysNames(); ERRTYPE WriteRc( WriteRcContext& rContext ); - void WriteSrc( FILE * fOutput, sal_uLong nFileIndex, + void WriteSrc( FILE * fOutput, RscFileTab::Index nFileIndex, bool bName = true ); void PutTranslatorKey( sal_uInt64 nKey ); void IncFilePos( sal_uLong nOffset ){ nFilePos += nOffset; } diff --git a/rsc/inc/rscdef.hxx b/rsc/inc/rscdef.hxx index 41e22f659a4d..d2194f040e21 100644 --- a/rsc/inc/rscdef.hxx +++ b/rsc/inc/rscdef.hxx @@ -221,8 +221,6 @@ public: bool IsIncFile(){ return bIncFile; }; }; -#define NOFILE_INDEX UNIQUEINDEX_ENTRY_NOTFOUND - class RscDefTree { RscDefine * pDefRoot; @@ -238,8 +236,13 @@ public: class RscFileTab : public UniqueIndex<RscFile> { +public: + using UniqueIndex<RscFile>::Index; + using UniqueIndex<RscFile>::IndexNotFound; + +private: RscDefTree aDefTree; - sal_uLong Find(const OString& rName); + Index Find(const OString& rName); public: RscFileTab(); ~RscFileTab(); @@ -250,22 +253,22 @@ public: return FindDef(rStr.getStr()); } - bool Depend( sal_uLong lDepend, sal_uLong lFree ); - bool TestDef( sal_uLong lFileKey, size_t lPos, + bool Depend( Index lDepend, Index lFree ); + bool TestDef( Index lFileKey, size_t lPos, const RscDefine * pDefDec ); - bool TestDef( sal_uLong lFileKey, size_t lPos, + bool TestDef( Index lFileKey, size_t lPos, const RscExpression * pExpDec ); - RscDefine * NewDef( sal_uLong lKey, const OString& rDefName, + RscDefine * NewDef( Index lKey, const OString& rDefName, sal_Int32 lId, sal_uLong lPos ); - RscDefine * NewDef( sal_uLong lKey, const OString& rDefName, + RscDefine * NewDef( Index lKey, const OString& rDefName, RscExpression *, sal_uLong lPos ); // deletes all defines defined in this file - void DeleteFileContext( sal_uLong lKey ); - sal_uLong NewCodeFile(const OString& rName); - sal_uLong NewIncFile(const OString& rName, const OString& rPath); - RscFile * GetFile( sal_uLong lFileKey ){ return Get( lFileKey ); } + void DeleteFileContext( Index lKey ); + Index NewCodeFile(const OString& rName); + Index NewIncFile(const OString& rName, const OString& rPath); + RscFile * GetFile( Index lFileKey ){ return Get( lFileKey ); } }; #endif // INCLUDED_RSC_INC_RSCDEF_HXX diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx index c3c34e76c150..2c253e8736c4 100644 --- a/rsc/source/parser/rscdb.cxx +++ b/rsc/source/parser/rscdb.cxx @@ -297,13 +297,13 @@ sal_uInt32 RscTypCont::PutSysName( sal_uInt32 nRscTyp, char * pFileName, return pSysEntry->nKey; } -void RscTypCont::WriteInc( FILE * fOutput, sal_uLong lFileKey ) +void RscTypCont::WriteInc( FILE * fOutput, RscFileTab::Index lFileKey ) { - if( NOFILE_INDEX == lFileKey ) + if( lFileKey == RscFileTab::IndexNotFound ) { - sal_uIntPtr aIndex = aFileTab.FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + RscFileTab::Index aIndex = aFileTab.FirstIndex(); + while( aIndex != RscFileTab::IndexNotFound ) { RscFile * pFName = aFileTab.Get( aIndex ); if( pFName->IsIncFile() ) @@ -503,7 +503,7 @@ ERRTYPE RscTypCont::WriteRc( WriteRcContext& rContext ) return aError; } -void RscTypCont::WriteSrc( FILE * fOutput, sal_uLong nFileKey, +void RscTypCont::WriteSrc( FILE * fOutput, RscFileTab::Index nFileKey, bool bName ) { RscEnumerateRef aEnumRef( this, pRoot, fOutput ); @@ -517,10 +517,10 @@ void RscTypCont::WriteSrc( FILE * fOutput, sal_uLong nFileKey, RscFile* pFName; WriteInc( fOutput, nFileKey ); - if( NOFILE_INDEX == nFileKey ) + if( nFileKey == RscFileTab::IndexNotFound ) { - sal_uIntPtr aIndex = aFileTab.FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + RscFileTab::Index aIndex = aFileTab.FirstIndex(); + while( aIndex != RscFileTab::IndexNotFound ) { pFName = aFileTab.Get( aIndex ); if( !pFName->IsIncFile() ) @@ -542,10 +542,10 @@ void RscTypCont::WriteSrc( FILE * fOutput, sal_uLong nFileKey, else { RscId::SetNames( false ); - if( NOFILE_INDEX == nFileKey ) + if( nFileKey == RscFileTab::IndexNotFound ) { - sal_uIntPtr aIndex = aFileTab.FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + RscFileTab::Index aIndex = aFileTab.FirstIndex(); + while( aIndex != RscFileTab::IndexNotFound ) { aEnumRef.WriteSrc( aIndex ); aIndex = aFileTab.NextIndex( aIndex ); @@ -579,7 +579,7 @@ IMPL_LINK_TYPED( RscDel, Delete, const NameNode&, r, void ) pNode->pObjBiTree = pNode->GetObjNode()->DelObjNode( pNode, lFileKey ); } -void RscTypCont::Delete( sal_uLong lFileKey ) +void RscTypCont::Delete( RscFileTab::Index lFileKey ) { // delete resource instance RscDel aDel( pRoot, lFileKey ); diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx index 47c31877ef6e..f5f7c0cb7871 100644 --- a/rsc/source/parser/rsclex.cxx +++ b/rsc/source/parser/rsclex.cxx @@ -369,7 +369,7 @@ void IncludeParser( RscFileInst * pFileInst ) int nToken; // token value YYSTYPE aYYSType; // token data RscFile * pFName; // file structure - sal_uLong lKey; // file key + RscFileTab::Index lKey; // file key RscTypCont * pTypCon = pFileInst->pTypCont; pFName = pTypCon->aFileTab.Get( pFileInst->GetFileIndex() ); diff --git a/rsc/source/parser/rscyacc.y b/rsc/source/parser/rscyacc.y index c084d9b2e988..c0a9114ed3a1 100644 --- a/rsc/source/parser/rscyacc.y +++ b/rsc/source/parser/rscyacc.y @@ -20,6 +20,7 @@ #include "sal/config.h" +#include <limits.h> #include <stdio.h> #include <ctype.h> #include <string.h> diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx index 77ec2b85aa7d..6d663a220344 100644 --- a/rsc/source/rsc/rsc.cxx +++ b/rsc/source/rsc/rsc.cxx @@ -333,8 +333,8 @@ ERRTYPE RscCompiler::Start() pTC->pEH->SetListFile( nullptr ); - sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk() ) + RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex(); + while( aIndex != RscFileTab::IndexNotFound && aError.IsOk() ) { pFName = pTC->aFileTab.Get( aIndex ); if( !pFName->bScanned && !pFName->IsIncFile() ) @@ -353,8 +353,8 @@ ERRTYPE RscCompiler::Start() if ( pTC->pEH->GetVerbosity() >= RscVerbosityVerbose ) { pTC->pEH->StdOut( "Files: " ); - sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex(); + while( aIndex != RscFileTab::IndexNotFound ) { pFName = pTC->aFileTab.Get( aIndex ); pTC->pEH->StdOut( pFName->aFileName.getStr() ); @@ -395,13 +395,13 @@ void RscCompiler::EndCompile() else { // write file - sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex(); + while( aIndex != RscFileTab::IndexNotFound ) { RscFile* pFN = pTC->aFileTab.Get( aIndex ); if( !pFN->IsIncFile() ) { - pTC->WriteSrc( foutput, NOFILE_INDEX, false ); + pTC->WriteSrc( foutput, RscFileTab::IndexNotFound, false ); break; // ?T 281091MM only one source file } } @@ -572,8 +572,8 @@ ERRTYPE RscCompiler::Link() for( it = pCL->m_aOutputFiles.begin(); it != pCL->m_aOutputFiles.end(); ++it ) { // cleanup nodes - for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); - aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk(); + for( RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex(); + aIndex != RscFileTab::IndexNotFound && aError.IsOk(); aIndex = pTC->aFileTab.NextIndex( aIndex ) ) { pFName = pTC->aFileTab.Get( aIndex ); @@ -673,8 +673,8 @@ ERRTYPE RscCompiler::Link() } // parse files for specific language - for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); - aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk(); + for( RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex(); + aIndex != RscFileTab::IndexNotFound && aError.IsOk(); aIndex = pTC->aFileTab.NextIndex( aIndex ) ) { pFName = pTC->aFileTab.Get( aIndex ); @@ -725,8 +725,8 @@ ERRTYPE RscCompiler::Link() else { // parse files - for( sal_uIntPtr aIndex = pTC->aFileTab.FirstIndex(); - aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && aError.IsOk(); + for( RscFileTab::Index aIndex = pTC->aFileTab.FirstIndex(); + aIndex != RscFileTab::IndexNotFound && aError.IsOk(); aIndex = pTC->aFileTab.NextIndex( aIndex ) ) { pFName = pTC->aFileTab.Get( aIndex ); diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx index 155382de4917..c3dbffe28d88 100644 --- a/rsc/source/tools/rscdef.cxx +++ b/rsc/source/tools/rscdef.cxx @@ -21,6 +21,8 @@ // overall program includes #include <rscdef.hxx> +#include <limits.h> + bool RscId::bNames = true; void RscId::SetNames( bool bSet ) @@ -489,24 +491,21 @@ RscFileTab::~RscFileTab() aDefTree.Remove(); - sal_uIntPtr aIndex = LastIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + Index aIndex = LastIndex(); + while( aIndex != IndexNotFound ) { delete Remove( aIndex ); aIndex = LastIndex(); }; } -sal_uLong RscFileTab::Find( const OString& rName ) +RscFileTab::Index RscFileTab::Find( const OString& rName ) { - sal_uIntPtr aIndex = FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND && (Get(aIndex)->aFileName != rName) ) + Index aIndex = FirstIndex(); + while( aIndex != IndexNotFound && (Get(aIndex)->aFileName != rName) ) aIndex = NextIndex(aIndex); - if( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) - return aIndex; - else - return NOFILE_INDEX; + return aIndex; } RscDefine * RscFileTab::FindDef( const char * pName ) @@ -516,13 +515,13 @@ RscDefine * RscFileTab::FindDef( const char * pName ) /* This method gives back true when lDepend exists and is behind lFree, or when lDepend does not exist. */ -bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree ) +bool RscFileTab::Depend( Index lDepend, Index lFree ) { if( lDepend == lFree ) return true; - sal_uIntPtr aIndex = FirstIndex(); - while( aIndex != UNIQUEINDEX_ENTRY_NOTFOUND ) + Index aIndex = FirstIndex(); + while( aIndex != IndexNotFound ) { RscFile * pFile = Get(aIndex); if( !pFile->IsIncFile() ) @@ -536,7 +535,7 @@ bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree ) return true; } -bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos, +bool RscFileTab::TestDef( Index lFileKey, size_t lPos, const RscDefine * pDefDec ) { if( lFileKey == pDefDec->GetFileKey() ) @@ -554,7 +553,7 @@ bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos, return TestDef( lFileKey, lPos, pDefDec->pExp ); } -bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos, +bool RscFileTab::TestDef( Index lFileKey, size_t lPos, const RscExpression * pExpDec ) { if( !pExpDec ) @@ -579,7 +578,7 @@ bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos, return true; } -RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName, +RscDefine * RscFileTab::NewDef( Index lFileKey, const OString& rDefName, sal_Int32 lId, sal_uLong lPos ) { RscDefine * pDef = FindDef( rDefName ); @@ -600,7 +599,7 @@ RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName, return pDef; } -RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName, +RscDefine * RscFileTab::NewDef( Index lFileKey, const OString& rDefName, RscExpression * pExp, sal_uLong lPos ) { RscDefine * pDef = FindDef( rDefName ); @@ -630,11 +629,9 @@ RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const OString& rDefName, return pDef; } -void RscFileTab::DeleteFileContext( sal_uLong lFileKey ) +void RscFileTab::DeleteFileContext( Index lFileKey ) { - RscFile * pFName; - - pFName = GetFile( lFileKey ); + RscFile* pFName = GetFile( lFileKey ); if( pFName ) { for ( size_t i = 0, n = pFName->aDefLst.maList.size(); i < n; ++i ) @@ -647,10 +644,10 @@ void RscFileTab::DeleteFileContext( sal_uLong lFileKey ) } } -sal_uLong RscFileTab::NewCodeFile( const OString& rName ) +RscFileTab::Index RscFileTab::NewCodeFile( const OString& rName ) { - sal_uLong lKey = Find( rName ); - if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey ) + Index lKey = Find( rName ); + if( lKey == IndexNotFound ) { RscFile * pFName = new RscFile(); pFName->aFileName = rName; @@ -661,11 +658,11 @@ sal_uLong RscFileTab::NewCodeFile( const OString& rName ) return lKey; } -sal_uLong RscFileTab::NewIncFile(const OString& rName, +RscFileTab::Index RscFileTab::NewIncFile(const OString& rName, const OString& rPath) { - sal_uLong lKey = Find( rName ); - if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey ) + Index lKey = Find( rName ); + if( lKey == IndexNotFound ) { RscFile * pFName = new RscFile(); pFName->aFileName = rName; diff --git a/tools/source/memtools/unqidx.cxx b/tools/source/memtools/unqidx.cxx index 8d7ed1ce399c..4bd05bb61d40 100644 --- a/tools/source/memtools/unqidx.cxx +++ b/tools/source/memtools/unqidx.cxx @@ -19,14 +19,14 @@ #include <tools/unqidx.hxx> -sal_uIntPtr UniqueIndexImpl::Insert( void* p ) +UniqueIndexImpl::Index UniqueIndexImpl::Insert( void* p ) { // NULL-Pointer not allowed if ( !p ) - return UNIQUEINDEX_ENTRY_NOTFOUND; + return IndexNotFound; // Expend array if full - sal_uIntPtr nTmp = maMap.size(); + Index nTmp = static_cast<Index>(maMap.size()); if( nTmp == nCount ) nTmp++; @@ -45,7 +45,7 @@ sal_uIntPtr UniqueIndexImpl::Insert( void* p ) return ( nUniqIndex + nStartIndex - 1 ); } -void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex ) +void* UniqueIndexImpl::Remove( Index nIndex ) { // Check for valid index if ( (nIndex >= nStartIndex) && @@ -53,7 +53,7 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex ) { // insert index as empty entry, and reduce indexcount, // if this entry was used - std::map<sal_uInt32, void*>::iterator it = maMap.find( nIndex - nStartIndex ); + std::map<Index, void*>::iterator it = maMap.find( nIndex - nStartIndex ); if( it != maMap.end() ) { void* p = it->second; @@ -65,52 +65,52 @@ void* UniqueIndexImpl::Remove( sal_uIntPtr nIndex ) return nullptr; } -void* UniqueIndexImpl::Get( sal_uIntPtr nIndex ) const +void* UniqueIndexImpl::Get( Index nIndex ) const { // check for valid index if ( (nIndex >= nStartIndex) && (nIndex < (maMap.size() + nStartIndex)) ) { - std::map<sal_uInt32, void*>::const_iterator it = maMap.find( nIndex - nStartIndex ); + std::map<Index, void*>::const_iterator it = maMap.find( nIndex - nStartIndex ); if( it != maMap.end() ) return it->second; } return nullptr; } -sal_uIntPtr UniqueIndexImpl::FirstIndex() const +UniqueIndexImpl::Index UniqueIndexImpl::FirstIndex() const { if ( maMap.empty() ) - return UNIQUEINDEX_ENTRY_NOTFOUND; + return IndexNotFound; return maMap.begin()->first; } -sal_uIntPtr UniqueIndexImpl::LastIndex() const +UniqueIndexImpl::Index UniqueIndexImpl::LastIndex() const { if ( maMap.empty() ) - return UNIQUEINDEX_ENTRY_NOTFOUND; + return IndexNotFound; return maMap.rbegin()->first; } -sal_uIntPtr UniqueIndexImpl::NextIndex(sal_uIntPtr aIndex) const +UniqueIndexImpl::Index UniqueIndexImpl::NextIndex(Index aIndex) const { std::map<sal_uInt32, void*>::const_iterator it = maMap.find( aIndex ); if ( it == maMap.end() ) - return UNIQUEINDEX_ENTRY_NOTFOUND; + return IndexNotFound; ++it; if ( it == maMap.end() ) - return UNIQUEINDEX_ENTRY_NOTFOUND; + return IndexNotFound; return it->first; } -sal_uIntPtr UniqueIndexImpl::GetIndexOf(void* p) const +UniqueIndexImpl::Index UniqueIndexImpl::GetIndexOf(void* p) const { for( std::map<sal_uInt32, void*>::const_iterator it = maMap.begin(); it != maMap.end(); ++it ) if( it->second == p ) return it->first; - return UNIQUEINDEX_ENTRY_NOTFOUND; + return IndexNotFound; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx index 4e44784f7fba..47dc22e40949 100644 --- a/tools/source/ref/pstm.cxx +++ b/tools/source/ref/pstm.cxx @@ -51,7 +51,7 @@ SvCreateInstancePersist SvClassManager::Get( sal_Int32 nClassId ) (cf. <SvPersistStream::SetStream>). @see SvPersistStream::SetStream */ -SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream, sal_uInt32 nStartIdxP ) +SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream, Index nStartIdxP ) : rClassMgr( rMgr ) , pStm( pStream ) , aPUIdx( nStartIdxP ) @@ -135,7 +135,7 @@ void SvPersistStream::FlushData() { } -sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const +SvPersistStream::Index SvPersistStream::GetIndex( SvPersistBase * pObj ) const { PersistBaseMap::const_iterator it = aPTable.find( pObj ); if( it == aPTable.end() ) @@ -148,7 +148,7 @@ sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const return it->second; } -SvPersistBase * SvPersistStream::GetObject( sal_uIntPtr nIdx ) const +SvPersistBase * SvPersistStream::GetObject( Index nIdx ) const { if( nIdx >= nStartIdx ) return aPUIdx.Get( nIdx ); @@ -388,7 +388,7 @@ static void ReadId ( SvStream & rStm, sal_uInt8 & nHdr, - sal_uInt32 & nId, + SvPersistStream::Index & nId, sal_uInt16 & nClassId ) { @@ -441,7 +441,7 @@ SvPersistStream& SvPersistStream::WritePointer if( pObj ) { - sal_uIntPtr nId = GetIndex( pObj ); + Index nId = GetIndex( pObj ); if( nId ) nP |= P_ID; else @@ -468,7 +468,7 @@ void SvPersistStream::ReadObj ) { sal_uInt8 nHdr; - sal_uInt32 nId = 0; + Index nId = 0; sal_uInt16 nClassId; rpObj = nullptr; // specification: 0 in case of error @@ -512,7 +512,7 @@ void SvPersistStream::ReadObj if( bRegister ) { // insert into table - sal_uIntPtr nNewId = aPUIdx.Insert( rpObj ); + const Index nNewId = aPUIdx.Insert( rpObj ); // in order to restore state after saving aPTable[ rpObj ] = nNewId; DBG_ASSERT( !(nHdr & P_DBGUTIL) || nId == nNewId, |