diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-06-21 10:38:30 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-07-25 17:28:14 +0200 |
commit | a7bf0d61db1343d8af564a2b657def3e17b39b79 (patch) | |
tree | 6c74a668a00a789af0824747e4db3b7534ae99b9 | |
parent | 89c7beea208e7d70072cd2b436280c816debc180 (diff) |
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 <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 31c05349320aceb056d61e4ecd06b18fc31509bb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137185
Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/qa/unit/data/xlsx/forcepoint107.xlsx | bin | 0 -> 398436 bytes | |||
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/documentimport.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 3 |
4 files changed, 20 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/forcepoint107.xlsx b/sc/qa/unit/data/xlsx/forcepoint107.xlsx Binary files differnew file mode 100644 index 000000000000..f5238dcb5c3e --- /dev/null +++ b/sc/qa/unit/data/xlsx/forcepoint107.xlsx 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 |