summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2013-06-23 23:50:53 +0200
committerCaolán McNamara <caolanm@redhat.com>2013-07-15 19:16:02 +0000
commit67db35da5d7a3b117a0e0035c17c2fb58e5f23e6 (patch)
treec977f011cc90afe5144ae683f40c799eca02e9f2
parent5bd6a5110bb812f82a81e73422a7b14851f84441 (diff)
DoubleToString: do not modify a reference argument, just return the result
Change-Id: I490aa61f8d9b47a6ead234afd51e2f5324530cb4 Reviewed-on: https://gerrit.libreoffice.org/4923 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/inc/fldbas.hxx4
-rw-r--r--sw/source/core/fields/fldbas.cxx27
-rw-r--r--sw/source/core/fields/usrfld.cxx5
3 files changed, 17 insertions, 19 deletions
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 53ab8266538a..057f9171c87b 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -385,8 +385,8 @@ public:
inline void EnableFormat(sal_Bool bFormat = sal_True) { bUseFormat = bFormat; }
String ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const;
- void DoubleToString(String &rValue, const double &rVal, LanguageType eLng) const;
- void DoubleToString(String &rValue, const double &rVal, sal_uInt32 nFmt) const;
+ String DoubleToString(const double &rVal, LanguageType eLng) const;
+ String DoubleToString(const double &rVal, sal_uInt32 nFmt) const;
};
class SW_DLLPUBLIC SwValueField : public SwField
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 524e1855774a..9db180b1c47d 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -467,9 +467,7 @@ String SwValueFieldType::ExpandValue( const double& rVal,
if( pFormatter->IsTextFormat( nFmt ) )
{
- String sValue;
- DoubleToString(sValue, rVal, nFmtLng);
- OUString sTempIn(sValue);
+ OUString sTempIn(DoubleToString(rVal, nFmtLng));
pFormatter->GetOutputString(sTempIn, nFmt, sExpand, &pCol);
}
else
@@ -479,17 +477,19 @@ String SwValueFieldType::ExpandValue( const double& rVal,
return sExpand;
}
-void SwValueFieldType::DoubleToString( String &rValue, const double &rVal,
+String SwValueFieldType::DoubleToString(const double &rVal,
sal_uInt32 nFmt) const
{
SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter();
const SvNumberformat* pEntry = pFormatter->GetEntry(nFmt);
- if (pEntry)
- DoubleToString(rValue, rVal, pEntry->GetLanguage());
+ if (!pEntry)
+ return String();
+
+ return DoubleToString(rVal, pEntry->GetLanguage());
}
-void SwValueFieldType::DoubleToString( String &rValue, const double &rVal,
+String SwValueFieldType::DoubleToString( const double &rVal,
sal_uInt16 nLng ) const
{
SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter();
@@ -499,7 +499,7 @@ void SwValueFieldType::DoubleToString( String &rValue, const double &rVal,
nLng = LANGUAGE_SYSTEM;
pFormatter->ChangeIntl( nLng ); // get separator in the correct language
- rValue = ::rtl::math::doubleToUString( rVal, rtl_math_StringFormat_F, 12,
+ return ::rtl::math::doubleToUString( rVal, rtl_math_StringFormat_F, 12,
pFormatter->GetDecSep(), true );
}
@@ -672,9 +672,8 @@ void SwFormulaField::SetExpandedFormula( const String& rStr )
if (pFormatter->IsNumberFormat(rStr, nFmt, fTmpValue))
{
SwValueField::SetValue(fTmpValue);
- sFormula.Erase();
- ((SwValueFieldType *)GetTyp())->DoubleToString(sFormula, fTmpValue, nFmt);
+ sFormula = ((SwValueFieldType *)GetTyp())->DoubleToString(fTmpValue, nFmt);
return;
}
}
@@ -694,10 +693,10 @@ String SwFormulaField::GetExpandedFormula() const
if (pFormatter->IsTextFormat(nFmt))
{
- String sValue;
- ((SwValueFieldType *)GetTyp())->DoubleToString(sValue, GetValue(), nFmt);
- OUString sTempIn(sValue);
- pFormatter->GetOutputString(sTempIn, nFmt, sFormattedValue, &pCol);
+ OUString sTempIn(((SwValueFieldType *)GetTyp())->DoubleToString(GetValue(), nFmt));
+ OUString sTempOut(sFormattedValue);
+ pFormatter->GetOutputString(sTempIn, nFmt, sTempOut, &pCol);
+ sFormattedValue = sTempOut;
}
else
{
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index 312948a6f474..21aab3236008 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -264,8 +264,7 @@ void SwUserFieldType::SetContent( const String& rStr, sal_uInt32 nFmt )
if (pFormatter->IsNumberFormat(rStr, nFmt, fValue))
{
SetValue(fValue);
- aContent.Erase();
- DoubleToString(aContent, fValue, nFmt);
+ aContent = DoubleToString(fValue, nFmt);
}
}
@@ -313,7 +312,7 @@ bool SwUserFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
// The following line is in fact wrong, since the language is unknown (is part of the
// field) and, thus, aContent should also belong to the field. Each field can have a
// differnt language, but the same content with just different formatting.
- DoubleToString(aContent, nValue, (sal_uInt16)LANGUAGE_SYSTEM);
+ aContent = DoubleToString(nValue, static_cast<sal_uInt32>(LANGUAGE_SYSTEM));
}
break;
case FIELD_PROP_PAR2: