/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
void ScFormulaOptions::GetDefaultFormulaSeparators(
OUString& rSepArg, OUString& rSepArrayCol, OUString& rSepArrayRow)
{ // Defaults to the old separator values.
rSepArg = ";";
rSepArrayCol = ";";
rSepArrayRow = "|";
const lang::Locale& rLocale = ScGlobal::GetLocale(); const OUString& rLang = rLocale.Language; if (rLang == "ru") // Don't do automatic guess for these languages, and fall back to // the old separator set. return;
// Excel by default uses system's list separator as the parameter // separator, which in English locales is a comma. However, OOo's list // separator value is set to ';' for all English locales. Because of this // discrepancy, we will hardcode the separator value here, for now. // Similar for decimal separator alternative. // However, if the decimal separator alternative is '.' and the decimal // separator is ',' this makes no sense, fall back to ';' in that case. if (cDecSep == '.' || (cDecSepAlt == '.' && cDecSep != ','))
cListSep = ','; elseif (cDecSep == ',' && cDecSepAlt == '.')
cListSep = ';';
// Special case for de_CH locale. if (rLocale.Language == "de" && rLocale.Country == "CH")
cListSep = ';';
// by default, the parameter separator equals the locale-specific // list separator.
rSepArg = OUString(cListSep);
if (cDecSep == cListSep && cDecSep != ';') // if the decimal and list separators are equal, set the // parameter separator to be ';', unless they are both // semicolon in which case don't change the decimal separator.
rSepArg = ";";
sal_Int32 nIntVal = 0; for(int nProp = 0; nProp < aNames.getLength(); nProp++)
{
PropsToIds::iterator it_end = aPropMap.end();
PropsToIds::iterator it = aPropMap.find( aNames[nProp] ); if(pValues[nProp].hasValue() && it != it_end )
{ switch(it->second)
{ case SCFORMULAOPT_GRAMMAR:
{ // Get default value in case this option is not set.
::formula::FormulaGrammar::Grammar eGram = GetFormulaSyntax();
do
{ if (!(pValues[nProp] >>= nIntVal)) // extracting failed. break;
switch (nIntVal)
{ case 0: // Calc A1
eGram = ::formula::FormulaGrammar::GRAM_NATIVE; break; case 1: // Excel A1
eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1; break; case 2: // Excel R1C1
eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1; break; default:
;
}
} while (false);
SetFormulaSyntax(eGram);
} break; case SCFORMULAOPT_ENGLISH_FUNCNAME:
{ bool bEnglish = false; if (pValues[nProp] >>= bEnglish)
SetUseEnglishFuncName(bEnglish);
} break; case SCFORMULAOPT_SEP_ARG:
{
OUString aSep; if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
SetFormulaSepArg(aSep);
} break; case SCFORMULAOPT_SEP_ARRAY_ROW:
{
OUString aSep; if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
SetFormulaSepArrayRow(aSep);
} break; case SCFORMULAOPT_SEP_ARRAY_COL:
{
OUString aSep; if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
SetFormulaSepArrayCol(aSep);
} break; case SCFORMULAOPT_STRING_REF_SYNTAX:
{ // Get default value in case this option is not set.
::formula::FormulaGrammar::AddressConvention eConv = GetCalcConfig().meStringRefAddressSyntax;
do
{ if (!(pValues[nProp] >>= nIntVal)) // extraction failed. break;
switch (nIntVal)
{ case -1: // Same as the formula grammar.
eConv = formula::FormulaGrammar::CONV_UNSPECIFIED; break; case 0: // Calc A1
eConv = formula::FormulaGrammar::CONV_OOO; break; case 1: // Excel A1
eConv = formula::FormulaGrammar::CONV_XL_A1; break; case 2: // Excel R1C1
eConv = formula::FormulaGrammar::CONV_XL_R1C1; break; case 3: // Calc A1 | Excel A1
eConv = formula::FormulaGrammar::CONV_A1_XL_A1; break; default:
;
}
} while (false);
GetCalcConfig().meStringRefAddressSyntax = eConv;
} break; case SCFORMULAOPT_STRING_CONVERSION:
{ // Get default value in case this option is not set.
ScCalcConfig::StringConversion eConv = GetCalcConfig().meStringConversion;
do
{ if (!(pValues[nProp] >>= nIntVal)) // extraction failed. break;
switch (nIntVal)
{ case 0:
eConv = ScCalcConfig::StringConversion::ILLEGAL; break; case 1:
eConv = ScCalcConfig::StringConversion::ZERO; break; case 2:
eConv = ScCalcConfig::StringConversion::UNAMBIGUOUS; break; case 3:
eConv = ScCalcConfig::StringConversion::LOCALE; break; default:
SAL_WARN("sc", "unknown string conversion option!");
}
} while (false);
GetCalcConfig().meStringConversion = eConv;
} break; case SCFORMULAOPT_EMPTY_OUSTRING_AS_ZERO:
{ bool bVal = GetCalcConfig().mbEmptyStringAsZero;
pValues[nProp] >>= bVal;
GetCalcConfig().mbEmptyStringAsZero = bVal;
} break; case SCFORMULAOPT_OOXML_RECALC:
{
ScRecalcOptions eOpt = RECALC_ASK; if (pValues[nProp] >>= nIntVal)
{ switch (nIntVal)
{ case 0:
eOpt = RECALC_ALWAYS; break; case 1:
eOpt = RECALC_NEVER; break; case 2:
eOpt = RECALC_ASK; break; default:
SAL_WARN("sc", "unknown ooxml recalc option!");
}
}
SetOOXMLRecalcOptions(eOpt);
} break; case SCFORMULAOPT_ODF_RECALC:
{
ScRecalcOptions eOpt = RECALC_ASK; if (pValues[nProp] >>= nIntVal)
{ switch (nIntVal)
{ case 0:
eOpt = RECALC_ALWAYS; break; case 1:
eOpt = RECALC_NEVER; break; case 2:
eOpt = RECALC_ASK; break; default:
SAL_WARN("sc", "unknown odf recalc option!");
}
}
SetODFRecalcOptions(eOpt);
} break; case SCFORMULAOPT_ROW_HEIGHT_RECALC:
{
ScRecalcOptions eOpt = RECALC_ASK; if (pValues[nProp] >>= nIntVal)
{ switch (nIntVal)
{ case 0:
eOpt = RECALC_ALWAYS; break; case 1:
eOpt = RECALC_NEVER; break; case 2:
eOpt = RECALC_ASK; break; default:
SAL_WARN("sc", "unknown optimal row height recalc option!");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.