include/vcl/formatter.hxx      |    6 ++++++
 svx/source/fmcomp/gridcell.cxx |   14 ++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

New commits:
commit 6f2dda05b8808729716a22e9f98ae28b03094ecb
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Sep 26 10:42:06 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Sep 26 17:31:06 2023 +0200

    Resolves: tdf#151919 mark blanked fields as requiring a reformat
    
    the next time a format is requested, even if the value of the
    Formatter is the same, otherwise if the value is the same it
    will remain blank.
    
    Change-Id: Iec77e6d9f792b51a83a9e289cbdb197605ab1a21
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157224
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/include/vcl/formatter.hxx b/include/vcl/formatter.hxx
index 4aa81ea1be30..54d6745587e1 100644
--- a/include/vcl/formatter.hxx
+++ b/include/vcl/formatter.hxx
@@ -186,6 +186,12 @@ public:
     // If the current String is invalid, GetValue() returns this value
     double  GetDefaultValue() const             { return m_dDefaultValue; }
 
+    // Make the formatter recreate the output text from the value on the next
+    // format attempt even if the value is the same as the current value.
+    // Needed if the associated widget had its text changed by something other
+    // that this Formatter (typically blanked out) since the last formatting
+    void    InvalidateValueState()    { m_ValueState = valueDirty; }
+
     void SetLastSelection(const Selection& rSelection) { m_aLastSelection = 
rSelection; }
 
     // Settings for the format
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 2bf339a19135..cb8ccf91955f 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -2067,15 +2067,16 @@ void DbNumericField::updateFromModel( Reference< 
XPropertySet > _rxModel )
     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbNumericField::updateFromModel: 
invalid call!" );
 
     FormattedControlBase* pControl = 
static_cast<FormattedControlBase*>(m_pWindow.get());
+    Formatter& rFormatter = pControl->get_formatter();
 
     double dValue = 0;
     if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
-    {
-        Formatter& rFormatter = pControl->get_formatter();
         rFormatter.SetValue(dValue);
-    }
     else
+    {
         pControl->get_widget().set_text(OUString());
+        rFormatter.InvalidateValueState();
+    }
 }
 
 bool DbNumericField::commitControl()
@@ -2187,15 +2188,16 @@ void DbCurrencyField::updateFromModel( Reference< 
XPropertySet > _rxModel )
     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCurrencyField::updateFromModel: 
invalid call!" );
 
     FormattedControlBase* pControl = 
static_cast<FormattedControlBase*>(m_pWindow.get());
+    Formatter& rFormatter = pControl->get_formatter();
 
     double dValue = 0;
     if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
-    {
-        Formatter& rFormatter = pControl->get_formatter();
         rFormatter.SetValue(dValue);
-    }
     else
+    {
         pControl->get_widget().set_text(OUString());
+        rFormatter.InvalidateValueState();
+    }
 }
 
 bool DbCurrencyField::commitControl()

Reply via email to