include/sfx2/IDocumentModelAccessor.hxx         |   47 +++++
 include/sfx2/objsh.hxx                          |    8 
 include/svx/tbcontrl.hxx                        |   74 --------
 sc/Library_sc.mk                                |    1 
 sc/qa/unit/ucalc.cxx                            |   72 ++++++++
 sc/source/core/data/docpool.cxx                 |    2 
 sc/source/ui/docshell/DocumentModelAccessor.cxx |   50 +++++
 sc/source/ui/docshell/docsh.cxx                 |    8 
 sc/source/ui/inc/DocumentModelAccessor.hxx      |   34 +++
 sc/source/ui/inc/docsh.hxx                      |    1 
 sfx2/source/doc/objcont.cxx                     |    6 
 svx/source/items/numfmtsh.cxx                   |    5 
 svx/source/tbxctrls/tbcontrl.cxx                |  211 +++++++++---------------
 13 files changed, 313 insertions(+), 206 deletions(-)

New commits:
commit e06d6dbc88845b70bf2e6ac04e895813a66053c9
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Jan 31 00:13:02 2024 +0900
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Feb 28 17:10:15 2024 +0100

    Currency pop-up: move getDocumentCurrencies to cxx, extend test
    
    Test now checks that multiple cells with the same currency still
    result in only one entry returned by getDocumentCurrencies.
    
    Change-Id: I34b0fd3b117ce01b3fd462f684d0927dd53f796d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162788
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164089
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
index d843a1b41ed8..9980ce09992e 100644
--- a/include/sfx2/IDocumentModelAccessor.hxx
+++ b/include/sfx2/IDocumentModelAccessor.hxx
@@ -11,9 +11,13 @@
 #pragma once
 
 #include <sfx2/dllapi.h>
+#include <i18nlangtag/lang.h>
+#include <rtl/ustring.hxx>
+#include <vector>
 
 namespace sfx
 {
+/** Currency ID, to identify the currency in the currency list */
 struct SFX2_DLLPUBLIC CurrencyID
 {
     OUString aSymbol;
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index d355dc0782dc..15a88dedc176 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -444,6 +444,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/ui/docshell/docsh6 \
     sc/source/ui/docshell/docsh8 \
     sc/source/ui/docshell/documentlinkmgr \
+    sc/source/ui/docshell/DocumentModelAccessor \
     sc/source/ui/docshell/editable \
     sc/source/ui/docshell/externalrefmgr \
     sc/source/ui/docshell/impex \
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 5ef08d8a54d6..e16d92ee6dbd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6850,7 +6850,7 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocumentModelAccessor_getDocumentCurrencies)
 {
     m_pDoc->InsertTab(0, "Sheet1");
 
-    // Check Document Currencies
+    // Check document currencies - expect 0
     auto pAccessor = m_xDocShell->GetDocumentModelAccessor();
     CPPUNIT_ASSERT(pAccessor);
     CPPUNIT_ASSERT_EQUAL(size_t(0), pAccessor->getDocumentCurrencies().size());
@@ -6876,13 +6876,45 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocumentModelAccessor_getDocumentCurrencies)
         CPPUNIT_ASSERT_EQUAL(u"2,00€"_ustr, m_pDoc->GetString(ScAddress(0, 0, 
0)));
     }
 
-    // Check Document Currencies Again
+    // Check document currencies again
     auto aCurrencyIDs = pAccessor->getDocumentCurrencies();
     CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
 
     CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
     CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
     CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol);
+
+    // Set the same currency to 2 more cells
+    {
+        m_pDoc->SetValue(ScAddress(1, 1, 0), 5.0);
+        m_pDoc->SetValue(ScAddress(2, 2, 0), 7.0);
+
+        OUString aCode = u"#.##0,00[$€-424]"_ustr;
+
+        sal_Int32 nCheckPos;
+        SvNumFormatType eType;
+        sal_uInt32 nFormat;
+
+        m_pDoc->GetFormatTable()->PutEntry(aCode, nCheckPos, eType, nFormat, 
LANGUAGE_SLOVENIAN);
+        CPPUNIT_ASSERT_EQUAL(SvNumFormatType::CURRENCY, eType);
+
+        ScPatternAttr aNewAttrs(m_pDoc->GetPool());
+        SfxItemSet& rSet = aNewAttrs.GetItemSet();
+        rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+        m_pDoc->ApplyPattern(1, 1, 0, aNewAttrs); // B2.
+        m_pDoc->ApplyPattern(2, 2, 0, aNewAttrs); // C3.
+
+        CPPUNIT_ASSERT_EQUAL(u"5,00€"_ustr, m_pDoc->GetString(ScAddress(1, 1, 
0)));
+        CPPUNIT_ASSERT_EQUAL(u"7,00€"_ustr, m_pDoc->GetString(ScAddress(2, 2, 
0)));
+    }
+
+    // Check document currencies again - should be 1 entry only
+    aCurrencyIDs = pAccessor->getDocumentCurrencies();
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
+
+    CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
+    CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
+    CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol);
 }
 
 
