summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-25 09:50:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-25 10:39:24 +0200
commit008b3845201f9cc036a19600a78a1b32bf1b3fbe (patch)
tree8cfb40bcfeb5d2e8814982ac65373340d6a4d412 /filter
parentinline some use-once constants (diff)
downloadcore-008b3845201f9cc036a19600a78a1b32bf1b3fbe.tar.gz
core-008b3845201f9cc036a19600a78a1b32bf1b3fbe.zip
filter/config: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: I4423d3acd0a3c77bb7e553511e296f682f87b3e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99419 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r--filter/Library_filterconfig.mk1
-rw-r--r--filter/source/config/cache/configflush.cxx29
-rw-r--r--filter/source/config/cache/configflush.hxx6
-rw-r--r--filter/source/config/cache/filterconfig1.component5
-rw-r--r--filter/source/config/cache/registration.cxx66
5 files changed, 14 insertions, 93 deletions
diff --git a/filter/Library_filterconfig.mk b/filter/Library_filterconfig.mk
index e9cd6bfabd5a..79557890786c 100644
--- a/filter/Library_filterconfig.mk
+++ b/filter/Library_filterconfig.mk
@@ -55,7 +55,6 @@ $(eval $(call gb_Library_add_exception_objects,filterconfig,\
filter/source/config/cache/filterfactory \
filter/source/config/cache/frameloaderfactory \
filter/source/config/cache/querytokenizer \
- filter/source/config/cache/registration \
filter/source/config/cache/typedetection \
))
diff --git a/filter/source/config/cache/configflush.cxx b/filter/source/config/cache/configflush.cxx
index 97699c2c0508..e0c4ca58f641 100644
--- a/filter/source/config/cache/configflush.cxx
+++ b/filter/source/config/cache/configflush.cxx
@@ -19,6 +19,8 @@
#include "configflush.hxx"
#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <rtl/ref.hxx>
namespace filter::config{
@@ -35,7 +37,7 @@ ConfigFlush::~ConfigFlush()
OUString SAL_CALL ConfigFlush::getImplementationName()
{
- return impl_getImplementationName();
+ return "com.sun.star.comp.filter.config.ConfigFlush";
// <- SAFE
}
@@ -46,7 +48,7 @@ sal_Bool SAL_CALL ConfigFlush::supportsService(const OUString& sServiceName)
css::uno::Sequence< OUString > SAL_CALL ConfigFlush::getSupportedServiceNames()
{
- return impl_getSupportedServiceNames();
+ return { "com.sun.star.document.FilterConfigRefresh" };
}
void SAL_CALL ConfigFlush::refresh()
@@ -99,24 +101,15 @@ void SAL_CALL ConfigFlush::removeRefreshListener(const css::uno::Reference< css:
}
-OUString ConfigFlush::impl_getImplementationName()
-{
- return "com.sun.star.comp.filter.config.ConfigFlush";
-}
-
-
-css::uno::Sequence< OUString > ConfigFlush::impl_getSupportedServiceNames()
-{
- return { "com.sun.star.document.FilterConfigRefresh" };
-}
-
+} // namespace filter::config
-css::uno::Reference< css::uno::XInterface > ConfigFlush::impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+filter_ConfigFlush_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
{
- ConfigFlush* pNew = new ConfigFlush;
- return css::uno::Reference< css::uno::XInterface >(static_cast< css::util::XRefreshable* >(pNew), css::uno::UNO_QUERY);
+ static rtl::Reference<filter::config::ConfigFlush> g_Instance(new filter::config::ConfigFlush());
+ g_Instance->acquire();
+ return static_cast<cppu::OWeakObject*>(g_Instance.get());
}
-} // namespace filter::config
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/config/cache/configflush.hxx b/filter/source/config/cache/configflush.hxx
index 179d59d74ff6..1546956e6a2b 100644
--- a/filter/source/config/cache/configflush.hxx
+++ b/filter/source/config/cache/configflush.hxx
@@ -84,12 +84,6 @@ class ConfigFlush final : public BaseLock
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener) override;
virtual void SAL_CALL removeRefreshListener(const css::uno::Reference< css::util::XRefreshListener >& xListener) override;
-
-
- // interface to register/create this instance as a UNO service
- static OUString impl_getImplementationName();
- static css::uno::Sequence< OUString > impl_getSupportedServiceNames();
- static css::uno::Reference< css::uno::XInterface > impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
};
} // namespace filter::config
diff --git a/filter/source/config/cache/filterconfig1.component b/filter/source/config/cache/filterconfig1.component
index da841a112962..9597348890ee 100644
--- a/filter/source/config/cache/filterconfig1.component
+++ b/filter/source/config/cache/filterconfig1.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="filterconfig1" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.filter.config.ConfigFlush">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.filter.config.ConfigFlush"
+ constructor="filter_ConfigFlush_get_implementation">
<service name="com.sun.star.document.FilterConfigRefresh"/>
</implementation>
<implementation name="com.sun.star.comp.filter.config.ContentHandlerFactory"
diff --git a/filter/source/config/cache/registration.cxx b/filter/source/config/cache/registration.cxx
deleted file mode 100644
index 76e7775913c3..000000000000
--- a/filter/source/config/cache/registration.cxx
+++ /dev/null
@@ -1,66 +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 <cppuhelper/factory.hxx>
-
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "typedetection.hxx"
-#include "filterfactory.hxx"
-#include "contenthandlerfactory.hxx"
-#include "frameloaderfactory.hxx"
-#include "configflush.hxx"
-
-
-namespace filter::config{
-
-
-extern "C" SAL_DLLPUBLIC_EXPORT void*
- filterconfig1_component_getFactory( const char* pImplementationName,
- void* pServiceManager,
- void* /* pRegistryKey */ )
-{
- if ((!pImplementationName) || (!pServiceManager ))
- return nullptr;
-
- css::uno::Reference< css::lang::XMultiServiceFactory >
- xSMGR = static_cast< css::lang::XMultiServiceFactory* >(pServiceManager);
- css::uno::Reference< css::lang::XSingleServiceFactory > xFactory;
- OUString sImplName = OUString::createFromAscii(pImplementationName);
-
- if (ConfigFlush::impl_getImplementationName() == sImplName)
- xFactory = cppu::createOneInstanceFactory( xSMGR,
- ConfigFlush::impl_getImplementationName(),
- ConfigFlush::impl_createInstance,
- ConfigFlush::impl_getSupportedServiceNames() );
-
- /* And if one of these checks was successful => xFactory was set! */
- if (xFactory.is())
- {
- xFactory->acquire();
- return xFactory.get();
- }
-
- return nullptr;
-}
-
-} // namespace filter::config
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */