cui/source/tabpages/numfmt.cxx | 2 +- include/svx/numfmtsh.hxx | 2 +- svx/source/items/numfmtsh.cxx | 31 +++++++++++++++++++++++-------- 3 files changed, 25 insertions(+), 10 deletions(-)
New commits: commit f69f0173b51ed502bf175ecbd3ef5fb1486a57fd Author: Eike Rathke <[email protected]> AuthorDate: Wed Jan 16 17:40:18 2019 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Thu Jan 17 14:01:38 2019 +0100 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 <[email protected]> Tested-by: Jenkins (cherry picked from commit c9d19b70c93b02e5c666414097e835039c598731) Reviewed-on: https://gerrit.libreoffice.org/66478 Reviewed-by: Laurent BP <[email protected]> Reviewed-by: Markus Mohrhard <[email protected]> Reviewed-by: Xisco FaulĂ <[email protected]> Tested-by: Xisco FaulĂ <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 344e381546b5..a150af80db56 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -1504,7 +1504,7 @@ void SvxNumberFormatTabPage::EditHdl_Impl(const weld::Entry* pEdFormat) if (nTmpCurPos != sal_uInt16(-1)) set_active_currency(nTmpCurPos); } - short nPosi=pNumFmtShell->GetListPos4Entry( nCurKey); + short nPosi=pNumFmtShell->GetListPos4Entry( nCurKey, aFormat); if(nPosi>=0) m_xLbFormat->select(static_cast<sal_uInt16>(nPosi)); diff --git a/include/svx/numfmtsh.hxx b/include/svx/numfmtsh.hxx index 8f1b0262f1cd..2b7d36e5c475 100644 --- a/include/svx/numfmtsh.hxx +++ b/include/svx/numfmtsh.hxx @@ -165,7 +165,7 @@ public: sal_uInt16 FindCurrencyFormat( const OUString& rFmtString ); sal_uInt16 FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,bool bTmpBanking); void SetCurCurrencyEntry(NfCurrencyEntry*); - short GetListPos4Entry(sal_uInt32 nIdx); + short GetListPos4Entry( sal_uInt32 nIdx, const OUString& rFmtString ); void GetCurrencySymbols(std::vector<OUString>& rList, sal_uInt16* pPos ); diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index 923a0db04f4b..2bf80b4cb33f 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -1329,24 +1329,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; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
