summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 032809b8f82e..429d57f9f479 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 705e0624c785..d69f481b751e 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2052,20 +2052,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 daa9791dba3c..c90c8479657c 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -791,8 +791,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
}
@@ -853,6 +856,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 &&
@@ -864,6 +868,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
{