summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 10:12:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 10:11:59 +0000
commit88c755e37cd36ddfe6d0d651540d9f2bd8a029a6 (patch)
treeffd0b8187deaf343f10f8357e9ad3dada397fd01 /sdext
parenta3bb39324e5e2cff2699e830454358ac1597ffff (diff)
new loplugin: useuniqueptr: sdext
Change-Id: Iae1dfc7f566d2f5bd1652f170218b502b5663126 Reviewed-on: https://gerrit.libreoffice.org/33205 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/inc/pdfparse.hxx11
-rw-r--r--sdext/source/pdfimport/pdfparse/pdfentries.cxx29
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx1
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx3
4 files changed, 22 insertions, 22 deletions
diff --git a/sdext/source/pdfimport/inc/pdfparse.hxx b/sdext/source/pdfimport/inc/pdfparse.hxx
index a43bfbbb321a..d36828604229 100644
--- a/sdext/source/pdfimport/inc/pdfparse.hxx
+++ b/sdext/source/pdfimport/inc/pdfparse.hxx
@@ -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;
diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
index ab8a2b999347..87dda7d06010 100644
--- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
@@ -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
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 5c096192cb9f..5d4a797f7c96 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -534,7 +534,6 @@ PDFOutDev::PDFOutDev( PDFDoc* pDoc ) :
}
PDFOutDev::~PDFOutDev()
{
- delete m_pUtf8Map;
}
void PDFOutDev::startPage(int /*pageNum*/, GfxState* state
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
index d060cde8ba54..f6d6fa41ddcb 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
@@ -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;