formula: create instances with uno constructors

See tdf#74608 for motivation

Change-Id: I5983c837977e40b91df02605c1012640ffd5c650
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98291
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2020-07-07 17:57:41 +02:00 committed by Noel Grandin
parent 0dffc65236
commit 9ff8a1173a
5 changed files with 13 additions and 78 deletions

View File

@ -41,7 +41,6 @@ $(eval $(call gb_Library_add_exception_objects,for,\
formula/source/core/api/FormulaCompiler \
formula/source/core/api/FormulaOpCodeMapperObj \
formula/source/core/api/grammar \
formula/source/core/api/services \
formula/source/core/api/token \
formula/source/core/api/vectortoken \
formula/source/core/resource/core_resource \

View File

@ -81,32 +81,24 @@ SAL_CALL FormulaOpCodeMapperObj::getAvailableMappings(
}
OUString SAL_CALL FormulaOpCodeMapperObj::getImplementationName( )
{
return getImplementationName_Static();
}
OUString FormulaOpCodeMapperObj::getImplementationName_Static()
{
return "simple.formula.FormulaOpCodeMapperObj";
}
uno::Sequence< OUString > SAL_CALL FormulaOpCodeMapperObj::getSupportedServiceNames( )
{
return getSupportedServiceNames_Static();
}
uno::Sequence< OUString > FormulaOpCodeMapperObj::getSupportedServiceNames_Static()
{
uno::Sequence<OUString> aSeq { "com.sun.star.sheet.FormulaOpCodeMapper" };
return aSeq;
}
uno::Reference< uno::XInterface > FormulaOpCodeMapperObj::create(
uno::Reference< uno::XComponentContext > const & /*_xContext*/)
{
return static_cast<sheet::XFormulaOpCodeMapper*>(new FormulaOpCodeMapperObj(std::make_unique<FormulaCompiler>()));
return { "com.sun.star.sheet.FormulaOpCodeMapper" };
}
} // formula
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
simple_formula_FormulaOpCodeMapperObj(
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& )
{
return cppu::acquire(
new formula::FormulaOpCodeMapperObj(std::make_unique<formula::FormulaCompiler>()));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1,53 +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 <sal/types.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <formula/FormulaOpCodeMapperObj.hxx>
/********************************************************************************************/
using namespace ::formula;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
// registry functions
namespace
{
cppu::ImplementationEntry const entries[] = {
{ &FormulaOpCodeMapperObj::create, &FormulaOpCodeMapperObj::getImplementationName_Static, &FormulaOpCodeMapperObj::getSupportedServiceNames_Static,
&cppu::createSingleComponentFactory, nullptr, 0 },
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
}
extern "C"
{
SAL_DLLPUBLIC_EXPORT void * for_component_getFactory(
char const * implName, void * serviceManager, void * registryKey)
{
return cppu::component_getFactoryHelper(
implName, serviceManager, registryKey, entries);
}
} // extern "C"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="for" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="simple.formula.FormulaOpCodeMapperObj">
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="simple.formula.FormulaOpCodeMapperObj"
constructor="simple_formula_FormulaOpCodeMapperObj">
<service name="com.sun.star.sheet.FormulaOpCodeMapper"/>
</implementation>
</component>

View File

@ -48,12 +48,8 @@ class FORMULA_DLLPUBLIC FormulaOpCodeMapperObj : public cppu::WeakImplHelper<
css::lang::XServiceInfo >
{
::std::unique_ptr<FormulaCompiler> m_pCompiler;
public:
static OUString getImplementationName_Static();
static css::uno::Sequence< OUString> getSupportedServiceNames_Static();
static css::uno::Reference< css::uno::XInterface > create(const css::uno::Reference< css::uno::XComponentContext >& _xContext);
protected:
public:
FormulaOpCodeMapperObj(::std::unique_ptr<FormulaCompiler> && _pCompiler);
virtual ~FormulaOpCodeMapperObj() override;