summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-06 13:54:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-07 11:34:36 +0200
commitb719e02868d364849b26080fa4182d4adfc68250 (patch)
tree64e06c4bbdd9313925a32b1752b0347c7df021ed /xmlhelp
parent439c9460408bb379cf2d37f3831461cf6879fb74 (diff)
xmlhelp: create instances with uno constructors
See tdf#74608 for motivation Change-Id: Id05885b9da95009609cf8875be489aa88fd5a3cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98232 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/Library_ucpchelp1.mk1
-rw-r--r--xmlhelp/source/cxxhelp/inc/tvfactory.hxx15
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.cxx43
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.hxx14
-rw-r--r--xmlhelp/source/cxxhelp/provider/services.cxx58
-rw-r--r--xmlhelp/source/treeview/tvfactory.cxx37
-rw-r--r--xmlhelp/util/ucpchelp1.component8
7 files changed, 20 insertions, 156 deletions
diff --git a/xmlhelp/Library_ucpchelp1.mk b/xmlhelp/Library_ucpchelp1.mk
index 506ddad704d5..ac4b5e0f7196 100644
--- a/xmlhelp/Library_ucpchelp1.mk
+++ b/xmlhelp/Library_ucpchelp1.mk
@@ -54,7 +54,6 @@ $(eval $(call gb_Library_add_exception_objects,ucpchelp1,\
xmlhelp/source/cxxhelp/provider/resultsetbase \
xmlhelp/source/cxxhelp/provider/resultsetforquery \
xmlhelp/source/cxxhelp/provider/resultsetforroot \
- xmlhelp/source/cxxhelp/provider/services \
xmlhelp/source/cxxhelp/provider/urlparameter \
xmlhelp/source/treeview/tvfactory \
xmlhelp/source/treeview/tvread \
diff --git a/xmlhelp/source/cxxhelp/inc/tvfactory.hxx b/xmlhelp/source/cxxhelp/inc/tvfactory.hxx
index 992c9fc3747e..6ca53c7f52e4 100644
--- a/xmlhelp/source/cxxhelp/inc/tvfactory.hxx
+++ b/xmlhelp/source/cxxhelp/inc/tvfactory.hxx
@@ -65,21 +65,6 @@ class TVFactory final : public cppu::WeakImplHelper <
virtual css::uno::Sequence< OUString > SAL_CALL
getAvailableServiceNames( ) override;
- // Other
-
- static OUString getImplementationName_static();
-
- static css::uno::Sequence< OUString > getSupportedServiceNames_static();
-
- static css::uno::Reference< css::lang::XSingleServiceFactory >
- createServiceFactory(
- const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr );
-
- static css::uno::Reference< css::uno::XInterface > SAL_CALL
- CreateInstance(
- const css::uno::Reference< css::lang::XMultiServiceFactory >& xMultiServiceFactory );
-
-
private:
// Members
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index b82ba4917d24..6f690da96583 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -39,6 +39,7 @@
using namespace com::sun::star;
using namespace chelp;
+
// ContentProvider Implementation.
ContentProvider::ContentProvider( const uno::Reference< uno::XComponentContext >& rxContext )
@@ -103,11 +104,6 @@ css::uno::Sequence< css::uno::Type > SAL_CALL ContentProvider::getTypes()
OUString SAL_CALL ContentProvider::getImplementationName()
{
- return getImplementationName_Static();
-}
-
-OUString ContentProvider::getImplementationName_Static()
-{
return "CHelpContentProvider";
}
@@ -120,35 +116,7 @@ ContentProvider::supportsService(const OUString& ServiceName )
uno::Sequence< OUString > SAL_CALL
ContentProvider::getSupportedServiceNames()
{
- return getSupportedServiceNames_Static();
-}
-
-/// @throws uno::Exception
-static uno::Reference< uno::XInterface >
-ContentProvider_CreateInstance(
- const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
-{
- lang::XServiceInfo * pX = new ContentProvider( comphelper::getComponentContext(rSMgr) );
- return uno::Reference< uno::XInterface >::query( pX );
-}
-
-uno::Sequence< OUString >
-ContentProvider::getSupportedServiceNames_Static()
-{
- return { MYUCP_CONTENT_PROVIDER_SERVICE_NAME1, MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 };
-}
-
-// Service factory implementation.
-
-css::uno::Reference< css::lang::XSingleServiceFactory >
-ContentProvider::createServiceFactory( const css::uno::Reference<
- css::lang::XMultiServiceFactory >& rxServiceMgr )
-{
- return cppu::createOneInstanceFactory(
- rxServiceMgr,
- ContentProvider::getImplementationName_Static(),
- ContentProvider_CreateInstance,
- ContentProvider::getSupportedServiceNames_Static() );
+ return { "com.sun.star.help.XMLHelp", "com.sun.star.ucb.HelpContentProvider" };
}
// XContentProvider methods.
@@ -268,4 +236,11 @@ void ContentProvider::subst( OUString& instpath )
instpath = aOptions.SubstituteVariable( instpath );
}
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+CHelpContentProvider_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new ContentProvider(context));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlhelp/source/cxxhelp/provider/provider.hxx b/xmlhelp/source/cxxhelp/provider/provider.hxx
index c12d0cb7b995..0e752d34f56a 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.hxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.hxx
@@ -31,13 +31,6 @@
namespace chelp {
-// UNO service name for the provider. This name will be used by the UCB to
-// create instances of the provider.
-
-#define MYUCP_CONTENT_PROVIDER_SERVICE_NAME1 "com.sun.star.help.XMLHelp"
-
-#define MYUCP_CONTENT_PROVIDER_SERVICE_NAME2 "com.sun.star.ucb.HelpContentProvider"
-
// URL scheme. This is the scheme the provider will be able to create
// contents for. The UCB will select the provider ( i.e. in order to create
// contents ) according to this scheme.
@@ -74,13 +67,6 @@ namespace chelp {
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- static OUString getImplementationName_Static();
-
- static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
-
- static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(
- const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr );
-
// XContentProvider
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(
const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override;
diff --git a/xmlhelp/source/cxxhelp/provider/services.cxx b/xmlhelp/source/cxxhelp/provider/services.cxx
deleted file mode 100644
index f1541d5c4b87..000000000000
--- a/xmlhelp/source/cxxhelp/provider/services.cxx
+++ /dev/null
@@ -1,58 +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/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "provider.hxx"
-#include <tvfactory.hxx>
-
-using namespace com::sun::star;
-
-extern "C" SAL_DLLPUBLIC_EXPORT void * ucpchelp_component_getFactory(
- const char * pImplName,
- void * pServiceManager,
- SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
-{
- void * pRet = nullptr;
-
- uno::Reference< lang::XMultiServiceFactory > xSMgr(
- static_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
- uno::Reference< lang::XSingleServiceFactory > xFactory;
-
- if ( ::chelp::ContentProvider::getImplementationName_Static().
- equalsAscii( pImplName ) )
- {
- xFactory = ::chelp::ContentProvider::createServiceFactory( xSMgr );
- }
- else if ( treeview::TVFactory::getImplementationName_static().equalsAscii( pImplName ) )
- {
- xFactory = treeview::TVFactory::createServiceFactory( xSMgr );
- }
-
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
-
- return pRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlhelp/source/treeview/tvfactory.cxx b/xmlhelp/source/treeview/tvfactory.cxx
index 9f59b66e4025..fb879a5c3229 100644
--- a/xmlhelp/source/treeview/tvfactory.cxx
+++ b/xmlhelp/source/treeview/tvfactory.cxx
@@ -48,7 +48,7 @@ TVFactory::~TVFactory()
OUString SAL_CALL
TVFactory::getImplementationName()
{
- return TVFactory::getImplementationName_static();
+ return "com.sun.star.help.TreeViewImpl";
}
sal_Bool SAL_CALL TVFactory::supportsService( const OUString& ServiceName )
@@ -59,7 +59,7 @@ sal_Bool SAL_CALL TVFactory::supportsService( const OUString& ServiceName )
Sequence< OUString > SAL_CALL
TVFactory::getSupportedServiceNames()
{
- return TVFactory::getSupportedServiceNames_static();
+ return { "com.sun.star.help.TreeView", "com.sun.star.ucb.HiearchyDataSource" };
}
// XMultiServiceFactory
@@ -121,37 +121,12 @@ TVFactory::getAvailableServiceNames( )
return { "com.sun.star.ucb.HierarchyDataReadAccess" };
}
-// static
-
-OUString
-TVFactory::getImplementationName_static()
-{
- return "com.sun.star.help.TreeViewImpl";
-}
-
-Sequence< OUString >
-TVFactory::getSupportedServiceNames_static()
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_help_TreeViewImpl_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
- return { "com.sun.star.help.TreeView", "com.sun.star.ucb.HiearchyDataSource" };
-}
-
-Reference< XSingleServiceFactory >
-TVFactory::createServiceFactory(
- const Reference< XMultiServiceFactory >& rxServiceMgr )
-{
- return cppu::createSingleFactory(
- rxServiceMgr,
- TVFactory::getImplementationName_static(),
- TVFactory::CreateInstance,
- TVFactory::getSupportedServiceNames_static() );
+ return cppu::acquire(new TVFactory(context));
}
-Reference< XInterface > SAL_CALL
-TVFactory::CreateInstance(
- const Reference< XMultiServiceFactory >& xMultiServiceFactory )
-{
- return static_cast<XServiceInfo*>(
- new TVFactory(comphelper::getComponentContext(xMultiServiceFactory)));
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlhelp/util/ucpchelp1.component b/xmlhelp/util/ucpchelp1.component
index 3df772cee1ae..dc1934ddfdcc 100644
--- a/xmlhelp/util/ucpchelp1.component
+++ b/xmlhelp/util/ucpchelp1.component
@@ -18,12 +18,14 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="ucpchelp" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="CHelpContentProvider">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="CHelpContentProvider"
+ constructor="CHelpContentProvider_get_implementation">
<service name="com.sun.star.help.XMLHelp"/>
<service name="com.sun.star.ucb.HelpContentProvider"/>
</implementation>
- <implementation name="com.sun.star.help.TreeViewImpl">
+ <implementation name="com.sun.star.help.TreeViewImpl"
+ constructor="com_sun_star_help_TreeViewImpl_get_implementation">
<service name="com.sun.star.help.TreeView"/>
<service name="com.sun.star.ucb.HiearchyDataSource"/>
</implementation>