summaryrefslogtreecommitdiff
path: root/basic/source/sbx/sbxvalue.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/sbx/sbxvalue.cxx')
-rw-r--r--basic/source/sbx/sbxvalue.cxx84
1 files changed, 44 insertions, 40 deletions
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index e67044def3f3..d644ca0c3c73 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -30,17 +30,19 @@
#include <basic/sbx.hxx>
#include <sbunoobj.hxx>
#include "sbxconv.hxx"
+#include <rtlproto.hxx>
#include <runtime.hxx>
+#include <filefmt.hxx>
///////////////////////////// constructors
-SbxValue::SbxValue() : SbxBase()
+SbxValue::SbxValue()
{
aData.eType = SbxEMPTY;
}
-SbxValue::SbxValue( SbxDataType t ) : SbxBase()
+SbxValue::SbxValue( SbxDataType t )
{
int n = t & 0x0FFF;
@@ -137,7 +139,8 @@ SbxValue& SbxValue::operator=( const SbxValue& r )
SbxValue::~SbxValue()
{
SetFlag( SbxFlagBits::Write );
- SbxValue::Clear();
+ // cid#1486004 silence Uncaught exception
+ suppress_fun_call_w_exception(SbxValue::Clear());
}
void SbxValue::Clear()
@@ -685,40 +688,40 @@ bool SbxValue::SetType( SbxDataType t )
}
t = SbxEMPTY;
}
- if( ( t & 0x0FFF ) != ( aData.eType & 0x0FFF ) )
+ if( ( t & 0x0FFF ) == ( aData.eType & 0x0FFF ) )
+ return true;
+
+ if( !CanWrite() || IsFixed() )
{
- if( !CanWrite() || IsFixed() )
- {
- SetError( ERRCODE_BASIC_CONVERSION );
- return false;
- }
- else
+ SetError( ERRCODE_BASIC_CONVERSION );
+ return false;
+ }
+ else
+ {
+ // De-allocate potential objects
+ switch( aData.eType )
{
- // De-allocate potential objects
- switch( aData.eType )
- {
- case SbxSTRING:
- delete aData.pOUString;
- break;
- case SbxOBJECT:
- if( aData.pObj && aData.pObj != this )
- {
- SAL_WARN("basic.sbx", "Not at Parent-Prop - otherwise CyclicRef");
- SbxVariable *pThisVar = dynamic_cast<SbxVariable*>( this );
- sal_uInt32 nSlotId = pThisVar
- ? pThisVar->GetUserData() & 0xFFFF
- : 0;
- DBG_ASSERT( nSlotId != 5345 || pThisVar->GetName() == "Parent",
- "SID_PARENTOBJECT is not named 'Parent'" );
- bool bParentProp = nSlotId == 5345;
- if ( !bParentProp )
- aData.pObj->ReleaseRef();
- }
- break;
- default: break;
- }
- aData.clear(t);
+ case SbxSTRING:
+ delete aData.pOUString;
+ break;
+ case SbxOBJECT:
+ if( aData.pObj && aData.pObj != this )
+ {
+ SAL_WARN("basic.sbx", "Not at Parent-Prop - otherwise CyclicRef");
+ SbxVariable *pThisVar = dynamic_cast<SbxVariable*>( this );
+ sal_uInt32 nSlotId = pThisVar
+ ? pThisVar->GetUserData() & 0xFFFF
+ : 0;
+ DBG_ASSERT( nSlotId != 5345 || pThisVar->GetName() == "Parent",
+ "SID_PARENTOBJECT is not named 'Parent'" );
+ bool bParentProp = nSlotId == 5345;
+ if ( !bParentProp )
+ aData.pObj->ReleaseRef();
+ }
+ break;
+ default: break;
}
+ aData.clear(t);
}
return true;
}
@@ -841,7 +844,8 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp )
if( GetType() == SbxSALUINT64 || GetType() == SbxSALINT64
|| GetType() == SbxCURRENCY || GetType() == SbxULONG )
aL.eType = aR.eType = GetType();
- else if ( bVBAInterop && eOpType == SbxBOOL )
+ // tdf#145960 - return type of boolean operators should be of type boolean
+ else if ( eOpType == SbxBOOL && eOp != SbxMOD && eOp != SbxIDIV )
aL.eType = aR.eType = SbxBOOL;
else
aL.eType = aR.eType = SbxLONG;
@@ -1323,7 +1327,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
RTL_TEXTENCODING_ASCII_US);
double d;
SbxDataType t;
- if( ImpScan( aVal, d, t, nullptr, true ) != ERRCODE_NONE || t == SbxDOUBLE )
+ if( ImpScan( aVal, d, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE || t == SbxDOUBLE )
{
aData.nSingle = 0.0F;
return false;
@@ -1338,7 +1342,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
OUString aVal = read_uInt16_lenPrefixed_uInt8s_ToOUString(r,
RTL_TEXTENCODING_ASCII_US);
SbxDataType t;
- if( ImpScan( aVal, aData.nDouble, t, nullptr, true ) != ERRCODE_NONE )
+ if( ImpScan( aVal, aData.nDouble, t, nullptr, !LibreOffice6FloatingPointMode() ) != ERRCODE_NONE )
{
aData.nDouble = 0.0;
return false;
@@ -1463,7 +1467,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
return true;
}
- bool SbxValue::StoreData( SvStream& r ) const
+ std::pair<bool, sal_uInt32> SbxValue::StoreData( SvStream& r ) const
{
sal_uInt16 nType = sal::static_int_cast< sal_uInt16 >(aData.eType);
r.WriteUInt16( nType );
@@ -1557,9 +1561,9 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
break;
default:
SAL_WARN( "basic.sbx", "Saving a non-supported data type" );
- return false;
+ return { false, 0 };
}
- return true;
+ return { true, B_IMG_VERSION_12 };
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */