Resolves: tdf#151886 Use default locale with English function names again
Automatically switching to en-US locale when using English
function names caused too much confusion. There also might be the
possibility that the '.' dot decimal separator clashes with the
inline array column separator in some locales.
A proper solution would make this user-specified and if set also
adjust the separators to the common English ones. For now keep the
default locale again as it previously was the case.
Change-Id: Ic4712c6609c14f35cf0d1d842ac7443806a6e115
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144924
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit cf8cfee9d4e64dba6a14dde16f08a7699fdff863)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144905
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index b0e21b2..f7dcba3 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1313,7 +1313,17 @@ void FormulaCompiler::OpCodeMap::copyFrom( const OpCodeMap& r )
maExternalHashMap = r.maExternalHashMap;
maReverseExternalHashMap = r.maReverseExternalHashMap;
mbCore = r.mbCore;
mbEnglish = r.mbEnglish;
if (mbEnglish != r.mbEnglish)
{
// For now keep mbEnglishLocale setting, which is false for a
// non-English native map we're copying to.
/* TODO:
if (!mbEnglish && r.mbEnglish)
mbEnglishLocale = "getUseEnglishLocaleFromConfiguration()";
or set from outside i.e. via ScCompiler.
*/
mbEnglish = r.mbEnglish;
}
}
}
@@ -2658,7 +2668,7 @@ const FormulaToken* FormulaCompiler::CreateStringFromToken( OUStringBuffer& rBuf
void FormulaCompiler::AppendDouble( OUStringBuffer& rBuffer, double fVal ) const
{
if ( mxSymbols->isEnglish() )
if ( mxSymbols->isEnglishLocale() )
{
::rtl::math::doubleToUStringBuffer( rBuffer, fVal,
rtl_math_StringFormat_Automatic,
diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx
index d94dbd4..08710f5 100644
--- a/include/formula/FormulaCompiler.hxx
+++ b/include/formula/FormulaCompiler.hxx
@@ -83,12 +83,13 @@ public:
{
OpCodeHashMap maHashMap; /// Hash map of symbols, OUString -> OpCode
std::unique_ptr<OUString[]> mpTable; /// Array of symbols, OpCode -> OUString, offset==OpCode
ExternalHashMap maExternalHashMap; /// Hash map of ocExternal, Filter String -> AddIn String
ExternalHashMap maReverseExternalHashMap; /// Hash map of ocExternal, AddIn String -> Filter String
ExternalHashMap maExternalHashMap; /// Hash map of ocExternal, Filter String -> AddIn String
ExternalHashMap maReverseExternalHashMap; /// Hash map of ocExternal, AddIn String -> Filter String
FormulaGrammar::Grammar meGrammar; /// Grammar, language and reference convention
sal_uInt16 mnSymbols; /// Count of OpCode symbols
bool mbCore : 1; /// If mapping was setup by core, not filters
bool mbEnglish : 1; /// If English symbols and external names
bool mbCore : 1; /// If mapping was setup by core, not filters
bool mbEnglish : 1; /// If English symbols and external names
bool mbEnglishLocale : 1; /// If English locale for numbers
OpCodeMap( const OpCodeMap& ) = delete;
OpCodeMap& operator=( const OpCodeMap& ) = delete;
@@ -101,7 +102,8 @@ public:
meGrammar( eGrammar),
mnSymbols( nSymbols),
mbCore( bCore),
mbEnglish ( FormulaGrammar::isEnglish(eGrammar) )
mbEnglish ( FormulaGrammar::isEnglish(eGrammar) ),
mbEnglishLocale ( mbEnglish )
{
}
@@ -145,6 +147,10 @@ public:
be English as well)? */
bool isEnglish() const { return mbEnglish; }
/** Are inline numbers parsed/formatted in en-US locale, as opposed
to default locale? */
bool isEnglishLocale() const { return mbEnglishLocale; }
/// Is it an ODF 1.1 compatibility mapping?
bool isPODF() const { return FormulaGrammar::isPODF( meGrammar); }
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index e55a7e9..3e8a65a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2154,8 +2154,8 @@ std::vector<ScCompiler::Whitespace> ScCompiler::NextSymbol(bool bInArray)
sal_Unicode cSep = mxSymbols->getSymbolChar( ocSep);
sal_Unicode cArrayColSep = mxSymbols->getSymbolChar( ocArrayColSep);
sal_Unicode cArrayRowSep = mxSymbols->getSymbolChar( ocArrayRowSep);
sal_Unicode cDecSep = (mxSymbols->isEnglish() ? '.' : ScGlobal::getLocaleData().getNumDecimalSep()[0]);
sal_Unicode cDecSepAlt = (mxSymbols->isEnglish() ? 0 : ScGlobal::getLocaleData().getNumDecimalSepAlt().toChar());
sal_Unicode cDecSep = (mxSymbols->isEnglishLocale() ? '.' : ScGlobal::getLocaleData().getNumDecimalSep()[0]);
sal_Unicode cDecSepAlt = (mxSymbols->isEnglishLocale() ? 0 : ScGlobal::getLocaleData().getNumDecimalSepAlt().toChar());
// special symbols specific to address convention used
sal_Unicode cSheetPrefix = pConv->getSpecialSymbol(ScCompiler::Convention::ABS_SHEET_PREFIX);
@@ -3168,7 +3168,7 @@ bool ScCompiler::ParseValue( const OUString& rSym )
}
double fVal;
sal_uInt32 nIndex = mxSymbols->isEnglish() ? mpFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) : 0;
sal_uInt32 nIndex = mxSymbols->isEnglishLocale() ? mpFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) : 0;
if (!mpFormatter->IsNumberFormat(rSym, nIndex, fVal))
return false;
@@ -3425,7 +3425,7 @@ bool ScCompiler::ParseReference( const OUString& rName, const OUString* pErrRef
mnCurrentSheetTab = -1;
sal_Unicode ch1 = rName[0];
sal_Unicode cDecSep = ( mxSymbols->isEnglish() ? '.' : ScGlobal::getLocaleData().getNumDecimalSep()[0] );
sal_Unicode cDecSep = ( mxSymbols->isEnglishLocale() ? '.' : ScGlobal::getLocaleData().getNumDecimalSep()[0] );
if ( ch1 == cDecSep )
return false;
// Code further down checks only if cDecSep=='.' so simply obtaining the