diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-02-07 14:04:53 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-02-07 17:16:35 +0200 |
commit | 0608c2cbfe8697f9912397afce2987bee23fd1ce (patch) | |
tree | 9aa502f91389e16c0f3b4290431671c7f538e8d6 | |
parent | 590624fb2ba1daaa2730c5b1d633c089565f6e8f (diff) |
Turn StringConversion into a C++11 scoped enumeration
Change-Id: I353a62bac6c8bf00b20c93d9778fc45ade5d502c
-rw-r--r-- | sc/inc/calcconfig.hxx | 10 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/tool/calcconfig.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/formulaopt.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/optdlg/calcoptionsdlg.cxx | 10 |
6 files changed, 36 insertions, 36 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx index 7cc8fadcc7d0..314aa95cc598 100644 --- a/sc/inc/calcconfig.hxx +++ b/sc/inc/calcconfig.hxx @@ -33,12 +33,12 @@ enum ScRecalcOptions struct SC_DLLPUBLIC ScCalcConfig { // from most stringent to most relaxed - enum StringConversion + enum class StringConversion { - STRING_CONVERSION_AS_ERROR = 0, ///< =1+"1" or =1+"x" give #VALUE! - STRING_CONVERSION_AS_ZERO, ///< =1+"1" or =1+"x" give 1 - STRING_CONVERSION_UNAMBIGUOUS, ///< =1+"1" gives 2, but =1+"1.000" or =1+"x" give #VALUE! - STRING_CONVERSION_LOCALE_DEPENDENT ///< =1+"1.000" may be 2 or 1001 ... =1+"x" gives #VALUE! + ERROR, ///< =1+"1" or =1+"x" give #VALUE! + ZERO, ///< =1+"1" or =1+"x" give 1 + UNAMBIGUOUS, ///< =1+"1" gives 2, but =1+"1.000" or =1+"x" give #VALUE! + LOCALE ///< =1+"1.000" may be 2 or 1001 ... =1+"x" gives #VALUE! }; formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax; StringConversion meStringConversion; diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index b839816dae1c..df258bcfecf9 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1534,7 +1534,7 @@ void Test::testFuncParam() ScCalcConfig aConfig; // With "Convert also locale dependent" and "Empty string as zero"=True option. - aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT; + aConfig.meStringConversion = ScCalcConfig::StringConversion::LOCALE; aConfig.mbEmptyStringAsZero = true; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); @@ -1550,7 +1550,7 @@ void Test::testFuncParam() CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7.4); // With "Convert also locale dependent" and "Empty string as zero"=False option. - aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT; + aConfig.meStringConversion = ScCalcConfig::StringConversion::LOCALE; aConfig.mbEmptyStringAsZero = false; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); @@ -1566,7 +1566,7 @@ void Test::testFuncParam() CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 7.4); // With "Convert only unambiguous" and "Empty string as zero"=True option. - aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS; + aConfig.meStringConversion = ScCalcConfig::StringConversion::UNAMBIGUOUS; aConfig.mbEmptyStringAsZero = true; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); @@ -1582,7 +1582,7 @@ void Test::testFuncParam() CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!"); // With "Convert only unambiguous" and "Empty string as zero"=False option. - aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS; + aConfig.meStringConversion = ScCalcConfig::StringConversion::UNAMBIGUOUS; aConfig.mbEmptyStringAsZero = false; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); @@ -1598,7 +1598,7 @@ void Test::testFuncParam() CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!"); // With "Treat as zero" ("Empty string as zero" is ignored). - aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ZERO; + aConfig.meStringConversion = ScCalcConfig::StringConversion::ZERO; aConfig.mbEmptyStringAsZero = true; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); @@ -1614,7 +1614,7 @@ void Test::testFuncParam() CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3); // With "Generate #VALUE! error" ("Empty string as zero" is ignored). - aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ERROR; + aConfig.meStringConversion = ScCalcConfig::StringConversion::ERROR; aConfig.mbEmptyStringAsZero = false; m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx index b4cdb8cd3be2..bcea83fbfa96 100644 --- a/sc/source/core/tool/calcconfig.cxx +++ b/sc/source/core/tool/calcconfig.cxx @@ -22,7 +22,7 @@ ScCalcConfig::ScCalcConfig() : meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED), - meStringConversion(STRING_CONVERSION_LOCALE_DEPENDENT), // old LibreOffice behavior + meStringConversion(StringConversion::LOCALE), // old LibreOffice behavior mbEmptyStringAsZero(false) { setOpenCLConfigToDefault(); @@ -105,10 +105,10 @@ std::string StringConversionToString(ScCalcConfig::StringConversion eConv) { switch (eConv) { - case ScCalcConfig::STRING_CONVERSION_AS_ERROR: return "ERROR"; - case ScCalcConfig::STRING_CONVERSION_AS_ZERO: return "ZERO"; - case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: return "UNAMBIGUOUS"; - case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: return "LOCALE"; + case ScCalcConfig::StringConversion::ERROR: return "ERROR"; + case ScCalcConfig::StringConversion::ZERO: return "ZERO"; + case ScCalcConfig::StringConversion::UNAMBIGUOUS: return "UNAMBIGUOUS"; + case ScCalcConfig::StringConversion::LOCALE: return "LOCALE"; default: return std::to_string((int) eConv); } } diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx index cd12d0a7c2ad..e9e474809882 100644 --- a/sc/source/core/tool/formulaopt.cxx +++ b/sc/source/core/tool/formulaopt.cxx @@ -387,16 +387,16 @@ void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames ) switch (nIntVal) { case 0: - eConv = ScCalcConfig::STRING_CONVERSION_AS_ERROR; + eConv = ScCalcConfig::StringConversion::ERROR; break; case 1: - eConv = ScCalcConfig::STRING_CONVERSION_AS_ZERO; + eConv = ScCalcConfig::StringConversion::ZERO; break; case 2: - eConv = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS; + eConv = ScCalcConfig::StringConversion::UNAMBIGUOUS; break; case 3: - eConv = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT; + eConv = ScCalcConfig::StringConversion::LOCALE; break; default: SAL_WARN("sc", "unknown string conversion option!"); @@ -558,10 +558,10 @@ void ScFormulaCfg::Commit() sal_Int32 nVal = 3; switch (GetCalcConfig().meStringConversion) { - case ScCalcConfig::STRING_CONVERSION_AS_ERROR: nVal = 0; break; - case ScCalcConfig::STRING_CONVERSION_AS_ZERO: nVal = 1; break; - case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: nVal = 2; break; - case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: nVal = 3; break; + case ScCalcConfig::StringConversion::ERROR: nVal = 0; break; + case ScCalcConfig::StringConversion::ZERO: nVal = 1; break; + case ScCalcConfig::StringConversion::UNAMBIGUOUS: nVal = 2; break; + case ScCalcConfig::StringConversion::LOCALE: nVal = 3; break; } pValues[nProp] <<= nVal; } diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 81ec490ce8cb..70a6b8792b97 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -207,7 +207,7 @@ bool isEmptyString( const OUString& rStr ) /** Convert string content to numeric value. Depending on the string conversion configuration different approaches are - taken. For ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS if the string is not + taken. For ScCalcConfig::StringConversion::UNAMBIGUOUS if the string is not empty the following conversion rules are applied: Converted are only integer numbers including exponent, and ISO 8601 dates @@ -240,7 +240,7 @@ bool isEmptyString( const OUString& rStr ) double ScInterpreter::ConvertStringToValue( const OUString& rStr ) { - // We keep ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT default until + // We keep ScCalcConfig::StringConversion::LOCALE default until // we provide a friendly way to convert string numbers into numbers in the UI. double fValue = 0.0; @@ -253,19 +253,19 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr ) switch (maCalcConfig.meStringConversion) { - case ScCalcConfig::STRING_CONVERSION_AS_ERROR: + case ScCalcConfig::StringConversion::ERROR: SetError( mnStringNoValueError); return fValue; - case ScCalcConfig::STRING_CONVERSION_AS_ZERO: + case ScCalcConfig::StringConversion::ZERO: return fValue; - case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: + case ScCalcConfig::StringConversion::LOCALE: { if (maCalcConfig.mbEmptyStringAsZero) { // The number scanner does not accept empty strings or strings // containing only spaces, be on par in these cases with what was // accepted in OOo and is in AOO (see also the - // STRING_CONVERSION_UNAMBIGUOUS branch) and convert to 0 to prevent + // StringConversion::UNAMBIGUOUS branch) and convert to 0 to prevent // interoperability nightmares. if (isEmptyString( rStr)) @@ -281,7 +281,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr ) return fValue; } break; - case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: + case ScCalcConfig::StringConversion::UNAMBIGUOUS: { if (!maCalcConfig.mbEmptyStringAsZero) { diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx index 0eada39c8130..7db6ae881181 100644 --- a/sc/source/ui/optdlg/calcoptionsdlg.cxx +++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx @@ -71,7 +71,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi get(mpFtMemory, "memory"); get(mpConversion,"comboConversion"); - mpConversion->SelectEntryPos(rConfig.meStringConversion, true); + mpConversion->SelectEntryPos(static_cast<sal_Int32>(rConfig.meStringConversion), true); mpConversion->SetSelectHdl(LINK(this, ScCalcOptionsDialog, ConversionModifiedHdl)); get(mpEmptyAsZero,"checkEmptyAsZero"); @@ -168,18 +168,18 @@ IMPL_LINK(ScCalcOptionsDialog, ConversionModifiedHdl, ListBox*, pConv ) maConfig.meStringConversion = (ScCalcConfig::StringConversion)pConv->GetSelectEntryPos(); switch (maConfig.meStringConversion) { - case ScCalcConfig::STRING_CONVERSION_AS_ERROR: + case ScCalcConfig::StringConversion::ERROR: maConfig.mbEmptyStringAsZero = false; mpEmptyAsZero->Check(false); mpEmptyAsZero->Enable(false); break; - case ScCalcConfig::STRING_CONVERSION_AS_ZERO: + case ScCalcConfig::StringConversion::ZERO: maConfig.mbEmptyStringAsZero = true; mpEmptyAsZero->Check(true); mpEmptyAsZero->Enable(false); break; - case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: - case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: + case ScCalcConfig::StringConversion::UNAMBIGUOUS: + case ScCalcConfig::StringConversion::LOCALE: // Reset to the value the user selected before. maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero; mpEmptyAsZero->Enable(true); |