From 8c8bac35c1a5de59559b60f963247dba23ff9d16 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 19 Nov 2024 12:51:52 +0000 Subject: catch invalid ranges at export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit log failure and continue to export the remainder of the document #0 0x0000733dda8ae4a1 in __cxa_throw () from target:/lib/x86_64-linux-gnu/libstdc++.so.6 #1 0x0000733dc5d0bd43 in ScCellRangeObj::getCellRangeByPosition (this=0x2a753d60, nLeft=43, nTop=-7, nRight=43, nBottom=-7) at sc/source/ui/unoobj/cellsuno.cxx:4638 #2 0x0000733dc66150d5 in ScTableSheetObj::getCellRangeByPosition (this=0x2a753d60, nLeft=43, nTop=-7, nRight=43, nBottom=-7) at sc/source/ui/unoobj/cellsuno.cxx:6711 #3 0x0000733dc62d3e38 in ScXMLExport::GetMerged (this=0x1fc74160, pCellAddress=, xTable=...) at sc/source/filter/xml/xmlexprt.cxx:2750 #4 0x0000733dc62d7104 in ScXMLExport::AddStyleFromCells (this=0x1fc74160, xProperties=..., xTable=..., nTable=0, pOldName=0x0) at sc/source/filter/xml/xmlexprt.cxx:2156 #5 0x0000733dc62dfebb in ScXMLExport::collectAutoStyles (this=) at sc/source/filter/xml/xmlexprt.cxx:2559 #6 0x0000733dc62d0fff in ScXMLExport::ExportAutoStyles_ (this=0x1fc74160) at sc/source/filter/xml/xmlexprt.cxx:2657 #7 0x0000733dd833a7a4 in SvXMLExport::ImplExportAutoStyles (this=0x1fc74160) at xmloff/source/core/xmlexp.cxx:1123 #8 0x0000733dd833d098 in SvXMLExport::exportDoc (this=0x1fc74160, eClass=) at xmloff/source/core/xmlexp.cxx:1389 #9 0x0000733dd83386f6 in SvXMLExport::filter (this=this@entry=0x1fc74160, aDescriptor=...) at xmloff/source/core/xmlexp.cxx:815 #10 0x0000733dc62e6452 in ScXMLExport::filter (this=0x1fc74160, aDescriptor=...) at sc/source/filter/xml/xmlexprt.cxx:5472 #11 0x0000733dc63204a0 in ScXMLImportWrapper::ExportToComponent (this=0x7ffc11959890, xContext=..., xModel=..., xWriter=..., aDescriptor=..., sName=..., sMediaType=..., sComponentName=..., aArgs=..., pSharedData=...) at sc/source/filter/xml/xmlwrap.cxx:707 #12 0x0000733dc632679a in ScXMLImportWrapper::Export (this=this@entry=0x7ffc11959890, bStylesOnly=bStylesOnly@entry=false) at sc/source/filter/xml/xmlwrap.cxx:943 #13 0x0000733dc6465d5e in ScDocShell::SaveXML (this=0x11d1c440, pSaveMedium=0x138252f0, xStor=...) at sc/source/ui/docshell/docsh.cxx:653 #14 0x0000733dc646a519 in ScDocShell::SaveAs (this=0x11d1c440, rMedium=...) at sc/source/ui/docshell/docsh.cxx:1913 #15 0x0000733dd6ae7432 in SfxObjectShell::SaveAsOwnFormat (this=0x11d1c440, rMedium=...) at sfx2/source/doc/objstor.cxx:3378 #16 0x0000733dd6af0ae6 in SfxObjectShell::SaveTo_Impl (this=0x11d1c440, rMedium=..., pSet=0x7ffc11959fe0) at sfx2/source/doc/objstor.cxx:1520 #17 0x0000733dd6af2f08 in SfxObjectShell::DoSave_Impl (this=0x11d1c440, pArgs=0x7ffc11959fe0) at sfx2/source/doc/objstor.cxx:2760 #18 0x0000733dd6b2b3aa in SfxBaseModel::storeSelf (this=0x5348c30, aSeqArgs=...) at /opt/rh/devtoolset-12/root/usr/include/c++/12/optional:306 #19 0x0000733dd6ab2671 in SfxStoringHelper::GUIStoreModel (this=this@entry=0x2ba275b0, xModel=..., aSlotName=..., aArgsSequence=..., bPreselectPassword=bPreselectPassword@entry=false, nDocumentSignatureState=SignatureState::NOSIGNATURES, bIsAsync=false) perhaps some relation to https://gerrit.libreoffice.org/c/core/+/160363 which is a somewhat similar situation Change-Id: I6b28ef0e9df0f44641fa5c582b5827dbcfb4af8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176765 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176792 Reviewed-by: Caolán McNamara Tested-by: Jenkins (cherry picked from commit 3746195ff989a4596afc456d53010d8860bd7b64) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176816 Reviewed-by: Michael Stahl --- sc/source/filter/xml/xmlexprt.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sc') diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 00231fc4ae38..0590c95d0e8b 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2733,6 +2733,20 @@ void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > const } } +static uno::Reference lclGetSheetRange(const uno::Reference & xTable, sal_Int32 nCol, sal_Int32 nRow) +{ + try + { + return uno::Reference(xTable->getCellRangeByPosition(nCol, nRow, nCol, nRow), uno::UNO_QUERY); + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("sc", "Exception in getCellRangeByPosition, col: " << nCol << ", row: " << nRow); + assert(false && "try and capture this in crashtesting"); + } + return nullptr; +} + bool ScXMLExport::GetMerged (const table::CellRangeAddress* pCellAddress, const uno::Reference & xTable) { @@ -2744,7 +2758,7 @@ bool ScXMLExport::GetMerged (const table::CellRangeAddress* pCellAddress, bool bRowInc(nEndRow > nRow); while(!bReady && nRow <= nEndRow && nCol <= nEndCol) { - uno::Reference xSheetCellRange(xTable->getCellRangeByPosition(nCol, nRow, nCol, nRow), uno::UNO_QUERY); + uno::Reference xSheetCellRange(lclGetSheetRange(xTable, nCol, nRow)); if (xSheetCellRange.is()) { uno::Reference xCursor(xTable->createCursorByRange(xSheetCellRange)); -- cgit