update ooo310-m15
[ooovba.git] / applied_patches / 0431-vba-redim-array-fix.diff
blob232c91fbd9ed62f0bc9e6cac46ac417f3dc9bebc
1 diff --git basic/source/inc/runtime.hxx basic/source/inc/runtime.hxx
2 index 5a1bff2..6384306 100644
3 --- basic/source/inc/runtime.hxx
4 +++ basic/source/inc/runtime.hxx
5 @@ -315,6 +315,7 @@ class SbiRuntime
6 SbxArrayRef refExprStk; // expression stack
7 SbxArrayRef refCaseStk; // CASE expression stack
8 SbxArrayRef refRedimpArray; // Array saved to use for REDIM PRESERVE
9 + SbxVariableRef refRedim; // Array saved to use for REDIM
10 SbxVariableRef xDummyVar; // Ersatz fuer nicht gefundene Variablen
11 SbxVariable* mpExtCaller; // Caller ( external - e.g. button name, shape, range object etc. - only in vba mode )
12 SbiArgvStack* pArgvStk; // ARGV-Stack
13 diff --git basic/source/runtime/step0.cxx basic/source/runtime/step0.cxx
14 index a2df718..fa66194 100644
15 --- basic/source/runtime/step0.cxx
16 +++ basic/source/runtime/step0.cxx
17 @@ -48,6 +48,11 @@
19 #include <algorithm>
21 +// for a patch forward declaring these methods below makes sense
22 +// but, #FIXME lets really just move the methods to the top
23 +void lcl_clearImpl( SbxVariableRef& refVar, SbxDataType& eType );
24 +void lcl_eraseImpl( SbxVariableRef& refVar, bool bVBAEnabled );
26 SbxVariable* getDefaultProp( SbxVariable* pRef );
28 void SbiRuntime::StepNOP()
29 @@ -637,6 +642,17 @@ void SbiRuntime::StepDIM()
30 // #56204 DIM-Funktionalitaet in Hilfsmethode auslagern (step0.cxx)
31 void SbiRuntime::DimImpl( SbxVariableRef refVar )
33 + // If refDim then this DIM statement is terminating a ReDIM and
34 + // previous StepERASE_CLEAR for an array, the following actions have
35 + // been delayed from ( StepERASE_CLEAR ) 'till here
36 + if ( refRedim )
37 + {
38 + if ( !refRedimpArray ) // only erase the array not ReDim Preserve
39 + lcl_eraseImpl( refVar, bVBAEnabled );
40 + SbxDataType eType = refVar->GetType();
41 + lcl_clearImpl( refVar, eType );
42 + refRedim = NULL;
43 + }
44 SbxArray* pDims = refVar->GetParameters();
45 // Muss eine gerade Anzahl Argumente haben
46 // Man denke daran, dass Arg[0] nicht zaehlt!
47 @@ -802,6 +818,7 @@ void SbiRuntime::StepREDIMP()
48 void SbiRuntime::StepREDIMP_ERASE()
50 SbxVariableRef refVar = PopVar();
51 + refRedim = refVar;
52 SbxDataType eType = refVar->GetType();
53 if( eType & SbxARRAY )
55 @@ -812,12 +829,6 @@ void SbiRuntime::StepREDIMP_ERASE()
56 refRedimpArray = pDimArray;
59 - // As in ERASE
60 - USHORT nSavFlags = refVar->GetFlags();
61 - refVar->ResetFlag( SBX_FIXED );
62 - refVar->SetType( SbxDataType(eType & 0x0FFF) );
63 - refVar->SetFlags( nSavFlags );
64 - refVar->Clear();
66 else
67 if( refVar->IsFixed() )
68 @@ -890,10 +901,7 @@ void SbiRuntime::StepERASE()
70 void SbiRuntime::StepERASE_CLEAR()
72 - SbxVariableRef refVar = PopVar();
73 - lcl_eraseImpl( refVar, bVBAEnabled );
74 - SbxDataType eType = refVar->GetType();
75 - lcl_clearImpl( refVar, eType );
76 + refRedim = PopVar();
79 void SbiRuntime::StepARRAYACCESS()
80 diff --git basic/source/runtime/step2.cxx basic/source/runtime/step2.cxx
81 index 5606274..8e82cbf 100644
82 --- basic/source/runtime/step2.cxx
83 +++ basic/source/runtime/step2.cxx
84 @@ -458,7 +458,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
86 // Falls wir ein Array haben, wollen wir bitte das Array-Element!
87 SbxArray* pPar;
88 - if( pElem->GetType() & SbxARRAY )
89 + if( ( pElem->GetType() & SbxARRAY ) && (SbxVariable*)refRedim != pElem )
91 SbxBase* pElemObj = pElem->GetObject();
92 SbxDimArray* pDimArray = PTR_CAST(SbxDimArray,pElemObj);