cui/source/tabpages/numfmt.cxx |    2 +-
 svx/source/items/numfmtsh.cxx  |   12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

New commits:
commit e607f1da329a2d4dd91904053d7ff86ac05c77bf
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed Oct 3 00:00:08 2018 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Oct 4 15:02:13 2018 +0200

    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 <er...@redhat.com>
    Tested-by: Jenkins

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 )
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to