[Libreoffice-commits] core.git: include/svx reportdesign/source sc/source sd/source svtools/source svx/source sw/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Oct 6 14:13:12 UTC 2017


 include/svx/xmleohlp.hxx                          |    4 +-
 reportdesign/source/core/api/ReportDefinition.cxx |   10 ++---
 sc/source/filter/xml/xmlwrap.cxx                  |   33 +++++++++---------
 sd/source/filter/xml/sdxmlwrp.cxx                 |   22 ++++++------
 svtools/source/misc/embedhlp.cxx                  |   40 +++++++++-------------
 svx/source/xml/xmleohlp.cxx                       |   20 ++---------
 svx/source/xml/xmlexport.cxx                      |   22 ++++++------
 sw/source/filter/xml/swxml.cxx                    |   11 +++---
 sw/source/filter/xml/wrtxml.cxx                   |   11 +++---
 sw/source/filter/xml/xmlexp.cxx                   |   12 +++---
 sw/source/filter/xml/xmlimp.cxx                   |   10 ++---
 sw/source/filter/xml/xmlimp.hxx                   |    3 +
 12 files changed, 94 insertions(+), 104 deletions(-)

New commits:
commit 3035a8066ffc7120bb6a6da2c50d5b032611bb90
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Oct 6 14:10:00 2017 +0200

    use rtl::Reference in SvXMLEmbeddedObjectHelper
    
    instead of manual ref-counting
    
    Change-Id: I559ebb3871dd3dd4a160bd83a259e36dd2f7b4d6
    Reviewed-on: https://gerrit.libreoffice.org/43200
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/xmleohlp.hxx b/include/svx/xmleohlp.hxx
index 51227dbb8b0d..8d93889e3723 100644
--- a/include/svx/xmleohlp.hxx
+++ b/include/svx/xmleohlp.hxx
@@ -99,11 +99,11 @@ public:
                                     ::comphelper::IEmbeddedHelper& rDocPersist,
                                     SvXMLEmbeddedObjectHelperMode eCreateMode );
 
-    static SvXMLEmbeddedObjectHelper*   Create(
+    static rtl::Reference<SvXMLEmbeddedObjectHelper> Create(
                                     const css::uno::Reference < css::embed::XStorage >&,
                                     ::comphelper::IEmbeddedHelper& rDocPersist,
                                     SvXMLEmbeddedObjectHelperMode eCreateMode );
-    static SvXMLEmbeddedObjectHelper*   Create(
+    static rtl::Reference<SvXMLEmbeddedObjectHelper>   Create(
                                     ::comphelper::IEmbeddedHelper& rDocPersist,
                                     SvXMLEmbeddedObjectHelperMode eCreateMode );
     static void                 Destroy( SvXMLEmbeddedObjectHelper* pSvXMLEmbeddedObjectHelper );
diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index a2a746474283..d26f42962e44 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1340,9 +1340,7 @@ void SAL_CALL OReportDefinition::storeToStorage( const uno::Reference< embed::XS
     SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(_xStorageToSaveTo,SvXMLGraphicHelperMode::Write);
     xGrfResolver = pGraphicHelper;
     pGraphicHelper->release();
-    SvXMLEmbeddedObjectHelper* pEmbeddedObjectHelper = SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo,*this, SvXMLEmbeddedObjectHelperMode::Write );
-    xObjectResolver = pEmbeddedObjectHelper;
-    pEmbeddedObjectHelper->release();
+    xObjectResolver = SvXMLEmbeddedObjectHelper::Create( _xStorageToSaveTo,*this, SvXMLEmbeddedObjectHelperMode::Write ).get();
 
     aDelegatorArguments.realloc(nArgsLen+2);
     aDelegatorArguments[nArgsLen++] <<= xGrfResolver;
@@ -2036,7 +2034,7 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWith
                 aValue.Value >>= xStorage;
         }
         m_pImpl->m_pObjectContainer->SwitchPersistence(xStorage);
-        xRet = static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( xStorage,*this, SvXMLEmbeddedObjectHelperMode::Read ));
+        xRet = static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( xStorage,*this, SvXMLEmbeddedObjectHelperMode::Read ).get());
     }
     return xRet;
 }
@@ -2123,9 +2121,9 @@ uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstance( co
         return m_pImpl->m_xMarkerTable;
     }
     else if ( aServiceSpecifier == "com.sun.star.document.ImportEmbeddedObjectResolver" )
-        return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, SvXMLEmbeddedObjectHelperMode::Read ));
+        return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, SvXMLEmbeddedObjectHelperMode::Read ).get());
     else if ( aServiceSpecifier == "com.sun.star.document.ExportEmbeddedObjectResolver" )
-        return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, SvXMLEmbeddedObjectHelperMode::Write ));
+        return static_cast< ::cppu::OWeakObject* >(SvXMLEmbeddedObjectHelper::Create( m_pImpl->m_xStorage,*this, SvXMLEmbeddedObjectHelperMode::Write ).get());
     else if ( aServiceSpecifier == "com.sun.star.document.ImportGraphicObjectResolver" )
     {
         SvXMLGraphicHelper* pGraphicHelper = SvXMLGraphicHelper::Create(m_pImpl->m_xStorage,SvXMLGraphicHelperMode::Write);
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index 2b4560480499..7e35690aed86 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -434,19 +434,19 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCode& rError )
         SAL_INFO( "sc.filter", "meta import end" );
     }
 
-    SvXMLGraphicHelper* pGraphicHelper = nullptr;
+    rtl::Reference<SvXMLGraphicHelper> xGraphicHelper;
     uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
 
     uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
-    SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr;
+    rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper;
 
     if( xStorage.is() )
     {
-        pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, SvXMLGraphicHelperMode::Read );
-        xGrfContainer = pGraphicHelper;
+        xGraphicHelper = SvXMLGraphicHelper::Create( xStorage, SvXMLGraphicHelperMode::Read );
+        xGrfContainer = xGraphicHelper.get();
 
-        pObjectHelper = SvXMLEmbeddedObjectHelper::Create(xStorage, mrDocShell, SvXMLEmbeddedObjectHelperMode::Read);
-        xObjectResolver = pObjectHelper;
+        xObjectHelper = SvXMLEmbeddedObjectHelper::Create(xStorage, mrDocShell, SvXMLEmbeddedObjectHelperMode::Read);
+        xObjectResolver = xObjectHelper.get();
     }
     uno::Sequence<uno::Any> aStylesArgs(4);
     uno::Any* pStylesArgs = aStylesArgs.getArray();
@@ -515,11 +515,13 @@ bool ScXMLImportWrapper::Import( ImportFlags nMode, ErrCode& rError )
 
         SAL_INFO( "sc.filter", "content import end" );
     }
-    if( pGraphicHelper )
-        SvXMLGraphicHelper::Destroy( pGraphicHelper );
+    if( xGraphicHelper.is() )
+        xGraphicHelper->dispose();
+    xGraphicHelper.clear();
 
-    if( pObjectHelper )
-        SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+    if( xObjectHelper.is() )
+        xObjectHelper->dispose();
+    xObjectHelper.clear();
 
     if (xStatusIndicator.is())
         xStatusIndicator->end();
@@ -862,7 +864,7 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
         }
 
         uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
-        SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr;
+        rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper;
 
         uno::Reference< document::XGraphicObjectResolver > xGrfContainer;
         SvXMLGraphicHelper* pGraphicHelper = nullptr;
@@ -875,8 +877,8 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
 
         if( pObjSh )
         {
-            pObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *pObjSh, SvXMLEmbeddedObjectHelperMode::Write );
-            xObjectResolver = pObjectHelper;
+            xObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *pObjSh, SvXMLEmbeddedObjectHelperMode::Write );
+            xObjectResolver = xObjectHelper.get();
         }
 
         // styles export
@@ -929,8 +931,9 @@ bool ScXMLImportWrapper::Export(bool bStylesOnly)
         if( pGraphicHelper )
             SvXMLGraphicHelper::Destroy( pGraphicHelper );
 
-        if( pObjectHelper )
-            SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+        if( xObjectHelper )
+            xObjectHelper->dispose();
+        xObjectHelper.clear();
 
         // settings export
 
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx
index 405ad7595ce6..00b61eb92859 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -509,7 +509,7 @@ bool SdXMLFilter::Import( ErrCode& nError )
     Reference< document::XGraphicObjectResolver > xGraphicResolver;
     SvXMLGraphicHelper *pGraphicHelper = nullptr;
     Reference< document::XEmbeddedObjectResolver > xObjectResolver;
-    SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr;
+    rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper;
 
     Reference< lang::XComponent > xModelComp( mxModel, uno::UNO_QUERY );
 
@@ -560,10 +560,10 @@ bool SdXMLFilter::Import( ErrCode& nError )
                                                      SvXMLGraphicHelperMode::Read,
                                                      false );
         xGraphicResolver = pGraphicHelper;
-        pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
+        xObjectHelper = SvXMLEmbeddedObjectHelper::Create(
                                     xStorage, *pDoc->GetPersist(),
                                     SvXMLEmbeddedObjectHelperMode::Read );
-        xObjectResolver = pObjectHelper;
+        xObjectResolver = xObjectHelper.get();
     }
 
     // Set base URI
@@ -652,8 +652,9 @@ bool SdXMLFilter::Import( ErrCode& nError )
     if( pGraphicHelper )
         SvXMLGraphicHelper::Destroy( pGraphicHelper );
     xGraphicResolver = nullptr;
-    if( pObjectHelper )
-        SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+    if( xObjectHelper.is() )
+        xObjectHelper->dispose();
+    xObjectHelper.clear();
     xObjectResolver = nullptr;
 
     if( mxStatusIndicator.is() )
@@ -783,7 +784,7 @@ bool SdXMLFilter::Import( ErrCode& nError )
 
 bool SdXMLFilter::Export()
 {
-    SvXMLEmbeddedObjectHelper*  pObjectHelper = nullptr;
+    rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper;
     SvXMLGraphicHelper*         pGraphicHelper = nullptr;
     bool                    bDocRet = false;
 
@@ -874,8 +875,8 @@ bool SdXMLFilter::Export()
             // create helper for graphic and ole export if we have a storage
             if( xStorage.is() )
             {
-                pObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *mrDocShell.GetDoc()->GetPersist(), SvXMLEmbeddedObjectHelperMode::Write );
-                xObjectResolver = pObjectHelper;
+                xObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *mrDocShell.GetDoc()->GetPersist(), SvXMLEmbeddedObjectHelperMode::Write );
+                xObjectResolver = xObjectHelper.get();
 
                 pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, SvXMLGraphicHelperMode::Write, false );
                 xGrfResolver = pGraphicHelper;
@@ -999,8 +1000,9 @@ bool SdXMLFilter::Export()
     if( pGraphicHelper )
         SvXMLGraphicHelper::Destroy( pGraphicHelper );
 
-    if( pObjectHelper )
-        SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+    if( xObjectHelper )
+        xObjectHelper->dispose();
+    xObjectHelper.clear();
 
     return bDocRet;
 }
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 636e5458500c..4c5a4469136d 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -71,7 +71,7 @@ public:
                                     , nState(-1)
                                 {}
 
-    static EmbedEventListener_Impl* Create( EmbeddedObjectRef* );
+    static rtl::Reference<EmbedEventListener_Impl> Create( EmbeddedObjectRef* );
 
     virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
     virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
@@ -82,23 +82,22 @@ public:
     virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
 };
 
