LCOV - code coverage report
Current view: top level - formula/source/core/api - grammar.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 17 23 73.9 %
Date: 2015-06-13 12:38:46 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          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             : 
      20             : #include <formula/grammar.hxx>
      21             : #include <tools/debug.hxx>
      22             : 
      23             : namespace formula {
      24             : 
      25         192 : FormulaGrammar::Grammar FormulaGrammar::mapAPItoGrammar( const bool bEnglish, const bool bXML )
      26             : {
      27             :     Grammar eGrammar;
      28         192 :     if (bEnglish && bXML)
      29           0 :         eGrammar = GRAM_PODF;
      30         192 :     else if (bEnglish && !bXML)
      31         148 :         eGrammar = GRAM_PODF_A1;
      32          44 :     else if (!bEnglish && bXML)
      33           0 :         eGrammar = GRAM_NATIVE_ODF;
      34             :     else // (!bEnglish && !bXML)
      35          44 :         eGrammar = GRAM_NATIVE;
      36         192 :     return eGrammar;
      37             : }
      38             : 
      39           0 : bool FormulaGrammar::isSupported( const Grammar eGrammar )
      40             : {
      41           0 :     switch (eGrammar)
      42             :     {
      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           0 :             return true;
      60             :         default:
      61           0 :             return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL;
      62             :     }
      63             : }
      64             : 
      65       55946 : FormulaGrammar::Grammar FormulaGrammar::setEnglishBit( const Grammar eGrammar, const bool bEnglish )
      66             : {
      67       55946 :     if (bEnglish)
      68       12001 :         return static_cast<Grammar>( eGrammar | kEnglishBit);
      69             :     else
      70       43945 :         return static_cast<Grammar>( eGrammar & ~kEnglishBit);
      71             : }
      72             : 
      73       55477 : FormulaGrammar::Grammar FormulaGrammar::mergeToGrammar( const Grammar eGrammar, const AddressConvention eConv )
      74             : {
      75       55477 :     bool bEnglish = isEnglish( eGrammar);
      76             :     Grammar eGram = static_cast<Grammar>(
      77       55477 :             extractFormulaLanguage( eGrammar) |
      78       55477 :             ((eConv + kConventionOffset) << kConventionShift));
      79       55477 :     eGram = setEnglishBit( eGram, bEnglish);
      80             :     DBG_ASSERT( isSupported( eGram), "CompilerGrammarMap::mergeToGrammar: unsupported grammar");
      81       55477 :     return eGram;
      82             : }
      83             : 
      84             : }
      85             : 
      86             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11