summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-08 15:44:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-09 11:02:45 +0200
commit3cff8c64e916eac04332c91d0bd424d4459a960b (patch)
tree33a73ff33e5f3fa4f6b30f572494fb0f72d54460
parent57fedb272cfcad3436142dbe9eac2870e3c3e3d2 (diff)
unotools: create instances with uno constructors
See tdf#74608 for motivation Change-Id: I7a68484564aea9b416c12d5364d20ff8af77f40b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98380 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rwxr-xr-xsolenv/bin/native-code.py4
-rw-r--r--unotools/IwyuFilter_unotools.yaml3
-rw-r--r--unotools/Library_utl.mk1
-rw-r--r--unotools/inc/pch/precompiled_utl.hxx1
-rw-r--r--unotools/inc/unotoolsservices.hxx22
-rw-r--r--unotools/source/misc/ServiceDocumenter.cxx51
-rw-r--r--unotools/source/misc/ServiceDocumenter.hxx9
-rw-r--r--unotools/source/misc/unotoolsservices.cxx23
-rw-r--r--unotools/source/ucbhelper/XTempFile.hxx9
-rw-r--r--unotools/source/ucbhelper/xtempfile.cxx30
-rw-r--r--unotools/util/utl.component8
11 files changed, 89 insertions, 72 deletions
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 409fda1798bf..ef2ed63dbf34 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -40,7 +40,6 @@ core_factory_list = [
("libucpfile1.a", "ucpfile_component_getFactory"),
("libucphier1.a", "ucphier1_component_getFactory"),
("libucptdoc1lo.a", "ucptdoc1_component_getFactory"),
- ("libutllo.a", "utl_component_getFactory"),
("libxstor.a", "xstor_component_getFactory"),
("libxmlfdlo.a", "xmlfd_component_getFactory"),
("libxmlfalo.a", "xmlfa_component_getFactory"),
@@ -304,6 +303,9 @@ core_constructor_list = [
"stardiv_Toolkit_VCLXPointer_get_implementation",
"stardiv_Toolkit_VCLXPopupMenu_get_implementation",
"stardiv_Toolkit_VCLXToolkit_get_implementation",
+# unotools/util/utl.component
+ "unotools_ServiceDocument_get_implementation",
+ "unotools_OTempFileService_get_implementation",
# unoxml/source/rdf/unordf.component
"unoxml_rdfRepository_get_implementation",
"unoxml_CURI_get_implementation",
diff --git a/unotools/IwyuFilter_unotools.yaml b/unotools/IwyuFilter_unotools.yaml
index 74d2033fad7e..f26aa4001590 100644
--- a/unotools/IwyuFilter_unotools.yaml
+++ b/unotools/IwyuFilter_unotools.yaml
@@ -1,9 +1,6 @@
---
assumeFilename: unotools/source/i18n/resmgr.cxx
blacklist:
- unotools/inc/unotoolsservices.hxx:
- # Needed for extern declaration
- - namespace comphelper::service_decl { class ServiceDecl; } }
unotools/source/config/itemholder1.hxx:
# Base class needs complete type
- com/sun/star/lang/XEventListener.hpp
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk
index b7c06cbf4a7f..84be1bb84b70 100644
--- a/unotools/Library_utl.mk
+++ b/unotools/Library_utl.mk
@@ -108,7 +108,6 @@ $(eval $(call gb_Library_add_exception_objects,utl,\
unotools/source/misc/mediadescriptor \
unotools/source/misc/sharedunocomponent \
unotools/source/misc/syslocale \
- unotools/source/misc/unotoolsservices \
unotools/source/misc/wincodepage \
unotools/source/misc/ServiceDocumenter \
unotools/source/misc/ZipPackageHelper \
diff --git a/unotools/inc/pch/precompiled_utl.hxx b/unotools/inc/pch/precompiled_utl.hxx
index 56d6decc7aa7..e54f7c9826f4 100644
--- a/unotools/inc/pch/precompiled_utl.hxx
+++ b/unotools/inc/pch/precompiled_utl.hxx
@@ -142,7 +142,6 @@
#include <unotools/syslocaleoptions.hxx>
#include <unotools/ucbhelper.hxx>
#include <unotools/unotoolsdllapi.h>
-#include <unotoolsservices.hxx>
#endif // PCH_LEVEL >= 4
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/inc/unotoolsservices.hxx b/unotools/inc/unotoolsservices.hxx
deleted file mode 100644
index 8a99f09e99ac..000000000000
--- a/unotools/inc/unotoolsservices.hxx
+++ /dev/null
@@ -1,22 +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_UNOTOOLS_INC_UNOTOOLSSERVICES_HXX
-#define INCLUDED_UNOTOOLS_INC_UNOTOOLSSERVICES_HXX
-
-#include <sal/config.h>
-
-namespace comphelper::service_decl { class ServiceDecl; }
-
-extern comphelper::service_decl::ServiceDecl const OTempFileServiceDecl;
-extern comphelper::service_decl::ServiceDecl const ServiceDocumenterDecl;
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/unotools/source/misc/ServiceDocumenter.cxx b/unotools/source/misc/ServiceDocumenter.cxx
index 0823d2a6651e..b2decb6b9a53 100644
--- a/unotools/source/misc/ServiceDocumenter.cxx
+++ b/unotools/source/misc/ServiceDocumenter.cxx
@@ -7,10 +7,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "ServiceDocumenter.hxx"
-#include <unotoolsservices.hxx>
-#include <comphelper/servicedecl.hxx>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
+
using namespace com::sun::star;
using uno::Reference;
using lang::XServiceInfo;
@@ -65,10 +67,43 @@ void unotools::misc::ServiceDocumenter::showServiceDocs(const Reference<XService
}
}
-namespace sdecl = ::comphelper::service_decl;
-sdecl::class_< unotools::misc::ServiceDocumenter > const ServiceDocumenterImpl;
-const sdecl::ServiceDecl ServiceDocumenterDecl(
- ServiceDocumenterImpl,
- "com.sun.star.comp.unotools.misc.ServiceDocumenter",
- "");
+// XServiceInfo
+sal_Bool unotools::misc::ServiceDocumenter::supportsService(const OUString& sServiceName)
+{
+ return cppu::supportsService(this, sServiceName);
+}
+OUString unotools::misc::ServiceDocumenter::getImplementationName()
+{
+ return "com.sun.star.comp.unotools.misc.ServiceDocumenter";
+}
+css::uno::Sequence< OUString > unotools::misc::ServiceDocumenter::getSupportedServiceNames()
+{
+ return { "com.sun.star.script.ServiceDocumenter" };
+}
+
+namespace {
+
+struct Instance {
+ explicit Instance(
+ css::uno::Reference<css::uno::XComponentContext> const & context):
+ instance(new unotools::misc::ServiceDocumenter(context))
+ {}
+
+ rtl::Reference<unotools::misc::ServiceDocumenter> instance;
+};
+
+struct Singleton:
+ public rtl::StaticWithArg<
+ Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+unotools_ServiceDocument_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(static_cast<cppu::OWeakObject *>(
+ Singleton::get(context).instance.get()));
+}
diff --git a/unotools/source/misc/ServiceDocumenter.hxx b/unotools/source/misc/ServiceDocumenter.hxx
index cad333ddb59a..3d5e4d75f7c4 100644
--- a/unotools/source/misc/ServiceDocumenter.hxx
+++ b/unotools/source/misc/ServiceDocumenter.hxx
@@ -11,13 +11,14 @@
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/script/XServiceDocumenter.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
namespace com::sun::star::uno { class XComponentContext; }
namespace unotools::misc {
class ServiceDocumenter : public ::cppu::WeakImplHelper<
- css::script::XServiceDocumenter>
+ css::script::XServiceDocumenter, css::lang::XServiceInfo>
{
public:
ServiceDocumenter(css::uno::Reference< css::uno::XComponentContext> const& xContext)
@@ -25,6 +26,12 @@ class ServiceDocumenter : public ::cppu::WeakImplHelper<
, m_sCoreBaseUrl("http://example.com")
, m_sServiceBaseUrl("https://api.libreoffice.org/docs/idl/ref")
{};
+
+ // 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;
+
// XServiceDocumenter
virtual OUString SAL_CALL getCoreBaseUrl() override
{ return m_sCoreBaseUrl; };
diff --git a/unotools/source/misc/unotoolsservices.cxx b/unotools/source/misc/unotoolsservices.cxx
deleted file mode 100644
index 4d1d897f15e5..000000000000
--- a/unotools/source/misc/unotoolsservices.cxx
+++ /dev/null
@@ -1,23 +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/.
- */
-
-#include <comphelper/servicedecl.hxx>
-
-#include <unotoolsservices.hxx>
-
-namespace sdecl = ::comphelper::service_decl;
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* utl_component_getFactory(
- char const* pImplName, void*, void*)
-{
- return sdecl::component_getFactoryHelper( pImplName,
- {&OTempFileServiceDecl, &ServiceDocumenterDecl});
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/ucbhelper/XTempFile.hxx b/unotools/source/ucbhelper/XTempFile.hxx
index f96bbb8f5786..50251312daa5 100644
--- a/unotools/source/ucbhelper/XTempFile.hxx
+++ b/unotools/source/ucbhelper/XTempFile.hxx
@@ -27,6 +27,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
@@ -42,7 +43,8 @@ typedef ::cppu::WeakImplHelper< css::io::XTempFile
, css::io::XTruncate
, css::beans::XPropertySet
, css::beans::XFastPropertySet
- , css::beans::XPropertyAccess > OTempFileBase;
+ , css::beans::XPropertyAccess
+ , css::lang::XServiceInfo> OTempFileBase;
class OTempFileService : public OTempFileBase
{
@@ -67,6 +69,11 @@ public:
// XTypeProvider
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) 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;
+
// XTempFile
virtual sal_Bool SAL_CALL getRemoveFile() override;
virtual void SAL_CALL setRemoveFile( sal_Bool _removefile ) override;
diff --git a/unotools/source/ucbhelper/xtempfile.cxx b/unotools/source/ucbhelper/xtempfile.cxx
index fe47394d96fa..7eb7e3677e18 100644
--- a/unotools/source/ucbhelper/xtempfile.cxx
+++ b/unotools/source/ucbhelper/xtempfile.cxx
@@ -18,15 +18,14 @@
*/
#include "XTempFile.hxx"
-#include <unotoolsservices.hxx>
#include <com/sun/star/io/BufferSizeExceededException.hpp>
#include <com/sun/star/io/NotConnectedException.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <cppuhelper/typeprovider.hxx>
-#include <comphelper/servicedecl.hxx>
#include <o3tl/safeint.hxx>
#include <unotools/tempfile.hxx>
#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/supportsservice.hxx>
OTempFileService::OTempFileService(css::uno::Reference< css::uno::XComponentContext > const &)
: mpStream( nullptr )
@@ -439,11 +438,26 @@ void OTempFileService::setPropertyValues( const ::css::uno::Sequence< ::css::bea
setPropertyValue( rPropVal.Name, rPropVal.Value );
}
-namespace sdecl = ::comphelper::service_decl;
-sdecl::class_< OTempFileService> const OTempFileServiceImpl;
-const sdecl::ServiceDecl OTempFileServiceDecl(
- OTempFileServiceImpl,
- "com.sun.star.io.comp.TempFile",
- "com.sun.star.io.TempFile");
+// XServiceInfo
+sal_Bool OTempFileService::supportsService(const OUString& sServiceName)
+{
+ return cppu::supportsService(this, sServiceName);
+}
+OUString OTempFileService::getImplementationName()
+{
+ return "com.sun.star.io.comp.TempFile";
+}
+css::uno::Sequence< OUString > OTempFileService::getSupportedServiceNames()
+{
+ return { "com.sun.star.io.TempFile" };
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+unotools_OTempFileService_get_implementation(
+ css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new OTempFileService(context));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/util/utl.component b/unotools/util/utl.component
index 8b9371343582..effef2146729 100644
--- a/unotools/util/utl.component
+++ b/unotools/util/utl.component
@@ -18,11 +18,13 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="utl" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.io.comp.TempFile">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.io.comp.TempFile"
+ constructor="unotools_OTempFileService_get_implementation">
<service name="com.sun.star.io.TempFile"/>
</implementation>
- <implementation name="com.sun.star.comp.unotools.misc.ServiceDocumenter">
+ <implementation name="com.sun.star.comp.unotools.misc.ServiceDocumenter"
+ constructor="unotools_ServiceDocument_get_implementation">
<singleton name="com.sun.star.util.theServiceDocumenter"/>
</implementation>
</component>