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

loplugin:useuniqueptr in PDFGrammar

Change-Id: I8eff505de0d2821a33bbbc8e4acc2cbee7c1058e
Reviewed-on: https://gerrit.libreoffice.org/59232
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c751fd0e
......@@ -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 );
}
......
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