bump product version to 7.2.5.1
[LibreOffice.git] / formula / source / core / api / grammar.cxx
blobb43e5436093ab0f03679b93e4de3b5b06ce517b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <formula/grammar.hxx>
21 #include <tools/debug.hxx>
22 #include <cassert>
24 namespace formula {
26 FormulaGrammar::Grammar FormulaGrammar::mapAPItoGrammar( const bool bEnglish, const bool bXML )
28 Grammar eGrammar;
29 if (bEnglish && bXML)
30 eGrammar = GRAM_PODF;
31 else if (bEnglish && !bXML)
32 eGrammar = GRAM_API;
33 else if (!bEnglish && bXML)
34 eGrammar = GRAM_NATIVE_ODF;
35 else // (!bEnglish && !bXML)
36 eGrammar = GRAM_NATIVE;
37 return eGrammar;
40 bool FormulaGrammar::isSupported( const Grammar eGrammar )
42 switch (eGrammar)
44 case GRAM_ODFF :
45 case GRAM_PODF :
46 case GRAM_ENGLISH :
47 case GRAM_NATIVE :
48 case GRAM_ODFF_UI :
49 case GRAM_ODFF_A1 :
50 case GRAM_PODF_UI :
51 case GRAM_PODF_A1 :
52 case GRAM_NATIVE_UI :
53 case GRAM_NATIVE_ODF :
54 case GRAM_NATIVE_XL_A1 :
55 case GRAM_NATIVE_XL_R1C1 :
56 case GRAM_ENGLISH_XL_A1 :
57 case GRAM_ENGLISH_XL_R1C1:
58 case GRAM_ENGLISH_XL_OOX :
59 case GRAM_OOXML :
60 case GRAM_API :
61 return true;
62 default:
63 return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL;
67 FormulaGrammar::Grammar FormulaGrammar::setEnglishBit( const Grammar eGrammar, const bool bEnglish )
69 if (bEnglish)
70 return static_cast<Grammar>( eGrammar | kEnglishBit);
71 else
72 return static_cast<Grammar>( eGrammar & ~kEnglishBit);
75 FormulaGrammar::Grammar FormulaGrammar::mergeToGrammar( const Grammar eGrammar, const AddressConvention eConv )
77 bool bEnglish = isEnglish( eGrammar);
78 Grammar eGram = static_cast<Grammar>(
79 extractFormulaLanguage( eGrammar) |
80 ((eConv + kConventionOffset) << kConventionShift));
81 eGram = setEnglishBit( eGram, bEnglish);
82 assert( isSupported( eGram));
83 return eGram;
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */