1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
24 #include "formula/FormulaOpCodeMapperObj.hxx"
25 #include "formula/opcode.hxx"
26 #include <comphelper/sequence.hxx>
27 #include <cppuhelper/supportsservice.hxx>
31 using namespace ::com::sun::star
;
33 sal_Bool SAL_CALL
FormulaOpCodeMapperObj::supportsService( const OUString
& _rServiceName
) throw(uno::RuntimeException
, std::exception
)
35 return cppu::supportsService(this, _rServiceName
);
38 FormulaOpCodeMapperObj::FormulaOpCodeMapperObj(::std::unique_ptr
<FormulaCompiler
> && _pCompiler
)
39 : m_pCompiler(std::move(_pCompiler
))
43 FormulaOpCodeMapperObj::~FormulaOpCodeMapperObj()
47 ::sal_Int32 SAL_CALL
FormulaOpCodeMapperObj::getOpCodeExternal()
48 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
54 ::sal_Int32 SAL_CALL
FormulaOpCodeMapperObj::getOpCodeUnknown()
55 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
57 return FormulaCompiler::OpCodeMap::getOpCodeUnknown();
61 ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaToken
>
62 SAL_CALL
FormulaOpCodeMapperObj::getMappings(
63 const ::com::sun::star::uno::Sequence
< OUString
>& rNames
,
65 throw ( ::com::sun::star::lang::IllegalArgumentException
,
66 ::com::sun::star::uno::RuntimeException
, std::exception
)
68 FormulaCompiler::OpCodeMapPtr xMap
= m_pCompiler
->GetOpCodeMap( nLanguage
);
70 throw lang::IllegalArgumentException();
71 return xMap
->createSequenceOfFormulaTokens( *m_pCompiler
,rNames
);
75 ::com::sun::star::uno::Sequence
< ::com::sun::star::sheet::FormulaOpCodeMapEntry
>
76 SAL_CALL
FormulaOpCodeMapperObj::getAvailableMappings(
77 sal_Int32 nLanguage
, sal_Int32 nGroups
)
78 throw ( ::com::sun::star::lang::IllegalArgumentException
,
79 ::com::sun::star::uno::RuntimeException
, std::exception
)
81 FormulaCompiler::OpCodeMapPtr xMap
= m_pCompiler
->GetOpCodeMap( nLanguage
);
83 throw lang::IllegalArgumentException();
84 return xMap
->createSequenceOfAvailableMappings( *m_pCompiler
,nGroups
);
87 OUString SAL_CALL
FormulaOpCodeMapperObj::getImplementationName( ) throw(uno::RuntimeException
, std::exception
)
89 return getImplementationName_Static();
92 OUString SAL_CALL
FormulaOpCodeMapperObj::getImplementationName_Static()
94 return OUString( "simple.formula.FormulaOpCodeMapperObj" );
97 uno::Sequence
< OUString
> SAL_CALL
FormulaOpCodeMapperObj::getSupportedServiceNames( ) throw(uno::RuntimeException
, std::exception
)
99 return getSupportedServiceNames_Static();
101 uno::Sequence
< OUString
> SAL_CALL
FormulaOpCodeMapperObj::getSupportedServiceNames_Static()
103 uno::Sequence
< OUString
> aSeq( 1 );
104 aSeq
[0] = "com.sun.star.sheet.FormulaOpCodeMapper";
108 uno::Reference
< uno::XInterface
> SAL_CALL
FormulaOpCodeMapperObj::create(
109 uno::Reference
< uno::XComponentContext
> const & /*_xContext*/)
111 return static_cast<sheet::XFormulaOpCodeMapper
*>(new FormulaOpCodeMapperObj(::std::unique_ptr
<FormulaCompiler
>(new FormulaCompiler())));
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */