summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-12 20:42:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-15 10:26:16 +0200
commit0c85d1ee0688435ffefd8eff797e57eac9bace27 (patch)
tree0681c97f574125c370a35ef858b7fc9aa9e8f687 /vcl
parent1c24c5047d08cce8cc7f0b0a4acc93cfc5739da5 (diff)
weld LongCurrencyControl
Change-Id: I700329aeee53f8ce91ce22a3b50fe59e3d19c063 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98613 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/weldutils.cxx27
-rw-r--r--vcl/source/control/longcurr.cxx28
2 files changed, 55 insertions, 0 deletions
diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx
index 329d15827b70..ba4c30b416d2 100644
--- a/vcl/source/app/weldutils.cxx
+++ b/vcl/source/app/weldutils.cxx
@@ -287,6 +287,33 @@ void DoubleNumericEntry::ResetConformanceTester()
m_pNumberValidator.reset(
new validation::NumberValidator(cSeparatorThousand, cSeparatorDecimal));
}
+
+LongCurrencyEntry::LongCurrencyEntry(weld::Entry& rEntry)
+ : EntryFormatter(rEntry)
+{
+}
+
+LongCurrencyEntry::LongCurrencyEntry(weld::FormattedSpinButton& rSpinButton)
+ : EntryFormatter(rSpinButton)
+ , m_bThousandSep(true)
+{
+ SetOutputHdl(LINK(this, LongCurrencyEntry, FormatOutputHdl));
+ SetInputHdl(LINK(this, LongCurrencyEntry, ParseInputHdl));
+}
+
+void LongCurrencyEntry::SetUseThousandSep(bool b)
+{
+ m_bThousandSep = b;
+ ReFormat();
+}
+
+void LongCurrencyEntry::SetCurrencySymbol(const OUString& rStr)
+{
+ m_aCurrencySymbol = rStr;
+ ReFormat();
+}
+
+LongCurrencyEntry::~LongCurrencyEntry() = default;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx
index ab2ba50e73aa..6e5baa5de9fe 100644
--- a/vcl/source/control/longcurr.cxx
+++ b/vcl/source/control/longcurr.cxx
@@ -26,7 +26,9 @@
#include <sal/log.hxx>
#include <vcl/event.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/toolkit/field.hxx>
+#include <vcl/weldutils.hxx>
#include <unotools/localedatawrapper.hxx>
@@ -219,6 +221,32 @@ static bool ImplLongCurrencyGetValue( const OUString& rStr, BigInt& rValue,
return ImplCurrencyGetValue( rStr, rValue, nDecDigits, rLocaleDataWrapper );
}
+namespace weld
+{
+ IMPL_LINK_NOARG(LongCurrencyEntry, FormatOutputHdl, LinkParamNone*, bool)
+ {
+ const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper();
+ const OUString& rCurrencySymbol = !m_aCurrencySymbol.isEmpty() ? m_aCurrencySymbol : rLocaleDataWrapper.getCurrSymbol();
+ double fValue = GetValue() * weld::SpinButton::Power10(GetDecimalDigits());
+ OUString aText = ImplGetCurr(rLocaleDataWrapper, fValue, GetDecimalDigits(), rCurrencySymbol, m_bThousandSep);
+ ImplSetTextImpl(aText, nullptr);
+ return true;
+ }
+
+ IMPL_LINK(LongCurrencyEntry, ParseInputHdl, sal_Int64*, result, TriState)
+ {
+ const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper();
+
+ BigInt value;
+ bool bRet = ImplLongCurrencyGetValue(GetEntryText(), value, GetDecimalDigits(), rLocaleDataWrapper);
+
+ if (bRet)
+ *result = double(value);
+
+ return bRet ? TRISTATE_TRUE : TRISTATE_FALSE;
+ }
+}
+
bool ImplLongCurrencyReformat( const OUString& rStr, BigInt const & nMin, BigInt const & nMax,
sal_uInt16 nDecDigits,
const LocaleDataWrapper& rLocaleDataWrapper, OUString& rOutStr,