diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-06 14:10:00 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-10-06 16:12:44 +0200 |
commit | 3035a8066ffc7120bb6a6da2c50d5b032611bb90 (patch) | |
tree | 8fa1c1b77d35f07a63f26ee7e9d4ae952378d6ac /svx/source/xml | |
parent | 0d24dd25e6f506b5f9128d70d7eb21f0bb4dde89 (diff) |
use rtl::Reference in SvXMLEmbeddedObjectHelper
instead of manual ref-counting
Change-Id: I559ebb3871dd3dd4a160bd83a259e36dd2f7b4d6
Reviewed-on: https://gerrit.libreoffice.org/43200
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/xml')
-rw-r--r-- | svx/source/xml/xmleohlp.cxx | 20 | ||||
-rw-r--r-- | svx/source/xml/xmlexport.cxx | 22 |
2 files changed, 15 insertions, 27 deletions
diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx index 7f821cc6aad9..c349ef624bdb 100644 --- a/svx/source/xml/xmleohlp.cxx +++ b/svx/source/xml/xmleohlp.cxx @@ -543,41 +543,29 @@ void SvXMLEmbeddedObjectHelper::Init( meCreateMode = eCreateMode; } -SvXMLEmbeddedObjectHelper* SvXMLEmbeddedObjectHelper::Create( +rtl::Reference<SvXMLEmbeddedObjectHelper> SvXMLEmbeddedObjectHelper::Create( const uno::Reference < embed::XStorage >& rRootStorage, ::comphelper::IEmbeddedHelper& rDocPersist, SvXMLEmbeddedObjectHelperMode eCreateMode ) { - SvXMLEmbeddedObjectHelper* pThis = new SvXMLEmbeddedObjectHelper; + rtl::Reference<SvXMLEmbeddedObjectHelper> pThis(new SvXMLEmbeddedObjectHelper); - pThis->acquire(); pThis->Init( rRootStorage, rDocPersist, eCreateMode ); return pThis; } -SvXMLEmbeddedObjectHelper* SvXMLEmbeddedObjectHelper::Create( +rtl::Reference<SvXMLEmbeddedObjectHelper> SvXMLEmbeddedObjectHelper::Create( ::comphelper::IEmbeddedHelper& rDocPersist, SvXMLEmbeddedObjectHelperMode eCreateMode ) { - SvXMLEmbeddedObjectHelper* pThis = new SvXMLEmbeddedObjectHelper; + rtl::Reference<SvXMLEmbeddedObjectHelper> pThis(new SvXMLEmbeddedObjectHelper); - pThis->acquire(); pThis->Init( nullptr, rDocPersist, eCreateMode ); return pThis; } -void SvXMLEmbeddedObjectHelper::Destroy( - SvXMLEmbeddedObjectHelper* pSvXMLEmbeddedObjectHelper ) -{ - if( pSvXMLEmbeddedObjectHelper ) - { - pSvXMLEmbeddedObjectHelper->dispose(); - pSvXMLEmbeddedObjectHelper->release(); - } -} - // XGraphicObjectResolver: alien objects! OUString SAL_CALL SvXMLEmbeddedObjectHelper::resolveEmbeddedObjectURL(const OUString& rURL) { diff --git a/svx/source/xml/xmlexport.cxx b/svx/source/xml/xmlexport.cxx index 0d827a29b6c7..be47ff334b92 100644 --- a/svx/source/xml/xmlexport.cxx +++ b/svx/source/xml/xmlexport.cxx @@ -56,7 +56,7 @@ bool SvxDrawingLayerExport( SdrModel* pModel, const uno::Reference<io::XOutputSt SvXMLGraphicHelper *pGraphicHelper = nullptr; Reference< document::XEmbeddedObjectResolver > xObjectResolver; - SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr; + rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper; Reference< lang::XComponent > xSourceDoc( xComponent ); try @@ -76,8 +76,8 @@ bool SvxDrawingLayerExport( SdrModel* pModel, const uno::Reference<io::XOutputSt ::comphelper::IEmbeddedHelper *pPersist = pModel->GetPersist(); if( pPersist ) { - pObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pPersist, SvXMLEmbeddedObjectHelperMode::Write ); - xObjectResolver = pObjectHelper; + xObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pPersist, SvXMLEmbeddedObjectHelperMode::Write ); + xObjectResolver = xObjectHelper.get(); } pGraphicHelper = SvXMLGraphicHelper::Create( SvXMLGraphicHelperMode::Write ); @@ -128,9 +128,8 @@ bool SvxDrawingLayerExport( SdrModel* pModel, const uno::Reference<io::XOutputSt SvXMLGraphicHelper::Destroy( pGraphicHelper ); xGraphicResolver = nullptr; - if( pObjectHelper ) - SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); - xObjectResolver = nullptr; + if( xObjectHelper.is() ) + xObjectHelper->dispose(); return bDocRet; } @@ -156,7 +155,7 @@ bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStr SvXMLGraphicHelper *pGraphicHelper = nullptr; Reference< document::XEmbeddedObjectResolver > xObjectResolver; - SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr; + rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper; Reference< lang::XComponent > xTargetDocument( xComponent ); if( !xTargetDocument.is() ) @@ -182,10 +181,10 @@ bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStr ::comphelper::IEmbeddedHelper *pPersist = pModel->GetPersist(); if( pPersist ) { - pObjectHelper = SvXMLEmbeddedObjectHelper::Create( + xObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pPersist, SvXMLEmbeddedObjectHelperMode::Read ); - xObjectResolver = pObjectHelper; + xObjectResolver = xObjectHelper.get(); } // parse @@ -231,8 +230,9 @@ bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStr SvXMLGraphicHelper::Destroy( pGraphicHelper ); xGraphicResolver = nullptr; - if( pObjectHelper ) - SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper ); + if( xObjectHelper.is() ) + xObjectHelper->dispose(); + xObjectHelper.clear(); xObjectResolver = nullptr; if ( xTargetModel.is() ) |