writerfilter/source/dmapper/DomainMapper_Impl.cxx | 52 +++++++++++++--------- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 2 2 files changed, 35 insertions(+), 19 deletions(-)
New commits: commit 8109dd0217cb8d8faac185176d638d7af588a520 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Apr 4 20:01:13 2021 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Apr 5 12:18:50 2021 +0200 crashtesting: assert in fdo6872-1.docx in CopyImplImpl after SAXError exception sw/source/core/doc/DocumentContentOperationsManager.cxx:5040 assert(pStt->nNode != pEnd->nNode); presumably due to the error the positions are wrong when CopyImplImpl is called in popping the context where the exception occured, so skip the asserting operation if the document failed to load and will be thrown away fixes fdo68738-1.docx, fdo46060-6.docx, fdo55725-1.docx, fdo68721-1.docx but similar ooo127821-1.docx remains Change-Id: I09aca7a6884f7806c74797466522bb489260da51 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113572 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 44ab9fdf3b36..200cb75667be 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/xml/sax/SAXException.hpp> #include <ooxml/resourceids.hxx> #include "DomainMapper_Impl.hxx" #include "ConversionHelper.hxx" @@ -354,7 +355,8 @@ DomainMapper_Impl::DomainMapper_Impl( m_bParaAutoBefore(false), m_bFirstParagraphInCell(true), m_bSaveFirstParagraphInCell(false), - m_bParaWithInlineObject(false) + m_bParaWithInlineObject(false), + m_bSaxError(false) { m_aBaseUrl = rMediaDesc.getUnpackedValueOrDefault( @@ -2973,23 +2975,26 @@ void DomainMapper_Impl::PopFootOrEndnote() xFootnotes->getByIndex(1) >>= xFootnoteFirst; else xEndnotes->getByIndex(1) >>= xFootnoteFirst; - uno::Reference< text::XText > xSrc( xFootnoteFirst, uno::UNO_QUERY_THROW ); - uno::Reference< text::XText > xDest( xFootnoteLast, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextCopy > xTxt, xTxt2; - xTxt.set( xSrc, uno::UNO_QUERY_THROW ); - xTxt2.set( xDest, uno::UNO_QUERY_THROW ); - xTxt2->copyText( xTxt ); - - // copy its redlines - std::vector<sal_Int32> redPos, redLen; - sal_Int32 redIdx; - enum StoredRedlines eType = IsInFootnote() ? StoredRedlines::FOOTNOTE : StoredRedlines::ENDNOTE; - lcl_CopyRedlines(xSrc, m_aStoredRedlines[eType], redPos, redLen, redIdx); - lcl_PasteRedlines(xDest, m_aStoredRedlines[eType], redPos, redLen, redIdx); - - // remove processed redlines - for( size_t i = 0; redIdx > -1 && i <= sal::static_int_cast<size_t>(redIdx) + 2; i++) - m_aStoredRedlines[eType].pop_front(); + if (!m_bSaxError) + { + uno::Reference< text::XText > xSrc( xFootnoteFirst, uno::UNO_QUERY_THROW ); + uno::Reference< text::XText > xDest( xFootnoteLast, uno::UNO_QUERY_THROW ); + uno::Reference< text::XTextCopy > xTxt, xTxt2; + xTxt.set( xSrc, uno::UNO_QUERY_THROW ); + xTxt2.set( xDest, uno::UNO_QUERY_THROW ); + xTxt2->copyText( xTxt ); + + // copy its redlines + std::vector<sal_Int32> redPos, redLen; + sal_Int32 redIdx; + enum StoredRedlines eType = IsInFootnote() ? StoredRedlines::FOOTNOTE : StoredRedlines::ENDNOTE; + lcl_CopyRedlines(xSrc, m_aStoredRedlines[eType], redPos, redLen, redIdx); + lcl_PasteRedlines(xDest, m_aStoredRedlines[eType], redPos, redLen, redIdx); + + // remove processed redlines + for( size_t i = 0; redIdx > -1 && i <= sal::static_int_cast<size_t>(redIdx) + 2; i++) + m_aStoredRedlines[eType].pop_front(); + } // remove temporary footnote xFootnoteFirst->getAnchor()->setString(""); @@ -7640,7 +7645,16 @@ void DomainMapper_Impl::substream(Id rName, PushAnnotation(); break; } - ref->resolve(m_rDMapper); + + try + { + ref->resolve(m_rDMapper); + } + catch (xml::sax::SAXException const&) + { + m_bSaxError = true; + throw; + } switch( rName ) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 1b29e96cbc27..c4d9b5014c04 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -1144,6 +1144,8 @@ private: bool m_bSaveFirstParagraphInCell; /// Current paragraph had at least one inline object in it. bool m_bParaWithInlineObject; + /// SAXException was seen so document will be abandoned + bool m_bSaxError; }; } //namespace writerfilter::dmapper _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits