[Libreoffice-commits] core.git: 2 commits - sd/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Mar 22 06:33:59 UTC 2018


 sd/source/ui/inc/DrawViewShell.hxx           |    4 
 sd/source/ui/presenter/PresenterTextView.cxx |  132 ++++++++++++---------------
 sd/source/ui/view/drviews2.cxx               |   74 +++++++--------
 sd/source/ui/view/drviews7.cxx               |    4 
 sd/source/ui/view/drviewsa.cxx               |   16 +--
 sd/source/ui/view/drviewse.cxx               |   24 ++--
 6 files changed, 120 insertions(+), 134 deletions(-)

New commits:
commit 00635fb32c09ab90bff713eb53333de045e301a6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Mar 19 15:11:25 2018 +0200

    loplugin:useuniqueptr in DrawViewShell
    
    Change-Id: I5125e973fbda75b2c7e52e294db74bc3bd5e0bd9
    Reviewed-on: https://gerrit.libreoffice.org/51662
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 494f96cf5588..1db285351c1b 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -355,7 +355,7 @@ public:
 
     virtual css::uno::Reference<css::drawing::XDrawSubController> CreateSubController() override;
 
-    DrawView*   GetDrawView() const { return mpDrawView; }
+    DrawView*   GetDrawView() const { return mpDrawView.get(); }
 
     /** Relocation to a new parent window is not supported for DrawViewShell
         objects so this method always returns <FALSE/>.
@@ -369,7 +369,7 @@ public:
     //move this method to ViewShell.
     //void  NotifyAccUpdate();
 protected:
-    DrawView*           mpDrawView;
+    std::unique_ptr<DrawView> mpDrawView;
     SdPage*             mpActualPage;
     ::tools::Rectangle           maMarkRect;
     Point               maMousePos;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 6ba5d833ee9b..35d290692da6 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -938,7 +938,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             else
             {
                 // open zoom dialog
-                SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+                SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             }
             Cancel();
         }
@@ -970,7 +970,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                 {
                     if( mpDrawView->IsVectorizeAllowed() )
                     {
-                        SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+                        SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
                     }
                     else
                     {
@@ -1329,7 +1329,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                     GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() );
                     m_ExternalEdits.push_back(
                         o3tl::make_unique<SdrExternalToolEdit>(
-                            mpDrawView, pObj));
+                            mpDrawView.get(), pObj));
                     m_ExternalEdits.back()->Edit( &aGraphicObject );
                 }
             }
@@ -1368,7 +1368,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_ATTRIBUTES_LINE:  // BASIC
         {
-            SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             if (rReq.GetArgs())
                 Cancel();
         }
@@ -1376,7 +1376,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_ATTRIBUTES_AREA:  // BASIC
         {
-            SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             if (rReq.GetArgs())
                 Cancel();
         }
@@ -1384,7 +1384,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_ATTR_TRANSFORM:
         {
-            SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             if (rReq.GetArgs())
             {
                 Invalidate(SID_RULER_OBJECT);
@@ -1396,14 +1396,14 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_CHAR_DLG_EFFECT:
         case SID_CHAR_DLG:  // BASIC
         {
-            SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
 
         case SID_PARA_DLG:
         {
-            SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
@@ -1430,7 +1430,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case FN_SVX_SET_BULLET:
         case FN_SVX_SET_NUMBER:
         {
-            SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
@@ -1444,21 +1444,21 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_INSERT_ZWSP:
         case SID_CHARMAP:
         {
-            SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
 
         case SID_PRESENTATION_LAYOUT:
         {
-            SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+            SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
             Cancel();
         }
         break;
 
         case SID_PASTE_SPECIAL:
         {
-            SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore ();
         }
@@ -1467,7 +1467,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_CHANGE_PICTURE:
         case SID_INSERT_GRAPHIC:
         {
-            SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq,
+            SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq,
                                                          nSId == SID_CHANGE_PICTURE ) );
             Cancel();
             rReq.Ignore ();
@@ -1476,7 +1476,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_INSERT_AVMEDIA:
         {
-            SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
 
             Cancel();
             rReq.Ignore ();
@@ -1489,12 +1489,12 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_INSERT_DIAGRAM:
         case SID_ATTR_TABLE:
         {
-            SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             // Set the selection tool as the old one. This in particular important for the
             // zoom function, in which clicking without dragging zooms as well, and that
             // makes exiting the object editing mode impossible.
             if (dynamic_cast<FuSelection*>( GetOldFunction().get() ) == nullptr)
-                SetOldFunction( FuSelection::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+                SetOldFunction( FuSelection::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore ();
         }
@@ -1565,7 +1565,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                     mpDrawView->SdrEndTextEdit();
                 }
 
-                SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+                SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             }
             Cancel();
             rReq.Ignore ();
@@ -1575,7 +1575,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_INSERTFILE:  // BASIC
         {
             Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
-            SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
             Cancel();
             rReq.Done ();
@@ -1588,7 +1588,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_ATTR_PAGE:
         case SID_PAGESETUP:  // BASIC ??
         {
-            SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore (); // we generate independent macros !!
         }
@@ -1597,7 +1597,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_BEFORE_OBJ:
         case SID_BEHIND_OBJ:
         {
-            SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+            SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
             rReq.Done();
             // finishes itself, no Cancel() needed!
         }
@@ -1613,14 +1613,14 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_ANIMATION_EFFECTS:
         {
-            SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+            SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
             Cancel();
         }
         break;
 
         case SID_LINEEND_POLYGON:
         {
-            SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
@@ -1631,14 +1631,14 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
             SAL_FALLTHROUGH;
         case SID_SET_SNAPITEM:
         {
-            SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+            SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
             Cancel();
         }
         break;
 
         case SID_MANAGE_LINKS:
         {
-            SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore ();
         }
@@ -1646,7 +1646,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_THESAURUS:
         {
-            SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore ();
         }
@@ -1654,7 +1654,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_TEXTATTR_DLG:
         {
-            SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore ();
         }
@@ -1662,7 +1662,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_MEASURE_DLG:
         {
-            SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Ignore ();
         }
@@ -1670,7 +1670,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_CONNECTION_DLG:
         {
-            SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
             rReq.Done();
         }
@@ -1759,7 +1759,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_POLYGON_MORPHING:
         {
-            SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
@@ -2790,7 +2790,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
                     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
                     if( pFact )
                     {
-                        ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetActiveWindow(), mpDrawView, GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) ));
+                        ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetActiveWindow(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) ));
                         if( pDlg )
                         {
                             pDlg->Execute();
@@ -2991,7 +2991,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
             if( rReq.GetArgs() )
             {
-                SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+                SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
                 if( rReq.GetSlot() == SID_STYLE_APPLY )
                     GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
                 Cancel();
@@ -3090,7 +3090,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_EXTRUSION_LIGHTING_FLOATER:
         case SID_EXTRUSION_SURFACE_FLOATER:
         case SID_EXTRUSION_DEPTH_DIALOG:
-            svx::ExtrusionBar::execute( mpDrawView, rReq, GetViewFrame()->GetBindings() );
+            svx::ExtrusionBar::execute( mpDrawView.get(), rReq, GetViewFrame()->GetBindings() );
             Cancel();
             rReq.Ignore ();
             break;
@@ -3105,7 +3105,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
         case SID_FONTWORK_ALIGNMENT_FLOATER:
         case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
-            svx::FontworkBar::execute( mpDrawView, rReq, GetViewFrame()->GetBindings() );
+            svx::FontworkBar::execute( mpDrawView.get(), rReq, GetViewFrame()->GetBindings() );
             Cancel();
             rReq.Ignore ();
             break;
@@ -3211,7 +3211,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_PRESENTATION_DLG:
         {
-            SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
@@ -3232,14 +3232,14 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_CUSTOMSHOW_DLG:
         {
-            SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
 
         case SID_EXPAND_PAGE:
         {
-            SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
@@ -3247,7 +3247,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         case SID_SUMMARY_PAGE:
         {
             mpDrawView->SdrEndTextEdit();
-            SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             Cancel();
         }
         break;
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 1e18528eadda..b416561ae130 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1679,8 +1679,8 @@ void DrawViewShell::GetModeSwitchingMenuState (SfxItemSet &rSet)
         rSet.DisableItem( SID_NOTES_MASTER_MODE );
     }
 
-    svx::ExtrusionBar::getState( mpDrawView, rSet );
-    svx::FontworkBar::getState( mpDrawView, rSet );
+    svx::ExtrusionBar::getState( mpDrawView.get(), rSet );
+    svx::FontworkBar::getState( mpDrawView.get(), rSet );
 }
 
 void DrawViewShell::GetPageProperties( SfxItemSet &rSet )
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
index d92d1b9eb0fe..f4dc01c89a82 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -183,10 +183,10 @@ DrawViewShell::~DrawViewShell()
         mxClipEvtLstnr.clear();
     }
 
-    delete mpDrawView;
+    mpDrawView.reset();
     // Set mpView to NULL so that the destructor of the ViewShell base class
     // does not access it.
-    mpView = mpDrawView = nullptr;
+    mpView = nullptr;
 
     mpFrameView->Disconnect();
     maTabControl.disposeAndClear();
@@ -212,8 +212,8 @@ void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
 
     GetDoc()->CreateFirstPages();
 
-    mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
-    mpView = mpDrawView;             // Pointer of base class ViewShell
+    mpDrawView.reset( new DrawView(pDocSh, GetActiveWindow(), this) );
+    mpView = mpDrawView.get();             // Pointer of base class ViewShell
     mpDrawView->SetSwapAsynchron(); // Asynchronous load of graphics
 
     // We do not read the page kind from the frame view anymore so we have
@@ -777,7 +777,7 @@ OUString const & DrawViewShell::GetSidebarContextName() const
 
 void DrawViewShell::ExecGoToNextPage (SfxRequest& rReq)
 {
-    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
     Cancel();
 }
 
@@ -792,7 +792,7 @@ void DrawViewShell::GetStateGoToNextPage (SfxItemSet& rSet)
 
 void DrawViewShell::ExecGoToPreviousPage (SfxRequest& rReq)
 {
-    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
     Cancel();
 }
 
@@ -807,7 +807,7 @@ void DrawViewShell::GetStateGoToPreviousPage (SfxItemSet& rSet)
 
 void DrawViewShell::ExecGoToFirstPage (SfxRequest& rReq)
 {
-    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
     Cancel();
 }
 
@@ -821,7 +821,7 @@ void DrawViewShell::GetStateGoToFirstPage (SfxItemSet& rSet)
 
 void DrawViewShell::ExecGoToLastPage (SfxRequest& rReq)
 {
-    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+    SetCurrentFunction( FuNavigation::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
     Cancel();
 }
 
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 2c917163ace7..c3a63836559b 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -234,7 +234,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_TEXT_FITTOSIZE:
         case SID_TEXT_FITTOSIZE_VERTICAL:
         {
-            SetCurrentFunction( FuText::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+            SetCurrentFunction( FuText::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
             GetCurrentFunction()->DoExecute(rReq);
 
             SfxBindings& rBindings = GetViewFrame()->GetBindings();
@@ -253,7 +253,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
 
         case SID_FM_CREATE_CONTROL:
         {
-            SetCurrentFunction( FuConstructUnoControl::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+            SetCurrentFunction( FuConstructUnoControl::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) );
             rReq.Done();
         }
         break;
@@ -266,7 +266,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
             if(pDescriptorItem)
             {
                 // get the form view
-                FmFormView* pFormView = dynamic_cast<FmFormView*>( mpDrawView );
+                FmFormView* pFormView = dynamic_cast<FmFormView*>( mpDrawView.get() );
                 SdrPageView* pPageView = pFormView ? pFormView->GetSdrPageView() : nullptr;
 
                 if(pPageView)
@@ -389,7 +389,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
                 }
             }
 
-            SetCurrentFunction( FuSelection::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+            SetCurrentFunction( FuSelection::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
             rReq.Done();
             Invalidate( SID_OBJECT_SELECT );
         }
@@ -449,7 +449,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_CONNECTOR_LINES_CIRCLE_END:
         case SID_CONNECTOR_LINES_CIRCLES:
         {
-            SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+            SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) );
             rReq.Done();
         }
         break;
@@ -462,7 +462,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_DRAW_BEZIER_FILL:          // BASIC
         case SID_DRAW_BEZIER_NOFILL:        // BASIC
         {
-            SetCurrentFunction( FuConstructBezierPolygon::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent) );
+            SetCurrentFunction( FuConstructBezierPolygon::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent) );
             rReq.Done();
         }
         break;
@@ -471,7 +471,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         {
             if (nOldSId != SID_GLUE_EDITMODE)
             {
-                SetCurrentFunction( FuEditGluePoints::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+                SetCurrentFunction( FuEditGluePoints::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) );
             }
             else
             {
@@ -493,7 +493,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_DRAW_CIRCLECUT:
         case SID_DRAW_CIRCLECUT_NOFILL:
         {
-            SetCurrentFunction( FuConstructArc::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent) );
+            SetCurrentFunction( FuConstructArc::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent) );
             rReq.Done();
         }
         break;
@@ -507,7 +507,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_3D_CONE:
         case SID_3D_PYRAMID:
         {
-            SetCurrentFunction( FuConstruct3dObject::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+            SetCurrentFunction( FuConstruct3dObject::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) );
             rReq.Done();
         }
         break;
@@ -520,7 +520,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_DRAWTBX_CS_STAR :
         case SID_DRAW_CS_ID :
         {
-            SetCurrentFunction( FuConstructCustomShape::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+            SetCurrentFunction( FuConstructCustomShape::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, bPermanent ) );
             rReq.Done();
 
             if ( nSId != SID_DRAW_CS_ID )
@@ -534,7 +534,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
 
         case SID_FORMATPAINTBRUSH:
         {
-            SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             rReq.Done();
             SfxBindings& rBind = GetViewFrame()->GetBindings();
             rBind.Invalidate( nSId );
@@ -546,7 +546,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
         case SID_ZOOM_PANNING:
         {
             mbZoomOnPage = false;
-            SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+            SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
             rReq.Done();
         }
         break;
commit b9ada4bc6f2de5cd67af460d51af16075cb2894b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Mar 19 14:55:42 2018 +0200

    loplugin:useuniqueptr in PresenterTextView::Implementation
    
    Change-Id: Ie5641d3a4b0791aa4ae4f126afeb3ec6f9760909
    Reviewed-on: https://gerrit.libreoffice.org/51661
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx
index 6d8ba55d7927..42406d994f55 100644
--- a/sd/source/ui/presenter/PresenterTextView.cxx
+++ b/sd/source/ui/presenter/PresenterTextView.cxx
@@ -83,7 +83,7 @@ private:
     Reference<rendering::XBitmap> mxBitmap;
     cppcanvas::CanvasSharedPtr mpCanvas;
     VclPtr<VirtualDevice> mpOutputDevice;
-    EditEngine* mpEditEngine;
+    std::unique_ptr<EditEngine> mpEditEngine;
     SfxItemPool* mpEditEngineItemPool;
     Size maSize;
     Color maBackgroundColor;
@@ -92,7 +92,6 @@ private:
     sal_Int32 mnTop;
     sal_Int32 mnTotalHeight;
 
-    EditEngine* CreateEditEngine();
     void CheckTop();
 };
 
@@ -242,85 +241,72 @@ PresenterTextView::Implementation::Implementation()
 {
     mpOutputDevice->SetMapMode(MapMode(MapUnit::MapPixel));
 
-    mpEditEngine = CreateEditEngine ();
+    // set fonts to be used
+    SvtLinguOptions aOpt;
+    SvtLinguConfig().GetOptions( aOpt );
+
+    struct FontDta {
+        LanguageType    nFallbackLang;
+        LanguageType    nLang;
+        DefaultFontType nFontType;
+        sal_uInt16      nFontInfoId;
+        } aTable[3] =
+    {
+        // info to get western font to be used
+        {   LANGUAGE_ENGLISH_US,    LANGUAGE_NONE,
+            DefaultFontType::SERIF,      EE_CHAR_FONTINFO },
+        // info to get CJK font to be used
+        {   LANGUAGE_JAPANESE,      LANGUAGE_NONE,
+            DefaultFontType::CJK_TEXT,   EE_CHAR_FONTINFO_CJK },
+        // info to get CTL font to be used
+        {   LANGUAGE_ARABIC_SAUDI_ARABIA,  LANGUAGE_NONE,
+            DefaultFontType::CTL_TEXT,   EE_CHAR_FONTINFO_CTL }
+    };
+    aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN);
+    aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN);
+    aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX);
+
+    for (FontDta & rFntDta : aTable)
+    {
+        LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
+            rFntDta.nFallbackLang : rFntDta.nLang;
+        vcl::Font aFont = OutputDevice::GetDefaultFont(
+            rFntDta.nFontType, nLang, GetDefaultFontFlags::OnlyOne);
+        mpEditEngineItemPool->SetPoolDefaultItem(
+            SvxFontItem(
+                aFont.GetFamilyType(),
+                aFont.GetFamilyName(),
+                aFont.GetStyleName(),
+                aFont.GetPitch(),
+                aFont.GetCharSet(),
+                rFntDta.nFontInfoId));
+    }
+
+    mpEditEngine.reset( new EditEngine (mpEditEngineItemPool) );
+
+    mpEditEngine->EnableUndo (true);
+    mpEditEngine->SetDefTab (sal_uInt16(
+        Application::GetDefaultDevice()->GetTextWidth("XXXX")));
+
+    mpEditEngine->SetControlWord(
+            EEControlBits(mpEditEngine->GetControlWord() | EEControlBits::AUTOINDENTING) &
+            EEControlBits(~EEControlBits::UNDOATTRIBS) &
+            EEControlBits(~EEControlBits::PASTESPECIAL) );
+
+    mpEditEngine->SetWordDelimiters (" .=+-*/(){}[];\"");
+    mpEditEngine->SetRefMapMode(MapMode(MapUnit::MapPixel));
+    mpEditEngine->SetPaperSize (Size(800, 0));
+    mpEditEngine->EraseVirtualDevice();
+    mpEditEngine->ClearModifyFlag();
 }
 
 PresenterTextView::Implementation::~Implementation()
 {
-    delete mpEditEngine;
+    mpEditEngine.reset();
     SfxItemPool::Free(mpEditEngineItemPool);
     mpOutputDevice.disposeAndClear();
 }
 
-EditEngine* PresenterTextView::Implementation::CreateEditEngine()
-{
-    EditEngine* pEditEngine = mpEditEngine;
-    if (pEditEngine == nullptr)
-    {
-
-        // set fonts to be used
-
-        SvtLinguOptions aOpt;
-        SvtLinguConfig().GetOptions( aOpt );
-
-        struct FontDta {
-            LanguageType    nFallbackLang;
-            LanguageType    nLang;
-            DefaultFontType nFontType;
-            sal_uInt16      nFontInfoId;
-            } aTable[3] =
-        {
-            // info to get western font to be used
-            {   LANGUAGE_ENGLISH_US,    LANGUAGE_NONE,
-                DefaultFontType::SERIF,      EE_CHAR_FONTINFO },
-            // info to get CJK font to be used
-            {   LANGUAGE_JAPANESE,      LANGUAGE_NONE,
-                DefaultFontType::CJK_TEXT,   EE_CHAR_FONTINFO_CJK },
-            // info to get CTL font to be used
-            {   LANGUAGE_ARABIC_SAUDI_ARABIA,  LANGUAGE_NONE,
-                DefaultFontType::CTL_TEXT,   EE_CHAR_FONTINFO_CTL }
-        };
-        aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN);
-        aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN);
-        aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX);
-
-        for (FontDta & rFntDta : aTable)
-        {
-            LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
-                rFntDta.nFallbackLang : rFntDta.nLang;
-            vcl::Font aFont = OutputDevice::GetDefaultFont(
-                rFntDta.nFontType, nLang, GetDefaultFontFlags::OnlyOne);
-            mpEditEngineItemPool->SetPoolDefaultItem(
-                SvxFontItem(
-                    aFont.GetFamilyType(),
-                    aFont.GetFamilyName(),
-                    aFont.GetStyleName(),
-                    aFont.GetPitch(),
-                    aFont.GetCharSet(),
-                    rFntDta.nFontInfoId));
-        }
-
-        pEditEngine = new EditEngine (mpEditEngineItemPool);
-
-        pEditEngine->EnableUndo (true);
-        pEditEngine->SetDefTab (sal_uInt16(
-            Application::GetDefaultDevice()->GetTextWidth("XXXX")));
-
-        pEditEngine->SetControlWord(
-                EEControlBits(pEditEngine->GetControlWord() | EEControlBits::AUTOINDENTING) &
-                EEControlBits(~EEControlBits::UNDOATTRIBS) &
-                EEControlBits(~EEControlBits::PASTESPECIAL) );
-
-        pEditEngine->SetWordDelimiters (" .=+-*/(){}[];\"");
-        pEditEngine->SetRefMapMode(MapMode(MapUnit::MapPixel));
-        pEditEngine->SetPaperSize (Size(800, 0));
-        pEditEngine->EraseVirtualDevice();
-        pEditEngine->ClearModifyFlag();
-    }
-
-    return pEditEngine;
-}
-
 void PresenterTextView::Implementation::SetCanvas (const cppcanvas::CanvasSharedPtr& rpCanvas)
 {
     mpCanvas = rpCanvas;


More information about the Libreoffice-commits mailing list