[Libreoffice-commits] core.git: sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jun 28 06:33:56 UTC 2018
sc/source/ui/inc/navipi.hxx | 6 ++++--
sc/source/ui/navipi/navipi.cxx | 31 +++++++++++--------------------
2 files changed, 15 insertions(+), 22 deletions(-)
New commits:
commit c25db26f4c2163c8fb8824ecf291dd39d7252d66
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jun 27 14:03:29 2018 +0200
loplugin:useuniqueptr in ScNavigatorDlg
Change-Id: I27ef6e27c8eef01a5de0f117ee03364ca545b27a
Reviewed-on: https://gerrit.libreoffice.org/56560
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx
index 98a8b48aaa89..c2f28289d6fd 100644
--- a/sc/source/ui/inc/navipi.hxx
+++ b/sc/source/ui/inc/navipi.hxx
@@ -173,6 +173,8 @@ friend class RowEdit;
friend class ScContentTree;
private:
+ static constexpr int CTRL_ITEMS = 4;
+
SfxBindings& rBindings; // must be first member
VclPtr<ColumnEdit> aEdCol;
@@ -201,7 +203,7 @@ private:
sal_uInt16 nDownId;
sal_uInt16 nUpId;
sal_uInt16 nDataId;
- ScArea* pMarkArea;
+ std::unique_ptr<ScArea> pMarkArea;
ScViewData* pViewData;
NavListMode eListMode;
@@ -210,7 +212,7 @@ private:
SCROW nCurRow;
SCTAB nCurTab;
- ScNavigatorControllerItem** ppBoundItems;
+ std::array<std::unique_ptr<ScNavigatorControllerItem>,CTRL_ITEMS> mvBoundItems;
DECL_LINK(TimeHdl, Timer*, void);
DECL_LINK(DocumentSelectHdl, ListBox&, void);
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index ce8090ea4fc4..39e72d477e0b 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -452,11 +452,6 @@ ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(vcl::Window* pParent,
SetWindow(pNavigator);
}
-#define CTRL_ITEMS 4
-
-#define REGISTER_SLOT(i,id) \
- ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
-
ScNavigatorDlg::ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent)
: PanelLayout(pParent, "NavigatorPanel", "modules/scalc/ui/navigatorpanel.ui", nullptr)
, rBindings(*pB)
@@ -510,14 +505,12 @@ ScNavigatorDlg::ScNavigatorDlg(SfxBindings* pB, vcl::Window* pParent)
aStrNotActive = " (" + ScResId(SCSTR_NOTACTIVE) + ")"; // " (not active)"
aStrHidden = " (" + ScResId(SCSTR_HIDDEN) + ")"; // " (hidden)"
- ppBoundItems = new ScNavigatorControllerItem* [CTRL_ITEMS];
-
rBindings.ENTERREGISTRATIONS();
- REGISTER_SLOT( 0, SID_CURRENTCELL );
- REGISTER_SLOT( 1, SID_CURRENTTAB );
- REGISTER_SLOT( 2, SID_CURRENTDOC );
- REGISTER_SLOT( 3, SID_SELECT_SCENARIO );
+ mvBoundItems[0].reset(new ScNavigatorControllerItem(SID_CURRENTCELL,*this,rBindings));
+ mvBoundItems[1].reset(new ScNavigatorControllerItem(SID_CURRENTTAB,*this,rBindings));
+ mvBoundItems[2].reset(new ScNavigatorControllerItem(SID_CURRENTDOC,*this,rBindings));
+ mvBoundItems[3].reset(new ScNavigatorControllerItem(SID_SELECT_SCENARIO,*this,rBindings));
rBindings.LEAVEREGISTRATIONS();
@@ -585,11 +578,9 @@ void ScNavigatorDlg::dispose()
{
aContentIdle.Stop();
- for (sal_uInt16 i = 0; i < CTRL_ITEMS; ++i)
- delete ppBoundItems[i];
-
- delete [] ppBoundItems;
- delete pMarkArea;
+ for (auto & p : mvBoundItems)
+ p.reset();
+ pMarkArea.reset();
EndListening( *(SfxGetpApp()) );
EndListening( rBindings );
@@ -700,7 +691,7 @@ void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo )
{
// SID_CURRENTCELL == Item #0 clear cache, so it's possible
// setting the current cell even in combined areas
- ppBoundItems[0]->ClearCache();
+ mvBoundItems[0]->ClearCache();
ScAddress aScAddress( nColNo, nRowNo, 0 );
OUString aAddr(aScAddress.Format(ScRefFlags::ADDR_ABS));
@@ -720,7 +711,7 @@ void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo )
void ScNavigatorDlg::SetCurrentCellStr( const OUString& rName )
{
- ppBoundItems[0]->ClearCache();
+ mvBoundItems[0]->ClearCache();
SfxStringItem aNameItem( SID_CURRENTCELL, rName );
rBindings.GetDispatcher()->ExecuteList(SID_CURRENTCELL,
@@ -1019,7 +1010,7 @@ void ScNavigatorDlg::MarkDataArea()
if ( pViewSh )
{
if ( !pMarkArea )
- pMarkArea = new ScArea;
+ pMarkArea.reset( new ScArea );
pViewSh->MarkDataArea();
ScRange aMarkRange;
@@ -1039,7 +1030,7 @@ void ScNavigatorDlg::UnmarkDataArea()
if ( pViewSh )
{
pViewSh->Unmark();
- DELETEZ( pMarkArea );
+ pMarkArea.reset();
}
}
More information about the Libreoffice-commits
mailing list