From 3d31d8157208e9300a6bf7d102a413b9c181b4fd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 4 Jul 2020 13:01:46 +0200 Subject: comphelper: create instances with uno constructors See tdf#74608 for motivation Change-Id: Ib7aa69cdf62992cea38a60aac9169c2f1779c1cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98094 Tested-by: Jenkins Reviewed-by: Noel Grandin --- comphelper/Library_comphelper.mk | 1 - comphelper/source/container/enumerablemap.cxx | 40 ++++------------- comphelper/source/inc/comphelper_services.hxx | 29 ------------ comphelper/source/misc/comphelper_services.cxx | 62 -------------------------- comphelper/util/comphelp.component | 5 ++- 5 files changed, 11 insertions(+), 126 deletions(-) delete mode 100644 comphelper/source/inc/comphelper_services.hxx delete mode 100644 comphelper/source/misc/comphelper_services.cxx (limited to 'comphelper') diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk index 7a8d5bd6f3a6..9a814e17d5bf 100644 --- a/comphelper/Library_comphelper.mk +++ b/comphelper/Library_comphelper.mk @@ -97,7 +97,6 @@ $(eval $(call gb_Library_add_exception_objects,comphelper,\ comphelper/source/misc/backupfilehelper \ comphelper/source/misc/base64 \ comphelper/source/misc/comphelper_module \ - comphelper/source/misc/comphelper_services \ comphelper/source/misc/componentbase \ comphelper/source/misc/componentmodule \ comphelper/source/misc/configuration \ diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx index f5c7069a17a7..55c2b9e28077 100644 --- a/comphelper/source/container/enumerablemap.cxx +++ b/comphelper/source/container/enumerablemap.cxx @@ -19,7 +19,6 @@ #include -#include #include #include #include @@ -153,8 +152,9 @@ namespace comphelper class EnumerableMap: public Map_IFace, public ComponentBase { - protected: + public: EnumerableMap(); + protected: virtual ~EnumerableMap() override; // XInitialization @@ -184,12 +184,6 @@ namespace comphelper virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; - public: - // XServiceInfo, static version (used for component registration) - static OUString getImplementationName_static( ); - static Sequence< OUString > getSupportedServiceNames_static( ); - static Reference< XInterface > Create( const Reference< XComponentContext >& ); - private: void impl_initValues_throw( const Sequence< Pair< Any, Any > >& _initialValues ); @@ -645,7 +639,7 @@ namespace comphelper OUString SAL_CALL EnumerableMap::getImplementationName( ) { - return getImplementationName_static(); + return "org.openoffice.comp.comphelper.EnumerableMap"; } sal_Bool SAL_CALL EnumerableMap::supportsService( const OUString& _serviceName ) @@ -656,29 +650,9 @@ namespace comphelper Sequence< OUString > SAL_CALL EnumerableMap::getSupportedServiceNames( ) { - return getSupportedServiceNames_static(); - } - - - OUString EnumerableMap::getImplementationName_static( ) - { - return "org.openoffice.comp.comphelper.EnumerableMap"; - } - - - Sequence< OUString > EnumerableMap::getSupportedServiceNames_static( ) - { - Sequence< OUString > aServiceNames { "com.sun.star.container.EnumerableMap" }; - return aServiceNames; + return { "com.sun.star.container.EnumerableMap" }; } - - Reference< XInterface > EnumerableMap::Create( SAL_UNUSED_PARAMETER const Reference< XComponentContext >& ) - { - return *new EnumerableMap; - } - - bool MapEnumerator::hasMoreElements() { if ( m_disposed ) @@ -729,9 +703,11 @@ namespace comphelper } // namespace comphelper -void createRegistryInfo_Map() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +org_openoffice_comp_comphelper_EnumerableMap( + css::uno::XComponentContext*, css::uno::Sequence const&) { - ::comphelper::module::OAutoRegistration< ::comphelper::EnumerableMap > aAutoRegistration; + return cppu::acquire(new comphelper::EnumerableMap()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx deleted file mode 100644 index cfb720119d89..000000000000 --- a/comphelper/source/inc/comphelper_services.hxx +++ /dev/null @@ -1,29 +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 . - */ - -#ifndef INCLUDED_COMPHELPER_SOURCE_INC_COMPHELPER_SERVICES_HXX -#define INCLUDED_COMPHELPER_SOURCE_INC_COMPHELPER_SERVICES_HXX - -#include - -void createRegistryInfo_Map(); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx deleted file mode 100644 index 4fe3269efcfc..000000000000 --- a/comphelper/source/misc/comphelper_services.cxx +++ /dev/null @@ -1,62 +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 - -#include - -namespace comphelper::module -{ - - - namespace - { - class doInitialize - { - public: - doInitialize() - { - createRegistryInfo_Map(); - } - }; - - struct theInitializer : public rtl::Static< doInitialize, theInitializer > {}; - } - - static void initializeModule() - { - // coverity[side_effect_free : FALSE] - not actually side-effect-free - theInitializer::get(); - } - - -} // namespace comphelper::module - - -extern "C" SAL_DLLPUBLIC_EXPORT void* comphelp_component_getFactory( - const char* pImplementationName, SAL_UNUSED_PARAMETER void*, - SAL_UNUSED_PARAMETER void* ) -{ - ::comphelper::module::initializeModule(); - return ::comphelper::module::ComphelperModule::getInstance().getComponentFactory( pImplementationName ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/comphelper/util/comphelp.component b/comphelper/util/comphelp.component index 5310f04b783a..705e870eb5e0 100644 --- a/comphelper/util/comphelp.component +++ b/comphelper/util/comphelp.component @@ -18,7 +18,7 @@ --> + xmlns="http://openoffice.org/2010/uno-components"> @@ -61,7 +61,8 @@ - + -- cgit