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).
This commit is contained in:
Kohei Yoshida
2010-10-05 14:47:09 -04:00
parent 5c2f0dae0c
commit 7260a33c96
2 changed files with 37 additions and 5 deletions

View File

@@ -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;

View File

@@ -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()
{