summaryrefslogtreecommitdiffstats
path: root/sdext
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-21 11:22:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-21 18:51:01 +0100
commit725b5863832ef712d05b3cd49b77d447d84b80bb (patch)
tree23ce2376ed31f9f1fe9ae57873700693c56b386f /sdext
parentpass UserData by unique_ptr in MasterPagesSelector (diff)
downloadcore-725b5863832ef712d05b3cd49b77d447d84b80bb.tar.gz
core-725b5863832ef712d05b3cd49b77d447d84b80bb.zip
use unique_ptr in sdext
Change-Id: I8362cf42dd6a838752b25a4b184da614eb81805e Reviewed-on: https://gerrit.libreoffice.org/65532 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/inc/pdfparse.hxx2
-rw-r--r--sdext/source/pdfimport/pdfparse/pdfentries.cxx24
2 files changed, 16 insertions, 10 deletions
diff --git a/sdext/source/pdfimport/inc/pdfparse.hxx b/sdext/source/pdfimport/inc/pdfparse.hxx
index e5d9dcc9bef0..e8fcd77f7863 100644
--- a/sdext/source/pdfimport/inc/pdfparse.hxx
+++ b/sdext/source/pdfimport/inc/pdfparse.hxx
@@ -191,7 +191,7 @@ struct PDFDict : public PDFContainer
// inserting a value of NULL will remove rName and the previous value
// from the dictionary
- void insertValue( const OString& rName, PDFEntry* pValue );
+ void insertValue( const OString& rName, std::unique_ptr<PDFEntry> pValue );
// removes a name/value pair from the dict
void eraseValue( const OString& rName );
// builds new map as of sub elements
diff --git a/sdext/source/pdfimport/pdfparse/pdfentries.cxx b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
index 7bc541c3b1bd..97ef24917cb4 100644
--- a/sdext/source/pdfimport/pdfparse/pdfentries.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfentries.cxx
@@ -523,26 +523,32 @@ bool PDFDict::emit( EmitContext& rWriteContext ) const
return rWriteContext.write( "\n>>\n", 4 );
}
-void PDFDict::insertValue( const OString& rName, PDFEntry* pValue )
+void PDFDict::insertValue( const OString& rName, std::unique_ptr<PDFEntry> pValue )
{
if( ! pValue )
eraseValue( rName );
+ auto pValueTmp = pValue.get();
std::unordered_map<OString,PDFEntry*>::iterator it = m_aMap.find( rName );
if( it == m_aMap.end() )
{
// new name/value, pair, append it
m_aSubElements.emplace_back(o3tl::make_unique<PDFName>(rName));
- m_aSubElements.emplace_back( pValue );
+ m_aSubElements.emplace_back( std::move(pValue) );
}
else
{
unsigned int nSub = m_aSubElements.size();
- for( unsigned int i = 0; i < nSub; i++ )
+ bool bFound = false;
+ for( unsigned int i = 0; i < nSub && !bFound; i++ )
if( m_aSubElements[i].get() == it->second )
- m_aSubElements[i].reset(pValue);
+ {
+ m_aSubElements[i] = std::move(pValue);
+ bFound = true;
+ break;
+ }
}
- m_aMap[ rName ] = pValue;
+ m_aMap[ rName ] = pValueTmp;
}
void PDFDict::eraseValue( const OString& rName )
@@ -833,10 +839,10 @@ bool PDFObject::emit( EmitContext& rWriteContext ) const
if( nOutBytes )
{
// clone this object
- PDFObject* pClone = static_cast<PDFObject*>(clone());
+ std::unique_ptr<PDFObject> pClone(static_cast<PDFObject*>(clone()));
// set length in the dictionary to new stream length
- PDFNumber* pNewLen = new PDFNumber( double(nOutBytes) );
- pClone->m_pStream->m_pDict->insertValue( "Length", pNewLen );
+ std::unique_ptr<PDFNumber> pNewLen(new PDFNumber( double(nOutBytes) ));
+ pClone->m_pStream->m_pDict->insertValue( "Length", std::move(pNewLen) );
if( bDeflate && rWriteContext.m_bDeflate )
{
@@ -871,7 +877,7 @@ bool PDFObject::emit( EmitContext& rWriteContext ) const
if( pClone->m_aSubElements[i].get() != pClone->m_pStream )
bRet = pClone->m_aSubElements[i]->emit( rWriteContext );
}
- delete pClone;
+ pClone.reset();
// write stream
if( bRet )
bRet = rWriteContext.write("stream\n", 7)