tdf#84938 Change average enum for scoped enum

This is a [partial] patch for tdf#84938, involving the substitution of an average enum for a scoped one.

Change-Id: I4b3a19914d30a14dec2640355ba392b943e1ddd7
Reviewed-on: https://gerrit.libreoffice.org/22808
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
baltasarq
2016-03-01 13:14:39 +01:00
committed by Noel Grandin
parent 87629f39bb
commit d9dacecd90
2 changed files with 25 additions and 23 deletions

View File

@@ -48,12 +48,11 @@ class SbiDllMgr;
class SvNumberFormatter; // time/date functions class SvNumberFormatter; // time/date functions
enum class SbiImageFlags; enum class SbiImageFlags;
enum ForType enum class ForType {
{ To,
FOR_TO, EachArray,
FOR_EACH_ARRAY, EachCollection,
FOR_EACH_COLLECTION, EachXEnumeration
FOR_EACH_XENUMERATION
}; };
struct SbiForStack { // for/next stack: struct SbiForStack { // for/next stack:
@@ -72,12 +71,13 @@ struct SbiForStack { // for/next stack:
SbiForStack() SbiForStack()
: pNext(nullptr) : pNext(nullptr)
, eForType(FOR_TO) , eForType(ForType::To)
, nCurCollectionIndex(0) , nCurCollectionIndex(0)
, pArrayCurIndices(nullptr) , pArrayCurIndices(nullptr)
, pArrayLowerBounds(nullptr) , pArrayLowerBounds(nullptr)
, pArrayUpperBounds(nullptr) , pArrayUpperBounds(nullptr)
{} {}
~SbiForStack() ~SbiForStack()
{ {
delete[] pArrayCurIndices; delete[] pArrayCurIndices;
@@ -86,13 +86,14 @@ struct SbiForStack { // for/next stack:
} }
}; };
#define MAXRECURSION 500
struct SbiGosubStack { // GOSUB-Stack: struct SbiGosubStack { // GOSUB-Stack:
SbiGosubStack* pNext; // Chain SbiGosubStack* pNext; // Chain
const sal_uInt8* pCode; // Return-Pointer const sal_uInt8* pCode; // Return-Pointer
sal_uInt16 nStartForLvl; // #118235: For Level in moment of gosub sal_uInt16 nStartForLvl; // #118235: For Level in moment of gosub
}; };
#define MAXRECURSION 500
#define Sb_ATTR_READONLY 0x0001 #define Sb_ATTR_READONLY 0x0001
#define Sb_ATTR_HIDDEN 0x0002 #define Sb_ATTR_HIDDEN 0x0002

View File

@@ -1139,7 +1139,7 @@ void SbiRuntime::ClearArgvStack()
void SbiRuntime::PushFor() void SbiRuntime::PushFor()
{ {
SbiForStack* p = new SbiForStack; SbiForStack* p = new SbiForStack;
p->eForType = FOR_TO; p->eForType = ForType::To;
p->pNext = pForStk; p->pNext = pForStk;
pForStk = p; pForStk = p;
@@ -1168,7 +1168,7 @@ void SbiRuntime::PushForEach()
bool bError_ = false; bool bError_ = false;
if (SbxDimArray* pArray = dynamic_cast<SbxDimArray*>(pObj)) if (SbxDimArray* pArray = dynamic_cast<SbxDimArray*>(pObj))
{ {
p->eForType = FOR_EACH_ARRAY; p->eForType = ForType::EachArray;
p->refEnd = reinterpret_cast<SbxVariable*>(pArray); p->refEnd = reinterpret_cast<SbxVariable*>(pArray);
short nDims = pArray->GetDims(); short nDims = pArray->GetDims();
@@ -1185,7 +1185,7 @@ void SbiRuntime::PushForEach()
} }
else if (BasicCollection* pCollection = dynamic_cast<BasicCollection*>(pObj)) else if (BasicCollection* pCollection = dynamic_cast<BasicCollection*>(pObj))
{ {
p->eForType = FOR_EACH_COLLECTION; p->eForType = ForType::EachCollection;
p->refEnd = pCollection; p->refEnd = pCollection;
p->nCurCollectionIndex = 0; p->nCurCollectionIndex = 0;
} }
@@ -1197,7 +1197,7 @@ void SbiRuntime::PushForEach()
if( (aAny >>= xEnumerationAccess) ) if( (aAny >>= xEnumerationAccess) )
{ {
p->xEnumeration = xEnumerationAccess->createEnumeration(); p->xEnumeration = xEnumerationAccess->createEnumeration();
p->eForType = FOR_EACH_XENUMERATION; p->eForType = ForType::EachXEnumeration;
} }
else if ( isVBAEnabled() && pUnoObj->isNativeCOMObject() ) else if ( isVBAEnabled() && pUnoObj->isNativeCOMObject() )
{ {
@@ -1207,7 +1207,7 @@ void SbiRuntime::PushForEach()
try try
{ {
p->xEnumeration = new ComEnumerationWrapper( xInvocation ); p->xEnumeration = new ComEnumerationWrapper( xInvocation );
p->eForType = FOR_EACH_XENUMERATION; p->eForType = ForType::EachXEnumeration;
} }
catch(const uno::Exception& ) catch(const uno::Exception& )
{} {}
@@ -1264,8 +1264,9 @@ SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* p
for (SbiForStack *p = pForStk; p; p = p->pNext) for (SbiForStack *p = pForStk; p; p = p->pNext)
{ {
SbxVariable* pVar = p->refEnd.Is() ? p->refEnd.get() : nullptr; SbxVariable* pVar = p->refEnd.Is() ? p->refEnd.get() : nullptr;
if( p->eForType == FOR_EACH_COLLECTION && pVar != nullptr && if( p->eForType == ForType::EachCollection
dynamic_cast<BasicCollection*>( pVar) == pCollection ) && pVar != nullptr
&& dynamic_cast<BasicCollection*>( pVar) == pCollection )
{ {
return p; return p;
} }
@@ -2604,7 +2605,7 @@ void SbiRuntime::StepNEXT()
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR ); StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
return; return;
} }
if( pForStk->eForType == FOR_TO ) if( pForStk->eForType == ForType::To )
{ {
pForStk->refVar->Compute( SbxPLUS, *pForStk->refInc ); pForStk->refVar->Compute( SbxPLUS, *pForStk->refInc );
} }
@@ -3018,14 +3019,14 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
bool bEndLoop = false; bool bEndLoop = false;
switch( pForStk->eForType ) switch( pForStk->eForType )
{ {
case FOR_TO: case ForType::To:
{ {
SbxOperator eOp = ( pForStk->refInc->GetDouble() < 0 ) ? SbxLT : SbxGT; SbxOperator eOp = ( pForStk->refInc->GetDouble() < 0 ) ? SbxLT : SbxGT;
if( pForStk->refVar->Compare( eOp, *pForStk->refEnd ) ) if( pForStk->refVar->Compare( eOp, *pForStk->refEnd ) )
bEndLoop = true; bEndLoop = true;
break; break;
} }
case FOR_EACH_ARRAY: case ForType::EachArray:
{ {
SbiForStack* p = pForStk; SbiForStack* p = pForStk;
if( p->pArrayCurIndices == nullptr ) if( p->pArrayCurIndices == nullptr )
@@ -3066,7 +3067,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
} }
break; break;
} }
case FOR_EACH_COLLECTION: case ForType::EachCollection:
{ {
BasicCollection* pCollection = static_cast<BasicCollection*>(static_cast<SbxVariable*>(pForStk->refEnd)); BasicCollection* pCollection = static_cast<BasicCollection*>(static_cast<SbxVariable*>(pForStk->refEnd));
SbxArrayRef xItemArray = pCollection->xItemArray; SbxArrayRef xItemArray = pCollection->xItemArray;
@@ -3083,7 +3084,7 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
} }
break; break;
} }
case FOR_EACH_XENUMERATION: case ForType::EachXEnumeration:
{ {
SbiForStack* p = pForStk; SbiForStack* p = pForStk;
if( p->xEnumeration->hasMoreElements() ) if( p->xEnumeration->hasMoreElements() )