merge the formfield patch from ooo-build
[ooovba.git] / formula / source / core / api / FormulaOpCodeMapperObj.cxx
blobd71126816a6d81ef8cba6b343f2031e3be8a43ad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tokenuno.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_formula.hxx"
31 #include "formula/FormulaOpCodeMapperObj.hxx"
32 #include "formula/opcode.hxx"
33 #include <comphelper/sequence.hxx>
35 // =============================================================================
36 namespace formula
38 // =============================================================================
40 using namespace ::com::sun::star;
42 // -----------------------------------------------------------------------------
43 // --------------------------------------------------------------------------------
44 sal_Bool SAL_CALL FormulaOpCodeMapperObj::supportsService( const ::rtl::OUString& _rServiceName ) throw(uno::RuntimeException)
46 return ::comphelper::findValue( getSupportedServiceNames_Static(), _rServiceName, sal_True ).getLength() != 0;
48 //------------------------------------------------------------------------
49 FormulaOpCodeMapperObj::FormulaOpCodeMapperObj(::std::auto_ptr<FormulaCompiler> _pCompiler)
50 : m_pCompiler(_pCompiler)
54 FormulaOpCodeMapperObj::~FormulaOpCodeMapperObj()
59 ::sal_Int32 SAL_CALL FormulaOpCodeMapperObj::getOpCodeExternal()
60 throw (::com::sun::star::uno::RuntimeException)
62 return ocExternal;
66 ::sal_Int32 SAL_CALL FormulaOpCodeMapperObj::getOpCodeUnknown()
67 throw (::com::sun::star::uno::RuntimeException)
69 return FormulaCompiler::OpCodeMap::getOpCodeUnknown();
73 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >
74 SAL_CALL FormulaOpCodeMapperObj::getMappings(
75 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames,
76 sal_Int32 nLanguage )
77 throw ( ::com::sun::star::lang::IllegalArgumentException,
78 ::com::sun::star::uno::RuntimeException)
80 FormulaCompiler::OpCodeMapPtr xMap = m_pCompiler->GetOpCodeMap( nLanguage);
81 if (!xMap)
82 throw lang::IllegalArgumentException();
83 return xMap->createSequenceOfFormulaTokens( *m_pCompiler,rNames);
87 ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaOpCodeMapEntry >
88 SAL_CALL FormulaOpCodeMapperObj::getAvailableMappings(
89 sal_Int32 nLanguage, sal_Int32 nGroups )
90 throw ( ::com::sun::star::lang::IllegalArgumentException,
91 ::com::sun::star::uno::RuntimeException)
93 FormulaCompiler::OpCodeMapPtr xMap = m_pCompiler->GetOpCodeMap( nLanguage);
94 if (!xMap)
95 throw lang::IllegalArgumentException();
96 return xMap->createSequenceOfAvailableMappings( *m_pCompiler,nGroups);
98 //--------------------------------------------------------------------------
99 ::rtl::OUString SAL_CALL FormulaOpCodeMapperObj::getImplementationName( ) throw(uno::RuntimeException)
101 return getImplementationName_Static();
103 // -----------------------------------------------------------------------------
104 ::rtl::OUString SAL_CALL FormulaOpCodeMapperObj::getImplementationName_Static()
106 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "simple.formula.FormulaOpCodeMapperObj" ) );
108 // --------------------------------------------------------------------------------
109 uno::Sequence< ::rtl::OUString > SAL_CALL FormulaOpCodeMapperObj::getSupportedServiceNames( ) throw(uno::RuntimeException)
111 return getSupportedServiceNames_Static();
113 uno::Sequence< rtl::OUString > SAL_CALL FormulaOpCodeMapperObj::getSupportedServiceNames_Static()
115 uno::Sequence< rtl::OUString > aSeq( 1 );
116 aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.FormulaOpCodeMapper" ));
117 return aSeq;
120 uno::Reference< uno::XInterface > SAL_CALL FormulaOpCodeMapperObj::create(
121 uno::Reference< uno::XComponentContext > const & /*_xContext*/)
123 return static_cast<sheet::XFormulaOpCodeMapper*>(new FormulaOpCodeMapperObj(::std::auto_ptr<FormulaCompiler>(new FormulaCompiler())));
125 // -----------------------------------------------------------------------------
127 // =============================================================================
128 } // formula
129 // =============================================================================