summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-09-16 10:05:05 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2010-09-16 10:05:05 +0200
commit6964bfe879aa12439ee2a02f4963276f4271e232 (patch)
treef664deb81fcefd62af7ad287f2c25920990276b2 /formula
parent4a5b4325d7bd690d14d90bf47ef8483bc7e697f4 (diff)
calc-grammar-xls-english-sc.diff: Support Excel English grammar
Support Excel English grammar needed for VBA and (probably) for xlsx filter.
Diffstat (limited to 'formula')
-rw-r--r--formula/inc/formula/FormulaCompiler.hxx2
-rw-r--r--formula/inc/formula/grammar.hxx12
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx21
3 files changed, 35 insertions, 0 deletions
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
}
@@ -681,6 +686,22 @@ void FormulaCompiler::InitSymbolsODFF() const
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
{
if ( !_xMap.get() )