diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-18 08:50:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-18 10:59:59 +0200 |
commit | 1d9ea5f576cab03c920a6be933a923b7bcdabc44 (patch) | |
tree | 90fe51c8e8d7c438051c4d3146dc9f22dad7b906 /linguistic/source | |
parent | e5634d4e3bcba6dc5aa46dc8ebfa388f6442abc0 (diff) |
use rtl::Reference in ConvDicList
instead of storing both a raw pointer and an uno::Reference
Change-Id: I7241edcb50736d0650349387ca1c032b88caf192
Diffstat (limited to 'linguistic/source')
-rw-r--r-- | linguistic/source/convdiclist.cxx | 36 | ||||
-rw-r--r-- | linguistic/source/convdiclist.hxx | 17 |
2 files changed, 21 insertions, 32 deletions
diff --git a/linguistic/source/convdiclist.cxx b/linguistic/source/convdiclist.cxx index 4efefdf7e936..e486175b2e4a 100644 --- a/linguistic/source/convdiclist.cxx +++ b/linguistic/source/convdiclist.cxx @@ -348,38 +348,34 @@ void ConvDicList::MyAppExitListener::AtExit() ConvDicList::ConvDicList() : aEvtListeners( GetLinguMutex() ) { - pNameContainer = nullptr; bDisposing = false; - pExitListener = new MyAppExitListener( *this ); - xExitListener = pExitListener; - pExitListener->Activate(); + mxExitListener = new MyAppExitListener( *this ); + mxExitListener->Activate(); } ConvDicList::~ConvDicList() { + if (!bDisposing && mxNameContainer.is()) + mxNameContainer->FlushDics(); - if (!bDisposing && pNameContainer) - pNameContainer->FlushDics(); - - pExitListener->Deactivate(); + mxExitListener->Deactivate(); } void ConvDicList::FlushDics() { // check only pointer to avoid creating the container when // the dictionaries were not accessed yet - if (pNameContainer) - pNameContainer->FlushDics(); + if (mxNameContainer.is()) + mxNameContainer->FlushDics(); } ConvDicNameContainer & ConvDicList::GetNameContainer() { - if (!pNameContainer) + if (!mxNameContainer.is()) { - pNameContainer = new ConvDicNameContainer; - pNameContainer->AddConvDics( GetDictionaryWriteablePath(), CONV_DIC_EXT ); - xNameContainer = pNameContainer; + mxNameContainer = new ConvDicNameContainer; + mxNameContainer->AddConvDics( GetDictionaryWriteablePath(), CONV_DIC_EXT ); // access list of text conversion dictionaries to activate SvtLinguOptions aOpt; @@ -389,7 +385,7 @@ ConvDicNameContainer & ConvDicList::GetNameContainer() for (sal_Int32 i = 0; i < nLen; ++i) { uno::Reference< XConversionDictionary > xDic = - pNameContainer->GetByName( pActiveConvDics[i] ); + mxNameContainer->GetByName( pActiveConvDics[i] ); if (xDic.is()) xDic->setActive( true ); } @@ -397,24 +393,24 @@ ConvDicNameContainer & ConvDicList::GetNameContainer() // since there is no UI to active/deactivate the dictionaries // for chinese text conversion they should be activated by default uno::Reference< XConversionDictionary > xS2TDic( - pNameContainer->GetByName( "ChineseS2T" ), UNO_QUERY ); + mxNameContainer->GetByName( "ChineseS2T" ), UNO_QUERY ); uno::Reference< XConversionDictionary > xT2SDic( - pNameContainer->GetByName( "ChineseT2S" ), UNO_QUERY ); + mxNameContainer->GetByName( "ChineseT2S" ), UNO_QUERY ); if (xS2TDic.is()) xS2TDic->setActive( true ); if (xT2SDic.is()) xT2SDic->setActive( true ); } - return *pNameContainer; + return *mxNameContainer; } uno::Reference< container::XNameContainer > SAL_CALL ConvDicList::getDictionaryContainer( ) throw (RuntimeException, std::exception) { MutexGuard aGuard( GetLinguMutex() ); GetNameContainer(); - DBG_ASSERT( xNameContainer.is(), "missing name container" ); - return xNameContainer; + DBG_ASSERT( mxNameContainer.is(), "missing name container" ); + return mxNameContainer.get(); } uno::Reference< XConversionDictionary > SAL_CALL ConvDicList::addNewDictionary( diff --git a/linguistic/source/convdiclist.hxx b/linguistic/source/convdiclist.hxx index 4c2bc3d0687f..98af26e1b431 100644 --- a/linguistic/source/convdiclist.hxx +++ b/linguistic/source/convdiclist.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase.hxx> #include <cppuhelper/interfacecontainer.h> +#include <rtl/ref.hxx> #include "linguistic/misc.hxx" #include "lngopt.hxx" @@ -51,18 +52,10 @@ class ConvDicList : virtual void AtExit() override; }; - - ::comphelper::OInterfaceContainerHelper2 aEvtListeners; - - ConvDicNameContainer *pNameContainer; - css::uno::Reference< - css::container::XNameContainer > xNameContainer; - - MyAppExitListener *pExitListener; - css::uno::Reference< css::frame:: - XTerminateListener > xExitListener; - - bool bDisposing; + ::comphelper::OInterfaceContainerHelper2 aEvtListeners; + rtl::Reference<ConvDicNameContainer> mxNameContainer; + rtl::Reference<MyAppExitListener> mxExitListener; + bool bDisposing; ConvDicList( const ConvDicList & ) = delete; ConvDicList & operator = (const ConvDicList &) = delete; |