From d1038da54d02f39019b47cffcbf5f94b8cfbcbce Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 13 Jul 2020 20:00:37 +0200 Subject: io: create instances with uno constructors See tdf#74608 for motivation. Change-Id: Ic5942f00147e4024ffc3d5880cf3c7462bcc14de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98678 Tested-by: Jenkins Reviewed-by: Noel Grandin --- io/IwyuFilter_io.yaml | 23 -- io/Library_io.mk | 1 - io/source/TextInputStream/TextInputStream.cxx | 32 +-- io/source/TextOutputStream/TextOutputStream.cxx | 34 +-- io/source/acceptor/acceptor.cxx | 293 +++++++++++------------- io/source/connector/connector.cxx | 190 +++++++-------- io/source/io.component | 38 +-- io/source/services.cxx | 101 -------- io/source/services.hxx | 102 --------- io/source/stm/odata.cxx | 108 +++------ io/source/stm/omark.cxx | 60 ++--- io/source/stm/opipe.cxx | 32 +-- io/source/stm/opump.cxx | 24 +- 13 files changed, 321 insertions(+), 717 deletions(-) delete mode 100644 io/source/services.cxx delete mode 100644 io/source/services.hxx (limited to 'io') diff --git a/io/IwyuFilter_io.yaml b/io/IwyuFilter_io.yaml index 6a96a8acf438..42fd7e3e5827 100644 --- a/io/IwyuFilter_io.yaml +++ b/io/IwyuFilter_io.yaml @@ -1,9 +1,6 @@ --- assumeFilename: io/source/services.cxx excludelist: - io/source/acceptor/acceptor.cxx: - # Avoid loplugin:unreffun error - - services.hxx io/source/connector/connector.hxx: # Base class needs full type - com/sun/star/connection/XConnection.hpp @@ -11,26 +8,6 @@ excludelist: # Don't replace with impl. detail - osl/socket.hxx - osl/pipe.hxx - io/source/connector/connector.cxx: - # Avoid loplugin:unreffun error - - services.hxx - io/source/TextInputStream/TextInputStream.cxx: - # Avoid loplugin:unreffun error - - services.hxx - io/source/TextOutputStream/TextOutputStream.cxx: - # Avoid loplugin:unreffun error - - services.hxx - io/source/stm/odata.cxx: - # Avoid loplugin:unreffun error - - services.hxx - io/source/stm/opipe.cxx: - # Avoid loplugin:unreffun error - - services.hxx io/source/stm/opump.cxx: - # Avoid loplugin:unreffun error - - services.hxx # Don't replace with URE API impl. detail - cppuhelper/interfacecontainer.hxx - io/source/stm/omark.cxx: - # Avoid loplugin:unreffun error - - services.hxx diff --git a/io/Library_io.mk b/io/Library_io.mk index 8f85ca8b42a8..b961b437cd46 100644 --- a/io/Library_io.mk +++ b/io/Library_io.mk @@ -28,7 +28,6 @@ $(eval $(call gb_Library_set_include,io,\ )) $(eval $(call gb_Library_add_exception_objects,io,\ - io/source/services \ io/source/acceptor/acc_pipe \ io/source/acceptor/acc_socket \ io/source/acceptor/acceptor \ diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx index fc860b1063b1..0c40aaa5935c 100644 --- a/io/source/TextInputStream/TextInputStream.cxx +++ b/io/source/TextInputStream/TextInputStream.cxx @@ -32,8 +32,6 @@ #include #include -#include - #include namespace com::sun::star::uno { class XComponentContext; } @@ -47,8 +45,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::io; -namespace io_TextInputStream -{ // Implementation XTextInputStream @@ -380,27 +376,9 @@ Reference< XInputStream > OTextInputStream::getInputStream() return mxStream; } - -Reference< XInterface > TextInputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference< XComponentContext > &) -{ - return Reference < XInterface >( static_cast(new OTextInputStream()) ); -} - -OUString TextInputStream_getImplementationName() -{ - return IMPLEMENTATION_NAME; -} - -Sequence< OUString > TextInputStream_getSupportedServiceNames() -{ - Sequence< OUString > seqNames { SERVICE_NAME }; - return seqNames; -} - OUString OTextInputStream::getImplementationName() { - return TextInputStream_getImplementationName(); + return IMPLEMENTATION_NAME; } sal_Bool OTextInputStream::supportsService(const OUString& ServiceName) @@ -410,9 +388,15 @@ sal_Bool OTextInputStream::supportsService(const OUString& ServiceName) Sequence< OUString > OTextInputStream::getSupportedServiceNames() { - return TextInputStream_getSupportedServiceNames(); + return { SERVICE_NAME }; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OTextInputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) +{ + return cppu::acquire(new OTextInputStream()); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx index 22b4de2f10fb..2700ec1e415a 100644 --- a/io/source/TextOutputStream/TextOutputStream.cxx +++ b/io/source/TextOutputStream/TextOutputStream.cxx @@ -29,8 +29,6 @@ #include #include -#include - namespace com::sun::star::uno { class XComponentContext; } #define IMPLEMENTATION_NAME "com.sun.star.comp.io.TextOutputStream" @@ -42,9 +40,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::io; -namespace io_TextOutputStream -{ - // Implementation XTextOutputStream namespace { @@ -220,28 +215,9 @@ Reference< XOutputStream > OTextOutputStream::getOutputStream() return mxStream; } - -Reference< XInterface > TextOutputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference< XComponentContext > &) -{ - return Reference < XInterface >( static_cast(new OTextOutputStream()) ); -} - -OUString TextOutputStream_getImplementationName() -{ - return IMPLEMENTATION_NAME; -} - - -Sequence< OUString > TextOutputStream_getSupportedServiceNames() -{ - Sequence< OUString > seqNames { SERVICE_NAME }; - return seqNames; -} - OUString OTextOutputStream::getImplementationName() { - return TextOutputStream_getImplementationName(); + return IMPLEMENTATION_NAME; } sal_Bool OTextOutputStream::supportsService(const OUString& ServiceName) @@ -251,10 +227,16 @@ sal_Bool OTextOutputStream::supportsService(const OUString& ServiceName) Sequence< OUString > OTextOutputStream::getSupportedServiceNames() { - return TextOutputStream_getSupportedServiceNames(); + return { SERVICE_NAME }; } + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OTextOutputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) +{ + return cppu::acquire(new OTextOutputStream()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx index 15df65592a33..fe761018de52 100644 --- a/io/source/acceptor/acceptor.cxx +++ b/io/source/acceptor/acceptor.cxx @@ -31,7 +31,6 @@ #include #include -#include #include "acceptor.hxx" #include @@ -44,9 +43,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::connection; -namespace io_acceptor -{ - namespace { +namespace { class OAcceptor : public WeakImplHelper< XAcceptor, XServiceInfo > { @@ -64,8 +61,8 @@ namespace io_acceptor virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; private: - std::unique_ptr m_pPipe; - std::unique_ptr m_pSocket; + std::unique_ptr m_pPipe; + std::unique_ptr m_pSocket; Mutex m_mutex; OUString m_sLastDescription; bool m_bInAccept; @@ -75,199 +72,185 @@ namespace io_acceptor Reference _xAcceptor; }; - } +} - OAcceptor::OAcceptor( const Reference< XComponentContext > & xCtx ) - : m_bInAccept( false ) - , _xSMgr( xCtx->getServiceManager() ) - , _xCtx( xCtx ) - {} +OAcceptor::OAcceptor( const Reference< XComponentContext > & xCtx ) + : m_bInAccept( false ) + , _xSMgr( xCtx->getServiceManager() ) + , _xCtx( xCtx ) +{} - OAcceptor::~OAcceptor() - { - m_pPipe.reset(); - } +OAcceptor::~OAcceptor() +{ + m_pPipe.reset(); +} - namespace { +namespace { +struct BeingInAccept +{ + /// @throws AlreadyAcceptingException + BeingInAccept( bool *pFlag,const OUString & sConnectionDescription ) + : m_pFlag( pFlag ) + { + if( *m_pFlag ) + throw AlreadyAcceptingException( "AlreadyAcceptingException :" + sConnectionDescription ); + *m_pFlag = true; + } + ~BeingInAccept() + { + *m_pFlag = false; + } + bool *m_pFlag; +}; +} - struct BeingInAccept - { - /// @throws AlreadyAcceptingException - BeingInAccept( bool *pFlag,const OUString & sConnectionDescription ) - : m_pFlag( pFlag ) - { - if( *m_pFlag ) - throw AlreadyAcceptingException( "AlreadyAcceptingException :" + sConnectionDescription ); - *m_pFlag = true; - } - ~BeingInAccept() - { - *m_pFlag = false; - } - bool *m_pFlag; - }; +Reference< XConnection > OAcceptor::accept( const OUString &sConnectionDescription ) +{ + // if there is a thread already accepting in this object, throw an exception. + struct BeingInAccept guard( &m_bInAccept, sConnectionDescription ); + Reference< XConnection > r; + if( !m_sLastDescription.isEmpty() && + m_sLastDescription != sConnectionDescription ) + { + // instantiate another acceptor for different ports + throw ConnectionSetupException( "acceptor::accept called multiple times with different connection strings\n" ); } - Reference< XConnection > OAcceptor::accept( const OUString &sConnectionDescription ) + if( m_sLastDescription.isEmpty() ) { - // if there is a thread already accepting in this object, throw an exception. - struct BeingInAccept guard( &m_bInAccept, sConnectionDescription ); - - Reference< XConnection > r; - if( !m_sLastDescription.isEmpty() && - m_sLastDescription != sConnectionDescription ) - { - // instantiate another acceptor for different ports - throw ConnectionSetupException( "acceptor::accept called multiple times with different connection strings\n" ); - } - - if( m_sLastDescription.isEmpty() ) + // setup the acceptor + try { - // setup the acceptor - try + cppu::UnoUrlDescriptor aDesc(sConnectionDescription); + if ( aDesc.getName() == "pipe" ) { - cppu::UnoUrlDescriptor aDesc(sConnectionDescription); - if ( aDesc.getName() == "pipe" ) - { - OUString aName( - aDesc.getParameter( - "name")); + OUString aName( + aDesc.getParameter( + "name")); - m_pPipe.reset(new PipeAcceptor(aName, sConnectionDescription)); + m_pPipe.reset(new io_acceptor::PipeAcceptor(aName, sConnectionDescription)); - try - { - m_pPipe->init(); - } - catch( ... ) - { - { - MutexGuard g( m_mutex ); - m_pPipe.reset(); - } - throw; - } + try + { + m_pPipe->init(); } - else if ( aDesc.getName() == "socket" ) + catch( ... ) { - OUString aHost; - if (aDesc.hasParameter( - "host")) - aHost = aDesc.getParameter( - "host"); - else - aHost = "localhost"; - sal_uInt16 nPort = static_cast< sal_uInt16 >( - aDesc.getParameter( - "port"). - toInt32()); - bool bTcpNoDelay - = aDesc.getParameter( - "tcpnodelay").toInt32() != 0; - - m_pSocket.reset(new SocketAcceptor( - aHost, nPort, bTcpNoDelay, sConnectionDescription)); - - try { - m_pSocket->init(); - } - catch( ... ) - { - { - MutexGuard g( m_mutex ); - m_pSocket.reset(); - } - throw; + MutexGuard g( m_mutex ); + m_pPipe.reset(); } + throw; } + } + else if ( aDesc.getName() == "socket" ) + { + OUString aHost; + if (aDesc.hasParameter( + "host")) + aHost = aDesc.getParameter( + "host"); else + aHost = "localhost"; + sal_uInt16 nPort = static_cast< sal_uInt16 >( + aDesc.getParameter( + "port"). + toInt32()); + bool bTcpNoDelay + = aDesc.getParameter( + "tcpnodelay").toInt32() != 0; + + m_pSocket.reset(new io_acceptor::SocketAcceptor( + aHost, nPort, bTcpNoDelay, sConnectionDescription)); + + try { - OUString delegatee = "com.sun.star.connection.Acceptor." + aDesc.getName(); - _xAcceptor.set(_xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY); - - if(!_xAcceptor.is()) - throw ConnectionSetupException("Acceptor: unknown delegatee " + delegatee); + m_pSocket->init(); + } + catch( ... ) + { + { + MutexGuard g( m_mutex ); + m_pSocket.reset(); + } + throw; } } - catch (const rtl::MalformedUriException & rEx) + else { - throw IllegalArgumentException( - rEx.getMessage(), - Reference< XInterface > (), - 0 ); - } - m_sLastDescription = sConnectionDescription; - } + OUString delegatee = "com.sun.star.connection.Acceptor." + aDesc.getName(); + _xAcceptor.set(_xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY); - if( m_pPipe ) - { - r = m_pPipe->accept(); - } - else if( m_pSocket ) - { - r = m_pSocket->accept(); + if(!_xAcceptor.is()) + throw ConnectionSetupException("Acceptor: unknown delegatee " + delegatee); + } } - else + catch (const rtl::MalformedUriException & rEx) { - r = _xAcceptor->accept(sConnectionDescription); + throw IllegalArgumentException( + rEx.getMessage(), + Reference< XInterface > (), + 0 ); } - - return r; + m_sLastDescription = sConnectionDescription; } - void SAL_CALL OAcceptor::stopAccepting( ) + if( m_pPipe ) { - MutexGuard guard( m_mutex ); - - if( m_pPipe ) - { - m_pPipe->stopAccepting(); - } - else if ( m_pSocket ) - { - m_pSocket->stopAccepting(); - } - else if( _xAcceptor.is() ) - { - _xAcceptor->stopAccepting(); - } - + r = m_pPipe->accept(); } - - OUString acceptor_getImplementationName() + else if( m_pSocket ) { - return IMPLEMENTATION_NAME; + r = m_pSocket->accept(); } - - Reference< XInterface > acceptor_CreateInstance( const Reference< XComponentContext > & xCtx) + else { - return Reference < XInterface >( static_cast(new OAcceptor(xCtx)) ); + r = _xAcceptor->accept(sConnectionDescription); } - Sequence< OUString > acceptor_getSupportedServiceNames() - { - Sequence< OUString > seqNames { SERVICE_NAME }; - return seqNames; - } + return r; +} + +void SAL_CALL OAcceptor::stopAccepting( ) +{ + MutexGuard guard( m_mutex ); - OUString OAcceptor::getImplementationName() + if( m_pPipe ) { - return acceptor_getImplementationName(); + m_pPipe->stopAccepting(); } - - sal_Bool OAcceptor::supportsService(const OUString& ServiceName) + else if ( m_pSocket ) { - return cppu::supportsService(this, ServiceName); + m_pSocket->stopAccepting(); } - - Sequence< OUString > OAcceptor::getSupportedServiceNames() + else if( _xAcceptor.is() ) { - return acceptor_getSupportedServiceNames(); + _xAcceptor->stopAccepting(); } +} + +OUString OAcceptor::getImplementationName() +{ + return IMPLEMENTATION_NAME; +} + +sal_Bool OAcceptor::supportsService(const OUString& ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} +Sequence< OUString > OAcceptor::getSupportedServiceNames() +{ + return { SERVICE_NAME }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OAcceptor_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) +{ + return cppu::acquire(new OAcceptor(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx index f5b77a43cb7d..c6f01e130814 100644 --- a/io/source/connector/connector.cxx +++ b/io/source/connector/connector.cxx @@ -31,7 +31,6 @@ #include #include -#include #include "connector.hxx" #define IMPLEMENTATION_NAME "com.sun.star.comp.io.Connector" @@ -43,9 +42,7 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::connection; -namespace stoc_connector -{ - namespace { +namespace { class OConnector : public WeakImplHelper< XConnector, XServiceInfo > { @@ -64,128 +61,119 @@ namespace stoc_connector virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; }; - } +} - OConnector::OConnector(const Reference< XComponentContext > &xCtx) - : _xSMgr( xCtx->getServiceManager() ) - , _xCtx( xCtx ) - {} +OConnector::OConnector(const Reference< XComponentContext > &xCtx) + : _xSMgr( xCtx->getServiceManager() ) + , _xCtx( xCtx ) +{} - Reference< XConnection > SAL_CALL OConnector::connect( const OUString& sConnectionDescription ) +Reference< XConnection > SAL_CALL OConnector::connect( const OUString& sConnectionDescription ) +{ + // split string into tokens + try { - // split string into tokens - try + cppu::UnoUrlDescriptor aDesc(sConnectionDescription); + + Reference< XConnection > r; + if ( aDesc.getName() == "pipe" ) { - cppu::UnoUrlDescriptor aDesc(sConnectionDescription); + OUString aName(aDesc.getParameter("name")); - Reference< XConnection > r; - if ( aDesc.getName() == "pipe" ) - { - OUString aName(aDesc.getParameter("name")); - - std::unique_ptr pConn(new PipeConnection( sConnectionDescription )); - - if( pConn->m_pipe.create( aName.pData, osl_Pipe_OPEN, osl::Security() ) ) - { - r.set( static_cast(pConn.release()) ); - } - else - { - OUString const sMessage( - "Connector : couldn't connect to pipe \"" + aName + "\": " - + OUString::number(pConn->m_pipe.getError())); - SAL_WARN("io.connector", sMessage); - throw NoConnectException( sMessage ); - } - } - else if ( aDesc.getName() == "socket" ) + std::unique_ptr pConn(new stoc_connector::PipeConnection( sConnectionDescription )); + + if( pConn->m_pipe.create( aName.pData, osl_Pipe_OPEN, osl::Security() ) ) { - OUString aHost; - if (aDesc.hasParameter("host")) - aHost = aDesc.getParameter("host"); - else - aHost = "localhost"; - sal_uInt16 nPort = static_cast< sal_uInt16 >( - aDesc.getParameter("port"). - toInt32()); - bool bTcpNoDelay - = aDesc.getParameter("tcpnodelay").toInt32() != 0; - - std::unique_ptr pConn(new SocketConnection( sConnectionDescription)); - - SocketAddr AddrTarget( aHost.pData, nPort ); - if(pConn->m_socket.connect(AddrTarget) != osl_Socket_Ok) - { - OUString sMessage("Connector : couldn't connect to socket ("); - OUString sError = pConn->m_socket.getErrorAsString(); - sMessage += sError + ")"; - throw NoConnectException( sMessage ); - } - // we enable tcpNoDelay for loopback connections because - // it can make a significant speed difference on linux boxes. - if( bTcpNoDelay || aHost == "localhost" || aHost.startsWith("127.0.0.") ) - { - sal_Int32 nTcpNoDelay = sal_Int32(true); - pConn->m_socket.setOption( osl_Socket_OptionTcpNoDelay , &nTcpNoDelay, - sizeof( nTcpNoDelay ) , osl_Socket_LevelTcp ); - } - pConn->completeConnectionString(); r.set( static_cast(pConn.release()) ); } else { - OUString delegatee= "com.sun.star.connection.Connector." + aDesc.getName(); - - Reference xConnector( - _xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY ); - - if(!xConnector.is()) - throw ConnectionSetupException("Connector: unknown delegatee " + delegatee); + OUString const sMessage( + "Connector : couldn't connect to pipe \"" + aName + "\": " + + OUString::number(pConn->m_pipe.getError())); + SAL_WARN("io.connector", sMessage); + throw NoConnectException( sMessage ); + } + } + else if ( aDesc.getName() == "socket" ) + { + OUString aHost; + if (aDesc.hasParameter("host")) + aHost = aDesc.getParameter("host"); + else + aHost = "localhost"; + sal_uInt16 nPort = static_cast< sal_uInt16 >( + aDesc.getParameter("port"). + toInt32()); + bool bTcpNoDelay + = aDesc.getParameter("tcpnodelay").toInt32() != 0; - sal_Int32 index = sConnectionDescription.indexOf(','); + std::unique_ptr pConn(new stoc_connector::SocketConnection( sConnectionDescription)); - r = xConnector->connect(sConnectionDescription.copy(index + 1).trim()); + SocketAddr AddrTarget( aHost.pData, nPort ); + if(pConn->m_socket.connect(AddrTarget) != osl_Socket_Ok) + { + OUString sMessage("Connector : couldn't connect to socket ("); + OUString sError = pConn->m_socket.getErrorAsString(); + sMessage += sError + ")"; + throw NoConnectException( sMessage ); + } + // we enable tcpNoDelay for loopback connections because + // it can make a significant speed difference on linux boxes. + if( bTcpNoDelay || aHost == "localhost" || aHost.startsWith("127.0.0.") ) + { + sal_Int32 nTcpNoDelay = sal_Int32(true); + pConn->m_socket.setOption( osl_Socket_OptionTcpNoDelay , &nTcpNoDelay, + sizeof( nTcpNoDelay ) , osl_Socket_LevelTcp ); } - return r; + pConn->completeConnectionString(); + r.set( static_cast(pConn.release()) ); } - catch (const rtl::MalformedUriException & rEx) + else { - throw ConnectionSetupException(rEx.getMessage()); - } - } + OUString delegatee= "com.sun.star.connection.Connector." + aDesc.getName(); - Sequence< OUString > connector_getSupportedServiceNames() - { - Sequence< OUString > seqNames { SERVICE_NAME }; - return seqNames; - } + Reference xConnector( + _xSMgr->createInstanceWithContext(delegatee, _xCtx), UNO_QUERY ); - OUString connector_getImplementationName() - { - return IMPLEMENTATION_NAME; - } + if(!xConnector.is()) + throw ConnectionSetupException("Connector: unknown delegatee " + delegatee); - OUString OConnector::getImplementationName() - { - return connector_getImplementationName(); - } + sal_Int32 index = sConnectionDescription.indexOf(','); - sal_Bool OConnector::supportsService(const OUString& ServiceName) - { - return cppu::supportsService(this, ServiceName); + r = xConnector->connect(sConnectionDescription.copy(index + 1).trim()); + } + return r; } - - Sequence< OUString > OConnector::getSupportedServiceNames() + catch (const rtl::MalformedUriException & rEx) { - return connector_getSupportedServiceNames(); + throw ConnectionSetupException(rEx.getMessage()); } +} - Reference< XInterface > connector_CreateInstance( const Reference< XComponentContext > & xCtx) - { - return Reference < XInterface >( static_cast(new OConnector(xCtx)) ); - } +OUString OConnector::getImplementationName() +{ + return IMPLEMENTATION_NAME; +} +sal_Bool OConnector::supportsService(const OUString& ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} + +Sequence< OUString > OConnector::getSupportedServiceNames() +{ + return { SERVICE_NAME }; +} +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OConnector_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) +{ + return cppu::acquire(new OConnector(context)); } + + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/io.component b/io/source/io.component index 12f954fc9e78..a5712c0f60c4 100644 --- a/io/source/io.component +++ b/io/source/io.component @@ -18,41 +18,53 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + - + - + - + - + - + - + - + - + - + - + - + diff --git a/io/source/services.cxx b/io/source/services.cxx deleted file mode 100644 index 9035cec86334..000000000000 --- a/io/source/services.cxx +++ /dev/null @@ -1,101 +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 "services.hxx" - -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; - -const struct ImplementationEntry g_entries[] = -{ - { - io_acceptor::acceptor_CreateInstance, io_acceptor::acceptor_getImplementationName , - io_acceptor::acceptor_getSupportedServiceNames, createSingleComponentFactory , - nullptr, 0 - }, - { - stoc_connector::connector_CreateInstance, stoc_connector::connector_getImplementationName , - stoc_connector::connector_getSupportedServiceNames, createSingleComponentFactory , - nullptr, 0 - }, - { - io_stm::OPipeImpl_CreateInstance, io_stm::OPipeImpl_getImplementationName , - io_stm::OPipeImpl_getSupportedServiceNames, createSingleComponentFactory , - nullptr, 0 - }, - { - io_stm::OPumpImpl_CreateInstance, io_stm::OPumpImpl_getImplementationName , - io_stm::OPumpImpl_getSupportedServiceNames, createSingleComponentFactory , - nullptr, 0 - }, - { - io_stm::ODataInputStream_CreateInstance, io_stm::ODataInputStream_getImplementationName, - io_stm::ODataInputStream_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { - io_stm::ODataOutputStream_CreateInstance, io_stm::ODataOutputStream_getImplementationName, - io_stm::ODataOutputStream_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { - io_stm::OObjectInputStream_CreateInstance, io_stm::OObjectInputStream_getImplementationName, - io_stm::OObjectInputStream_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { - io_stm::OObjectOutputStream_CreateInstance, io_stm::OObjectOutputStream_getImplementationName, - io_stm::OObjectOutputStream_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { - io_stm::OMarkableInputStream_CreateInstance, io_stm::OMarkableInputStream_getImplementationName, - io_stm::OMarkableInputStream_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { - io_stm::OMarkableOutputStream_CreateInstance, io_stm::OMarkableOutputStream_getImplementationName, - io_stm::OMarkableOutputStream_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { - io_TextInputStream::TextInputStream_CreateInstance, io_TextInputStream::TextInputStream_getImplementationName , - io_TextInputStream::TextInputStream_getSupportedServiceNames, createSingleComponentFactory , - nullptr, 0 - }, - { - io_TextOutputStream::TextOutputStream_CreateInstance, io_TextOutputStream::TextOutputStream_getImplementationName , - io_TextOutputStream::TextOutputStream_getSupportedServiceNames, createSingleComponentFactory , - nullptr, 0 - }, - {nullptr, nullptr, nullptr, nullptr, nullptr, 0} -}; - -extern "C" SAL_DLLPUBLIC_EXPORT void * io_component_getFactory( - const char * pImplName, void * pServiceManager, void * pRegistryKey ) -{ - return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/services.hxx b/io/source/services.hxx deleted file mode 100644 index 119f6e29feac..000000000000 --- a/io/source/services.hxx +++ /dev/null @@ -1,102 +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 . - */ - -#ifndef INCLUDED_IO_SOURCE_SERVICES_HXX -#define INCLUDED_IO_SOURCE_SERVICES_HXX - -#include - -#include -#include -#include -#include - -namespace com::sun::star::uno { class XComponentContext; } - -using namespace ::com::sun::star::uno; - -namespace io_acceptor{ - Reference< XInterface > acceptor_CreateInstance( const Reference< XComponentContext > & xCtx); - OUString acceptor_getImplementationName(); - Sequence< OUString > acceptor_getSupportedServiceNames(); -} - -namespace stoc_connector { - Reference< XInterface > connector_CreateInstance( const Reference< XComponentContext > & xCtx); - OUString connector_getImplementationName(); - Sequence< OUString > connector_getSupportedServiceNames(); -} - -namespace io_TextInputStream { - Reference< XInterface > TextInputStream_CreateInstance(SAL_UNUSED_PARAMETER const Reference< XComponentContext > &); - OUString TextInputStream_getImplementationName(); - Sequence< OUString > TextInputStream_getSupportedServiceNames(); -} - -namespace io_TextOutputStream { - Reference< XInterface > TextOutputStream_CreateInstance(SAL_UNUSED_PARAMETER const Reference< XComponentContext > &); - OUString TextOutputStream_getImplementationName(); - Sequence< OUString > TextOutputStream_getSupportedServiceNames(); -} - -namespace io_stm { - /// @throws Exception - Reference< XInterface > OPipeImpl_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString OPipeImpl_getImplementationName(); - Sequence OPipeImpl_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > ODataInputStream_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString ODataInputStream_getImplementationName(); - Sequence ODataInputStream_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > ODataOutputStream_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString ODataOutputStream_getImplementationName(); - Sequence ODataOutputStream_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > OMarkableOutputStream_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString OMarkableOutputStream_getImplementationName(); - Sequence OMarkableOutputStream_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > OMarkableInputStream_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString OMarkableInputStream_getImplementationName() ; - Sequence OMarkableInputStream_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > OObjectOutputStream_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString OObjectOutputStream_getImplementationName(); - Sequence OObjectOutputStream_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > OObjectInputStream_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString OObjectInputStream_getImplementationName() ; - Sequence OObjectInputStream_getSupportedServiceNames(); - - /// @throws Exception - Reference< XInterface > OPumpImpl_CreateInstance( const Reference< XComponentContext > & rSMgr ); - OUString OPumpImpl_getImplementationName(); - Sequence OPumpImpl_getSupportedServiceNames(); -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/stm/odata.cxx b/io/source/stm/odata.cxx index 3e802b2d37a5..ed543ab3c795 100644 --- a/io/source/stm/odata.cxx +++ b/io/source/stm/odata.cxx @@ -45,8 +45,6 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -#include - namespace io_stm { namespace { @@ -392,7 +390,7 @@ Reference < XConnectable > ODataInputStream::getPredecessor() // XServiceInfo OUString ODataInputStream::getImplementationName() { - return ODataInputStream_getImplementationName(); + return "com.sun.star.comp.io.stm.DataInputStream"; } // XServiceInfo @@ -404,32 +402,14 @@ sal_Bool ODataInputStream::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > ODataInputStream::getSupportedServiceNames() { - return ODataInputStream_getSupportedServiceNames(); + return { "com.sun.star.io.DataInputStream" }; } -/*** -* -* registration information -* -* -****/ - -Reference< XInterface > ODataInputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference < XComponentContext > & ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_ODataInputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - ODataInputStream *p = new ODataInputStream; - return Reference< XInterface > ( static_cast(p) ); -} - -OUString ODataInputStream_getImplementationName() -{ - return "com.sun.star.comp.io.stm.DataInputStream"; -} - -Sequence ODataInputStream_getSupportedServiceNames() -{ - Sequence aRet { "com.sun.star.io.DataInputStream" }; - return aRet; + return cppu::acquire(new ODataInputStream()); } namespace { @@ -704,7 +684,7 @@ Reference < XConnectable > ODataOutputStream::getPredecessor() // XServiceInfo OUString ODataOutputStream::getImplementationName() { - return ODataOutputStream_getImplementationName(); + return "com.sun.star.comp.io.stm.DataOutputStream"; } // XServiceInfo @@ -716,27 +696,14 @@ sal_Bool ODataOutputStream::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > ODataOutputStream::getSupportedServiceNames() { - return ODataOutputStream_getSupportedServiceNames(); + return { "com.sun.star.io.DataOutputStream" }; } -Reference< XInterface > ODataOutputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference < XComponentContext > & ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_ODataOutputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - ODataOutputStream *p = new ODataOutputStream; - Reference< XInterface > xService = *p; - return xService; -} - - -OUString ODataOutputStream_getImplementationName() -{ - return "com.sun.star.comp.io.stm.DataOutputStream"; -} - -Sequence ODataOutputStream_getSupportedServiceNames() -{ - Sequence aRet { "com.sun.star.io.DataOutputStream" }; - return aRet; + return cppu::acquire(new ODataOutputStream()); } namespace { @@ -974,29 +941,10 @@ sal_Int32 OObjectOutputStream::offsetToMark(sal_Int32 nMark) return m_rMarkable->offsetToMark( nMark ); } - -Reference< XInterface > OObjectOutputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference < XComponentContext > & ) -{ - OObjectOutputStream *p = new OObjectOutputStream; - return Reference< XInterface > ( static_cast< OWeakObject * >(p) ); -} - -OUString OObjectOutputStream_getImplementationName() -{ - return "com.sun.star.comp.io.stm.ObjectOutputStream"; -} - -Sequence OObjectOutputStream_getSupportedServiceNames() -{ - Sequence aRet { "com.sun.star.io.ObjectOutputStream" }; - return aRet; -} - // XServiceInfo OUString OObjectOutputStream::getImplementationName() { - return OObjectOutputStream_getImplementationName(); + return "com.sun.star.comp.io.stm.ObjectOutputStream"; } // XServiceInfo @@ -1008,7 +956,14 @@ sal_Bool OObjectOutputStream::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > OObjectOutputStream::getSupportedServiceNames() { - return OObjectOutputStream_getSupportedServiceNames(); + return { "com.sun.star.io.ObjectOutputStream" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OObjectOutputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) +{ + return cppu::acquire(new OObjectOutputStream()); } namespace { @@ -1247,7 +1202,7 @@ sal_Int32 OObjectInputStream::offsetToMark(sal_Int32 nMark) // XServiceInfo OUString OObjectInputStream::getImplementationName() { - return OObjectInputStream_getImplementationName(); + return "com.sun.star.comp.io.stm.ObjectInputStream"; } // XServiceInfo @@ -1259,26 +1214,17 @@ sal_Bool OObjectInputStream::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > OObjectInputStream::getSupportedServiceNames() { - return OObjectInputStream_getSupportedServiceNames(); -} - -Reference< XInterface > OObjectInputStream_CreateInstance( const Reference < XComponentContext > & rCtx ) -{ - OObjectInputStream *p = new OObjectInputStream( rCtx ); - return Reference< XInterface> ( static_cast< OWeakObject * >(p) ); + return { "com.sun.star.io.ObjectInputStream" }; } -OUString OObjectInputStream_getImplementationName() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OObjectInputStream_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const&) { - return "com.sun.star.comp.io.stm.ObjectInputStream"; + return cppu::acquire(new OObjectInputStream(context)); } -Sequence OObjectInputStream_getSupportedServiceNames() -{ - Sequence aRet { "com.sun.star.io.ObjectInputStream" }; - return aRet; } -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/stm/omark.cxx b/io/source/stm/omark.cxx index 0c7a821423f4..411f6412c830 100644 --- a/io/source/stm/omark.cxx +++ b/io/source/stm/omark.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,6 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -#include #include "streamhelper.hxx" namespace io_stm { @@ -345,7 +345,7 @@ void OMarkableOutputStream::checkMarksAndFlush() // XServiceInfo OUString OMarkableOutputStream::getImplementationName() { - return OMarkableOutputStream_getImplementationName(); + return "com.sun.star.comp.io.stm.MarkableOutputStream"; } // XServiceInfo @@ -357,32 +357,14 @@ sal_Bool OMarkableOutputStream::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > OMarkableOutputStream::getSupportedServiceNames() { - return OMarkableOutputStream_getSupportedServiceNames(); -} - -/*------------------------ -* -* external binding -* -*------------------------*/ -Reference< XInterface > OMarkableOutputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference < XComponentContext > & ) -{ - OMarkableOutputStream *p = new OMarkableOutputStream( ); - - return Reference < XInterface > ( static_cast(p) ); -} - -OUString OMarkableOutputStream_getImplementationName() -{ - return "com.sun.star.comp.io.stm.MarkableOutputStream"; + return { "com.sun.star.io.MarkableOutputStream" }; } -Sequence OMarkableOutputStream_getSupportedServiceNames() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OMarkableOutputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - Sequence aRet { "com.sun.star.io.MarkableOutputStream" }; - - return aRet; + return cppu::acquire(new OMarkableOutputStream()); } @@ -758,7 +740,7 @@ void OMarkableInputStream::checkMarksAndFlush() // XServiceInfo OUString OMarkableInputStream::getImplementationName() { - return OMarkableInputStream_getImplementationName(); + return "com.sun.star.comp.io.stm.MarkableInputStream"; } // XServiceInfo @@ -770,30 +752,14 @@ sal_Bool OMarkableInputStream::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > OMarkableInputStream::getSupportedServiceNames() { - return OMarkableInputStream_getSupportedServiceNames(); -} - -/*------------------------ -* -* external binding -* -*------------------------*/ -Reference < XInterface > OMarkableInputStream_CreateInstance( - SAL_UNUSED_PARAMETER const Reference < XComponentContext > & ) -{ - OMarkableInputStream *p = new OMarkableInputStream( ); - return Reference< XInterface > ( static_cast(p) ); -} - -OUString OMarkableInputStream_getImplementationName() -{ - return "com.sun.star.comp.io.stm.MarkableInputStream"; + return { "com.sun.star.io.MarkableInputStream" }; } -Sequence OMarkableInputStream_getSupportedServiceNames() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OMarkableInputStream_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - Sequence aRet { "com.sun.star.io.MarkableInputStream" }; - return aRet; + return cppu::acquire(new OMarkableInputStream()); } } diff --git a/io/source/stm/opipe.cxx b/io/source/stm/opipe.cxx index 07331472d5e5..732daafecaed 100644 --- a/io/source/stm/opipe.cxx +++ b/io/source/stm/opipe.cxx @@ -42,7 +42,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; using namespace ::com::sun::star::lang; -#include #include "streamhelper.hxx" namespace com::sun::star::uno { class XComponentContext; } @@ -334,7 +333,7 @@ Reference < XConnectable > OPipeImpl::getPredecessor() // XServiceInfo OUString OPipeImpl::getImplementationName() { - return OPipeImpl_getImplementationName(); + return IMPLEMENTATION_NAME; } // XServiceInfo @@ -346,35 +345,16 @@ sal_Bool OPipeImpl::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > OPipeImpl::getSupportedServiceNames() { - return OPipeImpl_getSupportedServiceNames(); -} - -/* implementation functions -* -* -*/ - - -Reference < XInterface > OPipeImpl_CreateInstance( - SAL_UNUSED_PARAMETER const Reference < XComponentContext > & ) -{ - OPipeImpl *p = new OPipeImpl; - - return Reference < XInterface > ( static_cast< OWeakObject * >(p) ); + return { "com.sun.star.io.Pipe" }; } - -OUString OPipeImpl_getImplementationName() -{ - return IMPLEMENTATION_NAME; } -Sequence OPipeImpl_getSupportedServiceNames() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_OPipeImpl_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - Sequence aRet { "com.sun.star.io.Pipe" }; - return aRet; -} + return cppu::acquire(new io_stm::OPipeImpl()); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/io/source/stm/opump.cxx b/io/source/stm/opump.cxx index cba66d3c50fc..b63f1a3a4895 100644 --- a/io/source/stm/opump.cxx +++ b/io/source/stm/opump.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -42,8 +43,6 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::io; -#include - namespace io_stm { namespace { @@ -421,7 +420,7 @@ Reference< XOutputStream > Pump::getOutputStream() // XServiceInfo OUString Pump::getImplementationName() { - return OPumpImpl_getImplementationName(); + return "com.sun.star.comp.io.Pump"; } // XServiceInfo @@ -433,26 +432,17 @@ sal_Bool Pump::supportsService(const OUString& ServiceName) // XServiceInfo Sequence< OUString > Pump::getSupportedServiceNames() { - return OPumpImpl_getSupportedServiceNames(); + return { "com.sun.star.io.Pump" }; } - -Reference< XInterface > OPumpImpl_CreateInstance( - SAL_UNUSED_PARAMETER const Reference< XComponentContext > & ) -{ - return Reference< XInterface >( *new Pump ); } -OUString OPumpImpl_getImplementationName() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +io_Pump_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence const&) { - return "com.sun.star.comp.io.Pump"; + return cppu::acquire(new io_stm::Pump()); } -Sequence OPumpImpl_getSupportedServiceNames() -{ - return Sequence< OUString > { "com.sun.star.io.Pump" }; -} - -} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit