diff options
Diffstat (limited to 'basic/source/sbx/sbxvalue.cxx')
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 2200aaa8c8..ebf05b6b73 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -301,7 +301,7 @@ SbxValue& SbxValue::operator=( const SbxValue& r ) { // string -> byte array if( IsFixed() && (aData.eType == SbxOBJECT) - && aData.pObj && ( aData.pObj->GetType() == (SbxARRAY | SbxBYTE) ) + && aData.pObj && ( aData.pObj->GetType() == (SbxARRAY | SbxBYTE) ) && (r.aData.eType == SbxSTRING) ) { ::rtl::OUString aStr = r.GetString(); @@ -1122,7 +1122,7 @@ BOOL SbxValue::Convert( SbxDataType eTo ) BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { - bool bVBAInterop = SbiRuntime::isVBAEnabled(); + bool bVBAInterop = SbiRuntime::isVBAEnabled(); SbxDataType eThisType = GetType(); SbxDataType eOpType = rOp.GetType(); @@ -1137,8 +1137,8 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) else if( eThisType == SbxNULL || eOpType == SbxNULL ) SetType( SbxNULL ); // Sonderregel 2: Ist ein Operand Empty, ist das Ergebnis der 2. Operand - else if( eThisType == SbxEMPTY - && !bVBAInterop + else if( eThisType == SbxEMPTY + && !bVBAInterop ) *this = rOp; // 13.2.96: Nicht schon vor Get auf SbxEMPTY pruefen @@ -1146,8 +1146,8 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { SbxValues aL, aR; bool bDecimal = false; - if( bVBAInterop && ( ( eThisType == SbxSTRING && eOpType != SbxSTRING ) || - ( eThisType != SbxSTRING && eOpType == SbxSTRING ) ) && + if( bVBAInterop && ( ( eThisType == SbxSTRING && eOpType != SbxSTRING && eOpType != SbxEMPTY ) || + ( eThisType != SbxSTRING && eThisType != SbxEMPTY && eOpType == SbxSTRING ) ) && ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS ) ) { goto Lbl_OpIsDouble; @@ -1194,6 +1194,8 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) aL.eType = aR.eType = GetType(); // else if( GetType() == SbxDouble || GetType() == SbxSingle ) // aL.eType = aR.eType = SbxLONG64; + else if ( bVBAInterop && eOpType == SbxBOOL ) + aL.eType = aR.eType = SbxBOOL; else aL.eType = aR.eType = SbxLONG; } @@ -1280,7 +1282,12 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) break; case SbxNOT: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 = ~aL.nLong64; + { + if ( aL.eType != SbxBOOL ) + aL.nLong64 = ~aL.nLong64; + else + aL.nLong = ~aL.nLong; + } else aL.nLong = ~aL.nLong; break; @@ -1288,7 +1295,7 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) } } } - else if( ( GetType() == SbxDECIMAL || rOp.GetType() == SbxDECIMAL ) && + else if( ( GetType() == SbxDECIMAL || rOp.GetType() == SbxDECIMAL ) && ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS || eOp == SbxNEG ) ) { aL.eType = aR.eType = SbxDECIMAL; @@ -1300,7 +1307,7 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) releaseDecimalPtr( aL.pDecimal ); goto Lbl_OpIsEmpty; } - if( Get( aL ) ) + if( Get( aL ) ) { if( aL.pDecimal && aR.pDecimal ) { @@ -1371,7 +1378,7 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { SetError( SbxERR_ZERODIV ); } - else + else { // #i20704 Implement directly BigInt b1( aL.nLong64 ); @@ -1397,7 +1404,7 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) } } else -Lbl_OpIsDouble: +Lbl_OpIsDouble: { // Andere Operatoren aL.eType = aR.eType = SbxDOUBLE; if( rOp.Get( aR ) ) @@ -1456,7 +1463,7 @@ Lbl_OpIsEmpty: BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const { - bool bVBAInterop = SbiRuntime::isVBAEnabled(); + bool bVBAInterop = SbiRuntime::isVBAEnabled(); BOOL bRes = FALSE; SbxError eOld = GetError(); @@ -1476,12 +1483,12 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const // Sonderregel 2: Wenn beide Variant sind und einer ist numerisch, // und der andere ein String, ist num < str else if( !IsFixed() && !rOp.IsFixed() - && ( rOp.GetType() == SbxSTRING && GetType() != SbxSTRING && IsNumeric() ) && !bVBAInterop + && ( rOp.GetType() == SbxSTRING && GetType() != SbxSTRING && IsNumeric() ) && !bVBAInterop ) bRes = BOOL( eOp == SbxLT || eOp == SbxLE || eOp == SbxNE ); else if( !IsFixed() && !rOp.IsFixed() - && ( GetType() == SbxSTRING && rOp.GetType() != SbxSTRING && rOp.IsNumeric() ) -&& !bVBAInterop + && ( GetType() == SbxSTRING && rOp.GetType() != SbxSTRING && rOp.IsNumeric() ) +&& !bVBAInterop ) bRes = BOOL( eOp == SbxGT || eOp == SbxGE || eOp == SbxNE ); else @@ -1813,7 +1820,7 @@ BOOL SbxValue::StoreData( SvStream& r ) const break; case SbxCHAR: { - char c = sal::static_int_cast< char >(aData.nChar); + char c = sal::static_int_cast< char >(aData.nChar); r << c; break; } |