[Libreoffice-commits] core.git: svl/source
Eike Rathke
erack at redhat.com
Mon Sep 26 16:36:54 UTC 2016
svl/source/numbers/zforlist.cxx | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
New commits:
commit 0f6a4ab13ec3dd4f9df0cb10e2de2c648cc4b0ac
Author: Eike Rathke <erack at redhat.com>
Date: Mon Sep 26 18:28:50 2016 +0200
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
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index e3805f3..b00fc30 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;
More information about the Libreoffice-commits
mailing list