summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-25 18:19:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-26 10:41:52 +0200
commit8a05c64a5bbf9b6ad7af8e94e7b970f1323a22c5 (patch)
treead963de32713418067c5ae9ea4436ee28b175625 /starmath
parent5406f8a3cd53ada63472bd62e5b9a886e2866c6f (diff)
starmath: create instances with uno constructors
See tdf#74608 for motivation. And adjust the sfx2 model factory code to cope with UNO constructor functions. Change-Id: I7e57fb3136ad0b3caadd511ea63cf98d3c03ab3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99446 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/Library_sm.mk1
-rw-r--r--starmath/source/register.cxx72
-rw-r--r--starmath/source/register.hxx37
-rw-r--r--starmath/source/unodoc.cxx26
-rw-r--r--starmath/util/sm.component5
5 files changed, 14 insertions, 127 deletions
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index d4b22f4d6623..33fb7525bba0 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -84,7 +84,6 @@ $(eval $(call gb_Library_add_exception_objects,sm,\
starmath/source/rtfexport \
starmath/source/parse \
starmath/source/rect \
- starmath/source/register \
starmath/source/smdll \
starmath/source/smmod \
starmath/source/symbol \
diff --git a/starmath/source/register.cxx b/starmath/source/register.cxx
deleted file mode 100644
index 89f7c2dd325a..000000000000
--- a/starmath/source/register.cxx
+++ /dev/null
@@ -1,72 +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 <rtl/ustring.hxx>
-
-#include <sfx2/sfxmodelfactory.hxx>
-
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "register.hxx"
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-
-extern "C" {
-
-SAL_DLLPUBLIC_EXPORT void* sm_component_getFactory( const char* pImplementationName,
- void* pServiceManager,
- void* /*pRegistryKey*/ )
-{
- // Set default return value for this operation - if it failed.
- void* pReturn = nullptr ;
-
- if (
- ( pImplementationName != nullptr ) &&
- ( pServiceManager != nullptr )
- )
- {
- // Define variables which are used in following macros.
- Reference< XSingleServiceFactory > xFactory ;
- Reference< XMultiServiceFactory > xServiceManager( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
-
- if (SmDocument_getImplementationName().equalsAscii(pImplementationName))
- {
- xFactory = ::sfx2::createSfxModelFactory( xServiceManager,
- SmDocument_getImplementationName(),
- SmDocument_createInstance,
- SmDocument_getSupportedServiceNames() );
- }
-
- // Factory is valid - service was found.
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pReturn = xFactory.get();
- }
- }
-
- // Return with result of this operation.
- return pReturn ;
-}
-} // extern "C"
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/register.hxx b/starmath/source/register.hxx
deleted file mode 100644
index be875fbeccb0..000000000000
--- a/starmath/source/register.hxx
+++ /dev/null
@@ -1,37 +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_STARMATH_SOURCE_REGISTER_HXX
-#define INCLUDED_STARMATH_SOURCE_REGISTER_HXX
-
-#include <sal/config.h>
-#include <sfx2/sfxmodelfactory.hxx>
-
-//Math document
-css::uno::Sequence< OUString >
- SmDocument_getSupportedServiceNames() throw();
-OUString
- SmDocument_getImplementationName() throw();
-/// @throws css::uno::Exception
-css::uno::Reference< css::uno::XInterface >
- SmDocument_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr, SfxModelFlags _nCreationFlags);
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/unodoc.cxx b/starmath/source/unodoc.cxx
index ac7a364390de..32c9692edd0d 100644
--- a/starmath/source/unodoc.cxx
+++ b/starmath/source/unodoc.cxx
@@ -19,7 +19,6 @@
#include <sfx2/sfxmodelfactory.hxx>
-#include "register.hxx"
#include <smdll.hxx>
#include <document.hxx>
#include <com/sun/star/frame/XModel.hpp>
@@ -27,23 +26,20 @@
using namespace ::com::sun::star;
-OUString SmDocument_getImplementationName() throw()
-{
- return "com.sun.star.comp.Math.FormulaDocument";
-}
-
-uno::Sequence< OUString > SmDocument_getSupportedServiceNames() throw()
-{
- return uno::Sequence<OUString>{ "com.sun.star.formula.FormulaProperties" };
-}
-
-uno::Reference< uno::XInterface > SmDocument_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > & /*rSMgr*/, SfxModelFlags _nCreationFlags )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+Math_FormulaDocument_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& args)
{
SolarMutexGuard aGuard;
SmGlobals::ensure();
- SfxObjectShell* pShell = new SmDocShell( _nCreationFlags );
- return uno::Reference< uno::XInterface >( pShell->GetModel() );
+ css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
+ [&](SfxModelFlags _nCreationFlags)
+ {
+ SfxObjectShell* pShell = new SmDocShell( _nCreationFlags );
+ return pShell->GetModel();
+ });
+ xInterface->acquire();
+ return xInterface.get();
}
diff --git a/starmath/util/sm.component b/starmath/util/sm.component
index 775b41100a97..4f354df4acb0 100644
--- a/starmath/util/sm.component
+++ b/starmath/util/sm.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="sm" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.Math.FormulaDocument">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.Math.FormulaDocument"
+ constructor="Math_FormulaDocument_get_implementation">
<service name="com.sun.star.formula.FormulaProperties"/>
</implementation>
<implementation name="com.sun.star.comp.Math.XMLContentExporter"