summaryrefslogtreecommitdiffstats
path: root/basic/source/runtime/runtime.cxx
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2021-08-03 20:56:22 +0200
committerAndreas Heinisch <andreas.heinisch@yahoo.de>2021-08-10 12:23:19 +0200
commit3bcfb1aac1f43f16c579486264103ebd4f3f829b (patch)
tree359a6d297ee164857ecc61055f3866b791bbe770 /basic/source/runtime/runtime.cxx
parentflatten PropertySetInfo a little (diff)
downloadcore-3bcfb1aac1f43f16c579486264103ebd4f3f829b.tar.gz
core-3bcfb1aac1f43f16c579486264103ebd4f3f829b.zip
tdf#143707 - Change strategy to support suffix type characters
In order to support the correct data type of numeric constants, booleans, and default values for strings, the strategy to transport the data type character to the runtime has been changed. The type character will be added after the literal and the string termination symbol in order to keep compatibility. This allows to retrieve the correct type in StepLOADNC and in StepPARAM. Any legacy written images are still possible to process, since if there is a suffix type character where the data type character was directly written after the numeric constant, it will be processed in StepLOADNC. Without this fix, an optional parameter of type Variant, would still include the suffixe type character, and will not be converted to the correct type in StepPARAM. Change-Id: I86c8192c6dc28457053fa7b23a073420e45407b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119945 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Diffstat (limited to 'basic/source/runtime/runtime.cxx')
-rw-r--r--basic/source/runtime/runtime.cxx20
1 files changed, 18 insertions, 2 deletions
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 43e8eea9a0e4..7a246247e903 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -2817,8 +2817,10 @@ void SbiRuntime::StepERROR()
void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
{
+ // tdf#143707 - check if the data type character was added after the string termination symbol
+ SbxDataType eTypeStr;
// #57844 use localized function
- OUString aStr = pImg->GetString( static_cast<short>( nOp1 ) );
+ OUString aStr = pImg->GetString(static_cast<short>(nOp1), &eTypeStr);
// also allow , !!!
sal_Int32 iComma = aStr.indexOf(',');
if( iComma >= 0 )
@@ -2833,6 +2835,8 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
SbxDataType eType = SbxDOUBLE;
if ( nParseEnd < aStr.getLength() )
{
+ // tdf#143707 - Check if there was a data type character after the numeric constant,
+ // added by older versions of the fix of the default values for strings.
switch ( aStr[nParseEnd] )
{
// See GetSuffixType in basic/source/comp/scanner.cxx for type characters
@@ -2844,6 +2848,12 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
case 'b': eType = SbxBOOL; break;
}
}
+ // tdf#143707 - if the data type character is different from the default value, it was added
+ // in basic/source/comp/symtbl.cxx. Hence, change the type of the numeric constant to be loaded.
+ else if (eTypeStr != SbxSTRING)
+ {
+ eType = eTypeStr;
+ }
SbxVariable* p = new SbxVariable( eType );
p->PutDouble( n );
// tdf#133913 - create variable with Variant/Type in order to prevent type conversion errors
@@ -4179,9 +4189,15 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 )
sal_uInt16 nDefaultId = static_cast<sal_uInt16>(pParam->nUserData & 0x0ffff);
if( nDefaultId > 0 )
{
- OUString aDefaultStr = pImg->GetString( nDefaultId );
+ // tdf#143707 - check if the data type character was added after the string
+ // termination symbol, and convert the variable if it was present. The
+ // data type character was It was added in basic/source/comp/symtbl.cxx.
+ SbxDataType eTypeStr;
+ OUString aDefaultStr = pImg->GetString( nDefaultId, &eTypeStr );
pVar = new SbxVariable(pParam-> eType);
pVar->PutString( aDefaultStr );
+ if (eTypeStr != SbxSTRING)
+ pVar->Convert(eTypeStr);
refParams->Put(pVar, nIdx);
}
else if ( SbiRuntime::isVBAEnabled() && eType != SbxVARIANT )