diff --git a/sc/source/ui/docshell/DocumentModelAccessor.cxx 
b/sc/source/ui/docshell/DocumentModelAccessor.cxx
new file mode 100644
index 000000000000..d8aab640fa20
--- /dev/null
+++ b/sc/source/ui/docshell/DocumentModelAccessor.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <DocumentModelAccessor.hxx>
+
+#include <document.hxx>
+#include <docpool.hxx>
+#include <scitems.hxx>
+#include <svl/intitem.hxx>
+#include <svl/zformat.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/numformat.hxx>
+#include <svl/itempool.hxx>
+
+namespace sc
+{
+std::vector<sfx::CurrencyID> DocumentModelAccessor::getDocumentCurrencies() 
const
+{
+    std::vector<sfx::CurrencyID> aCurrencyIDs;
+
+    for (const SfxPoolItem* pItem : 
m_pDocument->GetPool()->GetItemSurrogates(ATTR_VALUE_FORMAT))
+    {
+        auto* pIntItem = static_cast<const SfxUInt32Item*>(pItem);
+        sal_Int32 nFormat = pIntItem->GetValue();
+        SvNumberFormatter* pFormatter = m_pDocument->GetFormatTable();
+        if (pFormatter)
+        {
+            SvNumberformat const* pEntry = pFormatter->GetEntry(nFormat);
+            if (pEntry && pEntry->GetMaskedType() == SvNumFormatType::CURRENCY
+                && pEntry->HasNewCurrency() && pEntry->GetLanguage() != 
LANGUAGE_SYSTEM)
+            {
+                OUString aSymbol;
+                OUString aExtension;
+                pEntry->GetNewCurrencySymbol(aSymbol, aExtension);
+                aCurrencyIDs.push_back({ aSymbol, aExtension, 
pEntry->GetLanguage() });
+            }
+        }
+    }
+    return aCurrencyIDs;
+}
+
+} // end sc
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/DocumentModelAccessor.hxx 
b/sc/source/ui/inc/DocumentModelAccessor.hxx
index 562bbe1591c1..d0eec4bba174 100644
--- a/sc/source/ui/inc/DocumentModelAccessor.hxx
+++ b/sc/source/ui/inc/DocumentModelAccessor.hxx
@@ -11,10 +11,6 @@
 
 #include <sfx2/IDocumentModelAccessor.hxx>
 #include <document.hxx>
-#include <docpool.hxx>
-#include <svl/intitem.hxx>
-#include <svl/zformat.hxx>
-#include <svl/zforlist.hxx>
 
 namespace sc
 {
@@ -30,31 +26,7 @@ public:
     {
     }
 
-    std::vector<sfx::CurrencyID> getDocumentCurrencies() const override
-    {
-        std::vector<sfx::CurrencyID> aCurrencyIDs;
-        for (const SfxPoolItem* pItem :
-             m_pDocument->GetPool()->GetItemSurrogates(ATTR_VALUE_FORMAT))
-        {
-            auto* pIntItem = static_cast<const SfxUInt32Item*>(pItem);
-            sal_Int32 nFormat = pIntItem->GetValue();
-            SvNumberFormatter* pFormatter = m_pDocument->GetFormatTable();
-            if (pFormatter)
-            {
-                SvNumberformat const* pEntry = pFormatter->GetEntry(nFormat);
-                if (pEntry && pEntry->GetMaskedType() == 
SvNumFormatType::CURRENCY
-                    && pEntry->HasNewCurrency() && pEntry->GetLanguage() != 
LANGUAGE_SYSTEM)
-                {
-                    OUString aSymbol;
-                    OUString aExtension;
-                    pEntry->GetNewCurrencySymbol(aSymbol, aExtension);
-                    aCurrencyIDs.push_back({ aSymbol, aExtension, 
pEntry->GetLanguage() });
-                }
-            }
-        }
-
-        return aCurrencyIDs;
-    }
+    std::vector<sfx::CurrencyID> getDocumentCurrencies() const override;
 };
 
 } // end sc
commit 18fba49ab75b6b7435b8090beac201e1c8c39ee8
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Sat Jan 27 00:33:56 2024 +0900
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Feb 28 17:10:08 2024 +0100

    sc: put used currencies on top of the currency pop-up list
    
    The list of currencies is fairly long and there is no easy way
    to search the list, so to make it easier to concurrently fint the
    desired currency, put the currencies that are used in the document
    on top of the list.
    
    This adds a DocumentModelAccessor class, which is used to access
    parts of the document model from other modules throught the
    SfxObjectShell.
    
    Change-Id: I81a180b674ae69b373b0422f363678e8bab37194
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162638
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit 79da840fac78f11c156801c43d8b79d6d4f32869)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162755
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    (cherry picked from commit 2cac2ee38445c19c9281f54c2b961bbc9149cc00)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164088
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
new file mode 100644
index 000000000000..d843a1b41ed8
--- /dev/null
+++ b/include/sfx2/IDocumentModelAccessor.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <sfx2/dllapi.h>
+
+namespace sfx
+{
+struct SFX2_DLLPUBLIC CurrencyID
+{
+    OUString aSymbol;
+    OUString aExtension;
+    LanguageType eLanguage;
+};
+
+/** Document model accessor, used to access parts of the document model.
+ *
+ * This is useful when some common parts of the model are needed, but can
+ * only access the model indirecly from other modules that can access
+ * SfxObjectShell, but don't have a direct access to the document model
+ * (and access through UNO would be inconvenient).
+ *
+ * For example - get information about various parts of the document in
+ * generic dialogs (in CUI).
+ */
+class SFX2_DLLPUBLIC IDocumentModelAccessor
+{
+public:
+    virtual std::vector<CurrencyID> getDocumentCurrencies() const { return {}; 
}
+    virtual ~IDocumentModelAccessor() = default;
+};
+
+} // end sfx namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 20e497b6e4af..3175cb283642 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -89,8 +89,11 @@ namespace sfx2
 {
     class SvLinkSource;
     class StyleManager;
+    class IXmlIdRegistry;
 }
 
+namespace sfx { class IDocumentModelAccessor; }
+
 namespace com::sun::star::awt { class XWindow; }
 namespace com::sun::star::beans { struct PropertyValue; }
 namespace com::sun::star::document { struct CmisVersion; }
@@ -107,8 +110,6 @@ namespace com::sun::star::task { class XInteractionHandler; 
}
 namespace com::sun::star::lang { class XComponent; }
 namespace com::sun::star::text { class XTextRange; }
 
-namespace sfx2 { class IXmlIdRegistry; }
-
 #define SFX_TITLE_TITLE    0
 #define SFX_TITLE_FILENAME 1
 #define SFX_TITLE_FULLNAME 2
@@ -574,7 +575,8 @@ public:
     std::optional<NamedColor> GetRecentColor(sal_uInt16 nSlotId);
     void SetRecentColor(sal_uInt16 nSlotId, const NamedColor& rColor);
 
-    virtual std::set<Color>     GetDocColors();
+    virtual std::shared_ptr<sfx::IDocumentModelAccessor> 
GetDocumentModelAccessor() const;
+    virtual std::set<Color> GetDocColors();
     virtual std::shared_ptr<model::ColorSet> GetThemeColors();
 
     // Accessibility Check
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 9fffced835cb..f930d46b208d 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -146,10 +146,8 @@ class SfxStyleSheetBasePool;
 class SfxTemplateItem;
 class PaletteManager;
 
-namespace svx
-{
-    class ToolboxButtonColorUpdaterBase;
-}
+namespace svx { class ToolboxButtonColorUpdaterBase; }
+namespace sfx { struct CurrencyID; }
 
 class SvxStyleToolBoxControl final : public 
cppu::ImplInheritanceHelper<svt::ToolboxController,
                                                                                
           css::lang::XServiceInfo>
@@ -264,7 +262,8 @@ public:
     * @see SvxNumberFormatShell::GetCurrencySymbols
     **/
     static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag,
-                                    std::vector<sal_uInt16>& rCurrencyList );
+                                    std::vector<sal_uInt16>& rCurrencyList,
+                                    std::vector<sfx::CurrencyID> const& 
rCurrencyIDs);
 
     explicit SvxCurrencyToolBoxControl( const 
css::uno::Reference<css::uno::XComponentContext>& rContext );
     virtual ~SvxCurrencyToolBoxControl() override;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c75742eabdfc..5ef08d8a54d6 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -63,6 +63,7 @@
 #include <svl/srchitem.hxx>
 #include <svl/sharedstringpool.hxx>
 #include <unotools/collatorwrapper.hxx>
+#include <sfx2/IDocumentModelAccessor.hxx>
 
 #include <sfx2/sfxsids.hrc>
 
@@ -6845,6 +6846,45 @@ CPPUNIT_TEST_FIXTURE(Test, 
testInsertColumnsWithFormulaCells)
     m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testDocumentModelAccessor_getDocumentCurrencies)
+{
+    m_pDoc->InsertTab(0, "Sheet1");
+
+    // Check Document Currencies
+    auto pAccessor = m_xDocShell->GetDocumentModelAccessor();
+    CPPUNIT_ASSERT(pAccessor);
+    CPPUNIT_ASSERT_EQUAL(size_t(0), pAccessor->getDocumentCurrencies().size());
+
+    // Set a currency to a cell
+    {
+        m_pDoc->SetValue(ScAddress(0, 0, 0), 2.0);
+
+        OUString aCode = u"#.##0,00[$€-424]"_ustr;
+
+        sal_Int32 nCheckPos;
+        SvNumFormatType eType;
+        sal_uInt32 nFormat;
+
+        m_pDoc->GetFormatTable()->PutEntry(aCode, nCheckPos, eType, nFormat, 
LANGUAGE_SLOVENIAN);
+        CPPUNIT_ASSERT_EQUAL(SvNumFormatType::CURRENCY, eType);
+
+        ScPatternAttr aNewAttrs(m_pDoc->GetPool());
+        SfxItemSet& rSet = aNewAttrs.GetItemSet();
+        rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+        m_pDoc->ApplyPattern(0, 0, 0, aNewAttrs); // A1.
+
+        CPPUNIT_ASSERT_EQUAL(u"2,00€"_ustr, m_pDoc->GetString(ScAddress(0, 0, 
0)));
+    }
+
+    // Check Document Currencies Again
+    auto aCurrencyIDs = pAccessor->getDocumentCurrencies();
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
+
+    CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
+    CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
+    CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol);
+}
+
 
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index 05dd88958288..14ab909feda6 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -135,7 +135,7 @@ SfxItemInfo const  aItemInfos[] =
     { SID_ATTR_ALIGN_MARGIN,                false, true },    // ATTR_MARGIN
     { 0,                                    false, true },    // ATTR_MERGE
     { 0,                                    false, true },    // 
ATTR_MERGE_FLAG
-    { SID_ATTR_NUMBERFORMAT_VALUE,          false, true },    // 
ATTR_VALUE_FORMAT
+    { SID_ATTR_NUMBERFORMAT_VALUE,          true,  true },    // 
ATTR_VALUE_FORMAT
     { 0,                                    false, true },    // 
ATTR_LANGUAGE_FORMAT from 329, is combined with SID_ATTR_NUMBERFORMAT_VALUE in 
the dialog
     { SID_ATTR_BRUSH,                       true,  true },    // 
ATTR_BACKGROUND
     { SID_SCATTR_PROTECTION,                false, true },    // 
ATTR_PROTECTION
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 77cf975166de..71f72090d2a4 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -142,6 +142,7 @@
 #include <datastream.hxx>
 #include <documentlinkmgr.hxx>
 #include <refupdatecontext.hxx>
+#include <DocumentModelAccessor.hxx>
 
 #include <memory>
 #include <vector>
@@ -219,6 +220,13 @@ std::set<Color> ScDocShell::GetDocColors()
     return m_pDocument->GetDocColors();
 }
 
+std::shared_ptr<sfx::IDocumentModelAccessor> 
ScDocShell::GetDocumentModelAccessor() const
+{
+    std::shared_ptr<sfx::IDocumentModelAccessor> pReturn;
+    pReturn.reset(new sc::DocumentModelAccessor(m_pDocument));
+    return pReturn;
+}
+
 std::shared_ptr<model::ColorSet> ScDocShell::GetThemeColors()
 {
     ScTabViewShell* pShell = GetBestViewShell();
diff --git a/sc/source/ui/inc/DocumentModelAccessor.hxx 
b/sc/source/ui/inc/DocumentModelAccessor.hxx
new file mode 100644
index 000000000000..562bbe1591c1
--- /dev/null
+++ b/sc/source/ui/inc/DocumentModelAccessor.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sfx2/IDocumentModelAccessor.hxx>
+#include <document.hxx>
+#include <docpool.hxx>
+#include <svl/intitem.hxx>
+#include <svl/zformat.hxx>
+#include <svl/zforlist.hxx>
+
+namespace sc
+{
+/** DocumentModelAccessor implementation for Calc */
+class DocumentModelAccessor : public sfx::IDocumentModelAccessor
+{
+private:
+    std::shared_ptr<ScDocument> m_pDocument;
+
+public:
+    DocumentModelAccessor(std::shared_ptr<ScDocument> const& pDocument)
+        : m_pDocument(pDocument)
+    {
+    }
+
+    std::vector<sfx::CurrencyID> getDocumentCurrencies() const override
+    {
+        std::vector<sfx::CurrencyID> aCurrencyIDs;
+        for (const SfxPoolItem* pItem :
+             m_pDocument->GetPool()->GetItemSurrogates(ATTR_VALUE_FORMAT))
+        {
+            auto* pIntItem = static_cast<const SfxUInt32Item*>(pItem);
+            sal_Int32 nFormat = pIntItem->GetValue();
+            SvNumberFormatter* pFormatter = m_pDocument->GetFormatTable();
+            if (pFormatter)
+            {
+                SvNumberformat const* pEntry = pFormatter->GetEntry(nFormat);
+                if (pEntry && pEntry->GetMaskedType() == 
SvNumFormatType::CURRENCY
+                    && pEntry->HasNewCurrency() && pEntry->GetLanguage() != 
LANGUAGE_SYSTEM)
+                {
+                    OUString aSymbol;
+                    OUString aExtension;
+                    pEntry->GetNewCurrencySymbol(aSymbol, aExtension);
+                    aCurrencyIDs.push_back({ aSymbol, aExtension, 
pEntry->GetLanguage() });
+                }
+            }
+        }
+
+        return aCurrencyIDs;
+    }
+};
+
+} // end sc
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index f35d8a1c9798..a146ea0723e7 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -180,6 +180,7 @@ public:
                                sal_Int32 nFileFormat,
                                bool bTemplate = false ) const override;
 
+    std::shared_ptr<sfx::IDocumentModelAccessor> GetDocumentModelAccessor() 
const override;
     virtual std::set<Color> GetDocColors() override;
     virtual std::shared_ptr<model::ColorSet> GetThemeColors() override;
 
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 156e1aed3217..b762e9d11084 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -57,6 +57,7 @@
 #include <sfx2/strings.hrc>
 #include <sfx2/docfile.hxx>
 #include <sfx2/docfilt.hxx>
+#include <sfx2/IDocumentModelAccessor.hxx>
 #include <memory>
 #include <helpids.h>
 
@@ -338,6 +339,11 @@ std::set<Color> SfxObjectShell::GetDocColors()
 
 std::shared_ptr<model::ColorSet> SfxObjectShell::GetThemeColors() { return {}; 
}
 
