basic/qa/basic_coverage/test_format_function.bas |    1 +
 basic/qa/basic_coverage/test_str_method.bas      |    1 +
 basic/qa/basic_coverage/test_typename_method.bas |    2 ++
 basic/source/classes/image.cxx                   |    3 +++
 basic/source/comp/scanner.cxx                    |    2 +-
 basic/source/comp/symtbl.cxx                     |    5 +++++
 basic/source/inc/filefmt.hxx                     |    2 ++
 basic/source/runtime/runtime.cxx                 |    4 +++-
 8 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 3d7003a7c1010ba50cb6442f407d2560d9aaf26a
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Sep 27 00:42:27 2025 +0500
Commit:     Xisco Fauli <[email protected]>
CommitDate: Mon Sep 29 12:11:16 2025 +0200

    tdf#168569: support date values in string pool
    
    Commit f45463d8e2bb0771ec1837d159ff98108b0047cf (tdf#93727 Support date
    literals in basic, 2017-05-24) introduced correct parsing of literals
    like #2025-09-26#. However, it didn't retain the value type; there was
    a discussion about that in gerrit, but no solution was found, and type
    was set to double.
    
    Later, a similar problem (storing type of value in compiled image) was
    fixed in commit 5eedb3beeaeed88de0d1ebd041a9f15ceea7e78c (tdf#142460:
    properly handle boolean values in string pool, 2021-06-25).
    
    This change reuses the same method to store date type using 'd' char in
    the string pool.
    
    Change-Id: I32e8497ece1f30980ba6d4fca248687b817348f2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191555
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>
    (cherry picked from commit 22d7827c6695358e11ee06a5599b72a92ff0b2ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191595
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/basic/qa/basic_coverage/test_format_function.bas 
b/basic/qa/basic_coverage/test_format_function.bas
index 0492a51b8840..297b345c868f 100644
--- a/basic/qa/basic_coverage/test_format_function.bas
+++ b/basic/qa/basic_coverage/test_format_function.bas
@@ -43,6 +43,7 @@ Sub verify_testFormat
     TestUtil.AssertEqual(Format(" "), " ", "Format("" "")")
     TestUtil.AssertEqual(Format(" 00 "), "0", "Format("" 00 "")")
     TestUtil.AssertEqual(Format(CDate("2025-09-26")), "09/26/2025", 
"Format(CDate(""2025-09-26""))")
+    TestUtil.AssertEqual(Format(#2025-09-26#), "09/26/2025", 
"Format(#2025-09-26#)")
 
     Exit Sub
 errorHandler:
diff --git a/basic/qa/basic_coverage/test_str_method.bas 
b/basic/qa/basic_coverage/test_str_method.bas
index 2ce10952ee04..9ce67ff1dec3 100644
--- a/basic/qa/basic_coverage/test_str_method.bas
+++ b/basic/qa/basic_coverage/test_str_method.bas
@@ -32,6 +32,7 @@ Sub verify_testStr
 
     ' Dates are converted into locale-dependent strings (test uses en-US)
     TestUtil.AssertEqualStrict(Str(CDate("2025-09-26")), "09/26/2025", 
"Str(CDate(""2025-09-26""))")
+    TestUtil.AssertEqualStrict(Str(#2025-09-26#), "09/26/2025", 
"Str(#2025-09-26#)")
 
     TestUtil.AssertEqualStrict(Str(true), "True", "Str(true)")
 
diff --git a/basic/qa/basic_coverage/test_typename_method.bas 
b/basic/qa/basic_coverage/test_typename_method.bas
index 028f57f0e8db..f6fb90c2df79 100644
--- a/basic/qa/basic_coverage/test_typename_method.bas
+++ b/basic/qa/basic_coverage/test_typename_method.bas
@@ -43,6 +43,8 @@ Function doUnitTest ' TypeName()
     assert( TypeName(myUDF) = "Object"  , "TypeName(myUDF) is not ""Object""" )
     assert( TypeName(var)   = "Empty"   , "TypeName(var) is not ""Empty""" )
 
+    assert( TypeName(#2025-09-26#) = "Date" , "TypeName(#2025-09-26#) is not 
""Date""" )
+
     assert( TypeName(int_)      = "Integer" , "TypeName(int_) is not 
""Integer""" )
     assert( TypeName(long_)     = "Long"    , "TypeName(long_) is not 
""Long""" )
     assert( TypeName(single_)   = "Single"  , "TypeName(single_) is not 
""Single""" )
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 95e9a26ae6b2..9138ea78c55d 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -616,6 +616,7 @@ void SbiImage::AddEnum(SbxObject* pObject) // Register enum 
type
     rEnums->Insert(pObject, rEnums->Count());
 }
 
+// See also: SbiRuntime::StepLOADNC
 // Note: IDs start with 1
 OUString SbiImage::GetString( sal_uInt32 nId, SbxDataType *eType ) const
 {
@@ -655,6 +656,8 @@ OUString SbiImage::GetString( sal_uInt32 nId, SbxDataType 
*eType ) const
                         case '@': *eType = SbxCURRENCY; break;
                         // tdf#142460 - properly handle boolean values in 
string pool
                         case 'b': *eType = SbxBOOL; break;
+                        // tdf#168569 - support date values in string pool
+                        case 'd': *eType = SbxDATE; break; // Not in 
GetSuffixType
                     }
                 }
             }
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index a95ee3a994a4..656ba6d8442f 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -647,7 +647,7 @@ bool SbiScanner::NextSym()
                 GenError( ERRCODE_BASIC_CONVERSION );
 
             bNumber = true;
-            eScanType = SbxDOUBLE;
+            eScanType = SbxDATE;
         }
         else
         {
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 6f8b53ed0d5a..d28d5fde5e7c 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -100,6 +100,11 @@ short SbiStringPool::Add(double n, SbxDataType t)
             size = snprintf(buf, sizeof(buf), "%.16g", n) + 1;
             buf[size++] = '@';
             break;
+        case SbxDATE:
+            // tdf#168569 - support date values in string pool
+            size = snprintf(buf, sizeof(buf), "%.16g", n) + 1;
+            buf[size++] = 'd'; // Not in GetSuffixType
+            break;
         default: assert(false); break; // should not happen
     }
 
diff --git a/basic/source/inc/filefmt.hxx b/basic/source/inc/filefmt.hxx
index 38dfa95754f3..5f29d6cdf56d 100644
--- a/basic/source/inc/filefmt.hxx
+++ b/basic/source/inc/filefmt.hxx
@@ -43,6 +43,8 @@
 //             tdf#142460: properly handle boolean values in string pool (no
 //                       version number bump for backward compatibility; 
relies on
 //                       new integer type suffix 'b')
+//             tdf#168569: support date values in string pool (no version 
number bump
+//                       for backward compatibility; relies on new integer 
type suffix 'd')
 //
 
 #define B_IMG_VERSION_12 0x00000012
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 8a4946822507..9650e77ae520 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -2816,7 +2816,7 @@ void SbiRuntime::StepERROR()
 }
 
 // loading a numeric constant (+ID)
-
+// See also: SbiImage::GetString
 void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
 {
     // tdf#143707 - check if the data type character was added after the 
string termination symbol
@@ -2848,6 +2848,8 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
             case '@': eType = SbxCURRENCY; break;
             // tdf#142460 - properly handle boolean values in string pool
             case 'b': eType = SbxBOOL; break;
+            // tdf#168569 - support date values in string pool
+            case 'd': eType = SbxDATE; break; // Not in GetSuffixType
         }
     }
     // tdf#143707 - if the data type character is different from the default 
value, it was added

Reply via email to