Line data Source code
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 : #include "formula/FormulaOpCodeMapperObj.hxx"
20 : #include "formula/opcode.hxx"
21 : #include <comphelper/sequence.hxx>
22 :
23 : // =============================================================================
24 : namespace formula
25 : {
26 : // =============================================================================
27 :
28 : using namespace ::com::sun::star;
29 :
30 : // -----------------------------------------------------------------------------
31 : // --------------------------------------------------------------------------------
32 0 : sal_Bool SAL_CALL FormulaOpCodeMapperObj::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
33 : {
34 0 : return ::comphelper::findValue( getSupportedServiceNames_Static(), _rServiceName, sal_True ).getLength() != 0;
35 : }
36 : //------------------------------------------------------------------------
37 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
38 22 : FormulaOpCodeMapperObj::FormulaOpCodeMapperObj(::std::auto_ptr<FormulaCompiler> _pCompiler)
39 22 : : m_pCompiler(_pCompiler)
40 : {
41 22 : }
42 : SAL_WNODEPRECATED_DECLARATIONS_POP
43 :
44 22 : FormulaOpCodeMapperObj::~FormulaOpCodeMapperObj()
45 : {
46 22 : }
47 :
48 :
49 22 : ::sal_Int32 SAL_CALL FormulaOpCodeMapperObj::getOpCodeExternal()
50 : throw (::com::sun::star::uno::RuntimeException)
51 : {
52 22 : return ocExternal;
53 : }
54 :
55 :
56 22 : ::sal_Int32 SAL_CALL FormulaOpCodeMapperObj::getOpCodeUnknown()
57 : throw (::com::sun::star::uno::RuntimeException)
58 : {
59 22 : return FormulaCompiler::OpCodeMap::getOpCodeUnknown();
60 : }
61 :
62 :
63 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >
64 0 : SAL_CALL FormulaOpCodeMapperObj::getMappings(
65 : const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames,
66 : sal_Int32 nLanguage )
67 : throw ( ::com::sun::star::lang::IllegalArgumentException,
68 : ::com::sun::star::uno::RuntimeException)
69 : {
70 0 : FormulaCompiler::OpCodeMapPtr xMap = m_pCompiler->GetOpCodeMap( nLanguage);
71 0 : if (!xMap)
72 0 : throw lang::IllegalArgumentException();
73 0 : return xMap->createSequenceOfFormulaTokens( *m_pCompiler,rNames);
74 : }
75 :
76 :
77 : ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry >
78 132 : SAL_CALL FormulaOpCodeMapperObj::getAvailableMappings(
79 : sal_Int32 nLanguage, sal_Int32 nGroups )
80 : throw ( ::com::sun::star::lang::IllegalArgumentException,
81 : ::com::sun::star::uno::RuntimeException)
82 : {
83 132 : FormulaCompiler::OpCodeMapPtr xMap = m_pCompiler->GetOpCodeMap( nLanguage);
84 132 : if (!xMap)
85 0 : throw lang::IllegalArgumentException();
86 132 : return xMap->createSequenceOfAvailableMappings( *m_pCompiler,nGroups);
87 : }
88 : //--------------------------------------------------------------------------
89 0 : ::rtl::OUString SAL_CALL FormulaOpCodeMapperObj::getImplementationName( ) throw(uno::RuntimeException)
90 : {
91 0 : return getImplementationName_Static();
92 : }
93 : // -----------------------------------------------------------------------------
94 0 : ::rtl::OUString SAL_CALL FormulaOpCodeMapperObj::getImplementationName_Static()
95 : {
96 0 : return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "simple.formula.FormulaOpCodeMapperObj" ) );
97 : }
98 : // --------------------------------------------------------------------------------
99 0 : uno::Sequence< ::rtl::OUString > SAL_CALL FormulaOpCodeMapperObj::getSupportedServiceNames( ) throw(uno::RuntimeException)
100 : {
101 0 : return getSupportedServiceNames_Static();
102 : }
103 0 : uno::Sequence< rtl::OUString > SAL_CALL FormulaOpCodeMapperObj::getSupportedServiceNames_Static()
104 : {
105 0 : uno::Sequence< rtl::OUString > aSeq( 1 );
106 0 : aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.FormulaOpCodeMapper" ));
107 0 : return aSeq;
108 : }
109 :
110 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
111 0 : uno::Reference< uno::XInterface > SAL_CALL FormulaOpCodeMapperObj::create(
112 : uno::Reference< uno::XComponentContext > const & /*_xContext*/)
113 : {
114 0 : return static_cast<sheet::XFormulaOpCodeMapper*>(new FormulaOpCodeMapperObj(::std::auto_ptr<FormulaCompiler>(new FormulaCompiler())));
115 : }
116 : SAL_WNODEPRECATED_DECLARATIONS_POP
117 :
118 : // -----------------------------------------------------------------------------
119 :
120 : // =============================================================================
121 : } // formula
122 : // =============================================================================
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|