include/svl/zforlist.hxx         |    5 ++++-
 svx/source/tbxctrls/tbcontrl.cxx |   18 +++++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 3a76bba6bc2d638ce9e13179bcf03854b05b97e1
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Mon Oct 25 15:39:46 2021 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Tue Oct 26 00:08:20 2021 +0200

    Fix toolbar button's currency list's number format for default locale
    
    Always resulted in the currency's LCID being omitted in the number
    format for the default locale, which doesn't immediately harm but
    loses the context (what currency a $ sign is actually), and also
    lead to the "real" default currency format never matching the one
    being generated for the list so no entry was selected if that
    format was applied.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124152
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 97e63ff5375d9d80d6fe5d4bd68883e35bd56d91)
    
    Backported, deleted the deleted copy-ctor ...
    
    Change-Id: I7963e4d3701092d6e227705fc0e8282448f075b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124025
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index c3d82d7b109a..31559e80b209 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -312,7 +312,6 @@ class UNLESS_MERGELIBS(SVL_DLLPUBLIC) NfCurrencyEntry
     sal_uInt16      nDigits;            /// count of decimal digits
     sal_Unicode     cZeroChar;          /// which character is used for zeros 
as last decimal digits
 
-                        NfCurrencyEntry( const NfCurrencyEntry& ) = delete;
     NfCurrencyEntry&    operator=( const NfCurrencyEntry& ) = delete;
 
 private:
@@ -328,6 +327,7 @@ public:
     NfCurrencyEntry( const css::i18n::Currency & rCurr,
                      const LocaleDataWrapper& rLocaleData,
                      LanguageType eLang );
+    NfCurrencyEntry( const NfCurrencyEntry& ) = default;
 
                         /// Symbols and language identical
     bool                operator==( const NfCurrencyEntry& r ) const;
@@ -339,6 +339,9 @@ public:
     sal_uInt16          GetNegativeFormat() const   { return nNegativeFormat; }
     sal_uInt16          GetDigits() const           { return nDigits; }
 
+                        /** Only to resolve system locale for currency list. */
+    void                SetLanguage( LanguageType nLang ) { eLanguage = nLang; 
}
+
                         /** [$DM-407] (bBank==false) or [$DEM] (bBank==true)
                             is returned. If bBank==false and
                             bWithoutExtension==true only [$DM] */
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 1b94df39887d..076c2b6fe4aa 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -3566,11 +3566,23 @@ namespace
                     if (rItem.getLength() > sLongestString.getLength())
                         sLongestString = rItem;
 
-                    const NfCurrencyEntry& aCurrencyEntry = rCurrencyTable[ 
rCurrencyIndex ];
-
                     bIsSymbol = nPos >= nLen;
 
-                    sal_uInt16 nDefaultFormat = 
aFormatter.GetCurrencyFormatStrings( aStringsDtor, aCurrencyEntry, bIsSymbol );
+                    sal_uInt16 nDefaultFormat;
+                    const NfCurrencyEntry& rCurrencyEntry = rCurrencyTable[ 
rCurrencyIndex ];
+                    if (rCurrencyIndex == 0)
+                    {
+                        // Stored with system locale, but we want the resolved
+                        // full LCID format string. For example
+                        // "[$$-409]#,##0.00" instead of "[$$]#,##0.00".
+                        NfCurrencyEntry aCurrencyEntry( rCurrencyEntry);
+                        aCurrencyEntry.SetLanguage( LanguageTag( 
aCurrencyEntry.GetLanguage()).getLanguageType());
+                        nDefaultFormat = aFormatter.GetCurrencyFormatStrings( 
aStringsDtor, aCurrencyEntry, bIsSymbol);
+                    }
+                    else
+                    {
+                        nDefaultFormat = aFormatter.GetCurrencyFormatStrings( 
aStringsDtor, rCurrencyEntry, bIsSymbol);
+                    }
                     const OUString& rFormatStr = aStringsDtor[ nDefaultFormat 
];
                     m_aFormatEntries.push_back( rFormatStr );
                     if( rFormatStr == m_rSelectedFormat )

Reply via email to