[Libreoffice-commits] core.git: vcl/source

Mike Kaganski mike.kaganski at collabora.com
Mon Apr 2 08:45:57 UTC 2018


 vcl/source/control/field.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 3abd8b51cd855cf55dbc0f3cfeb8390a783372fc
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Mon Apr 2 08:48:09 2018 +0100

    Also use GetLanguageTag() for formatting percents
    
    Reading MetricFormatter value (in MetricFormatter::GetValueFromStringUnit)
    uses ImplGetLocaleDataWrapper() to convert the string using current locale
    (including decimal and thousands separator), which calls GetLanguageTag().
    On the other hand, in case of percent value, setting the control text (in
    MetricFormatter::CreateFieldText) uses Application::GetSettings().GetUILanguageTag().
    This gives wrong results e.g. when UI language is different from locale.
    
    For instance, if UI language is English (US), and locale is Russian, then
    increasing from "999 %" would give "1,000 %" (using English (US) locale),
    and then reading back, it would be processed as 1 % (using Russian locale,
    where comma is decimal separator).
    
    This change unifies setting percent text to also use GetLanguageTag().
    
    Change-Id: I9b8a2ee5d3be709a8db3807ea81e105d6475b6a4
    Reviewed-on: https://gerrit.libreoffice.org/52251
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 8d5fec70ec8a..a59557dcbb9b 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -1381,7 +1381,7 @@ OUString MetricFormatter::CreateFieldText( sal_Int64 nValue ) const
     {
         double dValue = nValue;
         dValue /= ImplPower10(GetDecimalDigits());
-        return unicode::formatPercent(dValue, Application::GetSettings().GetUILanguageTag());
+        return unicode::formatPercent(dValue, GetLanguageTag());
     }
 
     OUString aStr = NumericFormatter::CreateFieldText( nValue );


More information about the Libreoffice-commits mailing list