diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-25 11:12:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-26 10:41:17 +0200 |
commit | 5406f8a3cd53ada63472bd62e5b9a886e2866c6f (patch) | |
tree | 23afd53569ff019ea10c5604af74d8ca54603ee4 /package | |
parent | 6325046aad1df7f896328834259687e6610dee82 (diff) |
package/xstor: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: If1512d63fd1089f6f8486e32106c68f495a1f3df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99424
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r-- | package/Library_xstor.mk | 1 | ||||
-rw-r--r-- | package/source/xstor/register.cxx | 56 | ||||
-rw-r--r-- | package/source/xstor/xfactory.cxx | 32 | ||||
-rw-r--r-- | package/source/xstor/xfactory.hxx | 9 | ||||
-rw-r--r-- | package/source/xstor/xstor.component | 5 |
5 files changed, 16 insertions, 87 deletions
diff --git a/package/Library_xstor.mk b/package/Library_xstor.mk index 0d894e5d931b..c47b0c1fa8fe 100644 --- a/package/Library_xstor.mk +++ b/package/Library_xstor.mk @@ -35,7 +35,6 @@ $(eval $(call gb_Library_add_exception_objects,xstor,\ package/source/xstor/ohierarchyholder \ package/source/xstor/oseekinstream \ package/source/xstor/owriteablestream \ - package/source/xstor/register \ package/source/xstor/selfterminatefilestream \ package/source/xstor/switchpersistencestream \ package/source/xstor/xfactory \ diff --git a/package/source/xstor/register.cxx b/package/source/xstor/register.cxx deleted file mode 100644 index b4220ac28581..000000000000 --- a/package/source/xstor/register.cxx +++ /dev/null @@ -1,56 +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 <com/sun/star/registry/XRegistryKey.hpp> -#include <com/sun/star/registry/InvalidRegistryException.hpp> -#include <cppuhelper/factory.hxx> - -#include "xfactory.hxx" - -using namespace ::com::sun::star; - -extern "C" { - -SAL_DLLPUBLIC_EXPORT void * xstor_component_getFactory( const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) -{ - void * pRet = nullptr; - - OUString aImplName( OUString::createFromAscii( pImplName ) ); - uno::Reference< lang::XSingleServiceFactory > xFactory; - - if ( pServiceManager && aImplName == OStorageFactory::impl_staticGetImplementationName() ) - { - xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ), - OStorageFactory::impl_staticGetImplementationName(), - OStorageFactory::impl_staticCreateSelfInstance, - OStorageFactory::impl_staticGetSupportedServiceNames() ); - } - - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - -} // extern "C" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx index dcb8dd23a880..f398e5f2b909 100644 --- a/package/source/xstor/xfactory.cxx +++ b/package/source/xstor/xfactory.cxx @@ -66,24 +66,7 @@ static bool CheckPackageSignature_Impl( const uno::Reference< io::XInputStream > return true; // allow to create a storage based on empty stream } -uno::Sequence< OUString > OStorageFactory::impl_staticGetSupportedServiceNames() -{ - uno::Sequence< OUString > aRet(2); - aRet[0] = "com.sun.star.embed.StorageFactory"; - aRet[1] = "com.sun.star.comp.embed.StorageFactory"; - return aRet; -} -OUString OStorageFactory::impl_staticGetImplementationName() -{ - return "com.sun.star.comp.embed.StorageFactory"; -} - -uno::Reference< uno::XInterface > OStorageFactory::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new OStorageFactory( comphelper::getComponentContext(xServiceManager) ) ); -} uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstance() { @@ -285,7 +268,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr OUString SAL_CALL OStorageFactory::getImplementationName() { - return impl_staticGetImplementationName(); + return "com.sun.star.comp.embed.StorageFactory"; } sal_Bool SAL_CALL OStorageFactory::supportsService( const OUString& ServiceName ) @@ -295,7 +278,18 @@ sal_Bool SAL_CALL OStorageFactory::supportsService( const OUString& ServiceName uno::Sequence< OUString > SAL_CALL OStorageFactory::getSupportedServiceNames() { - return impl_staticGetSupportedServiceNames(); + return { "com.sun.star.embed.StorageFactory", + "com.sun.star.comp.embed.StorageFactory" }; +} + + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +package_OStorageFactory_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + static rtl::Reference<OStorageFactory> g_Instance(new OStorageFactory(context)); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(g_Instance.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/xstor/xfactory.hxx b/package/source/xstor/xfactory.hxx index a445f6a4c97a..96033464b874 100644 --- a/package/source/xstor/xfactory.hxx +++ b/package/source/xstor/xfactory.hxx @@ -38,15 +38,6 @@ public: OSL_ENSURE( xContext.is(), "No service manager is provided!" ); } - static css::uno::Sequence< OUString > - impl_staticGetSupportedServiceNames(); - - static OUString impl_staticGetImplementationName(); - - static css::uno::Reference< css::uno::XInterface > - impl_staticCreateSelfInstance( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - // XSingleServiceFactory virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance() override; virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const css::uno::Sequence< css::uno::Any >& aArguments ) override; diff --git a/package/source/xstor/xstor.component b/package/source/xstor/xstor.component index f6c9776b8494..550501f269f6 100644 --- a/package/source/xstor/xstor.component +++ b/package/source/xstor/xstor.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="xstor" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.embed.StorageFactory"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.embed.StorageFactory" + constructor="package_OStorageFactory_get_implementation"> <service name="com.sun.star.comp.embed.StorageFactory"/> <service name="com.sun.star.embed.StorageFactory"/> </implementation> |