diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:43:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:43:56 +0000 |
commit | 030eda2c4d6cad6d44c35499bcfc43ba89c88bb9 (patch) | |
tree | ed84eab0aa326f0af8421e20e99d57d62eab22e7 /sc/source/ui/undo | |
parent | Adding upstream version 4:24.2.1. (diff) | |
download | libreoffice-030eda2c4d6cad6d44c35499bcfc43ba89c88bb9.tar.xz libreoffice-030eda2c4d6cad6d44c35499bcfc43ba89c88bb9.zip |
Adding upstream version 4:24.2.2.upstream/4%24.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index d352ba143b..c74d23f6e7 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -1563,11 +1563,11 @@ bool ScUndoListNames::CanRepeat(SfxRepeatTarget& rTarget) const } ScUndoConditionalFormat::ScUndoConditionalFormat(ScDocShell* pNewDocShell, - ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const ScRange& rRange): + ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB nTab): ScSimpleUndo( pNewDocShell ), mpUndoDoc(std::move(pUndoDoc)), mpRedoDoc(std::move(pRedoDoc)), - maRange(rRange) + mnTab(nTab) { } @@ -1594,9 +1594,25 @@ void ScUndoConditionalFormat::DoChange(ScDocument* pSrcDoc) { ScDocument& rDoc = pDocShell->GetDocument(); - rDoc.DeleteAreaTab( maRange, InsertDeleteFlags::ALL ); - pSrcDoc->CopyToDocument(maRange, InsertDeleteFlags::ALL, false, rDoc); - pDocShell->PostPaint( maRange, PaintPartFlags::Grid ); + // Restore all conditional formats in the tab. This is simpler and more reliable, than + // restoring formats in a specific range, and then trying to join selectively the restored + // formats with the other formats in the tab, to get the correct state. + ScRangeList aCombinedRange; + if (const auto* pOldList = rDoc.GetCondFormList(mnTab)) + aCombinedRange = pOldList->GetCombinedRange(); + + if (const auto* pNewList = pSrcDoc->GetCondFormList(mnTab)) + { + for (const auto& cond : *pNewList) + for (const auto& range : cond->GetRange()) + aCombinedRange.Join(range); + rDoc.SetCondFormList(new ScConditionalFormatList(rDoc, *pNewList), mnTab); + } + else + { + rDoc.SetCondFormList(nullptr, mnTab); + } + pDocShell->PostPaint(aCombinedRange, PaintPartFlags::Grid); pDocShell->PostDataChanged(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) |