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

loplugin:useuniqueptr in PPDDecompressStream

Change-Id: Idad3c18c57e4ae4121505a0bd9761f8569685e33
Reviewed-on: https://gerrit.libreoffice.org/53358Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 7a67d7a7
...@@ -259,8 +259,8 @@ private: ...@@ -259,8 +259,8 @@ private:
PPDDecompressStream(const PPDDecompressStream&) = delete; PPDDecompressStream(const PPDDecompressStream&) = delete;
PPDDecompressStream& operator=(const PPDDecompressStream&) = delete; PPDDecompressStream& operator=(const PPDDecompressStream&) = delete;
SvFileStream* mpFileStream; std::unique_ptr<SvFileStream> mpFileStream;
SvMemoryStream* mpMemStream; std::unique_ptr<SvMemoryStream> mpMemStream;
OUString maFileName; OUString maFileName;
public: public:
...@@ -291,7 +291,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile ) ...@@ -291,7 +291,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
{ {
Close(); Close();
mpFileStream = new SvFileStream( i_rFile, StreamMode::READ ); mpFileStream.reset( new SvFileStream( i_rFile, StreamMode::READ ) );
maFileName = mpFileStream->GetFileName(); maFileName = mpFileStream->GetFileName();
if( ! mpFileStream->IsOpen() ) if( ! mpFileStream->IsOpen() )
...@@ -309,7 +309,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile ) ...@@ -309,7 +309,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
&& static_cast<unsigned char>(aLine[1]) == 0x8b /* check for gzip */ ) && static_cast<unsigned char>(aLine[1]) == 0x8b /* check for gzip */ )
{ {
// so let's try to decompress the stream // so let's try to decompress the stream
mpMemStream = new SvMemoryStream( 4096, 4096 ); mpMemStream.reset( new SvMemoryStream( 4096, 4096 ) );
ZCodec aCodec; ZCodec aCodec;
aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, false, true ); aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, false, true );
long nComp = aCodec.Decompress( *mpFileStream, *mpMemStream ); long nComp = aCodec.Decompress( *mpFileStream, *mpMemStream );
...@@ -317,15 +317,13 @@ void PPDDecompressStream::Open( const OUString& i_rFile ) ...@@ -317,15 +317,13 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
if( nComp < 0 ) if( nComp < 0 )
{ {
// decompression failed, must be an uncompressed stream after all // decompression failed, must be an uncompressed stream after all
delete mpMemStream; mpMemStream.reset();
mpMemStream = nullptr;
mpFileStream->Seek( 0 ); mpFileStream->Seek( 0 );
} }
else else
{ {
// compression successful, can get rid of file stream // compression successful, can get rid of file stream
delete mpFileStream; mpFileStream.reset();
mpFileStream = nullptr;
mpMemStream->Seek( 0 ); mpMemStream->Seek( 0 );
} }
} }
...@@ -333,10 +331,8 @@ void PPDDecompressStream::Open( const OUString& i_rFile ) ...@@ -333,10 +331,8 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
void PPDDecompressStream::Close() void PPDDecompressStream::Close()
{ {
delete mpMemStream; mpMemStream.reset();
mpMemStream = nullptr; mpFileStream.reset();
delete mpFileStream;
mpFileStream = nullptr;
} }
bool PPDDecompressStream::IsOpen() const bool PPDDecompressStream::IsOpen() const
......
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