summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2025-09-27 00:42:27 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2025-09-26 23:17:10 +0200
commit22d7827c6695358e11ee06a5599b72a92ff0b2ac (patch)
treefd779f7f6b4f63f60b163c7f6c2466dc0f7b7f66
parent87a7d94cc35253451e26e789e6243f2c5fd3ac77 (diff)
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 <mike.kaganski@collabora.com>
-rw-r--r--basic/qa/basic_coverage/test_format_function.bas1
-rw-r--r--basic/qa/basic_coverage/test_str_method.bas1
-rw-r--r--basic/qa/basic_coverage/test_typename_method.bas2
-rw-r--r--basic/source/classes/image.cxx3
-rw-r--r--basic/source/comp/scanner.cxx2
-rw-r--r--basic/source/comp/symtbl.cxx5
-rw-r--r--basic/source/inc/filefmt.hxx2
-rw-r--r--basic/source/runtime/runtime.cxx4
8 files changed, 18 insertions, 2 deletions
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 6f036e5c4c7a..01695e6b4939 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -618,6 +618,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
{
@@ -657,6 +658,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 93775a086554..17a09b190046 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -2810,7 +2810,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
@@ -2842,6 +2842,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