From dca6eefc211cc36b5e3ba7157d45e12ee6b9f5f8 Mon Sep 17 00:00:00 2001 From: Jochen Nitschke Date: Wed, 8 Feb 2017 14:26:08 +0100 Subject: [PATCH] use std::unique_ptr Change-Id: I6d80d47dcc40daf2749eeec58a7ca19d09c4b803 Reviewed-on: https://gerrit.libreoffice.org/34045 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/filter/excel/excrecds.cxx | 28 ++++++++++++---------------- sc/source/filter/inc/excrecds.hxx | 4 ++-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index d0e96abc9eb1..92b5460f77ba 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -874,9 +874,7 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm ) ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const ScDBData* pDefinedData ) : XclExpRoot( rRoot ), - pFilterMode( nullptr ), - pFilterInfo( nullptr ) - , mbAutoFilter (false) + mbAutoFilter (false) { XclExpNameManager& rNameMgr = GetNameManager(); @@ -920,7 +918,7 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const rNameMgr.InsertBuiltInName( EXC_BUILTIN_EXTRACT, aDestRange ); } - pFilterMode = new XclExpFiltermode; + m_pFilterMode.reset(new XclExpFiltermode); } // AutoFilter else @@ -963,8 +961,8 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const maFilterList.RemoveAllRecords(); if( !maFilterList.IsEmpty() ) - pFilterMode = new XclExpFiltermode; - pFilterInfo = new XclExpAutofilterinfo( aRange.aStart, nColCnt ); + m_pFilterMode.reset(new XclExpFiltermode); + m_pFilterInfo.reset(new XclExpAutofilterinfo( aRange.aStart, nColCnt )); if (maFilterList.IsEmpty () && !bConflict) mbAutoFilter = true; @@ -974,8 +972,6 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const ExcAutoFilterRecs::~ExcAutoFilterRecs() { - delete pFilterMode; - delete pFilterInfo; } XclExpAutofilter* ExcAutoFilterRecs::GetByCol( SCCOL nCol ) @@ -1002,10 +998,10 @@ bool ExcAutoFilterRecs::IsFiltered( SCCOL nCol ) void ExcAutoFilterRecs::AddObjRecs() { - if( pFilterInfo ) + if( m_pFilterInfo ) { - ScAddress aAddr( pFilterInfo->GetStartPos() ); - for( SCCOL nObj = 0, nCount = pFilterInfo->GetColCount(); nObj < nCount; nObj++ ) + ScAddress aAddr( m_pFilterInfo->GetStartPos() ); + for( SCCOL nObj = 0, nCount = m_pFilterInfo->GetColCount(); nObj < nCount; nObj++ ) { XclObj* pObjRec = new XclObjDropDown( GetObjectManager(), aAddr, IsFiltered( nObj ) ); GetObjectManager().AddObj( pObjRec ); @@ -1016,10 +1012,10 @@ void ExcAutoFilterRecs::AddObjRecs() void ExcAutoFilterRecs::Save( XclExpStream& rStrm ) { - if( pFilterMode ) - pFilterMode->Save( rStrm ); - if( pFilterInfo ) - pFilterInfo->Save( rStrm ); + if( m_pFilterMode ) + m_pFilterMode->Save( rStrm ); + if( m_pFilterInfo ) + m_pFilterInfo->Save( rStrm ); maFilterList.Save( rStrm ); } @@ -1040,7 +1036,7 @@ void ExcAutoFilterRecs::SaveXml( XclExpXmlStream& rStrm ) bool ExcAutoFilterRecs::HasFilterMode() const { - return pFilterMode != nullptr; + return m_pFilterMode != nullptr; } XclExpFilterManager::XclExpFilterManager( const XclExpRoot& rRoot ) : diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx index 3636c8953107..a2997097214e 100644 --- a/sc/source/filter/inc/excrecds.hxx +++ b/sc/source/filter/inc/excrecds.hxx @@ -424,8 +424,8 @@ private: typedef XclExpAutofilterList::RecordRefType XclExpAutofilterRef; XclExpAutofilterList maFilterList; - XclExpFiltermode* pFilterMode; - XclExpAutofilterinfo* pFilterInfo; + std::unique_ptr m_pFilterMode; + std::unique_ptr m_pFilterInfo; ScRange maRef; bool mbAutoFilter; };