summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-26 16:27:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-26 18:42:52 +0200
commit3812706bea44b0d1b58a9093845ec3614be7c316 (patch)
treea691c15f8b0f6f8d1f9fb78ff7c465366d524557
parentc6046e915df2496357a84736ad6a1962394a6378 (diff)
sw: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: Ibd5c19d78c1440b489d850fdacbaa74d0c3d1654 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99458 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rwxr-xr-xsolenv/bin/native-code.py2
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/source/core/inc/unofreg.hxx38
-rw-r--r--sw/source/uibase/uno/unodoc.cxx47
-rw-r--r--sw/source/uibase/uno/unofreg.cxx89
-rw-r--r--sw/util/sw.component5
6 files changed, 33 insertions, 149 deletions
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index c524d04f5046..c7e664c8c270 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -622,7 +622,6 @@ draw_constructor_list = [
]
writer_factory_list = [
- ("libswlo.a", "sw_component_getFactory"),
]
writer_constructor_list = [
@@ -632,6 +631,7 @@ writer_constructor_list = [
# filter/source/textfilterdetect/textfd.component
"com_sun_star_comp_filters_PlainTextFilterDetect_get_implementation",
# sw/util/sw.component
+ "Writer_SwTextDocument_get_implementation",
"com_sun_star_comp_Writer_XMLOasisContentImporter_get_implementation",
"com_sun_star_comp_Writer_XMLOasisImporter_get_implementation",
"com_sun_star_comp_Writer_XMLOasisMetaImporter_get_implementation",
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 0707fb93e9c4..5f7c204f0e6a 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -740,7 +740,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/uibase/uno/unodefaults \
sw/source/uibase/uno/unodispatch \
sw/source/uibase/uno/unodoc \
- sw/source/uibase/uno/unofreg \
sw/source/uibase/uno/unomailmerge \
sw/source/uibase/uno/unomod \
sw/source/uibase/uno/unomodule \
diff --git a/sw/source/core/inc/unofreg.hxx b/sw/source/core/inc/unofreg.hxx
deleted file mode 100644
index afb8e6dcdff5..000000000000
--- a/sw/source/core/inc/unofreg.hxx
+++ /dev/null
@@ -1,38 +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 .
- */
-
-#ifndef INCLUDED_SW_SOURCE_CORE_INC_UNOFREG_HXX
-#define INCLUDED_SW_SOURCE_CORE_INC_UNOFREG_HXX
-
-#include <sal/config.h>
-#include <sfx2/sfxmodelfactory.hxx>
-
-#include <com/sun/star/uno/Sequence.hxx>
-
-namespace com::sun::star::lang { class XMultiServiceFactory; }
-
-// writer documents
-css::uno::Sequence< OUString > SwTextDocument_getSupportedServiceNames() throw();
-OUString SwTextDocument_getImplementationName() throw();
-/// @throws css::uno::Exception
-css::uno::Reference< css::uno::XInterface > SwTextDocument_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > &rSMgr, SfxModelFlags _nCreationFlags );
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unodoc.cxx b/sw/source/uibase/uno/unodoc.cxx
index a61b23778165..d9a6928e2e46 100644
--- a/sw/source/uibase/uno/unodoc.cxx
+++ b/sw/source/uibase/uno/unodoc.cxx
@@ -18,40 +18,35 @@
*/
#include <sal/config.h>
+#include <config_features.h>
#include <com/sun/star/frame/XModel.hpp>
#include <sfx2/sfxmodelfactory.hxx>
#include <swdll.hxx>
-#include <unofreg.hxx>
#include <docsh.hxx>
#include <globdoc.hxx>
#include <wdocsh.hxx>
#include <vcl/svapp.hxx>
+#include <unomailmerge.hxx>
using namespace ::com::sun::star;
// com.sun.star.comp.Writer.TextDocument
-uno::Sequence< OUString > SwTextDocument_getSupportedServiceNames() throw()
-{
- // return only top level services here! All others must be
- // resolved by rtti!
- uno::Sequence< OUString > aRet { "com.sun.star.text.TextDocument" };
- return aRet;
-}
-
-OUString SwTextDocument_getImplementationName() throw()
-{
- return "com.sun.star.comp.Writer.TextDocument";
-}
-
-uno::Reference< uno::XInterface > SwTextDocument_createInstance(
- const uno::Reference< lang::XMultiServiceFactory >&, SfxModelFlags _nCreationFlags )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+Writer_SwTextDocument_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& args)
{
SolarMutexGuard aGuard;
SwGlobals::ensure();
- SfxObjectShell* pShell = new SwDocShell( _nCreationFlags );
- return uno::Reference< uno::XInterface >( pShell->GetModel() );
+ css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
+ [&](SfxModelFlags _nCreationFlags)
+ {
+ SfxObjectShell* pShell = new SwDocShell( _nCreationFlags );
+ return pShell->GetModel();
+ });
+ xInterface->acquire();
+ return xInterface.get();
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
@@ -79,4 +74,20 @@ com_sun_star_comp_Writer_GlobalDocument_get_implementation(css::uno::XComponentC
return model.get();
}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+SwXMailMerge_get_implementation(css::uno::XComponentContext*,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+#if HAVE_FEATURE_DBCONNECTIVITY
+ SolarMutexGuard aGuard;
+
+ //the module may not be loaded
+ SwGlobals::ensure();
+ return cppu::acquire(new SwXMailMerge());
+#else
+ return nullptr;
+#endif
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unofreg.cxx b/sw/source/uibase/uno/unofreg.cxx
deleted file mode 100644
index a170bb0854bb..000000000000
--- a/sw/source/uibase/uno/unofreg.cxx
+++ /dev/null
@@ -1,89 +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 <config_features.h>
-
-#include <swdll.hxx>
-#include <unofreg.hxx>
-#include <unomailmerge.hxx>
-#include <sal/types.h>
-#include <cppuhelper/factory.hxx>
-#include <sfx2/sfxmodelfactory.hxx>
-#include <vcl/svapp.hxx>
-
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include <string.h>
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::lang;
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void * sw_component_getFactory(
- const char * pImplName,
- void * pServiceManager,
- void * )
-{
- void * pRet = nullptr;
- if( pServiceManager )
- {
- uno::Reference< XMultiServiceFactory > xMSF(
- static_cast< XMultiServiceFactory * >( pServiceManager ) );
-
- uno::Reference< XSingleServiceFactory > xFactory;
-
- const sal_Int32 nImplNameLen = strlen( pImplName );
- if( SwTextDocument_getImplementationName().equalsAsciiL(
- pImplName, nImplNameLen ) )
- {
- xFactory = ::sfx2::createSfxModelFactory( xMSF,
- SwTextDocument_getImplementationName(),
- SwTextDocument_createInstance,
- SwTextDocument_getSupportedServiceNames() );
- }
-
- if( xFactory.is())
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
- }
- return pRet;
-}
-
-} // extern "C"
-
-extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
-SwXMailMerge_get_implementation(css::uno::XComponentContext*,
- css::uno::Sequence<css::uno::Any> const &)
-{
-#if HAVE_FEATURE_DBCONNECTIVITY
- SolarMutexGuard aGuard;
-
- //the module may not be loaded
- SwGlobals::ensure();
- return cppu::acquire(new SwXMailMerge());
-#else
- return nullptr;
-#endif
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/util/sw.component b/sw/util/sw.component
index 8d988dc93503..f4ad4f7e3339 100644
--- a/sw/util/sw.component
+++ b/sw/util/sw.component
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="sw" xmlns="http://openoffice.org/2010/uno-components">
+ xmlns="http://openoffice.org/2010/uno-components">
<implementation name="lo.writer.NavElementToolBoxController"
constructor="lo_writer_NavElementToolBoxController_get_implementation">
<service name="com.sun.star.frame.ToolbarController"/>
@@ -75,7 +75,8 @@
constructor="com_sun_star_comp_Writer_GlobalDocument_get_implementation">
<service name="com.sun.star.text.GlobalDocument"/>
</implementation>
- <implementation name="com.sun.star.comp.Writer.TextDocument">
+ <implementation name="com.sun.star.comp.Writer.TextDocument"
+ constructor="Writer_SwTextDocument_get_implementation">
<service name="com.sun.star.text.TextDocument"/>
</implementation>
<implementation name="com.sun.star.comp.Writer.WebDocument"