From a497b913ba36ff52ad294223a1fda843c16ececf Mon Sep 17 00:00:00 2001 From: Takeshi Abe Date: Tue, 21 Apr 2015 15:56:56 +0900 Subject: use std::unique_ptr<> to simplify ctor and dtor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icfb02807cb9370e72149cdb9122b3b108eb3e4a5 Reviewed-on: https://gerrit.libreoffice.org/15456 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- starmath/inc/unomodel.hxx | 4 ++-- starmath/source/unomodel.cxx | 9 +++------ starmath/source/view.cxx | 23 +++++------------------ 3 files changed, 10 insertions(+), 26 deletions(-) (limited to 'starmath') diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx index 7e4223ffeb8e..9dc6812877e6 100644 --- a/starmath/inc/unomodel.hxx +++ b/starmath/inc/unomodel.hxx @@ -29,7 +29,7 @@ #include #include #include - +#include #define PRTUIOPT_TITLE_ROW "TitleRow" @@ -55,7 +55,7 @@ class SmModel : public SfxBaseModel, public oox::FormulaExportBase, public oox::FormulaImportBase { - SmPrintUIOptions* m_pPrintUIOptions; + std::unique_ptr m_pPrintUIOptions; protected: virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw (css::uno::RuntimeException, css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, std::exception) SAL_OVERRIDE; diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index fe337b41ff54..f4bfcab8b8a9 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -311,14 +311,11 @@ static PropertySetInfo * lcl_createModelPropertyInfo () SmModel::SmModel( SfxObjectShell *pObjSh ) : SfxBaseModel(pObjSh) , PropertySetHelper ( lcl_createModelPropertyInfo () ) -, m_pPrintUIOptions( NULL ) - { } SmModel::~SmModel() throw () { - delete m_pPrintUIOptions; } uno::Any SAL_CALL SmModel::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception) @@ -991,7 +988,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SmModel::getRenderer( rValue.Value <<= aPageSize; if (!m_pPrintUIOptions) - m_pPrintUIOptions = new SmPrintUIOptions(); + m_pPrintUIOptions.reset(new SmPrintUIOptions); m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); return aRenderer; @@ -1081,7 +1078,7 @@ void SAL_CALL SmModel::render( (aPrtPageOffset.X() + OutputRect.Right())); if (!m_pPrintUIOptions) - m_pPrintUIOptions = new SmPrintUIOptions(); + m_pPrintUIOptions.reset(new SmPrintUIOptions); m_pPrintUIOptions->processProperties( rxOptions ); pView->Impl_Print( *pOut, *m_pPrintUIOptions, Rectangle( OutputRect ), Point() ); @@ -1090,7 +1087,7 @@ void SAL_CALL SmModel::render( // That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor. if (m_pPrintUIOptions->getBoolValue( "IsLastPage", false )) { - delete m_pPrintUIOptions; m_pPrintUIOptions = 0; + m_pPrintUIOptions.reset(); } } } diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 8a8eb2d53a47..4b22180b6ac3 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -908,20 +908,9 @@ SmCmdBoxWrapper::~SmCmdBoxWrapper() struct SmViewShell_Impl { - sfx2::DocumentInserter* pDocInserter; - SfxRequest* pRequest; + std::unique_ptr pDocInserter; + std::unique_ptr pRequest; SvtMiscOptions aOpts; - - SmViewShell_Impl() : - pDocInserter( NULL ) - , pRequest( NULL ) - {} - - ~SmViewShell_Impl() - { - delete pDocInserter; - delete pRequest; - } }; TYPEINIT1( SmViewShell, SfxViewShell ); @@ -1679,11 +1668,9 @@ void SmViewShell::Execute(SfxRequest& rReq) case SID_IMPORT_FORMULA: { - delete pImpl->pRequest; - pImpl->pRequest = new SfxRequest( rReq ); - delete pImpl->pDocInserter; - pImpl->pDocInserter = new ::sfx2::DocumentInserter( - GetDoc()->GetFactory().GetFactoryName(), false ); + pImpl->pRequest.reset(new SfxRequest( rReq )); + pImpl->pDocInserter.reset(new ::sfx2::DocumentInserter( + GetDoc()->GetFactory().GetFactoryName(), false )); pImpl->pDocInserter->StartExecuteModal( LINK( this, SmViewShell, DialogClosedHdl ) ); break; } -- cgit