sc/qa/unit/subsequent_export_test2.cxx | 19 +++++++++++++++++++ sc/source/filter/xml/xmlexprt.cxx | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit 02b31fcca378551a6a9e58b06aeb7b33c7e28f68 Author: Justin Luth <[email protected]> AuthorDate: Wed Dec 17 14:17:31 2025 -0500 Commit: Justin Luth <[email protected]> CommitDate: Thu Dec 18 21:48:44 2025 +0100 tdf#170012 sc drwlayer: avoid crash on ODS save This fixes a crash since 7.1 commit 1f0b3c7a40edfa81bbc7a58d123a6a2dfd83e4ca Instead of trying to save as a broken SCA_CELL_RESIZE it will save as a SCA_PAGE anchored object. The crash was occuring when saving to ODS format. It would loop forever because of the invalid address that GetNonRotatedObjData got during RecalcPos when it had been created but never "initialized". (An earlier patchset tried to force initialization and assert that, but I got tons of asserts in unit tests because of detfunc's bCreate without ScDrawLayer::InitializeCellAnchoredObj). Plus, doing initialization correctly sounds incomprehensible based on a code read. make CppunitTest_sc_subsequent_export_test2 \ CPPUNIT_TEST_NAME=testTdf170012_cellAnchor Change-Id: Ief717c8742d712bf2edec90f492fd258f9fd7741 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195807 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> (cherry picked from commit cbd9d23b7b953fdf53d66aaa072bab17db7905d3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195861 diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 0ca3d733b129..bd66ff250767 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -107,6 +107,25 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf166724_cellAnchor) CPPUNIT_ASSERT_EQUAL(tools::Long(557), aRect.GetHeight()); }; +CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf170012_cellAnchor) +{ + // Reuse the test document from the previous test + // A clean re-load is need (because the first load triggers an adjustment for autoRowHeight) + createScDoc("xlsx/tdf166724_cellAnchor.xlsx"); + + const SdrPage* pPage = getScDoc()->GetDrawLayer()->GetPage(0); + ScAnchorType anchorType = ScDrawLayer::GetAnchorType(*pPage->GetObj(0)); + CPPUNIT_ASSERT_EQUAL(SCA_CELL_RESIZE, anchorType); + + // round-trip cell-anchored controls in ODS format + // - this was looping forever, and creating infinite /tmp files - triggered by autoRowHeight + saveAndReload(TestFilter::ODS); + + pPage = getScDoc()->GetDrawLayer()->GetPage(0); + anchorType = ScDrawLayer::GetAnchorType(*pPage->GetObj(0)); + CPPUNIT_ASSERT_EQUAL(SCA_PAGE, anchorType); // fallback to page anchor when invalid cell anchor +} + CPPUNIT_TEST_FIXTURE(ScExportTest2, testFreezePaneStartCellXLSX) { // given a hand-mangled document with a newly-invalid topLeftCell for the active pane diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index d70ae952f147..6200754b01c9 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -544,7 +544,8 @@ void ScXMLExport::CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount) if (!pSdrObj) continue; - if (ScDrawObjData *pAnchor = ScDrawLayer::GetNonRotatedObjData(pSdrObj)) + ScDrawObjData* pAnchor = ScDrawLayer::GetNonRotatedObjData(pSdrObj); + if (pAnchor && pAnchor->maStart.IsValid()) { ScMyShape aMyShape; aMyShape.aAddress = pAnchor->maStart;
