From 67f4ece34ffae7404eaefc0286dfbe3ad64289ea Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 6 Jul 2020 10:04:59 +0200 Subject: 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 --- xmlscript/source/inc/unoservices.hxx | 45 --------------------------- xmlscript/source/misc/unoservices.cxx | 49 ------------------------------ xmlscript/source/xml_helper/xml_impctx.cxx | 27 +++++----------- 3 files changed, 8 insertions(+), 113 deletions(-) delete mode 100644 xmlscript/source/inc/unoservices.hxx delete mode 100644 xmlscript/source/misc/unoservices.cxx (limited to 'xmlscript/source') diff --git a/xmlscript/source/inc/unoservices.hxx b/xmlscript/source/inc/unoservices.hxx deleted file mode 100644 index aecdcea30427..000000000000 --- a/xmlscript/source/inc/unoservices.hxx +++ /dev/null @@ -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 - -#include -#include - -namespace com::sun::star::uno { - class XComponentContext; - class XInterface; -} - -namespace xmlscript { - -css::uno::Sequence -getSupportedServiceNames_DocumentHandlerImpl(); - -OUString getImplementationName_DocumentHandlerImpl(); - -css::uno::Reference create_DocumentHandlerImpl( - css::uno::Reference const & xContext); - -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlscript/source/misc/unoservices.cxx b/xmlscript/source/misc/unoservices.cxx deleted file mode 100644 index 31c5e7593a26..000000000000 --- a/xmlscript/source/misc/unoservices.cxx +++ /dev/null @@ -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 - -#include - -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: */ diff --git a/xmlscript/source/xml_helper/xml_impctx.cxx b/xmlscript/source/xml_helper/xml_impctx.cxx index 5bb2f59f50d6..53a24429c0de 100644 --- a/xmlscript/source/xml_helper/xml_impctx.cxx +++ b/xmlscript/source/xml_helper/xml_impctx.cxx @@ -19,7 +19,6 @@ #include -#include #include #include @@ -44,16 +43,6 @@ namespace xmlscript 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; namespace { @@ -363,7 +352,7 @@ inline ExtendedAttributes::ExtendedAttributes( OUString DocumentHandlerImpl::getImplementationName() { - return getImplementationName_DocumentHandlerImpl(); + return "com.sun.star.comp.xml.input.SaxDocumentHandler"; } sal_Bool DocumentHandlerImpl::supportsService( OUString const & servicename ) @@ -373,7 +362,7 @@ sal_Bool DocumentHandlerImpl::supportsService( OUString const & servicename ) Sequence< OUString > DocumentHandlerImpl::getSupportedServiceNames() { - return getSupportedServiceNames_DocumentHandlerImpl(); + return { "com.sun.star.xml.input.SaxDocumentHandler" }; } // XInitialization @@ -716,14 +705,14 @@ Reference< xml::sax::XDocumentHandler > createDocumentHandler( 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 const& ) +{ + return cppu::acquire(static_cast(new xmlscript::DocumentHandlerImpl( + Reference< xml::input::XRoot >(), false /* mt use */ ))); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit