diff options
author | Eike Rathke <erack@redhat.com> | 2018-10-03 00:00:08 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-10-04 15:02:13 +0200 |
commit | e607f1da329a2d4dd91904053d7ff86ac05c77bf (patch) | |
tree | 6d06f033090ac61791355438f25e7f42b791e8f9 | |
parent | 689b6a6ceb88b2c074b77c1030bc2396a1816eea (diff) |
Select the current format if multiple instead of first matching format code
This never worked..
Change-Id: I79b8687dde4faac383121abeda70931d0192b33d
Reviewed-on: https://gerrit.libreoffice.org/61290
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
-rw-r--r-- | cui/source/tabpages/numfmt.cxx | 2 | ||||
-rw-r--r-- | svx/source/items/numfmtsh.cxx | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 4257799ae311..19d103c6fd71 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -1489,7 +1489,7 @@ void SvxNumberFormatTabPage::EditHdl_Impl(const weld::Entry* pEdFormat) if (nTmpCurPos != sal_uInt16(-1)) set_active_currency(nTmpCurPos); } - short nPosi=pNumFmtShell->GetListPos4Entry(aFormat); + short nPosi=pNumFmtShell->GetListPos4Entry( nCurKey); if(nPosi>=0) m_xLbFormat->select(static_cast<sal_uInt16>(nPosi)); diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index 8d8547fce33b..8a92fba7b816 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -486,7 +486,17 @@ bool SvxNumberFormatShell::IsUserDefined( const OUString& rFmtString ) bool SvxNumberFormatShell::FindEntry( const OUString& rFmtString, sal_uInt32* pAt /* = NULL */ ) { bool bRes=false; - sal_uInt32 nFound = pFormatter->TestNewString( rFmtString, eCurLanguage ); + + sal_uInt32 nFound = NUMBERFORMAT_ENTRY_NOT_FOUND; + // There may be multiple builtin entries with the same format code, first + // try if the current key matches. + const SvNumberformat* pEntry = pFormatter->GetEntry( nCurFormatKey); + if (pEntry && pEntry->GetLanguage() == eCurLanguage && pEntry->GetFormatstring() == rFmtString) + nFound = nCurFormatKey; + + if (nFound == NUMBERFORMAT_ENTRY_NOT_FOUND) + // Find the first matching format code. + nFound = pFormatter->TestNewString( rFmtString, eCurLanguage ); if ( nFound == NUMBERFORMAT_ENTRY_NOT_FOUND ) { |