diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-25 15:54:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-26 08:13:46 +0200 |
commit | f025255bf66394ec168ae4cfc4d048c202800d16 (patch) | |
tree | dbd349df86257dbdd1841da909c982454750cd24 /sw | |
parent | 12ff6d6c35f84f4e57e59274049b7ece4e3d0a37 (diff) |
use rtl::Reference in SwXAutoTextEntry
instead of storing both a raw pointer and an uno::Reference
Change-Id: I52c8827446d999d0a34b91ab17c056d4237d71a7
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/inc/unoatxt.hxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/uno/unoatxt.cxx | 28 |
2 files changed, 18 insertions, 18 deletions
diff --git a/sw/source/uibase/inc/unoatxt.hxx b/sw/source/uibase/inc/unoatxt.hxx index feaf0ce69e04..00d6bb0de895 100644 --- a/sw/source/uibase/inc/unoatxt.hxx +++ b/sw/source/uibase/inc/unoatxt.hxx @@ -34,7 +34,9 @@ #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> #include <svtools/unoevent.hxx> + class SwTextBlocks; class SwGlossaries; class SwDoc; @@ -172,12 +174,12 @@ class SwXAutoTextEntry OUString sGroupName; OUString sEntryName; SwDocShellRef xDocSh; - SwXBodyText* pBodyText; - css::uno::Reference < css::lang::XServiceInfo> xBodyText; + rtl::Reference<SwXBodyText> + mxBodyText; void EnsureBodyText () { - if ( !pBodyText ) + if ( !mxBodyText.is() ) GetBodyText(); } void GetBodyText (); diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index f50550a2c661..3b19d0f2175d 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -721,8 +721,7 @@ SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const OUString& rGroupNa WeakComponentImplHelper(m_aMutex), pGlossaries(pGlss), sGroupName(rGroupName), - sEntryName(rEntryName), - pBodyText ( nullptr ) + sEntryName(rEntryName) { } @@ -761,7 +760,7 @@ void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint ) if (SfxEventHintId::PrepareCloseDoc == pEventHint->GetEventId()) { implFlushDocument(); - xBodyText = nullptr; + mxBodyText.clear(); EndListening( *xDocSh ); xDocSh.Clear(); } @@ -791,8 +790,7 @@ void SwXAutoTextEntry::GetBodyText () // start listening at the document StartListening( *xDocSh ); - pBodyText = new SwXBodyText ( xDocSh->GetDoc() ); - xBodyText.set( *pBodyText, uno::UNO_QUERY); + mxBodyText = new SwXBodyText ( xDocSh->GetDoc() ); } void SwXAutoTextEntry::disposing() @@ -805,7 +803,7 @@ uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursor() throw( { SolarMutexGuard aGuard; EnsureBodyText(); - return pBodyText->createTextCursor(); + return mxBodyText->createTextCursor(); } uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursorByRange( @@ -813,14 +811,14 @@ uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursorByRange( { SolarMutexGuard aGuard; EnsureBodyText(); - return pBodyText->createTextCursorByRange ( aTextPosition ); + return mxBodyText->createTextCursorByRange ( aTextPosition ); } void SwXAutoTextEntry::insertString(const uno::Reference< text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; EnsureBodyText(); - pBodyText->insertString ( xRange, aString, bAbsorb ); + mxBodyText->insertString ( xRange, aString, bAbsorb ); } void SwXAutoTextEntry::insertControlCharacter(const uno::Reference< text::XTextRange > & xRange, @@ -829,7 +827,7 @@ void SwXAutoTextEntry::insertControlCharacter(const uno::Reference< text::XTextR { SolarMutexGuard aGuard; EnsureBodyText(); - pBodyText->insertControlCharacter ( xRange, nControlCharacter, bAbsorb ); + mxBodyText->insertControlCharacter ( xRange, nControlCharacter, bAbsorb ); } void SwXAutoTextEntry::insertTextContent( @@ -839,7 +837,7 @@ void SwXAutoTextEntry::insertTextContent( { SolarMutexGuard aGuard; EnsureBodyText(); - pBodyText->insertTextContent ( xRange, xContent, bAbsorb ); + mxBodyText->insertTextContent ( xRange, xContent, bAbsorb ); } void SwXAutoTextEntry::removeTextContent( @@ -848,7 +846,7 @@ void SwXAutoTextEntry::removeTextContent( { SolarMutexGuard aGuard; EnsureBodyText(); - pBodyText->removeTextContent ( xContent ); + mxBodyText->removeTextContent ( xContent ); } uno::Reference< text::XText > SwXAutoTextEntry::getText() throw( uno::RuntimeException, std::exception ) @@ -862,28 +860,28 @@ uno::Reference< text::XTextRange > SwXAutoTextEntry::getStart() throw( uno::Run { SolarMutexGuard aGuard; EnsureBodyText(); - return pBodyText->getStart(); + return mxBodyText->getStart(); } uno::Reference< text::XTextRange > SwXAutoTextEntry::getEnd() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; EnsureBodyText(); - return pBodyText->getEnd(); + return mxBodyText->getEnd(); } OUString SwXAutoTextEntry::getString() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; EnsureBodyText(); - return pBodyText->getString(); + return mxBodyText->getString(); } void SwXAutoTextEntry::setString(const OUString& aString) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; EnsureBodyText(); - pBodyText->setString( aString ); + mxBodyText->setString( aString ); } void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextRange)throw( uno::RuntimeException, std::exception ) |