diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-16 13:24:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-16 17:45:17 +0200 |
commit | 3dd9fb3076511faa94363be56d416fdfa8249c30 (patch) | |
tree | 26711e0ee00d034ea7f8def0dd74e2a7f319aa15 | |
parent | f586c0c9257473d92936a91d632a4a408a36275e (diff) |
svx: use the fastparser API when possible
part of the process of making SvXMLImport fastparser-only
Change-Id: I30aa8a429fabf54e39cf401419f627cc13ed719c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104427
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | svx/source/xml/xmlexport.cxx | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/svx/source/xml/xmlexport.cxx b/svx/source/xml/xmlexport.cxx index 5f179873b0ca..e36f6f5191b7 100644 --- a/svx/source/xml/xmlexport.cxx +++ b/svx/source/xml/xmlexport.cxx @@ -185,9 +185,6 @@ bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStr xml::sax::InputSource aParserInput; aParserInput.aInputStream = xInputStream; - // get parser - Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext ); - // prepare filter arguments Sequence<Any> aFilterArgs( 2 ); Any *pArgs = aFilterArgs.getArray(); @@ -195,26 +192,20 @@ bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStr *pArgs++ <<= xObjectResolver; // get filter - Reference< xml::sax::XDocumentHandler > xFilter( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii( pImportService ), aFilterArgs, xContext), UNO_QUERY ); - uno::Reference< xml::sax::XFastParser > xFastParser = dynamic_cast< - xml::sax::XFastParser* >( xFilter.get() ); - DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." ); + Reference< XInterface > xFilter = xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii( pImportService ), aFilterArgs, xContext); + SAL_WARN_IF( !xFilter, "svx", "Can't instantiate filter component " << pImportService); + uno::Reference< xml::sax::XFastParser > xFastParser( xFilter, UNO_QUERY ); + assert(xFastParser); bRet = false; - if( xParser.is() && xFilter.is() ) + if( xFastParser.is() ) { - // connect parser and filter - xParser->setDocumentHandler( xFilter ); - // connect model and filter uno::Reference < document::XImporter > xImporter( xFilter, UNO_QUERY ); xImporter->setTargetDocument( xTargetDocument ); // finally, parser the stream - if( xFastParser.is() ) - xFastParser->parseStream( aParserInput ); - else - xParser->parseStream( aParserInput ); + xFastParser->parseStream( aParserInput ); bRet = true; } |