[Libreoffice-commits] core.git: include/svtools include/vcl solenv/clang-format svtools/source svx/source toolkit/source vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 15 08:27:02 UTC 2020


 include/svtools/editbrowsebox.hxx     |    6 +
 include/vcl/toolkit/field.hxx         |    8 --
 include/vcl/toolkit/longcurr.hxx      |   10 +--
 include/vcl/weldutils.hxx             |   19 +++++
 solenv/clang-format/excludelist       |    2 
 svtools/source/brwbox/ebbcontrols.cxx |   10 +++
 svx/source/fmcomp/gridcell.cxx        |  108 +++++++++++++---------------------
 svx/source/inc/gridcell.hxx           |    4 -
 toolkit/source/awt/vclxtoolkit.cxx    |    1 
 toolkit/source/awt/vclxwindows.cxx    |    1 
 vcl/source/app/weldutils.cxx          |   27 ++++++++
 vcl/source/control/longcurr.cxx       |   28 ++++++++
 12 files changed, 143 insertions(+), 81 deletions(-)

New commits:
commit 0c85d1ee0688435ffefd8eff797e57eac9bace27
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Jul 12 20:42:56 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 15 10:26:16 2020 +0200

    weld LongCurrencyControl
    
    Change-Id: I700329aeee53f8ce91ce22a3b50fe59e3d19c063
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98613
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index ecfd49d6d605..6732b9df211e 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -740,6 +740,12 @@ namespace svt
         DoubleNumericControl(BrowserDataWin* pParent, bool bSpinVariant);
     };
 
+    class SVT_DLLPUBLIC LongCurrencyControl : public FormattedControlBase
+    {
+    public:
+        LongCurrencyControl(BrowserDataWin* pParent, bool bSpinVariant);
+    };
+
     //= FormattedFieldCellController
     class SVT_DLLPUBLIC FormattedFieldCellController final : public EditCellController
     {
diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx
index dacaed6f0386..f996bd1efcab 100644
--- a/include/vcl/toolkit/field.hxx
+++ b/include/vcl/toolkit/field.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_TOOLKIT_FIELD_HXX
-#define INCLUDED_VCL_TOOLKIT_FIELD_HXX
+#pragma once
 
 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
 #error "don't use this in new code"
@@ -26,8 +25,7 @@
 
 #include <config_options.h>
 #include <vcl/toolkit/combobox.hxx>
-#include <vcl/field.hxx>
-#include <vcl/longcurr.hxx>
+#include <vcl/toolkit/longcurr.hxx>
 
 class VCL_DLLPUBLIC MetricFormatter : public NumericFormatter
 {
@@ -250,6 +248,4 @@ public:
     void            ReformatAll() override;
 };
 
-#endif // INCLUDED_VCL_FIELD_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/longcurr.hxx b/include/vcl/toolkit/longcurr.hxx
similarity index 95%
rename from include/vcl/longcurr.hxx
rename to include/vcl/toolkit/longcurr.hxx
index 6732a184b34b..d00c0aa0364b 100644
--- a/include/vcl/longcurr.hxx
+++ b/include/vcl/toolkit/longcurr.hxx
@@ -17,8 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_LONGCURR_HXX
-#define INCLUDED_VCL_LONGCURR_HXX
+#pragma once
+
+#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
+#error "don't use this in new code"
+#endif
 
 #include <config_options.h>
 #include <vcl/dllapi.h>
@@ -68,7 +71,6 @@ private:
 
 };
 
-
 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) LongCurrencyField final : public SpinField, public LongCurrencyFormatter
 {
     friend void ImplNewLongCurrencyFieldValue(LongCurrencyField*, const BigInt&);
@@ -97,6 +99,4 @@ public:
     const BigInt&   GetSpinSize() const { return mnSpinSize; }
 };
 
-#endif // INCLUDED_VCL_LONGCURR_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index 84e647835863..7acb919b493d 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -219,6 +219,25 @@ private:
     std::unique_ptr<validation::NumberValidator> m_pNumberValidator;
 };
 
+class VCL_DLLPUBLIC LongCurrencyEntry final : public EntryFormatter
+{
+public:
+    LongCurrencyEntry(weld::Entry& rEntry);
+    LongCurrencyEntry(weld::FormattedSpinButton& rSpinButton);
+
+    void SetUseThousandSep(bool b);
+    void SetCurrencySymbol(const OUString& rStr);
+
+    virtual ~LongCurrencyEntry() override;
+
+private:
+    DECL_LINK(FormatOutputHdl, LinkParamNone*, bool);
+    DECL_LINK(ParseInputHdl, sal_Int64*, TriState);
+
+    OUString m_aCurrencySymbol;
+    bool m_bThousandSep;
+};
+
 // get the row the iterator is on
 VCL_DLLPUBLIC size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::TreeIter& rIter);
 
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 97e745d97f26..9108087a4a11 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -7380,7 +7380,6 @@ include/vcl/keycodes.hxx
 include/vcl/layout.hxx
 include/vcl/lazydelete.hxx
 include/vcl/lineinfo.hxx
-include/vcl/longcurr.hxx
 include/vcl/mapmod.hxx
 include/vcl/menu.hxx
 include/vcl/menubtn.hxx
@@ -7449,6 +7448,7 @@ include/vcl/toolkit/fixedhyper.hxx
 include/vcl/toolkit/fmtfield.hxx
 include/vcl/toolkit/group.hxx
 include/vcl/toolkit/imgctrl.hxx
+include/vcl/toolkit/longcurr.hxx
 include/vcl/toolkit/lstbox.hxx
 include/vcl/toolkit/morebtn.hxx
 include/vcl/toolkit/prgsbar.hxx
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 69ed4d6b6b06..a10375adf5f8 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -455,6 +455,16 @@ namespace svt
         InitFormattedControlBase();
     }
 
+    LongCurrencyControl::LongCurrencyControl(BrowserDataWin* pParent, bool bSpinVariant)
+        : FormattedControlBase(pParent, bSpinVariant)
+    {
+        if (bSpinVariant)
+            m_xEntryFormatter.reset(new weld::LongCurrencyEntry(*m_xSpinButton));
+        else
+            m_xEntryFormatter.reset(new weld::LongCurrencyEntry(*m_xEntry));
+        InitFormattedControlBase();
+    }
+
     EditCellController::EditCellController(EditControlBase* pEdit)
         : CellController(pEdit)
         , m_pEditImplementation(new EntryImplementation(*pEdit))
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index a813e7710a99..ca50c2a427fc 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -62,7 +62,6 @@
 #include <toolkit/helper/vclunohelper.hxx>
 #include <tools/debug.hxx>
 #include <tools/diagnose_ex.h>
-#include <vcl/longcurr.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
 #include <connectivity/dbtools.hxx>
@@ -1943,7 +1942,6 @@ VclPtr<Control> DbNumericField::createField(BrowserDataWin* pParent, bool bSpinB
 
 namespace
 {
-
     OUString lcl_setFormattedNumeric_nothrow( FormattedControlBase& _rField, const DbCellControl& _rControl,
         const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
     {
@@ -2012,7 +2010,6 @@ bool DbNumericField::commitControl()
 
 DbCurrencyField::DbCurrencyField(DbGridColumn& _rColumn)
     :DbSpinField( _rColumn )
-    ,m_nScale( 0 )
 {
     doPropertyListening( FM_PROP_DECIMAL_ACCURACY );
     doPropertyListening( FM_PROP_VALUEMIN );
@@ -2023,6 +2020,10 @@ DbCurrencyField::DbCurrencyField(DbGridColumn& _rColumn)
     doPropertyListening( FM_PROP_CURRENCYSYMBOL );
 }
 
+CellControllerRef DbCurrencyField::CreateController() const
+{
+    return new ::svt::FormattedFieldCellController(static_cast<FormattedControlBase*>(m_pWindow.get()));
+}
 
 void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
 {
@@ -2031,7 +2032,7 @@ void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertyS
     if ( !m_pWindow || !_rxModel.is() )
         return;
 
-    m_nScale                = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
+    sal_Int16 nScale        = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
     double  nMin            = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) );
     double  nMax            = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) );
     double  nStep           = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) );
@@ -2039,55 +2040,39 @@ void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertyS
     bool    bThousand   = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
     OUString aStr( getString( _rxModel->getPropertyValue(FM_PROP_CURRENCYSYMBOL ) ) );
 
