diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-21 21:11:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-22 08:29:20 +0200 |
commit | 188540e37d33debcf1b89eb08e84547c56e19ba2 (patch) | |
tree | 71cf1e0691ea0c6317afc28f5a72c6b9128d5eca /ucb | |
parent | 925b91dacd1c14c91a8246123f285613292ec142 (diff) |
ucb/sorter: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I6d9b20e281238038f9eed1578a64316857cf6247
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99176
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/Library_srtrs1.mk | 1 | ||||
-rw-r--r-- | ucb/source/sorter/sortdynres.cxx | 38 | ||||
-rw-r--r-- | ucb/source/sorter/sortdynres.hxx | 11 | ||||
-rw-r--r-- | ucb/source/sorter/sortmain.cxx | 57 | ||||
-rw-r--r-- | ucb/source/sorter/srtrs1.component | 5 |
5 files changed, 12 insertions, 100 deletions
diff --git a/ucb/Library_srtrs1.mk b/ucb/Library_srtrs1.mk index 9aefed2c8aa4..6ceffd3cc685 100644 --- a/ucb/Library_srtrs1.mk +++ b/ucb/Library_srtrs1.mk @@ -26,7 +26,6 @@ $(eval $(call gb_Library_use_libraries,srtrs1,\ $(eval $(call gb_Library_add_exception_objects,srtrs1,\ ucb/source/sorter/sortdynres \ - ucb/source/sorter/sortmain \ ucb/source/sorter/sortresult \ )) diff --git a/ucb/source/sorter/sortdynres.cxx b/ucb/source/sorter/sortdynres.cxx index 52229f62d7a3..cd5d5f7282b4 100644 --- a/ucb/source/sorter/sortdynres.cxx +++ b/ucb/source/sorter/sortdynres.cxx @@ -94,7 +94,7 @@ sal_Bool SAL_CALL SortedDynamicResultSet::supportsService( const OUString& Servi css::uno::Sequence< OUString > SAL_CALL SortedDynamicResultSet::getSupportedServiceNames() { - return { DYNAMIC_RESULTSET_SERVICE_NAME }; + return { "com.sun.star.ucb.SortedDynamicResultSet" }; } // XComponent methods. @@ -419,11 +419,6 @@ SortedDynamicResultSetFactory::~SortedDynamicResultSetFactory() OUString SAL_CALL SortedDynamicResultSetFactory::getImplementationName() { - return getImplementationName_Static(); -} - -OUString SortedDynamicResultSetFactory::getImplementationName_Static() -{ return "com.sun.star.comp.ucb.SortedDynamicResultSetFactory"; } @@ -434,34 +429,17 @@ sal_Bool SAL_CALL SortedDynamicResultSetFactory::supportsService( const OUString css::uno::Sequence< OUString > SAL_CALL SortedDynamicResultSetFactory::getSupportedServiceNames() { - return getSupportedServiceNames_Static(); -} - -/// @throws css::uno::Exception -static css::uno::Reference< css::uno::XInterface > -SortedDynamicResultSetFactory_CreateInstance( const css::uno::Reference< - css::lang::XMultiServiceFactory> & rSMgr ) -{ - return static_cast<css::lang::XServiceInfo*>( - new SortedDynamicResultSetFactory(ucbhelper::getComponentContext(rSMgr))); -} - -css::uno::Sequence< OUString > SortedDynamicResultSetFactory::getSupportedServiceNames_Static() -{ - css::uno::Sequence<OUString> aSNS { DYNAMIC_RESULTSET_FACTORY_NAME }; - return aSNS; + return { "com.sun.star.ucb.SortedDynamicResultSetFactory" }; } -// Service factory implementation. -css::uno::Reference< css::lang::XSingleServiceFactory > -SortedDynamicResultSetFactory::createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ucb_SortedDynamicResultSetFactory_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return cppu::createOneInstanceFactory( - rxServiceMgr, - SortedDynamicResultSetFactory::getImplementationName_Static(), - SortedDynamicResultSetFactory_CreateInstance, - SortedDynamicResultSetFactory::getSupportedServiceNames_Static() ); + static rtl::Reference<SortedDynamicResultSetFactory> g_Instance(new SortedDynamicResultSetFactory(context)); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(g_Instance.get()); } // SortedDynamicResultSetFactory methods. diff --git a/ucb/source/sorter/sortdynres.hxx b/ucb/source/sorter/sortdynres.hxx index 5a1e3770b6b3..00e7720c0cc2 100644 --- a/ucb/source/sorter/sortdynres.hxx +++ b/ucb/source/sorter/sortdynres.hxx @@ -35,8 +35,6 @@ namespace comphelper { class OInterfaceContainerHelper2; } -#define DYNAMIC_RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedDynamicResultSet" -#define DYNAMIC_RESULTSET_FACTORY_NAME "com.sun.star.ucb.SortedDynamicResultSetFactory" class SortedDynamicResultSetListener; @@ -155,18 +153,11 @@ public: // XServiceInfo - - static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory( - const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr ); - - // XSortedDynamicResultSetFactory - virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - static OUString getImplementationName_Static(); - static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); + // XSortedDynamicResultSetFactory virtual css::uno::Reference< css::ucb::XDynamicResultSet > SAL_CALL createSortedDynamicResultSet( const css::uno::Reference< css::ucb::XDynamicResultSet > & Source, diff --git a/ucb/source/sorter/sortmain.cxx b/ucb/source/sorter/sortmain.cxx deleted file mode 100644 index 9d3706917e78..000000000000 --- a/ucb/source/sorter/sortmain.cxx +++ /dev/null @@ -1,57 +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 "sortdynres.hxx" -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; - - -extern "C" SAL_DLLPUBLIC_EXPORT void * srtrs1_component_getFactory( - const char * pImplName, void * pServiceManager, void * ) -{ - void * pRet = nullptr; - - Reference< XMultiServiceFactory > xSMgr( - static_cast< XMultiServiceFactory * >( pServiceManager ) ); - Reference< XSingleServiceFactory > xFactory; - - - // SortedDynamicResultSetFactory. - - - if ( SortedDynamicResultSetFactory::getImplementationName_Static(). - equalsAscii( pImplName ) ) - { - xFactory = SortedDynamicResultSetFactory::createServiceFactory( xSMgr ); - } - - - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/source/sorter/srtrs1.component b/ucb/source/sorter/srtrs1.component index 836be559940c..d3d26136002f 100644 --- a/ucb/source/sorter/srtrs1.component +++ b/ucb/source/sorter/srtrs1.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="srtrs1" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.ucb.SortedDynamicResultSetFactory"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.ucb.SortedDynamicResultSetFactory" + constructor="ucb_SortedDynamicResultSetFactory_get_implementation"> <service name="com.sun.star.ucb.SortedDynamicResultSetFactory"/> </implementation> </component> |