diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-10-28 21:44:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-29 09:04:55 +0100 |
commit | 4229467fa8528531dc27784f07bc54488c0d2fa9 (patch) | |
tree | f1844f9b9ad426b0b059222e0b2c771f926d8879 | |
parent | affbe9ed49b81c41a84f47653ce208e5e01f5353 (diff) |
crashtesting rhbz909647-2
as a consequence of
commit 2b946d245eaf4bd40a0091aa5508315fc37c81a0
Date: Mon Oct 19 09:36:04 2020 +0200
XmlFilterAdaptor: use the fastparser API when possible
re-introduce slowparser support here
Change-Id: I95470e51508f8e250f27c5af7ffdc1b737c16ab9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104975
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index dfebcced36db..44839ceb3f2d 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -110,11 +110,10 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler + // ...except when it's one of the XMLTransformer subclasses Reference < XInterface > xFilter = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( sXMLImportService, aAnys, mxContext ); assert(xFilter); - Reference < XFastDocumentHandler > xHandler( xFilter, UNO_QUERY ); - assert(xHandler); - Reference < XImporter > xImporter( xHandler, UNO_QUERY ); + Reference < XImporter > xImporter( xFilter, UNO_QUERY ); assert(xImporter); xImporter->setTargetDocument ( mxDoc ); @@ -166,8 +165,6 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& } } -// sal_Bool xconv_ret = sal_True; - if (xStatusIndicator.is()){ xStatusIndicator->setValue(nSteps++); } @@ -175,25 +172,44 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& // Calling Filtering Component try { - auto pImport = dynamic_cast<SvXMLImport*>(xHandler.get()); - assert(pImport); - if (xConverter2) + Reference < XFastParser > xFastParser( xFilter, UNO_QUERY ); // SvXMLImport subclasses + Reference < XDocumentHandler > xDocHandler( xFilter, UNO_QUERY ); // XMLTransformer subclasses + assert(xFastParser || xDocHandler); + if (xConverter2 && xFastParser) { - if (!xConverter2->importer(aDescriptor,pImport,msUserData)) { + if (!xConverter2->importer(aDescriptor,xFastParser,msUserData)) { if (xStatusIndicator.is()) xStatusIndicator->end(); return false; } } - else + else if (xConverter1 && xDocHandler) { - Reference<XDocumentHandler> xDocHandler = new SvXMLLegacyToFastDocHandler(pImport); if (!xConverter1->importer(aDescriptor,xDocHandler,msUserData)) { if (xStatusIndicator.is()) xStatusIndicator->end(); return false; } } + else if (xConverter1 && xFastParser) + { + auto pImport = dynamic_cast<SvXMLImport*>(xFastParser.get()); + assert(pImport); + Reference<XDocumentHandler> xLegacyDocHandler = new SvXMLLegacyToFastDocHandler(pImport); + if (!xConverter1->importer(aDescriptor,xLegacyDocHandler,msUserData)) { + if (xStatusIndicator.is()) + xStatusIndicator->end(); + return false; + } + } + else + { + SAL_WARN("filter.xmlfa", "no working combination found"); + assert(false); + if (xStatusIndicator.is()) + xStatusIndicator->end(); + return false; + } } catch( const Exception& ) { |