diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-05-20 08:59:38 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-05-20 15:23:09 +0100 |
commit | 93f9abda6b191f2be9cadae9fb23e9a7f7d230b3 (patch) | |
tree | 430a9cca3275ed5c20e022a5dfb821481b423703 | |
parent | 66f729541c1144bbe28f3c08c6a8930c646bdc56 (diff) |
return by ref instead of pointer
-rw-r--r-- | editeng/inc/editeng/eerdll.hxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 3 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/eerdll.cxx | 32 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 12 |
6 files changed, 28 insertions, 31 deletions
diff --git a/editeng/inc/editeng/eerdll.hxx b/editeng/inc/editeng/eerdll.hxx index 7388b09f50..14b4a2d557 100644 --- a/editeng/inc/editeng/eerdll.hxx +++ b/editeng/inc/editeng/eerdll.hxx @@ -47,12 +47,12 @@ class EditDLL GlobalEditData* pGlobalData; public: - EditDLL(); - ~EditDLL(); + EditDLL(); + ~EditDLL(); ResMgr* GetResMgr() const { return pResMgr; } GlobalEditData* GetGlobalData() const { return pGlobalData; } - static EditDLL* Get(); + static EditDLL& Get(); }; #define EE_DLL() EditDLL::Get() diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 08758a8f64..3412d702a4 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -2262,8 +2262,7 @@ EditEngineItemPool::EditEngineItemPool( sal_Bool bPersistenRefCounts ) SetVersionMap( 4, 3994, 4022, aV4Map ); SetVersionMap( 5, 3994, 4037, aV5Map ); - DBG_ASSERT( EE_DLL(), "EditDLL?!" ); - SfxPoolItem** ppDefItems = EE_DLL()->GetGlobalData()->GetDefItems(); + SfxPoolItem** ppDefItems = EE_DLL().GetGlobalData()->GetDefItems(); SetDefaults( ppDefItems ); } diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 40c9242930..ba27a22ad2 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1121,7 +1121,7 @@ sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditVie xub_Unicode nCharCode = rKeyEvent.GetCharCode(); pEditView->pImpEditView->DrawSelection(); // Autocorrection? - SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); + SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); if ( ( pImpEditEngine->GetStatus().DoAutoCorrect() ) && ( SvxAutoCorrect::IsAutoCorrectChar( nCharCode ) || pAutoCorrect->HasRunNext() ) ) diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index eb586a4a74..89ac0e1b87 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -1055,7 +1055,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) Reference< XSpellAlternatives > xSpellAlt = xSpeller->spell( aSelected, PIMPEE->GetLanguage( aPaM2 ), aPropVals ); - Reference< XLanguageGuessing > xLangGuesser( EE_DLL()->GetGlobalData()->GetLanguageGuesser() ); + Reference< XLanguageGuessing > xLangGuesser( EE_DLL().GetGlobalData()->GetLanguageGuesser() ); // check if text might belong to a different language... LanguageType nGuessLangWord = LANGUAGE_NONE; @@ -1272,7 +1272,7 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) { DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range"); String aWord = pAlt[nId - MN_AUTOSTART]; - SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); + SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); if ( pAutoCorrect ) pAutoCorrect->PutText( aSelected, aWord, PIMPEE->GetLanguage( aPaM2 ) ); InsertText( aWord ); diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx index 219e60353b..9a4e56313a 100644 --- a/editeng/source/editeng/eerdll.cxx +++ b/editeng/source/editeng/eerdll.cxx @@ -76,22 +76,24 @@ #include <editeng/forbiddencharacterstable.hxx> #include <editeng/justifyitem.hxx> #include <comphelper/processfactory.hxx> - -static EditDLL* pDLL=0; +#include <rtl/instance.hxx> using namespace ::com::sun::star; -EditDLL* EditDLL::Get() +namespace +{ + class theEditDLL : public rtl::Static<EditDLL, theEditDLL> {}; +} + +EditDLL& EditDLL::Get() { - if ( !pDLL ) - pDLL = new EditDLL; - return pDLL; + return theEditDLL::get(); } GlobalEditData::GlobalEditData() + : m_aStdRefDevice(::com::sun::star::uno::Reference<com::sun::star::lang::XComponent>(::comphelper::getProcessComponentContext(), ::com::sun::star::uno::UNO_QUERY_THROW)) { ppDefItems = NULL; - pStdRefDevice = NULL; } GlobalEditData::~GlobalEditData() @@ -100,7 +102,6 @@ GlobalEditData::~GlobalEditData() // Or simply keep them, since at end of excecution?! if ( ppDefItems ) SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, sal_True ); - delete pStdRefDevice; } SfxPoolItem** GlobalEditData::GetDefItems() @@ -208,30 +209,27 @@ uno::Reference< linguistic2::XLanguageGuessing > GlobalEditData::GetLanguageGues OutputDevice* GlobalEditData::GetStdRefDevice() { - if ( !pStdRefDevice ) + if ( !m_aStdRefDevice ) { - pStdRefDevice = new VirtualDevice; - pStdRefDevice->SetMapMode( MAP_TWIP ); + m_aStdRefDevice.reset(new VirtualDevice); + m_aStdRefDevice->SetMapMode( MAP_TWIP ); } - return pStdRefDevice; + return m_aStdRefDevice.get(); } EditResId::EditResId( sal_uInt16 nId ): - ResId( nId, *EE_DLL()->GetResMgr() ) + ResId( nId, *EE_DLL().GetResMgr() ) { } EditDLL::EditDLL() { pGlobalData = new GlobalEditData; - ByteString aResMgrName( "editeng" ); - pResMgr = ResMgr::CreateResMgr( - aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); + pResMgr = ResMgr::CreateResMgr( "editeng", Application::GetSettings().GetUILocale() ); } EditDLL::~EditDLL() { - delete pResMgr; delete pGlobalData; } diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 666d6300a7..93decd93c5 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -160,7 +160,7 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : aOnlineSpellTimer.SetTimeout( 100 ); aOnlineSpellTimer.SetTimeoutHdl( LINK( this, ImpEditEngine, OnlineSpellHdl ) ); - pRefDev = EE_DLL()->GetGlobalData()->GetStdRefDevice(); + pRefDev = EE_DLL().GetGlobalData()->GetStdRefDevice(); // Access data already from here on! SetRefDevice( pRefDev ); @@ -206,7 +206,7 @@ void ImpEditEngine::SetRefDevice( OutputDevice* pRef ) bOwnerOfRefDev = sal_False; if ( !pRef ) - pRefDev = EE_DLL()->GetGlobalData()->GetStdRefDevice(); + pRefDev = EE_DLL().GetGlobalData()->GetStdRefDevice(); nOnePixelInRef = (sal_uInt16)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width(); @@ -223,7 +223,7 @@ void ImpEditEngine::SetRefMapMode( const MapMode& rMapMode ) return; // When RefDev == GlobalRefDev => create own! - if ( !bOwnerOfRefDev && ( pRefDev == EE_DLL()->GetGlobalData()->GetStdRefDevice() ) ) + if ( !bOwnerOfRefDev && ( pRefDev == EE_DLL().GetGlobalData()->GetStdRefDevice() ) ) { pRefDev = new VirtualDevice; pRefDev->SetMapMode( MAP_TWIP ); @@ -2521,7 +2521,7 @@ EditPaM ImpEditEngine::AutoCorrect( const EditSelection& rCurSel, xub_Unicode c, sal_Bool bOverwrite, Window* pFrameWin ) { EditSelection aSel( rCurSel ); - SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get()->GetAutoCorrect(); + SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); if ( pAutoCorrect ) { if ( aSel.HasRange() ) @@ -4452,13 +4452,13 @@ rtl::Reference<SvxForbiddenCharactersTable> ImpEditEngine::GetForbiddenCharsTabl { rtl::Reference<SvxForbiddenCharactersTable> xF = xForbiddenCharsTable; if ( !xF.is() && bGetInternal ) - xF = EE_DLL()->GetGlobalData()->GetForbiddenCharsTable(); + xF = EE_DLL().GetGlobalData()->GetForbiddenCharsTable(); return xF; } void ImpEditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars ) { - EE_DLL()->GetGlobalData()->SetForbiddenCharsTable( xForbiddenChars ); + EE_DLL().GetGlobalData()->SetForbiddenCharsTable( xForbiddenChars ); } svtools::ColorConfig& ImpEditEngine::GetColorConfig() |