-    //fdo#42747 the min/max/first/last of vcl NumericFormatters needs to be
-    //multiplied by the no of decimal places. See also
-    //VclBuilder::mungeAdjustment
-    int nMul = rtl_math_pow10Exp(1, m_nScale);
-    nMin *= nMul;
-    nMax *= nMul;
-
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetUseThousandSep( bThousand );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetDecimalDigits( m_nScale );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetCurrencySymbol( aStr );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetFirst( nMin );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetLast( nMax );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetMin( nMin );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetMax( nMax );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetSpinSize( nStep );
-    static_cast< LongCurrencyField* >( m_pWindow.get() )->SetStrictFormat( bStrict );
-
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetUseThousandSep( bThousand );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetDecimalDigits( m_nScale );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetCurrencySymbol( aStr );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetFirst( nMin );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetLast( nMax );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetMin( nMin );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetMax( nMax );
-    static_cast< LongCurrencyField* >( m_pPainter.get() )->SetStrictFormat( bStrict );
-}
-
-VclPtr<Control> DbCurrencyField::createField(BrowserDataWin* _pParent, bool bSpinButton, const Reference< XPropertySet >& /*_rxModel*/  )
+    Formatter& rEditFormatter = static_cast<FormattedControlBase*>(m_pWindow.get())->get_formatter();
+    rEditFormatter.SetDecimalDigits(nScale);
+    rEditFormatter.SetMinValue(nMin);
+    rEditFormatter.SetMaxValue(nMax);
+    rEditFormatter.SetSpinSize(nStep);
+    rEditFormatter.SetStrictFormat(bStrict);
+    weld::LongCurrencyEntry& rCurrencyEditFormatter = static_cast<weld::LongCurrencyEntry&>(rEditFormatter);
+    rCurrencyEditFormatter.SetUseThousandSep(bThousand);
+    rCurrencyEditFormatter.SetCurrencySymbol(aStr);
+
+    Formatter& rPaintFormatter = static_cast<FormattedControlBase*>(m_pPainter.get())->get_formatter();
+    rPaintFormatter.SetDecimalDigits(nScale);
+    rPaintFormatter.SetMinValue(nMin);
+    rPaintFormatter.SetMaxValue(nMax);
+    rPaintFormatter.SetStrictFormat(bStrict);
+    weld::LongCurrencyEntry& rPaintCurrencyFormatter = static_cast<weld::LongCurrencyEntry&>(rPaintFormatter);
+    rPaintCurrencyFormatter.SetUseThousandSep(bThousand);
+    rPaintCurrencyFormatter.SetCurrencySymbol(aStr);
+}
+
+VclPtr<Control> DbCurrencyField::createField(BrowserDataWin* pParent, bool bSpinButton, const Reference< XPropertySet >& /*rxModel*/)
 {
-    WinBits _nFieldStyle = bSpinButton ? (WB_REPEAT | WB_SPIN) : 0;
-    return VclPtr<LongCurrencyField>::Create( _pParent, _nFieldStyle );
+    return VclPtr<LongCurrencyControl>::Create(pParent, bSpinButton);
 }
 
 double DbCurrencyField::GetCurrency(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const
 {
-    double fValue = GetValue(_rxField, xFormatter);
-    if (m_nScale)
-    {
-        // SAL_INFO("svx",("double = %.64f ",fValue);
-        fValue = ::rtl::math::pow10Exp(fValue, m_nScale);
-        fValue = ::rtl::math::round(fValue);
-    }
-    return fValue;
+    return GetValue(_rxField, xFormatter);
 }
 
 namespace
 {
-
-    OUString lcl_setFormattedCurrency_nothrow( LongCurrencyField& _rField, const DbCurrencyField& _rControl,
+    OUString lcl_setFormattedCurrency_nothrow( FormattedControlBase& _rField, const DbCurrencyField& _rControl,
         const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
     {
         OUString sValue;
@@ -2095,11 +2080,11 @@ namespace
         {
             try
             {
-                double fValue = _rControl.GetCurrency( _rxField, _rxFormatter );
+                double fValue = _rControl.GetValue( _rxField, _rxFormatter );
                 if ( !_rxField->wasNull() )
                 {
-                    _rField.SetValue( fValue );
-                    sValue = _rField.GetText();
+                    _rField.get_formatter().SetValue(fValue);
+                    sValue = _rField.get_widget().get_text();
                 }
             }
             catch( const Exception& )
@@ -2113,45 +2098,40 @@ namespace
 
 OUString DbCurrencyField::GetFormatText(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/)
 {
-    return lcl_setFormattedCurrency_nothrow( dynamic_cast< LongCurrencyField& >( *m_pPainter ), *this, _rxField, _rxFormatter );
+    return lcl_setFormattedCurrency_nothrow(dynamic_cast<FormattedControlBase&>(*m_pPainter), *this, _rxField, _rxFormatter);
 }
 
 void DbCurrencyField::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< css::util::XNumberFormatter >& _rxFormatter)
 {
-    lcl_setFormattedCurrency_nothrow( dynamic_cast< LongCurrencyField& >( *m_pWindow ), *this, _rxField, _rxFormatter );
+    lcl_setFormattedCurrency_nothrow(dynamic_cast<FormattedControlBase&>(*m_pWindow), *this, _rxField, _rxFormatter);
 }
 
 void DbCurrencyField::updateFromModel( Reference< XPropertySet > _rxModel )
 {
     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCurrencyField::updateFromModel: invalid call!" );
 
+    FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
+
     double dValue = 0;
     if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
     {
-        if ( m_nScale )
-        {
-            dValue = ::rtl::math::pow10Exp( dValue, m_nScale );
-            dValue = ::rtl::math::round(dValue);
-        }
-
-        static_cast< LongCurrencyField* >( m_pWindow.get() )->SetValue( dValue );
+        Formatter& rFormatter = pControl->get_formatter();
+        rFormatter.SetValue(dValue);
     }
     else
-        m_pWindow->SetText( OUString() );
+        pControl->get_widget().set_text(OUString());
 }
 
-
 bool DbCurrencyField::commitControl()
 {
-    OUString aText(m_pWindow->GetText());
+    FormattedControlBase* pControl = static_cast<FormattedControlBase*>(m_pWindow.get());
+    OUString aText(pControl->get_widget().get_text());
     Any aVal;
+
     if (!aText.isEmpty())   // not empty
     {
-        double fValue = static_cast<LongCurrencyField*>(m_pWindow.get())->GetValue();
-        if (m_nScale)
-        {
-            fValue /= ::rtl::math::pow10Exp(1.0, m_nScale);
-        }
+        Formatter& rFormatter = pControl->get_formatter();
+        double fValue = rFormatter.GetValue();
         aVal <<= fValue;
     }
     m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 1bff25674390..121720b29b1a 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -600,13 +600,11 @@ protected:
     virtual void    implAdjustGenericFieldSetting( const css::uno::Reference< css::beans::XPropertySet >& _rxModel ) override;
 };
 
-
 class DbCurrencyField : public DbSpinField
 {
-    sal_Int16  m_nScale;
-
 public:
     DbCurrencyField(DbGridColumn& _rColumn);
+    virtual ::svt::CellControllerRef CreateController() const override;
     virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, Color** ppColor = nullptr) override;
     virtual void UpdateFromField(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override;
 
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 4c9a01d2ab0c..8d067c05cf4c 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -95,7 +95,6 @@
 #include <vcl/toolkit/fmtfield.hxx>
 #include <vcl/toolkit/prgsbar.hxx>
 #include <vcl/scheduler.hxx>
-#include <vcl/longcurr.hxx>
 #include <vcl/toolkit/lstbox.hxx>
 #include <vcl/menubtn.hxx>
 #include <vcl/stdtext.hxx>
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index f3a41f03f7dd..964cdf0dd3a3 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -49,7 +49,6 @@
 #include <vcl/toolkit/combobox.hxx>
 #include <vcl/toolkit/field.hxx>
 #include <vcl/toolkit/fixedhyper.hxx>
-#include <vcl/longcurr.hxx>
 #include <vcl/toolkit/imgctrl.hxx>
 #include <vcl/toolkit/dialog.hxx>
 #include <vcl/toolkit/prgsbar.hxx>
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,


More information about the Libreoffice-commits mailing list