+std::shared_ptr<sfx::IDocumentModelAccessor> 
SfxObjectShell::GetDocumentModelAccessor() const
+{
+    return {};
+}
+
 sfx::AccessibilityIssueCollection SfxObjectShell::runAccessibilityCheck()
 {
     sfx::AccessibilityIssueCollection aCollection;
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 8605817491ba..4f0825a88bca 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -30,6 +30,7 @@
 #include <svx/numfmtsh.hxx>
 #include <svx/flagsdef.hxx>
 #include <svx/tbcontrl.hxx>
+#include <sfx2/IDocumentModelAccessor.hxx>
 
 #include <limits>
 
@@ -1397,7 +1398,9 @@ void 
SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, sal_
 
     bool bFlag = (pTmpCurrencyEntry == nullptr);
 
-    SvxCurrencyToolBoxControl::GetCurrencySymbols(rList, bFlag, 
aCurCurrencyList);
+    std::vector<sfx::CurrencyID> aDocumentCurrencyIDs;
+    SvxCurrencyToolBoxControl::GetCurrencySymbols(rList, bFlag, 
aCurCurrencyList,
+                                                  aDocumentCurrencyIDs);
 
     if (pPos == nullptr)
         return;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 192bf6c6fdd5..d3f89aad706c 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -92,16 +92,19 @@
 #include <svx/xfillit0.hxx>
 #include <svx/xflclit.hxx>
 #include <svl/currencytable.hxx>
+#include <svl/zformat.hxx>
 #include <svtools/langtab.hxx>
 #include <cppu/unotype.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <officecfg/Office/Common.hxx>
+#include <o3tl/temporary.hxx>
 #include <o3tl/safeint.hxx>
 #include <o3tl/string_view.hxx>
 #include <o3tl/typed_flags_set.hxx>
 #include <bitmaps.hlst>
 #include <sal/log.hxx>
 #include <unotools/collatorwrapper.hxx>
+#include <sfx2/IDocumentModelAccessor.hxx>
 
 #include <comphelper/lok.hxx>
 #include <tools/json_writer.hxx>
@@ -3919,7 +3922,13 @@ namespace
             SvNumberFormatter aFormatter( m_xControl->getContext(), 
LANGUAGE_SYSTEM );
             m_eFormatLanguage = aFormatter.GetLanguage();
 
-            SvxCurrencyToolBoxControl::GetCurrencySymbols( aList, true, 
aCurrencyList );
+            std::vector<sfx::CurrencyID> aCurrencyIDs;
+
+            SfxObjectShell* pDocShell = SfxObjectShell::Current();
+            if (auto pModelAccessor = pDocShell->GetDocumentModelAccessor())
+                aCurrencyIDs = pModelAccessor->getDocumentCurrencies();
+
+            SvxCurrencyToolBoxControl::GetCurrencySymbols(aList, true, 
aCurrencyList, aCurrencyIDs);
 
             sal_uInt16 nPos = 0, nCount = 0;
             sal_Int32 nSelectedPos = -1;
@@ -4109,8 +4118,9 @@ Reference< css::accessibility::XAccessible > 
SvxFontNameBox_Impl::CreateAccessib
 }
 
 //static
-void SvxCurrencyToolBoxControl::GetCurrencySymbols( std::vector<OUString>& 
rList, bool bFlag,
-                                                    std::vector<sal_uInt16>& 
rCurrencyList )
+void SvxCurrencyToolBoxControl::GetCurrencySymbols(std::vector<OUString>& 
rList, bool bFlag,
+                                                   std::vector<sal_uInt16>& 
rCurrencyList,
+                                                   
std::vector<sfx::CurrencyID> const& rDocumentCurrencyIDs)
 {
     rCurrencyList.clear();
 
@@ -4120,8 +4130,7 @@ void SvxCurrencyToolBoxControl::GetCurrencySymbols( 
std::vector<OUString>& rList
     sal_uInt16 nStart = 1;
 
     OUString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol() ) 
+ " " );
-    aString += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString(
-                                       rCurrencyTable[0].GetLanguage() ) );
+    aString += 
ApplyLreOrRleEmbedding(SvtLanguageTable::GetLanguageString(rCurrencyTable[0].GetLanguage()));
 
     rList.push_back( aString );
     rCurrencyList.push_back( sal_uInt16(-1) ); // nAuto
@@ -4140,17 +4149,40 @@ void SvxCurrencyToolBoxControl::GetCurrencySymbols( 
std::vector<OUString>& rList
 
     for( sal_uInt16 i = 1; i < nCount; ++i )
     {
-        OUString aStr( ApplyLreOrRleEmbedding( 
rCurrencyTable[i].GetBankSymbol() ) );
+        auto& rCurrencyEntry = rCurrencyTable[i];
+
+        OUString aStr( ApplyLreOrRleEmbedding(rCurrencyEntry.GetBankSymbol()));
         aStr += aTwoSpace;
-        aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol() );
+        aStr += ApplyLreOrRleEmbedding(rCurrencyEntry.GetSymbol());
         aStr += aTwoSpace;
-        aStr += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString(
-                                        rCurrencyTable[i].GetLanguage() ) );
+        aStr += 
ApplyLreOrRleEmbedding(SvtLanguageTable::GetLanguageString(rCurrencyEntry.GetLanguage()));
 
         std::vector<OUString>::size_type j = nStart;
-        for( ; j < rList.size(); ++j )
-            if ( aCollator.compareString( aStr, rList[j] ) < 0 )
-                break;  // insert before first greater than
+
+        // Search if the currency is present in the document
+        auto iter = std::find_if(rDocumentCurrencyIDs.begin(), 
rDocumentCurrencyIDs.end(), [rCurrencyEntry](sfx::CurrencyID const& rCurrency)
+        {
+            const NfCurrencyEntry* pEntry = 
SvNumberFormatter::GetCurrencyEntry(o3tl::temporary(bool()), rCurrency.aSymbol, 
rCurrency.aExtension, rCurrency.eLanguage);
+
+            if (pEntry)
+                return rCurrencyEntry.GetLanguage() == pEntry->GetLanguage() 
&& rCurrencyEntry.GetSymbol() == pEntry->GetSymbol();
+
+            return false;
+        });
+
+        // If currency is in document, insert it on top
+        if (iter != rDocumentCurrencyIDs.end())
+        {
+            nStart++;
+        }
+        else
+        {
+            for( ; j < rList.size(); ++j )
+            {
+                if ( aCollator.compareString( aStr, rList[j] ) < 0 )
+                    break;  // insert before first greater than
+            }
+        }
 
         rList.insert( rList.begin() + j, aStr );
         rCurrencyList.insert( rCurrencyList.begin() + j, i );
