diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-03-17 09:30:44 +0000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-03-17 18:39:27 +0000 |
commit | 32b2d00853d049bacb60cfb40e732602da048c89 (patch) | |
tree | 1c49783c76b47b07018be27bbb774a16180b6aae /sc/source/core | |
parent | dd3c70518851b532f43a853d8e0c6189013844c4 (diff) |
tdf#148008: do not proceed after the marked range
Implementation error in commit c008dc483f8c6840803983e7e351cec6fdd32070
("Switch to using multi_type_vector for cell storage.", 2013-06-24).
Change-Id: I1e946b3b816db3d24f79a10fe8aa0dfc673b2e4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149026
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/column2.cxx | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 1e879df34870..edc11bd54244 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -808,22 +808,20 @@ sal_uInt16 ScColumn::GetOptimalColWidth( // Go though all non-empty cells within selection. sc::CellStoreType::const_iterator itPos = maCells.begin(); - for (const auto& rMarkedSpan : aMarkedSpans) + for (auto [ nRow, nRow2 ] : aMarkedSpans) { - SCROW nRow1 = rMarkedSpan.mnRow1, nRow2 = rMarkedSpan.mnRow2; - SCROW nRow = nRow1; while (nRow <= nRow2) { - std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(itPos, nRow); - itPos = aPos.first; + size_t nOffset; + std::tie(itPos, nOffset) = maCells.position(itPos, nRow); if (itPos->type == sc::element_type_empty) { // Skip empty cells. - nRow += itPos->size - aPos.second; + nRow += itPos->size - nOffset; continue; } - for (size_t nOffset = aPos.second; nOffset < itPos->size; ++nOffset, ++nRow) + for (; nOffset < itPos->size && nRow <= nRow2; ++nOffset, ++nRow) { SvtScriptType nScript = rDocument.GetScriptType(nCol, nRow, nTab); if (nScript == SvtScriptType::NONE) |