dbaccess/source/ui/control/FieldDescControl.cxx |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

New commits:
commit 40ce74d57c7661a6bb556135c1304a87d92f0178
Author:     Neil Roberts <[email protected]>
AuthorDate: Mon Oct 20 12:58:01 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Oct 20 20:46:32 2025 +0200

    tdf#75509 tdf#138409 Convert default value to double without formatter
    
    Since e6004bddfc8d7d41f4e17691eaeefd770c608a13 the default value for a
    table field is converted to a locale-independant format where the
    decimal separator is always “.” using OUString::number. However when
    loading the value back again to display in the text box the value was
    being parsed with the decimal separator of the table field. This will
    fail if the decimal separator in the format for the field is not “.”. To
    fix that this patch changes it to parse the string with
    OUString::toDouble instead.
    
    I think that tdf#75509 and tdf#138409 are the same bug. I think the
    commit mentioned above fixes part of the problem so that if you create a
    field with a default value that has decimal places then they will be
    used when creating a new row. However, if you then try to edit the field
    again then without this patch the default value will be reset to a blank
    string because the double parsing code doesn’t understand the “.” in the
    canonicalised string.
    
    Without this patch it’s also quite difficult to create such a field at
    all. Whenever you try to save the table after editing, the text box for
    the default value reloads the new value and triggers the parsing problem
    so it gets reset to a blank string. The only way I can get it to work is
    by selecting a different field before saving the table or closing the
    edit window. Somehow this problem must have slipped through the testing
    for the second bug so I don’t know if the testers did the steps
    described above or if the problem is backend dependant or something.
    
    Change-Id: Ic1d47893245e93322248542bf2decfdc34987771
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192740
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx 
b/dbaccess/source/ui/control/FieldDescControl.cxx
index 2e9a33a50bfe..565d3dcdc4b2 100644
--- a/dbaccess/source/ui/control/FieldDescControl.cxx
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -1293,14 +1293,10 @@ OUString OFieldDescControl::getControlDefault( const 
OFieldDescription* _pFieldD
                 {
                     if ( !sDefault.isEmpty() )
                     {
-                        try
-                        {
-                            nValue = 
GetFormatter()->convertStringToNumber(nFormatKey,sDefault);
-                        }
-                        catch(const Exception&)
-                        {
-                            return OUString(); // return empty string for 
format example
-                        }
+                        // The number will have been canonicalized with 
OUString::number in
+                        // CanonicalizeToControlDefault so here we want to do 
the opposite in order
+                        // to get a number to format
+                        nValue = sDefault.toDouble();
                     }
                 }
             }

Reply via email to