sw/Library_vbaswobj.mk               |    1 
 sw/source/ui/vba/service.cxx         |   39 -----------------------------------
 sw/source/ui/vba/service.hxx         |   35 -------------------------------
 sw/source/ui/vba/vbadocument.cxx     |   13 ++++-------
 sw/source/ui/vba/vbaeventshelper.cxx |   29 +++++++++++++++++---------
 sw/source/ui/vba/vbaeventshelper.hxx |    5 ++++
 sw/source/ui/vba/vbaglobals.cxx      |   18 ++++------------
 sw/source/ui/vba/vbawrapformat.cxx   |   13 ++++-------
 sw/util/vbaswobj.component           |   11 +++++----
 9 files changed, 46 insertions(+), 118 deletions(-)

New commits:
commit d12f2e9025250a7e310078ff736f8c6756cf894d
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Jul 26 17:06:45 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jul 27 21:09:44 2020 +0200

    sw/vba: create instances with uno constructors
    
    See tdf#74608 for motivation.
    
    Change-Id: Ieaa5ef1eef7488d7b53454bdd3b14702de909beb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99519
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/Library_vbaswobj.mk b/sw/Library_vbaswobj.mk
index 2b2a5bef6e7b..822c986898d1 100644
--- a/sw/Library_vbaswobj.mk
+++ b/sw/Library_vbaswobj.mk
@@ -62,7 +62,6 @@ $(eval $(call gb_Library_use_externals,vbaswobj,\
 ))
 
 $(eval $(call gb_Library_add_exception_objects,vbaswobj,\
-    sw/source/ui/vba/service \
     sw/source/ui/vba/vbarange \
     sw/source/ui/vba/vbacell \
     sw/source/ui/vba/vbacells \
diff --git a/sw/source/ui/vba/service.cxx b/sw/source/ui/vba/service.cxx
deleted file mode 100644
index 43345e302eb1..000000000000
--- a/sw/source/ui/vba/service.cxx
+++ /dev/null
@@ -1,39 +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
-
-namespace sdecl = comphelper::service_decl;
-
-extern "C" SAL_DLLPUBLIC_EXPORT void * vbaswobj_component_getFactory(
-    const char * pImplName, void *, void *)
-{
-    void* pRet = sdecl::component_getFactoryHelper(pImplName,
-            {&globals::serviceDecl, &::document::serviceDecl,
-             &wrapformat::serviceDecl, &vbaeventshelper::serviceDecl} );
-    SAL_INFO("sw.vba", "Ret is " << pRet);
-    return pRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/vba/service.hxx b/sw/source/ui/vba/service.hxx
deleted file mode 100644
index 3ed37ff0ffe5..000000000000
--- a/sw/source/ui/vba/service.hxx
+++ /dev/null
@@ -1,35 +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_SW_SOURCE_UI_VBA_SERVICE_HXX
-#define INCLUDED_SW_SOURCE_UI_VBA_SERVICE_HXX
-
-#include <sal/config.h>
-
-namespace comphelper::service_decl { class ServiceDecl; }
-
-namespace document {
-extern comphelper::service_decl::ServiceDecl const serviceDecl;
-}
-
-namespace globals {
-extern comphelper::service_decl::ServiceDecl const serviceDecl;
-}
-
-namespace vbaeventshelper {
-extern comphelper::service_decl::ServiceDecl const serviceDecl;
-}
-
-namespace wrapformat {
-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/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index 9d91960e55be..beb74b865e98 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -20,7 +20,6 @@
 #include <sal/config.h>
 #include <sal/log.hxx>
 
-#include "service.hxx"
 #include "vbafilterpropsfromformat.hxx"
 #include "vbadocument.hxx"
 #include "vbarange.hxx"
@@ -708,14 +707,12 @@ SwVbaDocument::getServiceNames()
     return aServiceNames;
 }
 
-namespace document
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+Writer_SwVbaDocument_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> 
const& args)
 {
-namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<SwVbaDocument, sdecl::with_args<true> > const 
serviceImpl;
-sdecl::ServiceDecl const serviceDecl(
-    serviceImpl,
-    "SwVbaDocument",
-    "ooo.vba.word.Document" );
+    return cppu::acquire(new SwVbaDocument(args, context));
 }
 
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/vba/vbaeventshelper.cxx 
b/sw/source/ui/vba/vbaeventshelper.cxx
index 5b53c6fc9950..c1273b5038bf 100644
--- a/sw/source/ui/vba/vbaeventshelper.cxx
+++ b/sw/source/ui/vba/vbaeventshelper.cxx
@@ -19,11 +19,10 @@
 
 #include <sal/config.h>
 
-#include "service.hxx"
 #include "vbaeventshelper.hxx"
 #include <com/sun/star/script/ModuleType.hpp>
 #include <com/sun/star/script/vba/VBAEventId.hpp>
-#include <comphelper/servicedecl.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::script::vba::VBAEventId;
@@ -82,14 +81,26 @@ OUString SwVbaEventsHelper::implGetDocumentModuleName( 
const EventHandlerInfo& /
     return "ThisDocument";
 }
 
-namespace vbaeventshelper
+    // XServiceInfo
+OUString SwVbaEventsHelper::getImplementationName()
 {
-namespace sdecl = comphelper::service_decl;
-sdecl::inheritingClass_<SwVbaEventsHelper, sdecl::with_args<true> > const 
serviceImpl;
-sdecl::ServiceDecl const serviceDecl(
-    serviceImpl,
-    "SwVbaEventsHelper",
-    "com.sun.star.document.vba.VBATextEventProcessor" );
+    return "SwVbaEventsHelper";
+}
+sal_Bool SwVbaEventsHelper::supportsService( const OUString& ServiceName )
+{
+    return cppu::supportsService(this, ServiceName);
+}
+css::uno::Sequence< OUString > SwVbaEventsHelper::getSupportedServiceNames()
+{
+    return { "com.sun.star.document.vba.VBATextEventProcessor" };
+}
+
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+Writer_SwVbaEventsHelper_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> 
const& args)
+{
+    return cppu::acquire(new SwVbaEventsHelper(args, context));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/vba/vbaeventshelper.hxx 
b/sw/source/ui/vba/vbaeventshelper.hxx
index 03a2f8a45f2b..31a6b2808ee9 100644
--- a/sw/source/ui/vba/vbaeventshelper.hxx
+++ b/sw/source/ui/vba/vbaeventshelper.hxx
@@ -30,6 +30,11 @@ public:
         const css::uno::Reference< css::uno::XComponentContext >& rxContext );
     virtual ~SwVbaEventsHelper() override;
 
+    // XServiceInfo
+    virtual OUString SAL_CALL getImplementationName() override;
+    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) 
override;
+    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() 
override;
+
 protected:
     virtual bool implPrepareEvent( EventQueue& rEventQueue, const 
EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) 
override;
     virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const 
EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) 
override;
diff --git a/sw/source/ui/vba/vbaglobals.cxx b/sw/source/ui/vba/vbaglobals.cxx
index 527d6c61e787..7041b3b24d7b 100644
--- a/sw/source/ui/vba/vbaglobals.cxx
+++ b/sw/source/ui/vba/vbaglobals.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 #include <vbahelper/helperdecl.hxx>
-#include "service.hxx"
 #include "vbaglobals.hxx"
 #include <sal/log.hxx>
 
@@ -139,11 +138,7 @@ SwVbaGlobals::getServiceImplName()
 uno::Sequence< OUString >
 SwVbaGlobals::getServiceNames()
 {
-        static uno::Sequence< OUString > const aServiceNames
-        {
-            "ooo.vba.word.Globals"
-        };
-        return aServiceNames;
+    return { "ooo.vba.word.Globals" };
 }
 
 uno::Sequence< OUString >
@@ -161,14 +156,11 @@ SwVbaGlobals::getAvailableServiceNames(  )
     return serviceNames;
 }
 
-namespace globals
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+Writer_SwVbaGlobals_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> 
const& args)
 {
-namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<SwVbaGlobals, sdecl::with_args<true> > const 
serviceImpl;
-sdecl::ServiceDecl const serviceDecl(
-    serviceImpl,
-    "SwVbaGlobals",
-    "ooo.vba.word.Globals" );
+    return cppu::acquire(new SwVbaGlobals(args, context));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/vba/vbawrapformat.cxx 
b/sw/source/ui/vba/vbawrapformat.cxx
index b854027fe3d0..a8c1d69729f9 100644
--- a/sw/source/ui/vba/vbawrapformat.cxx
+++ b/sw/source/ui/vba/vbawrapformat.cxx
@@ -19,7 +19,6 @@
 
 #include <sal/config.h>
 
-#include "service.hxx"
 #include "vbawrapformat.hxx"
 #include <ooo/vba/word/WdWrapSideType.hpp>
 #include <ooo/vba/word/WdWrapType.hpp>
@@ -234,14 +233,12 @@ SwVbaWrapFormat::getServiceNames()
     return aServiceNames;
 }
 
-namespace wrapformat
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+Writer_SwVbaWrapFormat_get_implementation(
+    css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> 
const& args)
 {
-namespace sdecl = comphelper::service_decl;
-sdecl::vba_service_class_<SwVbaWrapFormat, sdecl::with_args<true> > const 
serviceImpl;
-sdecl::ServiceDecl const serviceDecl(
-    serviceImpl,
-    "SwVbaWrapFormat",
-    "ooo.vba.word.WrapFormat" );
+    return cppu::acquire(new SwVbaWrapFormat(args, context));
 }
 
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/util/vbaswobj.component b/sw/util/vbaswobj.component
index 07cff4402ec1..99ea11407d74 100644
--- a/sw/util/vbaswobj.component
+++ b/sw/util/vbaswobj.component
@@ -18,17 +18,18 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="vbaswobj" xmlns="http://openoffice.org/2010/uno-components";>
-  <implementation name="SwVbaDocument">
+    xmlns="http://openoffice.org/2010/uno-components";>
+  <implementation name="SwVbaDocument" 
constructor="Writer_SwVbaDocument_get_implementation">
     <service name="ooo.vba.word.Document"/>
   </implementation>
-  <implementation name="SwVbaEventsHelper">
+  <implementation name="SwVbaEventsHelper" 
constructor="Writer_SwVbaEventsHelper_get_implementation">
     <service name="com.sun.star.document.vba.VBATextEventProcessor"/>
   </implementation>
-  <implementation name="SwVbaGlobals">
+  <implementation name="SwVbaGlobals" 
constructor="Writer_SwVbaGlobals_get_implementation">
     <service name="ooo.vba.word.Globals"/>
   </implementation>
-  <implementation name="SwVbaWrapFormat">
+  <implementation name="SwVbaWrapFormat"
+    constructor="Writer_SwVbaWrapFormat_get_implementation">
     <service name="ooo.vba.word.WrapFormat"/>
   </implementation>
 </component>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to