diff options
author | Kohei Yoshida <kohei@libreoffice.org> | 2022-03-10 22:50:17 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei@libreoffice.org> | 2022-03-11 22:41:13 +0100 |
commit | 7049b1da30f715c502f38ed982eec037e096be08 (patch) | |
tree | 6d6c32a9647d9efbedb0e40514b9a99fcaa613d6 /sc | |
parent | f8f0304fe755bec98639b5f1cd46c0899dc24a36 (diff) |
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 <xiscofauli@libreoffice.org>
Reviewed-by: Kohei Yoshida <kohei@libreoffice.org>
(cherry picked from commit f19ae9b5e629d163314ee18d56973d0561d5fb3b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131378
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/column.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/column4.cxx | 22 |
2 files changed, 20 insertions, 7 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index 35c4b3eb0d3b..01e58fb9d055 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -349,6 +349,11 @@ public: 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 22bd15cb271c..bbae4747a13e 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -317,7 +317,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: @@ -576,12 +576,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(); @@ -634,10 +632,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); @@ -649,12 +647,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)) |