From b76e903ccc83d0ccf0c6548782622638dd8a0ee5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 21 Jul 2020 13:55:30 +0200 Subject: dtrans/clipboard: create instances with uno constructors See tdf#74608 for motivation. Change-Id: Iba30f1cf6892330495f57343619e234194bc5b5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99158 Tested-by: Jenkins Reviewed-by: Noel Grandin --- dtrans/source/win32/clipb/WinClipboard.cxx | 26 +++++----- dtrans/source/win32/clipb/wcbentry.cxx | 82 ------------------------------ 2 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 dtrans/source/win32/clipb/wcbentry.cxx (limited to 'dtrans/source/win32/clipb') diff --git a/dtrans/source/win32/clipb/WinClipboard.cxx b/dtrans/source/win32/clipb/WinClipboard.cxx index 919065a9f2fc..7de317766d77 100644 --- a/dtrans/source/win32/clipb/WinClipboard.cxx +++ b/dtrans/source/win32/clipb/WinClipboard.cxx @@ -22,7 +22,9 @@ #include #include #include +#include #include +#include #include "WinClipbImpl.hxx" using namespace osl; @@ -34,17 +36,6 @@ using namespace com::sun::star::datatransfer; using namespace com::sun::star::datatransfer::clipboard; using namespace com::sun::star::lang; -#define WINCLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32" - -namespace -{ - Sequence< OUString > WinClipboard_getSupportedServiceNames() - { - Sequence< OUString > aRet { "com.sun.star.datatransfer.clipboard.SystemClipboard" }; - return aRet; - } -} - /*XEventListener,*/ CWinClipboard::CWinClipboard( const Reference< XComponentContext >& rxContext, const OUString& aClipboardName ) : WeakComponentImplHelper< XSystemClipboard, XFlushableClipboard, XServiceInfo >( m_aCbListenerMutex ), @@ -223,7 +214,7 @@ void SAL_CALL CWinClipboard::disposing() OUString SAL_CALL CWinClipboard::getImplementationName( ) { - return WINCLIPBOARD_IMPL_NAME; + return "com.sun.star.datatransfer.clipboard.ClipboardW32"; } sal_Bool SAL_CALL CWinClipboard::supportsService( const OUString& ServiceName ) @@ -233,7 +224,16 @@ sal_Bool SAL_CALL CWinClipboard::supportsService( const OUString& ServiceName ) Sequence< OUString > SAL_CALL CWinClipboard::getSupportedServiceNames( ) { - return WinClipboard_getSupportedServiceNames(); + return { "com.sun.star.datatransfer.clipboard.SystemClipboard" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +dtrans_CWinClipboard_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) +{ + static rtl::Reference g_Instance(new CWinClipboard(context, "")); + g_Instance->acquire(); + return static_cast(g_Instance.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/dtrans/source/win32/clipb/wcbentry.cxx b/dtrans/source/win32/clipb/wcbentry.cxx deleted file mode 100644 index e91bde9c07d7..000000000000 --- a/dtrans/source/win32/clipb/wcbentry.cxx +++ /dev/null @@ -1,82 +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 -#include -#include "WinClipboard.hxx" - -#define WINCLIPBOARD_SERVICE_NAME "com.sun.star.datatransfer.clipboard.SystemClipboard" - -#define WINCLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32" - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::registry; -using namespace ::cppu; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::datatransfer::clipboard; - -namespace -{ - - // functions to create a new Clipboard instance; is needed by factory helper implementation - // @param rServiceManager - service manager, useful if the component needs other uno services - // so we should give it to every UNO-Implementation component - - Reference< XInterface > createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) - { - return static_cast( - new CWinClipboard(comphelper::getComponentContext(rServiceManager), "")); - } -} - -extern "C" -{ - -// component_getFactory -// returns a factory to create XFilePicker-Services - -SAL_DLLPUBLIC_EXPORT void* sysdtrans_component_getFactory( const char* pImplName, void* pSrvManager, void* /*pRegistryKey*/ ) -{ - void* pRet = nullptr; - - if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, WINCLIPBOARD_IMPL_NAME ) ) ) - { - Sequence< OUString > aSNS { WINCLIPBOARD_SERVICE_NAME }; - - //OUString( FPS_IMPL_NAME ) - Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory( - static_cast< XMultiServiceFactory* > ( pSrvManager ), - OUString::createFromAscii( pImplName ), - createInstance, - aSNS ) ); - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; -} - -} // extern "C" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit