[Libreoffice-commits] core.git: sw/inc sw/source

Matteo Casalin matteo.casalin at yahoo.com
Mon Jul 15 12:16:24 PDT 2013


 sw/inc/fldbas.hxx                |    4 ++--
 sw/source/core/fields/fldbas.cxx |   27 +++++++++++++--------------
 sw/source/core/fields/usrfld.cxx |    5 ++---
 3 files changed, 17 insertions(+), 19 deletions(-)

New commits:
commit 67db35da5d7a3b117a0e0035c17c2fb58e5f23e6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sun Jun 23 23:50:53 2013 +0200

    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 at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 53ab826..057f917 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 524e185..9db180b 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 312948a..21aab32 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:


More information about the Libreoffice-commits mailing list