summaryrefslogtreecommitdiff
path: root/svx/source/items/numfmtsh.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2019-01-16 17:40:18 +0100
committerEike Rathke <erack@redhat.com>2019-01-16 20:25:49 +0100
commitc9d19b70c93b02e5c666414097e835039c598731 (patch)
treea0acf9417a06ef14c4bc0df3734bb385c040a166 /svx/source/items/numfmtsh.cxx
parent7b7cc20d83f48a0d114f3e726c9d5710aabc1a4c (diff)
Resolves: tdf#122509 we have a second list with generated currency formats
... which kicks in if SvxNumberFormatShell::FindEntry() determined a format index of NUMBERFORMAT_ENTRY_NEW_CURRENCY instead of a real existing index. Regression from commit e607f1da329a2d4dd91904053d7ff86ac05c77bf CommitDate: Thu Oct 4 15:02:13 2018 +0200 Select the current format if multiple instead of first matching format code The old (now removed as unused) SvxNumberFormatShell::GetListPos4Entry(const OUString&) used before took care of that, add the functionality back but combine into the existing GetListPos4Entry() function, the additional FindEntry() call wasn't necessary anyway because it was just called before in the caller. The actual crash happened elsewhere in SvNumberFormatter::GenerateFormat() because no format exists for the then determined entry, which should be changed independently to prevent such abuses. Change-Id: Id42efa152693119fbde82b234f367679f818cfab Reviewed-on: https://gerrit.libreoffice.org/66472 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svx/source/items/numfmtsh.cxx')
-rw-r--r--svx/source/items/numfmtsh.cxx31
1 files changed, 23 insertions, 8 deletions
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 1fb809379a6c..feb595e11363 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -1327,24 +1327,39 @@ OUString SvxNumberFormatShell::GetFormat4Entry(short nEntry)
* Input: Number of the entry
* Output: Category number
*/
-short SvxNumberFormatShell::GetListPos4Entry(sal_uInt32 nIdx)
+short SvxNumberFormatShell::GetListPos4Entry( sal_uInt32 nIdx, const OUString& rFmtString )
{
short nSelP = SELPOS_NONE;
- // Check list size against return type limit.
- if (aCurEntryList.size() <= static_cast<size_t>(::std::numeric_limits<short>::max()))
+ if (nIdx != NUMBERFORMAT_ENTRY_NEW_CURRENCY)
{
- for (size_t i = 0; i < aCurEntryList.size(); ++i)
+ // Check list size against return type limit.
+ if (aCurEntryList.size() <= static_cast<size_t>(::std::numeric_limits<short>::max()))
{
- if (aCurEntryList[i] == nIdx)
+ for (size_t i = 0; i < aCurEntryList.size(); ++i)
{
- nSelP = i;
- break;
+ if (aCurEntryList[i] == nIdx)
+ {
+ nSelP = i;
+ break;
+ }
}
}
+ else
+ {
+ OSL_FAIL("svx::SvxNumberFormatShell::GetListPos4Entry(), list got too large!");
+ }
}
else
{
- OSL_FAIL("svx::SvxNumberFormatShell::GetListPos4Entry(), list got too large!");
+ // A second list holds the generated currency formats.
+ for (size_t i = 0; i < aCurrencyFormatList.size(); ++i)
+ {
+ if (rFmtString == aCurrencyFormatList[i])
+ {
+ nSelP = static_cast<short>(i);
+ break;
+ }
+ }
}
return nSelP;
}