diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2017-05-12 16:14:33 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-05-13 13:43:11 +0200 |
commit | f7900c486082573efdf2d7cc50ed0d3aefca4a32 (patch) | |
tree | 711614dc47fcd412693d488560005aad87409f21 /sc | |
parent | 8aee79e35208dd263928d7f5daa3f931fd3de99d (diff) |
Kill some code duplication, move shared code into private func
Change-Id: I4898f49c5bc6d68e73b283bc5b4abbfa0b000a40
Reviewed-on: https://gerrit.libreoffice.org/37541
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 42 |
2 files changed, 15 insertions, 28 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index abddcd9d7ebb..6390f4402af6 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -426,6 +426,7 @@ bool GetBool() { return GetDouble() != 0.0; } bool GetDoubleOrString( double& rValue, svl::SharedString& rString ); svl::SharedString GetString(); svl::SharedString GetStringFromMatrix(const ScMatrixRef& pMat); +svl::SharedString GetStringFromDouble( const double fVal); // pop matrix and obtain one element, upper left or according to jump matrix ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, svl::SharedString& rString ); ScMatrixRef CreateMatrixFromDoubleRef( const formula::FormulaToken* pToken, diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 9ed69677369f..a9fe3c62109a 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -260,13 +260,7 @@ void ScInterpreter::GetCellString( svl::SharedString& rStr, ScRefCellValue& rCel nErr = pFCell->GetErrCode(); if (pFCell->IsValue()) { - double fVal = pFCell->GetValue(); - sal_uLong nIndex = pFormatter->GetStandardFormat( - css::util::NumberFormat::NUMBER, - ScGlobal::eLnge); - OUString aStr; - pFormatter->GetInputLineString(fVal, nIndex, aStr); - rStr = mrStrPool.intern(aStr); + rStr = GetStringFromDouble( pFCell->GetValue() ); } else rStr = pFCell->GetString(); @@ -274,13 +268,7 @@ void ScInterpreter::GetCellString( svl::SharedString& rStr, ScRefCellValue& rCel break; case CELLTYPE_VALUE: { - double fVal = rCell.mfValue; - sal_uLong nIndex = pFormatter->GetStandardFormat( - css::util::NumberFormat::NUMBER, - ScGlobal::eLnge); - OUString aStr; - pFormatter->GetInputLineString(fVal, nIndex, aStr); - rStr = mrStrPool.intern(aStr); + rStr = GetStringFromDouble( rCell.mfValue ); } break; default: @@ -2279,13 +2267,7 @@ svl::SharedString ScInterpreter::GetString() return svl::SharedString::getEmptyString(); case svDouble: { - double fVal = PopDouble(); - sal_uLong nIndex = pFormatter->GetStandardFormat( - css::util::NumberFormat::NUMBER, - ScGlobal::eLnge); - OUString aStr; - pFormatter->GetInputLineString(fVal, nIndex, aStr); - return mrStrPool.intern(aStr); + return GetStringFromDouble( PopDouble() ); } case svString: return PopString(); @@ -2327,13 +2309,7 @@ svl::SharedString ScInterpreter::GetString() if (pToken->GetType() == svDouble) { - double fVal = pToken->GetDouble(); - sal_uLong nIndex = pFormatter->GetStandardFormat( - css::util::NumberFormat::NUMBER, - ScGlobal::eLnge); - OUString aStr; - pFormatter->GetInputLineString(fVal, nIndex, aStr); - return mrStrPool.intern(aStr); + return GetStringFromDouble( pToken->GetDouble() ); } else // svString or svEmpty return pToken->GetString(); @@ -2440,6 +2416,16 @@ ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( return nMatValType; } +svl::SharedString ScInterpreter::GetStringFromDouble( double fVal ) +{ + sal_uLong nIndex = pFormatter->GetStandardFormat( + css::util::NumberFormat::NUMBER, + ScGlobal::eLnge); + OUString aStr; + pFormatter->GetInputLineString(fVal, nIndex, aStr); + return mrStrPool.intern(aStr); +} + void ScInterpreter::ScDBGet() { bool bMissingField = false; |