diff options
author | Noel Grandin <noel@peralex.com> | 2020-07-21 13:55:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-22 14:41:19 +0200 |
commit | b76e903ccc83d0ccf0c6548782622638dd8a0ee5 (patch) | |
tree | b14771b617a88695bc283230fa4c5c4f84160bff /dtrans/source/win32/clipb | |
parent | 5c2b301f031ff8374fcf0e4c2ed8f9bd4300815e (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dtrans/source/win32/clipb')
-rw-r--r-- | dtrans/source/win32/clipb/WinClipboard.cxx | 26 | ||||
-rw-r--r-- | dtrans/source/win32/clipb/wcbentry.cxx | 82 |
2 files changed, 13 insertions, 95 deletions
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 <com/sun/star/datatransfer/clipboard/ClipboardEvent.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/supportsservice.hxx> +#include <rtl/ref.hxx> #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<css::uno::Any> const&) +{ + static rtl::Reference<CWinClipboard> g_Instance(new CWinClipboard(context, "")); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(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 <cppuhelper/factory.hxx> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/container/XSet.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#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<XClipboard*>( - 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: */ |