summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-16 12:38:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-17 08:24:07 +0200
commite4e39a48fd6da85189af278d194e06e42189690d (patch)
tree7510621bc335b8c77a82c55069ac4bcf8e86ebee /sdext
parentc751fd0ebd6724fe2b8ee9f308841cabbb002391 (diff)
loplugin:useuniqueptr in PDFGrammar
Change-Id: I8eff505de0d2821a33bbbc8e4acc2cbee7c1058e Reviewed-on: https://gerrit.libreoffice.org/59232 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/pdfparse/pdfparse.cxx30
1 files changed, 15 insertions, 15 deletions
diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx
index e976e8c3a7f4..c46ff60b373c 100644
--- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx
@@ -40,6 +40,7 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/alloc.h>
#include <sal/log.hxx>
+#include <o3tl/make_unique.hxx>
// disable warnings again because someone along the line has enabled them
// (we have included boost headers, what did you expect?)
@@ -322,7 +323,7 @@ public:
pContainer->m_aSubElements.emplace_back( pComment );
}
- void insertNewValue( PDFEntry* pNewValue, iteratorT pPos )
+ void insertNewValue( std::unique_ptr<PDFEntry> pNewValue, iteratorT pPos )
{
PDFContainer* pContainer = nullptr;
const char* pMsg = nullptr;
@@ -336,20 +337,20 @@ public:
if( pObj )
{
if( pObj->m_pObject == nullptr )
- pObj->m_pObject = pNewValue;
+ pObj->m_pObject = pNewValue.release();
else
{
pMsg = "second value for object";
pContainer = nullptr;
}
}
- else if( dynamic_cast<PDFDict*>(pNewValue) )
+ else if( dynamic_cast<PDFDict*>(pNewValue.get()) )
{
PDFTrailer* pTrailer = dynamic_cast<PDFTrailer*>(pContainer);
if( pTrailer )
{
if( pTrailer->m_pDict == nullptr )
- pTrailer->m_pDict = dynamic_cast<PDFDict*>(pNewValue);
+ pTrailer->m_pDict = dynamic_cast<PDFDict*>(pNewValue.get());
else
pContainer = nullptr;
}
@@ -361,44 +362,43 @@ public:
}
}
if( pContainer )
- pContainer->m_aSubElements.emplace_back( pNewValue );
+ pContainer->m_aSubElements.emplace_back( std::move(pNewValue) );
else
{
if( ! pMsg )
{
- if( dynamic_cast<PDFContainer*>(pNewValue) )
+ if( dynamic_cast<PDFContainer*>(pNewValue.get()) )
pMsg = "array without container";
else
pMsg = "value without container";
}
- delete pNewValue;
parseError( pMsg, pPos );
}
}
void pushName( iteratorT first, iteratorT last )
{
- insertNewValue( new PDFName(iteratorToString(first,last)), first );
+ insertNewValue( o3tl::make_unique<PDFName>(iteratorToString(first,last)), first );
}
void pushDouble( iteratorT first, SAL_UNUSED_PARAMETER iteratorT /*last*/ )
{
- insertNewValue( new PDFNumber(m_fDouble), first );
+ insertNewValue( o3tl::make_unique<PDFNumber>(m_fDouble), first );
}
void pushString( iteratorT first, iteratorT last )
{
- insertNewValue( new PDFString(iteratorToString(first,last)), first );
+ insertNewValue( o3tl::make_unique<PDFString>(iteratorToString(first,last)), first );
}
void pushBool( iteratorT first, iteratorT last )
{
- insertNewValue( new PDFBool( (last-first == 4) ), first );
+ insertNewValue( o3tl::make_unique<PDFBool>( last-first == 4 ), first );
}
void pushNull( iteratorT first, SAL_UNUSED_PARAMETER iteratorT )
{
- insertNewValue( new PDFNull(), first );
+ insertNewValue( o3tl::make_unique<PDFNull>(), first );
}
@@ -443,7 +443,7 @@ public:
m_aUIntStack.pop_back();
unsigned int nObject = m_aUIntStack.back();
m_aUIntStack.pop_back();
- insertNewValue( new PDFObjectRef(nObject,nGeneration), first );
+ insertNewValue( o3tl::make_unique<PDFObjectRef>(nObject,nGeneration), first );
}
void beginDict( iteratorT first, SAL_UNUSED_PARAMETER iteratorT )
@@ -451,7 +451,7 @@ public:
PDFDict* pDict = new PDFDict();
pDict->m_nOffset = first - m_aGlobalBegin;
- insertNewValue( pDict, first );
+ insertNewValue( std::unique_ptr<PDFEntry>(pDict), first );
// will not come here if insertion fails (exception)
m_aObjectStack.push_back( pDict );
}
@@ -481,7 +481,7 @@ public:
PDFArray* pArray = new PDFArray();
pArray->m_nOffset = first - m_aGlobalBegin;
- insertNewValue( pArray, first );
+ insertNewValue( std::unique_ptr<PDFEntry>(pArray), first );
// will not come here if insertion fails (exception)
m_aObjectStack.push_back( pArray );
}