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