diff options
-rw-r--r-- | framework/source/uielement/spinfieldtoolbarcontroller.cxx | 10 | ||||
-rw-r--r-- | include/vcl/formatter.hxx | 4 | ||||
-rw-r--r-- | include/vcl/weldutils.hxx | 6 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 2 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 13 | ||||
-rw-r--r-- | vcl/source/app/weldutils.cxx | 6 | ||||
-rw-r--r-- | vcl/source/control/field2.cxx | 12 | ||||
-rw-r--r-- | vcl/source/control/fmtfield.cxx | 13 | ||||
-rw-r--r-- | vcl/source/control/longcurr.cxx | 6 |
9 files changed, 33 insertions, 39 deletions
diff --git a/framework/source/uielement/spinfieldtoolbarcontroller.cxx b/framework/source/uielement/spinfieldtoolbarcontroller.cxx index 65ed36e3be9b..13ffcdc0cb44 100644 --- a/framework/source/uielement/spinfieldtoolbarcontroller.cxx +++ b/framework/source/uielement/spinfieldtoolbarcontroller.cxx @@ -61,7 +61,7 @@ public: OUString get_entry_text() const { return m_xWidget->get_text(); } DECL_LINK(ValueChangedHdl, weld::FormattedSpinButton&, void); - DECL_LINK(FormatOutputHdl, LinkParamNone*, bool); + DECL_LINK(FormatOutputHdl, double, std::optional<OUString>); DECL_LINK(ParseInputHdl, double*, TriState); DECL_LINK(ModifyHdl, weld::Entry&, void); DECL_LINK(ActivateHdl, weld::Entry&, bool); @@ -84,7 +84,7 @@ SpinfieldControl::SpinfieldControl(vcl::Window* pParent, SpinfieldToolbarControl m_xWidget->connect_focus_in(LINK(this, SpinfieldControl, FocusInHdl)); m_xWidget->connect_focus_out(LINK(this, SpinfieldControl, FocusOutHdl)); Formatter& rFormatter = m_xWidget->GetFormatter(); - rFormatter.SetOutputHdl(LINK(this, SpinfieldControl, FormatOutputHdl)); + rFormatter.SetFormatValueHdl(LINK(this, SpinfieldControl, FormatOutputHdl)); rFormatter.SetInputHdl(LINK(this, SpinfieldControl, ParseInputHdl)); m_xWidget->connect_value_changed(LINK(this, SpinfieldControl, ValueChangedHdl)); m_xWidget->connect_changed(LINK(this, SpinfieldControl, ModifyHdl)); @@ -156,11 +156,9 @@ IMPL_LINK_NOARG(SpinfieldControl, ActivateHdl, weld::Entry&, bool) return bConsumed; } -IMPL_LINK_NOARG(SpinfieldControl, FormatOutputHdl, LinkParamNone*, bool) +IMPL_LINK(SpinfieldControl, FormatOutputHdl, double, fValue, std::optional<OUString>) { - OUString aText = m_pSpinfieldToolbarController->FormatOutputString(m_xWidget->GetFormatter().GetValue()); - m_xWidget->set_text(aText); - return true; + return std::optional<OUString>(m_pSpinfieldToolbarController->FormatOutputString(fValue)); } SpinfieldToolbarController::SpinfieldToolbarController( diff --git a/include/vcl/formatter.hxx b/include/vcl/formatter.hxx index cb1665459904..f7246767bb85 100644 --- a/include/vcl/formatter.hxx +++ b/include/vcl/formatter.hxx @@ -144,7 +144,7 @@ protected: bool m_bUseInputStringForFormatting; Link<double*, TriState> m_aInputHdl; - Link<LinkParamNone*, bool> m_aOutputHdl; + Link<double, std::optional<OUString>> m_aFormatValueHdl; public: Formatter(); @@ -243,7 +243,7 @@ public: void TreatAsNumber(bool bDoSo) { m_bTreatAsNumber = bDoSo; } void SetInputHdl(const Link<double*,TriState>& rLink) { m_aInputHdl = rLink; } - void SetOutputHdl(const Link<LinkParamNone*, bool>& rLink) { m_aOutputHdl = rLink; } + void SetFormatValueHdl(const Link<double, std::optional<OUString>>& rLink) { m_aFormatValueHdl = rLink; } public: //The following methods are interesting, if m_bTreatAsNumber is set to sal_False diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx index dcf7128c2b7f..05a8ba2b22bd 100644 --- a/include/vcl/weldutils.hxx +++ b/include/vcl/weldutils.hxx @@ -284,7 +284,7 @@ public: SAL_DLLPRIVATE virtual ~LongCurrencyFormatter() override; private: - DECL_DLLPRIVATE_LINK(FormatOutputHdl, LinkParamNone*, bool); + DECL_DLLPRIVATE_LINK(FormatOutputHdl, double, std::optional<OUString>); DECL_DLLPRIVATE_LINK(ParseInputHdl, double*, TriState); SAL_DLLPRIVATE void Init(); @@ -312,7 +312,7 @@ public: virtual ~TimeFormatter() override; private: - DECL_DLLPRIVATE_LINK(FormatOutputHdl, LinkParamNone*, bool); + DECL_DLLPRIVATE_LINK(FormatOutputHdl, double, std::optional<OUString>); DECL_DLLPRIVATE_LINK(ParseInputHdl, double*, TriState); DECL_DLLPRIVATE_LINK(CursorChangedHdl, weld::Entry&, void); @@ -345,7 +345,7 @@ public: virtual ~DateFormatter() override; private: - DECL_DLLPRIVATE_LINK(FormatOutputHdl, LinkParamNone*, bool); + DECL_DLLPRIVATE_LINK(FormatOutputHdl, double, std::optional<OUString>); DECL_DLLPRIVATE_LINK(ParseInputHdl, double*, TriState); DECL_DLLPRIVATE_LINK(CursorChangedHdl, weld::Entry&, void); diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 19b292e500ab..5be5314157c9 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -680,7 +680,7 @@ protected: private: DECL_LINK(UpDownHdl, SpinField&, void); DECL_LINK(LoseFocusHdl, Control&, void); - DECL_LINK(OutputHdl, LinkParamNone*, bool); + DECL_LINK(OutputHdl, double, std::optional<OUString>); DECL_LINK(InputHdl, double*, TriState); DECL_LINK(ActivateHdl, Edit&, bool); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index ca2078879c26..89c024ab220d 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5855,7 +5855,7 @@ SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, SalInstanc m_xButton->SetUpHdl(LINK(this, SalInstanceSpinButton, UpDownHdl)); m_xButton->SetDownHdl(LINK(this, SalInstanceSpinButton, UpDownHdl)); m_xButton->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton, LoseFocusHdl)); - m_rFormatter.SetOutputHdl(LINK(this, SalInstanceSpinButton, OutputHdl)); + m_rFormatter.SetFormatValueHdl(LINK(this, SalInstanceSpinButton, OutputHdl)); m_rFormatter.SetInputHdl(LINK(this, SalInstanceSpinButton, InputHdl)); if (Edit* pEdit = m_xButton->GetSubEdit()) pEdit->SetActivateHdl(LINK(this, SalInstanceSpinButton, ActivateHdl)); @@ -5914,7 +5914,7 @@ SalInstanceSpinButton::~SalInstanceSpinButton() else m_xButton->SetActivateHdl(Link<Edit&, bool>()); m_rFormatter.SetInputHdl(Link<double*, TriState>()); - m_rFormatter.SetOutputHdl(Link<LinkParamNone*, bool>()); + m_rFormatter.SetFormatValueHdl(Link<double, std::optional<OUString>>()); m_xButton->SetLoseFocusHdl(Link<Control&, void>()); m_xButton->SetDownHdl(Link<SpinField&, void>()); m_xButton->SetUpHdl(Link<SpinField&, void>()); @@ -5931,14 +5931,9 @@ IMPL_LINK_NOARG(SalInstanceSpinButton, UpDownHdl, SpinField&, void) { signal_val IMPL_LINK_NOARG(SalInstanceSpinButton, LoseFocusHdl, Control&, void) { signal_value_changed(); } -IMPL_LINK_NOARG(SalInstanceSpinButton, OutputHdl, LinkParamNone*, bool) +IMPL_LINK(SalInstanceSpinButton, OutputHdl, double, fValue, std::optional<OUString>) { - std::optional<OUString> aText = format_floating_point_value(get_floating_point_value()); - if (!aText.has_value()) - return false; - - set_text(aText.value()); - return true; + return format_floating_point_value(fValue); } IMPL_LINK(SalInstanceSpinButton, InputHdl, double*, pResult, TriState) diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx index 9cc759dcdf12..92b421757e1e 100644 --- a/vcl/source/app/weldutils.cxx +++ b/vcl/source/app/weldutils.cxx @@ -317,7 +317,7 @@ LongCurrencyFormatter::LongCurrencyFormatter(weld::FormattedSpinButton& rSpinBut void LongCurrencyFormatter::Init() { - SetOutputHdl(LINK(this, LongCurrencyFormatter, FormatOutputHdl)); + SetFormatValueHdl(LINK(this, LongCurrencyFormatter, FormatOutputHdl)); SetInputHdl(LINK(this, LongCurrencyFormatter, ParseInputHdl)); } @@ -357,7 +357,7 @@ void TimeFormatter::Init() { DisableRemainderFactor(); //so with hh::mm::ss, incrementing mm will not reset ss - SetOutputHdl(LINK(this, TimeFormatter, FormatOutputHdl)); + SetFormatValueHdl(LINK(this, TimeFormatter, FormatOutputHdl)); SetInputHdl(LINK(this, TimeFormatter, ParseInputHdl)); SetMin(tools::Time(0, 0)); @@ -441,7 +441,7 @@ DateFormatter::DateFormatter(weld::Entry& rEntry) void DateFormatter::Init() { - SetOutputHdl(LINK(this, DateFormatter, FormatOutputHdl)); + SetFormatValueHdl(LINK(this, DateFormatter, FormatOutputHdl)); SetInputHdl(LINK(this, DateFormatter, ParseInputHdl)); SetMin(Date(1, 1, 1900)); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index ac47e1166567..fc0cab000da8 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -2247,11 +2247,9 @@ namespace weld return ::DateFormatter::FormatDate(Date(nValue), m_eFormat, rLocaleData, m_aStaticFormatter); } - IMPL_LINK_NOARG(DateFormatter, FormatOutputHdl, LinkParamNone*, bool) + IMPL_LINK(DateFormatter, FormatOutputHdl, double, fValue, std::optional<OUString>) { - OUString sText = FormatNumber(GetValue()); - ImplSetTextImpl(sText, nullptr); - return true; + return std::optional<OUString>(FormatNumber(fValue)); } IMPL_LINK(DateFormatter, ParseInputHdl, double*, result, TriState) @@ -3145,11 +3143,9 @@ namespace weld return ::TimeFormatter::FormatTime(ConvertValue(nValue), m_eFormat, m_eTimeFormat, m_bDuration, rLocaleData); } - IMPL_LINK_NOARG(TimeFormatter, FormatOutputHdl, LinkParamNone*, bool) + IMPL_LINK(TimeFormatter, FormatOutputHdl, double, fValue, std::optional<OUString>) { - OUString sText = FormatNumber(GetValue()); - ImplSetTextImpl(sText, nullptr); - return true; + return std::optional<OUString>(FormatNumber(fValue)); } IMPL_LINK(TimeFormatter, ParseInputHdl, double*, result, TriState) diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx index 0210f4e8727a..3dc7f1ac9a29 100644 --- a/vcl/source/control/fmtfield.cxx +++ b/vcl/source/control/fmtfield.cxx @@ -746,7 +746,11 @@ void Formatter::ImplSetValue(double dVal, bool bForce) m_ValueState = valueDouble; UpdateCurrentValue(dVal); - if (!m_aOutputHdl.IsSet() || !m_aOutputHdl.Call(nullptr)) + std::optional<OUString> aText; + if (m_aFormatValueHdl.IsSet()) + aText = m_aFormatValueHdl.Call(dVal); + + if (!aText.has_value()) { OUString sNewText; if (GetOrCreateFormatter()->IsTextFormat(m_nFormatKey)) @@ -768,10 +772,13 @@ void Formatter::ImplSetValue(double dVal, bool bForce) GetOrCreateFormatter()->GetOutputString(dVal, m_nFormatKey, sNewText, &m_pLastOutputColor); } } - ImplSetTextImpl(sNewText, nullptr); - DBG_ASSERT(CheckText(sNewText), "FormattedField::ImplSetValue : formatted string doesn't match the criteria !"); + aText = sNewText; } + assert(aText.has_value()); + ImplSetTextImpl(*aText, nullptr); + DBG_ASSERT(CheckText(*aText), "FormattedField::ImplSetValue : formatted string doesn't match the criteria !"); + m_ValueState = valueDouble; } diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index 39f3e295147a..a1698afb1f90 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -211,11 +211,10 @@ bool ImplCurrencyGetValue( const OUString& rStr, BigInt& rValue, namespace weld { - IMPL_LINK_NOARG(LongCurrencyFormatter, FormatOutputHdl, LinkParamNone*, bool) + IMPL_LINK(LongCurrencyFormatter, FormatOutputHdl, double, fValue, std::optional<OUString>) { const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); const OUString& rCurrencySymbol = !m_aCurrencySymbol.isEmpty() ? m_aCurrencySymbol : rLocaleDataWrapper.getCurrSymbol(); - double fValue = GetValue(); sal_uInt16 nDecimalDigits = GetDecimalDigits(); if (nDecimalDigits) { @@ -223,8 +222,7 @@ namespace weld fValue = std::round(fValue * weld::SpinButton::Power10(nDecimalDigits)); } OUString aText = ImplGetCurr(rLocaleDataWrapper, fValue, GetDecimalDigits(), rCurrencySymbol, m_bThousandSep); - ImplSetTextImpl(aText, nullptr); - return true; + return std::optional<OUString>(aText); } IMPL_LINK(LongCurrencyFormatter, ParseInputHdl, double*, result, TriState) |