diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-08 23:21:17 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-08 23:25:37 -0400 |
commit | 9aa36a1ad39e37c372cc833a44fba450b8cc30cd (patch) | |
tree | 59298a1683dcf7bf32afd56da2b8aca31d4b0072 | |
parent | 7adef94b82f5c71da483f238d05df7800b8da38b (diff) |
Move this one to a common place too.
Change-Id: I7f4e007cfc861dc323b42be353c6ba11091e8fa1
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfuncutil.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/inc/docfuncutil.hxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 9 |
4 files changed, 29 insertions, 11 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 6de4d7a86e2d..c529527cd46b 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -637,11 +637,9 @@ bool ScDocFunc::DeleteContents( const ScMarkData& rMark, InsertDeleteFlags nFlag // add undo action after drawing undo is complete (objects and note captions) if( bRecord ) { - ScUndoDeleteContents* pUndo = - new ScUndoDeleteContents( - &rDocShell, aMultiMark, aExtendedRange, pUndoDoc, bMulti, nFlags, bDrawUndo); - rDocShell.GetUndoManager()->AddUndoAction(pUndo); - pUndo->SetDataSpans(pDataSpans); + sc::DocFuncUtil::addDeleteContentsUndo( + rDocShell.GetUndoManager(), &rDocShell, aMultiMark, aExtendedRange, + pUndoDoc, nFlags, pDataSpans, bMulti, bDrawUndo); } if (!AdjustRowHeight( aExtendedRange )) diff --git a/sc/source/ui/docshell/docfuncutil.cxx b/sc/source/ui/docshell/docfuncutil.cxx index 35f3fb2b35af..1adb1355d556 100644 --- a/sc/source/ui/docshell/docfuncutil.cxx +++ b/sc/source/ui/docshell/docfuncutil.cxx @@ -22,6 +22,7 @@ #include <markdata.hxx> #include <undobase.hxx> #include <global.hxx> +#include <undoblk.hxx> #include <memory> @@ -70,6 +71,20 @@ ScDocument* DocFuncUtil::createDeleteContentsUndoDoc( return pUndoDoc.release(); } +void DocFuncUtil::addDeleteContentsUndo( + svl::IUndoManager* pUndoMgr, ScDocShell* pDocSh, const ScMarkData& rMark, + const ScRange& rRange, ScDocument* pUndoDoc, InsertDeleteFlags nFlags, + const boost::shared_ptr<ScSimpleUndo::DataSpansType>& pSpans, + bool bMulti, bool bDrawUndo ) +{ + std::unique_ptr<ScUndoDeleteContents> pUndo( + new ScUndoDeleteContents( + pDocSh, rMark, rRange, pUndoDoc, bMulti, nFlags, bDrawUndo)); + pUndo->SetDataSpans(pSpans); + + pUndoMgr->AddUndoAction(pUndo.release()); +} + ScSimpleUndo::DataSpansType* DocFuncUtil::getNonEmptyCellSpans( const ScDocument& rDoc, const ScMarkData& rMark, const ScRange& rRange ) { diff --git a/sc/source/ui/inc/docfuncutil.hxx b/sc/source/ui/inc/docfuncutil.hxx index 553bab684a96..65bf820526be 100644 --- a/sc/source/ui/inc/docfuncutil.hxx +++ b/sc/source/ui/inc/docfuncutil.hxx @@ -10,6 +10,8 @@ #include <undobase.hxx> +#include <boost/shared_ptr.hpp> + class ScDocument; class ScMarkData; class ScRange; @@ -27,6 +29,12 @@ public: ScDocument& rDoc, const ScMarkData& rMark, const ScRange& rRange, InsertDeleteFlags nFlags, bool bOnlyMarked ); + static void addDeleteContentsUndo( + svl::IUndoManager* pUndoMgr, ScDocShell* pDocSh, const ScMarkData& rMark, + const ScRange& rRange, ScDocument* pUndoDoc, InsertDeleteFlags nFlags, + const boost::shared_ptr<ScSimpleUndo::DataSpansType>& pSpans, + bool bMulti, bool bDrawUndo ); + static ScSimpleUndo::DataSpansType* getNonEmptyCellSpans( const ScDocument& rDoc, const ScMarkData& rMark, const ScRange& rRange ); }; diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index cb3db19165a8..f1ab1ebd8dba 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1850,12 +1850,9 @@ void ScViewFunc::DeleteContents( InsertDeleteFlags nFlags, bool bRecord ) if ( bRecord ) { - ScUndoDeleteContents* pUndo = - new ScUndoDeleteContents( - pDocSh, aFuncMark, aExtendedRange, pUndoDoc, bMulti, nFlags, bDrawUndo); - pUndo->SetDataSpans(pDataSpans); - - pDocSh->GetUndoManager()->AddUndoAction(pUndo); + sc::DocFuncUtil::addDeleteContentsUndo( + pDocSh->GetUndoManager(), pDocSh, aFuncMark, aExtendedRange, pUndoDoc, + nFlags, pDataSpans, bMulti, bDrawUndo); } if (!AdjustRowHeight( aExtendedRange.aStart.Row(), aExtendedRange.aEnd.Row() )) |