diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-15 08:29:31 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-16 11:45:58 +0200 |
commit | 57ca1aa405845077af8ff6955236e6fc88758a99 (patch) | |
tree | 06faa3349ce15ff962fd4df6288f2d19254a5f4e | |
parent | 5787f5b393ac8d239c043391e24ab91179d0ef1d (diff) |
loplugin:useuniqueptr in TextEngine
Change-Id: Iff5d10c4e962994823ec4ce6a765f4456c677352
-rw-r--r-- | include/vcl/texteng.hxx | 12 | ||||
-rw-r--r-- | vcl/source/edit/texteng.cxx | 30 | ||||
-rw-r--r-- | vcl/source/edit/textundo.hxx | 4 |
3 files changed, 22 insertions, 24 deletions
diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx index c4e70d56d06e..dcab1dd337b2 100644 --- a/include/vcl/texteng.hxx +++ b/include/vcl/texteng.hxx @@ -94,16 +94,16 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster friend class TextUndoInsertChars; friend class TextUndoRemoveChars; - TextDoc* mpDoc; - TEParaPortions* mpTEParaPortions; + std::unique_ptr<TextDoc> mpDoc; + std::unique_ptr<TEParaPortions> mpTEParaPortions; VclPtr<OutputDevice> mpRefDev; - TextViews* mpViews; + std::unique_ptr<TextViews> mpViews; TextView* mpActiveView; - TextUndoManager* mpUndoManager; + std::unique_ptr<TextUndoManager> mpUndoManager; - IdleFormatter* mpIdleFormatter; + std::unique_ptr<IdleFormatter> mpIdleFormatter; std::unique_ptr<TEIMEInfos> mpIMEInfos; @@ -113,7 +113,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster tools::Rectangle maInvalidRect; - LocaleDataWrapper* mpLocaleDataWrapper; + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; vcl::Font maFont; Color maTextColor; diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 379f2adeb6c0..ec57a36041a2 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -89,9 +89,9 @@ TextEngine::TextEngine() , mbRightToLeft {false} , mbHasMultiLineParas {false} { - mpViews = new TextViews; + mpViews.reset( new TextViews ); - mpIdleFormatter = new IdleFormatter; + mpIdleFormatter.reset( new IdleFormatter ); mpIdleFormatter->SetInvokeHandler( LINK( this, TextEngine, IdleFormatHdl ) ); mpIdleFormatter->SetDebugName( "vcl::TextEngine mpIdleFormatter" ); @@ -113,14 +113,14 @@ TextEngine::~TextEngine() { mbDowning = true; - delete mpIdleFormatter; - delete mpDoc; - delete mpTEParaPortions; - delete mpViews; // only the list, not the Views + mpIdleFormatter.reset(); + mpDoc.reset(); + mpTEParaPortions.reset(); + mpViews.reset(); // only the list, not the Views mpRefDev.disposeAndClear(); - delete mpUndoManager; + mpUndoManager.reset(); mpIMEInfos.reset(); - delete mpLocaleDataWrapper; + mpLocaleDataWrapper.reset(); } void TextEngine::InsertView( TextView* pTextView ) @@ -375,10 +375,9 @@ void TextEngine::ImpInitDoc() if ( mpDoc ) mpDoc->Clear(); else - mpDoc = new TextDoc; + mpDoc.reset( new TextDoc ); - delete mpTEParaPortions; - mpTEParaPortions = new TEParaPortions; + mpTEParaPortions.reset(new TEParaPortions); TextNode* pNode = new TextNode( OUString() ); mpDoc->GetNodes().insert( mpDoc->GetNodes().begin(), pNode ); @@ -1305,7 +1304,7 @@ void TextEngine::EnableUndo( bool bEnable ) ::svl::IUndoManager& TextEngine::GetUndoManager() { if ( !mpUndoManager ) - mpUndoManager = new TextUndoManager( this ); + mpUndoManager.reset( new TextUndoManager( this ) ); return *mpUndoManager; } @@ -2719,8 +2718,7 @@ uno::Reference< i18n::XBreakIterator > const & TextEngine::GetBreakIterator() void TextEngine::SetLocale( const css::lang::Locale& rLocale ) { maLocale = rLocale; - delete mpLocaleDataWrapper; - mpLocaleDataWrapper = nullptr; + mpLocaleDataWrapper.reset(); } css::lang::Locale const & TextEngine::GetLocale() @@ -2735,9 +2733,9 @@ css::lang::Locale const & TextEngine::GetLocale() LocaleDataWrapper* TextEngine::ImpGetLocaleDataWrapper() { if ( !mpLocaleDataWrapper ) - mpLocaleDataWrapper = new LocaleDataWrapper( LanguageTag( GetLocale()) ); + mpLocaleDataWrapper.reset( new LocaleDataWrapper( LanguageTag( GetLocale()) ) ); - return mpLocaleDataWrapper; + return mpLocaleDataWrapper.get(); } void TextEngine::SetRightToLeft( bool bR2L ) diff --git a/vcl/source/edit/textundo.hxx b/vcl/source/edit/textundo.hxx index caa985a84eb3..0ec4a9aba328 100644 --- a/vcl/source/edit/textundo.hxx +++ b/vcl/source/edit/textundo.hxx @@ -60,8 +60,8 @@ protected: TextView* GetView() const { return mpTextEngine->GetActiveView(); } void SetSelection( const TextSelection& rSel ); - TextDoc* GetDoc() const { return mpTextEngine->mpDoc; } - TEParaPortions* GetTEParaPortions() const { return mpTextEngine->mpTEParaPortions; } + TextDoc* GetDoc() const { return mpTextEngine->mpDoc.get(); } + TEParaPortions* GetTEParaPortions() const { return mpTextEngine->mpTEParaPortions.get(); } public: explicit TextUndo( TextEngine* pTextEngine ); |