sc/source/filter/inc/XclExpChangeTrack.hxx | 7 +++++++ sc/source/filter/xcl97/XclExpChangeTrack.cxx | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
New commits: commit f95c213cc9107e25f78e25c6a1bdfb8a5a61be2a Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sun Jun 25 11:54:07 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Jun 25 14:09:35 2023 +0200 crashtesting: crash seen on exporting fdo66241-1.ods to xlsx Change-Id: I730bd782ddf67555c40651aed1442465574a1c01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153560 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx index 9d007ba368f3..9701ba6e29f5 100644 --- a/sc/source/filter/inc/XclExpChangeTrack.hxx +++ b/sc/source/filter/inc/XclExpChangeTrack.hxx @@ -28,6 +28,7 @@ #include "xestring.hxx" #include "excrecds.hxx" #include "xlformula.hxx" +#include "xllink.hxx" #include "xeformula.hxx" class ExcXmlRecord : public ExcRecord @@ -365,6 +366,7 @@ protected: static inline void Write2DAddress( XclExpStream& rStrm, const ScAddress& rAddress ); static inline void Write2DRange( XclExpStream& rStrm, const ScRange& rRange ); inline sal_uInt16 GetTabId( SCTAB nTabId ) const; + inline bool IsDeletedTab( SCTAB nTab ) const; inline void WriteTabId( XclExpStream& rStrm, SCTAB nTabId ) const; // save header data, call SaveActionData() @@ -421,6 +423,11 @@ inline void XclExpChTrAction::Write2DRange( XclExpStream& rStrm, const ScRange& << static_cast<sal_uInt16>(rRange.aEnd.Col()); } +inline bool XclExpChTrAction::IsDeletedTab(SCTAB nTab) const +{ + return rTabInfo.GetXclTab(nTab) == EXC_TAB_DELETED; +} + inline sal_uInt16 XclExpChTrAction::GetTabId( SCTAB nTab ) const { return rIdBuffer.GetId( rTabInfo.GetXclTab( nTab ) ); diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index 57fd143bf659..71156df08e04 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -573,7 +573,7 @@ void XclExpChTrTabIdBuffer::InitFillup() sal_uInt16 XclExpChTrTabIdBuffer::GetId( sal_uInt16 nIndex ) const { - OSL_ENSURE( nIndex < nBufSize, "XclExpChTrTabIdBuffer::GetId - out of range" ); + assert(nIndex < nBufSize && "XclExpChTrTabIdBuffer::GetId - out of range"); return pBuffer[ nIndex ]; } @@ -1025,6 +1025,13 @@ static void lcl_WriteCell( XclExpXmlStream& rStrm, sal_Int32 nElement, const ScA void XclExpChTrCellContent::SaveXml( XclExpXmlStream& rRevisionLogStrm ) { + if (IsDeletedTab(aPosition.Tab())) + { + // seen on attempt to export tdf66241-1.ods to xlsx + SAL_WARN("sc", "XclExpChTrCellContent: unable to export position with tab of EXC_TAB_DELETED"); + return; + } + sax_fastparser::FSHelperPtr pStream = rRevisionLogStrm.GetCurrentStream(); pStream->startElement( XML_rcc, XML_rId, OString::number(GetActionNumber()), @@ -1155,6 +1162,13 @@ static const char* lcl_GetAction( sal_uInt16 nOpCode ) void XclExpChTrInsert::SaveXml( XclExpXmlStream& rRevisionLogStrm ) { + if (IsDeletedTab(aRange.aStart.Tab())) + { + // seen on attempt to export tdf66241-1.ods to xlsx + SAL_WARN("sc", "XclExpChTrCellContent: unable to export position with tab of EXC_TAB_DELETED"); + return; + } + sax_fastparser::FSHelperPtr pStream = rRevisionLogStrm.GetCurrentStream(); pStream->startElement( XML_rrc, XML_rId, OString::number(GetActionNumber()), @@ -1279,6 +1293,13 @@ std::size_t XclExpChTrMoveRange::GetActionByteCount() const void XclExpChTrMoveRange::SaveXml( XclExpXmlStream& rRevisionLogStrm ) { + if (IsDeletedTab(aDestRange.aStart.Tab()) || IsDeletedTab(aSourceRange.aStart.Tab())) + { + // seen on attempt to export tdf66241-1.ods to xlsx + SAL_WARN("sc", "XclExpChTrCellContent: unable to export position with tab of EXC_TAB_DELETED"); + return; + } + sax_fastparser::FSHelperPtr pStream = rRevisionLogStrm.GetCurrentStream(); pStream->startElement( XML_rm,