[Libreoffice-commits] .: sd/source
Joseph Powers
jpowers at kemper.freedesktop.org
Wed May 4 05:14:11 PDT 2011
sd/source/filter/eppt/pptexsoundcollection.cxx | 47 +++++++++++--------------
sd/source/filter/eppt/pptexsoundcollection.hxx | 20 ++++------
2 files changed, 31 insertions(+), 36 deletions(-)
New commits:
commit 2bae4a108e6f2b5eac64b7a97d56784b4066d51d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Tue May 3 18:23:16 2011 -0430
Remove List in sd::ExSoundCollection
diff --git a/sd/source/filter/eppt/pptexsoundcollection.cxx b/sd/source/filter/eppt/pptexsoundcollection.cxx
index 62122df..9bb6221 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 d3fa349..cf0a37e 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
More information about the Libreoffice-commits
mailing list