From f7ee0054cf9da35f210d9043a68339415aba2284 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 19 Jan 2017 11:54:53 +0200 Subject: use rtl::Reference in SwPostItField instead of manual acquire/release Change-Id: Id14ac4731e513ae37f922db5d1e497aee10b3b35 --- sw/inc/docufld.hxx | 4 ++-- sw/source/core/fields/docufld.cxx | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index b3685bcdb826..7b91dffeb559 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -21,7 +21,7 @@ #include #include - +#include #include #include "fldbas.hxx" @@ -443,7 +443,7 @@ class SW_DLLPUBLIC SwPostItField : public SwField OUString sName; ///< Name of the comment. DateTime aDateTime; OutlinerParaObject* mpText; - SwTextAPIObject* m_pTextObject; + rtl::Reference m_xTextObject; public: SwPostItField( SwPostItFieldType*, diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index e8205534509a..e9ab62338a93 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -1648,16 +1648,14 @@ SwPostItField::SwPostItField( SwPostItFieldType* pT, , sName( rName ) , aDateTime( rDateTime ) , mpText( nullptr ) - , m_pTextObject( nullptr ) { } SwPostItField::~SwPostItField() { - if ( m_pTextObject != nullptr ) + if ( m_xTextObject.is() ) { - m_pTextObject->DisposeEditSource(); - m_pTextObject->release(); + m_xTextObject->DisposeEditSource(); } delete mpText; @@ -1680,7 +1678,7 @@ SwField* SwPostItField::Copy() const if (mpText) pRet->SetTextObject( new OutlinerParaObject(*mpText) ); - // Note: member not copied. + // Note: member not copied. return pRet; } @@ -1747,21 +1745,20 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_TEXT: { - if ( !m_pTextObject ) + if ( !m_xTextObject.is() ) { SwPostItFieldType* pGetType = static_cast(GetTyp()); SwDoc* pDoc = pGetType->GetDoc(); SwTextAPIEditSource* pObj = new SwTextAPIEditSource( pDoc ); - const_cast (this)->m_pTextObject = new SwTextAPIObject( pObj ); - m_pTextObject->acquire(); + const_cast (this)->m_xTextObject = new SwTextAPIObject( pObj ); } if ( mpText ) - m_pTextObject->SetText( *mpText ); + m_xTextObject->SetText( *mpText ); else - m_pTextObject->SetString( sText ); + m_xTextObject->SetString( sText ); - uno::Reference < text::XText > xText( m_pTextObject ); + uno::Reference < text::XText > xText( m_xTextObject.get() ); rAny <<= xText; break; } -- cgit