fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / formula / source / core / api / grammar.cxx
blobf99bbddeaffbf614a75334bb772eb6ee18047ce6
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>
23 namespace formula {
25 FormulaGrammar::Grammar FormulaGrammar::mapAPItoGrammar( const bool bEnglish, const bool bXML )
27 Grammar eGrammar;
28 if (bEnglish && bXML)
29 eGrammar = GRAM_PODF;
30 else if (bEnglish && !bXML)
31 eGrammar = GRAM_PODF_A1;
32 else if (!bEnglish && bXML)
33 eGrammar = GRAM_NATIVE_ODF;
34 else // (!bEnglish && !bXML)
35 eGrammar = GRAM_NATIVE;
36 return eGrammar;
39 bool FormulaGrammar::isSupported( const Grammar eGrammar )
41 switch (eGrammar)
43 case GRAM_ODFF :
44 case GRAM_PODF :
45 case GRAM_ENGLISH :
46 case GRAM_NATIVE :
47 case GRAM_ODFF_UI :
48 case GRAM_ODFF_A1 :
49 case GRAM_PODF_UI :
50 case GRAM_PODF_A1 :
51 case GRAM_NATIVE_UI :
52 case GRAM_NATIVE_ODF :
53 case GRAM_NATIVE_XL_A1 :
54 case GRAM_NATIVE_XL_R1C1 :
55 case GRAM_ENGLISH_XL_A1 :
56 case GRAM_ENGLISH_XL_R1C1:
57 case GRAM_ENGLISH_XL_OOX :
58 case GRAM_OOXML :
59 return true;
60 default:
61 return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL;
65 FormulaGrammar::Grammar FormulaGrammar::setEnglishBit( const Grammar eGrammar, const bool bEnglish )
67 if (bEnglish)
68 return static_cast<Grammar>( eGrammar | kEnglishBit);
69 else
70 return static_cast<Grammar>( eGrammar & ~kEnglishBit);
73 FormulaGrammar::Grammar FormulaGrammar::mergeToGrammar( const Grammar eGrammar, const AddressConvention eConv )
75 bool bEnglish = isEnglish( eGrammar);
76 Grammar eGram = static_cast<Grammar>(
77 extractFormulaLanguage( eGrammar) |
78 ((eConv + kConventionOffset) << kConventionShift));
79 eGram = setEnglishBit( eGram, bEnglish);
80 DBG_ASSERT( isSupported( eGram), "CompilerGrammarMap::mergeToGrammar: unsupported grammar");
81 return eGram;
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */