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>
(cherry picked from commit 228f43f2e3c2896c227f1ea30c5d16231acf66da)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110866
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 5783225..36d8dde 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -48,6 +48,7 @@
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/xml/sax/Parser.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>
@@ -1765,13 +1766,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:"