[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/svl svl/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 21 09:51:37 UTC 2019


 include/svl/zforlist.hxx        |    3 +++
 svl/source/numbers/zforlist.cxx |   16 +++++++++++++---
 svl/source/numbers/zformat.cxx  |   18 ++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)

New commits:
commit a96b0e2f7d4e3d4b981fbe1b7902bc42af967f0e
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Tue Aug 20 19:42:39 2019 +0200
Commit:     Xisco FaulĂ­ <xiscofauli at libreoffice.org>
CommitDate: Wed Aug 21 11:50:37 2019 +0200

    Resolves: tdf#122110 convert condition decimal separator to target locale
    
    Otherwise re-scanning the format code in the target locale failed.
    
    Change-Id: Ia4face1b5630c197f68b1f521e62b163550301e6
    Reviewed-on: https://gerrit.libreoffice.org/77852
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 152c4fcbf1aa5b7454834581927056cfc9d1d7e5)
    Reviewed-on: https://gerrit.libreoffice.org/77859
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index cf7b1dec34a9..0a12e88ae3ac 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -718,6 +718,9 @@ public:
     /// Return the decimal separator matching the locale of the given format
     OUString GetFormatDecimalSep( sal_uInt32 nFormat ) const;
 
+    /// Return the decimal separator matching the given locale / LanguageType.
+    OUString GetLangDecimalSep( LanguageType nLang ) const;
+
     /// Return a NfCurrencyTable with pointers to <type>NfCurrencyEntry</type> entries
     static const NfCurrencyTable& GetTheCurrencyTable();
 
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 82727ddd3b1a..68e9ef12e1ba 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2041,20 +2041,30 @@ OUString SvNumberFormatter::GetFormatDecimalSep( sal_uInt32 nFormat ) const
 {
     ::osl::MutexGuard aGuard( GetInstanceMutex() );
     const SvNumberformat* pFormat = GetFormatEntry(nFormat);
-    if ( !pFormat || pFormat->GetLanguage() == ActLnge )
+    if (!pFormat)
+    {
+        return GetNumDecimalSep();
+    }
+    return GetLangDecimalSep( pFormat->GetLanguage());
+}
+
+OUString SvNumberFormatter::GetLangDecimalSep( LanguageType nLang ) const
+{
+    ::osl::MutexGuard aGuard( GetInstanceMutex() );
+    if (nLang == ActLnge)
     {
         return GetNumDecimalSep();
     }
     OUString aRet;
     LanguageType eSaveLang = xLocaleData.getCurrentLanguage();
-    if ( pFormat->GetLanguage() == eSaveLang )
+    if (nLang == eSaveLang)
     {
         aRet = xLocaleData->getNumDecimalSep();
     }
     else
     {
         LanguageTag aSaveLocale( xLocaleData->getLanguageTag() );
-        const_cast<SvNumberFormatter*>(this)->xLocaleData.changeLocale( LanguageTag( pFormat->GetLanguage()) );
+        const_cast<SvNumberFormatter*>(this)->xLocaleData.changeLocale( LanguageTag( nLang));
         aRet = xLocaleData->getNumDecimalSep();
         const_cast<SvNumberFormatter*>(this)->xLocaleData.changeLocale( aSaveLocale );
     }
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index eb96820c9892..8214409e9ae8 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -789,8 +789,11 @@ SvNumberformat::SvNumberformat(OUString& rString,
             sBuff.replace( cNNBSp, ' ');
     }
 
+    OUString aConvertFromDecSep;
+    OUString aConvertToDecSep;
     if (rScan.GetConvertMode())
     {
+        aConvertFromDecSep = GetFormatter().GetNumDecimalSep();
         maLocale.meLanguage = rScan.GetNewLnge();
         eLan = maLocale.meLanguage; // Make sure to return switch
     }
@@ -851,6 +854,7 @@ SvNumberformat::SvNumberformat(OUString& rString,
                     sal_Int32 nCntChars = ImpGetNumber(sBuff, nPos, sStr);
                     if (nCntChars > 0)
                     {
+                        sal_Int32 nDecPos;
                         SvNumFormatType F_Type = SvNumFormatType::UNDEFINED;
                         if (!pISc->IsNumberFormat(sStr, F_Type, fNumber, nullptr) ||
                             ( F_Type != SvNumFormatType::NUMBER &&
@@ -862,6 +866,20 @@ SvNumberformat::SvNumberformat(OUString& rString,
                             sBuff.insert(nPos, '0');
                             nPos++;
                         }
+                        else if (rScan.GetConvertMode() && ((nDecPos = sStr.indexOf( aConvertFromDecSep)) >= 0))
+                        {
+                            if (aConvertToDecSep.isEmpty())
+                                aConvertToDecSep = GetFormatter().GetLangDecimalSep( rScan.GetNewLnge());
+                            if (aConvertToDecSep != aConvertFromDecSep)
+                            {
+                                const OUString aStr( sStr.replaceAt( nDecPos,
+                                            aConvertFromDecSep.getLength(), aConvertToDecSep));
+                                nPos = nPos - nCntChars;
+                                sBuff.remove(nPos, nCntChars);
+                                sBuff.insert(nPos, aStr);
+                                nPos += aStr.getLength();
+                            }
+                        }
                     }
                     else
                     {


More information about the Libreoffice-commits mailing list