diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2011-06-11 20:29:26 -0430 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-06-14 23:41:39 -0400 |
commit | 133a04dcb76e4da4bb15756f27bf6337c7a6c86e (patch) | |
tree | 88c29573eebf809f80cd523465dd90c7945a9632 /sc/source | |
parent | 1617e4121692607faed133fbdbbde08dd658ffee (diff) |
Replace List with std::vector<StringHashEntry*>.
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/filter/excel/namebuff.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/inc/namebuff.hxx | 43 |
2 files changed, 24 insertions, 32 deletions
diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx index 3f128973ccc7..348d1c550ea4 100644 --- a/sc/source/filter/excel/namebuff.cxx +++ b/sc/source/filter/excel/namebuff.cxx @@ -67,22 +67,19 @@ sal_uInt32 StringHashEntry::MakeHashCode( const String& r ) NameBuffer::~NameBuffer() { - register StringHashEntry* pDel = ( StringHashEntry* ) List::First(); - while( pDel ) - { - delete pDel; - pDel = ( StringHashEntry* ) List::Next(); - } + std::vector<StringHashEntry*>::iterator pIter; + for ( pIter = maHashes.begin(); pIter != maHashes.end(); ++pIter ) + delete *pIter; } //void NameBuffer::operator <<( const SpString &rNewString ) void NameBuffer::operator <<( const String &rNewString ) { - OSL_ENSURE( Count() + nBase < 0xFFFF, + OSL_ENSURE( maHashes.size() + nBase < 0xFFFF, "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" ); - List::Insert( new StringHashEntry( rNewString ), LIST_APPEND ); + maHashes.push_back( new StringHashEntry( rNewString ) ); } diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx index f63b0bbf7c88..70f9af198396 100644 --- a/sc/source/filter/inc/namebuff.hxx +++ b/sc/source/filter/inc/namebuff.hxx @@ -102,29 +102,24 @@ inline sal_Bool StringHashEntry::operator ==( const StringHashEntry& r ) const -class NameBuffer : private List, public ExcRoot +class NameBuffer : public ExcRoot { private: sal_uInt16 nBase; // Index-Basis + std::vector<StringHashEntry*> maHashes; + public: -// inline NameBuffer( void ); //prevent empty rootdata + inline NameBuffer( RootData* ); inline NameBuffer( RootData*, sal_uInt16 nNewBase ); virtual ~NameBuffer(); - inline const String* Get( sal_uInt16 nIndex ); - inline sal_uInt16 GetLastIndex( void ); + inline const String* Get( sal_uInt16 nIndex ) const; + inline sal_uInt16 GetLastIndex() const; inline void SetBase( sal_uInt16 nNewBase = 0 ); void operator <<( const String& rNewString ); }; -//prevent empty rootdata -//inline NameBuffer::NameBuffer( void ) -//{ -// nBase = 0; -//} - - inline NameBuffer::NameBuffer( RootData* p ) : ExcRoot( p ) { nBase = 0; @@ -137,27 +132,27 @@ inline NameBuffer::NameBuffer( RootData* p, sal_uInt16 nNewBase ) : ExcRoot( p ) } -inline const String* NameBuffer::Get( sal_uInt16 n ) +inline const String* NameBuffer::Get ( sal_uInt16 n ) const { - if( n < nBase ) - return NULL; - else - { - StringHashEntry* pObj = ( StringHashEntry* ) List::GetObject( n ); + const String* pObj = NULL; - if( pObj ) - return &pObj->aString; - else - return NULL; + if( n > nBase ) + { + if ( n < maHashes.size() ) + pObj = &(maHashes[n]->aString); } + + return pObj; } -inline sal_uInt16 NameBuffer::GetLastIndex( void ) +inline sal_uInt16 NameBuffer::GetLastIndex () const { - OSL_ENSURE( Count() + nBase <= 0xFFFF, "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" ); + int size = maHashes.size() + nBase; + + OSL_ENSURE( size <= 0xFFFF, "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" ); - return ( sal_uInt16 ) ( Count() + nBase ); + return static_cast<sal_uInt16>( size ); } |