From effa6dcb553bd3fc6df89ac88604816feda98873 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sat, 8 Apr 2017 19:57:04 +0200 Subject: support undo of whole conditional format list, tdf#95617 Change-Id: I3ff0ddb05f794064e33164c60cd1b4e6b89dbcca Reviewed-on: https://gerrit.libreoffice.org/36295 Tested-by: Jenkins Reviewed-by: Markus Mohrhard --- sc/source/ui/undo/undoblk.cxx | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'sc/source/ui/undo') diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 217022845109..dccc583e1317 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1535,6 +1535,66 @@ bool ScUndoConditionalFormat::CanRepeat(SfxRepeatTarget& ) const return false; } +ScUndoConditionalFormatList::ScUndoConditionalFormatList(ScDocShell* pNewDocShell, + ScDocument* pUndoDoc, ScDocument* pRedoDoc, SCTAB nTab): + ScSimpleUndo( pNewDocShell ), + mpUndoDoc(pUndoDoc), + mpRedoDoc(pRedoDoc), + mnTab(nTab) +{ +} + +ScUndoConditionalFormatList::~ScUndoConditionalFormatList() +{ +} + +OUString ScUndoConditionalFormatList::GetComment() const +{ + return ScGlobal::GetRscString( STR_UNDO_CONDFORMAT_LIST ); +} + +void ScUndoConditionalFormatList::Undo() +{ + DoChange(mpUndoDoc.get()); +} + +void ScUndoConditionalFormatList::Redo() +{ + DoChange(mpRedoDoc.get()); +} + +void ScUndoConditionalFormatList::DoChange(ScDocument* pSrcDoc) +{ + ScDocument& rDoc = pDocShell->GetDocument(); + + if (pSrcDoc == mpUndoDoc.get()) + { + mpRedoDoc->GetCondFormList(mnTab)->RemoveFromDocument(&rDoc); + mpUndoDoc->GetCondFormList(mnTab)->AddToDocument(&rDoc); + } + else + { + mpUndoDoc->GetCondFormList(mnTab)->RemoveFromDocument(&rDoc); + mpRedoDoc->GetCondFormList(mnTab)->AddToDocument(&rDoc); + } + rDoc.SetCondFormList(new ScConditionalFormatList(&rDoc, *pSrcDoc->GetCondFormList(mnTab)), mnTab); + + pDocShell->PostPaintGridAll(); + pDocShell->PostDataChanged(); + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->CellContentChanged(); +} + +void ScUndoConditionalFormatList::Repeat(SfxRepeatTarget& ) +{ +} + +bool ScUndoConditionalFormatList::CanRepeat(SfxRepeatTarget& ) const +{ + return false; +} + ScUndoUseScenario::ScUndoUseScenario( ScDocShell* pNewDocShell, const ScMarkData& rMark, /*C*/ const ScArea& rDestArea, -- cgit