-EmbedEventListener_Impl* EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
+rtl::Reference<EmbedEventListener_Impl> EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
 {
-    EmbedEventListener_Impl* pRet = new EmbedEventListener_Impl( p );
-    pRet->acquire();
+    rtl::Reference<EmbedEventListener_Impl> pRet(new EmbedEventListener_Impl( p ));
 
     if ( p->GetObject().is() )
     {
-        p->GetObject()->addStateChangeListener( pRet );
+        p->GetObject()->addStateChangeListener( pRet.get() );
 
         uno::Reference < util::XCloseable > xClose( p->GetObject(), uno::UNO_QUERY );
         DBG_ASSERT( xClose.is(), "Object does not support XCloseable!" );
         if ( xClose.is() )
-            xClose->addCloseListener( pRet );
+            xClose->addCloseListener( pRet.get() );
 
         uno::Reference < document::XEventBroadcaster > xBrd( p->GetObject(), uno::UNO_QUERY );
         if ( xBrd.is() )
-            xBrd->addEventListener( pRet );
+            xBrd->addEventListener( pRet.get() );
 
         pRet->nState = p->GetObject()->getCurrentState();
         if ( pRet->nState == embed::EmbedStates::RUNNING )
@@ -106,7 +105,7 @@ EmbedEventListener_Impl* EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
             uno::Reference < util::XModifiable > xMod( p->GetObject()->getComponent(), uno::UNO_QUERY );
             if ( xMod.is() )
                 // listen for changes in running state (update replacements in case of changes)
-                xMod->addModifyListener( pRet );
+                xMod->addModifyListener( pRet.get() );
         }
     }
 
