diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-05-29 20:24:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-06-01 11:59:06 +0200 |
commit | 5e68d6cfade45f40b1ad46025a81afe4cb8dd337 (patch) | |
tree | af7740f3636e6b303371c764bfe7ff083e847879 /filter | |
parent | f15a6e1b1b186bf42e1ade05630d17841add2c46 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/Library_odfflatxml.mk | 1 | ||||
-rw-r--r-- | filter/Library_xmlfa.mk | 1 | ||||
-rw-r--r-- | filter/source/odfflatxml/OdfFlatXml.cxx | 25 | ||||
-rw-r--r-- | filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx | 17 | ||||
-rw-r--r-- | filter/source/xsltfilter/XSLTFilter.cxx | 31 |
5 files changed, 38 insertions, 37 deletions
diff --git a/filter/Library_odfflatxml.mk b/filter/Library_odfflatxml.mk index 176530035ddd..dd37086ab210 100644 --- a/filter/Library_odfflatxml.mk +++ b/filter/Library_odfflatxml.mk @@ -27,6 +27,7 @@ $(eval $(call gb_Library_use_libraries,odfflatxml,\ cppuhelper \ cppu \ sal \ + sax \ )) $(eval $(call gb_Library_add_exception_objects,odfflatxml,\ diff --git a/filter/Library_xmlfa.mk b/filter/Library_xmlfa.mk index e1157cca3059..7310b18149d8 100644 --- a/filter/Library_xmlfa.mk +++ b/filter/Library_xmlfa.mk @@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,xmlfa,\ cppuhelper \ cppu \ sal \ + sax \ tl \ utl \ xo \ diff --git a/filter/source/odfflatxml/OdfFlatXml.cxx b/filter/source/odfflatxml/OdfFlatXml.cxx index 4c838ab5f40e..0c76d193eb3b 100644 --- a/filter/source/odfflatxml/OdfFlatXml.cxx +++ b/filter/source/odfflatxml/OdfFlatXml.cxx @@ -23,19 +23,19 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/xml/XImportFilter.hpp> -#include <com/sun/star/xml/XImportFilter2.hpp> #include <com/sun/star/xml/XExportFilter.hpp> #include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/Writer.hpp> -#include <com/sun/star/xml/sax/XFastParser.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/io/XSeekable.hpp> #include <comphelper/diagnose_ex.hxx> +#include <sax/ximportfilter2.hxx> +#include <sax/xfastparser.hxx> using namespace ::cppu; using namespace ::osl; @@ -55,8 +55,9 @@ namespace filter::odfflatxml { * OdfFlatXml export and imports ODF flat XML documents by plugging a pass-through * filter implementation into XmlFilterAdaptor. */ - class OdfFlatXml : public WeakImplHelper<XImportFilter, XImportFilter2, - XExportFilter, DocumentHandlerAdapter, css::lang::XServiceInfo> + class OdfFlatXml : public WeakImplHelper<XImportFilter, + XExportFilter, DocumentHandlerAdapter, css::lang::XServiceInfo>, + public XImportFilter2 { private: Reference< XComponentContext > m_xContext; @@ -75,9 +76,9 @@ namespace filter::odfflatxml { const Sequence< OUString >& userData) override; // XImportFilter2 - virtual sal_Bool SAL_CALL + virtual bool importer(const Sequence< PropertyValue >& sourceData, - const Reference< XFastParser >& fastParser, + XFastParser& fastParser, const Sequence< OUString >& userData) override; // XExportFilter @@ -142,9 +143,9 @@ OdfFlatXml::importer( if ( xSeekable.is() ) xSeekable->seek( 0 ); - css::uno::Reference< css::xml::sax::XFastParser > xFastParser (docHandler, UNO_QUERY ); - if( xFastParser.is() ) - xFastParser->parseStream( inputSource ); + XFastParser* pFastParser = dynamic_cast<XFastParser*>(docHandler.get()); + if( pFastParser ) + pFastParser->parseStream( inputSource ); else { Reference<XParser> saxParser = Parser::create(m_xContext); @@ -165,10 +166,10 @@ OdfFlatXml::importer( return true; } -sal_Bool +bool OdfFlatXml::importer( const Sequence< PropertyValue >& sourceData, - const Reference< XFastParser >& xFastParser, + XFastParser& rFastParser, const Sequence< OUString >& /* userData */) { // Read InputStream to read from and a URL used for the system id @@ -201,7 +202,7 @@ OdfFlatXml::importer( if ( xSeekable.is() ) xSeekable->seek( 0 ); - xFastParser->parseStream( inputSource ); + rFastParser.parseStream( inputSource ); } catch (const Exception &) { diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index 525f567b67c0..0fa97b717104 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -25,7 +25,6 @@ #include "XmlFilterAdaptor.hxx" #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/xml/XImportFilter.hpp> -#include <com/sun/star/xml/XImportFilter2.hpp> #include <com/sun/star/xml/XExportFilter.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> @@ -42,7 +41,7 @@ #include <cppuhelper/supportsservice.hxx> #include <unotools/pathoptions.hxx> #include <xmloff/xmlimp.hxx> - +#include <sax/ximportfilter2.hxx> #include <strings.hrc> using namespace comphelper; @@ -132,7 +131,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& xStatusIndicator->setValue(nSteps++); Reference< XImportFilter > xConverter1( xConvBridge, UNO_QUERY ); - Reference< XImportFilter2 > xConverter2( xConvBridge, UNO_QUERY ); + XImportFilter2* pConverter2 = dynamic_cast<XImportFilter2*>(xConvBridge.get()); // prevent unnecessary broadcasting when loading Reference< XModel > xModel( mxDoc, UNO_QUERY ); @@ -170,12 +169,12 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& // Calling Filtering Component try { - Reference < XFastParser > xFastParser( xFilter, UNO_QUERY ); // SvXMLImport subclasses + XFastParser* pFastParser = dynamic_cast<XFastParser*>( xFilter.get() ); // SvXMLImport subclasses Reference < XDocumentHandler > xDocHandler( xFilter, UNO_QUERY ); // XMLTransformer subclasses - assert(xFastParser || xDocHandler); - if (xConverter2 && xFastParser) + assert(pFastParser || xDocHandler); + if (pConverter2 && pFastParser) { - if (!xConverter2->importer(aDescriptor,xFastParser,msUserData)) { + if (!pConverter2->importer(aDescriptor,*pFastParser,msUserData)) { if (xStatusIndicator.is()) xStatusIndicator->end(); return false; @@ -189,9 +188,9 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& return false; } } - else if (xConverter1 && xFastParser) + else if (xConverter1 && pFastParser) { - auto pImport = static_cast<SvXMLImport*>(xFastParser.get()); + auto pImport = static_cast<SvXMLImport*>(pFastParser); Reference<XDocumentHandler> xLegacyDocHandler = new SvXMLLegacyToFastDocHandler(pImport); if (!xConverter1->importer(aDescriptor,xLegacyDocHandler,msUserData)) { if (xStatusIndicator.is()) diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx index 44f9ce4d8172..3ceb2a002cc8 100644 --- a/filter/source/xsltfilter/XSLTFilter.cxx +++ b/filter/source/xsltfilter/XSLTFilter.cxx @@ -46,10 +46,8 @@ #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> -#include <com/sun/star/xml/sax/XFastParser.hpp> #include <com/sun/star/xml/sax/Writer.hpp> #include <com/sun/star/xml/XImportFilter.hpp> -#include <com/sun/star/xml/XImportFilter2.hpp> #include <com/sun/star/xml/XExportFilter.hpp> #include <com/sun/star/util/theMacroExpander.hpp> @@ -66,6 +64,8 @@ #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> #include <com/sun/star/xml/xslt/XSLTTransformer.hpp> +#include <sax/ximportfilter2.hxx> +#include <sax/xfastparser.hxx> #include <utility> #define TRANSFORMATION_TIMEOUT_SEC 60 @@ -118,8 +118,8 @@ namespace XSLT * supporting service from an extension for a specific filter; the * service must support com.sun.star.xml.xslt.XSLT2Transformer. */ - class XSLTFilter : public WeakImplHelper<XImportFilter, XImportFilter2, XExportFilter, - ExtendedDocumentHandlerAdapter, XServiceInfo> + class XSLTFilter : public WeakImplHelper<XImportFilter, XExportFilter, + ExtendedDocumentHandlerAdapter, XServiceInfo>, public XImportFilter2 { friend class XSLTFilterStreamListener; private: @@ -162,9 +162,9 @@ namespace XSLT const Sequence<OUString>& msUserData) override; // XImportFilter2 - virtual sal_Bool SAL_CALL - importer(const Sequence<PropertyValue>& aSourceData, const css::uno::Reference< - XFastParser>& xFastParser, + virtual bool + importer(const Sequence<PropertyValue>& aSourceData, + XFastParser& xFastParser, const Sequence<OUString>& msUserData) override; // XExportFilter @@ -362,8 +362,8 @@ namespace XSLT aInput.sPublicId = aURL; aInput.aInputStream = pipein; - css::uno::Reference< css::xml::sax::XFastParser > xFastParser( - xHandler, css::uno::UNO_QUERY ); + XFastParser* pFastParser = dynamic_cast<XFastParser*>( + xHandler.get() ); // transform m_tcontrol->start(); @@ -394,8 +394,8 @@ namespace XSLT result = m_cTransformed.wait(&timeout); }; if (!m_bError) { - if( xFastParser.is() ) - xFastParser->parseStream( aInput ); + if( pFastParser ) + pFastParser->parseStream( aInput ); else { // create SAX parser that will read the document file @@ -422,9 +422,9 @@ namespace XSLT } } - sal_Bool + bool XSLTFilter::importer(const Sequence<PropertyValue>& aSourceData, - const css::uno::Reference<XFastParser>& xFastParser, const Sequence< + XFastParser& rFastParser, const Sequence< OUString>& msUserData) { if (msUserData.getLength() < 5) @@ -461,10 +461,9 @@ namespace XSLT Any(NamedValue("SourceBaseURL", Any(INetURLObject(aURL).getBase()))) }; m_tcontrol = impl_createTransformer(msUserData[1], args); - assert(xFastParser.is()); OSL_ASSERT(xInputStream.is()); OSL_ASSERT(m_tcontrol.is()); - if (xFastParser.is() && xInputStream.is() && m_tcontrol.is()) + if (xInputStream.is() && m_tcontrol.is()) { try { @@ -521,7 +520,7 @@ namespace XSLT result = m_cTransformed.wait(&timeout); }; if (!m_bError) - xFastParser->parseStream( aInput ); + rFastParser.parseStream( aInput ); m_tcontrol->terminate(); return !m_bError; } |