diff options
author | DrGigioSan <luigi.iucci@hotmail.it> | 2023-03-14 21:19:08 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-03-17 12:58:37 +0000 |
commit | dc6b93011cc5435f367666e43e354c6ab97bbc90 (patch) | |
tree | 6e60e3d72cc8561a31c88cb1da9516d57263a8ac /include/svx | |
parent | 5f0a3a20efd26f50efbe92643c95f09bd21dfc0f (diff) |
store last five most recently used currencies in the currency toolbar drop-down
Refactory
Cause
Currency must be added in the MRU list in SvxCurrencyToolBoxControl::execute
method.
Unfortunately in this point the only information available is the number format.
It is not possibile to infer currency from number format (e.g: both USD and
AUD use symbol $).
Encapsulating currency data
In order to solve the problem currency data is enacpsulated in a SvxCurrencyData
struct. Added a vector of SvxCurrencyData to SvxCurrencyToolBoxControl.
Static and non static call
Former static SvxCurrencyToolBoxControl::GetCurrencySymbols has been
preserved, as it is called by SvxNumberFormatShell.
A new GetCurrencySymbols is used by the control.
To avoid code duplication, both functions call a static private function
inner_GetCurrencySymbols.
MRU Currencies
MRU currencies are stored in another member vector m_mru_curencies:
During currencies vector population (inner_GetCurrencySymbols) a space is reserved
on top of vector for mru currencies.
A new method addMruCurrency updates m_currencies. This method is called in
SvxCurrencyToolBoxControl::execute
Change-Id: I6f86179efd1839e31b089e0086b6ddbdda358f31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148896
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'include/svx')
-rw-r--r-- | include/svx/tbcontrl.hxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index 72acf5845a4a..e40c06f3eb44 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -249,15 +249,44 @@ public: class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SvxCurrencyToolBoxControl final : public svt::PopupWindowController { +public: + // struct containing currency data + struct SvxCurrencyData { + sal_uInt16 m_currencyIdx; + bool m_onlyIsoCode; + OUString m_label; + + static const sal_uInt16 InvalidCurrency; + + SvxCurrencyData( + sal_uInt16 currencyIdx = InvalidCurrency, + bool onlyIsoCode = false + ); + + bool operator == (const SvxCurrencyData& other) const; + }; + + typedef std::vector<SvxCurrencyData> SvxCurrencyVect_t; + private: OUString m_aFormatString; LanguageType m_eLanguage; sal_uInt32 m_nFormatKey; + SvxCurrencyVect_t m_currencies; + SvxCurrencyVect_t m_mru_currencies; + + void addMruCurrency(sal_Int16 currencyPosition); + + // inner static method for backward compatibility + static void inner_GetCurrencySymbols( bool bFlag, SvxCurrencyVect_t &p_mru_currencies, + SvxCurrencyVect_t &pCurrencies); public: static void GetCurrencySymbols( std::vector<OUString>& rList, bool bFlag, std::vector<sal_uInt16>& rCurrencyList ); + const SvxCurrencyVect_t& GetCurrencySymbols(); + explicit SvxCurrencyToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext ); virtual ~SvxCurrencyToolBoxControl() override; |