[Libreoffice-commits] core.git: package/Library_xstor.mk package/source solenv/bin

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 26 08:41:51 UTC 2020


 package/Library_xstor.mk             |    1 
 package/source/xstor/register.cxx    |   56 -----------------------------------
 package/source/xstor/xfactory.cxx    |   32 ++++++++------------
 package/source/xstor/xfactory.hxx    |    9 -----
 package/source/xstor/xstor.component |    5 +--
 solenv/bin/native-code.py            |    3 +
 6 files changed, 18 insertions(+), 88 deletions(-)

New commits:
commit 5406f8a3cd53ada63472bd62e5b9a886e2866c6f
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Jul 25 11:12:15 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 26 10:41:17 2020 +0200

    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 at collabora.co.uk>

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>
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index e0ef388dd818..fe98b0032674 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -23,7 +23,6 @@ core_factory_list = [
     ("libi18npoollo.a", "i18npool_component_getFactory"),
     ("libsmlo.a", "sm_component_getFactory"),
     ("libucb1.a", "ucb_component_getFactory"),
-    ("libxstor.a", "xstor_component_getFactory"),
     ("libvcllo.a", "vcl_component_getFactory"),
     ("libsvtlo.a", "svt_component_getFactory"),
     ]
@@ -245,6 +244,8 @@ core_constructor_list = [
     ("lingucomponent_SpellChecker_get_implementation", "#ifndef IOS"),
     "lingucomponent_LangGuess_get_implementation",
     "lingucomponent_Hyphenator_get_implementation",
+# package/source/xstor/xstor.component
+    "package_OStorageFactory_get_implementation",
 # package/util/package2.component
     "package_OZipFileAccess_get_implementation",
     "package_ZipPackage_get_implementation",


More information about the Libreoffice-commits mailing list