include/vcl/outdevstate.hxx | 21 +++++++++---------- include/vcl/texteng.hxx | 12 +++++----- vcl/source/edit/texteng.cxx | 30 ++++++++++++--------------- vcl/source/edit/textundo.hxx | 4 +-- vcl/source/outdev/outdevstate.cxx | 42 +++++++++++++++++++------------------- 5 files changed, 54 insertions(+), 55 deletions(-)
New commits: commit 9b22966b2ce43b81cd156777dc6b5673582d15f1 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 09:46:17 2018 +0200 loplugin:useuniqueptr in OutDevState Change-Id: I9e29ca57eb3f00987dbac74cf7da2222f5b6d869 diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx index 94cf877e03d0..d58faac00c52 100644 --- a/include/vcl/outdevstate.hxx +++ b/include/vcl/outdevstate.hxx @@ -29,6 +29,7 @@ #include <tools/gen.hxx> #include <tools/fontenum.hxx> #include <o3tl/typed_flags_set.hxx> +#include <memory> class Color; @@ -79,17 +80,17 @@ public: OutDevState(); ~OutDevState(); - MapMode* mpMapMode; + std::unique_ptr<MapMode> mpMapMode; bool mbMapActive; - vcl::Region* mpClipRegion; - Color* mpLineColor; - Color* mpFillColor; - vcl::Font* mpFont; - Color* mpTextColor; - Color* mpTextFillColor; - Color* mpTextLineColor; - Color* mpOverlineColor; - Point* mpRefPoint; + std::unique_ptr<vcl::Region> mpClipRegion; + std::unique_ptr<Color> mpLineColor; + std::unique_ptr<Color> mpFillColor; + std::unique_ptr<vcl::Font> mpFont; + std::unique_ptr<Color> mpTextColor; + std::unique_ptr<Color> mpTextFillColor; + std::unique_ptr<Color> mpTextLineColor; + std::unique_ptr<Color> mpOverlineColor; + std::unique_ptr<Point> mpRefPoint; TextAlign meTextAlign; RasterOp meRasterOp; ComplexTextLayoutFlags mnTextLayoutMode; diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index 388962906829..07b7d1cfa85e 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -52,16 +52,16 @@ OutDevState::OutDevState() OutDevState::~OutDevState() { - delete mpLineColor; - delete mpFillColor; - delete mpFont; - delete mpTextColor; - delete mpTextFillColor; - delete mpTextLineColor; - delete mpOverlineColor; - delete mpMapMode; - delete mpClipRegion; - delete mpRefPoint; + mpLineColor.reset(); + mpFillColor.reset(); + mpFont.reset(); + mpTextColor.reset(); + mpTextFillColor.reset(); + mpTextLineColor.reset(); + mpOverlineColor.reset(); + mpMapMode.reset(); + mpClipRegion.reset(); + mpRefPoint.reset(); } void OutputDevice::Push( PushFlags nFlags ) @@ -76,27 +76,27 @@ void OutputDevice::Push( PushFlags nFlags ) if (nFlags & PushFlags::LINECOLOR && mbLineColor) { - pState->mpLineColor = new Color( maLineColor ); + pState->mpLineColor.reset( new Color( maLineColor ) ); } if (nFlags & PushFlags::FILLCOLOR && mbFillColor) { - pState->mpFillColor = new Color( maFillColor ); + pState->mpFillColor.reset( new Color( maFillColor ) ); } if ( nFlags & PushFlags::FONT ) - pState->mpFont = new vcl::Font( maFont ); + pState->mpFont.reset( new vcl::Font( maFont ) ); if ( nFlags & PushFlags::TEXTCOLOR ) - pState->mpTextColor = new Color( GetTextColor() ); + pState->mpTextColor.reset( new Color( GetTextColor() ) ); if (nFlags & PushFlags::TEXTFILLCOLOR && IsTextFillColor()) { - pState->mpTextFillColor = new Color( GetTextFillColor() ); + pState->mpTextFillColor.reset( new Color( GetTextFillColor() ) ); } if (nFlags & PushFlags::TEXTLINECOLOR && IsTextLineColor()) { - pState->mpTextLineColor = new Color( GetTextLineColor() ); + pState->mpTextLineColor.reset( new Color( GetTextLineColor() ) ); } if (nFlags & PushFlags::OVERLINECOLOR && IsOverlineColor()) { - pState->mpOverlineColor = new Color( GetOverlineColor() ); + pState->mpOverlineColor.reset( new Color( GetOverlineColor() ) ); } if ( nFlags & PushFlags::TEXTALIGN ) pState->meTextAlign = GetTextAlign(); @@ -108,16 +108,16 @@ void OutputDevice::Push( PushFlags nFlags ) pState->meRasterOp = GetRasterOp(); if ( nFlags & PushFlags::MAPMODE ) { - pState->mpMapMode = new MapMode( maMapMode ); + pState->mpMapMode.reset( new MapMode( maMapMode ) ); pState->mbMapActive = mbMap; } if (nFlags & PushFlags::CLIPREGION && mbClipRegion) { - pState->mpClipRegion = new vcl::Region( maRegion ); + pState->mpClipRegion.reset( new vcl::Region( maRegion ) ); } if (nFlags & PushFlags::REFPOINT && mbRefPoint) { - pState->mpRefPoint = new Point( maRefPoint ); + pState->mpRefPoint.reset( new Point( maRefPoint ) ); } mpOutDevStateStack->push_back( pState ); @@ -213,7 +213,7 @@ void OutputDevice::Pop() } if ( rState.mnFlags & PushFlags::CLIPREGION ) - SetDeviceClipRegion( rState.mpClipRegion ); + SetDeviceClipRegion( rState.mpClipRegion.get() ); if ( rState.mnFlags & PushFlags::REFPOINT ) { commit 57ca1aa405845077af8ff6955236e6fc88758a99 Author: Noel Grandin <[email protected]> Date: Mon Jan 15 08:29:31 2018 +0200 loplugin:useuniqueptr in TextEngine Change-Id: Iff5d10c4e962994823ec4ce6a765f4456c677352 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 ); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
