diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-03-02 10:51:50 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-03-03 08:49:48 +0100 |
commit | 097fcd045e99edcf418e8b34ccb6d6b0b8b8de4b (patch) | |
tree | 69e783771b4823a19a7dc8cfbeba313c1c6c09ca /embeddedobj/source | |
parent | 31693833dc832228c3821f83e045b6869ec22cf2 (diff) |
loplugin:refcounting (clang-cl)
Change-Id: Ifa54eed0a772b658d266e9e42be5f5232e7a6b79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111812
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'embeddedobj/source')
-rw-r--r-- | embeddedobj/source/inc/oleembobj.hxx | 6 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 2 | ||||
-rw-r--r-- | embeddedobj/source/msole/olecomponent.hxx | 4 | ||||
-rw-r--r-- | embeddedobj/source/msole/olemisc.cxx | 20 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 12 |
5 files changed, 19 insertions, 25 deletions
diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx index a4cc71c0f8d8..bc75a5af9c4c 100644 --- a/embeddedobj/source/inc/oleembobj.hxx +++ b/embeddedobj/source/inc/oleembobj.hxx @@ -120,7 +120,7 @@ class OleEmbeddedObject : public ::cppu::WeakImplHelper ::osl::Mutex m_aMutex; - OleComponent* m_pOleComponent; + rtl::Reference<OleComponent> m_pOleComponent; std::unique_ptr<::cppu::OMultiTypeInterfaceContainerHelper> m_pInterfaceContainer; @@ -274,8 +274,8 @@ protected: #ifdef _WIN32 bool SaveObject_Impl(); bool OnShowWindow_Impl( bool bShow ); - void CreateOleComponent_Impl( OleComponent* pOleComponent = nullptr ); - void CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent = nullptr ); + void CreateOleComponent_Impl( rtl::Reference<OleComponent> const & pOleComponent = {} ); + void CreateOleComponentAndLoad_Impl( rtl::Reference<OleComponent> const & pOleComponent = {} ); void CreateOleComponentFromClipboard_Impl( OleComponent* pOleComponent = nullptr ); OUString CreateTempURLEmpty_Impl(); OUString GetTempURL_Impl(); diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 4a123d5ca0ab..9fe827bb00d9 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -881,7 +881,7 @@ void OleComponent::CreateLinkFromFile( const OUString& aFileURL ) } -void OleComponent::InitEmbeddedCopyOfLink( OleComponent const * pOleLinkComponent ) +void OleComponent::InitEmbeddedCopyOfLink( rtl::Reference<OleComponent> const & pOleLinkComponent ) { if ( !pOleLinkComponent || !pOleLinkComponent->m_pNativeImpl->m_pObj ) throw lang::IllegalArgumentException(); // TODO diff --git a/embeddedobj/source/msole/olecomponent.hxx b/embeddedobj/source/msole/olecomponent.hxx index 3ff53291c01f..63547c321adc 100644 --- a/embeddedobj/source/msole/olecomponent.hxx +++ b/embeddedobj/source/msole/olecomponent.hxx @@ -32,7 +32,7 @@ #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/uno/XComponentContext.hpp> - +#include <rtl/ref.hxx> namespace cppu { class OMultiTypeInterfaceContainerHelper; @@ -103,7 +103,7 @@ public: const css::uno::Reference< css::datatransfer::XTransferable >& xTransfer ); void CreateObjectFromFile( const OUString& aFileName ); void CreateLinkFromFile( const OUString& aFileName ); - void InitEmbeddedCopyOfLink( OleComponent const * pOleLinkComponent ); + void InitEmbeddedCopyOfLink( rtl::Reference<OleComponent> const & pOleLinkComponent ); void RunObject(); // switch OLE object to running state diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx index 90041729d03d..f85c845e31a8 100644 --- a/embeddedobj/source/msole/olemisc.cxx +++ b/embeddedobj/source/msole/olemisc.cxx @@ -36,9 +36,7 @@ #include "ownview.hxx" -#if defined(_WIN32) #include "olecomponent.hxx" -#endif using namespace ::com::sun::star; @@ -46,8 +44,7 @@ using namespace ::com::sun::star; OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentContext >& xContext, const uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName ) -: m_pOleComponent( nullptr ) -, m_bReadOnly( false ) +: m_bReadOnly( false ) , m_bDisposed( false ) , m_nObjectState( -1 ) , m_nTargetState( -1 ) @@ -78,8 +75,7 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentConte // In case of loading from persistent entry the classID of the object // will be retrieved from the entry, during construction it is unknown OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentContext >& xContext, bool bLink ) -: m_pOleComponent( nullptr ) -, m_bReadOnly( false ) +: m_bReadOnly( false ) , m_bDisposed( false ) , m_nObjectState( -1 ) , m_nTargetState( -1 ) @@ -107,8 +103,7 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentConte // this constructor let object be initialized from clipboard OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< uno::XComponentContext >& xContext ) -: m_pOleComponent( nullptr ) -, m_bReadOnly( false ) +: m_bReadOnly( false ) , m_bDisposed( false ) , m_nObjectState( -1 ) , m_nTargetState( -1 ) @@ -245,8 +240,7 @@ void OleEmbeddedObject::GetRidOfComponent() } m_pOleComponent->disconnectEmbeddedObject(); - m_pOleComponent->release(); - m_pOleComponent = nullptr; + m_pOleComponent.clear(); } #endif } @@ -376,13 +370,13 @@ uno::Reference< util::XCloseable > SAL_CALL OleEmbeddedObject::getComponent() } #if defined(_WIN32) - if (m_pOleComponent != nullptr) + if (m_pOleComponent.is()) { - return uno::Reference< util::XCloseable >( static_cast< ::cppu::OWeakObject* >( m_pOleComponent ), uno::UNO_QUERY ); + return uno::Reference< util::XCloseable >( m_pOleComponent ); } #endif - assert(m_pOleComponent == nullptr); + assert(!m_pOleComponent.is()); // TODO/LATER: Is it correct??? return uno::Reference< util::XCloseable >(); // throw uno::RuntimeException(); // TODO diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index 04d5b6433c07..7f5002ec2772 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -47,6 +47,7 @@ #include <comphelper/classids.hxx> #include <osl/diagnose.h> #include <osl/thread.hxx> +#include <rtl/ref.hxx> #include <sal/log.hxx> #include <closepreventer.hxx> @@ -926,12 +927,12 @@ OUString OleEmbeddedObject::GetTempURL_Impl() } -void OleEmbeddedObject::CreateOleComponent_Impl( OleComponent* pOleComponent ) +void OleEmbeddedObject::CreateOleComponent_Impl( + rtl::Reference<OleComponent> const & pOleComponent ) { if ( !m_pOleComponent ) { m_pOleComponent = pOleComponent ? pOleComponent : new OleComponent( m_xContext, this ); - m_pOleComponent->acquire(); // TODO: needs holder? if ( !m_xClosePreventer.is() ) m_xClosePreventer.set( static_cast< ::cppu::OWeakObject* >( new OClosePreventer ), @@ -942,7 +943,8 @@ void OleEmbeddedObject::CreateOleComponent_Impl( OleComponent* pOleComponent ) } -void OleEmbeddedObject::CreateOleComponentAndLoad_Impl( OleComponent* pOleComponent ) +void OleEmbeddedObject::CreateOleComponentAndLoad_Impl( + rtl::Reference<OleComponent> const & pOleComponent ) { if ( !m_pOleComponent ) { @@ -1886,13 +1888,12 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag OUString aOldTempURL = m_aTempURL; m_aTempURL.clear(); - OleComponent* pNewOleComponent = new OleComponent(m_xContext, this); + rtl::Reference<OleComponent> pNewOleComponent = new OleComponent(m_xContext, this); try { pNewOleComponent->InitEmbeddedCopyOfLink(m_pOleComponent); } catch (const uno::Exception&) { - delete pNewOleComponent; if (!m_aTempURL.isEmpty()) KillFile_Impl(m_aTempURL, m_xContext); m_aTempURL = aOldTempURL; @@ -1904,7 +1905,6 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag } catch (const uno::Exception&) { - delete pNewOleComponent; if (!m_aTempURL.isEmpty()) KillFile_Impl(m_aTempURL, m_xContext); m_aTempURL = aOldTempURL; |