@@ -4164,7 +4196,8 @@ void SvxCurrencyToolBoxControl::GetCurrencySymbols( 
std::vector<OUString>& rList
     for ( sal_uInt16 i = 1; i < nCount; ++i )
     {
         bool bInsert = true;
-        OUString aStr( ApplyLreOrRleEmbedding( 
rCurrencyTable[i].GetBankSymbol() ) );
+        auto& rCurrencyEntry = rCurrencyTable[i];
+        OUString aStr( ApplyLreOrRleEmbedding(rCurrencyEntry.GetBankSymbol()));
 
         std::vector<OUString>::size_type j = nCont;
         for ( ; j < rList.size() && bInsert; ++j )
commit a5ff53bab7c2a78dc9a8dae53408ee5d0b677b99
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Jan 30 22:59:11 2024 +0900
Commit:     Caolán McNamara <[email protected]>
CommitDate: Wed Feb 28 17:10:01 2024 +0100

    Revert "store last five MRU currencies in the currency drop-down"
    
    This reverts commit dc6b93011cc5435f367666e43e354c6ab97bbc90.
    
    Change-Id: Ia56cb2e906303d6d59061df3e21954306bee2298
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162754
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164087
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 11d41ee4ddde..9fffced835cb 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -249,73 +249,11 @@ public:
 /** Popup controller for currency combo widget **/
 class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SvxCurrencyToolBoxControl final : 
public svt::PopupWindowController
 {
-public:
-    /**
-    * Struct containing currency data<p>
-    * an instance corresponds to a line in the combo
-    **/
-    struct SvxCurrencyData {
-        /** position of the currency in 
SvxCurrencyToolBoxControl::CurrencySymbols vector **/
-        sal_uInt16 m_currencyIdx;
-
-        /**
-        * False if the instance corresponds to a line of the combo that shows 
only the ISO code<p>
-        * True otherwise
-        **/
-        bool m_onlyIsoCode;
-        OUString m_label;
-
-        /** Constant for invalid currency **/
-        static const sal_uInt16 InvalidCurrency;
-
-        /**
-        * Constructor
-        *
-        * @param currencyIdx Position of the currency in 
SvxCurrencyToolBoxControl::CurrencySymbols vector
-        * @param onlyIsoCode False if the instance corresponds to a line of 
the combo that shows
-        * only the ISO code<p> True otherwise
-        **/
-        SvxCurrencyData(
-            sal_uInt16 currencyIdx = InvalidCurrency,
-            bool onlyIsoCode = false
-        );
-
-        /** Needed by std::find **/
-        bool operator == (const SvxCurrencyData& other) const;
-    };
-
-    /** vector of combo box currencies **/
-    typedef std::vector<SvxCurrencyData> SvxCurrencyVect_t;
-
 private:
     OUString     m_aFormatString;
     LanguageType m_eLanguage;
     sal_uInt32   m_nFormatKey;
 
-    /** Currencies in the combo **/
-    SvxCurrencyVect_t  m_currencies;
-
-
-    /** Most recently used currencies **/
-    SvxCurrencyVect_t  m_mru_currencies;
-
-    /** Adds a currency to the most recently used list **/
-    void addMruCurrency(sal_Int16 currencyPosition);
-
-    /**
-    * Inner static method that polialtes the currency list and the most 
recently used
-    * currency list.<p>
-    * The method is static for backward compatibility: it is used by the two
-    * homonymous public methods, one of which is static while the other is 
instance
-    *
-    * @param bFlag used by SvxNumberFormatShell::GetCurrencySymbols
-    * @param p_mru_currencies output: most recently used currencies
-    * @param pCurrencies output: most recently used currencies
-    * @see SvxNumberFormatShell::GetCurrencySymbols
-    **/
-    static void inner_GetCurrencySymbols( bool bFlag, SvxCurrencyVect_t 
&p_mru_currencies,
-                                    SvxCurrencyVect_t &pCurrencies);
-
 public:
     /**
     * Static method used by SvxNumberFormatShell::GetCurrencySymbols<p>
@@ -328,9 +266,6 @@ public:
     static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag,
                                     std::vector<sal_uInt16>& rCurrencyList );
 
-    /** Instance method used by SvxCurrencyList_Impl constructor **/
-    const SvxCurrencyVect_t& GetCurrencySymbols();
-
     explicit SvxCurrencyToolBoxControl( const 
css::uno::Reference<css::uno::XComponentContext>& rContext );
     virtual ~SvxCurrencyToolBoxControl() override;
 
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 9a3669aac56a..192bf6c6fdd5 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -112,10 +112,6 @@
 
 #define COMBO_WIDTH_IN_CHARS        18
 
-#define MAX_MRU_CURRENCIES          5
-
-#define INVALID_CURRENCY            sal_uInt16(-2)
-
 // namespaces
 using namespace ::editeng;
 using namespace ::com::sun::star;
@@ -3915,13 +3911,15 @@ namespace
             , m_rSelectedFormat(rSelectedFormat)
             , m_eSelectedLanguage(eSelectedLanguage)
         {
+            std::vector< OUString > aList;
+            std::vector< sal_uInt16 > aCurrencyList;
             const NfCurrencyTable& rCurrencyTable = 
SvNumberFormatter::GetTheCurrencyTable();
             sal_uInt16 nLen = rCurrencyTable.size();
 
             SvNumberFormatter aFormatter( m_xControl->getContext(), 
LANGUAGE_SYSTEM );
             m_eFormatLanguage = aFormatter.GetLanguage();
 
-            const SvxCurrencyToolBoxControl::SvxCurrencyVect_t &rCurrencies = 
pControl->GetCurrencySymbols( );
+            SvxCurrencyToolBoxControl::GetCurrencySymbols( aList, true, 
aCurrencyList );
 
             sal_uInt16 nPos = 0, nCount = 0;
             sal_Int32 nSelectedPos = -1;
@@ -3931,11 +3929,9 @@ namespace
             OUString sLongestString;
 
             m_xCurrencyLb->freeze();
-            for( const SvxCurrencyToolBoxControl::SvxCurrencyData& curr : 
rCurrencies )
+            for( const auto& rItem : aList )
             {
-                const OUString& rItem = curr.m_label;
-                sal_uInt16 rCurrencyIndex = rCurrencies[ nCount 
].m_currencyIdx;
-
+                sal_uInt16& rCurrencyIndex = aCurrencyList[ nCount ];
                 if ( rCurrencyIndex < nLen )
                 {
                     m_xCurrencyLb->append_text(rItem);
@@ -4012,8 +4008,6 @@ namespace
 
         m_xControl->execute(nSelected + 1);
 
-        m_xCurrencyLb->scroll_to_row(0);
-
         m_xControl->EndPopupMode();
 
         return true;
@@ -4037,26 +4031,6 @@ void SvxCurrencyToolBoxControl::initialize( const 
css::uno::Sequence< css::uno::
         pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWN | 
pToolBox->GetItemBits(nId));
 }
 
-const SvxCurrencyToolBoxControl::SvxCurrencyVect_t  
&SvxCurrencyToolBoxControl::GetCurrencySymbols( ) {
-    inner_GetCurrencySymbols( true, m_currencies, m_mru_currencies );
-    return m_currencies;
-}
-
-void SvxCurrencyToolBoxControl::addMruCurrency(sal_Int16 currencyPosition) {
-    if (currencyPosition == 1)
-        return;
-
-    const SvxCurrencyData& curr = m_currencies[currencyPosition];
-    auto currencyIter = std::find( m_mru_currencies.begin(), 
m_mru_currencies.end(), curr );
-
-    if ( currencyIter != m_mru_currencies.end() )
-        m_mru_currencies.erase( currencyIter );
-
-    m_mru_currencies.insert( m_mru_currencies.begin(), curr );
-    if (m_mru_currencies.size() > MAX_MRU_CURRENCIES)
-        m_mru_currencies.resize( MAX_MRU_CURRENCIES );
-}
-
 std::unique_ptr<WeldToolbarPopup> SvxCurrencyToolBoxControl::weldPopupWindow()
 {
     return std::make_unique<SvxCurrencyList_Impl>(this, m_pToolbar, 
m_aFormatString, m_eLanguage);
@@ -4089,12 +4063,11 @@ void SvxCurrencyToolBoxControl::execute( sal_Int16 
nSelectModifier )
                 nFormatKey = rxNumberFormats->queryKey( m_aFormatString, 
aLocale, false );
                 if ( nFormatKey == NUMBERFORMAT_ENTRY_NOT_FOUND )
                     nFormatKey = rxNumberFormats->addNew( m_aFormatString, 
aLocale );
-                addMruCurrency(nSelectModifier);
-            }
-            catch( const uno::Exception& )
-            {
-                nFormatKey = m_nFormatKey;
-            }
+                }
+                catch( const uno::Exception& )
+                {
+                    nFormatKey = m_nFormatKey;
+                }
         }
         else
             nFormatKey = m_nFormatKey;
@@ -4135,135 +4108,78 @@ Reference< css::accessibility::XAccessible > 
SvxFontNameBox_Impl::CreateAccessib
     return InterimItemWindow::CreateAccessible();
 }
 
-//static
-sal_uInt16 const SvxCurrencyToolBoxControl::SvxCurrencyData::InvalidCurrency = 
INVALID_CURRENCY;
-
-SvxCurrencyToolBoxControl::SvxCurrencyData::SvxCurrencyData(
-        sal_uInt16 currencyIdx,
-        bool onlyIsoCode
-) :
-    m_currencyIdx(currencyIdx),
-    m_onlyIsoCode(onlyIsoCode)
-{}
-
-bool SvxCurrencyToolBoxControl::SvxCurrencyData::operator == (const 
SvxCurrencyData& other) const
-{
-    return
-        (m_currencyIdx == other.m_currencyIdx) &&
-        (m_onlyIsoCode == other.m_onlyIsoCode);
-}
-
 //static
 void SvxCurrencyToolBoxControl::GetCurrencySymbols( std::vector<OUString>& 
rList, bool bFlag,
                                                     std::vector<sal_uInt16>& 
rCurrencyList )
 {
-    SvxCurrencyVect_t currencies, mru_currencies;
-
-    inner_GetCurrencySymbols(bFlag, currencies, mru_currencies);
-
-    rList.resize(currencies.size());
-    rCurrencyList.resize(currencies.size());
-
-    for (size_t j = 0; j < currencies.size(); j++) {
-        rList[j] = std::move(currencies[j].m_label);
-        rCurrencyList[j] = currencies[j].m_currencyIdx;
-    }
-}
+    rCurrencyList.clear();
 
-//static
-void SvxCurrencyToolBoxControl::inner_GetCurrencySymbols(
-        bool bFlag,
-        SvxCurrencyVect_t &pCurrencies,
-        SvxCurrencyVect_t &p_mru_currencies)
-{
     const NfCurrencyTable& rCurrencyTable = 
SvNumberFormatter::GetTheCurrencyTable();
     sal_uInt16 nCount = rCurrencyTable.size();
 
-    // reserving space for mru currencies on top of vector after -1 element
-    pCurrencies.resize( p_mru_currencies.size() + 1);
-    std::fill( pCurrencies.begin() + 1, pCurrencies.end(), SvxCurrencyData() );
-
-    // lambda for vector insertion: mru currencies are on top
-    auto addCurrency = [&pCurrencies, &p_mru_currencies]
-                (SvxCurrencyData& curr,    size_t position = SIZE_MAX)
-    {
-        auto mruIter = std::find(p_mru_currencies.begin(), 
p_mru_currencies.end(), curr);
-
-        if (mruIter == p_mru_currencies.end()) {
-            if (position == SIZE_MAX)
-                pCurrencies.push_back( std::move(curr) );
-            else
-                pCurrencies.insert( pCurrencies.begin() + position, 
std::move(curr) );
-        }
-        else {
-            size_t index = mruIter - p_mru_currencies.begin();
-            pCurrencies[index] = std::move(curr);
-        }
-    };
+    sal_uInt16 nStart = 1;
 
-    SvxCurrencyData aCurr( sal_uInt16(-1) );
-    aCurr.m_label = ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol() ) + 
" ";
-    aCurr.m_label  += ApplyLreOrRleEmbedding( 
SvtLanguageTable::GetLanguageString(
+    OUString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0].GetSymbol() ) 
+ " " );
+    aString += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString(
                                        rCurrencyTable[0].GetLanguage() ) );
 