@@ -221,7 +220,7 @@ struct EmbeddedObjectRef_Impl
 {
     uno::Reference <embed::XEmbeddedObject> mxObj;
 
-    EmbedEventListener_Impl*                    xListener;
+    rtl::Reference<EmbedEventListener_Impl>     mxListener;
     OUString                                    aPersistName;
     OUString                                    aMediaType;
     comphelper::EmbeddedObjectContainer*        pContainer;
@@ -235,7 +234,6 @@ struct EmbeddedObjectRef_Impl
     awt::Size                                   aDefaultSizeForChart_In_100TH_MM;//#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this member
 
     EmbeddedObjectRef_Impl() :
-        xListener(nullptr),
         pContainer(nullptr),
         pGraphic(nullptr),
         nViewAspect(embed::Aspects::MSOLE_CONTENT),
@@ -247,7 +245,6 @@ struct EmbeddedObjectRef_Impl
 
     EmbeddedObjectRef_Impl( const EmbeddedObjectRef_Impl& r ) :
         mxObj(r.mxObj),
-        xListener(nullptr),
         aPersistName(r.aPersistName),
         aMediaType(r.aMediaType),
         pContainer(r.pContainer),
@@ -280,13 +277,13 @@ EmbeddedObjectRef::EmbeddedObjectRef( const uno::Reference < embed::XEmbeddedObj
 {
     mpImpl->nViewAspect = nAspect;
     mpImpl->mxObj = xObj;
-    mpImpl->xListener = EmbedEventListener_Impl::Create( this );
+    mpImpl->mxListener = EmbedEventListener_Impl::Create( this );
 }
 
 EmbeddedObjectRef::EmbeddedObjectRef( const EmbeddedObjectRef& rObj ) :
     mpImpl(new EmbeddedObjectRef_Impl(*rObj.mpImpl))
 {
-    mpImpl->xListener = EmbedEventListener_Impl::Create( this );
+    mpImpl->mxListener = EmbedEventListener_Impl::Create( this );
 }
 
 EmbeddedObjectRef::~EmbeddedObjectRef()
@@ -301,7 +298,7 @@ void EmbeddedObjectRef::Assign( const uno::Reference < embed::XEmbeddedObject >&
     Clear();
     mpImpl->nViewAspect = nAspect;
     mpImpl->mxObj = xObj;
-    mpImpl->xListener = EmbedEventListener_Impl::Create( this );
+    mpImpl->mxListener = EmbedEventListener_Impl::Create( this );
 
     //#i103460#
     if ( IsChart() )
@@ -315,17 +312,17 @@ void EmbeddedObjectRef::Assign( const uno::Reference < embed::XEmbeddedObject >&
 
 void EmbeddedObjectRef::Clear()
 {
-    if (mpImpl->mxObj.is() && mpImpl->xListener)
+    if (mpImpl->mxObj.is() && mpImpl->mxListener.is())
     {
-        mpImpl->mxObj->removeStateChangeListener(mpImpl->xListener);
+        mpImpl->mxObj->removeStateChangeListener(mpImpl->mxListener.get());
 
         uno::Reference<util::XCloseable> xClose(mpImpl->mxObj, uno::UNO_QUERY);
         if ( xClose.is() )
-            xClose->removeCloseListener( mpImpl->xListener );
+            xClose->removeCloseListener( mpImpl->mxListener.get() );
 
         uno::Reference<document::XEventBroadcaster> xBrd(mpImpl->mxObj, uno::UNO_QUERY);
         if ( xBrd.is() )
-            xBrd->removeEventListener( mpImpl->xListener );
+            xBrd->removeEventListener( mpImpl->mxListener.get() );
 
         if ( mpImpl->bIsLocked )
         {
@@ -348,11 +345,10 @@ void EmbeddedObjectRef::Clear()
         }
     }
 
-    if (mpImpl->xListener)
+    if (mpImpl->mxListener.is())
     {
-        mpImpl->xListener->pObject = nullptr;
-        mpImpl->xListener->release();
-        mpImpl->xListener = nullptr;
+        mpImpl->mxListener->pObject = nullptr;
+        mpImpl->mxListener.clear();
     }
 
     mpImpl->mxObj = nullptr;
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() )
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index bb42dffa51e6..6ddeb64b8f3e 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -476,7 +476,7 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
     uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
     SvXMLGraphicHelper *pGraphicHelper = nullptr;
     uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
-    SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr;
+    rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper;
 
     // get the input stream (storage or stream)
     uno::Reference<embed::XStorage> xStorage;
@@ -495,10 +495,10 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
     SfxObjectShell *pPersist = rDoc.GetPersist();
     if( pPersist )
     {
-        pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
+        xObjectHelper = SvXMLEmbeddedObjectHelper::Create(
                                         xStorage, *pPersist,
                                         SvXMLEmbeddedObjectHelperMode::Read );
-        xObjectResolver = pObjectHelper;
+        xObjectResolver = xObjectHelper.get();
     }
 
     // Get the docshell, the model, and finally the model's component
@@ -891,8 +891,9 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, con
     if( pGraphicHelper )
         SvXMLGraphicHelper::Destroy( pGraphicHelper );
     xGraphicResolver = nullptr;
-    if( pObjectHelper )
-        SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+    if( xObjectHelper )
+        xObjectHelper->dispose();
+    xObjectHelper.clear();
     xObjectResolver = nullptr;
     aHoldRef.clear();
 
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 00562c6f7a25..e7469aec35dc 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -82,7 +82,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
     uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
     SvXMLGraphicHelper *pGraphicHelper = nullptr;
     uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
-    SvXMLEmbeddedObjectHelper *pObjectHelper = nullptr;
+    rtl::Reference<SvXMLEmbeddedObjectHelper> xObjectHelper;
 
     OSL_ENSURE( xStg.is(), "Where is my storage?" );
     pGraphicHelper = SvXMLGraphicHelper::Create( xStg,
@@ -93,10 +93,10 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
     SfxObjectShell *pPersist = pDoc->GetPersist();
     if( pPersist )
     {
-        pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
+        xObjectHelper = SvXMLEmbeddedObjectHelper::Create(
                                          xStg, *pPersist,
                                          SvXMLEmbeddedObjectHelperMode::Write );
-        xObjectResolver = pObjectHelper;
+        xObjectResolver = xObjectHelper.get();
     }
 
     // create and prepare the XPropertySet that gets passed through
@@ -392,8 +392,9 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
         SvXMLGraphicHelper::Destroy( pGraphicHelper );
     xGraphicResolver = nullptr;
 
-    if( pObjectHelper )
-        SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+    if( xObjectHelper )
+        xObjectHelper->dispose();
+    xObjectHelper.clear();
     xObjectResolver = nullptr;
 
     // restore redline mode
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index d4827e1ba4b6..7838281e699c 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -246,17 +246,16 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
         SetGraphicResolver( xGraphicResolver );
     }
 
-    SvXMLEmbeddedObjectHelper *pEmbeddedResolver = nullptr;
+    rtl::Reference<SvXMLEmbeddedObjectHelper> xEmbeddedResolver;
     if( !GetEmbeddedResolver().is() )
     {
         SfxObjectShell *pPersist = pDoc->GetPersist();
         if( pPersist )
         {
-            pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
+            xEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
                                             *pPersist,
                                             SvXMLEmbeddedObjectHelperMode::Write );
-            Reference< XEmbeddedObjectResolver > xEmbeddedResolver( pEmbeddedResolver );
-            SetEmbeddedResolver( xEmbeddedResolver );
+            SetEmbeddedResolver( Reference<XEmbeddedObjectResolver>( xEmbeddedResolver.get() ) );
         }
     }
 
@@ -296,8 +295,9 @@ ErrCode SwXMLExport::exportDoc( enum XMLTokenEnum eClass )
 
     if( pGraphicResolver )
         SvXMLGraphicHelper::Destroy( pGraphicResolver );
-    if( pEmbeddedResolver )
-        SvXMLEmbeddedObjectHelper::Destroy( pEmbeddedResolver );
+    if( xEmbeddedResolver )
+        xEmbeddedResolver->dispose();
+    xEmbeddedResolver.clear();
 
     OSL_ENSURE( !m_pTableLines, "there are table columns infos left" );
 
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 6e1d0e70e1f6..03e0edaac60f 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -395,7 +395,6 @@ SwXMLImport::SwXMLImport(
     m_pTableElemTokenMap( nullptr ),
     m_pTableCellAttrTokenMap( nullptr ),
     m_pGraphicResolver( nullptr ),
-    m_pEmbeddedResolver( nullptr ),
     m_nStyleFamilyMask( SfxStyleFamily::All ),
     m_bLoadDoc( true ),
     m_bInsert( false ),
@@ -673,10 +672,10 @@ void SwXMLImport::startDocument()
         SfxObjectShell *pPersist = pDoc->GetPersist();
         if( pPersist )
         {
-            m_pEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
+            m_xEmbeddedResolver = SvXMLEmbeddedObjectHelper::Create(
                                             *pPersist,
                                             SvXMLEmbeddedObjectHelperMode::Read );
-            Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver( m_pEmbeddedResolver );
+            Reference< document::XEmbeddedObjectResolver > xEmbeddedResolver( m_xEmbeddedResolver.get() );
             SetEmbeddedResolver( xEmbeddedResolver );
         }
     }
@@ -693,8 +692,9 @@ void SwXMLImport::endDocument()
 
     if( m_pGraphicResolver )
         SvXMLGraphicHelper::Destroy( m_pGraphicResolver );
-    if( m_pEmbeddedResolver )
-        SvXMLEmbeddedObjectHelper::Destroy( m_pEmbeddedResolver );
+    if( m_xEmbeddedResolver )
+        m_xEmbeddedResolver->dispose();
+    m_xEmbeddedResolver.clear();
     // Clear the shape import to sort the shapes  (and not in the
     // destructor that might be called after the import has finished
     // for Java filters.
diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx
index 769efa031b5e..1afa89ac1650 100644
--- a/sw/source/filter/xml/xmlimp.hxx
+++ b/sw/source/filter/xml/xmlimp.hxx
@@ -69,7 +69,8 @@ class SwXMLImport: public SvXMLImport
     SvXMLTokenMap           *m_pTableElemTokenMap;
     SvXMLTokenMap           *m_pTableCellAttrTokenMap;
     SvXMLGraphicHelper      *m_pGraphicResolver;
-    SvXMLEmbeddedObjectHelper   *m_pEmbeddedResolver;
+    rtl::Reference<SvXMLEmbeddedObjectHelper>
+                            m_xEmbeddedResolver;
 
     SvXMLItemMapEntriesRef  m_xTableItemMap;
     SvXMLItemMapEntriesRef  m_xTableColItemMap;


More information about the Libreoffice-commits mailing list