diff options
author | Andreas Bregas <ab@openoffice.org> | 2010-08-11 14:18:10 +0200 |
---|---|---|
committer | Andreas Bregas <ab@openoffice.org> | 2010-08-11 14:18:10 +0200 |
commit | 73e504b3e526fe7bbb01e8947d329f1687d84011 (patch) | |
tree | 6d71e1a0b7da072ea9cff6b28e86e46778b42707 /basic | |
parent | e3046e29e116f5d22f6e56933058b66ce4f6d1bf (diff) |
mib18: #163237# Changed error handling in StepSET
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/runtime/step0.cxx | 223 |
1 files changed, 111 insertions, 112 deletions
diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 29965c7e9da5..596b30b9d691 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -431,144 +431,143 @@ void SbiRuntime::StepPUT() void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, bool bHandleDefaultProp ) { // #67733 Typen mit Array-Flag sind auch ok - SbxDataType eValType = refVal->GetType(); + + // Check var, !object is no error for sure if, only if type is fixed SbxDataType eVarType = refVar->GetType(); - if( (eValType != SbxOBJECT - && eValType != SbxEMPTY -// seems like when using the default method its possible for objects -// to be empty ( no broadcast has taken place yet ) or the actual value is - - && !bHandleDefaultProp - && !(eValType & SbxARRAY)) || - (eVarType != SbxOBJECT - && eVarType != SbxEMPTY - && !bHandleDefaultProp - && !(eVarType & SbxARRAY) ) ) + if( !bHandleDefaultProp && eVarType != SbxOBJECT && !(eVarType & SbxARRAY) && refVar->IsFixed() ) { Error( SbERR_INVALID_USAGE_OBJECT ); + return; } - else + + // Check value, !object is no error for sure if, only if type is fixed + SbxDataType eValType = refVal->GetType(); + bool bGetValObject = false; + if( !bHandleDefaultProp && eValType != SbxOBJECT && !(eValType & SbxARRAY) && refVal->IsFixed() ) { - // Getting in here causes problems with objects with default properties - // if they are SbxEMPTY I guess - if ( !bHandleDefaultProp || ( bHandleDefaultProp && refVal->GetType() == SbxOBJECT ) ) + Error( SbERR_INVALID_USAGE_OBJECT ); + return; + } + + // Getting in here causes problems with objects with default properties + // if they are SbxEMPTY I guess + if ( !bHandleDefaultProp || ( bHandleDefaultProp && eValType == SbxOBJECT ) ) + { + // Auf refVal GetObject fuer Collections ausloesen + SbxBase* pObjVarObj = refVal->GetObject(); + if( pObjVarObj ) { - // Auf refVal GetObject fuer Collections ausloesen - SbxBase* pObjVarObj = refVal->GetObject(); - if( pObjVarObj ) - { - SbxVariableRef refObjVal = PTR_CAST(SbxObject,pObjVarObj); + SbxVariableRef refObjVal = PTR_CAST(SbxObject,pObjVarObj); - // #67733 Typen mit Array-Flag sind auch ok - if( refObjVal ) - refVal = refObjVal; - else if( !(eValType & SbxARRAY) ) - refVal = NULL; - } + // #67733 Typen mit Array-Flag sind auch ok + if( refObjVal ) + refVal = refObjVal; + else if( !(eValType & SbxARRAY) ) + refVal = NULL; } + } - // #52896 Wenn Uno-Sequences bzw. allgemein Arrays einer als - // Object deklarierten Variable zugewiesen werden, kann hier - // refVal ungueltig sein! - if( !refVal ) + // #52896 Wenn Uno-Sequences bzw. allgemein Arrays einer als + // Object deklarierten Variable zugewiesen werden, kann hier + // refVal ungueltig sein! + if( !refVal ) + { + Error( SbERR_INVALID_USAGE_OBJECT ); + } + else + { + // Store auf die eigene Methode (innerhalb einer Function)? + BOOL bFlagsChanged = FALSE; + USHORT n = 0; + if( (SbxVariable*) refVar == (SbxVariable*) pMeth ) { - Error( SbERR_INVALID_USAGE_OBJECT ); + bFlagsChanged = TRUE; + n = refVar->GetFlags(); + refVar->SetFlag( SBX_WRITE ); } - else - { - // Store auf die eigene Methode (innerhalb einer Function)? - BOOL bFlagsChanged = FALSE; - USHORT n = 0; - if( (SbxVariable*) refVar == (SbxVariable*) pMeth ) - { - bFlagsChanged = TRUE; - n = refVar->GetFlags(); - refVar->SetFlag( SBX_WRITE ); - } - SbProcedureProperty* pProcProperty = PTR_CAST(SbProcedureProperty,(SbxVariable*)refVar); - if( pProcProperty ) - pProcProperty->setSet( true ); + SbProcedureProperty* pProcProperty = PTR_CAST(SbProcedureProperty,(SbxVariable*)refVar); + if( pProcProperty ) + pProcProperty->setSet( true ); - if ( bHandleDefaultProp ) + if ( bHandleDefaultProp ) + { + // get default properties for lhs & rhs where necessary + // SbxVariable* defaultProp = NULL; unused variable + bool bLHSHasDefaultProp = false; + // LHS try determine if a default prop exists + if ( refVar->GetType() == SbxOBJECT ) { - // get default properties for lhs & rhs where necessary - // SbxVariable* defaultProp = NULL; unused variable - bool bLHSHasDefaultProp = false; - // LHS try determine if a default prop exists - if ( refVar->GetType() == SbxOBJECT ) + SbxVariable* pDflt = getDefaultProp( refVar ); + if ( pDflt ) { - SbxVariable* pDflt = getDefaultProp( refVar ); - if ( pDflt ) - { - refVar = pDflt; - bLHSHasDefaultProp = true; - } + refVar = pDflt; + bLHSHasDefaultProp = true; } - // RHS only get a default prop is the rhs has one - if ( refVal->GetType() == SbxOBJECT ) - { - // check if lhs is a null object - // if it is then use the object not the default property - SbxObject* pObj = NULL; + } + // RHS only get a default prop is the rhs has one + if ( refVal->GetType() == SbxOBJECT ) + { + // check if lhs is a null object + // if it is then use the object not the default property + SbxObject* pObj = NULL; - pObj = PTR_CAST(SbxObject,(SbxVariable*)refVar); + pObj = PTR_CAST(SbxObject,(SbxVariable*)refVar); - // calling GetObject on a SbxEMPTY variable raises - // object not set errors, make sure its an Object - if ( !pObj && refVar->GetType() == SbxOBJECT ) - { - SbxBase* pObjVarObj = refVar->GetObject(); - pObj = PTR_CAST(SbxObject,pObjVarObj); - } - SbxVariable* pDflt = NULL; - if ( pObj || bLHSHasDefaultProp ) - // lhs is either a valid object || or has a defaultProp - pDflt = getDefaultProp( refVal ); - if ( pDflt ) - refVal = pDflt; + // calling GetObject on a SbxEMPTY variable raises + // object not set errors, make sure its an Object + if ( !pObj && refVar->GetType() == SbxOBJECT ) + { + SbxBase* pObjVarObj = refVar->GetObject(); + pObj = PTR_CAST(SbxObject,pObjVarObj); } + SbxVariable* pDflt = NULL; + if ( pObj || bLHSHasDefaultProp ) + // lhs is either a valid object || or has a defaultProp + pDflt = getDefaultProp( refVal ); + if ( pDflt ) + refVal = pDflt; } + } - // Handle withevents - BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS ); - if ( bWithEvents ) - { - Reference< XInterface > xComListener; - - SbxBase* pObj = refVal->GetObject(); - SbUnoObject* pUnoObj = (pObj != NULL) ? PTR_CAST(SbUnoObject,pObj) : NULL; - if( pUnoObj != NULL ) - { - Any aControlAny = pUnoObj->getUnoAny(); - String aDeclareClassName = refVar->GetDeclareClassName(); - ::rtl::OUString aVBAType = aDeclareClassName; - ::rtl::OUString aPrefix = refVar->GetName(); - SbxObjectRef xScopeObj = refVar->GetParent(); - xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj ); - - refVal->SetDeclareClassName( aDeclareClassName ); - refVal->SetComListener( xComListener ); // Hold reference - } + // Handle withevents + BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS ); + if ( bWithEvents ) + { + Reference< XInterface > xComListener; - *refVar = *refVal; - } - else + SbxBase* pObj = refVal->GetObject(); + SbUnoObject* pUnoObj = (pObj != NULL) ? PTR_CAST(SbUnoObject,pObj) : NULL; + if( pUnoObj != NULL ) { - *refVar = *refVal; + Any aControlAny = pUnoObj->getUnoAny(); + String aDeclareClassName = refVar->GetDeclareClassName(); + ::rtl::OUString aVBAType = aDeclareClassName; + ::rtl::OUString aPrefix = refVar->GetName(); + SbxObjectRef xScopeObj = refVar->GetParent(); + xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj ); + + refVal->SetDeclareClassName( aDeclareClassName ); + refVal->SetComListener( xComListener ); // Hold reference } - // lhs is a property who's value is currently (Empty e.g. no broadcast yet) - // in this case if there is a default prop involved the value of the - // default property may infact be void so the type will also be SbxEMPTY - // in this case we do not want to call checkUnoStructCopy 'cause that will - // cause an error also - if ( !bHandleDefaultProp || ( bHandleDefaultProp && ( refVar->GetType() != SbxEMPTY ) ) ) - // #67607 Uno-Structs kopieren - checkUnoStructCopy( refVal, refVar ); - if( bFlagsChanged ) - refVar->SetFlags( n ); + *refVar = *refVal; } + else + { + *refVar = *refVal; + } + + // lhs is a property who's value is currently (Empty e.g. no broadcast yet) + // in this case if there is a default prop involved the value of the + // default property may infact be void so the type will also be SbxEMPTY + // in this case we do not want to call checkUnoStructCopy 'cause that will + // cause an error also + if ( !bHandleDefaultProp || ( bHandleDefaultProp && ( refVar->GetType() != SbxEMPTY ) ) ) + // #67607 Uno-Structs kopieren + checkUnoStructCopy( refVal, refVar ); + if( bFlagsChanged ) + refVar->SetFlags( n ); } } |