diff options
Diffstat (limited to 'basic/source/sbx')
28 files changed, 1597 insertions, 1891 deletions
diff --git a/basic/source/sbx/makefile.mk b/basic/source/sbx/makefile.mk index cc20080cbe..332c6a0d42 100644..100755 --- a/basic/source/sbx/makefile.mk +++ b/basic/source/sbx/makefile.mk @@ -47,7 +47,6 @@ SLOFILES= \ $(SLO)$/sbxbyte.obj \ $(SLO)$/sbxchar.obj \ $(SLO)$/sbxcoll.obj \ - $(SLO)$/sbxcurr.obj \ $(SLO)$/sbxdec.obj \ $(SLO)$/sbxform.obj \ $(SLO)$/sbxint.obj \ @@ -58,12 +57,12 @@ SLOFILES= \ $(SLO)$/sbxsng.obj \ $(SLO)$/sbxuint.obj \ $(SLO)$/sbxulng.obj \ - $(SLO)$/sbxvals.obj \ $(SLO)$/sbxvar.obj EXCEPTIONSFILES= \ $(SLO)$/sbxarray.obj \ + $(SLO)$/sbxcurr.obj \ $(SLO)$/sbxdate.obj \ $(SLO)$/sbxdbl.obj \ $(SLO)$/sbxexec.obj \ diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index 200c10018c..eb95cf685c 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -36,8 +36,8 @@ using namespace std; struct SbxDim { // an array-dimension: SbxDim* pNext; // Link - INT32 nLbound, nUbound; // Limitations - INT32 nSize; // Number of elements + sal_Int32 nLbound, nUbound; // Limitations + sal_Int32 nSize; // Number of elements }; class SbxVarEntry : public SbxVariableRef { @@ -59,11 +59,7 @@ public: TYPEINIT1(SbxArray,SbxBase) TYPEINIT1(SbxDimArray,SbxArray) -////////////////////////////////////////////////////////////////////////// -// // SbxArray -// -////////////////////////////////////////////////////////////////////////// SbxArray::SbxArray( SbxDataType t ) : SbxBase() { @@ -89,7 +85,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray ) eType = rArray.eType; Clear(); SbxVarRefs* pSrc = rArray.pData; - for( UINT32 i = 0; i < pSrc->size(); i++ ) + for( sal_uInt32 i = 0; i < pSrc->size(); i++ ) { SbxVarEntryPtr pSrcRef = (*pSrc)[i]; const SbxVariable* pSrc_ = *pSrcRef; @@ -127,8 +123,8 @@ SbxClassType SbxArray::GetClass() const void SbxArray::Clear() { - UINT32 nSize = pData->size(); - for( UINT32 i = 0 ; i < nSize ; i++ ) + sal_uInt32 nSize = pData->size(); + for( sal_uInt32 i = 0 ; i < nSize ; i++ ) { SbxVarEntry* pEntry = (*pData)[i]; delete pEntry; @@ -136,19 +132,19 @@ void SbxArray::Clear() pData->clear(); } -UINT32 SbxArray::Count32() const +sal_uInt32 SbxArray::Count32() const { return pData->size(); } -USHORT SbxArray::Count() const +sal_uInt16 SbxArray::Count() const { - UINT32 nCount = pData->size(); + sal_uInt32 nCount = pData->size(); DBG_ASSERT( nCount <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" ); - return (USHORT)nCount; + return (sal_uInt16)nCount; } -SbxVariableRef& SbxArray::GetRef32( UINT32 nIdx ) +SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx ) { // If necessary extend the array DBG_ASSERT( nIdx <= SBX_MAXINDEX32, "SBX: Array-Index > SBX_MAXINDEX32" ); @@ -166,7 +162,7 @@ SbxVariableRef& SbxArray::GetRef32( UINT32 nIdx ) return *((*pData)[nIdx]); } -SbxVariableRef& SbxArray::GetRef( USHORT nIdx ) +SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx ) { // If necessary extend the array DBG_ASSERT( nIdx <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" ); @@ -184,7 +180,7 @@ SbxVariableRef& SbxArray::GetRef( USHORT nIdx ) return *((*pData)[nIdx]); } -SbxVariable* SbxArray::Get32( UINT32 nIdx ) +SbxVariable* SbxArray::Get32( sal_uInt32 nIdx ) { if( !CanRead() ) { @@ -203,7 +199,7 @@ SbxVariable* SbxArray::Get32( UINT32 nIdx ) return rRef; } -SbxVariable* SbxArray::Get( USHORT nIdx ) +SbxVariable* SbxArray::Get( sal_uInt16 nIdx ) { if( !CanRead() ) { @@ -222,7 +218,7 @@ SbxVariable* SbxArray::Get( USHORT nIdx ) return rRef; } -void SbxArray::Put32( SbxVariable* pVar, UINT32 nIdx ) +void SbxArray::Put32( SbxVariable* pVar, sal_uInt32 nIdx ) { if( !CanWrite() ) SetError( SbxERR_PROP_READONLY ); @@ -242,7 +238,7 @@ void SbxArray::Put32( SbxVariable* pVar, UINT32 nIdx ) } } -void SbxArray::Put( SbxVariable* pVar, USHORT nIdx ) +void SbxArray::Put( SbxVariable* pVar, sal_uInt16 nIdx ) { if( !CanWrite() ) SetError( SbxERR_PROP_READONLY ); @@ -262,7 +258,7 @@ void SbxArray::Put( SbxVariable* pVar, USHORT nIdx ) } } -const XubString& SbxArray::GetAlias( USHORT nIdx ) +const XubString& SbxArray::GetAlias( sal_uInt16 nIdx ) { if( !CanRead() ) { @@ -281,7 +277,7 @@ const XubString& SbxArray::GetAlias( USHORT nIdx ) return *rRef.pAlias; } -void SbxArray::PutAlias( const XubString& rAlias, USHORT nIdx ) +void SbxArray::PutAlias( const XubString& rAlias, sal_uInt16 nIdx ) { if( !CanWrite() ) SetError( SbxERR_PROP_READONLY ); @@ -295,7 +291,7 @@ void SbxArray::PutAlias( const XubString& rAlias, USHORT nIdx ) } } -void SbxArray::Insert32( SbxVariable* pVar, UINT32 nIdx ) +void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx ) { DBG_ASSERT( pData->size() <= SBX_MAXINDEX32, "SBX: Array wird zu gross" ); if( pData->size() > SBX_MAXINDEX32 ) @@ -318,7 +314,7 @@ void SbxArray::Insert32( SbxVariable* pVar, UINT32 nIdx ) SetFlag( SBX_MODIFIED ); } -void SbxArray::Insert( SbxVariable* pVar, USHORT nIdx ) +void SbxArray::Insert( SbxVariable* pVar, sal_uInt16 nIdx ) { DBG_ASSERT( pData->size() <= 0x3FF0, "SBX: Array wird zu gross" ); if( pData->size() > 0x3FF0 ) @@ -326,7 +322,7 @@ void SbxArray::Insert( SbxVariable* pVar, USHORT nIdx ) Insert32( pVar, nIdx ); } -void SbxArray::Remove32( UINT32 nIdx ) +void SbxArray::Remove32( sal_uInt32 nIdx ) { if( nIdx < pData->size() ) { @@ -337,7 +333,7 @@ void SbxArray::Remove32( UINT32 nIdx ) } } -void SbxArray::Remove( USHORT nIdx ) +void SbxArray::Remove( sal_uInt16 nIdx ) { if( nIdx < pData->size() ) { @@ -352,10 +348,9 @@ void SbxArray::Remove( SbxVariable* pVar ) { if( pVar ) { - for( UINT32 i = 0; i < pData->size(); i++ ) + for( sal_uInt32 i = 0; i < pData->size(); i++ ) { SbxVariableRef* pRef = (*pData)[i]; - // SbxVariableRef* pRef = pData->GetObject( i ); if( *pRef == pVar ) { Remove32( i ); break; @@ -371,8 +366,8 @@ void SbxArray::Merge( SbxArray* p ) { if( p ) { - UINT32 nSize = p->Count(); - for( UINT32 i = 0; i < nSize; i++ ) + sal_uInt32 nSize = p->Count(); + for( sal_uInt32 i = 0; i < nSize; i++ ) { SbxVarEntryPtr pRef1 = (*(p->pData))[i]; // Is the element by name already inside? @@ -381,8 +376,8 @@ void SbxArray::Merge( SbxArray* p ) if( pVar ) { XubString aName = pVar->GetName(); - USHORT nHash = pVar->GetHashCode(); - for( UINT32 j = 0; j < pData->size(); j++ ) + sal_uInt16 nHash = pVar->GetHashCode(); + for( sal_uInt32 j = 0; j < pData->size(); j++ ) { SbxVariableRef* pRef2 = (*pData)[j]; if( (*pRef2)->GetHashCode() == nHash @@ -409,10 +404,10 @@ void SbxArray::Merge( SbxArray* p ) // Search of an element via the user data. If the element is // object, it will also be scanned. -SbxVariable* SbxArray::FindUserData( UINT32 nData ) +SbxVariable* SbxArray::FindUserData( sal_uInt32 nData ) { SbxVariable* p = NULL; - for( UINT32 i = 0; i < pData->size(); i++ ) + for( sal_uInt32 i = 0; i < pData->size(); i++ ) { SbxVariableRef* pRef = (*pData)[i]; SbxVariable* pVar = *pRef; @@ -432,7 +427,7 @@ SbxVariable* SbxArray::FindUserData( UINT32 nData ) case SbxCLASS_OBJECT: { // Objects are not allowed to scan their parent. - USHORT nOld = pVar->GetFlags(); + sal_uInt16 nOld = pVar->GetFlags(); pVar->ResetFlag( SBX_GBLSEARCH ); p = ((SbxObject*) pVar)->FindUserData( nData ); pVar->SetFlags( nOld ); @@ -460,19 +455,19 @@ SbxVariable* SbxArray::FindUserData( UINT32 nData ) SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) { SbxVariable* p = NULL; - UINT32 nCount = pData->size(); + sal_uInt32 nCount = pData->size(); if( !nCount ) return NULL; - BOOL bExtSearch = IsSet( SBX_EXTSEARCH ); - USHORT nHash = SbxVariable::MakeHashCode( rName ); - for( UINT32 i = 0; i < nCount; i++ ) + sal_Bool bExtSearch = IsSet( SBX_EXTSEARCH ); + sal_uInt16 nHash = SbxVariable::MakeHashCode( rName ); + for( sal_uInt32 i = 0; i < nCount; i++ ) { SbxVariableRef* pRef = (*pData)[i]; SbxVariable* pVar = *pRef; if( pVar && pVar->IsVisible() ) { // The very secure search works as well, if there is no hashcode! - USHORT nVarHash = pVar->GetHashCode(); + sal_uInt16 nVarHash = pVar->GetHashCode(); if( ( !nVarHash || nVarHash == nHash ) && ( t == SbxCLASS_DONTCARE || pVar->GetClass() == t ) && ( pVar->GetName().EqualsIgnoreCaseAscii( rName ) ) ) @@ -489,7 +484,7 @@ SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) case SbxCLASS_OBJECT: { // Objects are not allowed to scan their parent. - USHORT nOld = pVar->GetFlags(); + sal_uInt16 nOld = pVar->GetFlags(); pVar->ResetFlag( SBX_GBLSEARCH ); p = ((SbxObject*) pVar)->Find( rName, t ); pVar->SetFlags( nOld ); @@ -511,18 +506,18 @@ SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) return p; } -BOOL SbxArray::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxArray::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { - UINT16 nElem; + sal_uInt16 nElem; Clear(); - BOOL bRes = TRUE; - USHORT f = nFlags; + sal_Bool bRes = sal_True; + sal_uInt16 f = nFlags; nFlags |= SBX_WRITE; rStrm >> nElem; nElem &= 0x7FFF; - for( UINT32 n = 0; n < nElem; n++ ) + for( sal_uInt32 n = 0; n < nElem; n++ ) { - UINT16 nIdx; + sal_uInt16 nIdx; rStrm >> nIdx; SbxVariable* pVar = (SbxVariable*) Load( rStrm ); if( pVar ) @@ -532,7 +527,7 @@ BOOL SbxArray::LoadData( SvStream& rStrm, USHORT nVer ) } else { - bRes = FALSE; break; + bRes = sal_False; break; } } if( bRes ) @@ -541,10 +536,10 @@ BOOL SbxArray::LoadData( SvStream& rStrm, USHORT nVer ) return bRes; } -BOOL SbxArray::StoreData( SvStream& rStrm ) const +sal_Bool SbxArray::StoreData( SvStream& rStrm ) const { - UINT32 nElem = 0; - UINT32 n; + sal_uInt32 nElem = 0; + sal_uInt32 n; // Which elements are even defined? for( n = 0; n < pData->size(); n++ ) { @@ -553,34 +548,30 @@ BOOL SbxArray::StoreData( SvStream& rStrm ) const if( p && !( p->GetFlags() & SBX_DONTSTORE ) ) nElem++; } - rStrm << (UINT16) nElem; + rStrm << (sal_uInt16) nElem; for( n = 0; n < pData->size(); n++ ) { SbxVariableRef* pRef = (*pData)[n]; SbxVariable* p = *pRef; if( p && !( p->GetFlags() & SBX_DONTSTORE ) ) { - rStrm << (UINT16) n; + rStrm << (sal_uInt16) n; if( !p->Store( rStrm ) ) - return FALSE; + return sal_False; } } return StorePrivateData( rStrm ); } // #100883 Method to set method directly to parameter array -void SbxArray::PutDirect( SbxVariable* pVar, UINT32 nIdx ) +void SbxArray::PutDirect( SbxVariable* pVar, sal_uInt32 nIdx ) { SbxVariableRef& rRef = GetRef32( nIdx ); rRef = pVar; } -////////////////////////////////////////////////////////////////////////// -// // SbxArray -// -////////////////////////////////////////////////////////////////////////// SbxDimArray::SbxDimArray( SbxDataType t ) : SbxArray( t ), mbHasFixedSize( false ) { @@ -632,7 +623,7 @@ void SbxDimArray::Clear() // Add a dimension -void SbxDimArray::AddDimImpl32( INT32 lb, INT32 ub, BOOL bAllowSize0 ) +void SbxDimArray::AddDimImpl32( sal_Int32 lb, sal_Int32 ub, sal_Bool bAllowSize0 ) { SbxError eRes = SbxERR_OK; if( ub < lb && !bAllowSize0 ) @@ -656,51 +647,51 @@ void SbxDimArray::AddDimImpl32( INT32 lb, INT32 ub, BOOL bAllowSize0 ) void SbxDimArray::AddDim( short lb, short ub ) { - AddDimImpl32( lb, ub, FALSE ); + AddDimImpl32( lb, ub, sal_False ); } void SbxDimArray::unoAddDim( short lb, short ub ) { - AddDimImpl32( lb, ub, TRUE ); + AddDimImpl32( lb, ub, sal_True ); } -void SbxDimArray::AddDim32( INT32 lb, INT32 ub ) +void SbxDimArray::AddDim32( sal_Int32 lb, sal_Int32 ub ) { - AddDimImpl32( lb, ub, FALSE ); + AddDimImpl32( lb, ub, sal_False ); } -void SbxDimArray::unoAddDim32( INT32 lb, INT32 ub ) +void SbxDimArray::unoAddDim32( sal_Int32 lb, sal_Int32 ub ) { - AddDimImpl32( lb, ub, TRUE ); + AddDimImpl32( lb, ub, sal_True ); } // Readout dimension data -BOOL SbxDimArray::GetDim32( INT32 n, INT32& rlb, INT32& rub ) const +sal_Bool SbxDimArray::GetDim32( sal_Int32 n, sal_Int32& rlb, sal_Int32& rub ) const { if( n < 1 || n > nDim ) { - SetError( SbxERR_BOUNDS ); rub = rlb = 0; return FALSE; + SetError( SbxERR_BOUNDS ); rub = rlb = 0; return sal_False; } SbxDim* p = pFirst; while( --n ) p = p->pNext; rub = p->nUbound; rlb = p->nLbound; - return TRUE; + return sal_True; } -BOOL SbxDimArray::GetDim( short n, short& rlb, short& rub ) const +sal_Bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const { - INT32 rlb32, rub32; - BOOL bRet = GetDim32( n, rlb32, rub32 ); + sal_Int32 rlb32, rub32; + sal_Bool bRet = GetDim32( n, rlb32, rub32 ); if( bRet ) { if( rlb32 < -SBX_MAXINDEX || rub32 > SBX_MAXINDEX ) { SetError( SbxERR_BOUNDS ); - return FALSE; + return sal_False; } rub = (short)rub32; rlb = (short)rlb32; @@ -710,15 +701,15 @@ BOOL SbxDimArray::GetDim( short n, short& rlb, short& rub ) const // Element-Ptr with the help of an index list -UINT32 SbxDimArray::Offset32( const INT32* pIdx ) +sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx ) { - UINT32 nPos = 0; + sal_uInt32 nPos = 0; for( SbxDim* p = pFirst; p; p = p->pNext ) { - INT32 nIdx = *pIdx++; + sal_Int32 nIdx = *pIdx++; if( nIdx < p->nLbound || nIdx > p->nUbound ) { - nPos = (UINT32)SBX_MAXINDEX32 + 1; break; + nPos = (sal_uInt32)SBX_MAXINDEX32 + 1; break; } nPos = nPos * p->nSize + nIdx - p->nLbound; } @@ -729,7 +720,7 @@ UINT32 SbxDimArray::Offset32( const INT32* pIdx ) return nPos; } -USHORT SbxDimArray::Offset( const short* pIdx ) +sal_uInt16 SbxDimArray::Offset( const short* pIdx ) { long nPos = 0; for( SbxDim* p = pFirst; p; p = p->pNext ) @@ -745,7 +736,7 @@ USHORT SbxDimArray::Offset( const short* pIdx ) { SetError( SbxERR_BOUNDS ); nPos = 0; } - return (USHORT) nPos; + return (sal_uInt16) nPos; } SbxVariableRef& SbxDimArray::GetRef( const short* pIdx ) @@ -763,17 +754,17 @@ void SbxDimArray::Put( SbxVariable* p, const short* pIdx ) SbxArray::Put( p, Offset( pIdx ) ); } -SbxVariableRef& SbxDimArray::GetRef32( const INT32* pIdx ) +SbxVariableRef& SbxDimArray::GetRef32( const sal_Int32* pIdx ) { return SbxArray::GetRef32( Offset32( pIdx ) ); } -SbxVariable* SbxDimArray::Get32( const INT32* pIdx ) +SbxVariable* SbxDimArray::Get32( const sal_Int32* pIdx ) { return SbxArray::Get32( Offset32( pIdx ) ); } -void SbxDimArray::Put32( SbxVariable* p, const INT32* pIdx ) +void SbxDimArray::Put32( SbxVariable* p, const sal_Int32* pIdx ) { SbxArray::Put32( p, Offset32( pIdx ) ); } @@ -781,38 +772,38 @@ void SbxDimArray::Put32( SbxVariable* p, const INT32* pIdx ) // Element-Number with the help of Parameter-Array -UINT32 SbxDimArray::Offset32( SbxArray* pPar ) +sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar ) { if( nDim == 0 || !pPar || ( ( nDim != ( pPar->Count() - 1 ) ) && SbiRuntime::isVBAEnabled() ) ) { SetError( SbxERR_BOUNDS ); return 0; } - UINT32 nPos = 0; - USHORT nOff = 1; // Non element 0! + sal_uInt32 nPos = 0; + sal_uInt16 nOff = 1; // Non element 0! for( SbxDim* p = pFirst; p && !IsError(); p = p->pNext ) { - INT32 nIdx = pPar->Get( nOff++ )->GetLong(); + sal_Int32 nIdx = pPar->Get( nOff++ )->GetLong(); if( nIdx < p->nLbound || nIdx > p->nUbound ) { - nPos = (UINT32) SBX_MAXINDEX32+1; break; + nPos = (sal_uInt32) SBX_MAXINDEX32+1; break; } nPos = nPos * p->nSize + nIdx - p->nLbound; } - if( nPos > (UINT32) SBX_MAXINDEX32 ) + if( nPos > (sal_uInt32) SBX_MAXINDEX32 ) { SetError( SbxERR_BOUNDS ); nPos = 0; } return nPos; } -USHORT SbxDimArray::Offset( SbxArray* pPar ) +sal_uInt16 SbxDimArray::Offset( SbxArray* pPar ) { - UINT32 nPos = Offset32( pPar ); + sal_uInt32 nPos = Offset32( pPar ); if( nPos > (long) SBX_MAXINDEX ) { SetError( SbxERR_BOUNDS ); nPos = 0; } - return (USHORT) nPos; + return (sal_uInt16) nPos; } SbxVariableRef& SbxDimArray::GetRef( SbxArray* pPar ) @@ -830,27 +821,27 @@ void SbxDimArray::Put( SbxVariable* p, SbxArray* pPar ) SbxArray::Put32( p, Offset32( pPar ) ); } -BOOL SbxDimArray::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxDimArray::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { short nDimension; rStrm >> nDimension; for( short i = 0; i < nDimension && rStrm.GetError() == SVSTREAM_OK; i++ ) { - INT16 lb, ub; + sal_Int16 lb, ub; rStrm >> lb >> ub; AddDim( lb, ub ); } return SbxArray::LoadData( rStrm, nVer ); } -BOOL SbxDimArray::StoreData( SvStream& rStrm ) const +sal_Bool SbxDimArray::StoreData( SvStream& rStrm ) const { - rStrm << (INT16) nDim; + rStrm << (sal_Int16) nDim; for( short i = 0; i < nDim; i++ ) { short lb, ub; GetDim( i, lb, ub ); - rStrm << (INT16) lb << (INT16) ub; + rStrm << (sal_Int16) lb << (sal_Int16) ub; } return SbxArray::StoreData( rStrm ); } diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx index f96c39730d..099b38f6b1 100644 --- a/basic/source/sbx/sbxbase.cxx +++ b/basic/source/sbx/sbxbase.cxx @@ -49,18 +49,11 @@ TYPEINIT0(SbxBase) SbxAppData* GetSbxData_Impl() { -#ifndef DOS SbxAppData** ppData = (SbxAppData**) ::GetAppData( SHL_SBX ); SbxAppData* p = *ppData; if( !p ) p = *ppData = new SbxAppData; return p; -#else - SbxAppData** ppData; - SbxAppData* p; - p = *ppData = new SbxAppData; - return p; -#endif } SbxAppData::~SbxAppData() @@ -116,13 +109,13 @@ void SbxBase::Clear() DBG_CHKTHIS( SbxBase, 0 ); } -BOOL SbxBase::IsFixed() const +sal_Bool SbxBase::IsFixed() const { DBG_CHKTHIS( SbxBase, 0 ); return IsSet( SBX_FIXED ); } -void SbxBase::SetModified( BOOL b ) +void SbxBase::SetModified( sal_Bool b ) { DBG_CHKTHIS( SbxBase, 0 ); if( IsSet( SBX_NO_MODIFY ) ) @@ -145,9 +138,9 @@ void SbxBase::SetError( SbxError e ) p->eSbxError = e; } -BOOL SbxBase::IsError() +sal_Bool SbxBase::IsError() { - return BOOL( GetSbxData_Impl()->eSbxError != SbxERR_OK ); + return sal_Bool( GetSbxData_Impl()->eSbxError != SbxERR_OK ); } void SbxBase::ResetError() @@ -161,7 +154,7 @@ void SbxBase::AddFactory( SbxFactory* pFac ) const SbxFactory* pTemp = pFac; // From 1996-03-06: take the HandleLast-Flag into account - USHORT nPos = p->aFacs.Count(); // Insert-Position + sal_uInt16 nPos = p->aFacs.Count(); // Insert position if( !pFac->IsHandleLast() ) // Only if not self HandleLast { // Rank new factory in front of factories with HandleLast @@ -175,7 +168,7 @@ void SbxBase::AddFactory( SbxFactory* pFac ) void SbxBase::RemoveFactory( SbxFactory* pFac ) { SbxAppData* p = GetSbxData_Impl(); - for( USHORT i = 0; i < p->aFacs.Count(); i++ ) + for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ ) { if( p->aFacs.GetObject( i ) == pFac ) { @@ -185,7 +178,7 @@ void SbxBase::RemoveFactory( SbxFactory* pFac ) } -SbxBase* SbxBase::Create( UINT16 nSbxId, UINT32 nCreator ) +SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) { // #91626: Hack to skip old Basic dialogs // Problem: There does not exist a factory any more, @@ -211,7 +204,7 @@ SbxBase* SbxBase::Create( UINT16 nSbxId, UINT32 nCreator ) // Unknown type: go over the factories! SbxAppData* p = GetSbxData_Impl(); SbxBase* pNew = NULL; - for( USHORT i = 0; i < p->aFacs.Count(); i++ ) + for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ ) { SbxFactory* pFac = p->aFacs.GetObject( i ); pNew = pFac->Create( nSbxId, nCreator ); @@ -233,7 +226,7 @@ SbxObject* SbxBase::CreateObject( const XubString& rClass ) { SbxAppData* p = GetSbxData_Impl(); SbxObject* pNew = NULL; - for( USHORT i = 0; i < p->aFacs.Count(); i++ ) + for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ ) { pNew = p->aFacs.GetObject( i )->CreateObject( rClass ); if( pNew ) @@ -251,15 +244,15 @@ SbxObject* SbxBase::CreateObject( const XubString& rClass ) return pNew; } -static BOOL bStaticEnableBroadcasting = TRUE; +static sal_Bool bStaticEnableBroadcasting = sal_True; // Sbx-Solution in exchange for SfxBroadcaster::Enable() -void SbxBase::StaticEnableBroadcasting( BOOL bEnable ) +void SbxBase::StaticEnableBroadcasting( sal_Bool bEnable ) { bStaticEnableBroadcasting = bEnable; } -BOOL SbxBase::StaticIsEnabledBroadcasting( void ) +sal_Bool SbxBase::StaticIsEnabledBroadcasting( void ) { return bStaticEnableBroadcasting; } @@ -267,15 +260,15 @@ BOOL SbxBase::StaticIsEnabledBroadcasting( void ) SbxBase* SbxBase::Load( SvStream& rStrm ) { - UINT16 nSbxId, nFlags, nVer; - UINT32 nCreator, nSize; + sal_uInt16 nSbxId, nFlags, nVer; + sal_uInt32 nCreator, nSize; rStrm >> nCreator >> nSbxId >> nFlags >> nVer; // Correcting a foolishness of mine: if( nFlags & SBX_RESERVED ) nFlags = ( nFlags & ~SBX_RESERVED ) | SBX_GBLSEARCH; - ULONG nOldPos = rStrm.Tell(); + sal_uIntPtr nOldPos = rStrm.Tell(); rStrm >> nSize; SbxBase* p = Create( nSbxId, nCreator ); if( p ) @@ -283,7 +276,7 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) p->nFlags = nFlags; if( p->LoadData( rStrm, nVer ) ) { - ULONG nNewPos = rStrm.Tell(); + sal_uIntPtr nNewPos = rStrm.Tell(); nOldPos += nSize; DBG_ASSERT( nOldPos >= nNewPos, "SBX: Zu viele Daten eingelesen" ); if( nOldPos != nNewPos ) @@ -311,81 +304,81 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) // Skip the Sbx-Object inside the stream void SbxBase::Skip( SvStream& rStrm ) { - UINT16 nSbxId, nFlags, nVer; - UINT32 nCreator, nSize; + sal_uInt16 nSbxId, nFlags, nVer; + sal_uInt32 nCreator, nSize; rStrm >> nCreator >> nSbxId >> nFlags >> nVer; - ULONG nStartPos = rStrm.Tell(); + sal_uIntPtr nStartPos = rStrm.Tell(); rStrm >> nSize; rStrm.Seek( nStartPos + nSize ); } -BOOL SbxBase::Store( SvStream& rStrm ) +sal_Bool SbxBase::Store( SvStream& rStrm ) { DBG_CHKTHIS( SbxBase, 0 ); if( !( nFlags & SBX_DONTSTORE ) ) { - rStrm << (UINT32) GetCreator() - << (UINT16) GetSbxId() - << (UINT16) GetFlags() - << (UINT16) GetVersion(); - ULONG nOldPos = rStrm.Tell(); - rStrm << (UINT32) 0L; - BOOL bRes = StoreData( rStrm ); - ULONG nNewPos = rStrm.Tell(); + rStrm << (sal_uInt32) GetCreator() + << (sal_uInt16) GetSbxId() + << (sal_uInt16) GetFlags() + << (sal_uInt16) GetVersion(); + sal_uIntPtr nOldPos = rStrm.Tell(); + rStrm << (sal_uInt32) 0L; + sal_Bool bRes = StoreData( rStrm ); + sal_uIntPtr nNewPos = rStrm.Tell(); rStrm.Seek( nOldPos ); - rStrm << (UINT32) ( nNewPos - nOldPos ); + rStrm << (sal_uInt32) ( nNewPos - nOldPos ); rStrm.Seek( nNewPos ); if( rStrm.GetError() != SVSTREAM_OK ) - bRes = FALSE; + bRes = sal_False; if( bRes ) bRes = StoreCompleted(); return bRes; } else - return TRUE; + return sal_True; } -BOOL SbxBase::LoadData( SvStream&, USHORT ) +sal_Bool SbxBase::LoadData( SvStream&, sal_uInt16 ) { DBG_CHKTHIS( SbxBase, 0 ); - return FALSE; + return sal_False; } -BOOL SbxBase::StoreData( SvStream& ) const +sal_Bool SbxBase::StoreData( SvStream& ) const { DBG_CHKTHIS( SbxBase, 0 ); - return FALSE; + return sal_False; } -BOOL SbxBase::LoadPrivateData( SvStream&, USHORT ) +sal_Bool SbxBase::LoadPrivateData( SvStream&, sal_uInt16 ) { DBG_CHKTHIS( SbxBase, 0 ); - return TRUE; + return sal_True; } -BOOL SbxBase::StorePrivateData( SvStream& ) const +sal_Bool SbxBase::StorePrivateData( SvStream& ) const { DBG_CHKTHIS( SbxBase, 0 ); - return TRUE; + return sal_True; } -BOOL SbxBase::LoadCompleted() +sal_Bool SbxBase::LoadCompleted() { DBG_CHKTHIS( SbxBase, 0 ); - return TRUE; + return sal_True; } -BOOL SbxBase::StoreCompleted() +sal_Bool SbxBase::StoreCompleted() { DBG_CHKTHIS( SbxBase, 0 ); - return TRUE; + return sal_True; } //////////////////////////////// SbxFactory //////////////////////////////// -SbxBase* SbxFactory::Create( UINT16, UINT32 ) +SbxBase* SbxFactory::Create( sal_uInt16, sal_uInt32 ) { return NULL; } @@ -401,7 +394,7 @@ SbxInfo::~SbxInfo() {} void SbxInfo::AddParam - ( const XubString& rName, SbxDataType eType, USHORT nFlags ) + ( const XubString& rName, SbxDataType eType, sal_uInt16 nFlags ) { const SbxParamInfo* p = new SbxParamInfo( rName, eType, nFlags ); aParams.Insert( p, aParams.Count() ); @@ -414,7 +407,7 @@ void SbxInfo::AddParam( const SbxParamInfo& r ) aParams.Insert( p, aParams.Count() ); } -const SbxParamInfo* SbxInfo::GetParam( USHORT n ) const +const SbxParamInfo* SbxInfo::GetParam( sal_uInt16 n ) const { if( n < 1 || n > aParams.Count() ) return NULL; @@ -422,18 +415,18 @@ const SbxParamInfo* SbxInfo::GetParam( USHORT n ) const return aParams.GetObject( n-1 ); } -BOOL SbxInfo::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxInfo::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { aParams.Remove( 0, aParams.Count() ); - UINT16 nParam; + sal_uInt16 nParam; rStrm.ReadByteString( aComment, RTL_TEXTENCODING_ASCII_US ); rStrm.ReadByteString( aHelpFile, RTL_TEXTENCODING_ASCII_US ); rStrm >> nHelpId >> nParam; while( nParam-- ) { XubString aName; - UINT16 nType, nFlags; - UINT32 nUserData = 0; + sal_uInt16 nType, nFlags; + sal_uInt32 nUserData = 0; rStrm.ReadByteString( aName, RTL_TEXTENCODING_ASCII_US ); rStrm >> nType >> nFlags; if( nVer > 1 ) @@ -442,23 +435,23 @@ BOOL SbxInfo::LoadData( SvStream& rStrm, USHORT nVer ) SbxParamInfo* p = aParams.GetObject( aParams.Count() - 1 ); p->nUserData = nUserData; } - return TRUE; + return sal_True; } -BOOL SbxInfo::StoreData( SvStream& rStrm ) const +sal_Bool SbxInfo::StoreData( SvStream& rStrm ) const { rStrm.WriteByteString( aComment, RTL_TEXTENCODING_ASCII_US ); rStrm.WriteByteString( aHelpFile, RTL_TEXTENCODING_ASCII_US ); rStrm << nHelpId << aParams.Count(); - for( USHORT i = 0; i < aParams.Count(); i++ ) + for( sal_uInt16 i = 0; i < aParams.Count(); i++ ) { SbxParamInfo* p = aParams.GetObject( i ); rStrm.WriteByteString( p->aName, RTL_TEXTENCODING_ASCII_US ); - rStrm << (UINT16) p->eType - << (UINT16) p->nFlags - << (UINT32) p->nUserData; + rStrm << (sal_uInt16) p->eType + << (sal_uInt16) p->nFlags + << (sal_uInt32) p->nUserData; } - return TRUE; + return sal_True; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxbool.cxx b/basic/source/sbx/sbxbool.cxx index 1f7d510e48..e0efbec32b 100644 --- a/basic/source/sbx/sbxbool.cxx +++ b/basic/source/sbx/sbxbool.cxx @@ -71,14 +71,10 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) } break; case SbxSALINT64: + case SbxCURRENCY: nRes = p->nInt64 ? SbxTRUE : SbxFALSE; break; case SbxSALUINT64: nRes = p->uInt64 ? SbxTRUE : SbxFALSE; break; - case SbxULONG64: - nRes = !!p->nULong64 ? SbxTRUE : SbxFALSE; break; - case SbxLONG64: - case SbxCURRENCY: - nRes = !!p->nLong64 ? SbxTRUE : SbxFALSE; break; case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: @@ -90,15 +86,15 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) else if( !p->pOUString->equalsIgnoreAsciiCase( SbxRes( STRING_FALSE ) ) ) { // Jetzt kann es noch in eine Zahl konvertierbar sein - BOOL bError = TRUE; + sal_Bool bError = sal_True; double n; SbxDataType t; - USHORT nLen = 0; + sal_uInt16 nLen = 0; if( ImpScan( *p->pOUString, n, t, &nLen ) == SbxERR_OK ) { if( nLen == p->pOUString->getLength() ) { - bError = FALSE; + bError = sal_False; if( n != 0.0 ) nRes = SbxTRUE; } @@ -139,23 +135,18 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: nRes = ( *p->pDouble != 0 ) ? SbxTRUE : SbxFALSE; break; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: nRes = ( *p->pnInt64 ) ? SbxTRUE : SbxFALSE; break; case SbxBYREF | SbxSALUINT64: nRes = ( *p->puInt64 ) ? SbxTRUE : SbxFALSE; break; - case SbxBYREF | SbxULONG64: - nRes = !!*p->pULong64 ? SbxTRUE : SbxFALSE; break; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - nRes = !!*p->pLong64 ? SbxTRUE : SbxFALSE; break; - default: SbxBase::SetError( SbxERR_CONVERSION ); nRes = SbxFALSE; } return nRes; } -void ImpPutBool( SbxValues* p, INT16 n ) +void ImpPutBool( SbxValues* p, sal_Int16 n ) { if( n ) n = SbxTRUE; @@ -164,34 +155,30 @@ void ImpPutBool( SbxValues* p, INT16 n ) case SbxCHAR: p->nChar = (xub_Unicode) n; break; case SbxUINT: - p->nByte = (BYTE) n; break; + p->nByte = (sal_uInt8) n; break; case SbxINTEGER: case SbxBOOL: p->nInteger = n; break; case SbxLONG: p->nLong = n; break; case SbxULONG: - p->nULong = (UINT32) n; break; + p->nULong = (sal_uInt32) n; break; case SbxERROR: case SbxUSHORT: - p->nUShort = (UINT16) n; break; + p->nUShort = (sal_uInt16) n; break; case SbxSINGLE: p->nSingle = n; break; case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: case SbxSALINT64: - p->nInt64 = n; break; + p->nInt64 = (sal_Int64) n; break; case SbxSALUINT64: - p->uInt64 = n; break; - case SbxULONG64: - p->nULong64.Set( (UINT32)n ); break; - case SbxLONG64: - case SbxCURRENCY: - p->nLong64.Set( (INT32)n ); break; + p->uInt64 = (sal_uInt64) n; break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: - ImpCreateDecimal( p )->setInt( (INT16)n ); + ImpCreateDecimal( p )->setInt( (sal_Int16)n ); break; case SbxBYREF | SbxSTRING: @@ -207,7 +194,7 @@ void ImpPutBool( SbxValues* p, INT16 n ) { SbxValue* pVal = PTR_CAST(SbxValue,p->pObj); if( pVal ) - pVal->PutBool( BOOL( n != 0 ) ); + pVal->PutBool( sal_Bool( n != 0 ) ); else SbxBase::SetError( SbxERR_NO_OBJECT ); break; @@ -215,32 +202,27 @@ void ImpPutBool( SbxValues* p, INT16 n ) case SbxBYREF | SbxCHAR: *p->pChar = (xub_Unicode) n; break; case SbxBYREF | SbxBYTE: - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: *p->pLong = n; break; case SbxBYREF | SbxULONG: - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSINGLE: *p->pSingle = n; break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: - *p->pnInt64 = n; break; + *p->pnInt64 = (sal_Int64) n; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = n; break; - case SbxBYREF | SbxULONG64: - p->pULong64->Set( (UINT32)n ); break; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - p->pLong64->Set( (INT32)n ); break; - + *p->puInt64 = (sal_uInt64) n; break; default: SbxBase::SetError( SbxERR_CONVERSION ); } diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx index 0151f59bc0..a3cf94e160 100644 --- a/basic/source/sbx/sbxbyte.cxx +++ b/basic/source/sbx/sbxbyte.cxx @@ -32,10 +32,10 @@ #include <basic/sbx.hxx> #include "sbxconv.hxx" -BYTE ImpGetByte( const SbxValues* p ) +sal_uInt8 ImpGetByte( const SbxValues* p ) { SbxValues aTmp; - BYTE nRes; + sal_uInt8 nRes; start: switch( +p->eType ) { @@ -49,10 +49,10 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) p->nChar; + nRes = (sal_uInt8) p->nChar; break; case SbxBYTE: - nRes = (BYTE) p->nByte; break; + nRes = (sal_uInt8) p->nByte; break; case SbxINTEGER: case SbxBOOL: if( p->nInteger > SbxMAXBYTE ) @@ -64,16 +64,16 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) p->nInteger; + nRes = (sal_uInt8) p->nInteger; break; case SbxERROR: case SbxUSHORT: - if( p->nUShort > (USHORT) SbxMAXBYTE ) + if( p->nUShort > (sal_uInt16) SbxMAXBYTE ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXBYTE; } else - nRes = (BYTE) p->nUShort; + nRes = (sal_uInt8) p->nUShort; break; case SbxLONG: if( p->nLong > SbxMAXBYTE ) @@ -85,7 +85,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) p->nLong; + nRes = (sal_uInt8) p->nLong; break; case SbxULONG: if( p->nULong > SbxMAXBYTE ) @@ -93,10 +93,15 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXBYTE; } else - nRes = (BYTE) p->nULong; + nRes = (sal_uInt8) p->nULong; break; + case SbxCURRENCY: case SbxSALINT64: - if( p->nInt64 > SbxMAXBYTE ) + { + sal_Int64 val = p->nInt64; + if ( p->eType == SbxCURRENCY ) + val = val / CURRENCY_FACTOR; + if( val > SbxMAXBYTE ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXBYTE; } @@ -105,15 +110,16 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) p->nInt64; + nRes = (sal_uInt8) val; break; + } case SbxSALUINT64: if( p->uInt64 > SbxMAXBYTE ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXBYTE; } else - nRes = (BYTE) p->uInt64; + nRes = (sal_uInt8) p->uInt64; break; case SbxSINGLE: if( p->nSingle > SbxMAXBYTE ) @@ -125,24 +131,15 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) ImpRound( p->nSingle ); + nRes = (sal_uInt8) ImpRound( p->nSingle ); break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -160,7 +157,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) ImpRound( dVal ); + nRes = (sal_uInt8) ImpRound( dVal ); break; } case SbxBYREF | SbxSTRING: @@ -183,7 +180,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (BYTE) ( d + 0.5 ); + nRes = (sal_uInt8) ( d + 0.5 ); } break; case SbxOBJECT: @@ -219,11 +216,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -238,7 +231,7 @@ start: return nRes; } -void ImpPutByte( SbxValues* p, BYTE n ) +void ImpPutByte( SbxValues* p, sal_uInt8 n ) { switch( +p->eType ) { @@ -259,16 +252,12 @@ void ImpPutByte( SbxValues* p, BYTE n ) case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxSALUINT64: p->uInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setByte( n ); @@ -312,16 +301,12 @@ void ImpPutByte( SbxValues* p, BYTE n ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; + case SbxBYREF | SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx index ab0aff6579..14e422bd9c 100644 --- a/basic/source/sbx/sbxchar.cxx +++ b/basic/source/sbx/sbxchar.cxx @@ -81,8 +81,15 @@ start: else nRes = (xub_Unicode) p->nULong; break; + case SbxCURRENCY: case SbxSALINT64: - if( p->nInt64 > SbxMAXCHAR ) + { + sal_Int64 val = p->nInt64; + + if ( p->eType == SbxCURRENCY ) + val = val / CURRENCY_FACTOR; + + if( val > SbxMAXCHAR ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXCHAR; } @@ -91,8 +98,9 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (xub_Unicode) p->nInt64; + nRes = (xub_Unicode) val; break; + } case SbxSALUINT64: if( p->uInt64 > SbxMAXCHAR ) { @@ -115,20 +123,11 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -146,7 +145,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (BYTE) ImpRound( dVal ); + nRes = (sal_uInt8) ImpRound( dVal ); break; } case SbxBYREF | SbxSTRING: @@ -202,11 +201,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -239,16 +234,12 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxSALUINT64: p->uInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setChar( n ); break; @@ -285,32 +276,28 @@ start: case SbxBYREF | SbxCHAR: *p->pChar = n; break; case SbxBYREF | SbxBYTE: - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: *p->pInteger = n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSINGLE: *p->pSingle = (float) n; break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; + case SbxBYREF | SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx index 5bc2e08f30..23eb1c2872 100644 --- a/basic/source/sbx/sbxcoll.cxx +++ b/basic/source/sbx/sbxcoll.cxx @@ -42,9 +42,8 @@ static const char* pCount; static const char* pAdd; static const char* pItem; static const char* pRemove; -static USHORT nCountHash = 0, nAddHash, nItemHash, nRemoveHash; +static sal_uInt16 nCountHash = 0, nAddHash, nItemHash, nRemoveHash; -///////////////////////////////////////////////////////////////////////// SbxCollection::SbxCollection( const XubString& rClass ) : SbxObject( rClass ) @@ -62,7 +61,7 @@ SbxCollection::SbxCollection( const XubString& rClass ) } Initialize(); // For Access on itself - StartListening( GetBroadcaster(), TRUE ); + StartListening( GetBroadcaster(), sal_True ); } SbxCollection::SbxCollection( const SbxCollection& rColl ) @@ -102,7 +101,7 @@ void SbxCollection::Initialize() p->SetFlag( SBX_DONTSTORE ); } -SbxVariable* SbxCollection::FindUserData( UINT32 nData ) +SbxVariable* SbxCollection::FindUserData( sal_uInt32 nData ) { if( GetParameters() ) { @@ -130,9 +129,9 @@ void SbxCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1, const SbxHint* p = PTR_CAST(SbxHint,&rHint); if( p ) { - ULONG nId = p->GetId(); - BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED ); - BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED ); + sal_uIntPtr nId = p->GetId(); + sal_Bool bRead = sal_Bool( nId == SBX_HINT_DATAWANTED ); + sal_Bool bWrite = sal_Bool( nId == SBX_HINT_DATACHANGED ); SbxVariable* pVar = p->GetVar(); SbxArray* pArg = pVar->GetParameters(); if( bRead || bWrite ) @@ -192,7 +191,7 @@ void SbxCollection::CollItem( SbxArray* pPar_ ) { short n = p->GetInteger(); if( n >= 1 && n <= (short) pObjs->Count() ) - pRes = pObjs->Get( (USHORT) n - 1 ); + pRes = pObjs->Get( (sal_uInt16) n - 1 ); } if( !pRes ) SetError( SbxERR_BAD_INDEX ); @@ -212,21 +211,20 @@ void SbxCollection::CollRemove( SbxArray* pPar_ ) if( n < 1 || n > (short) pObjs->Count() ) SetError( SbxERR_BAD_INDEX ); else - Remove( pObjs->Get( (USHORT) n - 1 ) ); + Remove( pObjs->Get( (sal_uInt16) n - 1 ) ); } } -BOOL SbxCollection::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxCollection::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { - BOOL bRes = SbxObject::LoadData( rStrm, nVer ); + sal_Bool bRes = SbxObject::LoadData( rStrm, nVer ); Initialize(); return bRes; } -///////////////////////////////////////////////////////////////////////// SbxStdCollection::SbxStdCollection - ( const XubString& rClass, const XubString& rElem, BOOL b ) + ( const XubString& rClass, const XubString& rElem, sal_Bool b ) : SbxCollection( rClass ), aElemClass( rElem ), bAddRemoveOk( b ) {} @@ -278,9 +276,9 @@ void SbxStdCollection::CollRemove( SbxArray* pPar_ ) SbxCollection::CollRemove( pPar_ ); } -BOOL SbxStdCollection::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxStdCollection::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { - BOOL bRes = SbxCollection::LoadData( rStrm, nVer ); + sal_Bool bRes = SbxCollection::LoadData( rStrm, nVer ); if( bRes ) { rStrm.ReadByteString( aElemClass, RTL_TEXTENCODING_ASCII_US ); @@ -289,9 +287,9 @@ BOOL SbxStdCollection::LoadData( SvStream& rStrm, USHORT nVer ) return bRes; } -BOOL SbxStdCollection::StoreData( SvStream& rStrm ) const +sal_Bool SbxStdCollection::StoreData( SvStream& rStrm ) const { - BOOL bRes = SbxCollection::StoreData( rStrm ); + sal_Bool bRes = SbxCollection::StoreData( rStrm ); if( bRes ) { rStrm.WriteByteString( aElemClass, RTL_TEXTENCODING_ASCII_US ); diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx index 66ce3fb03e..bbce15e0be 100644 --- a/basic/source/sbx/sbxconv.hxx +++ b/basic/source/sbx/sbxconv.hxx @@ -34,32 +34,34 @@ class SbxArray; // SBXSCAN.CXX -extern void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, BOOL bCoreString=FALSE ); +extern void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, sal_Bool bCoreString=sal_False ); extern SbxError ImpScan - ( const ::rtl::OUString& rSrc, double& nVal, SbxDataType& rType, USHORT* pLen, - BOOL bAllowIntntl=FALSE, BOOL bOnlyIntntl=FALSE ); + ( const ::rtl::OUString& rSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen, + sal_Bool bAllowIntntl=sal_False, sal_Bool bOnlyIntntl=sal_False ); // with advanced evaluation (International, "TRUE"/"FALSE") -extern BOOL ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ); +extern sal_Bool ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ); // SBXINT.CXX double ImpRound( double ); -INT16 ImpGetInteger( const SbxValues* ); -void ImpPutInteger( SbxValues*, INT16 ); +sal_Int16 ImpGetInteger( const SbxValues* ); +void ImpPutInteger( SbxValues*, sal_Int16 ); + sal_Int64 ImpGetInt64( const SbxValues* ); void ImpPutInt64( SbxValues*, sal_Int64 ); sal_uInt64 ImpGetUInt64( const SbxValues* ); void ImpPutUInt64( SbxValues*, sal_uInt64 ); -sal_Int64 ImpDoubleToSalInt64( double d ); +sal_Int64 ImpDoubleToSalInt64 ( double d ); sal_uInt64 ImpDoubleToSalUInt64( double d ); +double ImpSalInt64ToDouble ( sal_Int64 n ); double ImpSalUInt64ToDouble( sal_uInt64 n ); // SBXLNG.CXX -INT32 ImpGetLong( const SbxValues* ); -void ImpPutLong( SbxValues*, INT32 ); +sal_Int32 ImpGetLong( const SbxValues* ); +void ImpPutLong( SbxValues*, sal_Int32 ); // SBXSNG.CXX @@ -69,39 +71,20 @@ void ImpPutSingle( SbxValues*, float ); // SBXDBL.CXX double ImpGetDouble( const SbxValues* ); -void ImpPutDouble( SbxValues*, double, BOOL bCoreString=FALSE ); - -#if FALSE -// SBX64.CXX - -SbxINT64 ImpGetINT64( const SbxValues* ); -void ImpPutINT64( SbxValues*, const SbxINT64& ); -SbxUINT64 ImpGetUINT64( const SbxValues* ); -void ImpPutUINT64( SbxValues*, const SbxUINT64& ); -#endif +void ImpPutDouble( SbxValues*, double, sal_Bool bCoreString=sal_False ); // SBXCURR.CXX -SbxUINT64 ImpDoubleToUINT64( double ); -double ImpUINT64ToDouble( const SbxUINT64& ); -SbxINT64 ImpDoubleToINT64( double ); -double ImpINT64ToDouble( const SbxINT64& ); +sal_Int64 ImpGetCurrency( const SbxValues* ); +void ImpPutCurrency( SbxValues*, const sal_Int64 ); -#if TRUE -INT32 ImpGetCurrLong( const SbxValues* ); -void ImpPutCurrLong( SbxValues*, INT32 ); -INT32 ImpDoubleToCurrLong( double ); -double ImpCurrLongToDouble( INT32 ); -#endif +inline sal_Int64 ImpDoubleToCurrency( double d ) + { if (d > 0) return (sal_Int64)( d * CURRENCY_FACTOR + 0.5); + else return (sal_Int64)( d * CURRENCY_FACTOR - 0.5); + } -SbxINT64 ImpGetCurrency( const SbxValues* ); -void ImpPutCurrency( SbxValues*, const SbxINT64& ); -inline -SbxINT64 ImpDoubleToCurrency( double d ) - { return ImpDoubleToINT64( d * CURRENCY_FACTOR ); } -inline -double ImpCurrencyToDouble( const SbxINT64 &r ) - { return ImpINT64ToDouble( r ) / CURRENCY_FACTOR; } +inline double ImpCurrencyToDouble( const sal_Int64 r ) + { return (double)r / (double)CURRENCY_FACTOR; } // SBXDEC.CXX @@ -124,28 +107,28 @@ void ImpPutString( SbxValues*, const ::rtl::OUString* ); // SBXCHAR.CXX sal_Unicode ImpGetChar( const SbxValues* ); -void ImpPutChar( SbxValues*, sal_Unicode ); +void ImpPutChar( SbxValues*, sal_Unicode ); // SBXBYTE.CXX -BYTE ImpGetByte( const SbxValues* ); -void ImpPutByte( SbxValues*, BYTE ); +sal_uInt8 ImpGetByte( const SbxValues* ); +void ImpPutByte( SbxValues*, sal_uInt8 ); // SBXUINT.CXX -UINT16 ImpGetUShort( const SbxValues* ); -void ImpPutUShort( SbxValues*, UINT16 ); +sal_uInt16 ImpGetUShort( const SbxValues* ); +void ImpPutUShort( SbxValues*, sal_uInt16 ); // SBXULNG.CXX -UINT32 ImpGetULong( const SbxValues* ); -void ImpPutULong( SbxValues*, UINT32 ); +sal_uInt32 ImpGetULong( const SbxValues* ); +void ImpPutULong( SbxValues*, sal_uInt32 ); // SBXBOOL.CXX enum SbxBOOL ImpGetBool( const SbxValues* ); -void ImpPutBool( SbxValues*, INT16 ); +void ImpPutBool( SbxValues*, sal_Int16 ); -// ByteArry <--> String +// ByteArray <--> String SbxArray* StringToByteArray(const ::rtl::OUString& rStr); ::rtl::OUString ByteArrayToString(SbxArray* pArr); diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx index 0057d6f93a..0ea500bb0b 100644 --- a/basic/source/sbx/sbxcurr.cxx +++ b/basic/source/sbx/sbxcurr.cxx @@ -2,7 +2,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 @@ -29,101 +29,305 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#include <basic/sbx.hxx> #include <tools/errcode.hxx> +#include <vcl/svapp.hxx> // for SvtSysLocale -#define _TLBIGINT_INT64 -#include <tools/bigint.hxx> - +#include <basic/sbx.hxx> #include <basic/sbxvar.hxx> #include "sbxconv.hxx" -static ::rtl::OUString ImpCurrencyToString( const SbxINT64& ); -static SbxINT64 ImpStringToCurrency( const ::rtl::OUString& ); -SbxINT64 ImpGetCurrency( const SbxValues* p ) +static rtl::OUString ImpCurrencyToString( const sal_Int64 &rVal ) { - SbxValues aTmp; - SbxINT64 nRes; + bool isNeg = ( rVal < 0 ); + sal_Int64 absVal = isNeg ? -rVal : rVal; + + SvtSysLocale aSysLocale; + sal_Unicode cDecimalSep = '.'; +#if MAYBEFUTURE + sal_Unicode cThousandSep = ','; + const LocaleDataWrapper& rData = aSysLocale.GetLocaleData(); + cDecimalSep = rData.getNumDecimalSep().GetBuffer()[0]; + cThousandSep = rData.getNumThousandSep().GetBuffer()[0]; +#endif + + rtl::OUString aAbsStr = rtl::OUString::valueOf( absVal ); + rtl::OUStringBuffer aBuf; + + sal_Int32 initialLen = aAbsStr.getLength(); + + bool bLessThanOne = false; + if ( initialLen <= 4 ) // if less the 1 + bLessThanOne = true; + + sal_Int32 nCapacity = 6; // minimum e.g. 0.0000 + + if ( !bLessThanOne ) + { + nCapacity = initialLen + 1; +#if MAYBEFUTURE + if ( initialLen > 5 ) + { + sal_Int32 nThouSeperators = ( initialLen - 5 ) / 3; + nCapacity += nThouSeperators; + } +#endif + } + + if ( isNeg ) + ++nCapacity; + + aBuf.setLength( nCapacity ); + + + sal_Int32 nDigitCount = 0; + sal_Int32 nInsertIndex = nCapacity - 1; + sal_Int32 nEndIndex = isNeg ? 1 : 0; + + for ( sal_Int32 charCpyIndex = aAbsStr.getLength() - 1; nInsertIndex >= nEndIndex; ++nDigitCount ) + { + if ( nDigitCount == 4 ) + aBuf.setCharAt( nInsertIndex--, cDecimalSep ); +#if MAYBEFUTURE + if ( nDigitCount > 4 && ! ( ( nDigitCount - 4 ) % 3) ) + aBuf.setCharAt( nInsertIndex--, cThousandSep ); +#endif + if ( nDigitCount < initialLen ) + aBuf.setCharAt( nInsertIndex--, aAbsStr[ charCpyIndex-- ] ); + else + // Handle leading 0's to right of decimal point + // Note: in VBA the stringification is a little more complex + // but more natural as only the necessary digits + // to the right of the decimal places are displayed + // It would be great to conditionally be able to display like that too + // + // Val OOo (Cur) VBA (Cur) + // --- --------- --------- + // 0 0.0000 0 + // 0.1 0.1000 0.1 + + aBuf.setCharAt( nInsertIndex--, (sal_Unicode)'0' ); + } + if ( isNeg ) + aBuf.setCharAt( nInsertIndex, (sal_Unicode)'-' ); + + aAbsStr = aBuf.makeStringAndClear(); + return aAbsStr; +} + + +static sal_Int64 ImpStringToCurrency( const rtl::OUString &rStr ) +{ + + sal_Int32 nFractDigit = 4; + + SvtSysLocale aSysLocale; + sal_Unicode cDeciPnt = sal_Unicode('.'); + sal_Unicode c1000Sep = sal_Unicode(','); + +#if MAYBEFUTURE + const LocaleDataWrapper& rData = aSysLocale.GetLocaleData(); + sal_Unicode cLocaleDeciPnt = rData.getNumDecimalSep().GetBuffer()[0]; + sal_Unicode cLocale1000Sep = rData.getNumThousandSep().GetBuffer()[0]; + + // score each set of separators (Locale and Basic) on total number of matches + // if one set has more matches use that set + // if tied use the set with the only or rightmost decimal separator match + // currency is fixed pt system: usually expect the decimal pt, 1000sep may occur + sal_Int32 LocaleScore = 0; + sal_Int32 LocaleLastDeci = -1; + sal_Int32 LOBasicScore = 0; + sal_Int32 LOBasicLastDeci = -1; + + for( int idx=0; idx<rStr.getLength(); idx++ ) + { + if ( *(p+idx) == cLocaleDeciPnt ) + { + LocaleScore++; + LocaleLastDeci = idx; + } + if ( *(p+idx) == cLocale1000Sep ) + LocaleScore++; + + if ( *(p+idx) == cDeciPnt ) + { + LOBasicScore++; + LOBasicLastDeci = idx; + } + if ( *(p+idx) == c1000Sep ) + LOBasicScore++; + } + if ( ( LocaleScore > LOBasicScore ) + ||( LocaleScore = LOBasicScore && LocaleLastDeci > LOBasicLastDeci ) ) + { + cDeciPnt = cLocaleDeciPnt; + c1000Sep = cLocale1000Sep; + } +#endif + + // lets use the existing string number conversions + // there is a performance impact here ( multiple string copies ) + // but better I think than a home brewed string parser, if we need a parser + // we should share some existing ( possibly from calc is there a currency + // conversion there ? #TODO check ) + + rtl::OUString sTmp( rStr.trim() ); + const sal_Unicode* p = sTmp.getStr(); + + // normalise string number by removeing thousands & decimal point seperators + rtl::OUStringBuffer sNormalisedNumString( sTmp.getLength() + nFractDigit ); + + if ( *p == '-' || *p == '+' ) + sNormalisedNumString.append( *p ); + + while ( ( *p >= '0' && *p <= '9' ) ) + { + sNormalisedNumString.append( *p++ ); + // #TODO in vba mode set runtime error when a space ( or other ) + // illegal character is found + if( *p == c1000Sep ) + p++; + } + + bool bRoundUp = false; + + if( *p == cDeciPnt ) + { + p++; + while( nFractDigit && *p >= '0' && *p <= '9' ) + { + sNormalisedNumString.append( *p++ ); + nFractDigit--; + } + // Consume trailing content + if ( p != NULL ) + { + // Round up if necessary + if( *p >= '5' && *p <= '9' ) + bRoundUp = true; + while( *p >= '0' && *p <= '9' ) + p++; + } + + } + // can we raise error here ? ( previous behaviour was more forgiving ) + // so... not sure that could bread existing code, lets see if anyone + // complains. + + if ( p != sTmp.getStr() + sTmp.getLength() ) + SbxBase::SetError( SbxERR_CONVERSION ); + while( nFractDigit ) + { + sNormalisedNumString.append( sal_Unicode('0') ); + nFractDigit--; + } + + sal_Int64 result = sNormalisedNumString.makeStringAndClear().toInt64(); + + if ( bRoundUp ) + ++result; + return result; +} + + +sal_Int64 ImpGetCurrency( const SbxValues* p ) +{ + SbxValues aTmp; + sal_Int64 nRes; start: switch( +p->eType ) { + case SbxERROR: case SbxNULL: SbxBase::SetError( SbxERR_CONVERSION ); + nRes = 0; break; case SbxEMPTY: - nRes.SetNull(); break; - case SbxCHAR: - nRes = ImpDoubleToCurrency( (double)p->nChar ); break; + nRes = 0; break; + case SbxCURRENCY: + nRes = p->nInt64; break; case SbxBYTE: - nRes = ImpDoubleToCurrency( (double)p->nByte ); break; - case SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nByte); + break; + case SbxCHAR: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->pChar); + break; case SbxBOOL: - nRes = ImpDoubleToCurrency( (double)p->nInteger ); break; - case SbxERROR: + case SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nInteger); + break; case SbxUSHORT: - nRes = ImpDoubleToCurrency( (double)p->nUShort ); break; - case SbxCURRENCY: - nRes = p->nLong64; break; + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nUShort); + break; case SbxLONG: - nRes = ImpDoubleToCurrency( (double)p->nLong ); + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nLong); break; case SbxULONG: - nRes = ImpDoubleToCurrency( (double)p->nULong ); + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nULong); break; + case SbxSALINT64: - nRes = ImpDoubleToCurrency( (double)p->nInt64 ); - break; + { + nRes = p->nInt64 * CURRENCY_FACTOR; break; + if ( nRes > SbxMAXSALINT64 ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXSALINT64; + } + } case SbxSALUINT64: - nRes = ImpDoubleToCurrency( ImpSalUInt64ToDouble( p->uInt64 ) ); - break; - case SbxSINGLE: - if( p->nSingle > SbxMAXCURR ) + nRes = p->nInt64 * CURRENCY_FACTOR; break; + if ( nRes > SbxMAXSALINT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXSALINT64; } - else if( p->nSingle < SbxMINCURR ) + else if ( nRes < SbxMINSALINT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINSALINT64; } - else - nRes = ImpDoubleToCurrency( (double)p->nSingle ); break; - case SbxDATE: - case SbxDOUBLE: - if( p->nDouble > SbxMAXCURR ) +//TODO: bring back SbxINT64 types here for limits -1 with flag value at SAL_MAX/MIN + case SbxSINGLE: + if( p->nSingle * CURRENCY_FACTOR + 0.5 > (float)SAL_MAX_INT64 + || p->nSingle * CURRENCY_FACTOR - 0.5 < (float)SAL_MIN_INT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); + nRes = SAL_MAX_INT64; + if( p->nSingle * CURRENCY_FACTOR - 0.5 < (float)SAL_MIN_INT64 ) + nRes = SAL_MIN_INT64; + SbxBase::SetError( SbxERR_OVERFLOW ); + break; } - else if( p->nDouble < SbxMINCURR ) + nRes = ImpDoubleToCurrency( (double)p->nSingle ); + break; + + case SbxDATE: + case SbxDOUBLE: + if( p->nDouble * CURRENCY_FACTOR + 0.5 > (double)SAL_MAX_INT64 + || p->nDouble * CURRENCY_FACTOR - 0.5 < (double)SAL_MIN_INT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); + nRes = SAL_MAX_INT64; + if( p->nDouble * CURRENCY_FACTOR - 0.5 < (double)SAL_MIN_INT64 ) + nRes = SAL_MIN_INT64; + SbxBase::SetError( SbxERR_OVERFLOW ); + break; } - else - nRes = ImpDoubleToCurrency( p->nDouble ); + nRes = ImpDoubleToCurrency( p->nDouble ); break; + case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double d = 0.0; if( p->pDecimal ) p->pDecimal->getDouble( d ); - if( d > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); - } - else if( d < SbxMINCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); - } - else - nRes = ImpDoubleToCurrency( d ); + nRes = ImpDoubleToCurrency( d ); break; } + + case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: if( !p->pOUString ) - nRes.SetNull(); + nRes=0; else nRes = ImpStringToCurrency( *p->pOUString ); break; @@ -134,23 +338,26 @@ start: nRes = pVal->GetCurrency(); else { - SbxBase::SetError( SbxERR_NO_OBJECT ); nRes.SetNull(); + SbxBase::SetError( SbxERR_NO_OBJECT ); + nRes=0; } break; } case SbxBYREF | SbxCHAR: - nRes = ImpDoubleToCurrency( (double)*p->pChar ); break; + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pChar); + break; case SbxBYREF | SbxBYTE: - nRes = ImpDoubleToCurrency( (double)*p->pByte ); break; - case SbxBYREF | SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pByte); + break; case SbxBYREF | SbxBOOL: - nRes = ImpDoubleToCurrency( (double)*p->pInteger ); break; + case SbxBYREF | SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pInteger); + break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - nRes = ImpDoubleToCurrency( (double)*p->pUShort ); break; - case SbxBYREF | SbxCURRENCY: - nRes = *p->pLong64; break; + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pUShort); + break; // from here on had to be tested case SbxBYREF | SbxLONG: @@ -162,23 +369,25 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: aTmp.uInt64 = *p->puInt64; goto ref; ref: - aTmp.eType = SbxDataType( p->eType & 0x0FFF ); + aTmp.eType = SbxDataType( p->eType & ~SbxBYREF ); p = &aTmp; goto start; default: - SbxBase::SetError( SbxERR_CONVERSION ); nRes.SetNull(); + SbxBase::SetError( SbxERR_CONVERSION ); + nRes=0; } return nRes; } -void ImpPutCurrency( SbxValues* p, const SbxINT64 &r ) + +void ImpPutCurrency( SbxValues* p, const sal_Int64 r ) { - double dVal = ImpCurrencyToDouble( r ); SbxValues aTmp; start: switch( +p->eType ) @@ -204,29 +413,31 @@ start: // from here no longer case SbxSINGLE: - p->nSingle = (float)dVal; break; + p->nSingle = (float)( r / CURRENCY_FACTOR ); break; case SbxDATE: case SbxDOUBLE: - p->nDouble = dVal; break; - case SbxSALINT64: - p->nInt64 = ImpDoubleToSalInt64( dVal ); break; + p->nDouble = ImpCurrencyToDouble( r ); break; case SbxSALUINT64: - p->uInt64 = ImpDoubleToSalUInt64( dVal ); break; + p->uInt64 = r / CURRENCY_FACTOR; break; + case SbxSALINT64: + p->nInt64 = r / CURRENCY_FACTOR; break; + case SbxCURRENCY: - p->nLong64 = r; break; + p->nInt64 = r; break; + case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { SbxDecimal* pDec = ImpCreateDecimal( p ); - if( !pDec->setDouble( dVal ) ) - SbxBase::SetError( SbxERR_OVERFLOW ); + if( !pDec->setDouble( ImpCurrencyToDouble( r ) / CURRENCY_FACTOR ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); break; } case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: if( !p->pOUString ) - p->pOUString = new ::rtl::OUString; + p->pOUString = new rtl::OUString; *p->pOUString = ImpCurrencyToString( r ); break; @@ -240,158 +451,100 @@ start: break; } case SbxBYREF | SbxCHAR: - if( dVal > SbxMAXCHAR ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXCHAR ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXCHAR; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXCHAR; } - else if( dVal < SbxMINCHAR ) + else if( val < SbxMINCHAR ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINCHAR; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMINCHAR; } - *p->pChar = (xub_Unicode) dVal; break; + *p->pChar = (sal_Unicode) val; break; + } case SbxBYREF | SbxBYTE: - if( dVal > SbxMAXBYTE ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXBYTE ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXBYTE; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXBYTE; } - else if( dVal < 0 ) + else if( val < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); val = 0; } - *p->pByte = (BYTE) dVal; break; + *p->pByte = (sal_uInt8) val; break; + } case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: - if( dVal > SbxMAXINT ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( r > SbxMAXINT ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXINT; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXINT; } - else if( dVal < SbxMININT ) + else if( r < SbxMININT ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMININT; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMININT; } - *p->pInteger = (INT16) dVal; break; + *p->pInteger = (sal_uInt16) val; break; + } case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - if( dVal > SbxMAXUINT ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXUINT ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXUINT; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXUINT; } - else if( dVal < 0 ) + else if( val < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); val = 0; } - *p->pUShort = (UINT16) dVal; break; + *p->pUShort = (sal_uInt16) val; break; + } case SbxBYREF | SbxLONG: - if( dVal > SbxMAXLNG ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXLNG ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXLNG; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXLNG; } - else if( dVal < SbxMINLNG ) + else if( val < SbxMINLNG ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINLNG; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMINLNG; } - *p->pLong = (INT32) dVal; break; + *p->pLong = (sal_Int32) val; break; + } case SbxBYREF | SbxULONG: - if( dVal > SbxMAXULNG ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXULNG ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXULNG; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXULNG; } - else if( dVal < 0 ) + else if( val < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); val = 0; } - *p->pULong = (UINT32) dVal; break; + *p->pULong = (sal_uInt32) val; break; + break; + } + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = r; break; case SbxBYREF | SbxSALINT64: - *p->pnInt64 = ImpDoubleToSalInt64( dVal ); break; + *p->pnInt64 = r / CURRENCY_FACTOR; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = ImpDoubleToSalUInt64( dVal ); break; + *p->puInt64 = (sal_uInt64)r / CURRENCY_FACTOR; break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) dVal; break; + p->nSingle = (float)( r / CURRENCY_FACTOR ); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) dVal; break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = r; break; - + *p->pDouble = ImpCurrencyToDouble( r ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } -// help functions for the conversion - -static ::rtl::OUString ImpCurrencyToString( const SbxINT64 &r ) -{ - BigInt a10000 = 10000; - - //return GetpApp()->GetAppInternational().GetCurr( BigInt( r ), 4 ); - BigInt aInt( r ); - aInt.Abs(); - BigInt aFrac = aInt; - aInt /= a10000; - aFrac %= a10000; - aFrac += a10000; - - ::rtl::OUString aString; - if( r.nHigh < 0 ) - aString = ::rtl::OUString( (sal_Unicode)'-' ); - aString += aInt.GetString(); - aString += ::rtl::OUString( (sal_Unicode)'.' ); - aString += aFrac.GetString().GetBuffer()+1; - return aString; -} - -static SbxINT64 ImpStringToCurrency( const ::rtl::OUString &r ) -{ - int nDec = 4; - String aStr; - const sal_Unicode* p = r.getStr(); - - if( *p == '-' ) - aStr += *p++; - - while( *p >= '0' && *p <= '9' ) { - aStr += *p++; - if( *p == ',' ) - p++; - } - - if( *p == '.' ) { - p++; - while( nDec && *p >= '0' && *p <= '9' ) { - aStr += *p++; - nDec--; - } - } - while( nDec ) { - aStr += '0'; - nDec--; - } - - BigInt aBig( aStr ); - SbxINT64 nRes; - aBig.INT64( &nRes ); - return nRes; -} - -double ImpINT64ToDouble( const SbxINT64 &r ) -{ return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; } - -SbxINT64 ImpDoubleToINT64( double d ) -{ - SbxINT64 nRes; - nRes.Set( d ); - return nRes; -} - -double ImpUINT64ToDouble( const SbxUINT64 &r ) -{ return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; } - -SbxUINT64 ImpDoubleToUINT64( double d ) -{ - SbxUINT64 nRes; - nRes.Set( d ); - return nRes; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxdate.cxx b/basic/source/sbx/sbxdate.cxx index ed151a7967..afde12a7aa 100644 --- a/basic/source/sbx/sbxdate.cxx +++ b/basic/source/sbx/sbxdate.cxx @@ -67,12 +67,8 @@ double ImpGetDate( const SbxValues* p ) case SbxDATE: case SbxDOUBLE: nRes = p->nDouble; break; - case SbxULONG64: - nRes = ImpUINT64ToDouble( p->nULong64 ); break; - case SbxLONG64: - nRes = ImpINT64ToDouble( p->nLong64 ); break; case SbxCURRENCY: - nRes = ImpCurrencyToDouble( p->nLong64 ); break; + nRes = ImpCurrencyToDouble( p->nInt64 ); break; case SbxSALINT64: nRes = static_cast< double >(p->nInt64); break; case SbxSALUINT64: @@ -91,7 +87,6 @@ double ImpGetDate( const SbxValues* p ) nRes = 0; else { -#ifndef DOS LanguageType eLangType = GetpApp()->GetSettings().GetLanguage(); SvNumberFormatter* pFormatter; @@ -127,13 +122,13 @@ double ImpGetDate( const SbxValues* p ) pFormatter->PutandConvertEntry( aStr, nCheckPos, nType, nIndex, LANGUAGE_GERMAN, eLangType ); - BOOL bSuccess = pFormatter->IsNumberFormat( *p->pOUString, nIndex, nRes ); + sal_Bool bSuccess = pFormatter->IsNumberFormat( *p->pOUString, nIndex, nRes ); if ( bSuccess ) { short nType_ = pFormatter->GetType( nIndex ); if(!(nType_ & ( NUMBERFORMAT_DATETIME | NUMBERFORMAT_DATE | NUMBERFORMAT_TIME | NUMBERFORMAT_DEFINED ))) - bSuccess = FALSE; + bSuccess = sal_False; } if ( !bSuccess ) @@ -142,9 +137,6 @@ double ImpGetDate( const SbxValues* p ) } delete pFormatter; -#else - SbxBase::SetError( SbxERR_CONVERSION ); nRes = 0; -#endif } break; case SbxOBJECT: @@ -178,12 +170,8 @@ double ImpGetDate( const SbxValues* p ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: nRes = *p->pDouble; break; - case SbxBYREF | SbxULONG64: - nRes = ImpUINT64ToDouble( *p->pULong64 ); break; - case SbxBYREF | SbxLONG64: - nRes = ImpINT64ToDouble( *p->pLong64 ); break; case SbxBYREF | SbxCURRENCY: - nRes = ImpCurrencyToDouble( *p->pLong64 ); break; + nRes = ImpCurrencyToDouble( *p->pnInt64 ); break; case SbxBYREF | SbxSALINT64: nRes = static_cast< double >(*p->pnInt64); break; case SbxBYREF | SbxSALUINT64: @@ -223,11 +211,7 @@ start: aTmp.pUShort = &p->nUShort; goto direct; case SbxSINGLE: aTmp.pSingle = &p->nSingle; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: @@ -247,7 +231,6 @@ start: case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: -#ifndef DOS { if( !p->pOUString ) p->pOUString = new ::rtl::OUString; @@ -304,11 +287,8 @@ start: pFormatter->GetOutputString( n, nIndex, aTmpString, &pColor ); *p->pOUString = aTmpString; delete pFormatter; -#endif break; -#ifndef DOS } -#endif case SbxOBJECT: { SbxValue* pVal = PTR_CAST(SbxValue,p->pObj); @@ -337,7 +317,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -348,7 +328,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -359,7 +339,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { @@ -369,7 +349,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINLNG; } - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { @@ -379,7 +359,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSINGLE: if( n > SbxMAXSNG ) { @@ -406,7 +386,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR; } - *p->pLong64 = ImpDoubleToCurrency( n ); break; + *p->pnInt64 = ImpDoubleToCurrency( n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx index 32d4a891b3..10e24d0584 100644 --- a/basic/source/sbx/sbxdbl.cxx +++ b/basic/source/sbx/sbxdbl.cxx @@ -62,7 +62,7 @@ double ImpGetDouble( const SbxValues* p ) case SbxDOUBLE: nRes = p->nDouble; break; case SbxCURRENCY: - nRes = ImpCurrencyToDouble( p->nLong64 ); break; + nRes = ImpCurrencyToDouble( p->nInt64 ); break; case SbxSALINT64: nRes = static_cast< double >(p->nInt64); break; case SbxSALUINT64: @@ -129,7 +129,7 @@ double ImpGetDouble( const SbxValues* p ) case SbxBYREF | SbxDOUBLE: nRes = *p->pDouble; break; case SbxBYREF | SbxCURRENCY: - nRes = ImpCurrencyToDouble( *p->pLong64 ); break; + nRes = ImpCurrencyToDouble( *p->pnInt64 ); break; case SbxBYREF | SbxSALINT64: nRes = static_cast< double >(*p->pnInt64); break; case SbxBYREF | SbxSALUINT64: @@ -141,7 +141,7 @@ double ImpGetDouble( const SbxValues* p ) return nRes; } -void ImpPutDouble( SbxValues* p, double n, BOOL bCoreString ) +void ImpPutDouble( SbxValues* p, double n, sal_Bool bCoreString ) { SbxValues aTmp; start: @@ -156,7 +156,6 @@ start: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; case SbxLONG: - case SbxCURRENCY: aTmp.pLong = &p->nLong; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; @@ -177,6 +176,18 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; + case SbxCURRENCY: + if( n > SbxMAXCURR ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXCURR; + } + else if( n < SbxMINCURR ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR; + } + p->nInt64 = ImpDoubleToCurrency( n ); + break; + // from here on no longer case SbxSALINT64: p->nInt64 = ImpDoubleToSalInt64( n ); break; @@ -221,7 +232,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -232,7 +243,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -243,7 +254,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { @@ -253,7 +264,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINLNG; } - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { @@ -263,7 +274,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSINGLE: if( n > SbxMAXSNG ) { @@ -298,7 +309,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR; } - *p->pLong64 = ImpDoubleToCurrency( n ); break; + *p->pnInt64 = ImpDoubleToCurrency( n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx index 2b53c5fc1c..b0f146c088 100644 --- a/basic/source/sbx/sbxdec.cxx +++ b/basic/source/sbx/sbxdec.cxx @@ -36,14 +36,11 @@ #include <com/sun/star/bridge/oleautomation/Decimal.hpp> -// int GnDecCounter = 0; - // Implementation SbxDecimal SbxDecimal::SbxDecimal( void ) { setInt( 0 ); mnRefCount = 0; - // GnDecCounter++; } SbxDecimal::SbxDecimal( const SbxDecimal& rDec ) @@ -54,7 +51,6 @@ SbxDecimal::SbxDecimal( const SbxDecimal& rDec ) (void)rDec; #endif mnRefCount = 0; - // GnDecCounter++; } SbxDecimal::SbxDecimal @@ -70,7 +66,6 @@ SbxDecimal::SbxDecimal (void)rAutomationDec; #endif mnRefCount = 0; - // GnDecCounter++; } void SbxDecimal::fillAutomationDecimal @@ -89,7 +84,6 @@ void SbxDecimal::fillAutomationDecimal SbxDecimal::~SbxDecimal() { - // GnDecCounter--; } void releaseDecimalPtr( SbxDecimal*& rpDecimal ) @@ -159,32 +153,32 @@ SbxDecimal::CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight void SbxDecimal::setChar( sal_Unicode val ) { - VarDecFromUI2( (USHORT)val, &maDec ); + VarDecFromUI2( (sal_uInt16)val, &maDec ); } -void SbxDecimal::setByte( BYTE val ) +void SbxDecimal::setByte( sal_uInt8 val ) { - VarDecFromUI1( (BYTE)val, &maDec ); + VarDecFromUI1( (sal_uInt8)val, &maDec ); } -void SbxDecimal::setShort( INT16 val ) +void SbxDecimal::setShort( sal_Int16 val ) { VarDecFromI2( (short)val, &maDec ); } -void SbxDecimal::setLong( INT32 val ) +void SbxDecimal::setLong( sal_Int32 val ) { VarDecFromI4( (long)val, &maDec ); } -void SbxDecimal::setUShort( UINT16 val ) +void SbxDecimal::setUShort( sal_uInt16 val ) { - VarDecFromUI2( (USHORT)val, &maDec ); + VarDecFromUI2( (sal_uInt16)val, &maDec ); } -void SbxDecimal::setULong( UINT32 val ) +void SbxDecimal::setULong( sal_uInt32 val ) { - VarDecFromUI4( (ULONG)val, &maDec ); + VarDecFromUI4( (sal_uIntPtr)val, &maDec ); } bool SbxDecimal::setSingle( float val ) @@ -201,12 +195,12 @@ bool SbxDecimal::setDouble( double val ) void SbxDecimal::setInt( int val ) { - setLong( (INT32)val ); + setLong( (sal_Int32)val ); } void SbxDecimal::setUInt( unsigned int val ) { - setULong( (UINT32)val ); + setULong( (sal_uInt32)val ); } // sbxscan.cxx @@ -262,31 +256,31 @@ bool SbxDecimal::getChar( sal_Unicode& rVal ) return bRet; } -bool SbxDecimal::getByte( BYTE& rVal ) +bool SbxDecimal::getByte( sal_uInt8& rVal ) { bool bRet = ( VarUI1FromDec( &maDec, &rVal ) == S_OK ); return bRet; } -bool SbxDecimal::getShort( INT16& rVal ) +bool SbxDecimal::getShort( sal_Int16& rVal ) { bool bRet = ( VarI2FromDec( &maDec, &rVal ) == S_OK ); return bRet; } -bool SbxDecimal::getLong( INT32& rVal ) +bool SbxDecimal::getLong( sal_Int32& rVal ) { bool bRet = ( VarI4FromDec( &maDec, &rVal ) == S_OK ); return bRet; } -bool SbxDecimal::getUShort( UINT16& rVal ) +bool SbxDecimal::getUShort( sal_uInt16& rVal ) { bool bRet = ( VarUI2FromDec( &maDec, &rVal ) == S_OK ); return bRet; } -bool SbxDecimal::getULong( UINT32& rVal ) +bool SbxDecimal::getULong( sal_uInt32& rVal ) { bool bRet = ( VarUI4FromDec( &maDec, &rVal ) == S_OK ); return bRet; @@ -306,7 +300,7 @@ bool SbxDecimal::getDouble( double& rVal ) bool SbxDecimal::getInt( int& rVal ) { - INT32 TmpVal; + sal_Int32 TmpVal; bool bRet = getLong( TmpVal ); rVal = TmpVal; return bRet; @@ -314,7 +308,7 @@ bool SbxDecimal::getInt( int& rVal ) bool SbxDecimal::getUInt( unsigned int& rVal ) { - UINT32 TmpVal; + sal_uInt32 TmpVal; bool bRet = getULong( TmpVal ); rVal = TmpVal; return bRet; @@ -365,11 +359,11 @@ SbxDecimal::CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight } void SbxDecimal::setChar( sal_Unicode val ) { (void)val; } -void SbxDecimal::setByte( BYTE val ) { (void)val; } -void SbxDecimal::setShort( INT16 val ) { (void)val; } -void SbxDecimal::setLong( INT32 val ) { (void)val; } -void SbxDecimal::setUShort( UINT16 val ) { (void)val; } -void SbxDecimal::setULong( UINT32 val ) { (void)val; } +void SbxDecimal::setByte( sal_uInt8 val ) { (void)val; } +void SbxDecimal::setShort( sal_Int16 val ) { (void)val; } +void SbxDecimal::setLong( sal_Int32 val ) { (void)val; } +void SbxDecimal::setUShort( sal_uInt16 val ) { (void)val; } +void SbxDecimal::setULong( sal_uInt32 val ) { (void)val; } bool SbxDecimal::setSingle( float val ) { (void)val; return false; } bool SbxDecimal::setDouble( double val ) { (void)val; return false; } void SbxDecimal::setInt( int val ) { (void)val; } @@ -377,11 +371,11 @@ void SbxDecimal::setUInt( unsigned int val ) { (void)val; } bool SbxDecimal::setString( ::rtl::OUString* pOUString ) { (void)pOUString; return false; } bool SbxDecimal::getChar( sal_Unicode& rVal ) { (void)rVal; return false; } -bool SbxDecimal::getByte( BYTE& rVal ) { (void)rVal; return false; } -bool SbxDecimal::getShort( INT16& rVal ) { (void)rVal; return false; } -bool SbxDecimal::getLong( INT32& rVal ) { (void)rVal; return false; } -bool SbxDecimal::getUShort( UINT16& rVal ) { (void)rVal; return false; } -bool SbxDecimal::getULong( UINT32& rVal ) { (void)rVal; return false; } +bool SbxDecimal::getByte( sal_uInt8& rVal ) { (void)rVal; return false; } +bool SbxDecimal::getShort( sal_Int16& rVal ) { (void)rVal; return false; } +bool SbxDecimal::getLong( sal_Int32& rVal ) { (void)rVal; return false; } +bool SbxDecimal::getUShort( sal_uInt16& rVal ) { (void)rVal; return false; } +bool SbxDecimal::getULong( sal_uInt32& rVal ) { (void)rVal; return false; } bool SbxDecimal::getSingle( float& rVal ) { (void)rVal; return false; } bool SbxDecimal::getDouble( double& rVal ) { (void)rVal; return false; } bool SbxDecimal::getInt( int& rVal ) { (void)rVal; return false; } @@ -494,38 +488,32 @@ start: if( !pnDecRes->setSingle( p->nSingle ) ) SbxBase::SetError( SbxERR_OVERFLOW ); break; + case SbxCURRENCY: + { + if( !pnDecRes->setDouble( ImpCurrencyToDouble( p->nInt64 ) ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); + break; + } case SbxSALINT64: { - double d = (double)p->nInt64; - pnDecRes->setDouble( d ); + if( !pnDecRes->setDouble( (double)p->nInt64 ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); break; } case SbxSALUINT64: { - double d = ImpSalUInt64ToDouble( p->uInt64 ); - pnDecRes->setDouble( d ); + if( !pnDecRes->setDouble( (double)p->uInt64 ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); break; } case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: - { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else - dVal = p->nDouble; - + { + double dVal = p->nDouble; if( !pnDecRes->setDouble( dVal ) ) SbxBase::SetError( SbxERR_OVERFLOW ); break; - } + } case SbxLPSTR: case SbxSTRING: case SbxBYREF | SbxSTRING: @@ -564,11 +552,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -608,17 +592,17 @@ start: case SbxERROR: case SbxUSHORT: aTmp.pUShort = &p->nUShort; goto direct; - case SbxSALUINT64: - aTmp.puInt64 = &p->uInt64; goto direct; case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; case SbxLONG: aTmp.pLong = &p->nLong; goto direct; + case SbxCURRENCY: case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; + case SbxSALUINT64: + aTmp.puInt64 = &p->uInt64; goto direct; + direct: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; @@ -630,8 +614,6 @@ start: if( pDec != p->pDecimal ) { releaseDecimalPtr( p->pDecimal ); - // if( p->pDecimal ) - // p->pDecimal->ReleaseRef(); p->pDecimal = pDec; if( pDec ) pDec->addRef(); @@ -653,27 +635,12 @@ start: p->nDouble = d; break; } - case SbxULONG64: - { - double d; - pDec->getDouble( d ); - p->nULong64 = ImpDoubleToUINT64( d ); - break; - } - case SbxLONG64: - { - double d; - pDec->getDouble( d ); - p->nLong64 = ImpDoubleToINT64( d ); - break; - } case SbxLPSTR: case SbxSTRING: case SbxBYREF | SbxSTRING: if( !p->pOUString ) p->pOUString = new ::rtl::OUString; - // ImpCvtNum( (double) n, 0, *p->pString ); pDec->getString( *p->pOUString ); break; case SbxOBJECT: @@ -708,7 +675,6 @@ start: *p->pInteger = 0; } break; - // *p->pInteger = n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( !pDec->getUShort( *p->pUShort ) ) @@ -731,6 +697,12 @@ start: *p->pULong = 0; } break; + case SbxBYREF | SbxCURRENCY: + double d; + if( !pDec->getDouble( d ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); + *p->pnInt64 = ImpDoubleToCurrency( d ); + break; case SbxBYREF | SbxSALINT64: { double d; @@ -756,7 +728,6 @@ start: *p->pSingle = 0; } break; - // *p->pSingle = (float) n; break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: if( !pDec->getDouble( *p->pDouble ) ) @@ -765,28 +736,6 @@ start: *p->pDouble = 0; } break; - case SbxBYREF | SbxULONG64: - { - double d; - pDec->getDouble( d ); - *p->pULong64 = ImpDoubleToUINT64( d ); - break; - } - case SbxBYREF | SbxLONG64: - { - double d; - pDec->getDouble( d ); - *p->pLong64 = ImpDoubleToINT64( d ); - break; - } - case SbxBYREF | SbxCURRENCY: - { - double d; - pDec->getDouble( d ); - *p->pLong64 = ImpDoubleToCurrency( d ); - break; - } - default: SbxBase::SetError( SbxERR_CONVERSION ); } diff --git a/basic/source/sbx/sbxdec.hxx b/basic/source/sbx/sbxdec.hxx index 85d5509190..362d62e3be 100644 --- a/basic/source/sbx/sbxdec.hxx +++ b/basic/source/sbx/sbxdec.hxx @@ -34,17 +34,15 @@ #undef WB_LEFT #undef WB_RIGHT -#include <tools/prewin.h> -} // close extern "C" { + +#include <prewin.h> +#include <postwin.h> #ifndef __MINGW32__ #include <comutil.h> #endif #include <oleauto.h> -extern "C" { // reopen extern "C" { -#include <tools/postwin.h> - #endif #endif #include <basic/sbx.hxx> @@ -62,7 +60,7 @@ class SbxDecimal #ifdef WIN32 DECIMAL maDec; #endif - INT32 mnRefCount; + sal_Int32 mnRefCount; public: SbxDecimal( void ); @@ -77,11 +75,11 @@ public: void fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ); void setChar( sal_Unicode val ); - void setByte( BYTE val ); - void setShort( INT16 val ); - void setLong( INT32 val ); - void setUShort( UINT16 val ); - void setULong( UINT32 val ); + void setByte( sal_uInt8 val ); + void setShort( sal_Int16 val ); + void setLong( sal_Int32 val ); + void setUShort( sal_uInt16 val ); + void setULong( sal_uInt32 val ); bool setSingle( float val ); bool setDouble( double val ); void setInt( int val ); @@ -98,11 +96,11 @@ public: } bool getChar( sal_Unicode& rVal ); - bool getByte( BYTE& rVal ); - bool getShort( INT16& rVal ); - bool getLong( INT32& rVal ); - bool getUShort( UINT16& rVal ); - bool getULong( UINT32& rVal ); + bool getByte( sal_uInt8& rVal ); + bool getShort( sal_Int16& rVal ); + bool getLong( sal_Int32& rVal ); + bool getUShort( sal_uInt16& rVal ); + bool getULong( sal_uInt32& rVal ); bool getSingle( float& rVal ); bool getDouble( double& rVal ); bool getInt( int& rVal ); diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx index 0235bc5ce2..aee53b92fa 100644 --- a/basic/source/sbx/sbxexec.cxx +++ b/basic/source/sbx/sbxexec.cxx @@ -36,21 +36,21 @@ class SbxSimpleCharClass { public: - BOOL isAlpha( sal_Unicode c ) const + sal_Bool isAlpha( sal_Unicode c ) const { - BOOL bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + sal_Bool bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); return bRet; } - BOOL isDigit( sal_Unicode c ) const + sal_Bool isDigit( sal_Unicode c ) const { - BOOL bRet = (c >= '0' && c <= '9'); + sal_Bool bRet = (c >= '0' && c <= '9'); return bRet; } - BOOL isAlphaNumeric( sal_Unicode c ) const + sal_Bool isAlphaNumeric( sal_Unicode c ) const { - BOOL bRet = isDigit( c ) || isAlpha( c ); + sal_Bool bRet = isDigit( c ) || isAlpha( c ); return bRet; } }; @@ -72,7 +72,7 @@ static const xub_Unicode* SkipWhitespace( const xub_Unicode* p ) static const xub_Unicode* Symbol( const xub_Unicode* p, XubString& rSym, const SbxSimpleCharClass& rCharClass ) { - USHORT nLen = 0; + sal_uInt16 nLen = 0; // Did we have a nonstandard symbol? if( *p == '[' ) { @@ -142,7 +142,7 @@ static SbxVariable* QualifiedName // a function (with optional parameters). static SbxVariable* Operand - ( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf, BOOL bVar ) + ( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf, sal_Bool bVar ) { static SbxSimpleCharClass aCharClass; @@ -154,7 +154,7 @@ static SbxVariable* Operand || *p == '&' ) ) { // A number could be scanned in directly! - USHORT nLen; + sal_uInt16 nLen; if( !refVar->Scan( XubString( p ), &nLen ) ) refVar.Clear(); else @@ -192,12 +192,12 @@ static SbxVariable* Operand static SbxVariable* MulDiv( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf ) { const xub_Unicode* p = *ppBuf; - SbxVariableRef refVar( Operand( pObj, pGbl, &p, FALSE ) ); + SbxVariableRef refVar( Operand( pObj, pGbl, &p, sal_False ) ); p = SkipWhitespace( p ); while( refVar.Is() && ( *p == '*' || *p == '/' ) ) { xub_Unicode cOp = *p++; - SbxVariableRef refVar2( Operand( pObj, pGbl, &p, FALSE ) ); + SbxVariableRef refVar2( Operand( pObj, pGbl, &p, sal_False ) ); if( refVar2.Is() ) { // temporary variable! @@ -256,7 +256,7 @@ static SbxVariable* PlusMinus( SbxObject* pObj, SbxObject* pGbl, const xub_Unico static SbxVariable* Assign( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf ) { const xub_Unicode* p = *ppBuf; - SbxVariableRef refVar( Operand( pObj, pGbl, &p, TRUE ) ); + SbxVariableRef refVar( Operand( pObj, pGbl, &p, sal_True ) ); p = SkipWhitespace( p ); if( refVar.Is() ) { @@ -304,7 +304,7 @@ static SbxVariable* Element SbxVariableRef refVar; if( aSym.Len() ) { - USHORT nOld = pObj->GetFlags(); + sal_uInt16 nOld = pObj->GetFlags(); if( pObj == pGbl ) pObj->SetFlag( SBX_GBLSEARCH ); refVar = pObj->Find( aSym, t ); @@ -318,7 +318,7 @@ static SbxVariable* Element { p++; SbxArrayRef refPar = new SbxArray; - USHORT nArg = 0; + sal_uInt16 nArg = 0; // We are once relaxed and accept as well // the line- or commandend as delimiter // Search parameter always global! diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx index 533de965db..2463766efb 100644 --- a/basic/source/sbx/sbxform.cxx +++ b/basic/source/sbx/sbxform.cxx @@ -142,17 +142,11 @@ SbxBasicFormater::SbxBasicFormater( sal_Unicode _cDecPoint, sal_Unicode _cThousa } // Funktion zur Ausgabe eines Fehler-Textes (zum Debuggen) -/* -void SbxBasicFormater::ShowError( char * sErrMsg ) -{ -// cout << "ERROR in Format$(): " << sErrMsg << endl; -} -*/ // verschiebt alle Zeichen des Strings, angefangen von der nStartPos, // um eine Position zu gr"osseren Indizes, d.h. es wird Platz f"ur // ein neues (einzuf"ugendes) Zeichen geschafft. // ACHTUNG: der String MUSS gross genug sein ! -inline void SbxBasicFormater::ShiftString( String& sStrg, USHORT nStartPos ) +inline void SbxBasicFormater::ShiftString( String& sStrg, sal_uInt16 nStartPos ) { sStrg.Erase( nStartPos,1 ); } @@ -175,7 +169,7 @@ void SbxBasicFormater::AppendDigit( String& sStrg, short nDigit ) // verschiebt den Dezimal-Punkt um eine Stelle nach links void SbxBasicFormater::LeftShiftDecimalPoint( String& sStrg ) { - USHORT nPos = sStrg.Search( cDecPoint ); + sal_uInt16 nPos = sStrg.Search( cDecPoint ); if( nPos!=STRING_NOTFOUND ) { @@ -189,13 +183,13 @@ void SbxBasicFormater::LeftShiftDecimalPoint( String& sStrg ) // es wird ein Flag zur"uckgeliefert, falls ein Overflow auftrat, // d.h. 99.99 --> 100.00, d.h. ein Gr"ossenordung ge"andert wurde // (geschieht beim Runden einer 9). -void SbxBasicFormater::StrRoundDigit( String& sStrg, short nPos, BOOL& bOverflow ) +void SbxBasicFormater::StrRoundDigit( String& sStrg, short nPos, sal_Bool& bOverflow ) { // wurde ggf ein falscher Index uebergeben --> Aufruf ignorieren if( nPos<0 ) return; - bOverflow = FALSE; + bOverflow = sal_False; // "uberspringe den Dezimalpunkt und Tausender-Trennzeichen sal_Unicode c = sStrg.GetChar( nPos ); if( nPos>0 && (c == cDecPoint || c == cThousandSep) ) @@ -219,7 +213,7 @@ void SbxBasicFormater::StrRoundDigit( String& sStrg, short nPos, BOOL& bOverflow ShiftString( sStrg,0 ); // f"uhrende 1 einf"ugen: z.B. 99.99 f"ur 0.0 sStrg.SetChar( 0, '1' ); - bOverflow = TRUE; + bOverflow = sal_True; } else { @@ -244,7 +238,7 @@ void SbxBasicFormater::StrRoundDigit( String& sStrg, short nPos, BOOL& bOverflow ShiftString( sStrg,nPos+1 ); // f"uhrende 1 einf"ugen sStrg.SetChar( nPos+1, '1' ); - bOverflow = TRUE; + bOverflow = sal_True; } } } @@ -252,7 +246,7 @@ void SbxBasicFormater::StrRoundDigit( String& sStrg, short nPos, BOOL& bOverflow // rundet in einem String die Ziffer an der angegebenen Stelle void SbxBasicFormater::StrRoundDigit( String& sStrg, short nPos ) { - BOOL bOverflow; + sal_Bool bOverflow; StrRoundDigit( sStrg,nPos,bOverflow ); } @@ -303,7 +297,7 @@ void SbxBasicFormater::InitExp( double _dNewExp ) // bestimmt die Ziffer an der angegebenen Stelle (gedacht zur Anwendung im // Scan-Durchlauf) -short SbxBasicFormater::GetDigitAtPosScan( short nPos, BOOL& bFoundFirstDigit ) +short SbxBasicFormater::GetDigitAtPosScan( short nPos, sal_Bool& bFoundFirstDigit ) { // Versuch eine gr"ossere Ziffer zu lesen, // z.B. Stelle 4 in 1.234, @@ -313,18 +307,18 @@ short SbxBasicFormater::GetDigitAtPosScan( short nPos, BOOL& bFoundFirstDigit ) return _NO_DIGIT; // bestimme den Index der Stelle in dem Number-String: // "uberlese das Vorzeichen - USHORT no = 1; + sal_uInt16 no = 1; // falls notwendig den Dezimal-Punkt "uberlesen: if( nPos<nNumExp ) no++; no += nNumExp-nPos; // Abfrage der ersten (g"ultigen) Ziffer der Zahl --> Flag setzen if( nPos==nNumExp ) - bFoundFirstDigit = TRUE; + bFoundFirstDigit = sal_True; return (short)(sSciNumStrg.GetChar( no ) - ASCII_0); } -short SbxBasicFormater::GetDigitAtPosExpScan( short nPos, BOOL& bFoundFirstDigit ) +short SbxBasicFormater::GetDigitAtPosExpScan( short nPos, sal_Bool& bFoundFirstDigit ) { // ist die abgefragte Stelle zu gross f"ur den Exponenten ? if( nPos>nExpExp ) @@ -332,11 +326,11 @@ short SbxBasicFormater::GetDigitAtPosExpScan( short nPos, BOOL& bFoundFirstDigit // bestimme den Index der Stelle in dem Number-String: // "uberlese das Vorzeichen - USHORT no = 1; + sal_uInt16 no = 1; no += nExpExp-nPos; // Abfrage der ersten (g"ultigen) Ziffer der Zahl --> Flag setzen if( nPos==nExpExp ) - bFoundFirstDigit = TRUE; + bFoundFirstDigit = sal_True; return (short)(sNumExpStrg.GetChar( no ) - ASCII_0); } @@ -344,7 +338,7 @@ short SbxBasicFormater::GetDigitAtPosExpScan( short nPos, BOOL& bFoundFirstDigit // Zahl ggf. NICHT normiert (z.B. 1.2345e-03) dargestellt werden soll, // sondern eventuell 123.345e-3 ! short SbxBasicFormater::GetDigitAtPosExpScan( double dNewExponent, short nPos, - BOOL& bFoundFirstDigit ) + sal_Bool& bFoundFirstDigit ) { // neuer Exponent wurde "ubergeben, aktualisiere // die tempor"aren Klassen-Variablen @@ -379,19 +373,16 @@ TODO: ggf einen 'intelligenten' Peek-Parser um Rundungsfehler bei // In bFoundFirstDigit wird ggf. ein Flag gesetzt wenn eine Ziffer // gefunden wurde, dies wird dazu verwendet um 'Fehler' beim Parsen 202 // zu vermeiden, die -// // ACHTUNG: anscheinend gibt es manchmal noch Probleme mit Rundungs-Fehlern! short SbxBasicFormater::GetDigitAtPos( double dNumber, short nPos, - double& dNextNumber, BOOL& bFoundFirstDigit ) + double& dNextNumber, sal_Bool& bFoundFirstDigit ) // ACHTUNG: nPos kann auch negativ werden, f"ur Stellen nach dem Dezimal-Punkt { - double dTemp = dNumber; - double dDigit,dPos; + double dDigit; short nMaxDigit; // erst mal aus der Zahl eine positive Zahl machen: dNumber = fabs( dNumber ); - dPos = (double)nPos; // "uberpr"ufe ob Zahl zu klein f"ur angegebene Stelle ist nMaxDigit = (short)get_number_of_digits( dNumber ); @@ -401,7 +392,7 @@ short SbxBasicFormater::GetDigitAtPos( double dNumber, short nPos, if( nMaxDigit<nPos && !bFoundFirstDigit && nPos>=0 ) return _NO_DIGIT; // Ziffer gefunden, setze Flag: - bFoundFirstDigit = TRUE; + bFoundFirstDigit = sal_True; for( short i=nMaxDigit; i>=nPos; i-- ) { double dI = (double)i; @@ -433,14 +424,14 @@ short SbxBasicFormater::RoundDigit( double dNumber ) // und liefert diesen zur"uck. // Somit wird ein neuer String erzeugt, der vom Aufrufer wieder freigegeben // werden muss -String SbxBasicFormater::GetPosFormatString( const String& sFormatStrg, BOOL & bFound ) +String SbxBasicFormater::GetPosFormatString( const String& sFormatStrg, sal_Bool & bFound ) { - bFound = FALSE; // default... - USHORT nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); + bFound = sal_False; // default... + sal_uInt16 nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); if( nPos!=STRING_NOTFOUND ) { - bFound = TRUE; + bFound = sal_True; // der Format-String f"ur die positiven Zahlen ist alles // vor dem ersten ';' return sFormatStrg.Copy( 0,nPos ); @@ -452,10 +443,10 @@ String SbxBasicFormater::GetPosFormatString( const String& sFormatStrg, BOOL & b } // siehe auch GetPosFormatString() -String SbxBasicFormater::GetNegFormatString( const String& sFormatStrg, BOOL & bFound ) +String SbxBasicFormater::GetNegFormatString( const String& sFormatStrg, sal_Bool & bFound ) { - bFound = FALSE; // default... - USHORT nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); + bFound = sal_False; // default... + sal_uInt16 nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); if( nPos!=STRING_NOTFOUND ) { @@ -465,7 +456,7 @@ String SbxBasicFormater::GetNegFormatString( const String& sFormatStrg, BOOL & b String sTempStrg = sFormatStrg.Copy( nPos+1 ); // und suche darin ggf. ein weiteres ';' nPos = sTempStrg.Search( FORMAT_SEPARATOR ); - bFound = TRUE; + bFound = sal_True; if( nPos==STRING_NOTFOUND ) // keins gefunden, liefere alles... return sTempStrg; @@ -479,10 +470,10 @@ String SbxBasicFormater::GetNegFormatString( const String& sFormatStrg, BOOL & b } // siehe auch GetPosFormatString() -String SbxBasicFormater::Get0FormatString( const String& sFormatStrg, BOOL & bFound ) +String SbxBasicFormater::Get0FormatString( const String& sFormatStrg, sal_Bool & bFound ) { - bFound = FALSE; // default... - USHORT nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); + bFound = sal_False; // default... + sal_uInt16 nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); if( nPos!=STRING_NOTFOUND ) { @@ -494,7 +485,7 @@ String SbxBasicFormater::Get0FormatString( const String& sFormatStrg, BOOL & bFo nPos = sTempStrg.Search( FORMAT_SEPARATOR ); if( nPos!=STRING_NOTFOUND ) { - bFound = TRUE; + bFound = sal_True; sTempStrg = sTempStrg.Copy( nPos+1 ); nPos = sTempStrg.Search( FORMAT_SEPARATOR ); if( nPos==STRING_NOTFOUND ) @@ -511,10 +502,10 @@ String SbxBasicFormater::Get0FormatString( const String& sFormatStrg, BOOL & bFo } // siehe auch GetPosFormatString() -String SbxBasicFormater::GetNullFormatString( const String& sFormatStrg, BOOL & bFound ) +String SbxBasicFormater::GetNullFormatString( const String& sFormatStrg, sal_Bool & bFound ) { - bFound = FALSE; // default... - USHORT nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); + bFound = sal_False; // default... + sal_uInt16 nPos = sFormatStrg.Search( FORMAT_SEPARATOR ); if( nPos!=STRING_NOTFOUND ) { @@ -531,7 +522,7 @@ String SbxBasicFormater::GetNullFormatString( const String& sFormatStrg, BOOL & nPos = sTempStrg.Search( FORMAT_SEPARATOR ); if( nPos!=STRING_NOTFOUND ) { - bFound = TRUE; + bFound = sal_True; return sTempStrg.Copy( nPos+1 ); } } @@ -548,11 +539,11 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, short& nNoOfDigitsLeft, short& nNoOfDigitsRight, short& nNoOfOptionalDigitsLeft, short& nNoOfExponentDigits, short& nNoOfOptionalExponentDigits, - BOOL& bPercent, BOOL& bCurrency, BOOL& bScientific, - BOOL& bGenerateThousandSeparator, + sal_Bool& bPercent, sal_Bool& bCurrency, sal_Bool& bScientific, + sal_Bool& bGenerateThousandSeparator, short& nMultipleThousandSeparators ) { - USHORT nLen; + sal_uInt16 nLen; short nState = 0; nLen = sFormatStrg.Len(); @@ -562,9 +553,9 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, nNoOfOptionalDigitsLeft = 0; nNoOfExponentDigits = 0; nNoOfOptionalExponentDigits = 0; - bPercent = FALSE; - bCurrency = FALSE; - bScientific = FALSE; + bPercent = sal_False; + bCurrency = sal_False; + bScientific = sal_False; // ab 11.7.97: sobald ein Komma in dem Format String gefunden wird, // werden alle 3 Zehnerpotenzen markiert (d.h. tausender, milionen, ...) // bisher wurde nur an den gesetzten Position ein Tausender-Separator @@ -573,7 +564,7 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, bGenerateThousandSeparator = sFormatStrg.Search( ',' ) != STRING_NOTFOUND; nMultipleThousandSeparators = 0; // und untersuche den Format-String nach den gew"unschten Informationen - for( USHORT i=0; i<nLen; i++ ) + for( sal_uInt16 i=0; i<nLen; i++ ) { sal_Unicode c = sFormatStrg.GetChar( i ); switch( c ) { @@ -616,15 +607,10 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, return -1; // ERROR: zu viele Dezimal-Punkte break; case '%': - bPercent = TRUE; - /* old: - bPercent++; - if( bPercent>1 ) - return -2; // ERROR: zu viele Prozent-Zeichen - */ + bPercent = sal_True; break; case '(': - bCurrency = TRUE; + bCurrency = sal_True; break; case ',': { @@ -640,13 +626,8 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, if( nNoOfDigitsLeft > 0 || nNoOfDigitsRight > 0 ) { nState = -1; // breche jetzt das Z"ahlen der Stellen ab - bScientific = TRUE; + bScientific = sal_True; } - /* old: - bScientific++; - if( bScientific>1 ) - return -3; // ERROR: zu viele Exponent-Zeichen - */ break; // EIGENES Kommando-Zeichen, das die Erzeugung der // Tausender-Trennzeichen einschaltet @@ -655,7 +636,7 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, i++; break; case CREATE_1000SEP_CHAR: - bGenerateThousandSeparator = TRUE; + bGenerateThousandSeparator = sal_True; break; } } @@ -666,12 +647,12 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, // erzeugt werden soll void SbxBasicFormater::ScanFormatString( double dNumber, const String& sFormatStrg, String& sReturnStrg, - BOOL bCreateSign ) + sal_Bool bCreateSign ) { short /*nErr,*/nNoOfDigitsLeft,nNoOfDigitsRight,nNoOfOptionalDigitsLeft, nNoOfExponentDigits,nNoOfOptionalExponentDigits, nMultipleThousandSeparators; - BOOL bPercent,bCurrency,bScientific,bGenerateThousandSeparator; + sal_Bool bPercent,bCurrency,bScientific,bGenerateThousandSeparator; // Initialisiere den Return-String sReturnStrg = String(); @@ -693,23 +674,11 @@ void SbxBasicFormater::ScanFormatString( double dNumber, - sonstige Fehler ? mehrfache Dezimalpunkte, E's, etc. --> Fehler werden zur Zeit einfach ignoriert */ - /*nErr =*/ AnalyseFormatString( sFormatStrg,nNoOfDigitsLeft,nNoOfDigitsRight, + AnalyseFormatString( sFormatStrg,nNoOfDigitsLeft,nNoOfDigitsRight, nNoOfOptionalDigitsLeft,nNoOfExponentDigits, nNoOfOptionalExponentDigits, bPercent,bCurrency,bScientific,bGenerateThousandSeparator, nMultipleThousandSeparators ); - /* es werden alle Fehler ignoriert, wie in Visual-Basic - if( nErr!=0 ) - { - char sBuffer[512]; - - //sprintf( sBuffer,"bad format-string >%s< err=%i",sFormatStrg,nErr ); - strcpy( sBuffer,"bad format-string" ); - ShowError( sBuffer ); - } - else - */ - { // Spezialbehandlung f"ur Spezialzeichen if( bPercent ) dNumber *= 100.0; @@ -722,12 +691,12 @@ void SbxBasicFormater::ScanFormatString( double dNumber, double dExponent; short i,nLen; short nState,nDigitPos,nExponentPos,nMaxDigit,nMaxExponentDigit; - BOOL bFirstDigit,bFirstExponentDigit,bFoundFirstDigit, + sal_Bool bFirstDigit,bFirstExponentDigit,bFoundFirstDigit, bIsNegative,bZeroSpaceOn, bSignHappend,bDigitPosNegative; // Initialisierung der Arbeits-Variablen - bSignHappend = FALSE; - bFoundFirstDigit = FALSE; + bSignHappend = sal_False; + bFoundFirstDigit = sal_False; bIsNegative = dNumber<0.0; nLen = sFormatStrg.Len(); dExponent = get_number_of_digits( dNumber ); @@ -737,8 +706,6 @@ void SbxBasicFormater::ScanFormatString( double dNumber, bDigitPosNegative = false; if( bScientific ) { - //if( nNoOfOptionalDigitsLeft>0 ) - // ShowError( "# in scientific-format in front of the decimal-point has no effect" ); // beim Exponent ggf. "uberz"ahlige Stellen vor dem Komma abziehen dExponent = dExponent - (double)(nNoOfDigitsLeft-1); nDigitPos = nMaxDigit; @@ -751,8 +718,8 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // hier ben"otigt man keine Exponent-Daten ! bDigitPosNegative = (nDigitPos < 0); } - bFirstDigit = TRUE; - bFirstExponentDigit = TRUE; + bFirstDigit = sal_True; + bFirstExponentDigit = sal_True; nState = 0; // 0 --> Mantisse; 1 --> Exponent bZeroSpaceOn = 0; @@ -782,14 +749,13 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // Behandlung der Mantisse if( bFirstDigit ) { - //org:bFirstDigit = FALSE; // ggf. Vorzeichen erzeugen // Bem.: bei bCurrency soll das negative // Vorzeichen durch () angezeigt werden - if( bIsNegative && !bCreateSign/*!bCurrency*/ && !bSignHappend ) + if( bIsNegative && !bCreateSign && !bSignHappend ) { // nur einmal ein Vorzeichen ausgeben - bSignHappend = TRUE; + bSignHappend = sal_True; StrAppendChar( sReturnStrg,'-' ); } // hier jetzt "uberz"ahlige Stellen ausgeben, @@ -807,7 +773,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // wurde wirklich eine Ziffer eingefuegt ? if( nTempDigit!=_NO_DIGIT ) // jetzt wurde wirklich eine Ziffer ausgegeben, Flag setzen - bFirstDigit = FALSE; + bFirstDigit = sal_False; // muss ggf. ein Tausender-Trennzeichen erzeugt werden? if( bGenerateThousandSeparator && ( c=='0' || nMaxDigit>=nDigitPos ) && j>0 && (j % 3 == 0) ) StrAppendChar( sReturnStrg,cThousandSep ); @@ -819,7 +785,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, { AppendDigit( sReturnStrg,0 ); // Ja // jetzt wurde wirklich eine Ziffer ausgegeben, Flag setzen - bFirstDigit = FALSE; + bFirstDigit = sal_False; bZeroSpaceOn = 1; // BEM.: bei Visual-Basic schaltet die erste 0 f"ur alle // nachfolgenden # (bis zum Dezimal-Punkt) die 0 ein, @@ -839,7 +805,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // wurde wirklich eine Ziffer eingefuegt ? if( nTempDigit!=_NO_DIGIT ) // jetzt wurde wirklich eine Ziffer ausgegeben, Flag setzen - bFirstDigit = FALSE; + bFirstDigit = sal_False; // muss ggf. ein Tausender-Trennzeichen erzeugt werden? if( bGenerateThousandSeparator && ( c=='0' || nMaxDigit>=nDigitPos ) && nDigitPos>0 && (nDigitPos % 3 == 0) ) StrAppendChar( sReturnStrg,cThousandSep ); @@ -853,7 +819,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, if( bFirstExponentDigit ) { // Vorzeichen wurde schon bei e/E ausgegeben - bFirstExponentDigit = FALSE; + bFirstExponentDigit = sal_False; if( nMaxExponentDigit>nExponentPos ) // hier jetzt "uberz"ahlige Stellen ausgeben, // d.h. vom Format-String nicht erfasste Stellen @@ -914,7 +880,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber, break; } - BOOL bOverflow = FALSE; + sal_Bool bOverflow = sal_False; #ifdef _with_sprintf short nNextDigit = GetDigitAtPosScan( nDigitPos,bFoundFirstDigit ); #else @@ -960,19 +926,9 @@ void SbxBasicFormater::ScanFormatString( double dNumber, else StrAppendChar( sReturnStrg,'+' ); } - //else - // ShowError( "operator e/E did not find + or -" ); } - //else - // ShowError( "operator e/E ended with 0" ); break; case ',': - // ACHTUNG: nur falls Zahl bisher ausgegeben wurde - // das Zeichen ausgeben - ////--> Siehe Kommentar vom 11.7. in AnalyseFormatString() - ////if( !bFirstDigit ) - //// // gebe Tausender-Trennzeichen aus - //// StrAppendChar( sReturnStrg,cThousandSep ); break; case ';': break; @@ -1002,12 +958,9 @@ void SbxBasicFormater::ScanFormatString( double dNumber, ParseBack( sReturnStrg,sFormatStrg,i-1 ); // Sonderzeichen gefunden, gebe N"ACHSTES // Zeichen direkt aus (falls es existiert) - // i++; c = sFormatStrg.GetChar( ++i ); if( c!=0 ) StrAppendChar( sReturnStrg,c ); - //else - // ShowError( "operator \\ ended with 0" ); break; case CREATE_1000SEP_CHAR: // hier ignorieren, Aktion wurde schon in @@ -1019,9 +972,6 @@ void SbxBasicFormater::ScanFormatString( double dNumber, ( c>='A' && c<='Z' ) || ( c>='1' && c<='9' ) ) StrAppendChar( sReturnStrg,c ); - // else - // ignorieren ! - // ehemals: ShowError( "bad character in format-string" ); } } // Format-String wurde vollst"andig gescanned, @@ -1043,12 +993,11 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // ABER nur Stellen nach dem Dezimal-Punkt k"onnen gel"oscht werden if( nNoOfDigitsRight>0 ) ParseBack( sReturnStrg,sFormatStrg,sFormatStrg.Len()-1 ); - } } String SbxBasicFormater::BasicFormatNull( String sFormatStrg ) { - BOOL bNullFormatFound; + sal_Bool bNullFormatFound; String sNullFormatStrg = GetNullFormatString( sFormatStrg,bNullFormatFound ); if( bNullFormatFound ) @@ -1060,7 +1009,7 @@ String SbxBasicFormater::BasicFormatNull( String sFormatStrg ) String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg ) { - BOOL bPosFormatFound,bNegFormatFound,b0FormatFound; + sal_Bool bPosFormatFound,bNegFormatFound,b0FormatFound; // analysiere Format-String auf vordefinierte Formate: if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_GENERALNUMBER ) ) @@ -1087,7 +1036,6 @@ String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg ) String sPosFormatStrg = GetPosFormatString( sFormatStrg, bPosFormatFound ); String sNegFormatStrg = GetNegFormatString( sFormatStrg, bNegFormatFound ); String s0FormatStrg = Get0FormatString( sFormatStrg, b0FormatFound ); - //String sNullFormatStrg = GetNullFormatString( sFormatStrg, bNullFormatFound ); String sReturnStrg; String sTempStrg; @@ -1109,7 +1057,7 @@ String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg ) // verwende String fuer positive Werte sTempStrg = sPosFormatStrg; } - ScanFormatString( dNumber, sTempStrg, sReturnStrg,/*bCreateSign=*/FALSE ); + ScanFormatString( dNumber, sTempStrg, sReturnStrg,/*bCreateSign=*/sal_False ); } else { @@ -1138,33 +1086,33 @@ String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg ) { ScanFormatString( dNumber, (/*sPosFormatStrg!=EMPTYFORMATSTRING*/bPosFormatFound ? sPosFormatStrg : sFormatStrg), - sReturnStrg,/*bCreateSign=*/FALSE ); + sReturnStrg,/*bCreateSign=*/sal_False ); } } return sReturnStrg; } -BOOL SbxBasicFormater::isBasicFormat( String sFormatStrg ) +sal_Bool SbxBasicFormater::isBasicFormat( String sFormatStrg ) { if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_GENERALNUMBER ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_CURRENCY ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_FIXED ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_STANDARD ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_PERCENT ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_SCIENTIFIC ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_YESNO ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_TRUEFALSE ) ) - return TRUE; + return sal_True; if( sFormatStrg.EqualsIgnoreCaseAscii( BASICFORMAT_ONOFF ) ) - return TRUE; - return FALSE; + return sal_True; + return sal_False; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx index 1bf1836889..558f971c72 100644 --- a/basic/source/sbx/sbxint.cxx +++ b/basic/source/sbx/sbxint.cxx @@ -37,10 +37,10 @@ double ImpRound( double d ) return d + ( d < 0 ? -0.5 : 0.5 ); } -INT16 ImpGetInteger( const SbxValues* p ) +sal_Int16 ImpGetInteger( const SbxValues* p ) { SbxValues aTmp; - INT16 nRes; + sal_Int16 nRes; start: switch( +p->eType ) { @@ -57,12 +57,12 @@ start: nRes = p->nInteger; break; case SbxERROR: case SbxUSHORT: - if( p->nUShort > (USHORT) SbxMAXINT ) + if( p->nUShort > (sal_uInt16) SbxMAXINT ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXINT; } else - nRes = (INT16) p->nUShort; + nRes = (sal_Int16) p->nUShort; break; case SbxLONG: if( p->nLong > SbxMAXINT ) @@ -74,7 +74,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; } else - nRes = (INT16) p->nLong; + nRes = (sal_Int16) p->nLong; break; case SbxULONG: if( p->nULong > SbxMAXINT ) @@ -82,7 +82,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXINT; } else - nRes = (INT16) p->nULong; + nRes = (sal_Int16) p->nULong; break; case SbxSINGLE: if( p->nSingle > SbxMAXINT ) @@ -94,8 +94,24 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; } else - nRes = (INT16) ImpRound( p->nSingle ); + nRes = (sal_Int16) ImpRound( p->nSingle ); break; + case SbxCURRENCY: + { + sal_Int64 tstVal = (sal_Int64) p->nInt64 / (sal_Int64) CURRENCY_FACTOR; + + if( tstVal > SbxMAXINT ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXINT; + } + else if( tstVal < SbxMININT ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; + } + else + nRes = (sal_Int16) (tstVal); + break; + } case SbxSALINT64: if( p->nInt64 > SbxMAXINT ) { @@ -106,7 +122,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; } else - nRes = (INT16) p->nInt64; + nRes = (sal_Int16) p->nInt64; break; case SbxSALUINT64: if( p->uInt64 > SbxMAXINT ) @@ -114,26 +130,16 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXINT; } else - nRes = (INT16) p->uInt64; + nRes = (sal_Int16) p->uInt64; break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: + { + double dVal = 0.0; + if( p->eType == SbxDECIMAL ) { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) - { - dVal = 0.0; if( p->pDecimal ) p->pDecimal->getDouble( dVal ); } @@ -149,7 +155,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; } else - nRes = (INT16) ImpRound( dVal ); + nRes = (sal_Int16) ImpRound( dVal ); break; } case SbxLPSTR: @@ -172,7 +178,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; } else - nRes = (INT16) ImpRound( d ); + nRes = (sal_Int16) ImpRound( d ); } break; case SbxOBJECT: @@ -208,11 +214,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -227,7 +229,7 @@ start: return nRes; } -void ImpPutInteger( SbxValues* p, INT16 n ) +void ImpPutInteger( SbxValues* p, sal_Int16 n ) { SbxValues aTmp; start: @@ -249,7 +251,7 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // frome here no longer + // from here no tests needed case SbxINTEGER: case SbxBOOL: p->nInteger = n; break; @@ -260,14 +262,10 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setInt( n ); @@ -304,7 +302,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: *p->pInteger = n; break; @@ -314,21 +312,24 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: if( n < 0 ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: if( n < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); *p->puInt64 = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); + *p->puInt64 = 0; } else *p->puInt64 = n; @@ -338,12 +339,6 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); @@ -385,6 +380,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d ) return nRes; } + double ImpSalUInt64ToDouble( sal_uInt64 n ) { double d = 0.0; @@ -416,33 +412,20 @@ start: nRes = p->nInteger; break; case SbxERROR: case SbxUSHORT: - nRes = p->nUShort; break; + nRes = (sal_Int64) p->nUShort; break; case SbxLONG: - nRes = p->nLong; break; + nRes = (sal_Int64) p->nLong; break; case SbxULONG: nRes = (sal_Int64) p->nULong; break; case SbxSINGLE: - nRes = ImpDoubleToSalInt64( (double)p->nSingle ); + nRes = (sal_Int64) p->nSingle; break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: - { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else - dVal = p->nDouble; - - nRes = ImpDoubleToSalInt64( dVal ); + nRes = (sal_Int64) p->nDouble; break; - } + case SbxCURRENCY: + nRes = p->nInt64 / CURRENCY_FACTOR; break; case SbxSALINT64: nRes = p->nInt64; break; case SbxSALUINT64: @@ -472,7 +455,7 @@ start: if( ImpScan( *p->pOUString, d, t, NULL ) != SbxERR_OK ) nRes = 0; else - nRes = ImpDoubleToSalInt64( d ); + nRes = (sal_Int64) d; } } break; @@ -499,10 +482,15 @@ start: nRes = *p->pLong; break; case SbxBYREF | SbxULONG: nRes = *p->pULong; break; + case SbxBYREF | SbxCURRENCY: + nRes = p->nInt64 / CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: nRes = *p->pnInt64; break; // from here the values has to be checked + case SbxBYREF | SbxSALUINT64: + aTmp.uInt64 = *p->puInt64; goto ref; + case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: aTmp.nUShort = *p->pUShort; goto ref; @@ -511,13 +499,6 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; - case SbxBYREF | SbxSALUINT64: - aTmp.uInt64 = *p->puInt64; goto ref; ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -543,11 +524,6 @@ start: case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; case SbxERROR: @@ -555,6 +531,9 @@ start: aTmp.pUShort = &p->nUShort; goto direct; case SbxLONG: aTmp.pnInt64 = &p->nInt64; goto direct; + case SbxCURRENCY: + case SbxSALINT64: + aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: aTmp.puInt64 = &p->uInt64; goto direct; @@ -562,9 +541,6 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // Check not neccessary - case SbxSALINT64: - p->nInt64 = n; break; case SbxSINGLE: p->nSingle = (float) n; break; case SbxDATE: @@ -611,7 +587,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -622,7 +598,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -633,7 +609,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { @@ -643,7 +619,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINLNG; } - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { @@ -653,23 +629,14 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSINGLE: *p->pSingle = (float) n; break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; case SbxBYREF | SbxCURRENCY: - if( n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); n = (sal_Int64) SbxMAXCURR; - } - else if( n < SbxMINCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); n = (sal_Int64) SbxMINCURR; - } - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; - + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: @@ -710,27 +677,16 @@ start: case SbxULONG: nRes = (sal_uInt64) p->nULong; break; case SbxSINGLE: - nRes = ImpDoubleToSalUInt64( (double)p->nSingle ); - break; + nRes = (sal_uInt64) p->nSingle; break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else - dVal = p->nDouble; - - nRes = ImpDoubleToSalUInt64( dVal ); +//TODO overflow check + nRes = (sal_uInt64) p->nDouble; break; } + case SbxCURRENCY: + nRes = p->nInt64 * CURRENCY_FACTOR; break; case SbxSALINT64: if( p->nInt64 < 0 ) { @@ -738,6 +694,7 @@ start: } else nRes = (sal_uInt64) p->nInt64; + break; case SbxSALUINT64: nRes = p->uInt64; break; @@ -805,7 +762,7 @@ start: case SbxBYREF | SbxSALUINT64: nRes = *p->puInt64; break; - // from here the values has to be checked + // from here on the value has to be checked case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: aTmp.nUShort = *p->pUShort; goto ref; @@ -814,11 +771,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; ref: @@ -846,11 +799,6 @@ start: case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; case SbxERROR: @@ -858,6 +806,7 @@ start: aTmp.pUShort = &p->nUShort; goto direct; case SbxLONG: aTmp.pnInt64 = &p->nInt64; goto direct; + case SbxCURRENCY: case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSINGLE: @@ -908,45 +857,43 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXBYTE; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXINT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXUINT; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXLNG; } - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXULNG; } - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSINGLE: *p->pDouble = (float)ImpSalUInt64ToDouble( n ); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: + *p->pDouble = ImpSalUInt64ToDouble( n ); break; case SbxBYREF | SbxCURRENCY: - if( n > SbxMAXSALINT64 || (sal_Int64)n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); n = (sal_Int64) SbxMAXCURR; - } - *p->pLong64 = ImpDoubleToCurrency( (double)(sal_Int64) n ); break; - + if ( n > ( SbxMAXSALINT64 / CURRENCY_FACTOR ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXSALINT64; + *p->pnInt64 = ( sal_Int64) ( n * CURRENCY_FACTOR ); break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; case SbxBYREF | SbxSALINT64: diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx index 748034171d..654bc86dd0 100644 --- a/basic/source/sbx/sbxlng.cxx +++ b/basic/source/sbx/sbxlng.cxx @@ -32,10 +32,10 @@ #include <basic/sbx.hxx> #include "sbxconv.hxx" -INT32 ImpGetLong( const SbxValues* p ) +sal_Int32 ImpGetLong( const SbxValues* p ) { SbxValues aTmp; - INT32 nRes; + sal_Int32 nRes; start: switch( +p->eType ) { @@ -61,7 +61,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXLNG; } else - nRes = (INT32) p->nULong; + nRes = (sal_Int32) p->nULong; break; case SbxSINGLE: if( p->nSingle > SbxMAXLNG ) @@ -73,30 +73,30 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINLNG; } else - nRes = (INT32) ImpRound( p->nSingle ); + nRes = (sal_Int32) ImpRound( p->nSingle ); break; - case SbxDATE: - case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: case SbxSALINT64: + nRes = p->nInt64; + break; case SbxSALUINT64: + nRes = p->uInt64; + break; case SbxCURRENCY: + { + sal_Int64 tstVal = p->nInt64 / CURRENCY_FACTOR; + nRes = (sal_Int32) (tstVal); + if( tstVal < SbxMINLNG || SbxMAXLNG < tstVal ) SbxBase::SetError( SbxERR_OVERFLOW ); + if( SbxMAXLNG < tstVal ) nRes = SbxMAXLNG; + if( tstVal < SbxMINLNG ) nRes = SbxMINLNG; + break; + } + case SbxDATE: + case SbxDOUBLE: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxSALINT64 ) - dVal = static_cast< double >(p->nInt64); - else if( p->eType == SbxSALUINT64 ) - dVal = ImpSalUInt64ToDouble( p->uInt64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -114,7 +114,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINLNG; } else - nRes = (INT32) ImpRound( dVal ); + nRes = (sal_Int32) ImpRound( dVal ); break; } case SbxBYREF | SbxSTRING: @@ -137,7 +137,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINLNG; } else - nRes = (INT32) ImpRound( d ); + nRes = (sal_Int32) ImpRound( d ); } break; case SbxOBJECT: @@ -173,15 +173,12 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: aTmp.uInt64 = *p->puInt64; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; + ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -192,7 +189,7 @@ start: return nRes; } -void ImpPutLong( SbxValues* p, INT32 n ) +void ImpPutLong( SbxValues* p, sal_Int32 n ) { SbxValues aTmp; @@ -207,11 +204,6 @@ start: case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; case SbxSALUINT64: @@ -231,6 +223,8 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxDECIMAL: @@ -273,7 +267,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -284,7 +278,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -295,7 +289,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: *p->pLong = n; break; case SbxBYREF | SbxULONG: @@ -303,7 +297,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pULong = (UINT32) n; break; + *p->pULong = (sal_uInt32) n; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: @@ -320,21 +314,7 @@ start: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; case SbxBYREF | SbxCURRENCY: - double d; - if( n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); d = SbxMAXCURR; - } - else if( n < SbxMINCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); d = SbxMINCURR; - } - else - { - d = n; - } - *p->pLong64 = ImpDoubleToCurrency( d ); break; - + *p->pnInt64 = (sal_Int64)n * (sal_Int64)CURRENCY_FACTOR; break; default: SbxBase::SetError( SbxERR_CONVERSION ); } diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index afc7debdc9..2ad0e4ef6e 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -2,7 +2,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 @@ -31,7 +31,6 @@ #include <tools/stream.hxx> #include <vcl/sound.hxx> #include <basic/sbx.hxx> -#include <basic/sbxbase.hxx> #include "sbxres.hxx" #include <svl/brdcst.hxx> @@ -42,11 +41,9 @@ TYPEINIT2(SbxObject,SbxVariable,SfxListener) static const char* pNameProp; // Name-Property static const char* pParentProp; // Parent-Property -static USHORT nNameHash = 0, nParentHash = 0; +static sal_uInt16 nNameHash = 0, nParentHash = 0; -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// SbxObject::SbxObject( const XubString& rClass ) : SbxVariable( SbxOBJECT ), aClassName( rClass ) @@ -79,27 +76,27 @@ SbxObject& SbxObject::operator=( const SbxObject& r ) pMethods = new SbxArray; pProps = new SbxArray; pObjs = new SbxArray( SbxOBJECT ); - // Die Arrays werden kopiert, die Inhalte uebernommen + // The arrays were copied, the content taken over *pMethods = *r.pMethods; *pProps = *r.pProps; *pObjs = *r.pObjs; - // Da die Variablen uebernommen wurden, ist dies OK + // Because the variables were taken over, this is OK pDfltProp = r.pDfltProp; SetName( r.GetName() ); SetFlags( r.GetFlags() ); - SetModified( TRUE ); + SetModified( sal_True ); } return *this; } static void CheckParentsOnDelete( SbxObject* pObj, SbxArray* p ) { - for( USHORT i = 0; i < p->Count(); i++ ) + for( sal_uInt16 i = 0; i < p->Count(); i++ ) { SbxVariableRef& rRef = p->GetRef( i ); if( rRef->IsBroadcaster() ) - pObj->EndListening( rRef->GetBroadcaster(), TRUE ); - // Hat das Element mehr als eine Referenz und noch einen Listener? + pObj->EndListening( rRef->GetBroadcaster(), sal_True ); + // Did the element have more then one reference and still a Listener? if( rRef->GetRefCount() > 1 ) { rRef->SetParent( NULL ); @@ -113,6 +110,9 @@ SbxObject::~SbxObject() CheckParentsOnDelete( this, pProps ); CheckParentsOnDelete( this, pMethods ); CheckParentsOnDelete( this, pObjs ); + + // avoid handling in ~SbxVariable as SBX_DIM_AS_NEW == SBX_GBLSEARCH + ResetFlag( SBX_DIM_AS_NEW ); } SbxDataType SbxObject::GetType() const @@ -137,7 +137,7 @@ void SbxObject::Clear() p->ResetFlag( SBX_WRITE ); p->SetFlag( SBX_DONTSTORE ); pDfltProp = NULL; - SetModified( FALSE ); + SetModified( sal_False ); } void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, @@ -146,14 +146,14 @@ void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SbxHint* p = PTR_CAST(SbxHint,&rHint); if( p ) { - ULONG nId = p->GetId(); - BOOL bRead = BOOL( nId == SBX_HINT_DATAWANTED ); - BOOL bWrite = BOOL( nId == SBX_HINT_DATACHANGED ); + sal_uIntPtr nId = p->GetId(); + sal_Bool bRead = sal_Bool( nId == SBX_HINT_DATAWANTED ); + sal_Bool bWrite = sal_Bool( nId == SBX_HINT_DATACHANGED ); SbxVariable* pVar = p->GetVar(); if( bRead || bWrite ) { XubString aVarName( pVar->GetName() ); - USHORT nHash_ = MakeHashCode( aVarName ); + sal_uInt16 nHash_ = MakeHashCode( aVarName ); if( nHash_ == nNameHash && aVarName.EqualsIgnoreCaseAscii( pNameProp ) ) { @@ -174,12 +174,12 @@ void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, } } -BOOL SbxObject::IsClass( const XubString& rName ) const +sal_Bool SbxObject::IsClass( const XubString& rName ) const { - return BOOL( aClassName.EqualsIgnoreCaseAscii( rName ) ); + return sal_Bool( aClassName.EqualsIgnoreCaseAscii( rName ) ); } -SbxVariable* SbxObject::FindUserData( UINT32 nData ) +SbxVariable* SbxObject::FindUserData( sal_uInt32 nData ) { if( !GetAll( SbxCLASS_DONTCARE ) ) return NULL; @@ -189,17 +189,17 @@ SbxVariable* SbxObject::FindUserData( UINT32 nData ) pRes = pProps->FindUserData( nData ); if( !pRes ) pRes = pObjs->FindUserData( nData ); - // Search in den Parents? + // Search in the parents? if( !pRes && IsSet( SBX_GBLSEARCH ) ) { SbxObject* pCur = this; while( !pRes && pCur->pParent ) { - // Ich selbst bin schon durchsucht worden! - USHORT nOwn = pCur->GetFlags(); + // I myself was already searched through! + sal_uInt16 nOwn = pCur->GetFlags(); pCur->ResetFlag( SBX_EXTSEARCH ); - // Ich suche bereits global! - USHORT nPar = pCur->pParent->GetFlags(); + // I search already global! + sal_uInt16 nPar = pCur->pParent->GetFlags(); pCur->pParent->ResetFlag( SBX_GBLSEARCH ); pRes = pCur->pParent->FindUserData( nData ); pCur->SetFlags( nOwn ); @@ -213,7 +213,7 @@ SbxVariable* SbxObject::FindUserData( UINT32 nData ) SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) { #ifdef DBG_UTIL - static USHORT nLvl = 0; + static sal_uInt16 nLvl = 0; static const char* pCls[] = { "DontCare","Array","Value","Variable","Method","Property","Object" }; ByteString aNameStr1( (const UniString&)rName, RTL_TEXTENCODING_ASCII_US ); @@ -251,22 +251,22 @@ SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) if( pArray ) pRes = pArray->Find( rName, t ); } - // Extended Search im Objekt-Array? - // Fuer Objekte und DontCare ist das Objektarray bereits - // durchsucht worden + // ExtendedsSearch in the Object-Array? + // For objects and DontCare is the Objektarray already + // searched through if( !pRes && ( t == SbxCLASS_METHOD || t == SbxCLASS_PROPERTY ) ) pRes = pObjs->Find( rName, t ); - // Search in den Parents? + // Search in the parents? if( !pRes && IsSet( SBX_GBLSEARCH ) ) { SbxObject* pCur = this; while( !pRes && pCur->pParent ) { - // Ich selbst bin schon durchsucht worden! - USHORT nOwn = pCur->GetFlags(); + // I myself was already searched through! + sal_uInt16 nOwn = pCur->GetFlags(); pCur->ResetFlag( SBX_EXTSEARCH ); - // Ich suche bereits global! - USHORT nPar = pCur->pParent->GetFlags(); + // I search already global! + sal_uInt16 nPar = pCur->pParent->GetFlags(); pCur->pParent->ResetFlag( SBX_GBLSEARCH ); pRes = pCur->pParent->Find( rName, t ); pCur->SetFlags( nOwn ); @@ -287,27 +287,27 @@ SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) return pRes; } -// Kurzform: Die Parent-Kette wird durchsucht -// Das ganze rekursiv, da Call() ueberladen sein kann -// Qualified Names sind zugelassen +// Abbreviated version: The parent-string will be searched through +// The whole thing recursive, because Call() might be overloaded +// Qualified names are allowed -BOOL SbxObject::Call( const XubString& rName, SbxArray* pParam ) +sal_Bool SbxObject::Call( const XubString& rName, SbxArray* pParam ) { SbxVariable* pMeth = FindQualified( rName, SbxCLASS_DONTCARE); if( pMeth && pMeth->ISA(SbxMethod) ) { - // FindQualified() koennte schon zugeschlagen haben! + // FindQualified() might have been stroked! if( pParam ) pMeth->SetParameters( pParam ); pMeth->Broadcast( SBX_HINT_DATAWANTED ); pMeth->SetParameters( NULL ); - return TRUE; + return sal_True; } SetError( SbxERR_NO_METHOD ); - return FALSE; + return sal_False; } -SbxProperty* SbxObject::GetDfltProperty() +SbxProperty* SbxObject::GetDfltProperty() { if ( !pDfltProp && aDfltPropName.Len() ) { @@ -320,16 +320,16 @@ SbxProperty* SbxObject::GetDfltProperty() void SbxObject::SetDfltProperty( const XubString& rName ) { if ( rName != aDfltPropName ) - pDfltProp = NULL; + pDfltProp = NULL; aDfltPropName = rName; - SetModified( TRUE ); + SetModified( sal_True ); } void SbxObject::SetDfltProperty( SbxProperty* p ) { if( p ) { - USHORT n; + sal_uInt16 n; SbxArray* pArray = FindVar( p, n ); pArray->Put( p, n ); if( p->GetParent() != this ) @@ -337,14 +337,14 @@ void SbxObject::SetDfltProperty( SbxProperty* p ) Broadcast( SBX_HINT_OBJECTCHANGED ); } pDfltProp = p; - SetModified( TRUE ); + SetModified( sal_True ); } -// Suchen einer bereits vorhandenen Variablen. Falls sie gefunden wurde, -// wird der Index gesetzt, sonst wird der Count des Arrays geliefert. -// In jedem Fall wird das korrekte Array geliefert. +// Search of a already available variable. If she was located, +// the index will be set, elsewise will be delivered the Count of the Array. +// In any case it will be delivered the correct Array. -SbxArray* SbxObject::FindVar( SbxVariable* pVar, USHORT& nArrayIdx ) +SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { SbxArray* pArray = NULL; if( pVar ) switch( pVar->GetClass() ) @@ -359,11 +359,11 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, USHORT& nArrayIdx ) if( pArray ) { nArrayIdx = pArray->Count(); - // ist die Variable per Name vorhanden? + // Is the variable per name available? pArray->ResetFlag( SBX_EXTSEARCH ); SbxVariable* pOld = pArray->Find( pVar->GetName(), pVar->GetClass() ); if( pOld ) - for( USHORT i = 0; i < pArray->Count(); i++ ) + for( sal_uInt16 i = 0; i < pArray->Count(); i++ ) { SbxVariableRef& rRef = pArray->GetRef( i ); if( (SbxVariable*) rRef == pOld ) @@ -375,12 +375,12 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, USHORT& nArrayIdx ) return pArray; } -// Falls ein neues Objekt eingerichtet wird, wird es, falls es bereits -// eines mit diesem Namen gibt, indiziert. +// If a new object will be established, this object will be indexed, +// if an object of this name exists already. SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataType dt ) { - // Ist das Objekt bereits vorhanden? + // Is the object already available? SbxArray* pArray = NULL; switch( ct ) { @@ -393,26 +393,12 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy } if( !pArray ) return NULL; - // Collections duerfen gleichnamige Objekte enthalten + // Collections may contain objects of the same name if( !( ct == SbxCLASS_OBJECT && ISA(SbxCollection) ) ) { SbxVariable* pRes = pArray->Find( rName, ct ); if( pRes ) { -/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus -#ifdef DBG_UTIL - if( pRes->GetHashCode() != nNameHash - && pRes->GetHashCode() != nParentHash ) - { - XubString aMsg( "SBX-Element \"" ); - aMsg += pRes->GetName(); - aMsg += "\"\n in Objekt \""; - aMsg += GetName(); - aMsg += "\" bereits vorhanden"; - DbgError( (const char*)aMsg.GetStr() ); - } -#endif -*/ return pRes; } } @@ -433,35 +419,21 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy } pVar->SetParent( this ); pArray->Put( pVar, pArray->Count() ); - SetModified( TRUE ); - // Das Objekt lauscht immer - StartListening( pVar->GetBroadcaster(), TRUE ); + SetModified( sal_True ); + // The object listen always + StartListening( pVar->GetBroadcaster(), sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); return pVar; } SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClass ) { - // Ist das Objekt bereits vorhanden? + // Is the object already available? if( !ISA(SbxCollection) ) { SbxVariable* pRes = pObjs->Find( rName, SbxCLASS_OBJECT ); if( pRes ) { -/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus -#ifdef DBG_UTIL - if( pRes->GetHashCode() != nNameHash - && pRes->GetHashCode() != nParentHash ) - { - XubString aMsg( "SBX-Objekt \"" ); - aMsg += pRes->GetName(); - aMsg += "\"\n in Objekt \""; - aMsg += GetName(); - aMsg += "\" bereits vorhanden"; - DbgError( (const char*)aMsg.GetStr() ); - } -#endif -*/ return PTR_CAST(SbxObject,pRes); } } @@ -471,9 +443,9 @@ SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClas pVar->SetName( rName ); pVar->SetParent( this ); pObjs->Put( pVar, pObjs->Count() ); - SetModified( TRUE ); - // Das Objekt lauscht immer - StartListening( pVar->GetBroadcaster(), TRUE ); + SetModified( sal_True ); + // The object listen always + StartListening( pVar->GetBroadcaster(), sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } return pVar; @@ -481,39 +453,25 @@ SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClas void SbxObject::Insert( SbxVariable* pVar ) { - USHORT nIdx; + sal_uInt16 nIdx; SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray ) { - // Hinein damit. Man sollte allerdings auf die Pointer aufpassen! + // Into with it. But you should pay attention at the Pointer! if( nIdx < pArray->Count() ) { - // dann gibt es dieses Element bereits - // Bei Collections duerfen gleichnamige Objekte hinein + // Then this element exists already + // There are objects of the same name allowed at collections if( pArray == pObjs && ISA(SbxCollection) ) nIdx = pArray->Count(); else { SbxVariable* pOld = pArray->Get( nIdx ); - // schon drin: ueberschreiben + // already inside: overwrite if( pOld == pVar ) return; -/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus -#ifdef DBG_UTIL - if( pOld->GetHashCode() != nNameHash - && pOld->GetHashCode() != nParentHash ) - { - XubString aMsg( "SBX-Element \"" ); - aMsg += pVar->GetName(); - aMsg += "\"\n in Objekt \""; - aMsg += GetName(); - aMsg += "\" bereits vorhanden"; - DbgError( (const char*)aMsg.GetStr() ); - } -#endif -*/ - EndListening( pOld->GetBroadcaster(), TRUE ); + EndListening( pOld->GetBroadcaster(), sal_True ); if( pVar->GetClass() == SbxCLASS_PROPERTY ) { if( pOld == pDfltProp ) @@ -521,11 +479,11 @@ void SbxObject::Insert( SbxVariable* pVar ) } } } - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); pArray->Put( pVar, nIdx ); if( pVar->GetParent() != this ) pVar->SetParent( this ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); #ifdef DBG_UTIL static const char* pCls[] = @@ -543,8 +501,8 @@ void SbxObject::Insert( SbxVariable* pVar ) } } -// AB 23.4.1997, Optimierung, Einfuegen ohne Ueberpruefung auf doppelte -// Eintraege und ohne Broadcasts, wird nur in SO2/auto.cxx genutzt +// Optimisation, Insertion without checking about +// double entry and without broadcasts, will only be used in SO2/auto.cxx void SbxObject::QuickInsert( SbxVariable* pVar ) { SbxArray* pArray = NULL; @@ -562,11 +520,11 @@ void SbxObject::QuickInsert( SbxVariable* pVar ) } if( pArray ) { - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); pArray->Put( pVar, pArray->Count() ); if( pVar->GetParent() != this ) pVar->SetParent( this ); - SetModified( TRUE ); + SetModified( sal_True ); #ifdef DBG_UTIL static const char* pCls[] = { "DontCare","Array","Value","Variable","Method","Property","Object" }; @@ -583,7 +541,7 @@ void SbxObject::QuickInsert( SbxVariable* pVar ) } } -// AB 23.3.1997, Spezial-Methode, gleichnamige Controls zulassen +// special method, allow controls of the same name void SbxObject::VCPtrInsert( SbxVariable* pVar ) { SbxArray* pArray = NULL; @@ -601,11 +559,11 @@ void SbxObject::VCPtrInsert( SbxVariable* pVar ) } if( pArray ) { - StartListening( pVar->GetBroadcaster(), TRUE ); + StartListening( pVar->GetBroadcaster(), sal_True ); pArray->Put( pVar, pArray->Count() ); if( pVar->GetParent() != this ) pVar->SetParent( this ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } } @@ -617,7 +575,7 @@ void SbxObject::Remove( const XubString& rName, SbxClassType t ) void SbxObject::Remove( SbxVariable* pVar ) { - USHORT nIdx; + sal_uInt16 nIdx; SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray && nIdx < pArray->Count() ) { @@ -630,40 +588,40 @@ void SbxObject::Remove( SbxVariable* pVar ) #endif SbxVariableRef pVar_ = pArray->Get( nIdx ); if( pVar_->IsBroadcaster() ) - EndListening( pVar_->GetBroadcaster(), TRUE ); + EndListening( pVar_->GetBroadcaster(), sal_True ); if( (SbxVariable*) pVar_ == pDfltProp ) pDfltProp = NULL; pArray->Remove( nIdx ); if( pVar_->GetParent() == this ) pVar_->SetParent( NULL ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } } -// AB 23.3.1997, Loeschen per Pointer fuer Controls (doppelte Namen!) +// cleanup per Pointer for Controls (double names!) void SbxObject::VCPtrRemove( SbxVariable* pVar ) { - USHORT nIdx; - // Neu FindVar-Methode, sonst identisch mit normaler Methode + sal_uInt16 nIdx; + // New FindVar-Method, otherwise identical with the normal method SbxArray* pArray = VCPtrFindVar( pVar, nIdx ); if( pArray && nIdx < pArray->Count() ) { SbxVariableRef xVar = pArray->Get( nIdx ); if( xVar->IsBroadcaster() ) - EndListening( xVar->GetBroadcaster(), TRUE ); + EndListening( xVar->GetBroadcaster(), sal_True ); if( (SbxVariable*) xVar == pDfltProp ) pDfltProp = NULL; pArray->Remove( nIdx ); if( xVar->GetParent() == this ) xVar->SetParent( NULL ); - SetModified( TRUE ); + SetModified( sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } } -// AB 23.3.1997, Zugehoerige Spezial-Methode, nur ueber Pointer suchen -SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, USHORT& nArrayIdx ) +// associated special method, search only by Pointer +SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { SbxArray* pArray = NULL; if( pVar ) switch( pVar->GetClass() ) @@ -678,7 +636,7 @@ SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, USHORT& nArrayIdx ) if( pArray ) { nArrayIdx = pArray->Count(); - for( USHORT i = 0; i < pArray->Count(); i++ ) + for( sal_uInt16 i = 0; i < pArray->Count(); i++ ) { SbxVariableRef& rRef = pArray->GetRef( i ); if( (SbxVariable*) rRef == pVar ) @@ -692,9 +650,9 @@ SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, USHORT& nArrayIdx ) -void SbxObject::SetPos( SbxVariable* pVar, USHORT nPos ) +void SbxObject::SetPos( SbxVariable* pVar, sal_uInt16 nPos ) { - USHORT nIdx; + sal_uInt16 nIdx; SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray ) { @@ -707,53 +665,51 @@ void SbxObject::SetPos( SbxVariable* pVar, USHORT nPos ) pArray->Insert( refVar, nPos ); } } -// SetModified( TRUE ); -// Broadcast( SBX_HINT_OBJECTCHANGED ); } -static BOOL LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) +static sal_Bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) { SbxArrayRef p = (SbxArray*) SbxBase::Load( rStrm ); if( !p.Is() ) - return FALSE; - for( USHORT i = 0; i < p->Count(); i++ ) + return sal_False; + for( sal_uInt16 i = 0; i < p->Count(); i++ ) { SbxVariableRef& r = p->GetRef( i ); SbxVariable* pVar = r; if( pVar ) { pVar->SetParent( pThis ); - pThis->StartListening( pVar->GetBroadcaster(), TRUE ); + pThis->StartListening( pVar->GetBroadcaster(), sal_True ); } } pArray->Merge( p ); - return TRUE; + return sal_True; } -// Der Load eines Objekts ist additiv! +// The load of an object is additive! -BOOL SbxObject::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { - // Hilfe fuer das Einlesen alter Objekte: einfach TRUE zurueck, - // LoadPrivateData() muss Default-Zustand herstellen + // Help for the read in of old objects: just TRUE back, + // LoadPrivateData() had to set the default status up if( !nVer ) - return TRUE; + return sal_True; pDfltProp = NULL; if( !SbxVariable::LoadData( rStrm, nVer ) ) - return FALSE; - // Wenn kein fremdes Objekt enthalten ist, uns selbst eintragen + return sal_False; + // If it contains no alien object, insert ourselves if( aData.eType == SbxOBJECT && !aData.pObj ) aData.pObj = this; sal_uInt32 nSize; XubString aDfltProp; rStrm.ReadByteString( aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm.ReadByteString( aDfltProp, RTL_TEXTENCODING_ASCII_US ); - ULONG nPos = rStrm.Tell(); + sal_uIntPtr nPos = rStrm.Tell(); rStrm >> nSize; if( !LoadPrivateData( rStrm, nVer ) ) - return FALSE; - ULONG nNewPos = rStrm.Tell(); + return sal_False; + sal_uIntPtr nNewPos = rStrm.Tell(); nPos += nSize; DBG_ASSERT( nPos >= nNewPos, "SBX: Zu viele Daten eingelesen" ); if( nPos != nNewPos ) @@ -761,49 +717,49 @@ BOOL SbxObject::LoadData( SvStream& rStrm, USHORT nVer ) if( !LoadArray( rStrm, this, pMethods ) || !LoadArray( rStrm, this, pProps ) || !LoadArray( rStrm, this, pObjs ) ) - return FALSE; - // Properties setzen + return sal_False; + // Set properties if( aDfltProp.Len() ) pDfltProp = (SbxProperty*) pProps->Find( aDfltProp, SbxCLASS_PROPERTY ); - SetModified( FALSE ); - return TRUE; + SetModified( sal_False ); + return sal_True; } -BOOL SbxObject::StoreData( SvStream& rStrm ) const +sal_Bool SbxObject::StoreData( SvStream& rStrm ) const { if( !SbxVariable::StoreData( rStrm ) ) - return FALSE; + return sal_False; XubString aDfltProp; if( pDfltProp ) aDfltProp = pDfltProp->GetName(); rStrm.WriteByteString( aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm.WriteByteString( aDfltProp, RTL_TEXTENCODING_ASCII_US ); - ULONG nPos = rStrm.Tell(); - rStrm << (UINT32) 0L; + sal_uIntPtr nPos = rStrm.Tell(); + rStrm << (sal_uInt32) 0L; if( !StorePrivateData( rStrm ) ) - return FALSE; - ULONG nNew = rStrm.Tell(); + return sal_False; + sal_uIntPtr nNew = rStrm.Tell(); rStrm.Seek( nPos ); - rStrm << (UINT32) ( nNew - nPos ); + rStrm << (sal_uInt32) ( nNew - nPos ); rStrm.Seek( nNew ); if( !pMethods->Store( rStrm ) ) - return FALSE; + return sal_False; if( !pProps->Store( rStrm ) ) - return FALSE; + return sal_False; if( !pObjs->Store( rStrm ) ) - return FALSE; - ((SbxObject*) this)->SetModified( FALSE ); - return TRUE; + return sal_False; + ((SbxObject*) this)->SetModified( sal_False ); + return sal_True; } XubString SbxObject::GenerateSource( const XubString &rLinePrefix, const SbxObject* ) { - // Properties in einem String einsammeln + // Collect the properties in a String XubString aSource; SbxArrayRef xProps( GetProperties() ); bool bLineFeed = false; - for ( USHORT nProp = 0; nProp < xProps->Count(); ++nProp ) + for ( sal_uInt16 nProp = 0; nProp < xProps->Count(); ++nProp ) { SbxPropertyRef xProp = (SbxProperty*) xProps->Get(nProp); XubString aPropName( xProp->GetName() ); @@ -811,7 +767,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, && !( xProp->GetHashCode() == nNameHash && aPropName.EqualsIgnoreCaseAscii( pNameProp ) ) ) { - // ausser vor dem ersten Property immer einen Umbruch einfuegen + // Insert a break except in front of the first property if ( bLineFeed ) aSource.AppendAscii( "\n" ); else @@ -822,17 +778,17 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, aSource += aPropName; aSource.AppendAscii( " = " ); - // den Property-Wert textuell darstellen + // Display the property value textual switch ( xProp->GetType() ) { case SbxEMPTY: case SbxNULL: - // kein Wert + // no value break; case SbxSTRING: { - // Strings in Anf"uhrungszeichen + // Strings in quotation mark aSource.AppendAscii( "\"" ); aSource += xProp->GetString(); aSource.AppendAscii( "\"" ); @@ -841,7 +797,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, default: { - // sonstiges wie z.B. Zahlen direkt + // miscellaneous, such as e.g.numerary directly aSource += xProp->GetString(); break; } @@ -851,7 +807,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, return aSource; } -static BOOL CollectAttrs( const SbxBase* p, XubString& rRes ) +static sal_Bool CollectAttrs( const SbxBase* p, XubString& rRes ) { XubString aAttrs; if( p->IsHidden() ) @@ -879,19 +835,19 @@ static BOOL CollectAttrs( const SbxBase* p, XubString& rRes ) rRes.AssignAscii( " (" ); rRes += aAttrs; rRes += ')'; - return TRUE; + return sal_True; } else { rRes.Erase(); - return FALSE; + return sal_False; } } -void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) +void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill ) { - // Einr"uckung - static USHORT nLevel = 0; + // Shifting + static sal_uInt16 nLevel = 0; if ( nLevel > 10 ) { rStrm << "<too deep>" << endl; @@ -899,18 +855,18 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) } ++nLevel; String aIndent; - for ( USHORT n = 1; n < nLevel; ++n ) + for ( sal_uInt16 n = 1; n < nLevel; ++n ) aIndent.AppendAscii( " " ); - // ggf. Objekt vervollst"andigen + // if necessary complete the object if ( bFill ) GetAll( SbxCLASS_DONTCARE ); - // Daten des Objekts selbst ausgeben + // Output the data of the object itself ByteString aNameStr( (const UniString&)GetName(), RTL_TEXTENCODING_ASCII_US ); ByteString aClassNameStr( (const UniString&)aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm << "Object( " - << ByteString::CreateFromInt64( (ULONG) this ).GetBuffer() << "=='" + << ByteString::CreateFromInt64( (sal_uIntPtr) this ).GetBuffer() << "=='" << ( aNameStr.Len() ? aNameStr.GetBuffer() : "<unnamed>" ) << "', " << "of class '" << aClassNameStr.GetBuffer() << "', " << "counts " @@ -920,7 +876,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) { ByteString aParentNameStr( (const UniString&)GetName(), RTL_TEXTENCODING_ASCII_US ); rStrm << "in parent " - << ByteString::CreateFromInt64( (ULONG) GetParent() ).GetBuffer() + << ByteString::CreateFromInt64( (sal_uIntPtr) GetParent() ).GetBuffer() << "=='" << ( aParentNameStr.Len() ? aParentNameStr.GetBuffer() : "<unnamed>" ) << "'"; } else @@ -939,7 +895,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) // Methods rStrm << aIndentNameStr.GetBuffer() << "- Methods:" << endl; - for( USHORT i = 0; i < pMethods->Count(); i++ ) + for( sal_uInt16 i = 0; i < pMethods->Count(); i++ ) { SbxVariableRef& r = pMethods->GetRef( i ); SbxVariable* pVar = r; @@ -955,7 +911,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) aLine.AppendAscii( " !! Not a Method !!" ); rStrm.WriteByteString( aLine, RTL_TEXTENCODING_ASCII_US ); - // bei Object-Methods auch das Object ausgeben + // Output also the object at object-methods if ( pVar->GetValues_Impl().eType == SbxOBJECT && pVar->GetValues_Impl().pObj && pVar->GetValues_Impl().pObj != this && @@ -972,7 +928,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) // Properties rStrm << aIndentNameStr.GetBuffer() << "- Properties:" << endl; { - for( USHORT i = 0; i < pProps->Count(); i++ ) + for( sal_uInt16 i = 0; i < pProps->Count(); i++ ) { SbxVariableRef& r = pProps->GetRef( i ); SbxVariable* pVar = r; @@ -988,7 +944,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) aLine.AppendAscii( " !! Not a Property !!" ); rStrm.WriteByteString( aLine, RTL_TEXTENCODING_ASCII_US ); - // bei Object-Properties auch das Object ausgeben + // output also the object at object properties if ( pVar->GetValues_Impl().eType == SbxOBJECT && pVar->GetValues_Impl().pObj && pVar->GetValues_Impl().pObj != this && @@ -1006,7 +962,7 @@ void SbxObject::Dump( SvStream& rStrm, BOOL bFill ) // Objects rStrm << aIndentNameStr.GetBuffer() << "- Objects:" << endl; { - for( USHORT i = 0; i < pObjs->Count(); i++ ) + for( sal_uInt16 i = 0; i < pObjs->Count(); i++ ) { SbxVariableRef& r = pObjs->GetRef( i ); SbxVariable* pVar = r; @@ -1030,7 +986,7 @@ SvDispatch* SbxObject::GetSvDispatch() return NULL; } -BOOL SbxMethod::Run( SbxValues* pValues ) +sal_Bool SbxMethod::Run( SbxValues* pValues ) { SbxValues aRes; if( !pValues ) @@ -1049,16 +1005,15 @@ SbxClassType SbxProperty::GetClass() const return SbxCLASS_PROPERTY; } -void SbxObject::GarbageCollection( ULONG /*nObjects*/ ) +void SbxObject::GarbageCollection( sal_uIntPtr /* nObjects */ ) -/* [Beschreibung] +/* [Description] - Diese statische Methode durchsucht die n"achsten 'nObjects' der zur Zeit - existierenden <SbxObject>-Instanzen nach zyklischen Referenzen, die sich - nur noch selbst am Leben erhalten. Ist 'nObjects==0', dann werden - alle existierenden durchsucht. + This statistic method browse the next 'nObjects' of the currently existing + <SbxObject>-Instances for cyclic references, which keep only themselfes alive + If there is 'nObjects==0', then all existing will be browsed. - zur Zeit nur implementiert: Object -> Parent-Property -> Parent -> Object + currently only implemented: Object -> Parent-Property -> Parent -> Object */ { diff --git a/basic/source/sbx/sbxres.cxx b/basic/source/sbx/sbxres.cxx index 612911aaad..1db3372b9e 100644 --- a/basic/source/sbx/sbxres.cxx +++ b/basic/source/sbx/sbxres.cxx @@ -81,12 +81,12 @@ static const char* pSbxRes[] = { "True" }; -const char* GetSbxRes( USHORT nId ) +const char* GetSbxRes( sal_uInt16 nId ) { return ( ( nId > SBXRES_MAX ) ? "???" : pSbxRes[ nId ] ); } -SbxRes::SbxRes( USHORT nId ) +SbxRes::SbxRes( sal_uInt16 nId ) : ::rtl::OUString( ::rtl::OUString::createFromAscii( GetSbxRes( nId ) ) ) {} diff --git a/basic/source/sbx/sbxres.hxx b/basic/source/sbx/sbxres.hxx index eb2e202665..483302da95 100644 --- a/basic/source/sbx/sbxres.hxx +++ b/basic/source/sbx/sbxres.hxx @@ -79,10 +79,10 @@ class SbxRes : public ::rtl::OUString { public: - SbxRes( USHORT ); + SbxRes( sal_uInt16 ); }; -const char* GetSbxRes( USHORT ); +const char* GetSbxRes( sal_uInt16 ); #endif diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx index aeff9a4108..a1df7f7e7b 100644 --- a/basic/source/sbx/sbxscan.cxx +++ b/basic/source/sbx/sbxscan.cxx @@ -2,7 +2,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 @@ -71,7 +71,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep ) // Fixed ist und das ganze nicht hineinpasst! SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType, - USHORT* pLen, BOOL bAllowIntntl, BOOL bOnlyIntntl ) + sal_uInt16* pLen, sal_Bool bAllowIntntl, sal_Bool bOnlyIntntl ) { ::rtl::OString aBStr( ::rtl::OUStringToOString( rWSrc, RTL_TEXTENCODING_ASCII_US ) ); @@ -102,15 +102,15 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType const char* pStart = aBStr.getStr(); const char* p = pStart; char buf[ 80 ], *q = buf; - BOOL bRes = TRUE; - BOOL bMinus = FALSE; + sal_Bool bRes = sal_True; + sal_Bool bMinus = sal_False; nVal = 0; SbxDataType eScanType = SbxSINGLE; // Whitespace wech while( *p &&( *p == ' ' || *p == '\t' ) ) p++; // Zahl? Dann einlesen und konvertieren. if( *p == '-' ) - p++, bMinus = TRUE; + p++, bMinus = sal_True; if( isdigit( *p ) ||( (*p == cNonIntntlComma || *p == cIntntlComma || *p == cIntntl1000) && isdigit( *(p+1 ) ) ) ) { @@ -171,7 +171,7 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType *q = 0; // Komma, Exponent mehrfach vorhanden? if( comma > 1 || exp > 1 ) - bRes = FALSE; + bRes = sal_False; // Kann auf Integer gefaltet werden? if( !comma && !exp ) { @@ -203,7 +203,7 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType { case 'O': cmp = "01234567"; base = 8; ndig = 11; break; case 'H': break; - default : bRes = FALSE; + default : bRes = sal_False; } long l = 0; int i; @@ -212,7 +212,7 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType char ch = sal::static_int_cast< char >( toupper( *p ) ); p++; if( strchr( cmp, ch ) ) *q++ = ch; - else bRes = FALSE; + else bRes = sal_False; } *q = 0; for( q = buf; *q; q++ ) @@ -221,7 +221,7 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType if( i > 9 ) i -= 7; l =( l * base ) + i; if( !ndig-- ) - bRes = FALSE; + bRes = sal_False; } if( *p == '&' ) p++; nVal = (double) l; @@ -234,7 +234,7 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType return SbxERR_CONVERSION; } if( pLen ) - *pLen = (USHORT) ( p - pStart ); + *pLen = (sal_uInt16) ( p - pStart ); if( !bRes ) return SbxERR_CONVERSION; if( bMinus ) @@ -244,12 +244,12 @@ SbxError ImpScan( const ::rtl::OUString& rWSrc, double& nVal, SbxDataType& rType } // Schnittstelle fuer CDbl im Basic -SbxError SbxValue::ScanNumIntnl( const String& rSrc, double& nVal, BOOL bSingle ) +SbxError SbxValue::ScanNumIntnl( const String& rSrc, double& nVal, sal_Bool bSingle ) { SbxDataType t; - USHORT nLen = 0; + sal_uInt16 nLen = 0; SbxError nRetError = ImpScan( rSrc, nVal, t, &nLen, - /*bAllowIntntl*/FALSE, /*bOnlyIntntl*/TRUE ); + /*bAllowIntntl*/sal_False, /*bOnlyIntntl*/sal_True ); // Komplett gelesen? if( nRetError == SbxERR_OK && nLen != rSrc.Len() ) nRetError = SbxERR_CONVERSION; @@ -262,7 +262,6 @@ SbxError SbxValue::ScanNumIntnl( const String& rSrc, double& nVal, BOOL bSingle return nRetError; } -//////////////////////////////////////////////////////////////////////////// static double roundArray[] = { 5.0e+0, 0.5e+0, 0.5e-1, 0.5e-2, 0.5e-3, 0.5e-4, 0.5e-5, 0.5e-6, 0.5e-7, @@ -270,26 +269,26 @@ static double roundArray[] = { /*************************************************************************** |* -|* void myftoa( double, char *, short, short, BOOL, BOOL ) +|* void myftoa( double, char *, short, short, sal_Bool, sal_Bool ) |* |* Beschreibung: Konversion double --> ASCII |* Parameter: double die Zahl. |* char * der Zielpuffer |* short Anzahl Nachkommastellen |* short Weite des Exponenten( 0=kein E ) -|* BOOL TRUE: mit 1000er Punkten -|* BOOL TRUE: formatfreie Ausgabe +|* sal_Bool sal_True: mit 1000er Punkten +|* sal_Bool sal_True: formatfreie Ausgabe |* ***************************************************************************/ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, - BOOL bPt, BOOL bFix, sal_Unicode cForceThousandSep = 0 ) + sal_Bool bPt, sal_Bool bFix, sal_Unicode cForceThousandSep = 0 ) { short nExp = 0; // Exponent short nDig = nPrec + 1; // Anzahl Digits in Zahl short nDec; // Anzahl Vorkommastellen - register int i, digit; + register int i; // Komma besorgen sal_Unicode cDecimalSep, cThousandSep; @@ -339,6 +338,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, // Zahl ausgeben: if( nDig > 0 ) { + register int digit; for( i = 0 ; ; ++i ) { if( i < 16 ) @@ -390,7 +390,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, #pragma warning(disable: 4748) // "... because optimizations are disabled ..." #endif -void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, BOOL bCoreString ) +void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, sal_Bool bCoreString ) { char *q; char cBuf[ 40 ], *p = cBuf; @@ -406,7 +406,7 @@ void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, BOOL bCoreStrin } double dMaxNumWithoutExp = (nPrec == 6) ? 1E6 : 1E14; myftoa( nNum, p, nPrec,( nNum &&( nNum < 1E-1 || nNum >= dMaxNumWithoutExp ) ) ? 4:0, - FALSE, TRUE, cDecimalSep ); + sal_False, sal_True, cDecimalSep ); // Trailing Zeroes weg: for( p = cBuf; *p &&( *p != 'E' ); p++ ) {} q = p; p--; @@ -421,13 +421,13 @@ void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, BOOL bCoreStrin #pragma optimize( "", on ) #endif -BOOL ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ) +sal_Bool ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ) { // Merken, ob ueberhaupt was geaendert wurde - BOOL bChanged = FALSE; + sal_Bool bChanged = sal_False; ::rtl::OUString aNewString; - // Nur Spezial-Fälle behandeln, als Default tun wir nichts + // Nur Spezial-F�lle behandeln, als Default tun wir nichts switch( eTargetType ) { // Bei Fliesskomma International beruecksichtigen @@ -450,25 +450,25 @@ BOOL ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ) { sal_Unicode* pStr = (sal_Unicode*)aNewString.getStr(); pStr[nPos] = (sal_Unicode)'.'; - bChanged = TRUE; + bChanged = sal_True; } } break; } - // Bei BOOL TRUE und FALSE als String pruefen + // Bei sal_Bool sal_True und sal_False als String pruefen case SbxBOOL: { if( rSrc.equalsIgnoreAsciiCaseAscii( "true" ) ) { aNewString = ::rtl::OUString::valueOf( (sal_Int32)SbxTRUE ); - bChanged = TRUE; + bChanged = sal_True; } else if( rSrc.equalsIgnoreAsciiCaseAscii( "false" ) ) { aNewString = ::rtl::OUString::valueOf( (sal_Int32)SbxFALSE ); - bChanged = TRUE; + bChanged = sal_True; } break; } @@ -489,7 +489,7 @@ BOOL ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ) // lasse diesen Code vorl"aufig drin, zum 'abgucken' // der bisherigen Implementation -static USHORT printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt ) +static sal_uInt16 printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt ) { const String& rFmt = rWFmt; char cFill = ' '; // Fuellzeichen @@ -498,10 +498,10 @@ static USHORT printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt short nPrec = 0; // Anzahl Nachkommastellen short nWidth = 0; // Zahlenweite gesamnt short nLen; // Laenge konvertierte Zahl - BOOL bPoint = FALSE; // TRUE: mit 1000er Kommas - BOOL bTrail = FALSE; // TRUE, wenn folgendes Minus - BOOL bSign = FALSE; // TRUE: immer mit Vorzeichen - BOOL bNeg = FALSE; // TRUE: Zahl ist negativ + sal_Bool bPoint = sal_False; // sal_True: mit 1000er Kommas + sal_Bool bTrail = sal_False; // sal_True, wenn folgendes Minus + sal_Bool bSign = sal_False; // sal_True: immer mit Vorzeichen + sal_Bool bNeg = sal_False; // sal_True: Zahl ist negativ char cBuf [1024]; // Zahlenpuffer char * p; const char* pFmt = rFmt; @@ -517,7 +517,7 @@ static USHORT printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt case 0: break; case '+': - bSign = TRUE; nWidth++; break; + bSign = sal_True; nWidth++; break; case '*': nWidth++; cFill = '*'; if( *pFmt == '$' ) nWidth++, pFmt++, cPre = '$'; @@ -536,7 +536,7 @@ static USHORT printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt // 1000er Kommas? if( *pFmt == ',' ) { - nWidth++; pFmt++; bPoint = TRUE; + nWidth++; pFmt++; bPoint = sal_True; } else break; } // Nachkomma: @@ -550,14 +550,14 @@ static USHORT printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt pFmt++, nExpDig++, nWidth++; // Folgendes Minus: if( !bSign && *pFmt == '-' ) - pFmt++, bTrail = TRUE; + pFmt++, bTrail = sal_True; // Zahl konvertieren: if( nPrec > 15 ) nPrec = 15; - if( nNum < 0.0 ) nNum = -nNum, bNeg = TRUE; + if( nNum < 0.0 ) nNum = -nNum, bNeg = sal_True; p = cBuf; if( bSign ) *p++ = bNeg ? '-' : '+'; - myftoa( nNum, p, nPrec, nExpDig, bPoint, FALSE ); + myftoa( nNum, p, nPrec, nExpDig, bPoint, sal_False ); nLen = strlen( cBuf ); // Ueberlauf? @@ -572,12 +572,12 @@ static USHORT printfmtnum( double nNum, XubString& rRes, const XubString& rWFmt if( bTrail ) rRes += bNeg ? '-' : ' '; - return (USHORT) ( pFmt - (const char*) rFmt ); + return (sal_uInt16) ( pFmt - (const char*) rFmt ); } #endif //_old_format_code_ -static USHORT printfmtstr( const XubString& rStr, XubString& rRes, const XubString& rFmt ) +static sal_uInt16 printfmtstr( const XubString& rStr, XubString& rRes, const XubString& rFmt ) { const xub_Unicode* pStr = rStr.GetBuffer(); const xub_Unicode* pFmtStart = rFmt.GetBuffer(); @@ -602,12 +602,11 @@ static USHORT printfmtstr( const XubString& rStr, XubString& rRes, const XubStri rRes = rStr; break; } - return (USHORT) ( pFmt - pFmtStart ); + return (sal_uInt16) ( pFmt - pFmtStart ); } -///////////////////////////////////////////////////////////////////////// -BOOL SbxValue::Scan( const XubString& rSrc, USHORT* pLen ) +sal_Bool SbxValue::Scan( const XubString& rSrc, sal_uInt16* pLen ) { SbxError eRes = SbxERR_OK; if( !CanWrite() ) @@ -626,10 +625,10 @@ BOOL SbxValue::Scan( const XubString& rSrc, USHORT* pLen ) } if( eRes ) { - SetError( eRes ); return FALSE; + SetError( eRes ); return sal_False; } else - return TRUE; + return sal_True; } @@ -647,7 +646,7 @@ ResMgr* implGetResMgr( void ) class SbxValueFormatResId : public ResId { public: - SbxValueFormatResId( USHORT nId ) + SbxValueFormatResId( sal_uInt16 nId ) : ResId( nId, *implGetResMgr() ) {} }; @@ -662,7 +661,7 @@ enum VbaFormatType struct VbaFormatInfo { - VbaFormatType meType; + VbaFormatType meType; const char* mpVbaFormat; // Format string in vba NfIndexTableOffset meOffset; // SvNumberFormatter format index, if meType = VBA_FORMAT_TYPE_OFFSET const char* mpOOoFormat; // if meType = VBA_FORMAT_TYPE_USERDEFINED @@ -674,12 +673,12 @@ struct VbaFormatInfo #define VBA_FORMAT_USERDEFINED( pcUtf8, pcDefinedUtf8 ) \ { VBA_FORMAT_TYPE_USERDEFINED, pcUtf8, NF_NUMBER_STANDARD, pcDefinedUtf8 } -static VbaFormatInfo pFormatInfoTable[] = +static VbaFormatInfo pFormatInfoTable[] = { VBA_FORMAT_OFFSET( "Long Date", NF_DATE_SYSTEM_LONG ), VBA_FORMAT_USERDEFINED( "Medium Date", "DD-MMM-YY" ), VBA_FORMAT_OFFSET( "Short Date", NF_DATE_SYSTEM_SHORT ), - VBA_FORMAT_USERDEFINED( "Long Time", "H:MM:SS AM/PM" ), + VBA_FORMAT_USERDEFINED( "Long Time", "H:MM:SS AM/PM" ), VBA_FORMAT_OFFSET( "Medium Time", NF_TIME_HHMMAMPM ), VBA_FORMAT_OFFSET( "Short Time", NF_TIME_HHMM ), VBA_FORMAT_OFFSET( "ddddd", NF_DATE_SYSTEM_SHORT ), @@ -692,12 +691,12 @@ static VbaFormatInfo pFormatInfoTable[] = VbaFormatInfo* getFormatInfo( const String& rFmt ) { VbaFormatInfo* pInfo = NULL; - INT16 i = 0; + sal_Int16 i = 0; while( (pInfo = pFormatInfoTable + i )->mpVbaFormat != NULL ) { if( rFmt.EqualsIgnoreCaseAscii( pInfo->mpVbaFormat ) ) break; - i++; + i++; } return pInfo; } @@ -712,11 +711,11 @@ VbaFormatInfo* getFormatInfo( const String& rFmt ) #define VBAFORMAT_UPPERCASE ">" // From methods1.cxx -INT16 implGetWeekDay( double aDate, bool bFirstDayParam = false, INT16 nFirstDay = 0 ); +sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam = false, sal_Int16 nFirstDay = 0 ); // from methods.cxx -INT16 implGetMinute( double dDate ); -INT16 implGetDateYear( double aDate ); -BOOL implDateSerial( INT16 nYear, INT16 nMonth, INT16 nDay, double& rdRet ); +sal_Int16 implGetMinute( double dDate ); +sal_Int16 implGetDateYear( double aDate ); +sal_Bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double& rdRet ); void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const { @@ -724,7 +723,7 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const double d = 0; // pflin, It is better to use SvNumberFormatter to handle the date/time/number format. - // the SvNumberFormatter output is mostly compatible with + // the SvNumberFormatter output is mostly compatible with // VBA output besides the OOo-basic output if( pFmt && !SbxBasicFormater::isBasicFormat( *pFmt ) ) { @@ -742,21 +741,21 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const } LanguageType eLangType = GetpApp()->GetSettings().GetLanguage(); - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); SvNumberFormatter aFormatter( xFactory, eLangType ); sal_uInt32 nIndex; - xub_StrLen nCheckPos = 0; - short nType; double nNumber; Color* pCol; - BOOL bSuccess = aFormatter.IsNumberFormat( aStr, nIndex, nNumber ); + sal_Bool bSuccess = aFormatter.IsNumberFormat( aStr, nIndex, nNumber ); - // number format, use SvNumberFormatter to handle it. + // number format, use SvNumberFormatter to handle it. if( bSuccess ) { + xub_StrLen nCheckPos = 0; + short nType; String aFmtStr = *pFmt; VbaFormatInfo* pInfo = getFormatInfo( aFmtStr ); if( pInfo && pInfo->meType != VBA_FORMAT_TYPE_NULL ) @@ -773,14 +772,14 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const aFormatter.GetOutputString( nNumber, nIndex, rRes, &pCol ); } else if( aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_GENERALDATE ) - || aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_C )) + || aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_C )) { if( nNumber <=-1.0 || nNumber >= 1.0 ) { - // short date + // short date nIndex = aFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLangType ); aFormatter.GetOutputString( nNumber, nIndex, rRes, &pCol ); - + // long time if( floor( nNumber ) != nNumber ) { @@ -801,9 +800,9 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const } } else if( aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_N ) - || aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_NN )) + || aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_NN )) { - INT32 nMin = implGetMinute( nNumber ); + sal_Int32 nMin = implGetMinute( nNumber ); if( nMin < 10 && aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_NN ) ) { // Minute in two digits @@ -818,15 +817,15 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const } else if( aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_W )) { - INT32 nWeekDay = implGetWeekDay( nNumber ); + sal_Int32 nWeekDay = implGetWeekDay( nNumber ); rRes = String::CreateFromInt32( nWeekDay ); } else if( aFmtStr.EqualsIgnoreCaseAscii( VBAFORMAT_Y )) { - INT16 nYear = implGetDateYear( nNumber ); + sal_Int16 nYear = implGetDateYear( nNumber ); double dBaseDate; implDateSerial( nYear, 1, 1, dBaseDate ); - INT32 nYear32 = 1 + INT32( nNumber - dBaseDate ); + sal_Int32 nYear32 = 1 + sal_Int32( nNumber - dBaseDate ); rRes = String::CreateFromInt32( nYear32 ); } else @@ -931,8 +930,6 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const rRes = pData->pBasicFormater->BasicFormatNull( *pFmt ); } - // Die alte Implementierung: - //old: printfmtnum( GetDouble(), rRes, *pFmt ); } else { @@ -947,7 +944,7 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const // #45355 wenn es numerisch ist, muss gewandelt werden if( IsNumericRTL() ) { - ScanNumIntnl( GetString(), d, /*bSingle*/FALSE ); + ScanNumIntnl( GetString(), d, /*bSingle*/sal_False ); goto cvt2; } else diff --git a/basic/source/sbx/sbxsng.cxx b/basic/source/sbx/sbxsng.cxx index 21dd38f444..5c7f0c74a1 100644 --- a/basic/source/sbx/sbxsng.cxx +++ b/basic/source/sbx/sbxsng.cxx @@ -59,10 +59,6 @@ start: nRes = (float) p->nULong; break; case SbxSINGLE: nRes = p->nSingle; break; - case SbxSALINT64: - nRes = (float) p->nInt64; break; - case SbxSALUINT64: - nRes = (float) ImpSalUInt64ToDouble( p->uInt64 ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: if( p->pDecimal ) @@ -72,17 +68,17 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: case SbxCURRENCY: + case SbxSALINT64: + case SbxSALUINT64: { double dVal; if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); + dVal = ImpCurrencyToDouble( p->nInt64 ); + else if( p->eType == SbxSALINT64 ) + dVal = (float) p->nInt64; + else if( p->eType == SbxSALUINT64 ) + dVal = (float) p->uInt64; else dVal = p->nDouble; @@ -96,6 +92,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = static_cast< float >(SbxMINSNG); } + // tests for underflow - storing value too small for precision of single else if( dVal > 0 && dVal < SbxMAXSNG2 ) { SbxBase::SetError( SbxERR_OVERFLOW ); @@ -167,15 +164,11 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxSALINT64: - nRes = (float) *p->pnInt64; break; - case SbxBYREF | SbxSALUINT64: - nRes = (float) ImpSalUInt64ToDouble( *p->puInt64 ); break; case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; + aTmp.nInt64 = *p->pnInt64; goto ref; + case SbxBYREF | SbxSALUINT64: + aTmp.uInt64 = *p->puInt64; goto ref; ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -206,11 +199,7 @@ start: case SbxERROR: case SbxUSHORT: aTmp.pUShort = &p->nUShort; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: @@ -271,7 +260,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -282,7 +271,7 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -293,10 +282,10 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: { - INT32 i; + sal_Int32 i; if( n > SbxMAXLNG ) { SbxBase::SetError( SbxERR_OVERFLOW ); i = SbxMAXLNG; @@ -307,13 +296,13 @@ start: } else { - i = sal::static_int_cast< INT32 >(n); + i = sal::static_int_cast< sal_Int32 >(n); } *p->pLong = i; break; } case SbxBYREF | SbxULONG: { - UINT32 i; + sal_uInt32 i; if( n > SbxMAXULNG ) { SbxBase::SetError( SbxERR_OVERFLOW ); i = SbxMAXULNG; @@ -324,7 +313,7 @@ start: } else { - i = sal::static_int_cast< UINT32 >(n); + i = sal::static_int_cast< sal_uInt32 >(n); } *p->pULong = i; break; } @@ -334,9 +323,9 @@ start: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; case SbxBYREF | SbxSALINT64: - *p->pnInt64 = ImpDoubleToSalInt64( (double) n ); break; + *p->pnInt64 = (sal_Int64)n; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = ImpDoubleToSalUInt64( (double) n ); break; + *p->puInt64 = (sal_uInt64)n; break; case SbxBYREF | SbxCURRENCY: double d; if( n > SbxMAXCURR ) @@ -351,7 +340,7 @@ start: { d = n; } - *p->pLong64 = ImpDoubleToCurrency( n ); break; + *p->pnInt64 = ImpDoubleToCurrency( d ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxstr.cxx b/basic/source/sbx/sbxstr.cxx index ebfc7a01c2..4ac819c717 100644 --- a/basic/source/sbx/sbxstr.cxx +++ b/basic/source/sbx/sbxstr.cxx @@ -35,8 +35,8 @@ #include "runtime.hxx" #include <rtl/ustrbuf.hxx> -// Die Konversion eines Items auf String wird ueber die Put-Methoden -// der einzelnen Datentypen abgewickelt, um doppelten Code zu vermeiden. +// The conversion of an item onto String was handled via the Put-Methods +// of the several data types to avoid double code. ::rtl::OUString ImpGetString( const SbxValues* p ) { @@ -69,7 +69,7 @@ case SbxDOUBLE: ImpPutDouble( &aTmp, p->nDouble ); break; case SbxCURRENCY: - ImpPutCurrency( &aTmp, p->nLong64 ); break; + ImpPutCurrency( &aTmp, p->nInt64 ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpPutDecimal( &aTmp, p->pDecimal ); break; @@ -101,7 +101,7 @@ break; } case SbxERROR: - // Hier wird der String "Error n" erzeugt + // Here will be created the String "Error n" aRes = SbxRes( STRING_ERRORMSG ); aRes += ::rtl::OUString( p->nUShort ); break; case SbxDATE: @@ -127,7 +127,7 @@ case SbxBYREF | SbxDOUBLE: ImpPutDouble( &aTmp, *p->pDouble ); break; case SbxBYREF | SbxCURRENCY: - ImpPutCurrency( &aTmp, *p->pLong64 ); break; + ImpPutCurrency( &aTmp, *p->pnInt64 ); break; case SbxBYREF | SbxSALINT64: ImpPutInt64( &aTmp, *p->pnInt64 ); break; case SbxBYREF | SbxSALUINT64: @@ -138,19 +138,19 @@ return aRes; } -// AB 10.4.97, neue Funktion fuer SbxValue::GetCoreString() +// From 1997-04-10, new function for SbxValue::GetCoreString() ::rtl::OUString ImpGetCoreString( const SbxValues* p ) { - // Vorerst nur fuer double + // For now only for double if( ( p->eType & (~SbxBYREF) ) == SbxDOUBLE ) { SbxValues aTmp; XubString aRes; aTmp.eType = SbxSTRING; if( p->eType == SbxDOUBLE ) - ImpPutDouble( &aTmp, p->nDouble, /*bCoreString=*/TRUE ); + ImpPutDouble( &aTmp, p->nDouble, sal_True ); // true = bCoreString else - ImpPutDouble( &aTmp, *p->pDouble, /*bCoreString=*/TRUE ); + ImpPutDouble( &aTmp, *p->pDouble, sal_True ); // true = bCoreString return aRes; } else @@ -162,7 +162,7 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) SbxValues aTmp; aTmp.eType = SbxSTRING; ::rtl::OUString* pTmp = NULL; - // Sicherheitshalber, falls ein NULL-Ptr kommt + // as a precaution, if a NULL-Ptr appears if( !n ) n = pTmp = new ::rtl::OUString; aTmp.pOUString = (::rtl::OUString*)n; @@ -188,8 +188,8 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) p->nDouble = ImpGetDate( &aTmp ); break; case SbxDOUBLE: p->nDouble = ImpGetDouble( &aTmp ); break; - case SbxULONG64: - p->nLong64 = ImpGetCurrency( &aTmp ); break; + case SbxCURRENCY: + p->nInt64 = ImpGetCurrency( &aTmp ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: releaseDecimalPtr( p->pDecimal ); @@ -228,7 +228,7 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) case SbxBYREF | SbxINTEGER: *p->pInteger = ImpGetInteger( p ); break; case SbxBYREF | SbxBOOL: - *p->pUShort = sal::static_int_cast< UINT16 >( ImpGetBool( p ) ); + *p->pUShort = sal::static_int_cast< sal_uInt16 >( ImpGetBool( p ) ); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: @@ -244,13 +244,18 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) case SbxBYREF | SbxDOUBLE: *p->pDouble = ImpGetDouble( p ); break; case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpGetCurrency( p ); break; + *p->pnInt64 = ImpGetCurrency( p ); break; + case SbxBYREF | SbxSALINT64: + *p->pnInt64 = ImpGetInt64( p ); break; + case SbxBYREF | SbxSALUINT64: + *p->puInt64 = ImpGetUInt64( p ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } delete pTmp; } + // Convert string to an array of bytes, preserving unicode (2bytes per character) SbxArray* StringToByteArray(const ::rtl::OUString& rStr) { @@ -270,10 +275,10 @@ SbxArray* StringToByteArray(const ::rtl::OUString& rStr) pArray->unoAddDim( 0, -1 ); } - for( USHORT i=0; i< nArraySize; i++) + for( sal_uInt16 i=0; i< nArraySize; i++) { SbxVariable* pNew = new SbxVariable( SbxBYTE ); - BYTE aByte = static_cast< BYTE >( i%2 ? ((*pSrc) >> 8) & 0xff : (*pSrc) & 0xff ); + sal_uInt8 aByte = static_cast< sal_uInt8 >( i%2 ? ((*pSrc) >> 8) & 0xff : (*pSrc) & 0xff ); pNew->PutByte( aByte ); pNew->SetFlag( SBX_WRITE ); pArray->Put( pNew, i ); @@ -286,10 +291,10 @@ SbxArray* StringToByteArray(const ::rtl::OUString& rStr) // Convert an array of bytes to string (2bytes per character) ::rtl::OUString ByteArrayToString(SbxArray* pArr) { - USHORT nCount = pArr->Count(); + sal_uInt16 nCount = pArr->Count(); ::rtl::OUStringBuffer aStrBuf; sal_Unicode aChar = 0; - for( USHORT i = 0 ; i < nCount ; i++ ) + for( sal_uInt16 i = 0 ; i < nCount ; i++ ) { sal_Unicode aTempChar = pArr->Get(i)->GetByte(); if( i%2 ) @@ -312,4 +317,5 @@ SbxArray* StringToByteArray(const ::rtl::OUString& rStr) return aStrBuf.makeStringAndClear(); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxuint.cxx b/basic/source/sbx/sbxuint.cxx index d5123b814a..4a368c0ec6 100644 --- a/basic/source/sbx/sbxuint.cxx +++ b/basic/source/sbx/sbxuint.cxx @@ -32,10 +32,10 @@ #include <basic/sbx.hxx> #include "sbxconv.hxx" -UINT16 ImpGetUShort( const SbxValues* p ) +sal_uInt16 ImpGetUShort( const SbxValues* p ) { SbxValues aTmp; - UINT16 nRes; + sal_uInt16 nRes; start: switch( +p->eType ) { @@ -71,7 +71,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT16) p->nLong; + nRes = (sal_uInt16) p->nLong; break; case SbxULONG: if( p->nULong > SbxMAXUINT ) @@ -79,7 +79,19 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXUINT; } else - nRes = (UINT16) p->nULong; + nRes = (sal_uInt16) p->nULong; + break; + case SbxCURRENCY: + if( p->nInt64 / CURRENCY_FACTOR > SbxMAXUINT ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXUINT; + } + else if( p->nInt64 < 0 ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; + } + else + nRes = (sal_uInt16) (p->nInt64 / CURRENCY_FACTOR); break; case SbxSALINT64: if( p->nInt64 > SbxMAXUINT ) @@ -91,7 +103,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT16) p->nInt64; + nRes = (sal_uInt16) p->nInt64; break; case SbxSALUINT64: if( p->uInt64 > SbxMAXUINT ) @@ -99,7 +111,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXUINT; } else - nRes = (UINT16) p->uInt64; + nRes = (sal_uInt16) p->uInt64; break; case SbxSINGLE: if( p->nSingle > SbxMAXUINT ) @@ -111,24 +123,15 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT16) ( p->nSingle + 0.5 ); + nRes = (sal_uInt16) ( p->nSingle + 0.5 ); break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -146,7 +149,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT16) ( dVal + 0.5 ); + nRes = (sal_uInt16) ( dVal + 0.5 ); break; } case SbxBYREF | SbxSTRING: @@ -169,7 +172,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT16) ( d + 0.5 ); + nRes = (sal_uInt16) ( d + 0.5 ); } break; case SbxOBJECT: @@ -190,7 +193,7 @@ start: case SbxBYREF | SbxUSHORT: nRes = *p->pUShort; break; - // ab hier wird getestet + // from here on will be tested case SbxBYREF | SbxCHAR: aTmp.nChar = *p->pChar; goto ref; case SbxBYREF | SbxINTEGER: @@ -205,11 +208,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -224,7 +223,7 @@ start: return nRes; } -void ImpPutUShort( SbxValues* p, UINT16 n ) +void ImpPutUShort( SbxValues* p, sal_uInt16 n ) { SbxValues aTmp; @@ -243,22 +242,18 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxSALUINT64: p->uInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setUInt( n ); break; - // Tests ab hier + // from here on tests case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -294,14 +289,14 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXBYTE; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXINT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: *p->pUShort = n; break; @@ -314,16 +309,12 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxulng.cxx b/basic/source/sbx/sbxulng.cxx index 13c91f8e52..d1d876324d 100644 --- a/basic/source/sbx/sbxulng.cxx +++ b/basic/source/sbx/sbxulng.cxx @@ -32,10 +32,10 @@ #include <basic/sbx.hxx> #include "sbxconv.hxx" -UINT32 ImpGetULong( const SbxValues* p ) +sal_uInt32 ImpGetULong( const SbxValues* p ) { SbxValues aTmp; - UINT32 nRes; + sal_uInt32 nRes; start: switch( +p->eType ) { @@ -81,12 +81,10 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT32) ( p->nSingle + 0.5 ); + nRes = (sal_uInt32) ( p->nSingle + 0.5 ); break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: case SbxSALINT64: case SbxSALUINT64: case SbxCURRENCY: @@ -95,11 +93,7 @@ start: { double dVal; if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); + dVal = ImpCurrencyToDouble( p->nInt64 ); else if( p->eType == SbxSALINT64 ) dVal = static_cast< double >(p->nInt64); else if( p->eType == SbxSALUINT64 ) @@ -122,7 +116,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT32) ( dVal + 0.5 ); + nRes = (sal_uInt32) ( dVal + 0.5 ); break; } case SbxBYREF | SbxSTRING: @@ -145,7 +139,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (UINT32) ( d + 0.5 ); + nRes = (sal_uInt32) ( d + 0.5 ); } break; case SbxOBJECT: @@ -168,7 +162,7 @@ start: case SbxBYREF | SbxULONG: nRes = *p->pULong; break; - // Tests ab hier + // from here on tests case SbxBYREF | SbxCHAR: aTmp.nChar = *p->pChar; goto ref; case SbxBYREF | SbxINTEGER: @@ -181,15 +175,11 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: aTmp.uInt64 = *p->puInt64; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -200,7 +190,7 @@ start: return nRes; } -void ImpPutULong( SbxValues* p, UINT32 n ) +void ImpPutULong( SbxValues* p, sal_uInt32 n ) { SbxValues aTmp; start: @@ -213,8 +203,9 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: case SbxSALINT64: - p->nInt64 = n; break; + aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: p->uInt64 = n; break; case SbxDECIMAL: @@ -222,7 +213,7 @@ start: ImpCreateDecimal( p )->setULong( n ); break; - // Tests ab hier + // from here on tests case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxUINT: @@ -235,11 +226,6 @@ start: case SbxERROR: case SbxUSHORT: aTmp.pUShort = &p->nUShort; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; direct: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; @@ -271,27 +257,27 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXBYTE; } - *p->pByte = (BYTE) n; break; + *p->pByte = (sal_uInt8) n; break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXINT; } - *p->pInteger = (INT16) n; break; + *p->pInteger = (sal_Int16) n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXUINT; } - *p->pUShort = (UINT16) n; break; + *p->pUShort = (sal_uInt16) n; break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXLNG; } - *p->pLong = (INT32) n; break; + *p->pLong = (sal_Int32) n; break; case SbxBYREF | SbxULONG: *p->pULong = n; break; case SbxBYREF | SbxSINGLE: @@ -299,21 +285,12 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxCURRENCY: - double d; - if( n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); d = SbxMAXCURR; - } - else - { - d = n; - } - *p->pLong64 = ImpDoubleToCurrency( n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); diff --git a/basic/source/sbx/sbxvals.cxx b/basic/source/sbx/sbxvals.cxx index 4f08b3ba5f..443089a123 100644 --- a/basic/source/sbx/sbxvals.cxx +++ b/basic/source/sbx/sbxvals.cxx @@ -1,4 +1,3 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,21 +48,21 @@ SbxValues::SbxValues( const BigInt &rBig ) : eType(SbxCURRENCY) #pragma warning(disable: 4273) #endif -BOOL BigInt::INT64( SbxINT64 *p ) const +sal_Bool BigInt::INT64( SbxINT64 *p ) const { if( bIsBig ) { if( nLen > 4 || (nNum[3] & 0x8000) ) - return FALSE; + return sal_False; - p->nLow = ((UINT32)nNum[1] << 16) | (UINT32)nNum[0]; - p->nHigh = ((UINT32)nNum[3] << 16) | (UINT32)nNum[2]; + p->nLow = ((sal_uInt32)nNum[1] << 16) | (sal_uInt32)nNum[0]; + p->nHigh = ((sal_uInt32)nNum[3] << 16) | (sal_uInt32)nNum[2]; if( bIsNeg ) p->CHS(); } else - p->Set( (INT32)nVal ); + p->Set( (sal_Int32)nVal ); - return TRUE; + return sal_True; } BigInt::BigInt( const SbxINT64 &r ) @@ -73,28 +72,28 @@ BigInt::BigInt( const SbxINT64 &r ) *this = r.nHigh; if( r.nHigh ) *this *= a10000; - *this += (USHORT)(r.nLow >> 16); + *this += (sal_uInt16)(r.nLow >> 16); *this *= a10000; - *this += (USHORT)r.nLow; + *this += (sal_uInt16)r.nLow; } -BOOL BigInt::UINT64( SbxUINT64 *p ) const +sal_Bool BigInt::UINT64( SbxUINT64 *p ) const { if( bIsBig ) { if( bIsNeg || nLen > 4 ) - return FALSE; + return sal_False; - p->nLow = ((UINT32)nNum[1] << 16) | (UINT32)nNum[0]; - p->nHigh = ((UINT32)nNum[3] << 16) | (UINT32)nNum[2]; + p->nLow = ((sal_uInt32)nNum[1] << 16) | (sal_uInt32)nNum[0]; + p->nHigh = ((sal_uInt32)nNum[3] << 16) | (sal_uInt32)nNum[2]; } else { if( nVal < 0 ) - return FALSE; + return sal_False; - p->Set( (UINT32)nVal ); + p->Set( (sal_uInt32)nVal ); } - return TRUE; + return sal_True; } BigInt::BigInt( const SbxUINT64 &r ) @@ -104,9 +103,7 @@ BigInt::BigInt( const SbxUINT64 &r ) *this = BigInt(r.nHigh); if( r.nHigh ) *this *= a10000; - *this += (USHORT)(r.nLow >> 16); + *this += (sal_uInt16)(r.nLow >> 16); *this *= a10000; - *this += (USHORT)r.nLow; + *this += (sal_uInt16)r.nLow; } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 2c22aa246f..e21234ccac 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -29,154 +29,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#define _TLBIGINT_INT64 -#include <tools/bigint.hxx> +#include <math.h> #include <tools/stream.hxx> #include <basic/sbx.hxx> #include "sbxconv.hxx" -#include <math.h> #include "runtime.hxx" TYPEINIT1(SbxValue,SbxBase) -/////////////////////////// SbxINT64 ///////////////////////////////////// -SbxINT64 &SbxINT64::operator -= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b -= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator += ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b += BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator *= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b *= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator %= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b %= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator /= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b /= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator &= ( const SbxINT64 &r ) -{ - nHigh &= r.nHigh; - nLow &= r.nLow; - return *this; -} -SbxINT64 &SbxINT64::operator |= ( const SbxINT64 &r ) -{ - nHigh |= r.nHigh; - nLow |= r.nLow; - return *this; -} -SbxINT64 &SbxINT64::operator ^= ( const SbxINT64 &r ) -{ - nHigh ^= r.nHigh; - nLow ^= r.nLow; - return *this; -} - -SbxINT64 operator - ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a -= r; - return a; -} -SbxINT64 operator + ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a += r; - return a; -} -SbxINT64 operator / ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a /= r; - return a; -} -SbxINT64 operator % ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a %= r; - return a; -} -SbxINT64 operator * ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a *= r; - return a; -} -SbxINT64 operator & ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a; - a.nHigh = r.nHigh & l.nHigh; - a.nLow = r.nLow & l.nLow; - return a; -} -SbxINT64 operator | ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a; - a.nHigh = r.nHigh | l.nHigh; - a.nLow = r.nLow | l.nLow; - return a; -} -SbxINT64 operator ^ ( const SbxINT64 &r, const SbxINT64 &l ) -{ - SbxINT64 a; - a.nHigh = r.nHigh ^ l.nHigh; - a.nLow = r.nLow ^ l.nLow; - return a; -} - -SbxINT64 operator - ( const SbxINT64 &r ) -{ - SbxINT64 a( r ); - a.CHS(); - return a; -} -SbxINT64 operator ~ ( const SbxINT64 &r ) -{ - SbxINT64 a; - a.nHigh = ~r.nHigh; - a.nLow = ~r.nLow; - return a; -} - -SbxUINT64 &SbxUINT64::operator %= ( const SbxUINT64 &r ) -{ - BigInt b( *this ); - b %= BigInt( r ); - b.UINT64( this ); - return *this; -} -SbxUINT64 &SbxUINT64::operator /= ( const SbxUINT64 &r ) -{ - BigInt b( *this ); - b /= BigInt( r ); - b.UINT64( this ); - return *this; -} -/////////////////////////// Error processing ///////////////////////////// +///////////////////////////// error handling ////////////////////////////// +// bring back ?? was ever in ?? currently ifdef out ? #ifdef _USED // STILL Reverse ENGINEERING! @@ -198,13 +62,12 @@ int matherr( struct _exception* p ) #endif default: SbxBase::SetError( SbxERR_NOTIMP ); break; } - return TRUE; + return sal_True; } #endif #endif // _USED - ///////////////////////////// constructors ////////////////////////////// SbxValue::SbxValue() : SbxBase() @@ -224,21 +87,21 @@ SbxValue::SbxValue( SbxDataType t, void* p ) : SbxBase() if( p ) switch( t & 0x0FFF ) { - case SbxINTEGER: n |= SbxBYREF; aData.pInteger = (INT16*) p; break; - case SbxULONG64: n |= SbxBYREF; aData.pULong64 = (SbxUINT64*) p; break; - case SbxLONG64: - case SbxCURRENCY: n |= SbxBYREF; aData.pLong64 = (SbxINT64*) p; break; - case SbxLONG: n |= SbxBYREF; aData.pLong = (INT32*) p; break; + case SbxINTEGER: n |= SbxBYREF; aData.pInteger = (sal_Int16*) p; break; + case SbxSALUINT64: n |= SbxBYREF; aData.puInt64 = (sal_uInt64*) p; break; + case SbxSALINT64: + case SbxCURRENCY: n |= SbxBYREF; aData.pnInt64 = (sal_Int64*) p; break; + case SbxLONG: n |= SbxBYREF; aData.pLong = (sal_Int32*) p; break; case SbxSINGLE: n |= SbxBYREF; aData.pSingle = (float*) p; break; case SbxDATE: case SbxDOUBLE: n |= SbxBYREF; aData.pDouble = (double*) p; break; case SbxSTRING: n |= SbxBYREF; aData.pOUString = (::rtl::OUString*) p; break; case SbxERROR: case SbxUSHORT: - case SbxBOOL: n |= SbxBYREF; aData.pUShort = (UINT16*) p; break; - case SbxULONG: n |= SbxBYREF; aData.pULong = (UINT32*) p; break; - case SbxCHAR: n |= SbxBYREF; aData.pChar = (xub_Unicode*) p; break; - case SbxBYTE: n |= SbxBYREF; aData.pByte = (BYTE*) p; break; + case SbxBOOL: n |= SbxBYREF; aData.pUShort = (sal_uInt16*) p; break; + case SbxULONG: n |= SbxBYREF; aData.pULong = (sal_uInt32*) p; break; + case SbxCHAR: n |= SbxBYREF; aData.pChar = (sal_Unicode*) p; break; + case SbxBYTE: n |= SbxBYREF; aData.pByte = (sal_uInt8*) p; break; case SbxINT: n |= SbxBYREF; aData.pInt = (int*) p; break; case SbxOBJECT: aData.pObj = (SbxBase*) p; @@ -359,8 +222,8 @@ SbxValue::~SbxValue() { HACK(nicht bei Parent-Prop - sonst CyclicRef) SbxVariable *pThisVar = PTR_CAST(SbxVariable, this); - BOOL bParentProp = pThisVar && 5345 == - ( (INT16) ( pThisVar->GetUserData() & 0xFFFF ) ); + sal_Bool bParentProp = pThisVar && 5345 == + ( (sal_Int16) ( pThisVar->GetUserData() & 0xFFFF ) ); if ( !bParentProp ) aData.pObj->ReleaseRef(); } @@ -390,8 +253,8 @@ void SbxValue::Clear() { HACK(nicht bei Parent-Prop - sonst CyclicRef) SbxVariable *pThisVar = PTR_CAST(SbxVariable, this); - BOOL bParentProp = pThisVar && 5345 == - ( (INT16) ( pThisVar->GetUserData() & 0xFFFF ) ); + sal_Bool bParentProp = pThisVar && 5345 == + ( (sal_Int16) ( pThisVar->GetUserData() & 0xFFFF ) ); if ( !bParentProp ) aData.pObj->ReleaseRef(); } @@ -416,7 +279,7 @@ void SbxValue::Clear() // Dummy -void SbxValue::Broadcast( ULONG ) +void SbxValue::Broadcast( sal_uIntPtr ) {} //////////////////////////// Readout data ////////////////////////////// @@ -428,11 +291,13 @@ void SbxValue::Broadcast( ULONG ) SbxValue* SbxValue::TheRealValue() const { - return TheRealValue( TRUE ); + return TheRealValue( sal_True ); } // #55226 ship additional information -SbxValue* SbxValue::TheRealValue( BOOL bObjInObjError ) const +bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal ); // sbunoobj.cxx + +SbxValue* SbxValue::TheRealValue( sal_Bool bObjInObjError ) const { SbxValue* p = (SbxValue*) this; for( ;; ) @@ -449,7 +314,7 @@ SbxValue* SbxValue::TheRealValue( BOOL bObjInObjError ) const // If this is an object and contains itself, // we cannot access on it - // #55226# The old condition to set an error + // The old condition to set an error // is not correct, because e.g. a regular variant variable with an object // could be affected thereof, if another value should be assigned. // Therefore with flag. @@ -457,15 +322,15 @@ SbxValue* SbxValue::TheRealValue( BOOL bObjInObjError ) const ((SbxValue*) pObj)->aData.eType == SbxOBJECT && ((SbxValue*) pObj)->aData.pObj == pObj ) { - SetError( SbxERR_BAD_PROP_VALUE ); - p = NULL; + bool bSuccess = handleToStringForCOMObjects( pObj, p ); + if( !bSuccess ) + { + SetError( SbxERR_BAD_PROP_VALUE ); + p = NULL; + } } else if( pDflt ) p = pDflt; - /* ALT: - else - p = pDflt ? pDflt : (SbxVariable*) pObj; - */ break; } // Did we have an array? @@ -501,9 +366,9 @@ SbxValue* SbxValue::TheRealValue( BOOL bObjInObjError ) const return p; } -BOOL SbxValue::Get( SbxValues& rRes ) const +sal_Bool SbxValue::Get( SbxValues& rRes ) const { - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; SbxError eOld = GetError(); if( eOld != SbxERR_OK ) ResetError(); @@ -534,11 +399,11 @@ BOOL SbxValue::Get( SbxValues& rRes ) const case SbxSALUINT64: rRes.uInt64 = ImpGetUInt64( &p->aData ); break; case SbxSINGLE: rRes.nSingle = ImpGetSingle( &p->aData ); break; case SbxDOUBLE: rRes.nDouble = ImpGetDouble( &p->aData ); break; - case SbxCURRENCY:rRes.nLong64 = ImpGetCurrency( &p->aData ); break; + case SbxCURRENCY:rRes.nInt64 = ImpGetCurrency( &p->aData ); break; case SbxDECIMAL: rRes.pDecimal = ImpGetDecimal( &p->aData ); break; case SbxDATE: rRes.nDouble = ImpGetDate( &p->aData ); break; case SbxBOOL: - rRes.nUShort = sal::static_int_cast< UINT16 >( + rRes.nUShort = sal::static_int_cast< sal_uInt16 >( ImpGetBool( &p->aData ) ); break; case SbxCHAR: rRes.nChar = ImpGetChar( &p->aData ); break; @@ -593,18 +458,18 @@ BOOL SbxValue::Get( SbxValues& rRes ) const } if( !IsError() ) { - bRes = TRUE; + bRes = sal_True; if( eOld != SbxERR_OK ) SetError( eOld ); } return bRes; } -BOOL SbxValue::GetNoBroadcast( SbxValues& rRes ) +sal_Bool SbxValue::GetNoBroadcast( SbxValues& rRes ) { - USHORT nFlags_ = GetFlags(); + sal_uInt16 nFlags_ = GetFlags(); SetFlag( SBX_NO_BROADCAST ); - BOOL bRes = Get( rRes ); + sal_Bool bRes = Get( rRes ); SetFlags( nFlags_ ); return bRes; } @@ -644,7 +509,7 @@ const XubString& SbxValue::GetCoreString() const return aResult; } -BOOL SbxValue::HasObject() const +sal_Bool SbxValue::HasObject() const { ErrCode eErr = GetError(); SbxValues aRes; @@ -654,43 +519,41 @@ BOOL SbxValue::HasObject() const return 0 != aRes.pObj; } -BOOL SbxValue::GetBool() const +sal_Bool SbxValue::GetBool() const { SbxValues aRes; aRes.eType = SbxBOOL; Get( aRes ); - return BOOL( aRes.nUShort != 0 ); + return sal_Bool( aRes.nUShort != 0 ); } #define GET( g, e, t, m ) \ t SbxValue::g() const { SbxValues aRes(e); Get( aRes ); return aRes.m; } -GET( GetByte, SbxBYTE, BYTE, nByte ) -GET( GetChar, SbxCHAR, xub_Unicode, nChar ) -GET( GetCurrency, SbxCURRENCY, SbxINT64, nLong64 ) -GET( GetDate, SbxDATE, double, nDouble ) -GET( GetData, SbxDATAOBJECT, void*, pData ) -GET( GetDouble, SbxDOUBLE, double, nDouble ) -GET( GetErr, SbxERROR, UINT16, nUShort ) -GET( GetInt, SbxINT, int, nInt ) -GET( GetInteger, SbxINTEGER, INT16, nInteger ) -GET( GetLong, SbxLONG, INT32, nLong ) -GET( GetLong64, SbxLONG64, SbxINT64, nLong64 ) -GET( GetObject, SbxOBJECT, SbxBase*, pObj ) -GET( GetSingle, SbxSINGLE, float, nSingle ) -GET( GetULong, SbxULONG, UINT32, nULong ) -GET( GetULong64, SbxULONG64, SbxUINT64, nULong64 ) -GET( GetUShort, SbxUSHORT, UINT16, nUShort ) -GET( GetInt64, SbxSALINT64, sal_Int64, nInt64 ) -GET( GetUInt64, SbxSALUINT64, sal_uInt64, uInt64 ) -GET( GetDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) +GET( GetByte, SbxBYTE, sal_uInt8, nByte ) +GET( GetChar, SbxCHAR, xub_Unicode, nChar ) +GET( GetCurrency, SbxCURRENCY, sal_Int64, nInt64 ) +GET( GetDate, SbxDATE, double, nDouble ) +GET( GetData, SbxDATAOBJECT, void*, pData ) +GET( GetDouble, SbxDOUBLE, double, nDouble ) +GET( GetErr, SbxERROR, sal_uInt16, nUShort ) +GET( GetInt, SbxINT, int, nInt ) +GET( GetInteger, SbxINTEGER, sal_Int16, nInteger ) +GET( GetLong, SbxLONG, sal_Int32, nLong ) +GET( GetObject, SbxOBJECT, SbxBase*, pObj ) +GET( GetSingle, SbxSINGLE, float, nSingle ) +GET( GetULong, SbxULONG, sal_uInt32, nULong ) +GET( GetUShort, SbxUSHORT, sal_uInt16, nUShort ) +GET( GetInt64, SbxSALINT64, sal_Int64, nInt64 ) +GET( GetUInt64, SbxSALUINT64, sal_uInt64, uInt64 ) +GET( GetDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) //////////////////////////// Write data ///////////////////////////// -BOOL SbxValue::Put( const SbxValues& rVal ) +sal_Bool SbxValue::Put( const SbxValues& rVal ) { - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; SbxError eOld = GetError(); if( eOld != SbxERR_OK ) ResetError(); @@ -704,7 +567,7 @@ BOOL SbxValue::Put( const SbxValues& rVal ) // the real values SbxValue* p = this; if( rVal.eType != SbxOBJECT ) - p = TheRealValue( FALSE ); // #55226 Don't allow an error here + p = TheRealValue( sal_False ); // Don't allow an error here if( p ) { if( !p->CanWrite() ) @@ -721,7 +584,7 @@ BOOL SbxValue::Put( const SbxValues& rVal ) case SbxSALUINT64: ImpPutUInt64( &p->aData, rVal.uInt64 ); break; case SbxSINGLE: ImpPutSingle( &p->aData, rVal.nSingle ); break; case SbxDOUBLE: ImpPutDouble( &p->aData, rVal.nDouble ); break; - case SbxCURRENCY: ImpPutCurrency( &p->aData, rVal.nLong64 ); break; + case SbxCURRENCY: ImpPutCurrency( &p->aData, rVal.nInt64 ); break; case SbxDECIMAL: ImpPutDecimal( &p->aData, rVal.pDecimal ); break; case SbxDATE: ImpPutDate( &p->aData, rVal.nDouble ); break; case SbxBOOL: ImpPutBool( &p->aData, rVal.nInteger ); break; @@ -733,16 +596,16 @@ BOOL SbxValue::Put( const SbxValues& rVal ) case SbxSTRING: ImpPutString( &p->aData, rVal.pOUString ); break; case SbxINT: #if SAL_TYPES_SIZEOFINT == 2 - ImpPutInteger( &p->aData, (INT16) rVal.nInt ); + ImpPutInteger( &p->aData, (sal_Int16) rVal.nInt ); #else - ImpPutLong( &p->aData, (INT32) rVal.nInt ); + ImpPutLong( &p->aData, (sal_Int32) rVal.nInt ); #endif break; case SbxUINT: #if SAL_TYPES_SIZEOFINT == 2 - ImpPutUShort( &p->aData, (UINT16) rVal.nUInt ); + ImpPutUShort( &p->aData, (sal_uInt16) rVal.nUInt ); #else - ImpPutULong( &p->aData, (UINT32) rVal.nUInt ); + ImpPutULong( &p->aData, (sal_uInt32) rVal.nUInt ); #endif break; case SbxOBJECT: @@ -763,12 +626,12 @@ BOOL SbxValue::Put( const SbxValues& rVal ) { if ( p != this ) { - DBG_ERROR( "TheRealValue" ); + OSL_FAIL( "TheRealValue" ); } HACK(nicht bei Parent-Prop - sonst CyclicRef) SbxVariable *pThisVar = PTR_CAST(SbxVariable, this); - BOOL bParentProp = pThisVar && 5345 == - ( (INT16) ( pThisVar->GetUserData() & 0xFFFF ) ); + sal_Bool bParentProp = pThisVar && 5345 == + ( (sal_Int16) ( pThisVar->GetUserData() & 0xFFFF ) ); if ( !bParentProp ) p->aData.pObj->AddRef(); } @@ -788,11 +651,11 @@ BOOL SbxValue::Put( const SbxValues& rVal ) } if( !IsError() ) { - p->SetModified( TRUE ); + p->SetModified( sal_True ); p->Broadcast( SBX_HINT_DATACHANGED ); if( eOld != SbxERR_OK ) SetError( eOld ); - bRes = TRUE; + bRes = sal_True; } } } @@ -806,7 +669,7 @@ BOOL SbxValue::Put( const SbxValues& rVal ) // if Float were declared with ',' as the decimal seperator or BOOl // explicit with "TRUE" or "FALSE". // Implementation in ImpConvStringExt (SBXSCAN.CXX) -BOOL SbxValue::PutStringExt( const ::rtl::OUString& r ) +sal_Bool SbxValue::PutStringExt( const ::rtl::OUString& r ) { // Copy; if it is Unicode convert it immediately ::rtl::OUString aStr( r ); @@ -821,7 +684,7 @@ BOOL SbxValue::PutStringExt( const ::rtl::OUString& r ) // Only if really something was converted, take the copy, // elsewise take the original (Unicode remain) - BOOL bRet; + sal_Bool bRet; if( ImpConvStringExt( aStr, eTargetType ) ) aRes.pOUString = (::rtl::OUString*)&aStr; else @@ -829,7 +692,7 @@ BOOL SbxValue::PutStringExt( const ::rtl::OUString& r ) // #34939: Set a Fixed-Flag at Strings. which contain a number, and // if this has a Num-Type, so that the type will not be changed - USHORT nFlags_ = GetFlags(); + sal_uInt16 nFlags_ = GetFlags(); if( ( eTargetType >= SbxINTEGER && eTargetType <= SbxCURRENCY ) || ( eTargetType >= SbxCHAR && eTargetType <= SbxUINT ) || eTargetType == SbxBOOL ) @@ -841,7 +704,7 @@ BOOL SbxValue::PutStringExt( const ::rtl::OUString& r ) } Put( aRes ); - bRet = BOOL( !IsError() ); + bRet = sal_Bool( !IsError() ); // If it throwed an error with FIXED, set it back // (UI-Action should not cast an error, but only fail) @@ -852,104 +715,102 @@ BOOL SbxValue::PutStringExt( const ::rtl::OUString& r ) return bRet; } -BOOL SbxValue::PutString( const xub_Unicode* p ) +sal_Bool SbxValue::PutString( const xub_Unicode* p ) { ::rtl::OUString aVal( p ); SbxValues aRes; aRes.eType = SbxSTRING; aRes.pOUString = &aVal; Put( aRes ); - return BOOL( !IsError() ); + return sal_Bool( !IsError() ); } -BOOL SbxValue::PutBool( BOOL b ) +sal_Bool SbxValue::PutBool( sal_Bool b ) { SbxValues aRes; aRes.eType = SbxBOOL; - aRes.nUShort = sal::static_int_cast< UINT16 >(b ? SbxTRUE : SbxFALSE); + aRes.nUShort = sal::static_int_cast< sal_uInt16 >(b ? SbxTRUE : SbxFALSE); Put( aRes ); - return BOOL( !IsError() ); + return sal_Bool( !IsError() ); } -BOOL SbxValue::PutEmpty() +sal_Bool SbxValue::PutEmpty() { - BOOL bRet = SetType( SbxEMPTY ); - SetModified( TRUE ); + sal_Bool bRet = SetType( SbxEMPTY ); + SetModified( sal_True ); return bRet; } -BOOL SbxValue::PutNull() +sal_Bool SbxValue::PutNull() { - BOOL bRet = SetType( SbxNULL ); + sal_Bool bRet = SetType( SbxNULL ); if( bRet ) - SetModified( TRUE ); + SetModified( sal_True ); return bRet; } // Special decimal methods -BOOL SbxValue::PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ) +sal_Bool SbxValue::PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ) { SbxValue::Clear(); aData.pDecimal = new SbxDecimal( rAutomationDec ); aData.pDecimal->addRef(); aData.eType = SbxDECIMAL; - return TRUE; + return sal_True; } -BOOL SbxValue::fillAutomationDecimal +sal_Bool SbxValue::fillAutomationDecimal ( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ) { SbxDecimal* pDecimal = GetDecimal(); if( pDecimal != NULL ) { pDecimal->fillAutomationDecimal( rAutomationDec ); - return TRUE; + return sal_True; } - return FALSE; + return sal_False; } -BOOL SbxValue::PutpChar( const xub_Unicode* p ) +sal_Bool SbxValue::PutpChar( const xub_Unicode* p ) { ::rtl::OUString aVal( p ); SbxValues aRes; aRes.eType = SbxLPSTR; aRes.pOUString = &aVal; Put( aRes ); - return BOOL( !IsError() ); + return sal_Bool( !IsError() ); } -BOOL SbxValue::PutString( const ::rtl::OUString& r ) +sal_Bool SbxValue::PutString( const ::rtl::OUString& r ) { SbxValues aRes; aRes.eType = SbxSTRING; aRes.pOUString = (::rtl::OUString*) &r; Put( aRes ); - return BOOL( !IsError() ); + return sal_Bool( !IsError() ); } #define PUT( p, e, t, m ) \ -BOOL SbxValue::p( t n ) \ -{ SbxValues aRes(e); aRes.m = n; Put( aRes ); return BOOL( !IsError() ); } +sal_Bool SbxValue::p( t n ) \ +{ SbxValues aRes(e); aRes.m = n; Put( aRes ); return sal_Bool( !IsError() ); } -PUT( PutByte, SbxBYTE, BYTE, nByte ) -PUT( PutChar, SbxCHAR, xub_Unicode, nChar ) -PUT( PutCurrency, SbxCURRENCY, const SbxINT64&, nLong64 ) +PUT( PutByte, SbxBYTE, sal_uInt8, nByte ) +PUT( PutChar, SbxCHAR, sal_Unicode, nChar ) +PUT( PutCurrency, SbxCURRENCY, const sal_Int64&, nInt64 ) PUT( PutDate, SbxDATE, double, nDouble ) PUT( PutData, SbxDATAOBJECT, void*, pData ) PUT( PutDouble, SbxDOUBLE, double, nDouble ) -PUT( PutErr, SbxERROR, UINT16, nUShort ) +PUT( PutErr, SbxERROR, sal_uInt16, nUShort ) PUT( PutInt, SbxINT, int, nInt ) -PUT( PutInteger, SbxINTEGER, INT16, nInteger ) -PUT( PutLong, SbxLONG, INT32, nLong ) -PUT( PutLong64, SbxLONG64, const SbxINT64&, nLong64 ) +PUT( PutInteger, SbxINTEGER, sal_Int16, nInteger ) +PUT( PutLong, SbxLONG, sal_Int32, nLong ) PUT( PutObject, SbxOBJECT, SbxBase*, pObj ) PUT( PutSingle, SbxSINGLE, float, nSingle ) -PUT( PutULong, SbxULONG, UINT32, nULong ) -PUT( PutULong64, SbxULONG64, const SbxUINT64&, nULong64 ) -PUT( PutUShort, SbxUSHORT, UINT16, nUShort ) +PUT( PutULong, SbxULONG, sal_uInt32, nULong ) +PUT( PutUShort, SbxUSHORT, sal_uInt16, nUShort ) PUT( PutInt64, SbxSALINT64, sal_Int64, nInt64 ) PUT( PutUInt64, SbxSALUINT64, sal_uInt64, uInt64 ) PUT( PutDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) @@ -957,7 +818,7 @@ PUT( PutDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) ////////////////////////// Setting of the data type /////////////////////////// -BOOL SbxValue::IsFixed() const +sal_Bool SbxValue::IsFixed() const { return ( (GetFlags() & SBX_FIXED) | (aData.eType & SbxBYREF) ) != 0; } @@ -966,22 +827,22 @@ BOOL SbxValue::IsFixed() const // or if it contains a complete convertible String // #41692, implement it for RTL and Basic-Core seperably -BOOL SbxValue::IsNumeric() const +sal_Bool SbxValue::IsNumeric() const { - return ImpIsNumeric( /*bOnlyIntntl*/FALSE ); + return ImpIsNumeric( /*bOnlyIntntl*/sal_False ); } -BOOL SbxValue::IsNumericRTL() const +sal_Bool SbxValue::IsNumericRTL() const { - return ImpIsNumeric( /*bOnlyIntntl*/TRUE ); + return ImpIsNumeric( /*bOnlyIntntl*/sal_True ); } -BOOL SbxValue::ImpIsNumeric( BOOL bOnlyIntntl ) const +sal_Bool SbxValue::ImpIsNumeric( sal_Bool bOnlyIntntl ) const { if( !CanRead() ) { - SetError( SbxERR_PROP_WRITEONLY ); return FALSE; + SetError( SbxERR_PROP_WRITEONLY ); return sal_False; } // Test downcast!!! if( this->ISA(SbxVariable) ) @@ -994,14 +855,14 @@ BOOL SbxValue::ImpIsNumeric( BOOL bOnlyIntntl ) const ::rtl::OUString s( *aData.pOUString ); double n; SbxDataType t2; - USHORT nLen = 0; - if( ImpScan( s, n, t2, &nLen, /*bAllowIntntl*/FALSE, bOnlyIntntl ) == SbxERR_OK ) - return BOOL( nLen == s.getLength() ); + sal_uInt16 nLen = 0; + if( ImpScan( s, n, t2, &nLen, /*bAllowIntntl*/sal_False, bOnlyIntntl ) == SbxERR_OK ) + return sal_Bool( nLen == s.getLength() ); } - return FALSE; + return sal_False; } else - return BOOL( t == SbxEMPTY + return sal_Bool( t == SbxEMPTY || ( t >= SbxINTEGER && t <= SbxCURRENCY ) || ( t >= SbxCHAR && t <= SbxUINT ) ); } @@ -1021,19 +882,19 @@ SbxDataType SbxValue::GetFullType() const return aData.eType; } -BOOL SbxValue::SetType( SbxDataType t ) +sal_Bool SbxValue::SetType( SbxDataType t ) { DBG_ASSERT( !( t & 0xF000 ), "Setzen von BYREF|ARRAY verboten!" ); if( ( t == SbxEMPTY && aData.eType == SbxVOID ) || ( aData.eType == SbxEMPTY && t == SbxVOID ) ) - return TRUE; + return sal_True; if( ( t & 0x0FFF ) == SbxVARIANT ) { // Trial to set the data type to Variant ResetFlag( SBX_FIXED ); if( IsFixed() ) { - SetError( SbxERR_CONVERSION ); return FALSE; + SetError( SbxERR_CONVERSION ); return sal_False; } t = SbxEMPTY; } @@ -1041,7 +902,7 @@ BOOL SbxValue::SetType( SbxDataType t ) { if( !CanWrite() || IsFixed() ) { - SetError( SbxERR_CONVERSION ); return FALSE; + SetError( SbxERR_CONVERSION ); return sal_False; } else { @@ -1056,12 +917,12 @@ BOOL SbxValue::SetType( SbxDataType t ) { HACK(nicht bei Parent-Prop - sonst CyclicRef) SbxVariable *pThisVar = PTR_CAST(SbxVariable, this); - UINT16 nSlotId = pThisVar - ? ( (INT16) ( pThisVar->GetUserData() & 0xFFFF ) ) + sal_uInt16 nSlotId = pThisVar + ? ( (sal_Int16) ( pThisVar->GetUserData() & 0xFFFF ) ) : 0; DBG_ASSERT( nSlotId != 5345 || pThisVar->GetName() == UniString::CreateFromAscii( "Parent" ), "SID_PARENTOBJECT heisst nicht 'Parent'" ); - BOOL bParentProp = 5345 == nSlotId; + sal_Bool bParentProp = 5345 == nSlotId; if ( !bParentProp ) aData.pObj->ReleaseRef(); } @@ -1073,31 +934,31 @@ BOOL SbxValue::SetType( SbxDataType t ) aData.eType = t; } } - return TRUE; + return sal_True; } -BOOL SbxValue::Convert( SbxDataType eTo ) +sal_Bool SbxValue::Convert( SbxDataType eTo ) { eTo = SbxDataType( eTo & 0x0FFF ); if( ( aData.eType & 0x0FFF ) == eTo ) - return TRUE; + return sal_True; if( !CanWrite() ) - return FALSE; + return sal_False; if( eTo == SbxVARIANT ) { // Trial to set the data type to Variant ResetFlag( SBX_FIXED ); if( IsFixed() ) { - SetError( SbxERR_CONVERSION ); return FALSE; + SetError( SbxERR_CONVERSION ); return sal_False; } else - return TRUE; + return sal_True; } // Converting from zero doesn't work. Once zero, always zero! if( aData.eType == SbxNULL ) { - SetError( SbxERR_CONVERSION ); return FALSE; + SetError( SbxERR_CONVERSION ); return sal_False; } // Conversion of the data: @@ -1111,17 +972,17 @@ BOOL SbxValue::Convert( SbxDataType eTo ) { SetType( eTo ); Put( aNew ); - SetModified( TRUE ); + SetModified( sal_True ); } Broadcast( SBX_HINT_CONVERTED ); - return TRUE; + return sal_True; } else - return FALSE; + return sal_False; } ////////////////////////////////// Calculating ///////////////////////////////// -BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) +sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { bool bVBAInterop = SbiRuntime::isVBAEnabled(); @@ -1183,34 +1044,24 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) else if( eOpType == SbxSTRING && rOp.IsFixed() ) { // Numeric: there is no String allowed on the right side SetError( SbxERR_CONVERSION ); + // falls all the way out } else if( ( eOp >= SbxIDIV && eOp <= SbxNOT ) || eOp == SbxMOD ) { if( GetType() == eOpType ) { - if( GetType() == SbxULONG64 - || GetType() == SbxLONG64 - || GetType() == SbxCURRENCY - || GetType() == SbxULONG ) + if( GetType() == SbxSALUINT64 || GetType() == SbxSALINT64 + || GetType() == SbxCURRENCY || GetType() == SbxULONG ) 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; } - else if( GetType() == SbxCURRENCY || eOpType == SbxCURRENCY - || GetType() == SbxULONG64 || eOpType == SbxULONG64 - || GetType() == SbxLONG64 || eOpType == SbxLONG64 ) - aL.eType = aR.eType = SbxLONG64; -// else if( GetType() == SbxDouble || rOP.GetType() == SbxDouble -// || GetType() == SbxSingle || rOP.GetType() == SbxSingle ) -// aL.eType = aR.eType = SbxLONG64; else aL.eType = aR.eType = SbxLONG; - if( rOp.Get( aR ) ) + if( rOp.Get( aR ) ) // re-do Get after type assigns above { if( rOp.GetType() == SbxEMPTY ) { @@ -1221,13 +1072,17 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { case SbxIDIV: if( aL.eType == SbxCURRENCY ) - aL.eType = SbxLONG64; - if( aL.eType == SbxLONG64 ) - if( !aR.nLong64 ) SetError( SbxERR_ZERODIV ); - else aL.nLong64 /= aR.nLong64; - else if( aL.eType == SbxULONG64 ) - if( !aR.nULong64 ) SetError( SbxERR_ZERODIV ); - else aL.nULong64 /= aR.nULong64; + if( !aR.nInt64 ) SetError( SbxERR_ZERODIV ); + else { + aL.nInt64 /= aR.nInt64; + aL.nInt64 *= CURRENCY_FACTOR; + } + else if( aL.eType == SbxSALUINT64 ) + if( !aR.uInt64 ) SetError( SbxERR_ZERODIV ); + else aL.uInt64 /= aR.uInt64; + else if( aL.eType == SbxSALINT64 ) + if( !aR.nInt64 ) SetError( SbxERR_ZERODIV ); + else aL.nInt64 /= aR.nInt64; else if( aL.eType == SbxLONG ) if( !aR.nLong ) SetError( SbxERR_ZERODIV ); else aL.nLong /= aR.nLong; @@ -1236,14 +1091,12 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) else aL.nULong /= aR.nULong; break; case SbxMOD: - if( aL.eType == SbxCURRENCY ) - aL.eType = SbxLONG64; - if( aL.eType == SbxLONG64 ) - if( !aR.nLong64 ) SetError( SbxERR_ZERODIV ); - else aL.nLong64 %= aR.nLong64; - else if( aL.eType == SbxULONG64 ) - if( !aR.nULong64 ) SetError( SbxERR_ZERODIV ); - else aL.nULong64 %= aR.nULong64; + if( aL.eType == SbxCURRENCY || aL.eType == SbxSALINT64 ) + if( !aR.nInt64 ) SetError( SbxERR_ZERODIV ); + else aL.nInt64 %= aR.nInt64; + else if( aL.eType == SbxSALUINT64 ) + if( !aR.uInt64 ) SetError( SbxERR_ZERODIV ); + else aL.uInt64 %= aR.uInt64; else if( aL.eType == SbxLONG ) if( !aR.nLong ) SetError( SbxERR_ZERODIV ); else aL.nLong %= aR.nLong; @@ -1253,31 +1106,31 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) break; case SbxAND: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 &= aR.nLong64; + aL.nInt64 &= aR.nInt64; else aL.nLong &= aR.nLong; break; case SbxOR: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 |= aR.nLong64; + aL.nInt64 |= aR.nInt64; else aL.nLong |= aR.nLong; break; case SbxXOR: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 ^= aR.nLong64; + aL.nInt64 ^= aR.nInt64; else aL.nLong ^= aR.nLong; break; case SbxEQV: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 = (aL.nLong64 & aR.nLong64) | (~aL.nLong64 & ~aR.nLong64); + aL.nInt64 = (aL.nInt64 & aR.nInt64) | (~aL.nInt64 & ~aR.nInt64); else aL.nLong = (aL.nLong & aR.nLong) | (~aL.nLong & ~aR.nLong); break; case SbxIMP: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 = ~aL.nLong64 | aR.nLong64; + aL.nInt64 = ~aL.nInt64 | aR.nInt64; else aL.nLong = ~aL.nLong | aR.nLong; break; @@ -1285,7 +1138,7 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) if( aL.eType != SbxLONG && aL.eType != SbxULONG ) { if ( aL.eType != SbxBOOL ) - aL.nLong64 = ~aL.nLong64; + aL.nInt64 = ~aL.nInt64; else aL.nLong = ~aL.nLong; } @@ -1296,8 +1149,8 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) } } } - else if( ( GetType() == SbxDECIMAL || rOp.GetType() == SbxDECIMAL ) && - ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS || eOp == SbxNEG ) ) + else if( ( GetType() == SbxDECIMAL || rOp.GetType() == SbxDECIMAL ) + && ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS || eOp == SbxNEG ) ) { aL.eType = aR.eType = SbxDECIMAL; bDecimal = true; @@ -1353,52 +1206,81 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) if( rOp.Get( aR ) ) { - static BigInt n10K( 10000 ); - if( rOp.GetType() == SbxEMPTY ) goto Lbl_OpIsEmpty; if( Get( aL ) ) switch( eOp ) { + double dTest; case SbxMUL: - { - // #i20704 Implement directly - BigInt b1( aL.nLong64 ); - BigInt b2( aR.nLong64 ); - b1 *= b2; - b1 /= n10K; - double d = double( b1 ) / 10000.0; - if( d > SbxMAXCURR || d < SbxMINCURR ) + // first overflow check: see if product will fit - test real value of product (hence 2 curr factors) + dTest = (double)aL.nInt64 * (double)aR.nInt64 / (double)CURRENCY_FACTOR_SQUARE; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) + { + aL.nInt64 = SAL_MAX_INT64; + if( dTest < SbxMINCURR ) aL.nInt64 = SAL_MIN_INT64; SetError( SbxERR_OVERFLOW ); - else - b1.INT64( &aL.nLong64 ); + break; + } + // second overflow check: see if unscaled product overflows - if so use doubles + dTest = (double)aL.nInt64 * (double)aR.nInt64; + if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest) + { + aL.nInt64 = (sal_Int64)( dTest / (double)CURRENCY_FACTOR ); + break; + } + // precise calc: multiply then scale back (move decimal pt) + aL.nInt64 *= aR.nInt64; + aL.nInt64 /= CURRENCY_FACTOR; break; - } + case SbxDIV: - if( !aR.nLong64 ) + if( !aR.nInt64 ) { SetError( SbxERR_ZERODIV ); + break; } - else + // first overflow check: see if quotient will fit - calc real value of quotient (curr factors cancel) + dTest = (double)aL.nInt64 / (double)aR.nInt64; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) { - // #i20704 Implement directly - BigInt b1( aL.nLong64 ); - BigInt b2( aR.nLong64 ); - b1 *= n10K; - b1 /= b2; - double d = double( b1 ) / 10000.0; - if( d > SbxMAXCURR || d < SbxMINCURR ) - SetError( SbxERR_OVERFLOW ); - else - b1.INT64( &aL.nLong64 ); + SetError( SbxERR_OVERFLOW ); + break; + } + // second overflow check: see if scaled dividend overflows - if so use doubles + dTest = (double)aL.nInt64 * (double)CURRENCY_FACTOR; + if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest) + { + aL.nInt64 = (sal_Int64)(dTest / (double)aR.nInt64); + break; } + // precise calc: scale (move decimal pt) then divide + aL.nInt64 *= CURRENCY_FACTOR; + aL.nInt64 /= aR.nInt64; break; + case SbxPLUS: - aL.nLong64 += aR.nLong64; break; + dTest = ( (double)aL.nInt64 + (double)aR.nInt64 ) / (double)CURRENCY_FACTOR; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) + { + SetError( SbxERR_OVERFLOW ); + break; + } + aL.nInt64 += aR.nInt64; + break; + case SbxMINUS: - aL.nLong64 -= aR.nLong64; break; + dTest = ( (double)aL.nInt64 - (double)aR.nInt64 ) / (double)CURRENCY_FACTOR; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) + { + SetError( SbxERR_OVERFLOW ); + break; + } + aL.nInt64 -= aR.nInt64; + break; case SbxNEG: - aL.nLong64 = -aL.nLong64; break; + aL.nInt64 = -aL.nInt64; + break; default: SetError( SbxERR_NOTIMP ); } @@ -1406,7 +1288,7 @@ BOOL SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) } else Lbl_OpIsDouble: - { // other operators + { // other types and operators including Date, Double and Single aL.eType = aR.eType = SbxDOUBLE; if( rOp.Get( aR ) ) { @@ -1429,6 +1311,9 @@ Lbl_OpIsDouble: else aL.nDouble /= aR.nDouble; break; case SbxPLUS: aL.nDouble += aR.nDouble; break; + // #45465 Date needs with "+" a special handling: forces date type + if( GetType() == SbxDATE || rOp.GetType() == SbxDATE ) + aL.eType = SbxDATE; case SbxMINUS: aL.nDouble -= aR.nDouble; break; case SbxNEG: @@ -1437,9 +1322,6 @@ Lbl_OpIsDouble: SetError( SbxERR_NOTIMP ); } - // #45465 Date needs with "+" a special handling - if( eOp == SbxPLUS && (GetType() == SbxDATE || rOp.GetType() == SbxDATE ) ) - aL.eType = SbxDATE; } } @@ -1454,7 +1336,7 @@ Lbl_OpIsDouble: } Lbl_OpIsEmpty: - BOOL bRes = BOOL( !IsError() ); + sal_Bool bRes = sal_Bool( !IsError() ); if( bRes && eOld != SbxERR_OK ) SetError( eOld ); return bRes; @@ -1462,11 +1344,11 @@ Lbl_OpIsEmpty: // The comparison routine deliver TRUE or FALSE. -BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const +sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const { bool bVBAInterop = SbiRuntime::isVBAEnabled(); - BOOL bRes = FALSE; + sal_Bool bRes = sal_False; SbxError eOld = GetError(); if( eOld != SbxERR_OK ) ResetError(); @@ -1474,24 +1356,24 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const SetError( SbxERR_PROP_WRITEONLY ); else if( GetType() == SbxNULL && rOp.GetType() == SbxNULL && !bVBAInterop ) { - bRes = TRUE; + bRes = sal_True; } else if( GetType() == SbxEMPTY && rOp.GetType() == SbxEMPTY ) - bRes = !bVBAInterop ? TRUE : ( eOp == SbxEQ ? TRUE : FALSE ); + bRes = !bVBAInterop ? sal_True : ( eOp == SbxEQ ? sal_True : sal_False ); // Special rule 1: If an operand is zero, the result is FALSE else if( GetType() == SbxNULL || rOp.GetType() == SbxNULL ) - bRes = FALSE; + bRes = sal_False; // Special rule 2: If both are variant and one is numeric // and the other is a String, num is < str else if( !IsFixed() && !rOp.IsFixed() && ( rOp.GetType() == SbxSTRING && GetType() != SbxSTRING && IsNumeric() ) && !bVBAInterop ) - bRes = BOOL( eOp == SbxLT || eOp == SbxLE || eOp == SbxNE ); + bRes = sal_Bool( eOp == SbxLT || eOp == SbxLE || eOp == SbxNE ); else if( !IsFixed() && !rOp.IsFixed() && ( GetType() == SbxSTRING && rOp.GetType() != SbxSTRING && rOp.IsNumeric() ) && !bVBAInterop ) - bRes = BOOL( eOp == SbxGT || eOp == SbxGE || eOp == SbxNE ); + bRes = sal_Bool( eOp == SbxGT || eOp == SbxGE || eOp == SbxNE ); else { SbxValues aL, aR; @@ -1503,17 +1385,17 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const if( Get( aL ) && rOp.Get( aR ) ) switch( eOp ) { case SbxEQ: - bRes = BOOL( *aL.pOUString == *aR.pOUString ); break; + bRes = sal_Bool( *aL.pOUString == *aR.pOUString ); break; case SbxNE: - bRes = BOOL( *aL.pOUString != *aR.pOUString ); break; + bRes = sal_Bool( *aL.pOUString != *aR.pOUString ); break; case SbxLT: - bRes = BOOL( *aL.pOUString < *aR.pOUString ); break; + bRes = sal_Bool( *aL.pOUString < *aR.pOUString ); break; case SbxGT: - bRes = BOOL( *aL.pOUString > *aR.pOUString ); break; + bRes = sal_Bool( *aL.pOUString > *aR.pOUString ); break; case SbxLE: - bRes = BOOL( *aL.pOUString <= *aR.pOUString ); break; + bRes = sal_Bool( *aL.pOUString <= *aR.pOUString ); break; case SbxGE: - bRes = BOOL( *aL.pOUString >= *aR.pOUString ); break; + bRes = sal_Bool( *aL.pOUString >= *aR.pOUString ); break; default: SetError( SbxERR_NOTIMP ); } @@ -1527,17 +1409,17 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const switch( eOp ) { case SbxEQ: - bRes = BOOL( aL.nSingle == aR.nSingle ); break; + bRes = sal_Bool( aL.nSingle == aR.nSingle ); break; case SbxNE: - bRes = BOOL( aL.nSingle != aR.nSingle ); break; + bRes = sal_Bool( aL.nSingle != aR.nSingle ); break; case SbxLT: - bRes = BOOL( aL.nSingle < aR.nSingle ); break; + bRes = sal_Bool( aL.nSingle < aR.nSingle ); break; case SbxGT: - bRes = BOOL( aL.nSingle > aR.nSingle ); break; + bRes = sal_Bool( aL.nSingle > aR.nSingle ); break; case SbxLE: - bRes = BOOL( aL.nSingle <= aR.nSingle ); break; + bRes = sal_Bool( aL.nSingle <= aR.nSingle ); break; case SbxGE: - bRes = BOOL( aL.nSingle >= aR.nSingle ); break; + bRes = sal_Bool( aL.nSingle >= aR.nSingle ); break; default: SetError( SbxERR_NOTIMP ); } @@ -1553,17 +1435,17 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const switch( eOp ) { case SbxEQ: - bRes = BOOL( eRes == SbxDecimal::EQ ); break; + bRes = sal_Bool( eRes == SbxDecimal::EQ ); break; case SbxNE: - bRes = BOOL( eRes != SbxDecimal::EQ ); break; + bRes = sal_Bool( eRes != SbxDecimal::EQ ); break; case SbxLT: - bRes = BOOL( eRes == SbxDecimal::LT ); break; + bRes = sal_Bool( eRes == SbxDecimal::LT ); break; case SbxGT: - bRes = BOOL( eRes == SbxDecimal::GT ); break; + bRes = sal_Bool( eRes == SbxDecimal::GT ); break; case SbxLE: - bRes = BOOL( eRes != SbxDecimal::GT ); break; + bRes = sal_Bool( eRes != SbxDecimal::GT ); break; case SbxGE: - bRes = BOOL( eRes != SbxDecimal::LT ); break; + bRes = sal_Bool( eRes != SbxDecimal::LT ); break; default: SetError( SbxERR_NOTIMP ); } @@ -1579,24 +1461,23 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const else { aL.eType = aR.eType = SbxDOUBLE; - //if( Get( aL ) && rOp.Get( aR ) ) bool bGetL = Get( aL ); bool bGetR = rOp.Get( aR ); if( bGetL && bGetR ) switch( eOp ) { case SbxEQ: - bRes = BOOL( aL.nDouble == aR.nDouble ); break; + bRes = sal_Bool( aL.nDouble == aR.nDouble ); break; case SbxNE: - bRes = BOOL( aL.nDouble != aR.nDouble ); break; + bRes = sal_Bool( aL.nDouble != aR.nDouble ); break; case SbxLT: - bRes = BOOL( aL.nDouble < aR.nDouble ); break; + bRes = sal_Bool( aL.nDouble < aR.nDouble ); break; case SbxGT: - bRes = BOOL( aL.nDouble > aR.nDouble ); break; + bRes = sal_Bool( aL.nDouble > aR.nDouble ); break; case SbxLE: - bRes = BOOL( aL.nDouble <= aR.nDouble ); break; + bRes = sal_Bool( aL.nDouble <= aR.nDouble ); break; case SbxGE: - bRes = BOOL( aL.nDouble >= aR.nDouble ); break; + bRes = sal_Bool( aL.nDouble >= aR.nDouble ); break; default: SetError( SbxERR_NOTIMP ); } @@ -1608,7 +1489,7 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const if ( bVBAInterop && eOp == SbxEQ && GetError() == SbxERR_CONVERSION ) { ResetError(); - bRes = FALSE; + bRes = sal_False; } } } @@ -1620,10 +1501,12 @@ BOOL SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const ///////////////////////////// Reading/Writing //////////////////////////// -BOOL SbxValue::LoadData( SvStream& r, USHORT ) +sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) { + // #TODO see if these types are really dumped to any stream + // more than likely this is functionality used in the binfilter alone SbxValue::Clear(); - UINT16 nType; + sal_uInt16 nType; r >> nType; aData.eType = SbxDataType( nType ); switch( nType ) @@ -1643,7 +1526,7 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) if( ImpScan( aVal, d, t, NULL ) != SbxERR_OK || t == SbxDOUBLE ) { aData.nSingle = 0.0F; - return FALSE; + return sal_False; } aData.nSingle = (float) d; break; @@ -1658,19 +1541,25 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) if( ImpScan( aVal, aData.nDouble, t, NULL ) != SbxERR_OK ) { aData.nDouble = 0.0; - return FALSE; + return sal_False; } break; } - case SbxULONG64: - { - r >> aData.nULong64.nHigh >> aData.nULong64.nLow; + case SbxSALUINT64: + case SbxSALINT64: + // Rather ugly use of the union here because we only + // have a SvStream& SvStream::operator>>(sal_uInt64&) available to us + // There is no SvStream::operator>>(sal_Int64&) due to conflict with + // SvStream::operator>>(long&) ( at least on 64 bit linux ) + r >> aData.uInt64; break; - } - case SbxLONG64: case SbxCURRENCY: { - r >> aData.nLong64.nHigh >> aData.nLong64.nLow; + sal_uInt32 tmpHi = 0; + sal_uInt32 tmpLo = 0; + r >> tmpHi >> tmpLo; + aData.nInt64 = ((sal_Int64)tmpHi << 32); + aData.nInt64 |= (sal_Int64)tmpLo; break; } case SbxSTRING: @@ -1688,7 +1577,7 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) r >> aData.nUShort; break; case SbxOBJECT: { - BYTE nMode; + sal_uInt8 nMode; r >> nMode; switch( nMode ) { @@ -1697,7 +1586,7 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) break; case 1: aData.pObj = SbxBase::Load( r ); - return BOOL( aData.pObj != NULL ); + return sal_Bool( aData.pObj != NULL ); case 2: aData.pObj = this; break; @@ -1717,7 +1606,7 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) r >> aData.nULong; break; case SbxINT: { - BYTE n; + sal_uInt8 n; r >> n; // Match the Int on this system? if( n > SAL_TYPES_SIZEOFINT ) @@ -1728,7 +1617,7 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) } case SbxUINT: { - BYTE n; + sal_uInt8 n; r >> n; // Match the UInt on this system? if( n > SAL_TYPES_SIZEOFINT ) @@ -1753,14 +1642,14 @@ BOOL SbxValue::LoadData( SvStream& r, USHORT ) ResetFlag(SBX_FIXED); aData.eType = SbxNULL; DBG_ASSERT( !this, "Nicht unterstuetzer Datentyp geladen" ); - return FALSE; + return sal_False; } - return TRUE; + return sal_True; } -BOOL SbxValue::StoreData( SvStream& r ) const +sal_Bool SbxValue::StoreData( SvStream& r ) const { - UINT16 nType = sal::static_int_cast< UINT16 >(aData.eType); + sal_uInt16 nType = sal::static_int_cast< sal_uInt16 >(aData.eType); r << nType; switch( nType & 0x0FFF ) { @@ -1779,15 +1668,16 @@ BOOL SbxValue::StoreData( SvStream& r ) const case SbxDOUBLE: r.WriteByteString( GetCoreString(), RTL_TEXTENCODING_ASCII_US ); break; - case SbxULONG64: - { - r << aData.nULong64.nHigh << aData.nULong64.nLow; + case SbxSALUINT64: + case SbxSALINT64: + // see comment in SbxValue::StoreData + r << aData.uInt64; break; - } - case SbxLONG64: case SbxCURRENCY: { - r << aData.nLong64.nHigh << aData.nLong64.nLow; + sal_Int32 tmpHi = ( (aData.nInt64 >> 32) & 0xFFFFFFFF ); + sal_Int32 tmpLo = ( sal_Int32 )aData.nInt64; + r << tmpHi << tmpLo; break; } case SbxSTRING: @@ -1810,14 +1700,14 @@ BOOL SbxValue::StoreData( SvStream& r ) const { if( PTR_CAST(SbxValue,aData.pObj) != this ) { - r << (BYTE) 1; + r << (sal_uInt8) 1; return aData.pObj->Store( r ); } else - r << (BYTE) 2; + r << (sal_uInt8) 2; } else - r << (BYTE) 0; + r << (sal_uInt8) 0; break; case SbxCHAR: { @@ -1831,13 +1721,13 @@ BOOL SbxValue::StoreData( SvStream& r ) const r << aData.nULong; break; case SbxINT: { - BYTE n = SAL_TYPES_SIZEOFINT; + sal_uInt8 n = SAL_TYPES_SIZEOFINT; r << n << (sal_Int32)aData.nInt; break; } case SbxUINT: { - BYTE n = SAL_TYPES_SIZEOFINT; + sal_uInt8 n = SAL_TYPES_SIZEOFINT; r << n << (sal_uInt32)aData.nUInt; break; } @@ -1854,9 +1744,9 @@ BOOL SbxValue::StoreData( SvStream& r ) const break; default: DBG_ASSERT( !this, "Speichern eines nicht unterstuetzten Datentyps" ); - return FALSE; + return sal_False; } - return TRUE; + return sal_True; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 9ea647e673..b91eb87b11 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -2,7 +2,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 @@ -34,7 +34,6 @@ #include "svl/brdcst.hxx" #include <basic/sbx.hxx> -#include <basic/sbxbase.hxx> #include "sbxres.hxx" #include "sbxconv.hxx" #include <math.h> @@ -48,9 +47,9 @@ using namespace com::sun::star::uno; TYPEINIT1(SbxVariable,SbxValue) TYPEINIT1(SbxHint,SfxSimpleHint) -extern UINT32 nVarCreator; // in SBXBASE.CXX, fuer LoadData() +extern sal_uInt32 nVarCreator; // in SBXBASE.CXX, fuer LoadData() #ifdef DBG_UTIL -static ULONG nVar = 0; +static sal_uIntPtr nVar = 0; #endif ///////////////////////////// SbxVariableImpl //////////////////////////// @@ -60,13 +59,17 @@ class SbxVariableImpl friend class SbxVariable; String m_aDeclareClassName; Reference< XInterface > m_xComListener; + StarBASIC* m_pComListenerParentBasic; SbxVariableImpl( void ) + : m_pComListenerParentBasic( NULL ) {} SbxVariableImpl( const SbxVariableImpl& r ) : m_aDeclareClassName( r.m_aDeclareClassName ) , m_xComListener( r.m_xComListener ) - {} + , m_pComListenerParentBasic( r.m_pComListenerParentBasic ) + { + } }; @@ -81,16 +84,21 @@ SbxVariable::SbxVariable() : SbxValue() nHash = 0; #ifdef DBG_UTIL DbgOutf( "SbxVariable::Ctor %lx=%ld", (void*)this, ++nVar ); - GetSbxData_Impl()->aVars.Insert( this, LIST_APPEND ); #endif } +void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic ); + SbxVariable::SbxVariable( const SbxVariable& r ) : SvRefBase( r ), SbxValue( r ), mpPar( r.mpPar ), pInfo( r.pInfo ) { mpSbxVariableImpl = NULL; if( r.mpSbxVariableImpl != NULL ) + { mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl ); + if( mpSbxVariableImpl->m_xComListener.is() ) + registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic ); + } pCst = NULL; if( r.CanRead() ) { @@ -110,7 +118,6 @@ SbxVariable::SbxVariable( const SbxVariable& r ) if ( maName.EqualsAscii( aCellsStr ) ) maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 ); DbgOutf( "SbxVariable::Ctor %lx=%ld", (void*)this, ++nVar ); - GetSbxData_Impl()->aVars.Insert( this, LIST_APPEND ); #endif } @@ -123,10 +130,11 @@ SbxVariable::SbxVariable( SbxDataType t, void* p ) : SbxValue( t, p ) nHash = 0; #ifdef DBG_UTIL DbgOutf( "SbxVariable::Ctor %lx=%ld", (void*)this, ++nVar ); - GetSbxData_Impl()->aVars.Insert( this, LIST_APPEND ); #endif } +void removeDimAsNewRecoverItem( SbxVariable* pVar ); + SbxVariable::~SbxVariable() { #ifdef DBG_UTIL @@ -135,8 +143,9 @@ SbxVariable::~SbxVariable() static sal_Char const aCellsStr[] = "Cells"; if ( maName.EqualsAscii( aCellsStr ) ) maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 ); - GetSbxData_Impl()->aVars.Remove( this ); #endif + if( IsSet( SBX_DIM_AS_NEW )) + removeDimAsNewRecoverItem( this ); delete mpSbxVariableImpl; delete pCst; } @@ -153,7 +162,7 @@ SfxBroadcaster& SbxVariable::GetBroadcaster() // Perhaps some day one could cut the parameter 0. // then the copying will be dropped ... -void SbxVariable::Broadcast( ULONG nHintId ) +void SbxVariable::Broadcast( sal_uIntPtr nHintId ) { if( pCst && !IsSet( SBX_NO_BROADCAST ) && StaticIsEnabledBroadcasting() ) { @@ -168,7 +177,7 @@ void SbxVariable::Broadcast( ULONG nHintId ) // Avoid further broadcasting SfxBroadcaster* pSave = pCst; pCst = NULL; - USHORT nSaveFlags = GetFlags(); + sal_uInt16 nSaveFlags = GetFlags(); SetFlag( SBX_READWRITE ); if( mpPar.Is() ) // Register this as element 0, but don't change over the parent! @@ -186,7 +195,7 @@ SbxInfo* SbxVariable::GetInfo() { Broadcast( SBX_HINT_INFOWANTED ); if( pInfo.Is() ) - SetModified( TRUE ); + SetModified( sal_True ); } return pInfo; } @@ -233,7 +242,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const aTmp += cType; } aTmp += '('; - for( USHORT i = 0; i < pInfo->aParams.Count(); i++ ) + for( sal_uInt16 i = 0; i < pInfo->aParams.Count(); i++ ) { const SbxParamInfo* q = pInfo->aParams.GetObject( i ); int nt = q->eType & 0x0FFF; @@ -267,7 +276,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const aTmp += String( SbxRes( STRING_AS ) ); if( nt < 32 ) aTmp += String( SbxRes( - sal::static_int_cast< USHORT >( STRING_TYPES + nt ) ) ); + sal::static_int_cast< sal_uInt16 >( STRING_TYPES + nt ) ) ); else aTmp += String( SbxRes( STRING_ANY ) ); } @@ -280,7 +289,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const aTmp += String( SbxRes( STRING_AS ) ); if( et < 32 ) aTmp += String( SbxRes( - sal::static_int_cast< USHORT >( STRING_TYPES + et ) ) ); + sal::static_int_cast< sal_uInt16 >( STRING_TYPES + et ) ) ); else aTmp += String( SbxRes( STRING_ANY ) ); } @@ -290,21 +299,21 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const // Create a simple hashcode: the first six characters were evaluated. -USHORT SbxVariable::MakeHashCode( const XubString& rName ) +sal_uInt16 SbxVariable::MakeHashCode( const XubString& rName ) { - USHORT n = 0; - USHORT nLen = rName.Len(); + sal_uInt16 n = 0; + sal_uInt16 nLen = rName.Len(); if( nLen > 6 ) nLen = 6; const xub_Unicode* p = rName.GetBuffer(); while( nLen-- ) { - BYTE c = (BYTE)*p; + sal_uInt8 c = (sal_uInt8)*p; p++; // If we have a commen sigen break!! if( c >= 0x80 ) return 0; - n = sal::static_int_cast< USHORT >( ( n << 3 ) + toupper( c ) ); + n = sal::static_int_cast< sal_uInt16 >( ( n << 3 ) + toupper( c ) ); } return n; } @@ -316,7 +325,11 @@ SbxVariable& SbxVariable::operator=( const SbxVariable& r ) SbxValue::operator=( r ); delete mpSbxVariableImpl; if( r.mpSbxVariableImpl != NULL ) + { mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl ); + if( mpSbxVariableImpl->m_xComListener.is() ) + registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic ); + } else mpSbxVariableImpl = NULL; return *this; @@ -339,7 +352,7 @@ SbxClassType SbxVariable::GetClass() const return SbxCLASS_VARIABLE; } -void SbxVariable::SetModified( BOOL b ) +void SbxVariable::SetModified( sal_Bool b ) { if( IsSet( SBX_NO_MODIFY ) ) return; @@ -355,11 +368,11 @@ void SbxVariable::SetParent( SbxObject* p ) if ( p && ISA(SbxObject) ) { // then this had to be a child of the new parent - BOOL bFound = FALSE; + sal_Bool bFound = sal_False; SbxArray *pChilds = p->GetObjects(); if ( pChilds ) { - for ( USHORT nIdx = 0; !bFound && nIdx < pChilds->Count(); ++nIdx ) + for ( sal_uInt16 nIdx = 0; !bFound && nIdx < pChilds->Count(); ++nIdx ) bFound = ( this == pChilds->Get(nIdx) ); } if ( !bFound ) @@ -397,26 +410,35 @@ void SbxVariable::SetDeclareClassName( const String& rDeclareClassName ) pImpl->m_aDeclareClassName = rDeclareClassName; } -void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener ) +void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener, + StarBASIC* pParentBasic ) { SbxVariableImpl* pImpl = getImpl(); pImpl->m_xComListener = xComListener; + pImpl->m_pComListenerParentBasic = pParentBasic; + registerComListenerVariableForBasic( this, pParentBasic ); +} + +void SbxVariable::ClearComListener( void ) +{ + SbxVariableImpl* pImpl = getImpl(); + pImpl->m_xComListener.clear(); } ////////////////////////////// Loading/Saving ///////////////////////////// -BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) +sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { - UINT16 nType; - BYTE cMark; + sal_uInt16 nType; + sal_uInt8 cMark; rStrm >> cMark; if( cMark == 0xFF ) { if( !SbxValue::LoadData( rStrm, nVer ) ) - return FALSE; + return sal_False; rStrm.ReadByteString( maName, RTL_TEXTENCODING_ASCII_US ); - UINT32 nTemp; + sal_uInt32 nTemp; rStrm >> nTemp; nUserData = nTemp; } @@ -425,7 +447,7 @@ BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) rStrm.SeekRel( -1L ); rStrm >> nType; rStrm.ReadByteString( maName, RTL_TEXTENCODING_ASCII_US ); - UINT32 nTemp; + sal_uInt32 nTemp; rStrm >> nTemp; nUserData = nTemp; // correction: old methods have instead of SbxNULL now SbxEMPTY @@ -453,7 +475,7 @@ BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) if( ImpScan( aTmpString, d, t, NULL ) != SbxERR_OK || t == SbxDOUBLE ) { aTmp.nSingle = 0; - return FALSE; + return sal_False; } aTmp.nSingle = (float) d; break; @@ -467,7 +489,7 @@ BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) if( ImpScan( aTmpString, aTmp.nDouble, t, NULL ) != SbxERR_OK ) { aTmp.nDouble = 0; - return FALSE; + return sal_False; } break; } @@ -481,11 +503,11 @@ BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) default: aData.eType = SbxNULL; DBG_ASSERT( !this, "Nicht unterstuetzer Datentyp geladen" ); - return FALSE; + return sal_False; } // putt value if( nType != SbxNULL && nType != SbxEMPTY && !Put( aTmp ) ) - return FALSE; + return sal_False; } rStrm >> cMark; // cMark is also a version number! @@ -494,29 +516,29 @@ BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer ) if( cMark ) { if( cMark > 2 ) - return FALSE; + return sal_False; pInfo = new SbxInfo; - pInfo->LoadData( rStrm, (USHORT) cMark ); + pInfo->LoadData( rStrm, (sal_uInt16) cMark ); } // Load private data only, if it is a SbxVariable if( GetClass() == SbxCLASS_VARIABLE && !LoadPrivateData( rStrm, nVer ) ) - return FALSE; + return sal_False; ((SbxVariable*) this)->Broadcast( SBX_HINT_DATACHANGED ); nHash = MakeHashCode( maName ); - SetModified( TRUE ); - return TRUE; + SetModified( sal_True ); + return sal_True; } -BOOL SbxVariable::StoreData( SvStream& rStrm ) const +sal_Bool SbxVariable::StoreData( SvStream& rStrm ) const { - rStrm << (BYTE) 0xFF; // Marker - BOOL bValStore; + rStrm << (sal_uInt8) 0xFF; // Marker + sal_Bool bValStore; if( this->IsA( TYPE(SbxMethod) ) ) { // #50200 Avoid that objects , which during the runtime // as return-value are saved in the method as a value were saved SbxVariable* pThis = (SbxVariable*)this; - USHORT nSaveFlags = GetFlags(); + sal_uInt16 nSaveFlags = GetFlags(); pThis->SetFlag( SBX_WRITE ); pThis->SbxValue::Clear(); pThis->SetFlags( nSaveFlags ); @@ -530,23 +552,21 @@ BOOL SbxVariable::StoreData( SvStream& rStrm ) const else bValStore = SbxValue::StoreData( rStrm ); if( !bValStore ) - return FALSE; - // if( !SbxValue::StoreData( rStrm ) ) - // return FALSE; + return sal_False; rStrm.WriteByteString( maName, RTL_TEXTENCODING_ASCII_US ); - rStrm << (UINT32)nUserData; + rStrm << (sal_uInt32)nUserData; if( pInfo.Is() ) { - rStrm << (BYTE) 2; // Version 2: with UserData! + rStrm << (sal_uInt8) 2; // Version 2: with UserData! pInfo->StoreData( rStrm ); } else - rStrm << (BYTE) 0; + rStrm << (sal_uInt8) 0; // Save private data only, if it is a SbxVariable if( GetClass() == SbxCLASS_VARIABLE ) return StorePrivateData( rStrm ); else - return TRUE; + return sal_True; } ////////////////////////////// SbxInfo /////////////////////////////////// @@ -554,7 +574,7 @@ BOOL SbxVariable::StoreData( SvStream& rStrm ) const SbxInfo::SbxInfo() : aHelpFile(), nHelpId( 0 ), aParams() {} -SbxInfo::SbxInfo( const String& r, UINT32 n ) +SbxInfo::SbxInfo( const String& r, sal_uInt32 n ) : aHelpFile( r ), nHelpId( n ), aParams() {} @@ -587,7 +607,7 @@ SbxAlias::~SbxAlias() EndListening( xAlias->GetBroadcaster() ); } -void SbxAlias::Broadcast( ULONG nHt ) +void SbxAlias::Broadcast( sal_uIntPtr nHt ) { if( xAlias.Is() && StaticIsEnabledBroadcasting() ) { @@ -617,11 +637,11 @@ void SbxAlias::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, } } -void SbxVariable::Dump( SvStream& rStrm, BOOL bFill ) +void SbxVariable::Dump( SvStream& rStrm, sal_Bool bFill ) { ByteString aBNameStr( (const UniString&)GetName( SbxNAME_SHORT_TYPES ), RTL_TEXTENCODING_ASCII_US ); rStrm << "Variable( " - << ByteString::CreateFromInt64( (ULONG) this ).GetBuffer() << "==" + << ByteString::CreateFromInt64( (sal_uIntPtr) this ).GetBuffer() << "==" << aBNameStr.GetBuffer(); ByteString aBParentNameStr( (const UniString&)GetParent()->GetName(), RTL_TEXTENCODING_ASCII_US ); if ( GetParent() ) |