Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <stdlib.h>
22 : : #include <rtl/math.hxx>
23 : : #include <basic/sbuno.hxx>
24 : : #include "runtime.hxx"
25 : : #include "sbintern.hxx"
26 : : #include "iosys.hxx"
27 : : #include "image.hxx"
28 : : #include "sbunoobj.hxx"
29 : : #include "errobject.hxx"
30 : :
31 : : bool checkUnoObjectType( SbUnoObject* refVal, const ::rtl::OUString& aClass );
32 : :
33 : : // loading a numeric constant (+ID)
34 : :
35 : 0 : void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
36 : : {
37 [ # # ][ # # ]: 0 : SbxVariable* p = new SbxVariable( SbxDOUBLE );
38 : :
39 : : // #57844 use localized function
40 [ # # ]: 0 : String aStr = pImg->GetString( static_cast<short>( nOp1 ) );
41 : : // also allow , !!!
42 [ # # ]: 0 : sal_uInt16 iComma = aStr.Search( ',' );
43 [ # # ]: 0 : if( iComma != STRING_NOTFOUND )
44 : : {
45 [ # # ]: 0 : String aStr1 = aStr.Copy( 0, iComma );
46 [ # # ]: 0 : String aStr2 = aStr.Copy( iComma + 1 );
47 [ # # ]: 0 : aStr = aStr1;
48 [ # # ]: 0 : aStr += '.';
49 [ # # ][ # # ]: 0 : aStr += aStr2;
[ # # ]
50 : : }
51 [ # # ]: 0 : double n = ::rtl::math::stringToDouble( aStr, '.', ',', NULL, NULL );
52 : :
53 [ # # ]: 0 : p->PutDouble( n );
54 [ # # ][ # # ]: 0 : PushVar( p );
55 : 0 : }
56 : :
57 : : // loading a string constant (+ID)
58 : :
59 : 1902 : void SbiRuntime::StepLOADSC( sal_uInt32 nOp1 )
60 : : {
61 [ + - ]: 1902 : SbxVariable* p = new SbxVariable;
62 [ + - ][ + - ]: 1902 : p->PutString( pImg->GetString( static_cast<short>( nOp1 ) ) );
63 : 1902 : PushVar( p );
64 : 1902 : }
65 : :
66 : : // Immediate Load (+Wert)
67 : :
68 : 2268 : void SbiRuntime::StepLOADI( sal_uInt32 nOp1 )
69 : : {
70 [ + - ]: 2268 : SbxVariable* p = new SbxVariable;
71 : 2268 : p->PutInteger( static_cast<sal_Int16>( nOp1 ) );
72 : 2268 : PushVar( p );
73 : 2268 : }
74 : :
75 : : // stora a named argument in Argv (+Arg-no. from 1!)
76 : :
77 : 40 : void SbiRuntime::StepARGN( sal_uInt32 nOp1 )
78 : : {
79 [ - + ]: 40 : if( !refArgv )
80 : 0 : StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
81 : : else
82 : : {
83 [ + - ]: 40 : String aAlias( pImg->GetString( static_cast<short>( nOp1 ) ) );
84 [ + - ]: 40 : SbxVariableRef pVal = PopVar();
85 [ + - ][ + - ]: 40 : if( bVBAEnabled && ( pVal->ISA(SbxMethod) || pVal->ISA(SbUnoProperty) || pVal->ISA(SbProcedureProperty) ) )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ - + ]
86 : : {
87 : : // named variables ( that are Any especially properties ) can be empty at this point and need a broadcast
88 [ # # ][ # # ]: 0 : if ( pVal->GetType() == SbxEMPTY )
89 [ # # ]: 0 : pVal->Broadcast( SBX_HINT_DATAWANTED );
90 : : // evaluate methods and properties!
91 [ # # ][ # # ]: 0 : SbxVariable* pRes = new SbxVariable( *pVal );
92 [ # # ]: 0 : pVal = pRes;
93 : : }
94 [ + - ]: 40 : refArgv->Put( pVal, nArgc );
95 [ + - ][ + - ]: 40 : refArgv->PutAlias( aAlias, nArgc++ );
[ + - ]
96 : : }
97 : 40 : }
98 : :
99 : : // converting the type of an argument in Argv for DECLARE-Fkt. (+type)
100 : :
101 : 0 : void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 )
102 : : {
103 [ # # ]: 0 : if( !refArgv )
104 : 0 : StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
105 : : else
106 : : {
107 : 0 : bool bByVal = (nOp1 & 0x8000) != 0; // Ist BYVAL requested?
108 : 0 : SbxDataType t = (SbxDataType) (nOp1 & 0x7FFF);
109 : 0 : SbxVariable* pVar = refArgv->Get( refArgv->Count() - 1 ); // last Arg
110 : :
111 : : // check BYVAL
112 [ # # ]: 0 : if( pVar->GetRefCount() > 2 ) // 2 is normal for BYVAL
113 : : {
114 : : // parameter is a reference
115 [ # # ]: 0 : if( bByVal )
116 : : {
117 : : // Call by Value is requested -> create a copy
118 [ # # ]: 0 : pVar = new SbxVariable( *pVar );
119 : 0 : pVar->SetFlag( SBX_READWRITE );
120 : 0 : refExprStk->Put( pVar, refArgv->Count() - 1 );
121 : : }
122 : : else
123 : 0 : pVar->SetFlag( SBX_REFERENCE ); // Ref-Flag for DllMgr
124 : : }
125 : : else
126 : : {
127 : : // parameter is NO reference
128 [ # # ]: 0 : if( bByVal )
129 : 0 : pVar->ResetFlag( SBX_REFERENCE ); // no reference -> OK
130 : : else
131 : 0 : Error( SbERR_BAD_PARAMETERS ); // reference needed
132 : : }
133 : :
134 [ # # ]: 0 : if( pVar->GetType() != t )
135 : : {
136 : : // variant for correct conversion
137 : : // besides error, if SbxBYREF
138 : 0 : pVar->Convert( SbxVARIANT );
139 : 0 : pVar->Convert( t );
140 : : }
141 : : }
142 : 0 : }
143 : :
144 : : // bring string to a definite length (+length)
145 : :
146 : 0 : void SbiRuntime::StepPAD( sal_uInt32 nOp1 )
147 : : {
148 : 0 : SbxVariable* p = GetTOS();
149 : 0 : String& s = (String&)(const String&) *p;
150 [ # # ]: 0 : if( s.Len() > nOp1 )
151 : 0 : s.Erase( static_cast<xub_StrLen>( nOp1 ) );
152 : : else
153 : 0 : s.Expand( static_cast<xub_StrLen>( nOp1 ), ' ' );
154 : 0 : }
155 : :
156 : : // jump (+target)
157 : :
158 : 3752 : void SbiRuntime::StepJUMP( sal_uInt32 nOp1 )
159 : : {
160 : : #ifdef DBG_UTIL
161 : : // #QUESTION shouln't this be
162 : : // if( (sal_uInt8*)( nOp1+pImagGetCode() ) >= pImg->GetCodeSize() )
163 : : if( nOp1 >= pImg->GetCodeSize() )
164 : : StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
165 : : #endif
166 : 3752 : pCode = (const sal_uInt8*) pImg->GetCode() + nOp1;
167 : 3752 : }
168 : :
169 : : // evaluate TOS, conditional jump (+target)
170 : :
171 : 0 : void SbiRuntime::StepJUMPT( sal_uInt32 nOp1 )
172 : : {
173 [ # # ]: 0 : SbxVariableRef p = PopVar();
174 [ # # ][ # # ]: 0 : if( p->GetBool() )
175 [ # # ]: 0 : StepJUMP( nOp1 );
176 : 0 : }
177 : :
178 : : // evaluate TOS, conditional jump (+target)
179 : :
180 : 1362 : void SbiRuntime::StepJUMPF( sal_uInt32 nOp1 )
181 : : {
182 [ + - ]: 1362 : SbxVariableRef p = PopVar();
183 : : // In a test e.g. If Null then
184 : : // will evaluate Null will act as if False
185 [ + + ][ + - ]: 1362 : if( ( bVBAEnabled && p->IsNull() ) || !p->GetBool() )
[ + - ][ + - ]
[ + + ][ + + ]
186 [ + - ]: 1362 : StepJUMP( nOp1 );
187 : 1362 : }
188 : :
189 : : // evaluate TOS, jump into JUMP-table (+MaxVal)
190 : : // looks like this:
191 : : // ONJUMP 2
192 : : // JUMP target1
193 : : // JUMP target2
194 : : // ...
195 : : // if 0x8000 is set in the operand, push the return address (ON..GOSUB)
196 : :
197 : 0 : void SbiRuntime::StepONJUMP( sal_uInt32 nOp1 )
198 : : {
199 [ # # ]: 0 : SbxVariableRef p = PopVar();
200 [ # # ]: 0 : sal_Int16 n = p->GetInteger();
201 [ # # ]: 0 : if( nOp1 & 0x8000 )
202 : : {
203 : 0 : nOp1 &= 0x7FFF;
204 [ # # ]: 0 : PushGosub( pCode + 5 * nOp1 );
205 : : }
206 [ # # ][ # # ]: 0 : if( n < 1 || static_cast<sal_uInt32>(n) > nOp1 )
207 : 0 : n = static_cast<sal_Int16>( nOp1 + 1 );
208 : 0 : nOp1 = (sal_uInt32) ( (const char*) pCode - pImg->GetCode() ) + 5 * --n;
209 [ # # ]: 0 : StepJUMP( nOp1 );
210 : 0 : }
211 : :
212 : : // UP-call (+target)
213 : :
214 : 0 : void SbiRuntime::StepGOSUB( sal_uInt32 nOp1 )
215 : : {
216 : 0 : PushGosub( pCode );
217 [ # # ]: 0 : if( nOp1 >= pImg->GetCodeSize() )
218 : 0 : StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
219 : 0 : pCode = (const sal_uInt8*) pImg->GetCode() + nOp1;
220 : 0 : }
221 : :
222 : : // UP-return (+0 or target)
223 : :
224 : 0 : void SbiRuntime::StepRETURN( sal_uInt32 nOp1 )
225 : : {
226 : 0 : PopGosub();
227 [ # # ]: 0 : if( nOp1 )
228 : 0 : StepJUMP( nOp1 );
229 : 0 : }
230 : :
231 : : // check FOR-variable (+Endlabel)
232 : :
233 : 484 : void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
234 : : {
235 [ - + ]: 484 : if( !pForStk )
236 : : {
237 : 0 : StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
238 : 484 : return;
239 : : }
240 : :
241 : 484 : bool bEndLoop = false;
242 [ + - - - : 484 : switch( pForStk->eForType )
- ]
243 : : {
244 : : case FOR_TO:
245 : : {
246 [ - + ]: 484 : SbxOperator eOp = ( pForStk->refInc->GetDouble() < 0 ) ? SbxLT : SbxGT;
247 [ + + ]: 484 : if( pForStk->refVar->Compare( eOp, *pForStk->refEnd ) )
248 : 64 : bEndLoop = true;
249 : 484 : break;
250 : : }
251 : : case FOR_EACH_ARRAY:
252 : : {
253 : 0 : SbiForStack* p = pForStk;
254 [ # # ]: 0 : if( p->pArrayCurIndices == NULL )
255 : : {
256 : 0 : bEndLoop = true;
257 : : }
258 : : else
259 : : {
260 : 0 : SbxDimArray* pArray = (SbxDimArray*)(SbxVariable*)p->refEnd;
261 : 0 : short nDims = pArray->GetDims();
262 : :
263 : : // Empty array?
264 [ # # ][ # # ]: 0 : if( nDims == 1 && p->pArrayLowerBounds[0] > p->pArrayUpperBounds[0] )
265 : : {
266 : 0 : bEndLoop = true;
267 : 0 : break;
268 : : }
269 : 0 : SbxVariable* pVal = pArray->Get32( p->pArrayCurIndices );
270 : 0 : *(p->refVar) = *pVal;
271 : :
272 : 0 : bool bFoundNext = false;
273 [ # # ]: 0 : for( short i = 0 ; i < nDims ; i++ )
274 : : {
275 [ # # ]: 0 : if( p->pArrayCurIndices[i] < p->pArrayUpperBounds[i] )
276 : : {
277 : 0 : bFoundNext = true;
278 : 0 : p->pArrayCurIndices[i]++;
279 [ # # ]: 0 : for( short j = i - 1 ; j >= 0 ; j-- )
280 : 0 : p->pArrayCurIndices[j] = p->pArrayLowerBounds[j];
281 : 0 : break;
282 : : }
283 : : }
284 [ # # ]: 0 : if( !bFoundNext )
285 : : {
286 [ # # ]: 0 : delete[] p->pArrayCurIndices;
287 : 0 : p->pArrayCurIndices = NULL;
288 : : }
289 : : }
290 : 0 : break;
291 : : }
292 : : case FOR_EACH_COLLECTION:
293 : : {
294 : 0 : BasicCollection* pCollection = (BasicCollection*)(SbxVariable*)pForStk->refEnd;
295 : 0 : SbxArrayRef xItemArray = pCollection->xItemArray;
296 [ # # ]: 0 : sal_Int32 nCount = xItemArray->Count32();
297 [ # # ]: 0 : if( pForStk->nCurCollectionIndex < nCount )
298 : : {
299 [ # # ]: 0 : SbxVariable* pRes = xItemArray->Get32( pForStk->nCurCollectionIndex );
300 : 0 : pForStk->nCurCollectionIndex++;
301 [ # # ]: 0 : (*pForStk->refVar) = *pRes;
302 : : }
303 : : else
304 : : {
305 : 0 : bEndLoop = true;
306 : : }
307 [ # # ]: 0 : break;
308 : : }
309 : : case FOR_EACH_XENUMERATION:
310 : : {
311 : 0 : SbiForStack* p = pForStk;
312 [ # # ]: 0 : if( p->xEnumeration->hasMoreElements() )
313 : : {
314 [ # # ][ # # ]: 0 : Any aElem = p->xEnumeration->nextElement();
315 [ # # ][ # # ]: 0 : SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
316 [ # # ]: 0 : unoToSbxValue( (SbxVariable*)xVar, aElem );
317 [ # # ][ # # ]: 0 : (*pForStk->refVar) = *xVar;
318 : : }
319 : : else
320 : : {
321 : 0 : bEndLoop = true;
322 : : }
323 : 0 : break;
324 : : }
325 : : }
326 [ + + ]: 484 : if( bEndLoop )
327 : : {
328 : 64 : PopFor();
329 : 64 : StepJUMP( nOp1 );
330 : : }
331 : : }
332 : :
333 : : // Tos+1 <= Tos+2 <= Tos, 2xremove (+Target)
334 : :
335 : 0 : void SbiRuntime::StepCASETO( sal_uInt32 nOp1 )
336 : : {
337 [ # # ][ # # ]: 0 : if( !refCaseStk || !refCaseStk->Count() )
[ # # ]
338 : 0 : StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
339 : : else
340 : : {
341 [ # # ]: 0 : SbxVariableRef xTo = PopVar();
342 [ # # ]: 0 : SbxVariableRef xFrom = PopVar();
343 [ # # ][ # # ]: 0 : SbxVariableRef xCase = refCaseStk->Get( refCaseStk->Count() - 1 );
344 [ # # ][ # # ]: 0 : if( *xCase >= *xFrom && *xCase <= *xTo )
[ # # ][ # # ]
[ # # ]
345 [ # # ][ # # ]: 0 : StepJUMP( nOp1 );
[ # # ]
346 : : }
347 : 0 : }
348 : :
349 : :
350 : 30 : void SbiRuntime::StepERRHDL( sal_uInt32 nOp1 )
351 : : {
352 : 30 : const sal_uInt8* p = pCode;
353 : 30 : StepJUMP( nOp1 );
354 : 30 : pError = pCode;
355 : 30 : pCode = p;
356 [ + - ]: 30 : pInst->aErrorMsg = String();
357 : 30 : pInst->nErr = 0;
358 : 30 : pInst->nErl = 0;
359 : 30 : nError = 0;
360 [ + - ][ + - ]: 30 : SbxErrObject::getUnoErrObject()->Clear();
361 : 30 : }
362 : :
363 : : // Resume after errors (+0=statement, 1=next or Label)
364 : :
365 : 0 : void SbiRuntime::StepRESUME( sal_uInt32 nOp1 )
366 : : {
367 : : // #32714 Resume without error? -> error
368 [ # # ]: 0 : if( !bInError )
369 : : {
370 : 0 : Error( SbERR_BAD_RESUME );
371 : 0 : return;
372 : : }
373 [ # # ]: 0 : if( nOp1 )
374 : : {
375 : : // set Code-pointer to the next statement
376 : : sal_uInt16 n1, n2;
377 [ # # ]: 0 : pCode = pMod->FindNextStmnt( pErrCode, n1, n2, sal_True, pImg );
378 : : }
379 : : else
380 : 0 : pCode = pErrStmnt;
381 [ # # ]: 0 : if ( pError ) // current in error handler ( and got a Resume Next statment )
382 [ # # ][ # # ]: 0 : SbxErrObject::getUnoErrObject()->Clear();
383 : :
384 [ # # ]: 0 : if( nOp1 > 1 )
385 : 0 : StepJUMP( nOp1 );
386 [ # # ]: 0 : pInst->aErrorMsg = String();
387 : 0 : pInst->nErr = 0;
388 : 0 : pInst->nErl = 0;
389 : 0 : nError = 0;
390 : 0 : bInError = false;
391 : : }
392 : :
393 : : // close channel (+channel, 0=all)
394 : 22 : void SbiRuntime::StepCLOSE( sal_uInt32 nOp1 )
395 : : {
396 : : SbError err;
397 [ - + ]: 22 : if( !nOp1 )
398 : 0 : pIosys->Shutdown();
399 : : else
400 : : {
401 : 22 : err = pIosys->GetError();
402 [ + - ]: 22 : if( !err )
403 : : {
404 : 22 : pIosys->Close();
405 : : }
406 : : }
407 : 22 : err = pIosys->GetError();
408 : 22 : Error( err );
409 : 22 : }
410 : :
411 : : // output character (+char)
412 : :
413 : 184 : void SbiRuntime::StepPRCHAR( sal_uInt32 nOp1 )
414 : : {
415 : 184 : rtl::OString s(static_cast<sal_Char>(nOp1));
416 [ + - ]: 184 : pIosys->Write( s );
417 [ + - ][ + - ]: 184 : Error( pIosys->GetError() );
418 : 184 : }
419 : :
420 : : // check whether TOS is a certain object class (+StringID)
421 : :
422 : 6 : bool SbiRuntime::implIsClass( SbxObject* pObj, const ::rtl::OUString& aClass )
423 : : {
424 : 6 : bool bRet = true;
425 : :
426 [ + - ]: 6 : if( !aClass.isEmpty() )
427 : : {
428 : 6 : bRet = pObj->IsClass( aClass );
429 [ - + ]: 6 : if( !bRet )
430 : 0 : bRet = aClass.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("object") );
431 [ - + ]: 6 : if( !bRet )
432 : : {
433 [ # # ]: 0 : String aObjClass = pObj->GetClassName();
434 [ # # ][ # # ]: 0 : SbModule* pClassMod = GetSbData()->pClassFac->FindClass( aObjClass );
435 : : SbClassData* pClassData;
436 [ # # ][ # # ]: 0 : if( pClassMod && (pClassData=pClassMod->pClassData) != NULL )
[ # # ]
437 : : {
438 : : SbxVariable* pClassVar =
439 [ # # ]: 0 : pClassData->mxIfaces->Find( aClass, SbxCLASS_DONTCARE );
440 : 0 : bRet = (pClassVar != NULL);
441 [ # # ]: 0 : }
442 : : }
443 : : }
444 : 6 : return bRet;
445 : : }
446 : :
447 : 6 : bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal,
448 : : const ::rtl::OUString& aClass, bool bRaiseErrors, bool bDefault )
449 : : {
450 : 6 : bool bOk = bDefault;
451 : :
452 : 6 : SbxDataType t = refVal->GetType();
453 : 6 : SbxVariable* pVal = (SbxVariable*)refVal;
454 : : // we don't know the type of uno properties that are (maybevoid)
455 [ # # ][ - + ]: 6 : if ( t == SbxEMPTY && refVal->ISA(SbUnoProperty) )
[ - + ]
456 : : {
457 : 0 : SbUnoProperty* pProp = (SbUnoProperty*)pVal;
458 : 0 : t = pProp->getRealType();
459 : : }
460 [ + - ]: 6 : if( t == SbxOBJECT )
461 : : {
462 : : SbxObject* pObj;
463 [ - + ]: 6 : if( pVal->IsA( TYPE(SbxObject) ) )
464 : 0 : pObj = (SbxObject*) pVal;
465 : : else
466 : : {
467 : 6 : pObj = (SbxObject*) refVal->GetObject();
468 [ - + ][ - + ]: 6 : if( pObj && !pObj->IsA( TYPE(SbxObject) ) )
[ + - ]
469 : 0 : pObj = NULL;
470 : : }
471 [ + - ]: 6 : if( pObj )
472 : : {
473 [ - + ]: 6 : if( !implIsClass( pObj, aClass ) )
474 : : {
475 [ # # ][ # # ]: 0 : if ( bVBAEnabled && pObj->IsA( TYPE(SbUnoObject) ) )
[ # # ]
476 : : {
477 [ # # ][ # # ]: 0 : SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pObj);
478 : 0 : bOk = checkUnoObjectType( pUnoObj, aClass );
479 : : }
480 : : else
481 : 0 : bOk = false;
482 [ # # ]: 0 : if ( !bOk )
483 : : {
484 [ # # ]: 0 : if( bRaiseErrors )
485 : 0 : Error( SbERR_INVALID_USAGE_OBJECT );
486 : : }
487 : : }
488 : : else
489 : : {
490 : 6 : bOk = true;
491 : :
492 [ + - ][ - + ]: 6 : SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pObj);
493 [ - + ]: 6 : if( pClassModuleObject != NULL )
494 : 0 : pClassModuleObject->triggerInitializeEvent();
495 : : }
496 : : }
497 : : }
498 : : else
499 : : {
500 [ # # ]: 0 : if ( !bVBAEnabled )
501 : : {
502 [ # # ]: 0 : if( bRaiseErrors )
503 : 0 : Error( SbERR_NEEDS_OBJECT );
504 : 0 : bOk = false;
505 : : }
506 : : }
507 : 6 : return bOk;
508 : : }
509 : :
510 : 6 : void SbiRuntime::StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt )
511 : : {
512 [ + - ]: 6 : SbxVariableRef refVal = PopVar();
513 [ + - ]: 6 : SbxVariableRef refVar = PopVar();
514 [ + - ]: 6 : String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
515 : :
516 [ + - ][ + - ]: 6 : bool bOk = checkClass_Impl( refVal, aClass, true );
517 [ + - ]: 6 : if( bOk )
518 [ + - ][ + - ]: 6 : StepSET_Impl( refVal, refVar, bHandleDflt ); // don't do handle dflt prop for a "proper" set
[ + - ][ + - ]
519 : 6 : }
520 : :
521 : 0 : void SbiRuntime::StepVBASETCLASS( sal_uInt32 nOp1 )
522 : : {
523 : 0 : StepSETCLASS_impl( nOp1, false );
524 : 0 : }
525 : :
526 : 6 : void SbiRuntime::StepSETCLASS( sal_uInt32 nOp1 )
527 : : {
528 : 6 : StepSETCLASS_impl( nOp1, true );
529 : 6 : }
530 : :
531 : 0 : void SbiRuntime::StepTESTCLASS( sal_uInt32 nOp1 )
532 : : {
533 [ # # ]: 0 : SbxVariableRef xObjVal = PopVar();
534 [ # # ]: 0 : String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
535 : 0 : bool bDefault = !bVBAEnabled;
536 [ # # ][ # # ]: 0 : bool bOk = checkClass_Impl( xObjVal, aClass, false, bDefault );
537 : :
538 [ # # ][ # # ]: 0 : SbxVariable* pRet = new SbxVariable;
539 [ # # ]: 0 : pRet->PutBool( bOk );
540 [ # # ][ # # ]: 0 : PushVar( pRet );
[ # # ]
541 : 0 : }
542 : :
543 : : // define library for following declare-call
544 : :
545 : 0 : void SbiRuntime::StepLIB( sal_uInt32 nOp1 )
546 : : {
547 [ # # ]: 0 : aLibName = pImg->GetString( static_cast<short>( nOp1 ) );
548 : 0 : }
549 : :
550 : : // TOS is incremented by BASE, BASE is pushed before (+BASE)
551 : : // This opcode is pushed before DIM/REDIM-commands,
552 : : // if there's been only one index named.
553 : :
554 : 72 : void SbiRuntime::StepBASED( sal_uInt32 nOp1 )
555 : : {
556 [ + - ][ + - ]: 72 : SbxVariable* p1 = new SbxVariable;
557 [ + - ]: 72 : SbxVariableRef x2 = PopVar();
558 : :
559 : : // #109275 Check compatiblity mode
560 : 72 : bool bCompatible = ((nOp1 & 0x8000) != 0);
561 : 72 : sal_uInt16 uBase = static_cast<sal_uInt16>(nOp1 & 1); // Can only be 0 or 1
562 [ + - ]: 72 : p1->PutInteger( uBase );
563 [ + - ]: 72 : if( !bCompatible )
564 [ + - ]: 72 : x2->Compute( SbxPLUS, *p1 );
565 [ + - ]: 72 : PushVar( x2 ); // first the Expr
566 [ + - ][ + - ]: 72 : PushVar( p1 ); // then the Base
567 : 72 : }
568 : :
569 : :
570 : :
571 : :
572 : :
573 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|