LibreOffice Module formula (master) 1
FormulaOpCodeMapperObj.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <memory>
21#include <sal/config.h>
22
23#include <utility>
24
27#include <formula/opcode.hxx>
29#include <com/sun/star/lang/IllegalArgumentException.hpp>
30
31namespace formula
32{
33 using namespace ::com::sun::star;
34
35sal_Bool SAL_CALL FormulaOpCodeMapperObj::supportsService( const OUString& _rServiceName )
36{
37 return cppu::supportsService(this, _rServiceName);
38}
39
40FormulaOpCodeMapperObj::FormulaOpCodeMapperObj(::std::unique_ptr<FormulaCompiler> && _pCompiler)
41: m_pCompiler(std::move(_pCompiler))
42{
43}
44
46{
47}
48
50{
51 return ocExternal;
52}
53
54
56{
58}
59
60
61css::uno::Sequence< css::sheet::FormulaToken >
63 const css::uno::Sequence< OUString >& rNames,
64 sal_Int32 nLanguage )
65{
66 FormulaCompiler::OpCodeMapPtr xMap = m_pCompiler->GetOpCodeMap( nLanguage);
67 if (!xMap)
68 throw lang::IllegalArgumentException();
69 return xMap->createSequenceOfFormulaTokens( *m_pCompiler,rNames);
70}
71
72
73css::uno::Sequence< css::sheet::FormulaOpCodeMapEntry >
75 sal_Int32 nLanguage, sal_Int32 nGroups )
76{
77 FormulaCompiler::OpCodeMapPtr xMap = m_pCompiler->GetOpCodeMap( nLanguage);
78 if (!xMap)
79 throw lang::IllegalArgumentException();
80 return xMap->createSequenceOfAvailableMappings( *m_pCompiler,nGroups);
81}
82
84{
85 return "simple.formula.FormulaOpCodeMapperObj";
86}
87
89{
90 return { "com.sun.star.sheet.FormulaOpCodeMapper" };
91}
92
93} // formula
94
95extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
97 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& )
98{
99 return cppu::acquire(
100 new formula::FormulaOpCodeMapperObj(std::make_unique<formula::FormulaCompiler>()));
101}
102
103
104/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * simple_formula_FormulaOpCodeMapperObj(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
static sal_Int32 getOpCodeUnknown()
The value used in createSequenceOfAvailableMappings() and thus in XFormulaOpCodeMapper::getMappings()...
std::shared_ptr< const OpCodeMap > OpCodeMapPtr
virtual css::uno::Sequence< css::sheet::FormulaOpCodeMapEntry > SAL_CALL getAvailableMappings(sal_Int32 nLanguage, sal_Int32 nGroups) override
virtual ::sal_Int32 SAL_CALL getOpCodeExternal() override
virtual css::uno::Sequence< css::sheet::FormulaToken > SAL_CALL getMappings(const css::uno::Sequence< OUString > &rNames, sal_Int32 nLanguage) override
virtual ::sal_Int32 SAL_CALL getOpCodeUnknown() override
FormulaOpCodeMapperObj(::std::unique_ptr< FormulaCompiler > &&_pCompiler)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
::std::unique_ptr< FormulaCompiler > m_pCompiler
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
@ ocExternal
Definition: opcode.hxx:34
unsigned char sal_Bool