Kaydet (Commit) 1f969657 authored tarafından Noel Grandin's avatar Noel Grandin

use more std::unique_ptr in ScUndoMoveTab and ScUndoCopyTab

Change-Id: Id69d87369d2a73b00e4ed6159047eef3135722e1
Reviewed-on: https://gerrit.libreoffice.org/61432
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 54d82085
......@@ -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 ) );
......
......@@ -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;
......
......@@ -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()
......
......@@ -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)));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment