xmlscript: create instances with uno constructors

See tdf#74608 for motivation

Change-Id: I648835e938746ff4f89b05d73d8960f9f8953070
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98191
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-07-06 10:04:59 +02:00
parent 08f6f7e90b
commit 67f4ece34f
6 changed files with 12 additions and 117 deletions

View File

@@ -49,7 +49,6 @@ core_factory_list = [
("libxmlfdlo.a", "xmlfd_component_getFactory"), ("libxmlfdlo.a", "xmlfd_component_getFactory"),
("libxmlfalo.a", "xmlfa_component_getFactory"), ("libxmlfalo.a", "xmlfa_component_getFactory"),
("libodfflatxmllo.a", "odfflatxml_component_getFactory"), ("libodfflatxmllo.a", "odfflatxml_component_getFactory"),
("libxmlscriptlo.a", "xmlscript_component_getFactory"),
("libmcnttype.a", "mcnttype_component_getFactory"), ("libmcnttype.a", "mcnttype_component_getFactory"),
("libvcllo.a", "vcl_component_getFactory"), ("libvcllo.a", "vcl_component_getFactory"),
("libspelllo.a", "spell_component_getFactory", "#ifndef IOS"), ("libspelllo.a", "spell_component_getFactory", "#ifndef IOS"),
@@ -383,6 +382,7 @@ core_constructor_list = [
"com_sun_star_comp_Writer_XMLAutotextEventsExporter_get_implementation", "com_sun_star_comp_Writer_XMLAutotextEventsExporter_get_implementation",
"com_sun_star_comp_Writer_XMLOasisAutotextEventsImporter_get_implementation", "com_sun_star_comp_Writer_XMLOasisAutotextEventsImporter_get_implementation",
# xmlscript/util/xmlscript.component # xmlscript/util/xmlscript.component
"com_sun_star_comp_xml_input_SaxDocumentHandler_get_implementation",
"com_sun_star_comp_xmlscript_XMLBasicExporter", "com_sun_star_comp_xmlscript_XMLBasicExporter",
"com_sun_star_comp_xmlscript_XMLOasisBasicExporter", "com_sun_star_comp_xmlscript_XMLOasisBasicExporter",
# xmlsecurity/util/xmlsecurity.component # xmlsecurity/util/xmlsecurity.component

View File

@@ -36,7 +36,6 @@ $(eval $(call gb_Library_add_defs,xmlscript,\
$(eval $(call gb_Library_set_precompiled_header,xmlscript,xmlscript/inc/pch/precompiled_xmlscript)) $(eval $(call gb_Library_set_precompiled_header,xmlscript,xmlscript/inc/pch/precompiled_xmlscript))
$(eval $(call gb_Library_add_exception_objects,xmlscript,\ $(eval $(call gb_Library_add_exception_objects,xmlscript,\
xmlscript/source/misc/unoservices \
xmlscript/source/xml_helper/xml_byteseq \ xmlscript/source/xml_helper/xml_byteseq \
xmlscript/source/xml_helper/xml_element \ xmlscript/source/xml_helper/xml_element \
xmlscript/source/xml_helper/xml_impctx \ xmlscript/source/xml_helper/xml_impctx \

View File

@@ -1,45 +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 <sal/config.h>
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustring.hxx>
namespace com::sun::star::uno {
class XComponentContext;
class XInterface;
}
namespace xmlscript {
css::uno::Sequence<OUString>
getSupportedServiceNames_DocumentHandlerImpl();
OUString getImplementationName_DocumentHandlerImpl();
css::uno::Reference<css::uno::XInterface> create_DocumentHandlerImpl(
css::uno::Reference<css::uno::XComponentContext> const & xContext);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -1,49 +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 .
*/
#include <cppuhelper/implementationentry.hxx>
#include <unoservices.hxx>
using namespace ::com::sun::star::uno;
namespace xmlscript
{
const struct ::cppu::ImplementationEntry s_entries [] =
{
{
create_DocumentHandlerImpl, getImplementationName_DocumentHandlerImpl,
getSupportedServiceNames_DocumentHandlerImpl, ::cppu::createSingleComponentFactory,
nullptr, 0
},
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
}
extern "C"
{
SAL_DLLPUBLIC_EXPORT void * xmlscript_component_getFactory(
const char * pImplName, void * pServiceManager, void * pRegistryKey )
{
return ::cppu::component_getFactoryHelper(
pImplName, pServiceManager, pRegistryKey, ::xmlscript::s_entries );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -19,7 +19,6 @@
#include <sal/config.h> #include <sal/config.h>
#include <unoservices.hxx>
#include <xml_import.hxx> #include <xml_import.hxx>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
@@ -44,16 +43,6 @@ namespace xmlscript
const sal_Int32 UID_UNKNOWN = -1; const sal_Int32 UID_UNKNOWN = -1;
Sequence< OUString > getSupportedServiceNames_DocumentHandlerImpl()
{
return Sequence< OUString > { "com.sun.star.xml.input.SaxDocumentHandler" };
}
OUString getImplementationName_DocumentHandlerImpl()
{
return "com.sun.star.comp.xml.input.SaxDocumentHandler";
}
typedef std::unordered_map< OUString, sal_Int32 > t_OUString2LongMap; typedef std::unordered_map< OUString, sal_Int32 > t_OUString2LongMap;
namespace { namespace {
@@ -363,7 +352,7 @@ inline ExtendedAttributes::ExtendedAttributes(
OUString DocumentHandlerImpl::getImplementationName() OUString DocumentHandlerImpl::getImplementationName()
{ {
return getImplementationName_DocumentHandlerImpl(); return "com.sun.star.comp.xml.input.SaxDocumentHandler";
} }
sal_Bool DocumentHandlerImpl::supportsService( OUString const & servicename ) sal_Bool DocumentHandlerImpl::supportsService( OUString const & servicename )
@@ -373,7 +362,7 @@ sal_Bool DocumentHandlerImpl::supportsService( OUString const & servicename )
Sequence< OUString > DocumentHandlerImpl::getSupportedServiceNames() Sequence< OUString > DocumentHandlerImpl::getSupportedServiceNames()
{ {
return getSupportedServiceNames_DocumentHandlerImpl(); return { "com.sun.star.xml.input.SaxDocumentHandler" };
} }
// XInitialization // XInitialization
@@ -716,14 +705,14 @@ Reference< xml::sax::XDocumentHandler > createDocumentHandler(
return Reference< xml::sax::XDocumentHandler >(); return Reference< xml::sax::XDocumentHandler >();
} }
Reference< XInterface > create_DocumentHandlerImpl(
SAL_UNUSED_PARAMETER Reference< XComponentContext > const & )
{
return static_cast< ::cppu::OWeakObject * >(
new DocumentHandlerImpl(
Reference< xml::input::XRoot >(), false /* mt use */ ) );
} }
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_xml_input_SaxDocumentHandler_get_implementation(
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& )
{
return cppu::acquire(static_cast<cppu::OWeakObject*>(new xmlscript::DocumentHandlerImpl(
Reference< xml::input::XRoot >(), false /* mt use */ )));
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -18,8 +18,9 @@
--> -->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="xmlscript" xmlns="http://openoffice.org/2010/uno-components"> xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.xml.input.SaxDocumentHandler"> <implementation name="com.sun.star.comp.xml.input.SaxDocumentHandler"
constructor="com_sun_star_comp_xml_input_SaxDocumentHandler_get_implementation">
<service name="com.sun.star.xml.input.SaxDocumentHandler"/> <service name="com.sun.star.xml.input.SaxDocumentHandler"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.xmlscript.XMLBasicExporter" <implementation name="com.sun.star.comp.xmlscript.XMLBasicExporter"