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 @@
#include "rtl/tencinfo.h"
#include "rtl/textenc.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 ) :
mnId ( nId ),
......@@ -207,11 +208,12 @@ PropItem& PropItem::operator=( PropItem& rPropItem )
}
Section::Section( const Section& rSection )
: mnTextEnc(rSection.mnTextEnc),
maEntries(rSection.maEntries.clone())
: mnTextEnc(rSection.mnTextEnc)
{
for ( int i = 0; i < 16; 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 )
......@@ -225,10 +227,10 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem )
{
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)
{
if (iter->mnId == nId)
if ((*iter)->mnId == nId)
break;
}
......@@ -236,7 +238,7 @@ bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem )
{
rPropItem.Clear();
rPropItem.SetTextEncoding( mnTextEnc );
rPropItem.Write( iter->mpBuf,iter->mnSize );
rPropItem.Write( (*iter)->mpBuf, (*iter)->mnSize );
rPropItem.Seek( STREAM_SEEK_TO_BEGIN );
return true;
}
......@@ -254,34 +256,34 @@ void Section::AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBu
nId = 0;
// 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 )
{
if ( iter->mnId == nId )
maEntries.replace( iter, new PropEntry( nId, pBuf, nBufSize, mnTextEnc ));
else if ( iter->mnId > nId )
maEntries.insert( iter, new PropEntry( nId, pBuf, nBufSize, mnTextEnc ));
if ( (*iter)->mnId == nId )
(*iter).reset(new PropEntry( nId, pBuf, nBufSize, mnTextEnc ));
else if ( (*iter)->mnId > nId )
maEntries.insert( iter, o3tl::make_unique<PropEntry>( nId, pBuf, nBufSize, mnTextEnc ));
else
continue;
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)
{
boost::ptr_vector<PropEntry>::iterator iter;
std::vector<std::unique_ptr<PropEntry> >::iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
{
if ( iter->mnId == 0 )
if ( (*iter)->mnId == 0 )
break;
}
if (iter == maEntries.end())
return;
SvMemoryStream aStream( iter->mpBuf, iter->mnSize, StreamMode::READ );
SvMemoryStream aStream( (*iter)->mpBuf, (*iter)->mnSize, StreamMode::READ );
aStream.Seek( STREAM_SEEK_TO_BEGIN );
sal_uInt32 nDictCount(0);
aStream.ReadUInt32( nDictCount );
......@@ -537,7 +539,8 @@ Section& Section::operator=( const Section& rSection )
{
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;
}
......
......@@ -21,6 +21,8 @@
#define INCLUDED_SD_SOURCE_FILTER_PPT_PROPREAD_HXX
#include <map>
#include <vector>
#include <memory>
#include <boost/ptr_container/ptr_vector.hpp>
#include <sal/types.h>
......@@ -108,7 +110,7 @@ public:
void Clear();
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 );
using SvStream::Read;
......@@ -117,7 +119,7 @@ public:
class Section
{
sal_uInt16 mnTextEnc;
boost::ptr_vector<PropEntry> maEntries;
std::vector<std::unique_ptr<PropEntry> > maEntries;
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