summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2019-08-20 19:42:39 +0200
committerXisco FaulĂ­ <xiscofauli@libreoffice.org>2019-08-21 11:50:37 +0200
commita96b0e2f7d4e3d4b981fbe1b7902bc42af967f0e (patch)
treea916e4dc0d93a81d5097de9821aeb44baa8f7e51
parent3dd86101182543dcbad4df0c2e746ede26f1cbbb (diff)
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>
-rw-r--r--include/svl/zforlist.hxx3
-rw-r--r--svl/source/numbers/zforlist.cxx16
-rw-r--r--svl/source/numbers/zformat.cxx18
3 files changed, 34 insertions, 3 deletions
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
{