diff options
author | Noel Grandin <noel@peralex.com> | 2020-07-21 16:09:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-22 08:29:47 +0200 |
commit | 00c7afecc319061b70b77a709ca2ae9583df4145 (patch) | |
tree | dd8fd6cd708d895d376f68f52ac9a987a6673d84 /embeddedobj/source/commonembedding | |
parent | 188540e37d33debcf1b89eb08e84547c56e19ba2 (diff) |
embeddedobj/util: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: I52734cc1420ae7915da3191cf94ac61287a0983a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99162
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'embeddedobj/source/commonembedding')
-rw-r--r-- | embeddedobj/source/commonembedding/register.cxx | 76 | ||||
-rw-r--r-- | embeddedobj/source/commonembedding/xfactory.cxx | 49 | ||||
-rw-r--r-- | embeddedobj/source/commonembedding/xfactory.hxx | 17 |
3 files changed, 18 insertions, 124 deletions
diff --git a/embeddedobj/source/commonembedding/register.cxx b/embeddedobj/source/commonembedding/register.cxx deleted file mode 100644 index 148fd5ad534f..000000000000 --- a/embeddedobj/source/commonembedding/register.cxx +++ /dev/null @@ -1,76 +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 <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <cppuhelper/factory.hxx> - -#include "xfactory.hxx" -#include <xcreator.hxx> - -using namespace ::com::sun::star; - - -extern "C" { - -SAL_DLLPUBLIC_EXPORT void * embobj_component_getFactory( - const char * pImplName, void * pServiceManager, - SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ ) -{ - void * pRet = nullptr; - - OUString aImplName( OUString::createFromAscii( pImplName ) ); - uno::Reference< lang::XSingleServiceFactory > xFactory; - - if ( pServiceManager ) - { - if ( aImplName == OOoEmbeddedObjectFactory::impl_staticGetImplementationName() ) - { - xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ), - OOoEmbeddedObjectFactory::impl_staticGetImplementationName(), - OOoEmbeddedObjectFactory::impl_staticCreateSelfInstance, - OOoEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() ); - } - else if ( aImplName == OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName() ) - { - xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ), - OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName(), - OOoSpecialEmbeddedObjectFactory::impl_staticCreateSelfInstance, - OOoSpecialEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() ); - } - else if ( aImplName == UNOEmbeddedObjectCreator::impl_staticGetImplementationName() ) - { - xFactory= ::cppu::createOneInstanceFactory( static_cast< lang::XMultiServiceFactory*>( pServiceManager ), - UNOEmbeddedObjectCreator::impl_staticGetImplementationName(), - UNOEmbeddedObjectCreator::impl_staticCreateSelfInstance, - UNOEmbeddedObjectCreator::impl_staticGetSupportedServiceNames() ); - } - } - - if ( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - - return pRet; -} - -} // extern "C" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embeddedobj/source/commonembedding/xfactory.cxx b/embeddedobj/source/commonembedding/xfactory.cxx index bfd7d548358a..d383567f3e47 100644 --- a/embeddedobj/source/commonembedding/xfactory.cxx +++ b/embeddedobj/source/commonembedding/xfactory.cxx @@ -35,21 +35,6 @@ using namespace ::com::sun::star; -uno::Sequence< OUString > OOoEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() -{ - return { "com.sun.star.embed.OOoEmbeddedObjectFactory", "com.sun.star.comp.embed.OOoEmbeddedObjectFactory" }; -} - -OUString OOoEmbeddedObjectFactory::impl_staticGetImplementationName() -{ - return "com.sun.star.comp.embed.OOoEmbeddedObjectFactory"; -} - -uno::Reference< uno::XInterface > OOoEmbeddedObjectFactory::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new OOoEmbeddedObjectFactory( comphelper::getComponentContext(xServiceManager) ) ); -} uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInstanceInitFromEntry( const uno::Reference< embed::XStorage >& xStorage, @@ -367,7 +352,7 @@ uno::Reference< uno::XInterface > SAL_CALL OOoEmbeddedObjectFactory::createInsta OUString SAL_CALL OOoEmbeddedObjectFactory::getImplementationName() { - return impl_staticGetImplementationName(); + return "com.sun.star.comp.embed.OOoEmbeddedObjectFactory"; } sal_Bool SAL_CALL OOoEmbeddedObjectFactory::supportsService( const OUString& ServiceName ) @@ -377,24 +362,18 @@ sal_Bool SAL_CALL OOoEmbeddedObjectFactory::supportsService( const OUString& Ser uno::Sequence< OUString > SAL_CALL OOoEmbeddedObjectFactory::getSupportedServiceNames() { - return impl_staticGetSupportedServiceNames(); -} - -uno::Sequence< OUString > OOoSpecialEmbeddedObjectFactory::impl_staticGetSupportedServiceNames() -{ - return { "com.sun.star.embed.OOoSpecialEmbeddedObjectFactory", "com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory" }; + return { "com.sun.star.embed.OOoEmbeddedObjectFactory", "com.sun.star.comp.embed.OOoEmbeddedObjectFactory" }; } -OUString OOoSpecialEmbeddedObjectFactory::impl_staticGetImplementationName() +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +embeddedobj_OOoEmbeddedObjectFactory_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return "com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory"; + static rtl::Reference<OOoEmbeddedObjectFactory> g_Instance(new OOoEmbeddedObjectFactory(context)); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(g_Instance.get()); } -uno::Reference< uno::XInterface > OOoSpecialEmbeddedObjectFactory::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) -{ - return uno::Reference< uno::XInterface >( *new OOoSpecialEmbeddedObjectFactory( comphelper::getComponentContext(xServiceManager) ) ); -} uno::Reference< uno::XInterface > SAL_CALL OOoSpecialEmbeddedObjectFactory::createInstanceUserInit( const uno::Sequence< sal_Int8 >& aClassID, @@ -419,7 +398,7 @@ uno::Reference< uno::XInterface > SAL_CALL OOoSpecialEmbeddedObjectFactory::crea OUString SAL_CALL OOoSpecialEmbeddedObjectFactory::getImplementationName() { - return impl_staticGetImplementationName(); + return "com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory"; } sal_Bool SAL_CALL OOoSpecialEmbeddedObjectFactory::supportsService( const OUString& ServiceName ) @@ -429,7 +408,15 @@ sal_Bool SAL_CALL OOoSpecialEmbeddedObjectFactory::supportsService( const OUStri uno::Sequence< OUString > SAL_CALL OOoSpecialEmbeddedObjectFactory::getSupportedServiceNames() { - return impl_staticGetSupportedServiceNames(); + return { "com.sun.star.embed.OOoSpecialEmbeddedObjectFactory", "com.sun.star.comp.embed.OOoSpecialEmbeddedObjectFactory" }; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +embeddedobj_OOoSpecialEmbeddedObjectFactory_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + static rtl::Reference<OOoSpecialEmbeddedObjectFactory> g_Instance(new OOoSpecialEmbeddedObjectFactory(context)); + g_Instance->acquire(); + return static_cast<cppu::OWeakObject*>(g_Instance.get()); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/embeddedobj/source/commonembedding/xfactory.hxx b/embeddedobj/source/commonembedding/xfactory.hxx index 48bef30ea79d..87ff4886a20c 100644 --- a/embeddedobj/source/commonembedding/xfactory.hxx +++ b/embeddedobj/source/commonembedding/xfactory.hxx @@ -45,15 +45,6 @@ public: OSL_ENSURE( rxContext.is(), "No service manager is provided!" ); } - static css::uno::Sequence< OUString > impl_staticGetSupportedServiceNames(); - - static OUString impl_staticGetImplementationName(); - - static css::uno::Reference< css::uno::XInterface > - impl_staticCreateSelfInstance( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - - // XEmbedObjectCreator virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitNew( const css::uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName, const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceInitFromEntry( const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, const css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; @@ -92,14 +83,6 @@ public: OSL_ENSURE( rxContext.is(), "No service manager is provided!" ); } - static css::uno::Sequence< OUString > impl_staticGetSupportedServiceNames(); - - static OUString impl_staticGetImplementationName(); - - static css::uno::Reference< css::uno::XInterface > - impl_staticCreateSelfInstance( - const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - // XEmbedObjectFactory virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceUserInit( const css::uno::Sequence< sal_Int8 >& aClassID, const OUString& aClassName, const css::uno::Reference< css::embed::XStorage >& xStorage, const OUString& sEntName, sal_Int32 nEntryConnectionMode, const css::uno::Sequence< css::beans::PropertyValue >& lArguments, const css::uno::Sequence< css::beans::PropertyValue >& lObjArgs ) override; |