summaryrefslogtreecommitdiff
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
commitfa0e57adc40e440129055f0c8ab52eaab1006896 (patch)
treee7870265ecbb1920ad85d0a5b2a77b688132ff2f
parent7fedd05085f7a41cae74f645acde82f2a2c55c4a (diff)
calc-grammar-xls-english-sc.diff: Support Excel English grammar
Support Excel English grammar needed for VBA and (probably) for xlsx filter.
-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 d82e2c83bb..47fefb3682 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 691dbcb715..acaf7d8039 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 508d780d3a..fed0aabaea 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() )