From a2baea7faff31d26459dab3668a39eae85e4991b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:27:30 +0200 Subject: Adding upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- scripting/source/basprov/basscript.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'scripting') diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index de50f62e11..148d1877d8 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -41,6 +41,17 @@ using namespace ::com::sun::star::document; using namespace ::com::sun::star::beans; +static void ChangeTypeKeepingValue(SbxVariable& var, SbxDataType to) +{ + SbxValues val(to); + var.Get(val); + bool bSetFlag = var.IsSet(SbxFlagBits::Fixed); + var.ResetFlag(SbxFlagBits::Fixed); + var.Put(val); + if (bSetFlag) + var.SetFlag(SbxFlagBits::Fixed); +} + namespace basprov { @@ -218,14 +229,14 @@ constexpr OUString BASSCRIPT_PROPERTY_CALLER = u"Caller"_ustr; { sal_Int32 val = xSbxVar->GetLong(); if (val >= -16777216 && val <= 16777215) - xSbxVar->SetType(t); + ChangeTypeKeepingValue(*xSbxVar, t); } else if (t == SbxDOUBLE && (a == SbxINTEGER || a == SbxLONG)) - xSbxVar->SetType(t); + ChangeTypeKeepingValue(*xSbxVar, t); else if (t == SbxLONG && a == SbxINTEGER) - xSbxVar->SetType(t); + ChangeTypeKeepingValue(*xSbxVar, t); else if (t == SbxULONG && a == SbxUSHORT) - xSbxVar->SetType(t); + ChangeTypeKeepingValue(*xSbxVar, t); // Enable passing by ref if (t != SbxVARIANT) xSbxVar->SetFlag(SbxFlagBits::Fixed); -- cgit v1.2.3