sc/inc/refupdatecontext.hxx | 2 ++ sc/source/core/data/conditio.cxx | 15 ++++++++++++--- sc/source/core/tool/token.cxx | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-)
New commits: commit 5653238332deac00affa4fa913354b3c8384dab9 Author: Matt K <matt...@gmail.com> AuthorDate: Mon Jan 1 11:44:35 2024 -0600 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jan 9 09:54:44 2024 +0100 tdf#73678 Prevent conditional formatting from being lost in Calc The problem is that when a Calc tab sheet is moved from one position to another, the ScConditionEntry aSrcPos member variable isn't updated, and therefore when deleting a blank sheet in front of a data sheet the deletion still thinks it's looking at the correct sheet but it is now out-of-date and as such the conditional formatting references are invalidated such that all math operations are tested against 0.0 instead of the actual formula value for the condtional formatting, which has the side effect of updating cells colors that should be uncolored as per the conditional formats set on them. The fix is to update this aSrcPos member variable of ScConditionEntry via the call to ScTokenArray::AdjustReferenceOnMovedTab from ScConditionEntry::UpdateMoveTab, which is called on tab sheet move. This way, the aSrcPos variable is up to date when ScConditionEntry::UpdateDeleteTab is called, which is called on tab sheet delete. Change-Id: I3bbc8111bb1685d6f7f307a15c852c6657f37b3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160234 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 0ba4e0483bacd698a227d0d18422fc6a08055c28) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161754 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx index 1c50c7a2c0d1..50eb60c88d18 100644 --- a/sc/inc/refupdatecontext.hxx +++ b/sc/inc/refupdatecontext.hxx @@ -113,6 +113,8 @@ struct RefUpdateResult */ bool mbNameModified; + SCTAB nTab; + RefUpdateResult(); }; diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 93094e929bf4..04ee4e6fc239 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -595,20 +595,29 @@ void ScConditionEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) StartListening(); } -void ScConditionEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) +void ScConditionEntry::UpdateMoveTab(sc::RefUpdateMoveTabContext& rCxt) { + sc::RefUpdateResult aResFinal; + aResFinal.nTab = aSrcPos.Tab(); if (pFormula1) { - pFormula1->AdjustReferenceOnMovedTab(rCxt, aSrcPos); + sc::RefUpdateResult aRes = pFormula1->AdjustReferenceOnMovedTab(rCxt, aSrcPos); + if (aRes.mbValueChanged) + aResFinal.nTab = aRes.nTab; pFCell1.reset(); } if (pFormula2) { - pFormula2->AdjustReferenceOnMovedTab(rCxt, aSrcPos); + sc::RefUpdateResult aRes = pFormula2->AdjustReferenceOnMovedTab(rCxt, aSrcPos); + if (aRes.mbValueChanged) + aResFinal.nTab = aRes.nTab; pFCell2.reset(); } + if (aResFinal.nTab != aSrcPos.Tab()) + aSrcPos.SetTab(aResFinal.nTab); + StartListening(); } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 8abf686f2510..f927f2389450 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -4417,7 +4417,11 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMovedTab( const sc::RefUpdate ScAddress aNewPos = rOldPos; if (adjustTabOnMove(aNewPos, rCxt)) + { aRes.mbReferenceModified = true; + aRes.mbValueChanged = true; + aRes.nTab = aNewPos.Tab(); // this sets the new tab position used when deleting + } TokenPointers aPtrs( pCode.get(), nLen, pRPN, nRPN); for (size_t j=0; j<2; ++j)