diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2011-05-03 18:23:16 -0430 |
---|---|---|
committer | Joseph Powers <jpowers27@cox.net> | 2011-05-04 05:13:38 -0700 |
commit | 62e4b2e2fa9319d3db123226d23a3c41f14dcae5 (patch) | |
tree | 57b7940a35b6d396d24bac6afda6258e9a3d894e | |
parent | f871a4e489543458e1624c53f9862f57be2d66b5 (diff) |
Remove List in sd::ExSoundCollection
-rw-r--r-- | sd/source/filter/eppt/pptexsoundcollection.cxx | 47 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptexsoundcollection.hxx | 20 |
2 files changed, 31 insertions, 36 deletions
diff --git a/sd/source/filter/eppt/pptexsoundcollection.cxx b/sd/source/filter/eppt/pptexsoundcollection.cxx index 159e3e53d362..33988419b5aa 100644 --- a/sd/source/filter/eppt/pptexsoundcollection.cxx +++ b/sd/source/filter/eppt/pptexsoundcollection.cxx @@ -96,7 +96,7 @@ sal_uInt32 ExSoundEntry::GetSize( sal_uInt32 nId ) const return nSize; } -void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) +void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) const { try { @@ -154,27 +154,25 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) } } -ExSoundCollection::~ExSoundCollection() -{ - for( void* pPtr = List::First(); pPtr; pPtr = List::Next() ) - delete (ExSoundEntry*)pPtr; -} - sal_uInt32 ExSoundCollection::GetId( const String& rString ) { sal_uInt32 nSoundId = 0; if( rString.Len() ) { - const sal_uInt32 nSoundCount = Count(); + const sal_uInt32 nSoundCount = maEntries.size(); + boost::ptr_vector<ExSoundEntry>::const_iterator iter; - for( ; nSoundId < nSoundCount; nSoundId++ ) - if( ImplGetByIndex( nSoundId )->IsSameURL( rString ) ) + for (iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++nSoundId) + { + if (iter->IsSameURL(rString)) break; + } + if ( nSoundId++ == nSoundCount ) { ExSoundEntry* pEntry = new ExSoundEntry( rString ); if ( pEntry->GetFileSize() ) - List::Insert( pEntry, LIST_APPEND ); + maEntries.push_back(pEntry); else { nSoundId = 0; // only insert sounds that are accessible @@ -185,37 +183,36 @@ sal_uInt32 ExSoundCollection::GetId( const String& rString ) return nSoundId; } -const ExSoundEntry* ExSoundCollection::ImplGetByIndex( sal_uInt32 nIndex ) const -{ - return (ExSoundEntry*)List::GetObject( nIndex ); -} - sal_uInt32 ExSoundCollection::GetSize() const { sal_uInt32 nSize = 0; - sal_uInt32 i, nSoundCount = Count(); - if ( nSoundCount ) + sal_uInt32 i = 1; + if (!maEntries.empty()) { nSize += 8 + 12; // size of SoundCollectionContainerHeader + SoundCollAtom - for ( i = 0; i < nSoundCount; i++ ) - nSize += ImplGetByIndex( i )->GetSize( i + 1 ); + boost::ptr_vector<ExSoundEntry>::const_iterator iter; + for ( iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++i) + nSize += iter->GetSize(i); } return nSize; } -void ExSoundCollection::Write( SvStream& rSt ) +void ExSoundCollection::Write( SvStream& rSt ) const { - sal_uInt32 i, nSoundCount = Count(); - if ( nSoundCount ) + if (!maEntries.empty()) { + sal_uInt32 i = 1; + sal_uInt32 nSoundCount = maEntries.size(); + // create SoundCollection Container rSt << (sal_uInt16)0xf << (sal_uInt16)EPP_SoundCollection << (sal_uInt32)( GetSize() - 8 ); // create SoundCollAtom ( reference to the next free SoundId ); rSt << (sal_uInt32)( EPP_SoundCollAtom << 16 ) << (sal_uInt32)4 << nSoundCount; - for ( i = 0; i < nSoundCount; i++ ) - ((ExSoundEntry*)List::GetObject( i ))->Write( rSt, i + 1 ); + boost::ptr_vector<ExSoundEntry>::const_iterator iter; + for ( iter = maEntries.begin(); iter != maEntries.end(); ++iter, ++i) + iter->Write(rSt,i); } } diff --git a/sd/source/filter/eppt/pptexsoundcollection.hxx b/sd/source/filter/eppt/pptexsoundcollection.hxx index 5881bbff3150..cc7eaa80d9dc 100644 --- a/sd/source/filter/eppt/pptexsoundcollection.hxx +++ b/sd/source/filter/eppt/pptexsoundcollection.hxx @@ -29,14 +29,13 @@ #ifndef _SD_PPT_EXSOUNDCOLLECTION_HXX #define _SD_PPT_EXSOUNDCOLLECTION_HXX +#include <boost/ptr_container/ptr_vector.hpp> + #ifdef DBG_ANIM_LOG #include <stdio.h> #endif #include <tools/string.hxx> #include <tools/stream.hxx> -#include <boost/shared_ptr.hpp> - -#include <list> namespace ppt { @@ -58,23 +57,22 @@ class ExSoundEntry // returns the size of a complete SoundContainer sal_uInt32 GetSize( sal_uInt32 nId ) const; - void Write( SvStream& rSt, sal_uInt32 nId ); + void Write( SvStream& rSt, sal_uInt32 nId ) const; }; -class ExSoundCollection : private List +class ExSoundCollection { - const ExSoundEntry* ImplGetByIndex( sal_uInt32 nId ) const; - public: - ExSoundCollection() {} - ~ExSoundCollection(); - sal_uInt32 GetId( const String& ); // returns the size of a complete SoundCollectionContainer sal_uInt32 GetSize() const; - void Write( SvStream& rSt ); + void Write( SvStream& rSt ) const; + +private: + + boost::ptr_vector<ExSoundEntry> maEntries; }; } // namespace ppt |