sfx2/source/doc/SfxDocumentMetaData.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
New commits: commit 228f43f2e3c2896c227f1ea30c5d16231acf66da Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Feb 14 19:25:40 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Feb 14 19:13:00 2021 +0100 tdf#140308 Crash import old OpenOffice template regression from commit cfe5a5044845a3fc90e3634e996edb4d85808d3c sfx2: use the fastparser API when possible We end up using the OOo2OasisTransformer filter, which is not fastparser compatible Bisected with: bibisect-linux64-7.1 Change-Id: I7bd4191f098096034dc8ff368aba4b1ff313ce18 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110883 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 0c406c76fe24..4312c241e32d 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/xml/sax/Writer.hpp> +#include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/XFastParser.hpp> #include <com/sun/star/xml/dom/DOMException.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> @@ -1764,13 +1765,19 @@ SfxDocumentMetaData::loadFromStorage( xMsf->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pServiceName), args, m_xContext); assert(xFilter); - css::uno::Reference<css::xml::sax::XFastParser> xDocHandler(xFilter, css::uno::UNO_QUERY); - assert(xDocHandler); - css::uno::Reference<css::document::XImporter> xImp(xDocHandler, css::uno::UNO_QUERY); - assert(xImp); + css::uno::Reference<css::xml::sax::XFastParser> xFastParser(xFilter, css::uno::UNO_QUERY); + css::uno::Reference<css::document::XImporter> xImp(xFilter, css::uno::UNO_QUERY_THROW); xImp->setTargetDocument(css::uno::Reference<css::lang::XComponent>(this)); try { - xDocHandler->parseStream(input); + if (xFastParser) + xFastParser->parseStream(input); + else + { + css::uno::Reference<css::xml::sax::XDocumentHandler> xDocHandler(xFilter, css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::xml::sax::XParser> xParser = css::xml::sax::Parser::create(m_xContext); + xParser->setDocumentHandler(xDocHandler); + xParser->parseStream(input); + } } catch (const css::xml::sax::SAXException &) { throw css::io::WrongFormatException( "SfxDocumentMetaData::loadFromStorage:" _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits