From 5e68d6cfade45f40b1ad46025a81afe4cb8dd337 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 29 May 2023 20:24:02 +0200 Subject: Convert XFastParser into a normal C++ interface There is no need for it to be an UNO interface anymore (ever since we started supporting dynamic_cast on UNO objects). Which means that XImportFilter2 also needs become a C++ interface. Change-Id: Ice2db0f098271bba32b199bd083b08cb8410ce93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152388 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/swg/SwXMLTextBlocks1.cxx | 18 +++++++++--------- sw/source/filter/xml/swxml.cxx | 10 +++++----- sw/source/uibase/config/StoredChapterNumbering.cxx | 1 + 3 files changed, 15 insertions(+), 14 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx index e8a2b088e67c..ffe4872dc28f 100644 --- a/sw/source/core/swg/SwXMLTextBlocks1.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -114,7 +114,7 @@ ErrCode SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx ) uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = new SwXMLTextBlockTokenHandler(); // connect parser and filter - uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); + rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; xParser->setFastDocumentHandler( xFilter ); xParser->setTokenHandler( xTokenHandler ); @@ -214,16 +214,16 @@ ErrCode SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx, // parse the stream try { - Reference xFastParser(xFilterInt, UNO_QUERY); + XFastParser* pFastParser = dynamic_cast(xFilterInt.get()); Reference xFastDocHandler(xFilterInt, UNO_QUERY); - if (xFastParser) + if (pFastParser) { - xFastParser->parseStream(aParserInput); + pFastParser->parseStream(aParserInput); } else if (xFastDocHandler) { - Reference xParser - = css::xml::sax::FastParser::create(xContext); + rtl::Reference xParser + = new sax_fastparser::FastSaxParser; xParser->setFastDocumentHandler(xFastDocHandler); xParser->parseStream(aParserInput); } @@ -297,7 +297,7 @@ ErrCode SwXMLTextBlocks::GetBlockText( std::u16string_view rShort, OUString& rTe uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = new SwXMLTextBlockTokenHandler(); // connect parser and filter - uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); + rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; xParser->setFastDocumentHandler( xFilter ); xParser->setTokenHandler( xTokenHandler ); @@ -421,7 +421,7 @@ void SwXMLTextBlocks::ReadInfo() uno::Reference< xml::sax::XFastTokenHandler > xTokenHandler = new SwXMLBlockListTokenHandler(); // connect parser and filter - uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); + rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; xParser->setFastDocumentHandler( xFilter ); xParser->registerNamespace( "http://openoffice.org/2001/block-list", FastToken::NAMESPACE | XML_NAMESPACE_BLOCKLIST ); xParser->setTokenHandler( xTokenHandler ); diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index b679f111a3b6..31ee26289830 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -159,11 +159,11 @@ ErrCode ReadThroughComponent( if( !xFilter.is() ) return ERR_SWG_READ_ERROR; // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler - uno::Reference< xml::sax::XFastParser > xFastParser(xFilter, UNO_QUERY); + XFastParser* pFastParser = dynamic_cast(xFilter.get()); uno::Reference< xml::sax::XDocumentHandler > xDocumentHandler; - if (!xFastParser) + if (!pFastParser) xDocumentHandler.set(xFilter, UNO_QUERY); - if (!xDocumentHandler && !xFastParser) + if (!xDocumentHandler && !pFastParser) { SAL_WARN("sd", "service does not implement XFastParser or XDocumentHandler"); assert(false); @@ -177,8 +177,8 @@ ErrCode ReadThroughComponent( // finally, parse the stream try { - if (xFastParser) - xFastParser->parseStream( aParserInput ); + if (pFastParser) + pFastParser->parseStream( aParserInput ); else { uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(rxContext); diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx index fd3cb6e4a39c..eab7ad13022c 100644 --- a/sw/source/uibase/config/StoredChapterNumbering.cxx +++ b/sw/source/uibase/config/StoredChapterNumbering.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include -- cgit