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

new loplugin: useuniqueptr: sdext

Change-Id: Iae1dfc7f566d2f5bd1652f170218b502b5663126
Reviewed-on: https://gerrit.libreoffice.org/33205Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a3bb3932
......@@ -26,6 +26,7 @@
#include <unordered_map>
#include <vector>
#include <memory>
namespace pdfparse
{
......@@ -50,7 +51,7 @@ public:
private:
friend struct PDFEntry;
EmitImplData* m_pImplData;
std::unique_ptr<EmitImplData> m_pImplData;
};
struct PDFEntry
......@@ -227,17 +228,13 @@ struct PDFFileImplData;
struct PDFFile : public PDFContainer
{
private:
mutable PDFFileImplData* m_pData;
mutable std::unique_ptr<PDFFileImplData> m_pData;
PDFFileImplData* impl_getData() const;
public:
unsigned int m_nMajor; // PDF major
unsigned int m_nMinor; // PDF minor
PDFFile()
: PDFContainer(),
m_pData( nullptr ),
m_nMajor( 0 ), m_nMinor( 0 )
{}
PDFFile();
virtual ~PDFFile() override;
virtual bool emit( EmitContext& rWriteContext ) const override;
......
......@@ -97,12 +97,11 @@ EmitContext::EmitContext( const PDFContainer* pTop ) :
m_pImplData( nullptr )
{
if( pTop )
m_pImplData = new EmitImplData( pTop );
m_pImplData.reset( new EmitImplData( pTop ) );
}
EmitContext::~EmitContext()
{
delete m_pImplData;
}
PDFEntry::~PDFEntry()
......@@ -111,14 +110,14 @@ PDFEntry::~PDFEntry()
EmitImplData* PDFEntry::getEmitData( EmitContext& rContext )
{
return rContext.m_pImplData;
return rContext.m_pImplData.get();
}
void PDFEntry::setEmitData( EmitContext& rContext, EmitImplData* pNewEmitData )
{
if( rContext.m_pImplData && rContext.m_pImplData != pNewEmitData )
delete rContext.m_pImplData;
rContext.m_pImplData = pNewEmitData;
if( rContext.m_pImplData && rContext.m_pImplData.get() != pNewEmitData )
rContext.m_pImplData.reset();
rContext.m_pImplData.reset( pNewEmitData );
}
PDFValue::~PDFValue()
......@@ -1051,9 +1050,13 @@ struct PDFFileImplData
};
}
PDFFile::PDFFile()
: PDFContainer(), m_nMajor( 0 ), m_nMinor( 0 )
{
}
PDFFile::~PDFFile()
{
delete m_pData;
}
bool PDFFile::isEncrypted() const
......@@ -1223,7 +1226,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
m_pData->m_aDigest = rtl_digest_createMD5();
// first try user password
bool bValid = check_user_password( rPwd, m_pData );
bool bValid = check_user_password( rPwd, m_pData.get() );
if( ! bValid )
{
......@@ -1232,7 +1235,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
sal_uInt8 aKey[ENCRYPTION_KEY_LEN];
sal_uInt8 nPwd[ENCRYPTION_BUF_LEN];
memset( nPwd, 0, sizeof(nPwd) );
sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, m_pData, true );
sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, m_pData.get(), true );
if( m_pData->m_nStandardRevision == 2 )
{
rtl_cipher_initARCFOUR( m_pData->m_aCipher, rtl_Cipher_DirectionDecode,
......@@ -1256,7 +1259,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
nPwd, 32 ); // decrypt inplace
}
}
bValid = check_user_password( OString( reinterpret_cast<char*>(nPwd), 32 ), m_pData );
bValid = check_user_password( OString( reinterpret_cast<char*>(nPwd), 32 ), m_pData.get() );
}
return bValid;
......@@ -1265,8 +1268,8 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
PDFFileImplData* PDFFile::impl_getData() const
{
if( m_pData )
return m_pData;
m_pData = new PDFFileImplData();
return m_pData.get();
m_pData.reset( new PDFFileImplData );
// check for encryption dict in a trailer
unsigned int nElements = m_aSubElements.size();
while( nElements-- > 0 )
......@@ -1400,7 +1403,7 @@ PDFFileImplData* PDFFile::impl_getData() const
}
}
return m_pData;
return m_pData.get();
}
bool PDFFile::emit( EmitContext& rWriteContext ) const
......
......@@ -534,7 +534,6 @@ PDFOutDev::PDFOutDev( PDFDoc* pDoc ) :
}
PDFOutDev::~PDFOutDev()
{
delete m_pUtf8Map;
}
void PDFOutDev::startPage(int /*pageNum*/, GfxState* state
......
......@@ -48,6 +48,7 @@
#include <unordered_map>
#include <vector>
#include <memory>
class GfxPath;
class GfxFont;
......@@ -134,7 +135,7 @@ namespace pdfi
PDFDoc* m_pDoc;
mutable std::unordered_map< long long,
FontAttributes > m_aFontMap;
UnicodeMap* m_pUtf8Map;
std::unique_ptr<UnicodeMap> m_pUtf8Map;
bool m_bSkipImages;
int parseFont( long long nNewId, GfxFont* pFont, GfxState* state ) 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