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 cbd9d23b7b953fdf53d66aaa072bab17db7905d3 Author: Justin Luth <[email protected]> AuthorDate: Wed Dec 17 14:17:31 2025 -0500 Commit: Justin Luth <[email protected]> CommitDate: Thu Dec 18 20:31:14 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]> diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 78bfb4c1f837..0b1962a4125f 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -105,6 +105,25 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf166724_cellAnchor) CPPUNIT_ASSERT_EQUAL(SCROW(1), aFoundCell.aStart.Row()); }; +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;
