diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-10-05 14:47:09 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-10-05 14:47:09 -0400 |
commit | 7260a33c965eda5a5dc9dcd785621af152147d3b (patch) | |
tree | 58d18ea74d123d399bed742ca420bd8c8c55366f /formula | |
parent | Ported calc-english-func-names-*.diff from ooo-build. (diff) | |
download | core-7260a33c965eda5a5dc9dcd785621af152147d3b.tar.gz core-7260a33c965eda5a5dc9dcd785621af152147d3b.zip |
Ported calc-english-func-names-*.diff from ooo-build.
Add option to switch to English function names instead of the
localized ones. In some locales (especially in Hungary) the users are
more accustomed to the English function names rather other than
translated names (i#38765).
Diffstat (limited to 'formula')
-rw-r--r-- | formula/inc/formula/FormulaCompiler.hxx | 4 | ||||
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 38 |
2 files changed, 37 insertions, 5 deletions
diff --git a/formula/inc/formula/FormulaCompiler.hxx b/formula/inc/formula/FormulaCompiler.hxx index 4da7318807a2..5666bf682d5a 100644 --- a/formula/inc/formula/FormulaCompiler.hxx +++ b/formula/inc/formula/FormulaCompiler.hxx @@ -122,6 +122,7 @@ public: } virtual ~OpCodeMap(); + void copyFrom( const OpCodeMap& r ); /// Get the symbol String -> OpCode hash map for finds. inline const OpCodeHashMap* getHashMap() const { return mpHashMap; } @@ -243,7 +244,8 @@ public: inline FormulaGrammar::Grammar GetGrammar() const { return meGrammar; } static void UpdateSeparatorsNative( const rtl::OUString& rSep, const rtl::OUString& rArrayColSep, const rtl::OUString& rArrayRowSep ); - + static void ResetNativeSymbols(); + static void SetNativeSymbols( const OpCodeMapPtr& xMap ); protected: virtual String FindAddInFunction( const String& rUpperName, BOOL bLocalFirst ) const; virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const; diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 2a2832d59f0d..d2ede5596cf9 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -642,6 +642,7 @@ const String& FormulaCompiler::GetNativeSymbol( OpCode eOp ) // ----------------------------------------------------------------------------- void FormulaCompiler::InitSymbolsNative() const { +#if 0 // No point in keeping this since you can now do this from the UI. if (mxSymbolsNative.get()) return; //! Experimental! @@ -656,10 +657,9 @@ void FormulaCompiler::InitSymbolsNative() const mxSymbolsNative = mxSymbolsEnglish; return; } - static NonConstOpCodeMapPtr s_sSymbol; - if ( !s_sSymbol.get() ) - lcl_fillNativeSymbols(s_sSymbol); - mxSymbolsNative = s_sSymbol; +#endif + + lcl_fillNativeSymbols(mxSymbolsNative); } // ----------------------------------------------------------------------------- void FormulaCompiler::InitSymbolsEnglish() const @@ -796,6 +796,22 @@ FormulaCompiler::OpCodeMap::~OpCodeMap() delete mpHashMap; } // ----------------------------------------------------------------------------- +void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r ) +{ + delete mpHashMap; + mpHashMap = new OpCodeHashMap(mnSymbols); + + USHORT n = r.getSymbolCount(); + for (USHORT i = 0; i < n; ++i) + { + OpCode eOp = OpCode(i); + const String& rSymbol = r.getSymbol(eOp); + putOpCode(rSymbol, eOp); + } + + // TODO: maybe copy the external maps too? +} +// ----------------------------------------------------------------------------- sal_Int32 FormulaCompiler::OpCodeMap::getOpCodeUnknown() { static const sal_Int32 kOpCodeUnknown = -1; @@ -1710,6 +1726,20 @@ void FormulaCompiler::UpdateSeparatorsNative( xSymbolsNative->putOpCode(rArrayRowSep, ocArrayRowSep); } +void FormulaCompiler::ResetNativeSymbols() +{ + NonConstOpCodeMapPtr xSymbolsNative; + lcl_fillNativeSymbols(xSymbolsNative, true); + lcl_fillNativeSymbols(xSymbolsNative); +} + +void FormulaCompiler::SetNativeSymbols( const OpCodeMapPtr& xMap ) +{ + NonConstOpCodeMapPtr xSymbolsNative; + lcl_fillNativeSymbols(xSymbolsNative); + xSymbolsNative->copyFrom(*xMap); +} + // ----------------------------------------------------------------------------- OpCode FormulaCompiler::NextToken() { |