diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk index 05697c36eaff..54bc946766d8 100644 --- a/chart2/Library_chartcore.mk +++ b/chart2/Library_chartcore.mk @@ -48,7 +48,6 @@ $(eval $(call gb_Library_use_libraries,chartcore,\ i18nlangtag \ sal \ salhelper \ - sax \ sfx \ svl \ svt \ diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index 6362fc91beed..6eccb22be375 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -44,11 +44,11 @@ #include #include #include +#include #include #include #include #include -#include using namespace ::com::sun::star; @@ -463,9 +463,9 @@ ErrCode XMLFilter::impl_ImportStream( aParserInput.aInputStream.set(xInputStream, uno::UNO_QUERY_THROW); // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler - XFastParser* pFastParser = dynamic_cast(xFilter.get()); - if (pFastParser) - pFastParser->parseStream(aParserInput); + Reference< xml::sax::XFastParser > xFastParser(xFilter, uno::UNO_QUERY); + if (xFastParser.is()) + xFastParser->parseStream(aParserInput); else { Reference xParser = xml::sax::Parser::create(m_xContext); diff --git a/chart2/source/model/inc/XMLFilter.hxx b/chart2/source/model/inc/XMLFilter.hxx index e8a2890c0b24..c26587c3ebad 100644 --- a/chart2/source/model/inc/XMLFilter.hxx +++ b/chart2/source/model/inc/XMLFilter.hxx @@ -36,6 +36,9 @@ namespace com::sun::star { namespace embed { class XStorage; } + namespace xml::sax { + class XFastParser; + } namespace document { class XGraphicStorageHandler; } diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index c32022e4e6dc..318da6536df9 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -71,7 +72,6 @@ #include #include #include -#include using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::uno; @@ -2278,7 +2278,7 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp( uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SvXMLExceptionListImport ( xContext, *rpLst ); // connect parser and filter - rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create( xContext ); uno::Reference xTokenHandler = new SvXMLAutoCorrectTokenHandler; xParser->setFastDocumentHandler( xFilter ); xParser->registerNamespace( "http://openoffice.org/2001/block-list", SvXMLAutoCorrectToken::NAMESPACE ); @@ -2385,7 +2385,7 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList() aParserInput.aInputStream = xStrm->getInputStream(); // get parser - rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); SAL_INFO("editeng", "AutoCorrect Import" ); uno::Reference< xml::sax::XFastDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xContext, pAutocorr_List.get(), rAutoCorrect, xStg ); uno::Reference xTokenHandler = new SvXMLAutoCorrectTokenHandler; diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx index 11c4be560342..d04e37a822bf 100644 --- a/editeng/source/xml/xmltxtimp.cxx +++ b/editeng/source/xml/xmltxtimp.cxx @@ -18,7 +18,6 @@ */ #include -#include #include #include #include diff --git a/filter/Library_odfflatxml.mk b/filter/Library_odfflatxml.mk index dd37086ab210..176530035ddd 100644 --- a/filter/Library_odfflatxml.mk +++ b/filter/Library_odfflatxml.mk @@ -27,7 +27,6 @@ $(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 7310b18149d8..e1157cca3059 100644 --- a/filter/Library_xmlfa.mk +++ b/filter/Library_xmlfa.mk @@ -35,7 +35,6 @@ $(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 0c76d193eb3b..4c838ab5f40e 100644 --- a/filter/source/odfflatxml/OdfFlatXml.cxx +++ b/filter/source/odfflatxml/OdfFlatXml.cxx @@ -23,19 +23,19 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include #include #include -#include -#include using namespace ::cppu; using namespace ::osl; @@ -55,9 +55,8 @@ namespace filter::odfflatxml { * OdfFlatXml export and imports ODF flat XML documents by plugging a pass-through * filter implementation into XmlFilterAdaptor. */ - class OdfFlatXml : public WeakImplHelper, - public XImportFilter2 + class OdfFlatXml : public WeakImplHelper { private: Reference< XComponentContext > m_xContext; @@ -76,9 +75,9 @@ namespace filter::odfflatxml { const Sequence< OUString >& userData) override; // XImportFilter2 - virtual bool + virtual sal_Bool SAL_CALL importer(const Sequence< PropertyValue >& sourceData, - XFastParser& fastParser, + const Reference< XFastParser >& fastParser, const Sequence< OUString >& userData) override; // XExportFilter @@ -143,9 +142,9 @@ OdfFlatXml::importer( if ( xSeekable.is() ) xSeekable->seek( 0 ); - XFastParser* pFastParser = dynamic_cast(docHandler.get()); - if( pFastParser ) - pFastParser->parseStream( inputSource ); + css::uno::Reference< css::xml::sax::XFastParser > xFastParser (docHandler, UNO_QUERY ); + if( xFastParser.is() ) + xFastParser->parseStream( inputSource ); else { Reference saxParser = Parser::create(m_xContext); @@ -166,10 +165,10 @@ OdfFlatXml::importer( return true; } -bool +sal_Bool OdfFlatXml::importer( const Sequence< PropertyValue >& sourceData, - XFastParser& rFastParser, + const Reference< XFastParser >& xFastParser, const Sequence< OUString >& /* userData */) { // Read InputStream to read from and a URL used for the system id @@ -202,7 +201,7 @@ OdfFlatXml::importer( if ( xSeekable.is() ) xSeekable->seek( 0 ); - rFastParser.parseStream( inputSource ); + xFastParser->parseStream( inputSource ); } catch (const Exception &) { diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index 0fa97b717104..525f567b67c0 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -25,6 +25,7 @@ #include "XmlFilterAdaptor.hxx" #include #include +#include #include #include #include @@ -41,7 +42,7 @@ #include #include #include -#include + #include using namespace comphelper; @@ -131,7 +132,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& xStatusIndicator->setValue(nSteps++); Reference< XImportFilter > xConverter1( xConvBridge, UNO_QUERY ); - XImportFilter2* pConverter2 = dynamic_cast(xConvBridge.get()); + Reference< XImportFilter2 > xConverter2( xConvBridge, UNO_QUERY ); // prevent unnecessary broadcasting when loading Reference< XModel > xModel( mxDoc, UNO_QUERY ); @@ -169,12 +170,12 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& // Calling Filtering Component try { - XFastParser* pFastParser = dynamic_cast( xFilter.get() ); // SvXMLImport subclasses + Reference < XFastParser > xFastParser( xFilter, UNO_QUERY ); // SvXMLImport subclasses Reference < XDocumentHandler > xDocHandler( xFilter, UNO_QUERY ); // XMLTransformer subclasses - assert(pFastParser || xDocHandler); - if (pConverter2 && pFastParser) + assert(xFastParser || xDocHandler); + if (xConverter2 && xFastParser) { - if (!pConverter2->importer(aDescriptor,*pFastParser,msUserData)) { + if (!xConverter2->importer(aDescriptor,xFastParser,msUserData)) { if (xStatusIndicator.is()) xStatusIndicator->end(); return false; @@ -188,9 +189,9 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& return false; } } - else if (xConverter1 && pFastParser) + else if (xConverter1 && xFastParser) { - auto pImport = static_cast(pFastParser); + auto pImport = static_cast(xFastParser.get()); Reference 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 3ceb2a002cc8..44f9ce4d8172 100644 --- a/filter/source/xsltfilter/XSLTFilter.cxx +++ b/filter/source/xsltfilter/XSLTFilter.cxx @@ -46,8 +46,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -64,8 +66,6 @@ #include #include #include -#include -#include #include #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, public XImportFilter2 + class XSLTFilter : public WeakImplHelper { friend class XSLTFilterStreamListener; private: @@ -162,9 +162,9 @@ namespace XSLT const Sequence& msUserData) override; // XImportFilter2 - virtual bool - importer(const Sequence& aSourceData, - XFastParser& xFastParser, + virtual sal_Bool SAL_CALL + importer(const Sequence& aSourceData, const css::uno::Reference< + XFastParser>& xFastParser, const Sequence& msUserData) override; // XExportFilter @@ -362,8 +362,8 @@ namespace XSLT aInput.sPublicId = aURL; aInput.aInputStream = pipein; - XFastParser* pFastParser = dynamic_cast( - xHandler.get() ); + css::uno::Reference< css::xml::sax::XFastParser > xFastParser( + xHandler, css::uno::UNO_QUERY ); // transform m_tcontrol->start(); @@ -394,8 +394,8 @@ namespace XSLT result = m_cTransformed.wait(&timeout); }; if (!m_bError) { - if( pFastParser ) - pFastParser->parseStream( aInput ); + if( xFastParser.is() ) + xFastParser->parseStream( aInput ); else { // create SAX parser that will read the document file @@ -422,9 +422,9 @@ namespace XSLT } } - bool + sal_Bool XSLTFilter::importer(const Sequence& aSourceData, - XFastParser& rFastParser, const Sequence< + const css::uno::Reference& xFastParser, const Sequence< OUString>& msUserData) { if (msUserData.getLength() < 5) @@ -461,9 +461,10 @@ 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 (xInputStream.is() && m_tcontrol.is()) + if (xFastParser.is() && xInputStream.is() && m_tcontrol.is()) { try { @@ -520,7 +521,7 @@ namespace XSLT result = m_cTransformed.wait(&timeout); }; if (!m_bError) - rFastParser.parseStream( aInput ); + xFastParser->parseStream( aInput ); m_tcontrol->terminate(); return !m_bError; } diff --git a/include/IwyuFilter_include.yaml b/include/IwyuFilter_include.yaml index c6b3e170645c..7a225d3b9488 100644 --- a/include/IwyuFilter_include.yaml +++ b/include/IwyuFilter_include.yaml @@ -285,6 +285,7 @@ excludelist: # base class has to be a complete type - com/sun/star/lang/XInitialization.hpp - com/sun/star/lang/XServiceInfo.hpp + - com/sun/star/xml/sax/XFastParser.hpp include/svl/numuno.hxx: # base class has to be a complete type - com/sun/star/lang/XUnoTunnel.hpp @@ -432,6 +433,7 @@ excludelist: - com/sun/star/lang/XUnoTunnel.hpp - com/sun/star/xml/sax/XExtendedDocumentHandler.hpp - com/sun/star/xml/sax/XFastDocumentHandler.hpp + - com/sun/star/xml/sax/XFastParser.hpp include/svtools/asynclink.hxx: # unique_ptr needs complete type - osl/mutex.hxx diff --git a/include/sax/fastparser.hxx b/include/sax/fastparser.hxx index 4e884e9c0993..fe388fce21cc 100644 --- a/include/sax/fastparser.hxx +++ b/include/sax/fastparser.hxx @@ -20,10 +20,11 @@ #ifndef INCLUDED_SAX_FASTPARSER_HXX #define INCLUDED_SAX_FASTPARSER_HXX +#include #include #include +#include -#include #include #include @@ -39,8 +40,10 @@ class FastSaxParserImpl; // This class implements the external Parser interface class SAX_DLLPUBLIC FastSaxParser final - : public ::cppu::WeakImplHelper, - public XFastParser + : public ::cppu::WeakImplHelper< + css::lang::XInitialization, + css::xml::sax::XFastParser, + css::lang::XServiceInfo > { std::unique_ptr mpImpl; @@ -52,16 +55,16 @@ public: virtual void SAL_CALL initialize(css::uno::Sequence const& rArguments) override; // XFastParser - virtual void parseStream( const css::xml::sax::InputSource& aInputSource ) override; - virtual void setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override; - virtual void setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override; - virtual void registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override; - virtual OUString getNamespaceURL( std::u16string_view aPrefix ) override; - virtual void setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override; - virtual void setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override; - virtual void setLocale( const css::lang::Locale& rLocale ) override; - virtual void setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override; - virtual void setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override; + virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override; + virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override; + virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override; + virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override; + virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override; + virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override; + virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override; + virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override; + virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override; + virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override; // XServiceInfo virtual OUString SAL_CALL getImplementationName( ) override; diff --git a/include/sax/xfastparser.hxx b/include/sax/xfastparser.hxx deleted file mode 100644 index 84282162db68..000000000000 --- a/include/sax/xfastparser.hxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include -#include -#include - -namespace com::sun::star::xml::sax -{ -struct InputSource; -class XErrorHandler; -class XFastDocumentHandler; -class XEntityResolver; -class XFastTokenHandler; -class XFastNamespaceHandler; -} -namespace com::sun::star::lang -{ -struct Locale; -} - -class SAX_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") XFastParser -{ -public: - virtual ~XFastParser(); - - // XFastParser - virtual void parseStream(const css::xml::sax::InputSource& aInputSource) = 0; - virtual void - setFastDocumentHandler(const css::uno::Reference& Handler) - = 0; - virtual void - setTokenHandler(const css::uno::Reference& Handler) - = 0; - virtual void registerNamespace(const OUString& NamespaceURL, sal_Int32 NamespaceToken) = 0; - virtual OUString getNamespaceURL(std::u16string_view Prefix) = 0; - virtual void setErrorHandler(const css::uno::Reference& Handler) - = 0; - virtual void - setEntityResolver(const css::uno::Reference& Resolver) - = 0; - virtual void setLocale(const css::lang::Locale& rLocale) = 0; - virtual void - setNamespaceHandler(const css::uno::Reference& Handler) - = 0; - virtual void setCustomEntityNames( - const ::css::uno::Sequence<::css::beans::Pair<::rtl::OUString, ::rtl::OUString>>& - replacements) - = 0; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sax/ximportfilter2.hxx b/include/sax/ximportfilter2.hxx deleted file mode 100644 index 9428e46e101e..000000000000 --- a/include/sax/ximportfilter2.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include -#include -#include -#include - -namespace com::sun::star::beans { - struct PropertyValue; -} -class XFastParser; - -class SAX_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") XImportFilter2 -{ -public: - virtual ~XImportFilter2(); - - // XImportFilter2 - virtual bool - importer(const css::uno::Sequence< css::beans::PropertyValue >& sourceData, - XFastParser& fastParser, - const css::uno::Sequence< OUString >& userData) = 0; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 52a60269122a..3287911f1112 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,7 +42,6 @@ #include #include #include -#include #include #include @@ -57,7 +56,6 @@ namespace com::sun::star::document { class XEmbeddedObjectResolver; } namespace com::sun::star::document { class XGraphicStorageHandler; } namespace com::sun::star::embed { class XStorage; } namespace com::sun::star::graphic { class XGraphic; } -namespace com::sun::star::io { class XInputStream; } namespace com::sun::star::task { class XStatusIndicator; } namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::util { class XNumberFormatsSupplier; } @@ -73,8 +71,6 @@ namespace com::sun::star { namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; } namespace comphelper { class AttributeList; } -namespace sax_fastparser { class FastSaxParser; } - namespace xmloff { class RDFaImportHelper; } @@ -184,7 +180,8 @@ class XMLOFF_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") SvXMLImport : public c css::lang::XServiceInfo, css::lang::XInitialization, css::document::XImporter, - css::document::XFilter>, public XFastParser + css::document::XFilter, + css::xml::sax::XFastParser> { friend class SvXMLImportContext; friend class SvXMLLegacyToFastDocHandler; @@ -231,7 +228,7 @@ class XMLOFF_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") SvXMLImport : public c SvXMLImportFlags mnImportFlags; std::set< OUString > m_embeddedFontUrlsKnown; - rtl::Reference< sax_fastparser::FastSaxParser > mxParser; + css::uno::Reference< css::xml::sax::XFastParser > mxParser; rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler; rtl::Reference < comphelper::AttributeList > maNamespaceAttrList; css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler; @@ -334,16 +331,16 @@ public: const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override; // XFastParser - virtual void parseStream( const css::xml::sax::InputSource& aInputSource ) override; - virtual void setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override; - virtual void setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override; - virtual void registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override; - virtual OUString getNamespaceURL( std::u16string_view aPrefix ) override; - virtual void setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override; - virtual void setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override; - virtual void setLocale( const css::lang::Locale& rLocale ) override; - virtual void setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override; - virtual void setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override; + virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override; + virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override; + virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override; + virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override; + virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override; + virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override; + virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override; + virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override; + virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override; + virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override; // XImporter virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override; diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index f266da0e83e7..7ee71bb984c1 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -473,6 +473,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/dom,\ SAXDocumentBuilder \ )) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/xml/sax,\ + FastParser \ FastTokenHandler \ Parser \ Writer \ @@ -4267,6 +4268,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/xml,\ FastAttribute \ XExportFilter \ XImportFilter \ + XImportFilter2 \ )) $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/xml/crypto,\ CipherID \ @@ -4384,6 +4386,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/xml/sax,\ XFastAttributeList \ XFastContextHandler \ XFastDocumentHandler \ + XFastParser \ XFastSAXSerializable \ XFastTokenHandler \ XLocator \ diff --git a/offapi/com/sun/star/xml/XImportFilter2.idl b/offapi/com/sun/star/xml/XImportFilter2.idl new file mode 100644 index 000000000000..3d1ae5bcdae2 --- /dev/null +++ b/offapi/com/sun/star/xml/XImportFilter2.idl @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +module com { module sun { module star { module xml { + + + +/** interface to implement for an XML-based import filter. + Enhanced vs XImportFilter to take a XFastDocumentHandler. + + @since LibreOffice 7.1 + */ +interface XImportFilter2: com::sun::star::uno::XInterface +{ + /** performs the import. + +

The source data (location indicated by aSourceData), + and the XML representation of the document must be generated by calls + to xocHandler (???) methods. + + @param aSourceData + com::sun::star::document::MediaDescriptor + which defines the data source + + @param msUserData + Sequence of strings which contains the user data defined in the + TypeDetection.xml + + @param xFastParser + the fast parser for the XML document, i.e. an SvXMLImport subclass + + @returns + `TRUE` if import process is successful + */ + boolean importer( + [in] sequence< com::sun::star::beans::PropertyValue > aSourceData, + [in] com::sun::star::xml::sax::XFastParser xFastParser, + [in] sequence< string > msUserData ) + raises( com::sun::star::lang::IllegalArgumentException ); +}; + +}; }; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/xml/sax/FastParser.idl b/offapi/com/sun/star/xml/sax/FastParser.idl new file mode 100644 index 000000000000..5eaa3482a22c --- /dev/null +++ b/offapi/com/sun/star/xml/sax/FastParser.idl @@ -0,0 +1,16 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +module com { module sun { module star { module xml { module sax { + +service FastParser: XFastParser; + +}; }; }; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/xml/sax/XFastParser.idl b/offapi/com/sun/star/xml/sax/XFastParser.idl new file mode 100644 index 000000000000..8f17b3ddaf87 --- /dev/null +++ b/offapi/com/sun/star/xml/sax/XFastParser.idl @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +module com { module sun { module star { module xml { module sax { + + +/** specifies a SAX parser that uses integer values for known XML names + (elements, attributes and attribute values). The parser also handles + namespaces and allows to have individual contexts for each XML element. + +

Before parsing is possible you have to set your + XFastDocumentHandler using setFastDocumentHandler(). + +

Parsing starts with calling parseStream(). If the parser + finds a valid XML file with the given InputSource, it calls + XFastDocumentHandler::startDocument() first. + +

This parser generates either "fast" events that use integer token + values for namespaces, elements and attributes or "unknown" events for + elements that are unknown. + +

A namespace is unknown if the namespace URL was not registered with + registerNamespace(). + +

An element is unknown if no XFastTokenHandler is set + or if the XFastTokenHandler does not return a valid + identifier for the elements local name. An element is also unknown if + the elements local name is known but it uses a namespace that is unknown. + +

Setting a XFastTokenHandler with setTokenHandler() + is optional, but without a XFastTokenHandler you will only + get unknown sax events. This can be useful if you are only interested + in the namespace handling and/or the context feature. + +

For each element the parser sends a create child element event to the + elements parent context by calling + XFastContextHandler::createFastChildContext() for known + elements or XFastContextHandler::createUnknownChildContext() + for unknown elements. +
The parent context for the root element is the XFastDocumentHandler + itself. + +

If the parent context returns an empty reference, no further events for + the element and all of its children are created. + +

If a valid context is returned this context gets a start event by a call to + XFastContextHandler::startFastElement() for known elements or + XFastContextHandler::startUnknownElement() for unknown elements. + +

After processing all its child elements the context gets an end event by a call to + XFastContextHandler::endFastElement() for known elements or + XFastContextHandler::endUnknownElement() for unknown elements. + +

It is valid to return one instance of XFastContextHandler more + than once. It is even possible to only use the XFastDocumentHandler + by always returning a reference to itself for each create child context event. + +

After the last element is processed the parser generates an end document + event at the XFastDocumentHandler by calling + XFastDocumentHandler::endDocument(). + + @see http://wiki.openoffice.org/wiki/FastParser +*/ +interface XFastParser: com::sun::star::uno::XInterface +{ + /** parses an XML document from a stream. + +

Set the desired handlers before calling this method.

+ */ + void parseStream( [in] InputSource aInputSource ) + raises( SAXException, com::sun::star::io::IOException ); + + + /** Application must register a document event handler to get + sax events for the parsed stream. + */ + void setFastDocumentHandler( [in] XFastDocumentHandler Handler ); + + + /** must be registered to translate known XML names to integer tokens. + */ + void setTokenHandler( [in] XFastTokenHandler Handler ); + + + /** registers a known namespace url with the given integer token.
+ @param NamespaceURL the namespace URL. + @param NamespaceToken + an integer token that must be greater than FastToken::NAMESPACE. + */ + void registerNamespace( [in] string NamespaceURL, [in] long NamespaceToken ) + raises( com::sun::star::lang::IllegalArgumentException ); + + /** allows an application to register an error event handler. + +

Note that the error handler can throw an exception when an error or + warning occurs. Note that an exception is thrown by the parser when + an unrecoverable (fatal) error occurs.

+ */ + void setErrorHandler( [in] XErrorHandler Handler ); + + /** allows an application to register a DTD-Handler. + */ + void setEntityResolver( [in] XEntityResolver Resolver ); + + /** sets a locale specified for localization of warnings and error messages. + +

Set the language of the error messages. Useful when the parsing + errors will be presented to the user.

+ */ + void setLocale( [in] com::sun::star::lang::Locale locale ); + + /** Gets the namespace url string. + */ + string getNamespaceURL( [in] string prefix ) + raises( com::sun::star::lang::IllegalArgumentException ); + + /** @since LibreOffice 5.3 */ + void setNamespaceHandler( [in] XFastNamespaceHandler Handler); + + /** + * Simulate a DTD file. + * Will allow to use customized entity references like ∞ . + * @since LibreOffice 7.1 + */ + void setCustomEntityNames( [in] sequence< beans::Pair > replacements); +}; + + +}; }; }; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/fastparser.cxx b/oox/source/core/fastparser.cxx index 22ba37c7d671..53e5eb78a849 100644 --- a/oox/source/core/fastparser.cxx +++ b/oox/source/core/fastparser.cxx @@ -20,7 +20,6 @@ #include #include -#include #include #include diff --git a/oox/source/crypto/AgileEngine.cxx b/oox/source/crypto/AgileEngine.cxx index 7a667943d8e2..f7518498171d 100644 --- a/oox/source/crypto/AgileEngine.cxx +++ b/oox/source/crypto/AgileEngine.cxx @@ -26,12 +26,11 @@ #include #include #include -#include +#include #include -#include +#include #include -#include using namespace css; using namespace css::beans; @@ -522,7 +521,7 @@ bool AgileEngine::readEncryptionInfo(uno::Reference & rxInputS Reference xFastDocumentHandler(new AgileDocumentHandler(mInfo)); Reference xFastTokenHandler(new AgileTokenHandler); - rtl::Reference xParser = new sax_fastparser::FastSaxParser; + Reference xParser(css::xml::sax::FastParser::create(comphelper::getProcessComponentContext())); xParser->setFastDocumentHandler(xFastDocumentHandler); xParser->setTokenHandler(xFastTokenHandler); diff --git a/reportdesign/source/filter/xml/xmlfilter.cxx b/reportdesign/source/filter/xml/xmlfilter.cxx index 1ad8d01bffbd..caf2c7b9907c 100644 --- a/reportdesign/source/filter/xml/xmlfilter.cxx +++ b/reportdesign/source/filter/xml/xmlfilter.cxx @@ -226,15 +226,15 @@ static ErrCode ReadThroughComponent( aFilterCompArgsRange[ nArgs++ ] <<= _xProp; // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler - Reference< XInterface > xInstance = - rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sFilterName, aFilterCompArgs, rxContext); - XFastParser* pFastParser = dynamic_cast(xInstance.get()); + Reference< XFastParser > xFastParser( + rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sFilterName, aFilterCompArgs, rxContext), + uno::UNO_QUERY_THROW ); uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream(); // read from the stream return ReadThroughComponent( xInputStream ,xModelComponent ,rxContext - ,pFastParser ); + ,xFastParser ); } diff --git a/sax/qa/cppunit/parser.cxx b/sax/qa/cppunit/parser.cxx index 88e0ebd90cf9..261091fe8769 100644 --- a/sax/qa/cppunit/parser.cxx +++ b/sax/qa/cppunit/parser.cxx @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/sax/source/expatwrap/expwrap.component b/sax/source/expatwrap/expwrap.component index dbc9822c566d..1f72eccf3145 100644 --- a/sax/source/expatwrap/expwrap.component +++ b/sax/source/expatwrap/expwrap.component @@ -27,6 +27,10 @@ constructor="com_sun_star_extensions_xml_sax_Writer_get_implementation"> + + + diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index d92d0de0321d..344dda9cd63e 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -28,13 +27,8 @@ #include #include #include -#include #include -#include #include -#include -#include -#include #include #include #include @@ -1490,9 +1484,9 @@ void FastSaxParser::registerNamespace( const OUString& NamespaceURL, sal_Int32 N mpImpl->registerNamespace(NamespaceURL, NamespaceToken); } -OUString FastSaxParser::getNamespaceURL( std::u16string_view aPrefix ) +OUString FastSaxParser::getNamespaceURL( const OUString& rPrefix ) { - return mpImpl->getNamespaceURL(aPrefix); + return mpImpl->getNamespaceURL(rPrefix); } void FastSaxParser::setErrorHandler( const uno::Reference< xml::sax::XErrorHandler >& Handler ) @@ -1681,9 +1675,5 @@ static bool NormalizeOasisURN( OUString& rName ) return true; } -XFastParser::~XFastParser() {} - -XImportFilter2::~XImportFilter2() {} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/fastparser/legacyfastparser.cxx b/sax/source/fastparser/legacyfastparser.cxx index 8dd5e5379aa0..62e7b8a57a88 100644 --- a/sax/source/fastparser/legacyfastparser.cxx +++ b/sax/source/fastparser/legacyfastparser.cxx @@ -19,16 +19,13 @@ #include #include -#include -#include -#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -118,7 +115,7 @@ public: sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; private: - rtl::Reference< sax_fastparser::FastSaxParser > m_xParser; + Reference< XFastParser > m_xParser; Reference< XDocumentHandler > m_xDocumentHandler; Reference< XFastTokenHandler > m_xTokenHandler; @@ -284,7 +281,7 @@ void SAL_CALL CallbackDocumentHandler::characters( const OUString& aChars ) } SaxLegacyFastParser::SaxLegacyFastParser( ) : m_aNamespaceHandler( new NamespaceHandler ), - m_xParser(new sax_fastparser::FastSaxParser) + m_xParser(FastParser::create(::comphelper::getProcessComponentContext() )) { m_xParser->setNamespaceHandler( m_aNamespaceHandler ); } @@ -311,7 +308,9 @@ void SAL_CALL SaxLegacyFastParser::initialize(Sequence< Any > const& rArguments } else { - m_xParser->initialize( rArguments ); + uno::Reference const xInit(m_xParser, + uno::UNO_QUERY_THROW); + xInit->initialize( rArguments ); } } diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx index d403bc4cff26..3546bfe5f043 100644 --- a/sc/source/filter/xml/xmlwrap.cxx +++ b/sc/source/filter/xml/xmlwrap.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -179,9 +180,9 @@ ErrCode ScXMLImportWrapper::ImportFromComponent(const uno::Reference(xImportInterface.get()); - if (pFastParser) - pFastParser->parseStream( aParserInput ); + uno::Reference< xml::sax::XFastParser > xFastParser(xImportInterface, uno::UNO_QUERY); + if (xFastParser) + xFastParser->parseStream( aParserInput ); else { uno::Reference xParser = xml::sax::Parser::create(xContext); diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx index 65aa70b8fe96..242af4bd3a00 100644 --- a/sd/source/core/CustomAnimationPreset.cxx +++ b/sd/source/core/CustomAnimationPreset.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -225,12 +225,11 @@ Reference< XAnimationNode > implImportEffects( const Reference< XMultiServiceFac aParserInput.aInputStream = xInputStream; // get filter - Reference< XInterface > xInterface( xServiceFactory->createInstance("com.sun.star.comp.Xmloff.AnimationsImport" ) ); - XFastParser* pFilter = dynamic_cast(xInterface.get()); + Reference< xml::sax::XFastParser > xFilter( xServiceFactory->createInstance("com.sun.star.comp.Xmloff.AnimationsImport" ), UNO_QUERY_THROW ); - pFilter->parseStream( aParserInput ); + xFilter->parseStream( aParserInput ); - Reference< XAnimationNodeSupplier > xAnimationNodeSupplier( xInterface, UNO_QUERY_THROW ); + Reference< XAnimationNodeSupplier > xAnimationNodeSupplier( xFilter, UNO_QUERY_THROW ); xRootNode = xAnimationNodeSupplier->getAnimationNode(); } catch (const Exception&) diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index db64ba8e88b6..91c4dc600703 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -647,9 +646,9 @@ void SdDrawDocument::CreateDefaultCellStyles() css::xml::sax::InputSource aParserInput; aParserInput.sPublicId = aURL; aParserInput.aInputStream = xInputStream; - XFastParser* pFastParser = dynamic_cast(xImporter.get()); - if (pFastParser) - pFastParser->parseStream(aParserInput); + Reference xFastParser(xImporter, UNO_QUERY); + if (xFastParser) + xFastParser->parseStream(aParserInput); // Set default fonts, if they were not defined in the xml. vcl::Font aLatinFont, aCJKFont, aCTLFont; diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx index ad36030f5e1c..43c3d0d7766d 100644 --- a/sd/source/filter/xml/sdxmlwrp.cxx +++ b/sd/source/filter/xml/sdxmlwrp.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -198,11 +198,11 @@ ErrCode ReadThroughComponent( SAL_WARN_IF(!xFilter.is(), "sd.filter", "Can't instantiate filter component: " << aFilterName); if( !xFilter.is() ) return SD_XML_READERROR; - XFastParser* pFastParser = dynamic_cast(xFilter.get()); + Reference< xml::sax::XFastParser > xFastParser(xFilter, UNO_QUERY); Reference< xml::sax::XDocumentHandler > xDocumentHandler; - if (!pFastParser) + if (!xFastParser) xDocumentHandler.set(xFilter, UNO_QUERY); - if (!pFastParser && !xDocumentHandler) + if (!xFastParser && !xDocumentHandler) { SAL_WARN("sd", "service does not implement XFastParser or XDocumentHandler"); assert(false); @@ -218,8 +218,8 @@ ErrCode ReadThroughComponent( SAL_INFO( "sd.filter", "parsing stream" ); try { - if (pFastParser) - pFastParser->parseStream( aParserInput ); + if (xFastParser) + xFastParser->parseStream( aParserInput ); else { Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(rxContext); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 431e2455668a..7d1f16c01fd9 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,6 @@ #include #include #include -#include #include #include @@ -1826,12 +1826,12 @@ SfxDocumentMetaData::loadFromStorage( xMsf->createInstanceWithArgumentsAndContext( OUString::createFromAscii(pServiceName), args, m_xContext); assert(xFilter); - XFastParser* pFastParser = dynamic_cast(xFilter.get()); + css::uno::Reference xFastParser(xFilter, css::uno::UNO_QUERY); css::uno::Reference xImp(xFilter, css::uno::UNO_QUERY_THROW); xImp->setTargetDocument(css::uno::Reference(this)); try { - if (pFastParser) - pFastParser->parseStream(input); + if (xFastParser) + xFastParser->parseStream(input); else { css::uno::Reference xDocHandler(xFilter, css::uno::UNO_QUERY_THROW); diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 3469926f95b1..6dc5def61b1a 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -321,6 +321,7 @@ core_constructor_list = [ "package_ManifestReader_get_implementation", "package_ManifestWriter_get_implementation", # sax/source/expatwrap/expwrap.component + "com_sun_star_comp_extensions_xml_sax_FastParser_get_implementation", "com_sun_star_comp_extensions_xml_sax_ParserExpat_get_implementation", "com_sun_star_extensions_xml_sax_Writer_get_implementation", # scripting/util/scriptframe.component diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index be8d80e7aeae..55666de2c6e3 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -5522,7 +5522,6 @@ include/sax/fastparser.hxx include/sax/fshelper.hxx include/sax/tools/converter.hxx include/sax/tools/documenthandleradapter.hxx -include/sax/ximportfilter2.hxx include/sfx2/DocumentMetadataAccess.hxx include/sfx2/Metadatable.hxx include/sfx2/StyleManager.hxx diff --git a/starmath/source/mathml/import.cxx b/starmath/source/mathml/import.cxx index f653705b1391..8a0463283286 100644 --- a/starmath/source/mathml/import.cxx +++ b/starmath/source/mathml/import.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -28,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -394,17 +393,17 @@ ErrCode SmMLImportWrapper::ReadThroughComponentIS( // Finally, parser the stream try { - XFastParser* pFastParser = dynamic_cast(xFilter.get()); + Reference xFastParser(xFilter, UNO_QUERY); Reference xFastDocHandler(xFilter, UNO_QUERY); - if (pFastParser) + if (xFastParser) { - pFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); - pFastParser->parseStream(aParserInput); + xFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); + xFastParser->parseStream(aParserInput); } else if (xFastDocHandler) { - rtl::Reference xParser - = new sax_fastparser::FastSaxParser; + Reference xParser + = css::xml::sax::FastParser::create(rxContext); xParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); xParser->setFastDocumentHandler(xFastDocHandler); xParser->parseStream(aParserInput); diff --git a/starmath/source/mathml/mathmlimport.cxx b/starmath/source/mathml/mathmlimport.cxx index 4fcd1e4dc76c..a33a4015846f 100644 --- a/starmath/source/mathml/mathmlimport.cxx +++ b/starmath/source/mathml/mathmlimport.cxx @@ -22,6 +22,7 @@ into one string, xml parser hands them to us line by line rather than all in one go*/ #include +#include #include #include #include @@ -39,7 +40,6 @@ one go*/ #include #include #include -#include #include #include #include @@ -266,18 +266,18 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent(const Reference(xFilter.get()); + Reference xFastParser(xFilter, UNO_QUERY); Reference xFastDocHandler(xFilter, UNO_QUERY); - if (pFastParser) + if (xFastParser) { if (bUseHTMLMLEntities) - pFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); - pFastParser->parseStream(aParserInput); + xFastParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); + xFastParser->parseStream(aParserInput); } else if (xFastDocHandler) { - rtl::Reference xParser - = new sax_fastparser::FastSaxParser; + Reference xParser + = css::xml::sax::FastParser::create(rxContext); if (bUseHTMLMLEntities) xParser->setCustomEntityNames(starmathdatabase::icustomMathmlHtmlEntities); xParser->setFastDocumentHandler(xFastDocHandler); diff --git a/svx/source/xml/xmlexport.cxx b/svx/source/xml/xmlexport.cxx index 79e65373a496..d6bc3870ce08 100644 --- a/svx/source/xml/xmlexport.cxx +++ b/svx/source/xml/xmlexport.cxx @@ -22,12 +22,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -193,18 +193,18 @@ bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference xFilter = xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii( pImportService ), aFilterArgs, xContext); SAL_WARN_IF( !xFilter, "svx", "Can't instantiate filter component " << pImportService); - XFastParser* pFastParser = dynamic_cast( xFilter.get() ); - assert(pFastParser); + uno::Reference< xml::sax::XFastParser > xFastParser( xFilter, UNO_QUERY ); + assert(xFastParser); bRet = false; - if( pFastParser ) + if( xFastParser.is() ) { // connect model and filter uno::Reference < document::XImporter > xImporter( xFilter, UNO_QUERY ); xImporter->setTargetDocument( xTargetDocument ); // finally, parser the stream - pFastParser->parseStream( aParserInput ); + xFastParser->parseStream( aParserInput ); bRet = true; } diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx index e653f5695872..19c2a66ce1bb 100644 --- a/svx/source/xml/xmlxtimp.cxx +++ b/svx/source/xml/xmlxtimp.cxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx index ffe4872dc28f..e8a2b088e67c 100644 --- a/sw/source/core/swg/SwXMLTextBlocks1.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #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 - rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); xParser->setFastDocumentHandler( xFilter ); xParser->setTokenHandler( xTokenHandler ); @@ -214,16 +214,16 @@ ErrCode SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx, // parse the stream try { - XFastParser* pFastParser = dynamic_cast(xFilterInt.get()); + Reference xFastParser(xFilterInt, UNO_QUERY); Reference xFastDocHandler(xFilterInt, UNO_QUERY); - if (pFastParser) + if (xFastParser) { - pFastParser->parseStream(aParserInput); + xFastParser->parseStream(aParserInput); } else if (xFastDocHandler) { - rtl::Reference xParser - = new sax_fastparser::FastSaxParser; + Reference xParser + = css::xml::sax::FastParser::create(xContext); 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 - rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); 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 - rtl::Reference< sax_fastparser::FastSaxParser > xParser = new sax_fastparser::FastSaxParser; + uno::Reference< xml::sax::XFastParser > xParser = xml::sax::FastParser::create(xContext); 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 31ee26289830..b679f111a3b6 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 - XFastParser* pFastParser = dynamic_cast(xFilter.get()); + uno::Reference< xml::sax::XFastParser > xFastParser(xFilter, UNO_QUERY); uno::Reference< xml::sax::XDocumentHandler > xDocumentHandler; - if (!pFastParser) + if (!xFastParser) xDocumentHandler.set(xFilter, UNO_QUERY); - if (!xDocumentHandler && !pFastParser) + if (!xDocumentHandler && !xFastParser) { SAL_WARN("sd", "service does not implement XFastParser or XDocumentHandler"); assert(false); @@ -177,8 +177,8 @@ ErrCode ReadThroughComponent( // finally, parse the stream try { - if (pFastParser) - pFastParser->parseStream( aParserInput ); + if (xFastParser) + xFastParser->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 eab7ad13022c..fd3cb6e4a39c 100644 --- a/sw/source/uibase/config/StoredChapterNumbering.cxx +++ b/sw/source/uibase/config/StoredChapterNumbering.cxx @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx index 7fd5462d2e60..6b47ab752177 100644 --- a/writerfilter/inc/ooxml/OOXMLDocument.hxx +++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -66,8 +67,6 @@ core API to insert the according elements to the core. */ -namespace sax_fastparser { class FastSaxParser; } - namespace writerfilter::ooxml { @@ -81,7 +80,7 @@ public: /** Returns fast parser for this stream. */ - virtual rtl::Reference getFastParser() = 0; + virtual css::uno::Reference getFastParser() = 0; virtual css::uno::Reference getDocumentStream() = 0; diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index 35f70c01e01b..3a7359df22e4 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -91,7 +91,7 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler, OOXMLStream::Pointer_t savedStream = mpStream; mpStream = pStream; - rtl::Reference xParser(mpStream->getFastParser()); + uno::Reference xParser(mpStream->getFastParser()); if (xParser.is()) { @@ -445,7 +445,7 @@ void OOXMLDocumentImpl::resolve(Stream & rStream) return; } - rtl::Reference xParser(mpStream->getFastParser()); + uno::Reference xParser(mpStream->getFastParser()); if (mxModel.is()) { diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx index eb5a9c36376f..ec65290c6214 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx @@ -22,7 +22,6 @@ #include #include -#include extern OUString customTarget; extern OUString embeddingsTarget; @@ -39,7 +38,7 @@ class OOXMLStreamImpl : public OOXMLStream css::uno::Reference mxStorage; css::uno::Reference mxRelationshipAccess; css::uno::Reference mxDocumentStream; - rtl::Reference mxFastParser; + css::uno::Reference mxFastParser; css::uno::Reference mxFastTokenHandler; StreamType_t mnStreamType; @@ -68,7 +67,7 @@ public: virtual ~OOXMLStreamImpl() override; - virtual rtl::Reference getFastParser() override; + virtual css::uno::Reference getFastParser() override; virtual css::uno::Reference getDocumentStream() override; virtual css::uno::Reference getContext() override; virtual OUString getTargetForId(const OUString & rId) override; diff --git a/writerfilter/source/ooxml/factoryimpl.py b/writerfilter/source/ooxml/factoryimpl.py index 302ecf47eca4..c68d5ba06160 100644 --- a/writerfilter/source/ooxml/factoryimpl.py +++ b/writerfilter/source/ooxml/factoryimpl.py @@ -147,14 +147,15 @@ std::string fastTokenToId(sal_uInt32 nToken) def getFastParser(): - print("""rtl::Reference OOXMLStreamImpl::getFastParser() + print("""uno::Reference OOXMLStreamImpl::getFastParser() { if (!mxFastParser.is()) { - mxFastParser = new sax_fastparser::FastSaxParser; + mxFastParser = css::xml::sax::FastParser::create(mxContext); // the threaded parser is about 20% slower loading writer documents + css::uno::Reference< css::lang::XInitialization > xInit( mxFastParser, css::uno::UNO_QUERY_THROW ); css::uno::Sequence< css::uno::Any > args{ css::uno::Any(OUString("DisableThreadedParser")) }; - mxFastParser->initialize(args); + xInit->initialize(args); """) for url in sorted(ooxUrlAliases.keys()): print(""" mxFastParser->registerNamespace("%s", oox::NMSP_%s);""" % (url, ooxUrlAliases[url])) @@ -169,7 +170,7 @@ def getFastParser(): def createImpl(model): print(""" -#include +#include #include #include "ooxml/OOXMLFactory.hxx" #include "ooxml/OOXMLFastHelper.hxx" diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 979a7233c970..a3c5e6fb31d6 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -75,7 +76,6 @@ #include #include #include -#include #include #include @@ -430,7 +430,7 @@ SvXMLImport::SvXMLImport( { SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" ); InitCtor_(); - mxParser = new sax_fastparser::FastSaxParser; + mxParser = xml::sax::FastParser::create( xContext ); setNamespaceHandler( maNamespaceHandler ); setTokenHandler( xTokenHandler ); if ( !bIsNSMapsInitialized ) @@ -479,9 +479,9 @@ namespace class setFastDocumentHandlerGuard { private: - rtl::Reference mxParser; + css::uno::Reference mxParser; public: - setFastDocumentHandlerGuard(rtl::Reference Parser, + setFastDocumentHandlerGuard(css::uno::Reference Parser, const css::uno::Reference& Handler) : mxParser(std::move(Parser)) { @@ -496,53 +496,53 @@ namespace } // XFastParser -void SvXMLImport::parseStream( const xml::sax::InputSource& aInputSource ) +void SAL_CALL SvXMLImport::parseStream( const xml::sax::InputSource& aInputSource ) { setFastDocumentHandlerGuard aDocumentHandlerGuard(mxParser, mxFastDocumentHandler.is() ? mxFastDocumentHandler : this); mxParser->parseStream(aInputSource); } -void SvXMLImport::setFastDocumentHandler( const uno::Reference< xml::sax::XFastDocumentHandler >& Handler ) +void SAL_CALL SvXMLImport::setFastDocumentHandler( const uno::Reference< xml::sax::XFastDocumentHandler >& Handler ) { mxFastDocumentHandler = Handler; } -void SvXMLImport::setTokenHandler( const uno::Reference< xml::sax::XFastTokenHandler >& Handler ) +void SAL_CALL SvXMLImport::setTokenHandler( const uno::Reference< xml::sax::XFastTokenHandler >& Handler ) { mxParser->setTokenHandler( Handler ); } -void SvXMLImport::registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) +void SAL_CALL SvXMLImport::registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) { mxParser->registerNamespace( NamespaceURL, NamespaceToken ); } -OUString SvXMLImport::getNamespaceURL( std::u16string_view aPrefix ) +OUString SAL_CALL SvXMLImport::getNamespaceURL( const OUString& rPrefix ) { - return mxParser->getNamespaceURL( aPrefix ); + return mxParser->getNamespaceURL( rPrefix ); } -void SvXMLImport::setErrorHandler( const uno::Reference< xml::sax::XErrorHandler >& Handler ) +void SAL_CALL SvXMLImport::setErrorHandler( const uno::Reference< xml::sax::XErrorHandler >& Handler ) { mxParser->setErrorHandler( Handler ); } -void SvXMLImport::setEntityResolver( const uno::Reference< xml::sax::XEntityResolver >& Resolver ) +void SAL_CALL SvXMLImport::setEntityResolver( const uno::Reference< xml::sax::XEntityResolver >& Resolver ) { mxParser->setEntityResolver( Resolver ); } -void SvXMLImport::setLocale( const lang::Locale& rLocale ) +void SAL_CALL SvXMLImport::setLocale( const lang::Locale& rLocale ) { mxParser->setLocale( rLocale ); } -void SvXMLImport::setNamespaceHandler( const uno::Reference< xml::sax::XFastNamespaceHandler >& Handler) +void SAL_CALL SvXMLImport::setNamespaceHandler( const uno::Reference< xml::sax::XFastNamespaceHandler >& Handler) { mxParser->setNamespaceHandler( Handler ); } -void SvXMLImport::setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) +void SAL_CALL SvXMLImport::setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) { mxParser->setCustomEntityNames( replacements ); } @@ -1039,7 +1039,8 @@ void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen } } - mxParser->initialize( { Any(OUString("IgnoreMissingNSDecl")) }); + uno::Reference const xInit(mxParser, uno::UNO_QUERY_THROW); + xInit->initialize( { Any(OUString("IgnoreMissingNSDecl")) }); } // XServiceInfo