LibreOffice Module formula (master)
1
formula
source
core
api
grammar.cxx
Go to the documentation of this file.
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 <cassert>
22
23
namespace
formula
{
24
25
FormulaGrammar::Grammar
FormulaGrammar::mapAPItoGrammar
(
const
bool
bEnglish,
const
bool
bXML )
26
{
27
Grammar
eGrammar;
28
if
(bEnglish && bXML)
29
eGrammar =
GRAM_PODF
;
30
else
if
(bEnglish && !bXML)
31
eGrammar =
GRAM_API
;
32
else
if
(!bEnglish && bXML)
33
eGrammar =
GRAM_NATIVE_ODF
;
34
else
// (!bEnglish && !bXML)
35
eGrammar =
GRAM_NATIVE
;
36
return
eGrammar;
37
}
38
39
bool
FormulaGrammar::isSupported
(
const
Grammar
eGrammar )
40
{
41
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
case
GRAM_API
:
60
return
true
;
61
default
:
62
return
extractFormulaLanguage
( eGrammar) ==
GRAM_EXTERNAL
;
63
}
64
}
65
66
FormulaGrammar::Grammar
FormulaGrammar::setEnglishBit
(
const
Grammar
eGrammar,
const
bool
bEnglish )
67
{
68
if
(bEnglish)
69
return
static_cast<
Grammar
>
( eGrammar |
kEnglishBit
);
70
else
71
return
static_cast<
Grammar
>
( eGrammar & ~kEnglishBit);
72
}
73
74
FormulaGrammar::Grammar
FormulaGrammar::mergeToGrammar
(
const
Grammar
eGrammar,
const
AddressConvention
eConv )
75
{
76
bool
bEnglish =
isEnglish
( eGrammar);
77
Grammar
eGram =
static_cast<
Grammar
>
(
78
extractFormulaLanguage
( eGrammar) |
79
((eConv +
kConventionOffset
) <<
kConventionShift
));
80
eGram =
setEnglishBit
( eGram, bEnglish);
81
assert(
isSupported
( eGram));
82
return
eGram;
83
}
84
85
}
86
87
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
formula::FormulaGrammar::AddressConvention
AddressConvention
Definition:
grammar.hxx:35
formula::FormulaGrammar::mapAPItoGrammar
static Grammar mapAPItoGrammar(const bool bEnglish, const bool bXML)
Compatibility helper for old "bCompileEnglish, bCompileXML" API calls to obtain the new grammar.
Definition:
grammar.cxx:25
formula::FormulaGrammar::isSupported
static bool isSupported(const Grammar eGrammar)
Definition:
grammar.cxx:39
formula::FormulaGrammar::kConventionShift
static const int kConventionShift
Definition:
grammar.hxx:57
formula::FormulaGrammar::extractFormulaLanguage
static sal_Int32 extractFormulaLanguage(const Grammar eGrammar)
Definition:
grammar.hxx:175
formula::FormulaGrammar::mergeToGrammar
static Grammar mergeToGrammar(const Grammar eGrammar, const AddressConvention eConv)
Definition:
grammar.cxx:74
formula::FormulaGrammar::kEnglishBit
static const int kEnglishBit
Definition:
grammar.hxx:59
formula::FormulaGrammar::isEnglish
static bool isEnglish(const Grammar eGrammar)
If English parsing/formatting is associated with a grammar.
Definition:
grammar.hxx:164
formula::FormulaGrammar::Grammar
Grammar
Values encoding the formula language plus address reference convention plus English parsing/formattin...
Definition:
grammar.hxx:68
formula::FormulaGrammar::GRAM_API
@ GRAM_API
API English with A1 reference style, unbracketed.
Definition:
grammar.hxx:147
formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1
@ GRAM_NATIVE_XL_R1C1
Native with Excel R1C1 reference style.
Definition:
grammar.hxx:123
formula::FormulaGrammar::GRAM_NATIVE_ODF
@ GRAM_NATIVE_ODF
Native with ODF A1 bracketed references. Not very useful but supported.
Definition:
grammar.hxx:115
formula::FormulaGrammar::GRAM_NATIVE
@ GRAM_NATIVE
Native with default A1 reference style.
Definition:
grammar.hxx:87
formula::FormulaGrammar::GRAM_NATIVE_XL_A1
@ GRAM_NATIVE_XL_A1
Native with Excel A1 reference style.
Definition:
grammar.hxx:119
formula::FormulaGrammar::GRAM_ENGLISH_XL_OOX
@ GRAM_ENGLISH_XL_OOX
English with Excel OOXML reference style.
Definition:
grammar.hxx:137
formula::FormulaGrammar::GRAM_ENGLISH
@ GRAM_ENGLISH
English with default A1 reference style.
Definition:
grammar.hxx:82
formula::FormulaGrammar::GRAM_NATIVE_UI
@ GRAM_NATIVE_UI
Native with reference style as set in UI, may be A1 or R1C1.
Definition:
grammar.hxx:111
formula::FormulaGrammar::GRAM_ODFF
@ GRAM_ODFF
ODFF with default ODF A1 bracketed references.
Definition:
grammar.hxx:72
formula::FormulaGrammar::GRAM_PODF_UI
@ GRAM_PODF_UI
ODF 1.1 with reference style as set in UI, may be A1 or R1C1.
Definition:
grammar.hxx:101
formula::FormulaGrammar::GRAM_PODF
@ GRAM_PODF
ODF 1.1 with default ODF A1 bracketed references.
Definition:
grammar.hxx:77
formula::FormulaGrammar::GRAM_ENGLISH_XL_A1
@ GRAM_ENGLISH_XL_A1
English with Excel A1 reference style.
Definition:
grammar.hxx:127
formula::FormulaGrammar::GRAM_PODF_A1
@ GRAM_PODF_A1
ODF 1.1 with A1 reference style, unbracketed.
Definition:
grammar.hxx:106
formula::FormulaGrammar::GRAM_ODFF_UI
@ GRAM_ODFF_UI
ODFF with reference style as set in UI, may be A1 or R1C1.
Definition:
grammar.hxx:91
formula::FormulaGrammar::GRAM_EXTERNAL
@ GRAM_EXTERNAL
OpCodeMap set by external filter and merged with reference convention plus English bit on top.
Definition:
grammar.hxx:160
formula::FormulaGrammar::GRAM_ODFF_A1
@ GRAM_ODFF_A1
ODFF with A1 reference style, unbracketed.
Definition:
grammar.hxx:96
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1
@ GRAM_ENGLISH_XL_R1C1
English with Excel R1C1 reference style.
Definition:
grammar.hxx:132
formula::FormulaGrammar::GRAM_OOXML
@ GRAM_OOXML
Excel OOXML with Excel OOXML reference style.
Definition:
grammar.hxx:142
formula::FormulaGrammar::kConventionOffset
static const int kConventionOffset
CONV_UNSPECIFIED is a negative value!
Definition:
grammar.hxx:55
formula::FormulaGrammar::setEnglishBit
static Grammar setEnglishBit(const Grammar eGrammar, const bool bEnglish)
Definition:
grammar.cxx:66
grammar.hxx
formula
Generated on Sun Jul 30 2023 04:36:34 for LibreOffice Module formula (master) by
1.9.3