[Libreoffice-commits] core.git: sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 17 06:41:01 UTC 2018


 sc/inc/scabstdlg.hxx                      |    2 +-
 sc/source/ui/attrdlg/scdlgfact.cxx        |    2 +-
 sc/source/ui/attrdlg/scdlgfact.hxx        |    2 +-
 sc/source/ui/condformat/condformatmgr.cxx |   10 ++++------
 sc/source/ui/inc/condformatmgr.hxx        |    4 ++--
 sc/source/ui/view/cellsh1.cxx             |   10 +++++-----
 6 files changed, 14 insertions(+), 16 deletions(-)

New commits:
commit db20ca1171475967e60e416df09a12ec565e2d8b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jul 16 17:07:23 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 17 08:40:38 2018 +0200

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

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 4019eae3792b..d6c7e0deda94 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -87,7 +87,7 @@ class AbstractScCondFormatManagerDlg : public VclAbstractDialog
 protected:
     virtual             ~AbstractScCondFormatManagerDlg() override = default;
 public:
-    virtual ScConditionalFormatList* GetConditionalFormatList() = 0;
+    virtual std::unique_ptr<ScConditionalFormatList> GetConditionalFormatList() = 0;
 
     virtual bool CondFormatsChanged() const = 0;
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 9f7bb7190d62..a511594f2126 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -503,7 +503,7 @@ sal_uLong AbstractScLinkedAreaDlg_Impl::GetRefresh()
     return m_xDlg->GetRefresh();
 }
 
-ScConditionalFormatList* AbstractScCondFormatManagerDlg_Impl::GetConditionalFormatList()
+std::unique_ptr<ScConditionalFormatList> AbstractScCondFormatManagerDlg_Impl::GetConditionalFormatList()
 {
     return pDlg->GetConditionalFormatList();
 }
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index dd56b7f9a712..ec1f62d35f9f 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -131,7 +131,7 @@ class AbstractScCondFormatManagerDlg_Impl : public AbstractScCondFormatManagerDl
 {
     DECL_ABSTDLG_BASE(AbstractScCondFormatManagerDlg_Impl, ScCondFormatManagerDlg)
 
-    virtual ScConditionalFormatList* GetConditionalFormatList() override;
+    virtual std::unique_ptr<ScConditionalFormatList> GetConditionalFormatList() override;
 
     virtual bool CondFormatsChanged() const override;
 
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 75c5e77ef8e0..45d169b0e22e 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -110,7 +110,7 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(vcl::Window* pParent, ScDocument*
     Size aSize(LogicToPixel(Size(290, 220), MapMode(MapUnit::MapAppFont)));
     pContainer->set_width_request(aSize.Width());
     pContainer->set_height_request(aSize.Height());
-    m_pCtrlManager = VclPtr<ScCondFormatManagerWindow>::Create(*pContainer, pDoc, mpFormatList);
+    m_pCtrlManager = VclPtr<ScCondFormatManagerWindow>::Create(*pContainer, pDoc, mpFormatList.get());
     get(m_pBtnAdd, "add");
     get(m_pBtnRemove, "remove");
     get(m_pBtnEdit, "edit");
@@ -128,7 +128,7 @@ ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
 
 void ScCondFormatManagerDlg::dispose()
 {
-    delete mpFormatList;
+    mpFormatList.reset();
     m_pBtnAdd.clear();
     m_pBtnRemove.clear();
     m_pBtnEdit.clear();
@@ -137,11 +137,9 @@ void ScCondFormatManagerDlg::dispose()
 }
 
 
-ScConditionalFormatList* ScCondFormatManagerDlg::GetConditionalFormatList()
+std::unique_ptr<ScConditionalFormatList> ScCondFormatManagerDlg::GetConditionalFormatList()
 {
-    ScConditionalFormatList* pList = mpFormatList;
-    mpFormatList = nullptr;
-    return pList;
+    return std::move(mpFormatList);
 }
 
 // Get the current conditional format selected.
diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx
index 8fd579a87809..369bfb679f5f 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -51,7 +51,7 @@ public:
     virtual ~ScCondFormatManagerDlg() override;
     virtual void dispose() override;
 
-    ScConditionalFormatList* GetConditionalFormatList();
+    std::unique_ptr<ScConditionalFormatList> GetConditionalFormatList();
 
     bool CondFormatsChanged() const;
     void SetModified();
@@ -62,7 +62,7 @@ private:
     VclPtr<PushButton> m_pBtnAdd;
     VclPtr<PushButton> m_pBtnRemove;
     VclPtr<PushButton> m_pBtnEdit;
-    ScConditionalFormatList* mpFormatList;
+    std::unique_ptr<ScConditionalFormatList> mpFormatList;
     VclPtr<ScCondFormatManagerWindow> m_pCtrlManager;
 
     DECL_LINK(RemoveBtnHdl, Button*, void);
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 400a0273c9dd..7722f9ca1c1b 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2526,17 +2526,17 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     pDlg->SetModified();
 
                 short nRet = pDlg->Execute();
-                ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
+                std::unique_ptr<ScConditionalFormatList> pCondFormatList = pDlg->GetConditionalFormatList();
                 if(nRet == RET_OK && pDlg->CondFormatsChanged())
                 {
-                    pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
+                    pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList.release(), aPos.Tab());
                 }
                 else if(nRet == DLG_RET_ADD)
                 {
                     // Put the xml string parameter to initialize the
                     // Conditional Format Dialog. ( add new )
                     pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
-                                std::shared_ptr<ScConditionalFormatList>(pCondFormatList), -1, true));
+                                std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), -1, true));
                     // Queue message to open Conditional Format Dialog
                     GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
                 }
@@ -2547,13 +2547,13 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                     // Put the xml string parameter to initialize the
                     // Conditional Format Dialog. ( edit selected conditional format )
                     pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
-                                std::shared_ptr<ScConditionalFormatList>(pCondFormatList), nIndex, true));
+                                std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true));
 
                     // Queue message to open Conditional Format Dialog
                     GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
                 }
                 else
-                    delete pCondFormatList;
+                    pCondFormatList.reset();
 
                 if (pDlgItem)
                     pTabViewShell->GetPool().Remove(*pDlgItem);


More information about the Libreoffice-commits mailing list