diff options
author | Matt K <mattkse@gmail.com> | 2024-01-01 11:44:35 -0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-01-06 18:20:29 +0100 |
commit | 0ba4e0483bacd698a227d0d18422fc6a08055c28 (patch) | |
tree | 0e6a6fc963ead043a9e16ba6857d687c665e7e07 | |
parent | 06eeb2fb3d4ec3778db5c9c342d2d17aea456577 (diff) |
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.kaganski@collabora.com>
-rw-r--r-- | sc/inc/refupdatecontext.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 15 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 4 |
3 files changed, 18 insertions, 3 deletions
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) |