diff options
author | Eike Rathke <erack@redhat.com> | 2017-10-27 15:07:00 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-10-27 18:29:44 +0200 |
commit | 21052ba2edeef9e16bf90fea62f007b1131c73c0 (patch) | |
tree | a147891b7d5ac1c5ccc1cbb6f39f6ccb6c04a243 /i18npool | |
parent | 922a94f376d90c72315f86f2604924c142fca5be (diff) |
Allow decimalSeparatorAlternative in cclass_unicode::parseText(), tdf#81671
Change-Id: I0469027951e68d3c08f40c236db3865edbdaa3e0
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/inc/cclass_unicode.hxx | 1 | ||||
-rw-r--r-- | i18npool/source/characterclassification/cclass_unicode_parser.cxx | 18 |
2 files changed, 14 insertions, 5 deletions
diff --git a/i18npool/inc/cclass_unicode.hxx b/i18npool/inc/cclass_unicode.hxx index d276347fa78c..b3390de4b6f1 100644 --- a/i18npool/inc/cclass_unicode.hxx +++ b/i18npool/inc/cclass_unicode.hxx @@ -138,6 +138,7 @@ private: ScanState eState; sal_Unicode cGroupSep; sal_Unicode cDecimalSep; + sal_Unicode cDecimalSepAlt; /// Get corresponding KParseTokens flag for a character static sal_Int32 getParseTokensType(sal_uInt32 c, bool isFirst); diff --git a/i18npool/source/characterclassification/cclass_unicode_parser.cxx b/i18npool/source/characterclassification/cclass_unicode_parser.cxx index 6e7279c229dc..1979135b8eca 100644 --- a/i18npool/source/characterclassification/cclass_unicode_parser.cxx +++ b/i18npool/source/characterclassification/cclass_unicode_parser.cxx @@ -433,18 +433,21 @@ void cclass_Unicode::initParserTable( const Locale& rLocale, sal_Int32 startChar // specials if( mxLocaleData.is() ) { - LocaleDataItem aItem = - mxLocaleData->getLocaleItem( aParserLocale ); + LocaleDataItem2 aItem = + mxLocaleData->getLocaleItem2( aParserLocale ); //!TODO: theoretically separators may be a string, adjustment would have to be //! done here and in parsing and in ::rtl::math::stringToDouble() cGroupSep = aItem.thousandSeparator[0]; cDecimalSep = aItem.decimalSeparator[0]; + cDecimalSepAlt = aItem.decimalSeparatorAlternative.toChar(); } if ( cGroupSep < nDefCnt ) pTable[cGroupSep] |= ParserFlags::VALUE; if ( cDecimalSep < nDefCnt ) pTable[cDecimalSep] |= ParserFlags::CHAR_VALUE | ParserFlags::VALUE; + if ( cDecimalSepAlt && cDecimalSepAlt < nDefCnt ) + pTable[cDecimalSepAlt] |= ParserFlags::CHAR_VALUE | ParserFlags::VALUE; // Modify characters according to KParseTokens definitions. { @@ -593,6 +596,8 @@ ParserFlags cclass_Unicode::getFlagsExtended(sal_uInt32 const c) return ParserFlags::VALUE; else if ( c == cDecimalSep ) return ParserFlags::CHAR_VALUE | ParserFlags::VALUE; + else if ( cDecimalSepAlt && c == cDecimalSepAlt ) + return ParserFlags::CHAR_VALUE | ParserFlags::VALUE; bool bStart = (eState == ssGetChar || eState == ssGetWordFirstChar || eState == ssRewindFromValue || eState == ssIgnoreLeadingInRewind); sal_Int32 nTypes = (bStart ? nStartTypes : nContTypes); @@ -704,6 +709,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 bool bQuote = false; bool bMightBeWord = true; bool bMightBeWordLast = true; + bool bDecSepAltUsed = false; //! All the variables above (plus ParseResult) have to be resetted on ssRewindFromValue! sal_Int32 nextCharIndex(nPos); // == index of nextChar @@ -743,7 +749,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 else r.TokenType = KParseType::ASC_NUMBER; } - else if (current == cDecimalSep) + else if (current == cDecimalSep || (bDecSepAltUsed = (cDecimalSepAlt && current == cDecimalSep))) { if (nextChar) ++nDecSeps; @@ -812,7 +818,8 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 } if ( nMask & ParserFlags::VALUE ) { - if (current == cDecimalSep && ++nDecSeps > 1) + if ((current == cDecimalSep || (bDecSepAltUsed = (cDecimalSepAlt && current == cDecimalSepAlt))) && + ++nDecSeps > 1) { if (nCodePoints == 2) eState = ssRewindFromValue; @@ -954,6 +961,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 bQuote = false; bMightBeWord = true; bMightBeWordLast = true; + bDecSepAltUsed = false; } else { @@ -1001,7 +1009,7 @@ void cclass_Unicode::parseText( ParseResult& r, const OUString& rText, sal_Int32 if ( r.TokenType & KParseType::ASC_NUMBER ) { r.Value = rtl_math_uStringToDouble(rText.getStr() + nPos + r.LeadingWhiteSpace, - rText.getStr() + r.EndPos, cDecimalSep, cGroupSep, nullptr, nullptr); + rText.getStr() + r.EndPos, (bDecSepAltUsed ? cDecimalSepAlt : cDecimalSep), cGroupSep, nullptr, nullptr); if ( bMightBeWord ) r.TokenType |= KParseType::IDENTNAME; } |