diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-23 12:47:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-27 08:21:33 +0200 |
commit | 26ebaae4f1e43d43646cf132379058b4b78065af (patch) | |
tree | 455d21361005cf1f60b990a0ff910dda6a4ef803 | |
parent | 449d416335802b23cf0f8f4725042f92138019cd (diff) |
loplugin:useuniqueptr in ScPrintSaverTab
Change-Id: I51ef59e97e9b46cf9496dbefaabcc15471e9cdae
Reviewed-on: https://gerrit.libreoffice.org/51902
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/inc/prnsave.hxx | 8 | ||||
-rw-r--r-- | sc/source/core/tool/prnsave.cxx | 16 |
2 files changed, 10 insertions, 14 deletions
diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx index 463a424451ad..f5137aefebd9 100644 --- a/sc/inc/prnsave.hxx +++ b/sc/inc/prnsave.hxx @@ -31,8 +31,8 @@ class ScPrintSaverTab typedef ::std::vector< ScRange > ScRangeVec; ScRangeVec maPrintRanges; ///< Array - ScRange* mpRepeatCol; ///< single - ScRange* mpRepeatRow; ///< single + std::unique_ptr<ScRange> mpRepeatCol; ///< single + std::unique_ptr<ScRange> mpRepeatRow; ///< single bool mbEntireSheet; public: @@ -44,8 +44,8 @@ public: const ScRangeVec& GetPrintRanges() const { return maPrintRanges; } bool IsEntireSheet() const { return mbEntireSheet; } - const ScRange* GetRepeatCol() const { return mpRepeatCol; } - const ScRange* GetRepeatRow() const { return mpRepeatRow; } + const ScRange* GetRepeatCol() const { return mpRepeatCol.get(); } + const ScRange* GetRepeatRow() const { return mpRepeatRow.get(); } bool operator==( const ScPrintSaverTab& rCmp ) const; }; diff --git a/sc/source/core/tool/prnsave.cxx b/sc/source/core/tool/prnsave.cxx index 223647db7cee..97b3ebe09101 100644 --- a/sc/source/core/tool/prnsave.cxx +++ b/sc/source/core/tool/prnsave.cxx @@ -26,16 +26,14 @@ // Data per table ScPrintSaverTab::ScPrintSaverTab() : - mpRepeatCol(nullptr), - mpRepeatRow(nullptr), mbEntireSheet(false) { } ScPrintSaverTab::~ScPrintSaverTab() { - delete mpRepeatCol; - delete mpRepeatRow; + mpRepeatCol.reset(); + mpRepeatRow.reset(); } void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, bool bEntireSheet ) @@ -46,10 +44,8 @@ void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, bool bEntireSheet ) void ScPrintSaverTab::SetRepeat( const ScRange* pCol, const ScRange* pRow ) { - delete mpRepeatCol; - mpRepeatCol = pCol ? new ScRange(*pCol) : nullptr; - delete mpRepeatRow; - mpRepeatRow = pRow ? new ScRange(*pRow) : nullptr; + mpRepeatCol.reset(pCol ? new ScRange(*pCol) : nullptr); + mpRepeatRow.reset(pRow ? new ScRange(*pRow) : nullptr); } inline bool PtrEqual( const ScRange* p1, const ScRange* p2 ) @@ -60,8 +56,8 @@ inline bool PtrEqual( const ScRange* p1, const ScRange* p2 ) bool ScPrintSaverTab::operator==( const ScPrintSaverTab& rCmp ) const { return - PtrEqual( mpRepeatCol, rCmp.mpRepeatCol ) && - PtrEqual( mpRepeatRow, rCmp.mpRepeatRow ) && + PtrEqual( mpRepeatCol.get(), rCmp.mpRepeatCol.get() ) && + PtrEqual( mpRepeatRow.get(), rCmp.mpRepeatRow.get() ) && (mbEntireSheet == rCmp.mbEntireSheet) && (maPrintRanges == rCmp.maPrintRanges); } |