-    pCurrencies[0] = aCurr;
-    if( bFlag ) {
-        aCurr.m_currencyIdx = 0;
-        addCurrency( aCurr );
-    }
+    rList.push_back( aString );
+    rCurrencyList.push_back( sal_uInt16(-1) ); // nAuto
 
-    sal_uInt16 nStart = pCurrencies.size();
+    if( bFlag )
+    {
+        rList.push_back( aString );
+        rCurrencyList.push_back( 0 );
+        ++nStart;
+    }
 
     CollatorWrapper aCollator( ::comphelper::getProcessComponentContext() );
     aCollator.loadDefaultCollator( 
Application::GetSettings().GetLanguageTag().getLocale(), 0 );
 
     static constexpr OUString aTwoSpace(u"  "_ustr);
 
-    // appending "long symbol" list
     for( sal_uInt16 i = 1; i < nCount; ++i )
     {
-        SvxCurrencyData curr( i );
-        curr.m_label = ApplyLreOrRleEmbedding( 
rCurrencyTable[i].GetBankSymbol() );
-        curr.m_label += aTwoSpace;
-        curr.m_label += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol() 
);
-        curr.m_label += aTwoSpace;
-        curr.m_label += ApplyLreOrRleEmbedding( 
SvtLanguageTable::GetLanguageString(
+        OUString aStr( ApplyLreOrRleEmbedding( 
rCurrencyTable[i].GetBankSymbol() ) );
+        aStr += aTwoSpace;
+        aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i].GetSymbol() );
+        aStr += aTwoSpace;
+        aStr += ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString(
                                         rCurrencyTable[i].GetLanguage() ) );
 
