sc/source/ui/undo/undoblk.cxx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
New commits: commit 6ce53c051454a5f3c675b8c6f7e78e590921c718 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Wed Jan 22 15:08:29 2025 +0500 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Thu Jan 23 21:49:55 2025 +0100 tdf#164785: make sure to not modify CF list in undo/redo Commit 21830c58f27977ca4a1dbacd2f41583c9f3ae775 added a call to CopyToDocument to CF undo/redo. But that could modify the CF list (calling its DeleteArea method, and tab's CopyConditionalFormat). This change prevents that by using document's AddCondFormatData instead of CopyToDocument. Change-Id: Ic59a6724b5cc70ef16ec1ef3b3e2674cb3cc83f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180570 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 7a51400b327b94929ff51035196253341ccf9036) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180586 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index fbe1d4557213..b70394179524 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1626,12 +1626,7 @@ ScDocumentUniquePtr ScUndoConditionalFormat::createUndoRedoData() ScDocumentUniquePtr pUndoRedoDoc(new ScDocument(SCDOCMODE_UNDO)); pUndoRedoDoc->InitUndo(rDoc, mnTab, mnTab); if (const auto* pList = rDoc.GetCondFormList(mnTab)) - { pUndoRedoDoc->SetCondFormList(new ScConditionalFormatList(*pUndoRedoDoc, *pList), mnTab); - // Save CF keys in cells' attributes - for (const auto& range : pList->GetCombinedRange()) - rDoc.CopyToDocument(range, InsertDeleteFlags::ATTRIB, false, *pUndoRedoDoc); - } return pUndoRedoDoc; } @@ -1668,14 +1663,14 @@ void ScUndoConditionalFormat::DoChange(ScDocument* pSrcDoc) if (const auto* pNewList = pSrcDoc->GetCondFormList(mnTab)) { - ScRangeList aCombinedRange2 = pNewList->GetCombinedRange(); - rDoc.SetCondFormList(new ScConditionalFormatList(rDoc, *pNewList), mnTab); - for (const auto& range : aCombinedRange2) + for (const auto& cond : *pNewList) { - aCombinedRange.Join(range); // Restore the CF keys to cell attributes - pSrcDoc->CopyToDocument(range, InsertDeleteFlags::ATTRIB, false, rDoc); + rDoc.AddCondFormatData(cond->GetRange(), mnTab, cond->GetKey()); + for (const auto& range : cond->GetRange()) + aCombinedRange.Join(range); } + rDoc.SetCondFormList(new ScConditionalFormatList(rDoc, *pNewList), mnTab); } else {