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 <formula/grammar.hxx>
21 #include <tools/debug.hxx>
25 FormulaGrammar::Grammar
FormulaGrammar::mapAPItoGrammar( const bool bEnglish
, const bool bXML
)
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
;
39 bool FormulaGrammar::isSupported( const Grammar eGrammar
)
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
:
61 return extractFormulaLanguage( eGrammar
) == GRAM_EXTERNAL
;
65 FormulaGrammar::Grammar
FormulaGrammar::setEnglishBit( const Grammar eGrammar
, const bool bEnglish
)
68 return static_cast<Grammar
>( eGrammar
| kEnglishBit
);
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");
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */