Kaydet (Commit) 9304ce96 authored tarafından Noel Grandin's avatar Noel Grandin

sd: boost::ptr_vector->std::vector<std::unique_ptr>

Change-Id: Ie0073c439cdfe37e5340081f16afb906d32a8369
üst 85d26ef9
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "rtl/tencinfo.h" #include "rtl/tencinfo.h"
#include "rtl/textenc.h" #include "rtl/textenc.h"
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <o3tl/make_unique.hxx>
PropEntry::PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize, sal_uInt16 nTextEnc ) : PropEntry::PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize, sal_uInt16 nTextEnc ) :
mnId ( nId ), mnId ( nId ),
...@@ -207,11 +208,12 @@ PropItem& PropItem::operator=( PropItem& rPropItem ) ...@@ -207,11 +208,12 @@ PropItem& PropItem::operator=( PropItem& rPropItem )
} }
Section::Section( const Section& rSection ) Section::Section( const Section& rSection )
: mnTextEnc(rSection.mnTextEnc), : mnTextEnc(rSection.mnTextEnc)
maEntries(rSection.maEntries.clone())
{ {
for ( int i = 0; i < 16; i++ ) for ( int i = 0; i < 16; i++ )
aFMTID[ i ] = rSection.aFMTID[ i ]; aFMTID[ i ] = rSection.aFMTID[ i ];
for(const std::unique_ptr<PropEntry>& rEntry : rSection.maEntries)
maEntries.push_back(o3tl::make_unique<PropEntry>(*rEntry.get()));
} }
Section::Section( const sal_uInt8* pFMTID ) Section::Section( const sal_uInt8* pFMTID )
...@@ -225,10 +227,10 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem ) ...@@ -225,10 +227,10 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem )
{ {
if ( nId ) if ( nId )
{ {
boost::ptr_vector<PropEntry>::const_iterator iter; std::vector<std::unique_ptr<PropEntry> >::const_iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter) for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
{ {
if (iter->mnId == nId) if ((*iter)->mnId == nId)
break; break;
} }
...@@ -236,7 +238,7 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem ) ...@@ -236,7 +238,7 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem )
{ {
rPropItem.Clear(); rPropItem.Clear();
rPropItem.SetTextEncoding( mnTextEnc ); rPropItem.SetTextEncoding( mnTextEnc );
rPropItem.Write( iter->mpBuf,iter->mnSize ); rPropItem.Write( (*iter)->mpBuf, (*iter)->mnSize );
rPropItem.Seek( STREAM_SEEK_TO_BEGIN ); rPropItem.Seek( STREAM_SEEK_TO_BEGIN );
return true; return true;
} }
...@@ -254,34 +256,34 @@ void Section::AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBu ...@@ -254,34 +256,34 @@ void Section::AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBu
nId = 0; nId = 0;
// do not allow same PropId's, sort // do not allow same PropId's, sort
boost::ptr_vector<PropEntry>::iterator iter; std::vector<std::unique_ptr<PropEntry> >::iterator iter;
for ( iter = maEntries.begin(); iter != maEntries.end(); ++iter ) for ( iter = maEntries.begin(); iter != maEntries.end(); ++iter )
{ {
if ( iter->mnId == nId ) if ( (*iter)->mnId == nId )
maEntries.replace( iter, new PropEntry( nId, pBuf, nBufSize, mnTextEnc )); (*iter).reset(new PropEntry( nId, pBuf, nBufSize, mnTextEnc ));
else if ( iter->mnId > nId ) else if ( (*iter)->mnId > nId )
maEntries.insert( iter, new PropEntry( nId, pBuf, nBufSize, mnTextEnc )); maEntries.insert( iter, o3tl::make_unique<PropEntry>( nId, pBuf, nBufSize, mnTextEnc ));
else else
continue; continue;
return; return;
} }
maEntries.push_back( new PropEntry( nId, pBuf, nBufSize, mnTextEnc ) ); maEntries.push_back( o3tl::make_unique<PropEntry>( nId, pBuf, nBufSize, mnTextEnc ) );
} }
void Section::GetDictionary(Dictionary& rDict) void Section::GetDictionary(Dictionary& rDict)
{ {
boost::ptr_vector<PropEntry>::iterator iter; std::vector<std::unique_ptr<PropEntry> >::iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter) for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
{ {
if ( iter->mnId == 0 ) if ( (*iter)->mnId == 0 )
break; break;
} }
if (iter == maEntries.end()) if (iter == maEntries.end())
return; return;
SvMemoryStream aStream( iter->mpBuf, iter->mnSize, StreamMode::READ ); SvMemoryStream aStream( (*iter)->mpBuf, (*iter)->mnSize, StreamMode::READ );
aStream.Seek( STREAM_SEEK_TO_BEGIN ); aStream.Seek( STREAM_SEEK_TO_BEGIN );
sal_uInt32 nDictCount(0); sal_uInt32 nDictCount(0);
aStream.ReadUInt32( nDictCount ); aStream.ReadUInt32( nDictCount );
...@@ -537,7 +539,8 @@ Section& Section::operator=( const Section& rSection ) ...@@ -537,7 +539,8 @@ Section& Section::operator=( const Section& rSection )
{ {
memcpy( static_cast<void*>(aFMTID), static_cast<void const *>(rSection.aFMTID), 16 ); memcpy( static_cast<void*>(aFMTID), static_cast<void const *>(rSection.aFMTID), 16 );
maEntries = rSection.maEntries.clone(); for(const std::unique_ptr<PropEntry>& rEntry : rSection.maEntries)
maEntries.push_back(o3tl::make_unique<PropEntry>(*rEntry.get()));
} }
return *this; return *this;
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#define INCLUDED_SD_SOURCE_FILTER_PPT_PROPREAD_HXX #define INCLUDED_SD_SOURCE_FILTER_PPT_PROPREAD_HXX
#include <map> #include <map>
#include <vector>
#include <memory>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <sal/types.h> #include <sal/types.h>
...@@ -108,7 +110,7 @@ public: ...@@ -108,7 +110,7 @@ public:
void Clear(); void Clear();
void SetTextEncoding( sal_uInt16 nTextEnc ){ mnTextEnc = nTextEnc; }; void SetTextEncoding( sal_uInt16 nTextEnc ){ mnTextEnc = nTextEnc; };
bool Read( OUString& rString, sal_uInt32 nType = VT_EMPTY, bool bDwordAlign = true ); bool Read( OUString& rString, sal_uInt32 nType = VT_EMPTY, bool bDwordAlign = true );
PropItem& operator=( PropItem& rPropItem ); PropItem& operator=( PropItem& rPropItem );
using SvStream::Read; using SvStream::Read;
...@@ -117,7 +119,7 @@ public: ...@@ -117,7 +119,7 @@ public:
class Section class Section
{ {
sal_uInt16 mnTextEnc; sal_uInt16 mnTextEnc;
boost::ptr_vector<PropEntry> maEntries; std::vector<std::unique_ptr<PropEntry> > maEntries;
protected: protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment