summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2025-01-22 15:08:29 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2025-01-22 13:11:47 +0100
commit7a51400b327b94929ff51035196253341ccf9036 (patch)
tree10fb11fbf1631e7b4e55dd8c1a8d49e942a57670
parent99e09f215d694b455c7b911cc2b2dc38ee0a7a2e (diff)
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.kaganski@collabora.com>
-rw-r--r--sc/source/ui/undo/undoblk.cxx15
1 files changed, 5 insertions, 10 deletions
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
{