diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx index 97b7b980678a..4da7318807a2 100644 --- a/formula/inc/formula/FormulaCompiler.hxx +++ b/formula/inc/formula/FormulaCompiler.hxx @@ -320,6 +320,7 @@ private: void InitSymbolsEnglish() const; /// only SymbolsEnglish, maybe later void InitSymbolsPODF() const; /// only SymbolsPODF, on demand void InitSymbolsODFF() const; /// only SymbolsODFF, on demand + void InitSymbolsEnglishXL() const; /// only SymbolsEnglishXL, on demand void loadSymbols(USHORT _nSymbols,FormulaGrammar::Grammar _eGrammar,NonConstOpCodeMapPtr& _xMap) const; @@ -373,6 +374,7 @@ private: mutable NonConstOpCodeMapPtr mxSymbolsPODF; // ODF 1.1 symbols mutable NonConstOpCodeMapPtr mxSymbolsNative; // native symbols mutable NonConstOpCodeMapPtr mxSymbolsEnglish; // English symbols + mutable NonConstOpCodeMapPtr mxSymbolsEnglishXL; // English Excel symbols (for VBA formula parsing) }; // ============================================================================= } // formula diff --git a/formula/inc/formula/grammar.hxx b/formula/inc/formula/grammar.hxx index 5f8e6be82350..a6f542ac5054 100644 --- a/formula/inc/formula/grammar.hxx +++ b/formula/inc/formula/grammar.hxx @@ -127,6 +127,16 @@ public: GRAM_NATIVE_XL_R1C1 = ::com::sun::star::sheet::FormulaLanguage::NATIVE | ((CONV_XL_R1C1 + kConventionOffset) << kConventionShift), + /// English with Excel A1 reference style. + GRAM_ENGLISH_XL_A1 = ::com::sun::star::sheet::FormulaLanguage::XL_ENGLISH | + ((CONV_XL_A1 + + kConventionOffset) << kConventionShift) | + kEnglishBit, + /// English with Excel R1C1 reference style. + GRAM_ENGLISH_XL_R1C1 = ::com::sun::star::sheet::FormulaLanguage::XL_ENGLISH | + ((CONV_XL_R1C1 + + kConventionOffset) << kConventionShift) | + kEnglishBit, /// Central definition of the default grammar to be used. GRAM_DEFAULT = GRAM_NATIVE_UI, @@ -177,6 +187,8 @@ public: case GRAM_NATIVE_ODF : case GRAM_NATIVE_XL_A1 : case GRAM_NATIVE_XL_R1C1 : + case GRAM_ENGLISH_XL_A1 : + case GRAM_ENGLISH_XL_R1C1: return true; default: return extractFormulaLanguage( eGrammar) == GRAM_EXTERNAL; diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 607700960ca1..2a2832d59f0d 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -568,6 +568,11 @@ FormulaCompiler::OpCodeMapPtr FormulaCompiler::GetOpCodeMap( const sal_Int32 nLa InitSymbolsNative(); xMap = mxSymbolsNative; break; + case FormulaLanguage::XL_ENGLISH: + if (!mxSymbolsEnglishXL) + InitSymbolsEnglishXL(); + xMap = mxSymbolsEnglishXL; + break; default: ; // nothing, NULL map returned } @@ -680,6 +685,22 @@ void FormulaCompiler::InitSymbolsODFF() const loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF,FormulaGrammar::GRAM_ODFF,s_sSymbol); mxSymbolsODFF = s_sSymbol; } +// ----------------------------------------------------------------------------- +void FormulaCompiler::InitSymbolsEnglishXL() const +{ + static NonConstOpCodeMapPtr s_sSymbol; + if ( !s_sSymbol.get() ) + loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH,FormulaGrammar::GRAM_ENGLISH,s_sSymbol); + mxSymbolsEnglishXL = s_sSymbol; + + // TODO: For now, just replace the separators to the Excel English + // variants. Later, if we want to properly map Excel functions with Calc + // functions, we'll need to do a little more work here. + mxSymbolsEnglishXL->putOpCode(sal_Unicode(','), ocSep); + mxSymbolsEnglishXL->putOpCode(sal_Unicode(','), ocArrayColSep); + mxSymbolsEnglishXL->putOpCode(sal_Unicode(';'), ocArrayRowSep); +} + // ----------------------------------------------------------------------------- void FormulaCompiler::loadSymbols(USHORT _nSymbols,FormulaGrammar::Grammar _eGrammar,NonConstOpCodeMapPtr& _xMap) const {