update dev300-m58
[ooovba.git] / applied_patches / 0159-calc-grammar-xls-english-sc.diff
blob223506e4a5fe1e08bc66150b612446ea163390df
1 diff --git formula/inc/formula/FormulaCompiler.hxx formula/inc/formula/FormulaCompiler.hxx
2 index 6df4898..8327237 100644
3 --- formula/inc/formula/FormulaCompiler.hxx
4 +++ formula/inc/formula/FormulaCompiler.hxx
5 @@ -315,6 +315,7 @@ private:
6 void InitSymbolsEnglish() const; /// only SymbolsEnglish, maybe later
7 void InitSymbolsPODF() const; /// only SymbolsPODF, on demand
8 void InitSymbolsODFF() const; /// only SymbolsODFF, on demand
9 + void InitSymbolsEnglishXL() const; /// only SymbolsEnglishXL, on demand
11 void loadSymbols(USHORT _nSymbols,FormulaGrammar::Grammar _eGrammar,NonConstOpCodeMapPtr& _xMap) const;
13 @@ -368,6 +369,7 @@ private:
14 mutable NonConstOpCodeMapPtr mxSymbolsPODF; // ODF 1.1 symbols
15 mutable NonConstOpCodeMapPtr mxSymbolsNative; // native symbols
16 mutable NonConstOpCodeMapPtr mxSymbolsEnglish; // English symbols
17 + mutable NonConstOpCodeMapPtr mxSymbolsEnglishXL; // English Excel symbols (for VBA formula parsing)
19 // =============================================================================
20 } // formula
21 diff --git formula/inc/formula/grammar.hxx formula/inc/formula/grammar.hxx
22 index 74520da..3da926f 100644
23 --- formula/inc/formula/grammar.hxx
24 +++ formula/inc/formula/grammar.hxx
25 @@ -130,6 +130,16 @@ public:
26 GRAM_NATIVE_XL_R1C1 = ::com::sun::star::sheet::FormulaLanguage::NATIVE |
27 ((CONV_XL_R1C1 +
28 kConventionOffset) << kConventionShift),
29 + /// English with Excel A1 reference style.
30 + GRAM_ENGLISH_XL_A1 = ::com::sun::star::sheet::FormulaLanguage::XL_ENGLISH |
31 + ((CONV_XL_A1 +
32 + kConventionOffset) << kConventionShift) |
33 + kEnglishBit,
34 + /// English with Excel R1C1 reference style.
35 + GRAM_ENGLISH_XL_R1C1 = ::com::sun::star::sheet::FormulaLanguage::XL_ENGLISH |
36 + ((CONV_XL_R1C1 +
37 + kConventionOffset) << kConventionShift) |
38 + kEnglishBit,
39 /// Central definition of the default grammar to be used.
40 GRAM_DEFAULT = GRAM_NATIVE_UI,
42 @@ -180,6 +190,8 @@ public:
43 case GRAM_NATIVE_ODF :
44 case GRAM_NATIVE_XL_A1 :
45 case GRAM_NATIVE_XL_R1C1 :
46 + case GRAM_ENGLISH_XL_A1 :
47 + case GRAM_ENGLISH_XL_R1C1:
48 return true;
49 default:
50 return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL;
51 diff --git formula/source/core/api/FormulaCompiler.cxx formula/source/core/api/FormulaCompiler.cxx
52 index 5834e9e..af541e5 100644
53 --- formula/source/core/api/FormulaCompiler.cxx
54 +++ formula/source/core/api/FormulaCompiler.cxx
55 @@ -571,6 +571,11 @@ FormulaCompiler::OpCodeMapPtr FormulaCompiler::GetOpCodeMap( const sal_Int32 nLa
56 InitSymbolsNative();
57 xMap = mxSymbolsNative;
58 break;
59 + case FormulaLanguage::XL_ENGLISH:
60 + if (!mxSymbolsEnglishXL)
61 + InitSymbolsEnglishXL();
62 + xMap = mxSymbolsEnglishXL;
63 + break;
64 default:
65 ; // nothing, NULL map returned
67 @@ -684,6 +689,22 @@ void FormulaCompiler::InitSymbolsODFF() const
68 mxSymbolsODFF = s_sSymbol;
70 // -----------------------------------------------------------------------------
71 +void FormulaCompiler::InitSymbolsEnglishXL() const
73 + static NonConstOpCodeMapPtr s_sSymbol;
74 + if ( !s_sSymbol.get() )
75 + loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH,FormulaGrammar::GRAM_ENGLISH,s_sSymbol);
76 + mxSymbolsEnglishXL = s_sSymbol;
78 + // TODO: For now, just replace the separators to the Excel English
79 + // variants. Later, if we want to properly map Excel functions with Calc
80 + // functions, we'll need to do a little more work here.
81 + mxSymbolsEnglishXL->putOpCode(sal_Unicode(','), ocSep);
82 + mxSymbolsEnglishXL->putOpCode(sal_Unicode(','), ocArrayColSep);
83 + mxSymbolsEnglishXL->putOpCode(sal_Unicode(';'), ocArrayRowSep);
86 +// -----------------------------------------------------------------------------
87 void FormulaCompiler::loadSymbols(USHORT _nSymbols,FormulaGrammar::Grammar _eGrammar,NonConstOpCodeMapPtr& _xMap) const
89 if ( !_xMap.get() )