diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 11:54:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-19 13:06:47 +0200 |
commit | f7ee0054cf9da35f210d9043a68339415aba2284 (patch) | |
tree | a742188e64af9a40d3c33be5017888b501f78ef3 /sw | |
parent | a754294ac7a902fe96fbbd6b8b6824a360d6b248 (diff) |
use rtl::Reference in SwPostItField
instead of manual acquire/release
Change-Id: Id14ac4731e513ae37f922db5d1e497aee10b3b35
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/docufld.hxx | 4 | ||||
-rw-r--r-- | 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 <tools/date.hxx> #include <tools/datetime.hxx> - +#include <rtl/ref.hxx> #include <svl/macitem.hxx> #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<SwTextAPIObject> 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 <m_pTextObject> not copied. + // Note: member <m_xTextObject> 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<SwPostItFieldType*>(GetTyp()); SwDoc* pDoc = pGetType->GetDoc(); SwTextAPIEditSource* pObj = new SwTextAPIEditSource( pDoc ); - const_cast <SwPostItField*> (this)->m_pTextObject = new SwTextAPIObject( pObj ); - m_pTextObject->acquire(); + const_cast <SwPostItField*> (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; } |