diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-06 14:22:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-11 14:54:24 +0200 |
commit | 45c8885705afd585b1d59bf793ceaa39abef3eae (patch) | |
tree | 4bf3c6ccc1d39a636bd14dc83dd09d31bc7c4d9e /vbahelper | |
parent | a97224fe77c857831634df198792e368be1d61a2 (diff) |
vbahelper: create instances with uno constructors
See tdf#74608 for motivation
Change-Id: I190d58fe45aa0b724b7239f5417bd0293d6dca80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98234
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vbahelper')
-rw-r--r-- | vbahelper/Library_msforms.mk | 1 | ||||
-rw-r--r-- | vbahelper/source/msforms/service.cxx | 45 | ||||
-rw-r--r-- | vbahelper/source/msforms/service.hxx | 27 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbacontrol.cxx | 43 | ||||
-rw-r--r-- | vbahelper/source/msforms/vbauserform.cxx | 18 | ||||
-rw-r--r-- | vbahelper/util/msforms.component | 8 |
6 files changed, 37 insertions, 105 deletions
diff --git a/vbahelper/Library_msforms.mk b/vbahelper/Library_msforms.mk index c9424d6f2716..2a5cb1ed942d 100644 --- a/vbahelper/Library_msforms.mk +++ b/vbahelper/Library_msforms.mk @@ -58,7 +58,6 @@ $(eval $(call gb_Library_use_libraries,msforms,\ # add all source files that shall be compiled with exceptions enabled # the name is relative to $(SRCROOT) and must not contain an extension $(eval $(call gb_Library_add_exception_objects,msforms,\ - vbahelper/source/msforms/service \ vbahelper/source/msforms/vbabutton \ vbahelper/source/msforms/vbacheckbox \ vbahelper/source/msforms/vbacombobox \ diff --git a/vbahelper/source/msforms/service.cxx b/vbahelper/source/msforms/service.cxx deleted file mode 100644 index ed348af03570..000000000000 --- a/vbahelper/source/msforms/service.cxx +++ /dev/null @@ -1,45 +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 <comphelper/servicedecl.hxx> -#include <sal/log.hxx> - -#include "service.hxx" - -// component exports - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace sdecl = comphelper::service_decl; - -extern "C" -{ - SAL_DLLPUBLIC_EXPORT void * msforms_component_getFactory( - const char * pImplName, void *, void *) - { - SAL_INFO("vbahelper", "In component_getFactory for " << pImplName ); - void* pRet = sdecl::component_getFactoryHelper( - pImplName, {&controlprovider::serviceDecl, &userform::serviceDecl} ); - SAL_INFO("vbahelper", "Ret is 0x" << std::hex << pRet); - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/service.hxx b/vbahelper/source/msforms/service.hxx deleted file mode 100644 index a94d54e3c411..000000000000 --- a/vbahelper/source/msforms/service.hxx +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * 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/. - */ - -#ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_SERVICE_HXX -#define INCLUDED_VBAHELPER_SOURCE_MSFORMS_SERVICE_HXX - -#include <sal/config.h> - -namespace comphelper::service_decl { class ServiceDecl; } - -namespace controlprovider { -extern comphelper::service_decl::ServiceDecl const serviceDecl; -} - -namespace userform { -extern comphelper::service_decl::ServiceDecl const serviceDecl; -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 8efb94de7780..af21ad4bfa01 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/awt/XActionListener.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -37,7 +38,6 @@ #include <ooo/vba/XControlProvider.hpp> #include <ooo/vba/msforms/fmMousePointer.hpp> #include <svtools/bindablecontrolhelper.hxx> -#include "service.hxx" #include "vbacontrol.hxx" #include "vbacombobox.hxx" #include "vbabutton.hxx" @@ -56,11 +56,11 @@ #include "vbaimage.hxx" #include <toolkit/helper/vclunohelper.hxx> #include <vcl/window.hxx> -#include <comphelper/servicedecl.hxx> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> #include <svx/svdobj.hxx> #include <cppuhelper/implbase.hxx> +#include <cppuhelper/supportsservice.hxx> using namespace com::sun::star; using namespace ooo::vba; @@ -707,11 +707,7 @@ ScVbaControl::getServiceImplName() uno::Sequence< OUString > ScVbaControl::getServiceNames() { - static uno::Sequence< OUString > const aServiceNames - { - "ooo.vba.excel.Control" - }; - return aServiceNames; + return { "ooo.vba.excel.Control" }; } sal_Int32 const nSysCols[] = { 0xC8D0D4, 0x0, 0x6A240A, 0x808080, 0xE4E4E4, 0xFFFFFF, 0x0, 0x0, 0x0, 0xFFFFFF, 0xE4E4E4, 0xE4E4E4, 0x808080, 0x6A240A, 0xFFFFFF, 0xE4E4E4, 0x808080, 0x808080, 0x0, 0xC8D0D4, 0xFFFFFF, 0x404040, 0xE4E4E4, 0x0, 0xE1FFFF }; @@ -767,16 +763,35 @@ void ScVbaControl::setLocked( bool bLocked ) namespace { -class ControlProviderImpl : public cppu::WeakImplHelper< XControlProvider > +class ControlProviderImpl : public cppu::WeakImplHelper< XControlProvider, css::lang::XServiceInfo > { uno::Reference< uno::XComponentContext > m_xCtx; public: explicit ControlProviderImpl( const uno::Reference< uno::XComponentContext >& xCtx ) : m_xCtx( xCtx ) {} virtual uno::Reference< msforms::XControl > SAL_CALL createControl( const uno::Reference< drawing::XControlShape >& xControl, const uno::Reference< frame::XModel >& xDocOwner ) override; + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override; + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; } +// XServiceInfo +sal_Bool ControlProviderImpl::supportsService(const OUString& sServiceName) +{ + return cppu::supportsService(this, sServiceName); +} +OUString ControlProviderImpl::getImplementationName() +{ + return "ControlProviderImpl"; +} +css::uno::Sequence< OUString > ControlProviderImpl::getSupportedServiceNames() +{ + return { "ooo.vba.ControlProvider" }; +} + uno::Reference< msforms::XControl > SAL_CALL ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape >& xControlShape, const uno::Reference< frame::XModel >& xDocOwner ) { @@ -787,15 +802,11 @@ ControlProviderImpl::createControl( const uno::Reference< drawing::XControlShape } -namespace controlprovider +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ControlProviderImpl_get_implementation( + css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&) { -namespace sdecl = comphelper::service_decl; -sdecl::class_<ControlProviderImpl, sdecl::with_args<false> > const serviceImpl; -sdecl::ServiceDecl const serviceDecl( - serviceImpl, - "ControlProviderImpl", - "ooo.vba.ControlProvider" ); + return cppu::acquire(new ControlProviderImpl(context)); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index a89ab604a4ef..e2719bc135e9 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include <vbahelper/helperdecl.hxx> -#include "service.hxx" #include "vbauserform.hxx" #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XControlContainer.hpp> @@ -184,11 +183,7 @@ ScVbaUserForm::getServiceImplName() uno::Sequence< OUString > ScVbaUserForm::getServiceNames() { - static uno::Sequence< OUString > const aServiceNames - { - "ooo.vba.excel.UserForm" - }; - return aServiceNames; + return { "ooo.vba.excel.UserForm" }; } uno::Reference< beans::XIntrospectionAccess > SAL_CALL @@ -307,14 +302,11 @@ ScVbaUserForm::hasProperty( const OUString& aName ) return false; } -namespace userform +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ScVbaUserForm_get_implementation( + css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const& args) { -namespace sdecl = comphelper::service_decl; -sdecl::vba_service_class_<ScVbaUserForm, sdecl::with_args<true> > const serviceImpl; -sdecl::ServiceDecl const serviceDecl( - serviceImpl, - "ScVbaUserForm", - "ooo.vba.msforms.UserForm" ); + return cppu::acquire(new ScVbaUserForm(args, context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vbahelper/util/msforms.component b/vbahelper/util/msforms.component index 7f48716f6754..eb70eb2a66c4 100644 --- a/vbahelper/util/msforms.component +++ b/vbahelper/util/msforms.component @@ -18,11 +18,13 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="msforms" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="ControlProviderImpl"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="ControlProviderImpl" + constructor="ControlProviderImpl_get_implementation"> <service name="ooo.vba.ControlProvider"/> </implementation> - <implementation name="ScVbaUserForm"> + <implementation name="ScVbaUserForm" + constructor="ScVbaUserForm_get_implementation"> <service name="ooo.vba.msforms.UserForm"/> </implementation> </component> |