sc/inc/column.hxx | 5 +++++ sc/source/core/data/column4.cxx | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-)
New commits: commit f19ae9b5e629d163314ee18d56973d0561d5fb3b Author: Kohei Yoshida <ko...@libreoffice.org> AuthorDate: Thu Mar 10 22:50:17 2022 -0500 Commit: Kohei Yoshida <ko...@libreoffice.org> CommitDate: Fri Mar 11 15:01:52 2022 +0100 tdf#147744: Make sure to pass valid position hints. When pasting a single cell to a range with filtered rows, the existing code wasn't updating the position hint iterator after inserting cloned formula cells via ScColumn::CloneFormulaCell(). This caused the next call into the cell store to receive an invalid position hint. This problem has been there all along, but apparently it did not cause a process termination with the previous storage layout of multi_type_vector for a reason unknown to me. Change-Id: Ie1a4b99c7077536499c6373ccb7022961e9d93e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131331 Tested-by: Jenkins Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Kohei Yoshida <ko...@libreoffice.org> diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index b6fde6801a2f..689f0c0ccbd0 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -408,6 +408,11 @@ public: bool HasFormulaCell() const; bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const; + void CloneFormulaCell( + sc::ColumnBlockPosition& rBlockPos, + const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr, + const std::vector<sc::RowSpan>& rRanges ); + void CloneFormulaCell( const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr, const std::vector<sc::RowSpan>& rRanges ); diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index 6e93ce9b8df8..3a7145608de8 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -312,7 +312,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1, std::vector<sc::RowSpan> aRanges; aRanges.reserve(1); aRanges.emplace_back(nRow1, nRow2); - CloneFormulaCell(*rSrcCell.mpFormula, rSrcAttr, aRanges); + CloneFormulaCell(*pBlockPos, *rSrcCell.mpFormula, rSrcAttr, aRanges); } break; default: @@ -571,12 +571,10 @@ void ScColumn::DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDele } void ScColumn::CloneFormulaCell( + sc::ColumnBlockPosition& rBlockPos, const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr, const std::vector<sc::RowSpan>& rRanges ) { - sc::CellStoreType::iterator itPos = maCells.begin(); - sc::CellTextAttrStoreType::iterator itAttrPos = maCellTextAttrs.begin(); - SCCOL nMatrixCols = 0; SCROW nMatrixRows = 0; ScMatrixMode nMatrixFlag = rSrc.GetMatrixFlag(); @@ -629,10 +627,10 @@ void ScColumn::CloneFormulaCell( } } - itPos = maCells.set(itPos, nRow1, aFormulas.begin(), aFormulas.end()); + rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow1, aFormulas.begin(), aFormulas.end()); // Join the top and bottom of the pasted formula cells as needed. - sc::CellStoreType::position_type aPosObj = maCells.position(itPos, nRow1); + sc::CellStoreType::position_type aPosObj = maCells.position(rBlockPos.miCellPos, nRow1); assert(aPosObj.first->type == sc::element_type_formula); ScFormulaCell* pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second); @@ -644,12 +642,22 @@ void ScColumn::CloneFormulaCell( JoinNewFormulaCell(aPosObj, *pCell); std::vector<sc::CellTextAttr> aTextAttrs(nLen, rAttr); - itAttrPos = maCellTextAttrs.set(itAttrPos, nRow1, aTextAttrs.begin(), aTextAttrs.end()); + rBlockPos.miCellTextAttrPos = maCellTextAttrs.set( + rBlockPos.miCellTextAttrPos, nRow1, aTextAttrs.begin(), aTextAttrs.end()); } CellStorageModified(); } +void ScColumn::CloneFormulaCell( + const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr, + const std::vector<sc::RowSpan>& rRanges ) +{ + sc::ColumnBlockPosition aBlockPos; + InitBlockPosition(aBlockPos); + CloneFormulaCell(aBlockPos, rSrc, rAttr, rRanges); +} + std::unique_ptr<ScPostIt> ScColumn::ReleaseNote( SCROW nRow ) { if (!GetDoc().ValidRow(nRow))