diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-02-14 19:25:40 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-14 19:13:00 +0100 |
commit | 228f43f2e3c2896c227f1ea30c5d16231acf66da (patch) | |
tree | f1ec95304c36c030abd8955fa2a7bc52624036ce | |
parent | 2b09d37e1ce666829392c6e1580db41e7b976016 (diff) |
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.grandin@collabora.co.uk>
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 17 |
1 files changed, 12 insertions, 5 deletions
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:" |