sc/source/ui/docshell/docsh5.cxx | 4 ++-- sc/source/ui/inc/undotab.hxx | 28 ++++++++++++++-------------- sc/source/ui/undo/undotab.cxx | 34 +++++++++++++++------------------- sc/source/ui/view/viewfun2.cxx | 4 ++-- 4 files changed, 33 insertions(+), 37 deletions(-)
New commits: commit 1f969657a64abc14cb8d1a5428a4da519d7cf6d8 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Oct 5 11:06:43 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Oct 6 12:33:17 2018 +0200 use more std::unique_ptr in ScUndoMoveTab and ScUndoCopyTab Change-Id: Id69d87369d2a73b00e4ed6159047eef3135722e1 Reviewed-on: https://gerrit.libreoffice.org/61432 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 58a9ead66043..79710f264618 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -937,7 +937,7 @@ bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRec unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab)); unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab)); GetUndoManager()->AddUndoAction( - new ScUndoCopyTab(this, pSrcList.release(), pDestList.release())); + new ScUndoCopyTab(this, std::move(pSrcList), std::move(pDestList))); } bool bVbaEnabled = m_aDocument.IsInVBAMode(); @@ -1004,7 +1004,7 @@ bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRec unique_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab)); unique_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab)); GetUndoManager()->AddUndoAction( - new ScUndoMoveTab(this, pSrcList.release(), pDestList.release())); + new ScUndoMoveTab(this, std::move(pSrcList), std::move(pDestList))); } Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) ); diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx index 468e70d84c1d..31866fb6a9cc 100644 --- a/sc/source/ui/inc/undotab.hxx +++ b/sc/source/ui/inc/undotab.hxx @@ -146,10 +146,10 @@ class ScUndoMoveTab: public ScSimpleUndo public: ScUndoMoveTab( ScDocShell* pNewDocShell, - ::std::vector<SCTAB>* pOldTabs, - ::std::vector<SCTAB>* pNewTabs, - ::std::vector< OUString>* pOldNames = nullptr, - ::std::vector< OUString>* pNewNames = nullptr ); + std::unique_ptr<std::vector<SCTAB>> pOldTabs, + std::unique_ptr<std::vector<SCTAB>> pNewTabs, + std::unique_ptr<std::vector< OUString>> pOldNames = nullptr, + std::unique_ptr<std::vector< OUString>> pNewNames = nullptr ); virtual ~ScUndoMoveTab() override; @@ -161,10 +161,10 @@ public: virtual OUString GetComment() const override; private: - std::shared_ptr< ::std::vector<SCTAB> > mpOldTabs; - std::shared_ptr< ::std::vector<SCTAB> > mpNewTabs; - std::shared_ptr< ::std::vector< OUString> > mpOldNames; - std::shared_ptr< ::std::vector< OUString> > mpNewNames; + std::unique_ptr< ::std::vector<SCTAB> > mpOldTabs; + std::unique_ptr< ::std::vector<SCTAB> > mpNewTabs; + std::unique_ptr< ::std::vector< OUString> > mpOldNames; + std::unique_ptr< ::std::vector< OUString> > mpNewNames; void DoChange( bool bUndo ) const; }; @@ -174,9 +174,9 @@ class ScUndoCopyTab: public ScSimpleUndo public: ScUndoCopyTab( ScDocShell* pNewDocShell, - ::std::vector<SCTAB>* pOldTabs, - ::std::vector<SCTAB>* pNewTabs, - ::std::vector< OUString>* pNewNames = nullptr ); + std::unique_ptr<std::vector<SCTAB>> pOldTabs, + std::unique_ptr<std::vector<SCTAB>> pNewTabs, + std::unique_ptr<std::vector< OUString>> pNewNames = nullptr ); virtual ~ScUndoCopyTab() override; @@ -188,9 +188,9 @@ public: virtual OUString GetComment() const override; private: - std::shared_ptr< ::std::vector<SCTAB> > mpOldTabs; - std::shared_ptr< ::std::vector<SCTAB> > mpNewTabs; - std::shared_ptr< ::std::vector< OUString> > mpNewNames; + std::unique_ptr< ::std::vector<SCTAB> > mpOldTabs; + std::unique_ptr< ::std::vector<SCTAB> > mpNewTabs; + std::unique_ptr< ::std::vector< OUString> > mpNewNames; std::unique_ptr<SdrUndoAction> pDrawUndo; void DoChange() const; diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 0cef12f8bd5e..aff057b84354 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -462,19 +462,16 @@ bool ScUndoRenameTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const } ScUndoMoveTab::ScUndoMoveTab( - ScDocShell* pNewDocShell, vector<SCTAB>* pOldTabs, vector<SCTAB>* pNewTabs, - vector<OUString>* pOldNames, vector<OUString>* pNewNames) : + ScDocShell* pNewDocShell, std::unique_ptr<vector<SCTAB>> pOldTabs, std::unique_ptr<vector<SCTAB>> pNewTabs, + std::unique_ptr<vector<OUString>> pOldNames, std::unique_ptr<vector<OUString>> pNewNames) : ScSimpleUndo( pNewDocShell ), - mpOldTabs(pOldTabs), mpNewTabs(pNewTabs), - mpOldNames(pOldNames), mpNewNames(pNewNames) + mpOldTabs(std::move(pOldTabs)), mpNewTabs(std::move(pNewTabs)), + mpOldNames(std::move(pOldNames)), mpNewNames(std::move(pNewNames)) { - if (mpOldNames && mpOldTabs->size() != mpOldNames->size()) - // The sizes differ. Something is wrong. - mpOldNames.reset(); - - if (mpNewNames && mpNewTabs->size() != mpNewNames->size()) - // The sizes differ. Something is wrong. - mpNewNames.reset(); + // The sizes differ. Something is wrong. + assert(!mpOldNames || mpOldTabs->size() == mpOldNames->size()); + // The sizes differ. Something is wrong. + assert(!mpNewNames || mpNewTabs->size() == mpNewNames->size()); } ScUndoMoveTab::~ScUndoMoveTab() @@ -566,18 +563,17 @@ bool ScUndoMoveTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const ScUndoCopyTab::ScUndoCopyTab( ScDocShell* pNewDocShell, - vector<SCTAB>* pOldTabs, vector<SCTAB>* pNewTabs, - vector<OUString>* pNewNames) : + std::unique_ptr<vector<SCTAB>> pOldTabs, std::unique_ptr<vector<SCTAB>> pNewTabs, + std::unique_ptr<vector<OUString>> pNewNames) : ScSimpleUndo( pNewDocShell ), - mpOldTabs(pOldTabs), - mpNewTabs(pNewTabs), - mpNewNames(pNewNames) + mpOldTabs(std::move(pOldTabs)), + mpNewTabs(std::move(pNewTabs)), + mpNewNames(std::move(pNewNames)) { pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ); - if (mpNewNames && mpNewTabs->size() != mpNewNames->size()) - // The sizes differ. Something is wrong. - mpNewNames.reset(); + // The sizes differ. Something is wrong. + assert(!mpNewNames || mpNewTabs->size() == mpNewNames->size()); } ScUndoCopyTab::~ScUndoCopyTab() diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index d4ffd0644c23..38533736a681 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -2966,13 +2966,13 @@ void ScViewFunc::MoveTable( { pDocShell->GetUndoManager()->AddUndoAction( new ScUndoCopyTab( - pDocShell, pSrcTabs.release(), pDestTabs.release(), pDestNames.release())); + pDocShell, std::move(pSrcTabs), std::move(pDestTabs), std::move(pDestNames))); } else { pDocShell->GetUndoManager()->AddUndoAction( new ScUndoMoveTab( - pDocShell, pSrcTabs.release(), pDestTabs.release(), pTabNames.release(), pDestNames.release())); + pDocShell, std::move(pSrcTabs), std::move(pDestTabs), std::move(pTabNames), std::move(pDestNames))); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits