[Libreoffice-commits] core.git: sfx2/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sat Oct 17 08:29:11 UTC 2020


 sfx2/source/doc/SfxDocumentMetaData.cxx |   22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

New commits:
commit cfe5a5044845a3fc90e3634e996edb4d85808d3c
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Oct 17 08:08:36 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Oct 17 10:28:29 2020 +0200

    sfx2: use the fastparser API when possible
    
    part of the process of making SvXMLImport fastparser-only
    
    Change-Id: Ib5acae303483eb86338cb39dd97a357ff90b1870
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104453
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 38ba5b33b472..578322556b60 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -1737,7 +1737,6 @@ SfxDocumentMetaData::loadFromStorage(
     // create DOM parser service
     css::uno::Reference<css::lang::XMultiComponentFactory> xMsf (
         m_xContext->getServiceManager());
-    css::uno::Reference<css::xml::sax::XParser> xParser = css::xml::sax::Parser::create(m_xContext);
     css::xml::sax::InputSource input;
     input.aInputStream = xInStream;
 
@@ -1761,21 +1760,18 @@ SfxDocumentMetaData::loadFromStorage(
     css::uno::Sequence< css::uno::Any > args(1);
     args[0] <<= xPropArg;
 
-    css::uno::Reference<css::xml::sax::XDocumentHandler> xDocHandler (
+    // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler
+    css::uno::Reference<XInterface> xFilter =
         xMsf->createInstanceWithArgumentsAndContext(
-            OUString::createFromAscii(pServiceName), args, m_xContext),
-        css::uno::UNO_QUERY_THROW);
-    css::uno::Reference<css::document::XImporter> xImp (xDocHandler,
-        css::uno::UNO_QUERY_THROW);
+            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);
     xImp->setTargetDocument(css::uno::Reference<css::lang::XComponent>(this));
-    xParser->setDocumentHandler(xDocHandler);
-    css::uno::Reference< css::xml::sax::XFastParser > xFastParser = dynamic_cast<
-                            css::xml::sax::XFastParser* >( xDocHandler.get() );
     try {
-        if( xFastParser.is() )
-            xFastParser->parseStream(input);
-        else
-            xParser->parseStream(input);
+        xDocHandler->parseStream(input);
     } catch (const css::xml::sax::SAXException &) {
         throw css::io::WrongFormatException(
                 "SfxDocumentMetaData::loadFromStorage:"


More information about the Libreoffice-commits mailing list