Update to m13
[ooovba.git] / applied_patches / 0423-vba-allow-arrays-in-usertypes.diff
blob1cd4b84e4176d31603e7cc0167d7209606e77866
1 diff --git basic/source/classes/sb.cxx basic/source/classes/sb.cxx
2 index 6cce61d..7a66707 100644
3 --- basic/source/classes/sb.cxx
4 +++ basic/source/classes/sb.cxx
5 @@ -340,6 +340,32 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj )
6 if( pProp )
8 SbxProperty* pNewProp = new SbxProperty( *pProp );
9 + if( pVar->GetType() & SbxARRAY )
10 + {
11 + SbxBase* pParObj = pVar->GetObject();
12 + SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj);
13 + SbxDimArray* pDest = new SbxDimArray( pVar->GetType() );
14 + INT32 lb = 0;
15 + INT32 ub = 0;
17 + pDest->setHasFixedSize( pSource->hasFixedSize() );
18 + if ( pSource->GetDims() && pSource->hasFixedSize() )
19 + {
20 + for ( INT32 i=1; i <= pSource->GetDims(); ++i )
21 + {
22 + pSource->GetDim32( (INT32)i, lb, ub );
23 + pDest->AddDim32( lb, ub );
24 + }
25 + }
26 + else
27 + pDest->unoAddDim( 0, -1 ); // variant array
28 + USHORT nSavFlags = pVar->GetFlags();
29 + pNewProp->ResetFlag( SBX_FIXED );
30 + // need to reset the FIXED flag
31 + // when calling PutObject ( because the type will not match Object )
32 + pNewProp->PutObject( pDest );
33 + pNewProp->SetFlags( nSavFlags );
34 + }
35 pProps->PutDirect( pNewProp, i );
38 diff --git basic/source/comp/dim.cxx basic/source/comp/dim.cxx
39 index 3e46579..b37ff96 100644
40 --- basic/source/comp/dim.cxx
41 +++ basic/source/comp/dim.cxx
42 @@ -579,13 +579,6 @@ void SbiParser::DefType( BOOL bPrivate )
43 pElem = VarDecl(&pDim,FALSE,FALSE);
44 if( !pElem )
45 bDone = TRUE; // Error occured
46 - if( pDim )
47 - {
48 - // HOT FIX, to be updated
49 - delete pDim;
50 - Error( SbERR_NO_STRINGS_ARRAYS );
51 - }
54 if( pElem )
56 @@ -595,6 +588,44 @@ void SbiParser::DefType( BOOL bPrivate )
57 else
59 SbxProperty *pTypeElem = new SbxProperty (pElem->GetName(),pElem->GetType());
60 + if( pDim )
61 + {
62 + SbxDimArray* pArray = new SbxDimArray( pElem->GetType() );
63 + if ( pDim->GetSize() )
64 + {
65 + // Dimension the target array
67 + for ( int i=0; i<pDim->GetSize();++i )
68 + {
70 + INT32 ub = -1;
71 + INT32 lb = nBase;
72 + SbiExprNode* pNode = pDim->Get(i)->GetExprNode();
73 + ub = pNode->GetNumber();
74 + if ( !pDim->Get( i )->IsBased() ) // each dim is low/up
75 + {
76 + if ( ++i >= pDim->GetSize() ) // trouble
77 + StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
78 + pNode = pDim->Get(i)->GetExprNode();
79 + lb = ub;
80 + ub = pNode->GetNumber();
81 + }
82 + else if ( !bCompatible )
83 + ub += nBase;
84 + pArray->AddDim32( lb, ub );
85 + }
86 + pArray->setHasFixedSize( true );
87 + }
88 + else
89 + pArray->unoAddDim( 0, -1 ); // variant array
90 + USHORT nSavFlags = pTypeElem->GetFlags();
91 + // need to reset the FIXED flag
92 + // when calling PutObject ( because the type will not match Object )
93 + pTypeElem->ResetFlag( SBX_FIXED );
94 + pTypeElem->PutObject( pArray );
95 + pTypeElem->SetFlags( nSavFlags );
96 + }
97 + delete pDim;
98 pTypeMembers->Insert( pTypeElem, pTypeMembers->Count() );
100 delete pElem;
101 diff --git basic/source/inc/expr.hxx basic/source/inc/expr.hxx
102 index d31e741..c87b2e5 100644
103 --- basic/source/inc/expr.hxx
104 +++ basic/source/inc/expr.hxx
105 @@ -144,6 +144,7 @@ public:
106 SbiExprNode* GetRealNode(); // letzter Knoten in x.y.z
107 short GetDepth(); // Tiefe eines Baumes berechnen
108 const String& GetString() { return aStrVal; }
109 + short GetNumber() { return (short)nVal; }
110 SbiExprList* GetParameters() { return aVar.pPar; }
111 SbiExprListVector* GetMoreParameters() { return aVar.pvMorePar; }