sc/source/core/data/column3.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
New commits: commit 23d607b104013e412295ac83956edc74e94ed2df Author: Eike Rathke <er...@redhat.com> AuthorDate: Sat Sep 10 00:12:22 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Sep 12 10:39:23 2022 +0200 Resolves: tdf#150766 Listen to entire shared formula group instead of a slice Change-Id: I677602bd3401dbd401e35f7db64cd34d164d9d92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139744 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit 0919d8a389cba5626c14b08549243546830cfb8d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139662 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 424beb65e500..1a65d3edad5a 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -569,6 +569,40 @@ void ScColumn::AttachFormulaCells( sc::StartListeningContext& rCxt, SCROW nRow1, if (GetDoc().IsClipOrUndo()) return; + // Need to process (start listening) entire shared formula groups, not just + // a slice thereof. + bool bEnlargedDown = false; + aPos = maCells.position(nRow1); + it = aPos.first; + if (it->type == sc::element_type_formula) + { + ScFormulaCell& rCell = *sc::formula_block::at(*it->data, aPos.second); + if (rCell.IsShared()) + { + nRow1 = std::min( nRow1, rCell.GetSharedTopRow()); + if (nRow2 < rCell.GetSharedTopRow() + rCell.GetSharedLength()) + { + nRow2 = rCell.GetSharedTopRow() + rCell.GetSharedLength() - 1; + bEnlargedDown = true; + // Same end row is also enlarged, i.e. doesn't need to be + // checked for another group. + } + } + } + if (!bEnlargedDown) + { + aPos = maCells.position(it, nRow2); + it = aPos.first; + if (it->type == sc::element_type_formula) + { + ScFormulaCell& rCell = *sc::formula_block::at(*it->data, aPos.second); + if (rCell.IsShared()) + { + nRow2 = std::max( nRow2, rCell.GetSharedTopRow() + rCell.GetSharedLength() - 1); + } + } + } + AttachFormulaCellsHandler aFunc(rCxt); sc::ProcessFormula(it, maCells, nRow1, nRow2, aFunc); }