update ooo310-m15
[ooovba.git] / applied_patches / 0394-vba-null-not-treatment.diff
blob9d7ee59c766118e714e5b5f7a6ffe0b1bd46aafe
1 diff --git basic/source/runtime/step0.cxx basic/source/runtime/step0.cxx
2 index 0666725..a2df718 100644
3 --- basic/source/runtime/step0.cxx
4 +++ basic/source/runtime/step0.cxx
5 @@ -118,8 +118,21 @@ void SbiRuntime::StepCompare( SbxOperato
6 #ifndef WIN
7 static SbxVariable* pTRUE = NULL;
8 static SbxVariable* pFALSE = NULL;
10 - if( p2->Compare( eOp, *p1 ) )
11 + static SbxVariable* pNULL = NULL;
12 + // why do this on non-windows ?
13 + // why do this at all ?
14 + // I dumbly follow the pattern :-/
15 + if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
16 + {
17 + if( !pNULL )
18 + {
19 + pNULL = new SbxVariable;
20 + pNULL->PutNull();
21 + pNULL->AddRef();
22 + }
23 + PushVar( pNULL );
24 + }
25 + else if( p2->Compare( eOp, *p1 ) )
27 if( !pTRUE )
29 @@ -140,9 +153,14 @@ void SbiRuntime::StepCompare( SbxOperato
30 PushVar( pFALSE );
32 #else
33 - BOOL bRes = p2->Compare( eOp, *p1 );
34 SbxVariable* pRes = new SbxVariable;
35 - pRes->PutBool( bRes );
36 + if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
37 + pRes->PutNull();
38 + else
39 + {
40 + BOOL bRes = p2->Compare( eOp, *p1 );
41 + pRes->PutBool( bRes );
42 + }
43 PushVar( pRes );
44 #endif
46 diff --git basic/source/runtime/step1.cxx basic/source/runtime/step1.cxx
47 index 8a4adfa..57d7f02 100644
48 --- basic/source/runtime/step1.cxx
49 +++ basic/source/runtime/step1.cxx
50 @@ -192,7 +192,9 @@ void SbiRuntime::StepJUMPT( UINT32 nOp1 )
51 void SbiRuntime::StepJUMPF( UINT32 nOp1 )
53 SbxVariableRef p = PopVar();
54 - if( !p->GetBool() )
55 + // In a test e.g. If Null then
56 + // will evaluate Null will act as if False
57 + if( ( bVBAEnabled && p->IsNull() ) || !p->GetBool() )
58 StepJUMP( nOp1 );
61 diff --git basic/source/sbx/sbxvalue.cxx basic/source/sbx/sbxvalue.cxx
62 index 37e9523..5447439 100644
63 --- basic/source/sbx/sbxvalue.cxx
64 +++ basic/source/sbx/sbxvalue.cxx
65 @@ -1195,6 +1195,8 @@ BOOL SbxValue::Compute( SbxOperator eOp,
66 aL.eType = aR.eType = GetType();
67 // else if( GetType() == SbxDouble || GetType() == SbxSingle )
68 // aL.eType = aR.eType = SbxLONG64;
69 + else if ( bVBAInterop && eOpType == SbxBOOL )
70 + aL.eType = aR.eType = SbxBOOL;
71 else
72 aL.eType = aR.eType = SbxLONG;
74 @@ -1281,7 +1283,12 @@ BOOL SbxValue::Compute( SbxOperator eOp,
75 break;
76 case SbxNOT:
77 if( aL.eType != SbxLONG && aL.eType != SbxULONG )
78 - aL.nLong64 = ~aL.nLong64;
79 + {
80 + if ( aL.eType != SbxBOOL )
81 + aL.nLong64 = ~aL.nLong64;
82 + else
83 + aL.nLong = ~aL.nLong;
84 + }
85 else
86 aL.nLong = ~aL.nLong;
87 break;