From dcf0877cd04280e598943ecfe299cf7360971056 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 27 Oct 2017 15:35:37 +0200 Subject: Handle decimalSeparatorAlternative in SvNumberFormatter parsing, tdf#81671 Change-Id: Ic10aa36805ec4214f7ac54529fb391cf1e390a70 --- svl/source/numbers/zforfind.cxx | 15 +++++++++++++-- svl/source/numbers/zforlist.cxx | 13 +++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'svl/source') diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 83c37af79c2e..5f717108f263 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -794,6 +794,12 @@ inline bool ImpSvNumberInputScan::GetDecSep( const OUString& rString, sal_Int32& nPos = nPos + rSep.getLength(); return true; } + const OUString& rSepAlt = pFormatter->GetNumDecimalSepAlt(); + if ( !rSepAlt.isEmpty() && rString.match( rSepAlt, nPos) ) + { + nPos = nPos + rSepAlt.getLength(); + return true; + } } return false; } @@ -3121,7 +3127,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString, / if (eSetType == css::util::NumberFormat::FRACTION) // Fraction 1 = 1/1 { if (i >= nStringsCnt || // no end string nor decimal separator - sStrArray[i] == pFormatter->GetNumDecimalSep()) + pFormatter->IsDecimalSep( sStrArray[i])) { eScannedType = css::util::NumberFormat::FRACTION; nMatchedAllStrings &= ~nMatchedVirgin; @@ -3144,7 +3150,7 @@ bool ImpSvNumberInputScan::IsNumberFormatMain( const OUString& rString, / eScannedType == css::util::NumberFormat::UNDEFINED && // not date or currency nDecPos == 0 && // no previous decimal separator (i >= nStringsCnt || // no end string nor decimal separator - sStrArray[i] == pFormatter->GetNumDecimalSep()) + pFormatter->IsDecimalSep( sStrArray[i])) ) { eScannedType = css::util::NumberFormat::FRACTION; @@ -3490,6 +3496,11 @@ void ImpSvNumberInputScan::ChangeIntl() sal_Unicode cDecSep = pFormatter->GetNumDecimalSep()[0]; bDecSepInDateSeps = ( cDecSep == '-' || cDecSep == pFormatter->GetDateSep()[0] ); + if (!bDecSepInDateSeps) + { + sal_Unicode cDecSepAlt = pFormatter->GetNumDecimalSepAlt().toChar(); + bDecSepInDateSeps = cDecSepAlt && (cDecSepAlt == '-' || cDecSepAlt == pFormatter->GetDateSep()[0]); + } bTextInitialized = false; aUpperCurrSymbol.clear(); InvalidateDateAcceptancePatterns(); diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 94912797057c..f4c236827a01 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -307,6 +307,7 @@ void SvNumberFormatter::ImpConstruct( LanguageType eLang ) // cached locale data items const LocaleDataWrapper* pLoc = GetLocaleData(); aDecimalSep = pLoc->getNumDecimalSep(); + aDecimalSepAlt = pLoc->getNumDecimalSepAlt(); aThousandSep = pLoc->getNumThousandSep(); aDateSep = pLoc->getDateSep(); @@ -338,6 +339,7 @@ void SvNumberFormatter::ChangeIntl(LanguageType eLnge) // cached locale data items, initialize BEFORE calling ChangeIntl below const LocaleDataWrapper* pLoc = GetLocaleData(); aDecimalSep = pLoc->getNumDecimalSep(); + aDecimalSepAlt = pLoc->getNumDecimalSepAlt(); aThousandSep = pLoc->getNumThousandSep(); aDateSep = pLoc->getDateSep(); @@ -537,10 +539,21 @@ const NativeNumberWrapper* SvNumberFormatter::GetNatNum() const { return xNatNum const OUString& SvNumberFormatter::GetNumDecimalSep() const { return aDecimalSep; } +const OUString& SvNumberFormatter::GetNumDecimalSepAlt() const { return aDecimalSepAlt; } + const OUString& SvNumberFormatter::GetNumThousandSep() const { return aThousandSep; } const OUString& SvNumberFormatter::GetDateSep() const { return aDateSep; } +bool SvNumberFormatter::IsDecimalSep( const OUString& rStr ) const +{ + if (rStr == GetNumDecimalSep()) + return true; + if (GetNumDecimalSepAlt().isEmpty()) + return false; + return rStr == GetNumDecimalSepAlt(); +} + bool SvNumberFormatter::IsTextFormat(sal_uInt32 F_Index) const { const SvNumberformat* pFormat = GetFormatEntry(F_Index); -- cgit v1.2.3