From 09a3b52f883783a2047d77b058d085a3b14e4c9b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 23 Jul 2020 16:36:22 +0200 Subject: extensions/scanner: create instances with uno constructors See tdf#74608 for motivation. Change-Id: Ibf8247cb0321e6c1125a6ee49cdabdc8d4218b22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99325 Tested-by: Jenkins Reviewed-by: Noel Grandin --- extensions/Library_scn.mk | 1 - extensions/source/scanner/scanner.cxx | 26 +++++++---------- extensions/source/scanner/scanner.hxx | 4 --- extensions/source/scanner/scn.component | 5 ++-- extensions/source/scanner/scnserv.cxx | 51 --------------------------------- 5 files changed, 14 insertions(+), 73 deletions(-) delete mode 100644 extensions/source/scanner/scnserv.cxx diff --git a/extensions/Library_scn.mk b/extensions/Library_scn.mk index a95675823495..4fc8788e851d 100644 --- a/extensions/Library_scn.mk +++ b/extensions/Library_scn.mk @@ -40,7 +40,6 @@ $(eval $(call gb_Library_use_libraries,scn,\ )) $(eval $(call gb_Library_add_exception_objects,scn,\ - extensions/source/scanner/scnserv \ extensions/source/scanner/scanner \ )) diff --git a/extensions/source/scanner/scanner.cxx b/extensions/source/scanner/scanner.cxx index ae0bd96893c8..b661a4f7e254 100644 --- a/extensions/source/scanner/scanner.cxx +++ b/extensions/source/scanner/scanner.cxx @@ -21,6 +21,7 @@ #include #include +#include Reference< XInterface > ScannerManager_CreateInstance( const Reference< css::lang::XMultiServiceFactory >& /*rxFactory*/ ) { @@ -49,7 +50,7 @@ Sequence< sal_Int8 > SAL_CALL ScannerManager::getMaskDIB() OUString ScannerManager::getImplementationName() { - return getImplementationName_Static(); + return "com.sun.star.scanner.ScannerManager"; } @@ -61,20 +62,7 @@ sal_Bool ScannerManager::supportsService(OUString const & ServiceName) css::uno::Sequence ScannerManager::getSupportedServiceNames() { - return getSupportedServiceNames_Static(); -} - - -OUString ScannerManager::getImplementationName_Static() throw() -{ - return "com.sun.star.scanner.ScannerManager"; -} - - -Sequence< OUString > ScannerManager::getSupportedServiceNames_Static() throw () -{ - Sequence< OUString > aSNS { "com.sun.star.scanner.ScannerManager" }; - return aSNS; + return { "com.sun.star.scanner.ScannerManager" }; } @@ -90,4 +78,12 @@ void SAL_CALL ScannerManager::initialize(const css::uno::Sequence aProperties.get("ParentWindow") >>= mxDialogParent; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +extensions_ScannerManager_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) +{ + return cppu::acquire(new ScannerManager()); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/scanner/scanner.hxx b/extensions/source/scanner/scanner.hxx index 9f59fccc6957..42e03a4533eb 100644 --- a/extensions/source/scanner/scanner.hxx +++ b/extensions/source/scanner/scanner.hxx @@ -73,10 +73,6 @@ public: virtual void SAL_CALL initialize(const css::uno::Sequence& rArguments) override; - // Misc - static OUString getImplementationName_Static() throw(); - static Sequence< OUString > getSupportedServiceNames_Static() throw(); - #ifdef _WIN32 void* GetData() const { return mpData; } #endif diff --git a/extensions/source/scanner/scn.component b/extensions/source/scanner/scn.component index 6fe7af4ebfda..19215a7c3a91 100644 --- a/extensions/source/scanner/scn.component +++ b/extensions/source/scanner/scn.component @@ -18,8 +18,9 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + diff --git a/extensions/source/scanner/scnserv.cxx b/extensions/source/scanner/scnserv.cxx deleted file mode 100644 index 5c5cca36b0d2..000000000000 --- a/extensions/source/scanner/scnserv.cxx +++ /dev/null @@ -1,51 +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 "scanner.hxx" - -#include - -using namespace com::sun::star::registry; - - -extern "C" SAL_DLLPUBLIC_EXPORT void* scn_component_getFactory( const char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ ) -{ - Reference< css::lang::XSingleServiceFactory > xFactory; - void* pRet = nullptr; - - if( OUString::createFromAscii( pImplName ) == ScannerManager::getImplementationName_Static() ) - { - xFactory.set( ::cppu::createSingleFactory( - static_cast< css::lang::XMultiServiceFactory* >( pServiceManager ), - ScannerManager::getImplementationName_Static(), - ScannerManager_CreateInstance, - ScannerManager::getSupportedServiceNames_Static() ) ); - } - - if( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit