sc/qa/unit/data/xlsx/forcepoint107.xlsx |binary sc/qa/unit/filters-test.cxx | 9 +++++++++ sc/source/core/data/documentimport.cxx | 8 ++++++++ sc/source/core/data/formulacell.cxx | 3 +++ 4 files changed, 20 insertions(+)
New commits: commit a7bf0d61db1343d8af564a2b657def3e17b39b79 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Jun 21 10:38:30 2022 +0100 Commit: Eike Rathke <[email protected]> CommitDate: Mon Jul 25 17:28:14 2022 +0200 forcepoint#107: ensure to be deleted formulas are unshared first Change-Id: I32cee0a22616e96d85c59d76319a6f6074fcde8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136228 Tested-by: Jenkins Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit 31c05349320aceb056d61e4ecd06b18fc31509bb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137185 Reviewed-by: Eike Rathke <[email protected]> diff --git a/sc/qa/unit/data/xlsx/forcepoint107.xlsx b/sc/qa/unit/data/xlsx/forcepoint107.xlsx new file mode 100644 index 000000000000..f5238dcb5c3e Binary files /dev/null and b/sc/qa/unit/data/xlsx/forcepoint107.xlsx differ diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index 7025fdc52018..44dc5ace5ad7 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -82,6 +82,7 @@ public: void testSortWithSheetExternalReferencesODS_Impl( ScDocShellRef const & xDocShRef, SCROW nRow1, SCROW nRow2, bool bCheckRelativeInSheet ); void testSortWithFormattingXLS(); + void testForcepoint107(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCVEs); @@ -108,6 +109,7 @@ public: CPPUNIT_TEST(testSortWithSharedFormulasODS); CPPUNIT_TEST(testSortWithSheetExternalReferencesODS); CPPUNIT_TEST(testSortWithFormattingXLS); + CPPUNIT_TEST(testForcepoint107); CPPUNIT_TEST_SUITE_END(); @@ -869,6 +871,13 @@ void ScFiltersTest::testSortWithFormattingXLS() xDocSh->DoClose(); } +// just needs to not crash on recalc +void ScFiltersTest::testForcepoint107() +{ + ScDocShellRef xDocSh = loadDoc(u"forcepoint107.", FORMAT_XLSX, true); + xDocSh->DoHardRecalc(); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) , mbUpdateReferenceOnSort(false) diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx index 68b02a0e7666..7ce2d0a001c9 100644 --- a/sc/source/core/data/documentimport.cxx +++ b/sc/source/core/data/documentimport.cxx @@ -387,6 +387,14 @@ void ScDocumentImport::setFormulaCell(const ScAddress& rPos, ScFormulaCell* pCel mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pCell->GetCode()); sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells; + + sc::CellStoreType::position_type aPos = rCells.position(rPos.Row()); + if (aPos.first != rCells.end() && aPos.first->type == sc::element_type_formula) + { + ScFormulaCell* p = sc::formula_block::at(*aPos.first->data, aPos.second); + sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p); + } + pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), pCell); } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 404abe0988cc..f2d840cb9efb 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -925,6 +925,9 @@ ScFormulaCell::~ScFormulaCell() if (!mxGroup || !mxGroup->mpCode) // Formula token is not shared. delete pCode; + + if (mxGroup && mxGroup->mpTopCell == this) + mxGroup->mpTopCell = nullptr; } ScFormulaCell* ScFormulaCell::Clone() const
