diff options
author | Eike Rathke <erack@redhat.com> | 2019-05-02 20:54:16 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-05-02 22:35:35 +0200 |
commit | 15c39bb2e75df40c30bcbf789d815376dd2e31ce (patch) | |
tree | 34a73fa514bd35d05c5230c26d3fc3ee4a240b1e /basic/source/sbx | |
parent | 47a1a7f181eb93759f47109c4402cbef392bab1c (diff) |
Resolves: tdf#124605 ditch "if operand 1 is Empty, result is operand 2"
It has been like that since the initial import but is utter
nonsense. It might had (doubtfully) served some early StarBasic
compatibility quirk, but is wrong and was implementation defined
buggy behaviour. The Option VBASupport 1 even explicitly disabled
it.
In future we may want to implement the VBA Nothing value for an
SbxEMPTY at least for boolean operators, but this for Calc user
defined macro functions might even need a distinguished
SbxEMPTYCELL or such. Or an explicit SbxNOTHING.
Change-Id: I28919d982d0e60b9b840a12271dc717effa59662
Reviewed-on: https://gerrit.libreoffice.org/71701
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'basic/source/sbx')
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index b92d43d2d688..8b0f16491633 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -821,12 +821,6 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) // Special rule 1: If one operand is null, the result is null else if( eThisType == SbxNULL || eOpType == SbxNULL ) SetType( SbxNULL ); - // Special rule 2: If the operand is Empty, the result is the 2. operand - else if( eThisType == SbxEMPTY - && !bVBAInterop - ) - *this = rOp; - // 1996-2-13: Don't test for SbxEMPTY before Get else { SbxValues aL, aR; @@ -846,7 +840,7 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) rOp.Get( aR ); // From 1999-12-8, #70399: Here call GetType() again, Get() can change the type! if( rOp.GetType() == SbxEMPTY ) - goto Lbl_OpIsEmpty; + goto Lbl_OpIsEmpty; // concatenate empty, *this stays lhs as result Get( aL ); // #30576: To begin with test, if the conversion worked @@ -891,13 +885,18 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) if( rOp.Get( aR ) ) // re-do Get after type assigns above { - if( rOp.GetType() == SbxEMPTY ) - { - if ( !bVBAInterop || ( eOp != SbxNOT ) ) - goto Lbl_OpIsEmpty; - } if( Get( aL ) ) switch( eOp ) { + /* TODO: For SbxEMPTY operands with boolean operators use + * the VBA Nothing definition of Comparing Nullable Types? + * https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/data-types/nullable-value-types + */ + /* TODO: it is unclear yet whether this also should be done + * for the non-bVBAInterop case or not, or at all, consider + * user defined spreadsheet functions where an empty cell + * is SbxEMPTY and usually is treated as 0 zero or "" empty + * string. + */ case SbxIDIV: if( aL.eType == SbxCURRENCY ) if( !aR.nInt64 ) SetError( ERRCODE_BASIC_ZERODIV ); @@ -984,11 +983,6 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) bDecimal = true; if( rOp.Get( aR ) ) { - if( rOp.GetType() == SbxEMPTY ) - { - releaseDecimalPtr( aL.pDecimal ); - goto Lbl_OpIsEmpty; - } if( Get( aL ) ) { if( aL.pDecimal && aR.pDecimal ) @@ -1034,9 +1028,6 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) if( rOp.Get( aR ) ) { - if( rOp.GetType() == SbxEMPTY ) - goto Lbl_OpIsEmpty; - if( Get( aL ) ) switch( eOp ) { case SbxMUL: @@ -1127,11 +1118,6 @@ Lbl_OpIsDouble: aL.eType = aR.eType = SbxDOUBLE; if( rOp.Get( aR ) ) { - if( rOp.GetType() == SbxEMPTY ) - { - if ( !bVBAInterop || ( eOp != SbxNEG ) ) - goto Lbl_OpIsEmpty; - } if( Get( aL ) ) { switch( eOp ) |