summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-09-26 18:28:50 +0200
committerEike Rathke <erack@redhat.com>2016-09-26 18:33:39 +0200
commit0f6a4ab13ec3dd4f9df0cb10e2de2c648cc4b0ac (patch)
treed2510deaeb9cb6a590c32f814dbfe8a2d54f8b55 /svl
parentfabb8f48dd89d71378daf293a974a412deccc961 (diff)
prevent adding duplicates in calls to GetCurrencyFormatStrings()
Identical currency format codes popped up with fabb8f48dd89d71378daf293a974a412deccc961 that adds several currency symbols for the same ISO currency code, which of course also duplicates the format codes that use the ISO code. Do not offer them in UI which just looks confusing. Change-Id: I0bf039c400aa2e3bad946848ed4e57c8cfcb0fc3
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforlist.cxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index e3805f391135..b00fc30098ea 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -3916,6 +3916,15 @@ void SvNumberFormatter::ImpInitCurrencyTable()
}
+static void addToCurrencyFormatsList( NfWSStringsDtor& rStrArr, const OUString& rFormat )
+{
+ // Prevent duplicates even over subsequent calls of
+ // GetCurrencyFormatStrings() with the same vector.
+ if (std::find( rStrArr.begin(), rStrArr.end(), rFormat) == rStrArr.end())
+ rStrArr.push_back( rFormat);
+}
+
+
sal_uInt16 SvNumberFormatter::GetCurrencyFormatStrings( NfWSStringsDtor& rStrArr,
const NfCurrencyEntry& rCurr,
bool bBank ) const
@@ -3934,13 +3943,13 @@ sal_uInt16 SvNumberFormatter::GetCurrencyFormatStrings( NfWSStringsDtor& rStrArr
OUString format1 = aPositiveBank
+ ";"
+ aNegativeBank;
- rStrArr.push_back(format1);
+ addToCurrencyFormatsList( rStrArr, format1);
OUString format2 = aPositiveBank
+ ";"
+ aRed
+ aNegativeBank;
- rStrArr.push_back(format2);
+ addToCurrencyFormatsList( rStrArr, format2);
nDefault = rStrArr.size() - 1;
}
@@ -3988,18 +3997,18 @@ sal_uInt16 SvNumberFormatter::GetCurrencyFormatStrings( NfWSStringsDtor& rStrArr
if (rCurr.GetDigits())
{
- rStrArr.push_back(format1);
+ addToCurrencyFormatsList( rStrArr, format1);
}
- rStrArr.push_back(format2);
+ addToCurrencyFormatsList( rStrArr, format2);
if (rCurr.GetDigits())
{
- rStrArr.push_back(format3);
+ addToCurrencyFormatsList( rStrArr, format3);
}
- rStrArr.push_back(format4);
+ addToCurrencyFormatsList( rStrArr, format4);
nDefault = rStrArr.size() - 1;
if (rCurr.GetDigits())
{
- rStrArr.push_back(format5);
+ addToCurrencyFormatsList( rStrArr, format5);
}
}
return nDefault;