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@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 152c4fcbf1aa5b7454834581927056cfc9d1d7e5)
Reviewed-on: https://gerrit.libreoffice.org/77859
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index cf7b1de..0a12e88 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 82727dd..68e9ef1 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 eb96820..8214409 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
                    {