-        SvxCurrencyVect_t::size_type j = nStart;
-        for( ; j < pCurrencies.size(); ++j )
-            if ( aCollator.compareString( curr.m_label, pCurrencies[j].m_label 
) < 0 )
+        std::vector<OUString>::size_type j = nStart;
+        for( ; j < rList.size(); ++j )
+            if ( aCollator.compareString( aStr, rList[j] ) < 0 )
                 break;  // insert before first greater than
 
-        addCurrency( curr, j );
+        rList.insert( rList.begin() + j, aStr );
+        rCurrencyList.insert( rCurrencyList.begin() + j, i );
     }
 
     // Append ISO codes to symbol list.
     // XXX If this is to be changed, various other places would had to be
     // adapted that assume this order!
-    size_t nCont = pCurrencies.size();
+    std::vector<OUString>::size_type nCont = rList.size();
 
     for ( sal_uInt16 i = 1; i < nCount; ++i )
     {
         bool bInsert = true;
-        SvxCurrencyData curr( i, true );
-        curr.m_label = 
ApplyLreOrRleEmbedding(rCurrencyTable[i].GetBankSymbol());
+        OUString aStr( ApplyLreOrRleEmbedding( 
rCurrencyTable[i].GetBankSymbol() ) );
 
-        size_t j = nCont;
-        for ( ; j < pCurrencies.size() && bInsert; ++j )
+        std::vector<OUString>::size_type j = nCont;
+        for ( ; j < rList.size() && bInsert; ++j )
         {
-            if( pCurrencies[j].m_label == curr.m_label )
+            if( rList[j] == aStr )
                 bInsert = false;
-            else if ( aCollator.compareString( curr.m_label, 
pCurrencies[j].m_label ) < 0 )
+            else if ( aCollator.compareString( aStr, rList[j] ) < 0 )
                 break;  // insert before first greater than
         }
         if ( bInsert )
-            addCurrency( curr, j );
+        {
+            rList.insert( rList.begin() + j, aStr );
+            rCurrencyList.insert( rCurrencyList.begin() + j, i );
+        }
     }
-
-    for ( int j = p_mru_currencies.size() - 1; j > 0; j-- )
-        if ( pCurrencies[j].m_currencyIdx == SvxCurrencyData::InvalidCurrency )
-            pCurrencies.erase( pCurrencies.begin() + j );
 }
 
 ListBoxColorWrapper::ListBoxColorWrapper(ColorListBox* pControl)

Reply via email to