summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-10-27 15:35:37 +0200
committerEike Rathke <erack@redhat.com>2017-10-27 18:29:44 +0200
commitdcf0877cd04280e598943ecfe299cf7360971056 (patch)
tree052d8677ce212385eedf9680e2df5603d6e70c53 /svl
parent5ab5243068ff0e023da35633922f140688c7fcbd (diff)
Handle decimalSeparatorAlternative in SvNumberFormatter parsing, tdf#81671
Change-Id: Ic10aa36805ec4214f7ac54529fb391cf1e390a70
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx15
-rw-r--r--svl/source/numbers/zforlist.cxx13
2 files changed, 26 insertions, 2 deletions
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);