diff options
40 files changed, 402 insertions, 402 deletions
diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx index 3560938295f5..4efcb829c217 100644 --- a/basic/qa/cppunit/test_scanner.cxx +++ b/basic/qa/cppunit/test_scanner.cxx @@ -341,8 +341,8 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[3].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[4].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[4].type); - CPPUNIT_ASSERT_EQUAL(1u, (unsigned int)symbols[5].text.getLength()); - CPPUNIT_ASSERT_EQUAL('a', (char)symbols[5].text[0]); + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(symbols[5].text.getLength())); + CPPUNIT_ASSERT_EQUAL('a', static_cast<char>(symbols[5].text[0])); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[5].type); CPPUNIT_ASSERT_EQUAL(OUString("sdf"), symbols[6].text); CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[6].type); @@ -575,7 +575,7 @@ namespace CPPUNIT_ASSERT_DOUBLES_EQUAL(12345.0, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source2, errors); CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size()); @@ -584,35 +584,35 @@ namespace CPPUNIT_ASSERT_DOUBLES_EQUAL(.3, symbols[1].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[1].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text); - CPPUNIT_ASSERT_EQUAL(1u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); symbols = getSymbols(source3, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(123.4, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source4, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(.5, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source5, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source6, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source7, errors); CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size()); @@ -620,7 +620,7 @@ namespace CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, symbols[1].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[1].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source8, errors); CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size()); @@ -628,7 +628,7 @@ namespace CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[1].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[1].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source9, errors); CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size()); @@ -636,21 +636,21 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(OUString("dE3"), symbols[1].text); CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text); - CPPUNIT_ASSERT_EQUAL(1u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); symbols = getSymbols(source10, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(12000.0, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source11, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(12000.0, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source12, errors); CPPUNIT_ASSERT_EQUAL(size_t(6), symbols.size()); @@ -662,14 +662,14 @@ namespace CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, symbols[4].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[4].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[5].text); - CPPUNIT_ASSERT_EQUAL(1u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); symbols = getSymbols(source13, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(.012, symbols[0].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source14, errors); CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size()); @@ -677,7 +677,7 @@ namespace CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(OUString("+"), symbols[1].text); CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source15, errors); CPPUNIT_ASSERT_EQUAL(size_t(6), symbols.size()); @@ -690,7 +690,7 @@ namespace CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, symbols[4].number, 1E-12); CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[4].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[5].text); - CPPUNIT_ASSERT_EQUAL(0u, (unsigned int)errors); + CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors)); symbols = getSymbols(source16, errors); CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size()); @@ -699,7 +699,7 @@ namespace CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); // This error is from a "buffer overflow" which is stupid because // the buffer is artificially constrained by the scanner. - CPPUNIT_ASSERT_EQUAL(1u, (unsigned int)errors); // HACK + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // HACK double fInf = 0.0; rtl::math::setInf( &fInf, false); @@ -708,7 +708,7 @@ namespace CPPUNIT_ASSERT_EQUAL(fInf, symbols[0].number); CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type); CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text); - CPPUNIT_ASSERT_EQUAL(1u, (unsigned int)errors); // math error, overflow + CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // math error, overflow } void ScannerTest::testDataType() diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 8c9429324fe9..b50fbfcc900e 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -1057,7 +1057,7 @@ StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const OUString& rLibName, // Use original name otherwise ImpLoadLibrary failes... pLibInfo->SetLibName( rLibName ); // but doesn't work this way if name exists twice - sal_uInt16 nLibId = (sal_uInt16) mpImpl->aLibs.size() - 1; + sal_uInt16 nLibId = static_cast<sal_uInt16>(mpImpl->aLibs.size()) - 1; // Set StorageName before load because it is compared with pCurStorage pLibInfo->SetStorageName( aStorageName ); @@ -1194,7 +1194,7 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage ) sal_uInt16 BasicManager::GetLibCount() const { - return (sal_uInt16)mpImpl->aLibs.size(); + return static_cast<sal_uInt16>(mpImpl->aLibs.size()); } StarBASIC* BasicManager::GetLib( sal_uInt16 nLib ) const @@ -1231,7 +1231,7 @@ sal_uInt16 BasicManager::GetLibId( const OUString& rName ) const { if (mpImpl->aLibs[i]->GetLibName().equalsIgnoreAsciiCase( rName )) { - return (sal_uInt16)i; + return static_cast<sal_uInt16>(i); } } return LIB_NOTFOUND; @@ -1473,8 +1473,8 @@ namespace SbMethod* lcl_queryMacro( BasicManager* i_manager, OUString const& i_fullyQualifiedName ) { sal_Int32 nLast = 0; - OUString sLibName = i_fullyQualifiedName.getToken( (sal_Int32)0, '.', nLast ); - OUString sModule = i_fullyQualifiedName.getToken( (sal_Int32)0, '.', nLast ); + OUString sLibName = i_fullyQualifiedName.getToken( sal_Int32(0), '.', nLast ); + OUString sModule = i_fullyQualifiedName.getToken( sal_Int32(0), '.', nLast ); OUString sMacro; if(nLast >= 0) { diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index e7003e7eb550..97e3f78b4329 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -184,7 +184,7 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any if( comphelper::string::getTokenCount(aMacro, '.') == 3 ) { sal_Int32 nLast = 0; - OUString aFullLibName = aMacro.getToken( (sal_Int32)0, '.', nLast ); + OUString aFullLibName = aMacro.getToken( sal_Int32(0), '.', nLast ); sal_Int32 nIndex = aFullLibName.indexOf( ':' ); if (nIndex >= 0) diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index 6fc7a50b17d7..9a26496db45b 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -119,7 +119,7 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) eCharSet = nCharSet; eCharSet = GetSOLoadTextEncoding( eCharSet ); bBadVer = ( nVersion > B_CURVERSION ); - nDimBase = (sal_uInt16) lDimBase; + nDimBase = static_cast<sal_uInt16>(lDimBase); } bool bLegacy = ( nVersion < B_EXT_IMG_VERSION ); @@ -170,7 +170,7 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) if ( bLegacy ) { ReleaseLegacyBuffer(); // release any previously held buffer - nLegacyCodeSize = (sal_uInt16) nCodeSize; + nLegacyCodeSize = static_cast<sal_uInt16>(nCodeSize); pLegacyPCode = pCode; PCodeBuffConvertor< sal_uInt16, sal_uInt32 > aLegacyToNew( reinterpret_cast<sal_uInt8*>(pLegacyPCode), nLegacyCodeSize ); @@ -209,20 +209,20 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) for( i = 0; i < nStrings && SbiGood( r ); i++ ) { r.ReadUInt32( nOff ); - pStringOff[ i ] = (sal_uInt16) nOff; + pStringOff[ i ] = static_cast<sal_uInt16>(nOff); } r.ReadUInt32( nLen ); if( SbiGood( r ) ) { delete [] pStrings; pStrings = new sal_Unicode[ nLen ]; - nStringSize = (sal_uInt16) nLen; + nStringSize = static_cast<sal_uInt16>(nLen); std::unique_ptr<char[]> pByteStrings(new char[ nLen ]); r.ReadBytes(pByteStrings.get(), nStringSize); for( short j = 0; j < nStrings; j++ ) { - sal_uInt16 nOff2 = (sal_uInt16) pStringOff[ j ]; + sal_uInt16 nOff2 = static_cast<sal_uInt16>(pStringOff[ j ]); OUString aStr( pByteStrings.get() + nOff2, strlen(pByteStrings.get() + nOff2), eCharSet ); memcpy( pStrings + nOff2, aStr.getStr(), (aStr.getLength() + 1) * sizeof( sal_Unicode ) ); } @@ -439,7 +439,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) std::unique_ptr<char[]> pByteStrings(new char[ nStringSize ]); for( i = 0; i < nStrings; i++ ) { - sal_uInt16 nOff = (sal_uInt16) pStringOff[ i ]; + sal_uInt16 nOff = static_cast<sal_uInt16>(pStringOff[ i ]); OString aStr(OUStringToOString(OUString(pStrings + nOff), eCharSet)); memcpy( pByteStrings.get() + nOff, aStr.getStr(), (aStr.getLength() + 1) * sizeof( char ) ); } diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 79e40d298660..85ea6d902ec1 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -2187,7 +2187,7 @@ void BasicCollection::CollItem( SbxArray* pPar_ ) SbxVariable* pRes = nullptr; SbxVariable* p = pPar_->Get( 1 ); sal_Int32 nIndex = implGetIndex( p ); - if( nIndex >= 0 && nIndex < (sal_Int32)xItemArray->Count32() ) + if( nIndex >= 0 && nIndex < static_cast<sal_Int32>(xItemArray->Count32()) ) { pRes = xItemArray->Get32( nIndex ); } @@ -2211,7 +2211,7 @@ void BasicCollection::CollRemove( SbxArray* pPar_ ) SbxVariable* p = pPar_->Get( 1 ); sal_Int32 nIndex = implGetIndex( p ); - if( nIndex >= 0 && nIndex < (sal_Int32)xItemArray->Count32() ) + if( nIndex >= 0 && nIndex < static_cast<sal_Int32>(xItemArray->Count32()) ) { xItemArray->Remove( nIndex ); diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 8a67a697e5f0..d622d887ce21 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -364,7 +364,7 @@ OUString implGetExceptionMsg( const EXCEPTION& e ) void implHandleBasicErrorException( BasicErrorException const & e ) { - ErrCode nError = StarBASIC::GetSfxFromVBError( (sal_uInt16)e.ErrorCode ); + ErrCode nError = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(e.ErrorCode) ); StarBASIC::Error( nError, e.ErrorMessageArgument ); } @@ -391,7 +391,7 @@ void implHandleWrappedTargetException( const Any& _rWrappedTargetException ) // special handling for BasicErrorException errors if ( aWrapped.TargetException >>= aBasicError ) { - nError = StarBASIC::GetSfxFromVBError( (sal_uInt16)aBasicError.ErrorCode ); + nError = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(aBasicError.ErrorCode) ); aMessageBuf.append( aBasicError.ErrorMessageArgument ); aExamine.clear(); break; @@ -540,7 +540,7 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int sal_Int32 nLen = xIdlArray->getLen( aValue ); for ( sal_Int32 index = 0; index < nLen; ++index ) { - Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)index ); + Any aElementAny = xIdlArray->get( aValue, static_cast<sal_uInt32>(index) ); // This detects the dimension were currently processing if ( dimCopy == dimension ) { @@ -767,7 +767,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) for( i = 0 ; i < nLen ; i++ ) { // convert elements - Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)i ); + Any aElementAny = xIdlArray->get( aValue, static_cast<sal_uInt32>(i) ); auto xVar = tools::make_ref<SbxVariable>( eSbxElementType ); unoToSbxValue( xVar.get(), aElementAny ); @@ -1432,7 +1432,7 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property const * pUn if( bOverflow ) StarBASIC::Error( ERRCODE_BASIC_MATH_OVERFLOW ); - sal_Int8 nByteVal = (sal_Int8)nVal; + sal_Int8 nByteVal = static_cast<sal_Int8>(nVal); aRetVal <<= nByteVal; break; } @@ -1463,7 +1463,7 @@ void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, sal_uInt Any aValAny; for( i = 0 ; i < nParamCount ; i++ ) { - sal_uInt16 iSbx = (sal_uInt16)(i+1); + sal_uInt16 iSbx = static_cast<sal_uInt16>(i+1); aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ), bBlockConversionToSmallestType ); @@ -1486,7 +1486,7 @@ void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, sal_uInt { for( i = 0 ; i < nParamCount ; i++ ) { - pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (sal_uInt16)(i+1) ), + pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( static_cast<sal_uInt16>(i+1) ), bBlockConversionToSmallestType ); } } @@ -1526,9 +1526,9 @@ Any invokeAutomationMethod( const OUString& Name, Sequence< Any > const & args, for( sal_uInt32 j = 0 ; j < nLen ; j++ ) { sal_Int16 iTarget = pIndices[ j ]; - if( iTarget >= (sal_Int16)nParamCount ) + if( iTarget >= static_cast<sal_Int16>(nParamCount) ) break; - unoToSbxValue( pParams->Get( (sal_uInt16)(j+1) ), pNewValues[ j ] ); + unoToSbxValue( pParams->Get( static_cast<sal_uInt16>(j+1) ), pNewValues[ j ] ); } } return aRetAny; @@ -2061,7 +2061,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { try { - sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (static_cast<sal_uInt32>(pParams->Count()) - 1) : 0; bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() ); Any aRetAny; if ( bCanBeConsideredAMethod && nParamCount ) @@ -2147,7 +2147,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if( pHint->GetId() == SfxHintId::BasicDataWanted ) { // number of Parameter -1 because of Param0 == this - sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (static_cast<sal_uInt32>(pParams->Count()) - 1) : 0; Sequence<Any> args; bool bOutParams = false; sal_uInt32 i; @@ -2200,7 +2200,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) css::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() ); // ATTENTION: Don't forget for Sbx-Parameter the offset! - pAnyArgs[i] = sbxToUnoValue( pParams->Get( (sal_uInt16)(i+1) ), aType ); + pAnyArgs[i] = sbxToUnoValue( pParams->Get( static_cast<sal_uInt16>(i+1) ), aType ); // If it is not certain check whether the out-parameter are available. if( !bOutParams ) @@ -2243,7 +2243,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) const ParamInfo& rInfo = pParamInfos[j]; ParamMode aParamMode = rInfo.aMode; if( aParamMode != ParamMode_IN ) - unoToSbxValue( pParams->Get( (sal_uInt16)(j+1) ), pAnyArgs[ j ] ); + unoToSbxValue( pParams->Get( static_cast<sal_uInt16>(j+1) ), pAnyArgs[ j ] ); } } } @@ -3518,7 +3518,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if( pUnoCtor && pHint->GetId() == SfxHintId::BasicDataWanted ) { // Parameter count -1 because of Param0 == this - sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (static_cast<sal_uInt32>(pParams->Count()) - 1) : 0; Sequence<Any> args; Reference< XServiceConstructorDescription > xCtor = pUnoCtor->getServiceCtorDesc(); @@ -3585,7 +3585,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) Any* pAnyArgs = args.getArray(); for( sal_uInt32 i = 0 ; i < nEffectiveParamCount ; i++ ) { - sal_uInt16 iSbx = (sal_uInt16)(i + nSbxParameterOffset + nParameterOffsetByContext); + sal_uInt16 iSbx = static_cast<sal_uInt16>(i + nSbxParameterOffset + nParameterOffsetByContext); // bRestParameterMode allows nEffectiveParamCount > nUnoParamCount Reference< XParameter > xParam; @@ -3650,7 +3650,7 @@ void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) continue; if( xParam->isOut() ) - unoToSbxValue( pParams->Get( (sal_uInt16)(j+1) ), pAnyArgs[ j ] ); + unoToSbxValue( pParams->Get( static_cast<sal_uInt16>(j+1) ), pAnyArgs[ j ] ); } } } @@ -3727,7 +3727,7 @@ void SbUnoSingleton::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { SbxVariable* pVar = pHint->GetVar(); SbxArray* pParams = pVar->GetParameters(); - sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0; + sal_uInt32 nParamCount = pParams ? (static_cast<sal_uInt32>(pParams->Count()) - 1) : 0; sal_uInt32 nAllowedParamCount = 1; Reference < XComponentContext > xContextToUse; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 85b5a2412653..3c28f7a5b765 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1448,7 +1448,7 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, sal_uInt16& nCol, bool bFollowJumps, const SbiImage* pImg ) const { - sal_uInt32 nPC = (sal_uInt32) ( p - reinterpret_cast<const sal_uInt8*>(pImage->GetCode()) ); + sal_uInt32 nPC = static_cast<sal_uInt32>( p - reinterpret_cast<const sal_uInt8*>(pImage->GetCode()) ); while( nPC < pImage->GetCodeSize() ) { SbiOpcode eOp = (SbiOpcode ) ( *p++ ); @@ -1472,7 +1472,7 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, nl |= *p++ << 16 ; nl |= *p++ << 24; nc = *p++; nc |= *p++ << 8; nc |= *p++ << 16 ; nc |= *p++ << 24; - nLine = (sal_uInt16)nl; nCol = (sal_uInt16)nc; + nLine = static_cast<sal_uInt16>(nl); nCol = static_cast<sal_uInt16>(nc); return p; } else if( eOp >= SbiOpcode::SbOP2_START && eOp <= SbiOpcode::SbOP2_END ) @@ -1582,14 +1582,14 @@ SbModule::fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg ) const pImg = pImage; for( sal_uInt32 i = 0; i < pMethods->Count(); i++ ) { - SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get( (sal_uInt16)i ) ); + SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get( static_cast<sal_uInt16>(i) ) ); if( pMeth ) { //fixup method start positions if ( bCvtToLegacy ) pMeth->nStart = pImg->CalcLegacyOffset( pMeth->nStart ); else - pMeth->nStart = pImg->CalcNewOffset( (sal_uInt16)pMeth->nStart ); + pMeth->nStart = pImg->CalcNewOffset( static_cast<sal_uInt16>(pMeth->nStart) ); } } @@ -1986,7 +1986,7 @@ bool SbMethod::LoadData( SvStream& rStrm, sal_uInt16 nVer ) sal_uInt16 nFlag; rStrm.ReadUInt16( nFlag ); - sal_Int16 nTempStart = (sal_Int16)nStart; + sal_Int16 nTempStart = static_cast<sal_Int16>(nStart); if( nVer == 2 ) { diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx index c863d92085bf..7b8feaa36165 100644 --- a/basic/source/comp/buffer.cxx +++ b/basic/source/comp/buffer.cxx @@ -109,10 +109,10 @@ void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val ) sal_uInt16 val1 = static_cast<sal_uInt16>( val & 0xFFFF ); sal_uInt16 val2 = static_cast<sal_uInt16>( val >> 16 ); sal_uInt8* p = reinterpret_cast<sal_uInt8*>(pBuf.get()) + off; - *p++ = (char) ( val1 & 0xFF ); - *p++ = (char) ( val1 >> 8 ); - *p++ = (char) ( val2 & 0xFF ); - *p = (char) ( val2 >> 8 ); + *p++ = static_cast<char>( val1 & 0xFF ); + *p++ = static_cast<char>( val1 >> 8 ); + *p++ = static_cast<char>( val2 & 0xFF ); + *p = static_cast<char>( val2 >> 8 ); } } @@ -139,10 +139,10 @@ void SbiBuffer::Chain( sal_uInt32 off ) pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "BACKCHAIN" ); break; } - *ip++ = (char) ( val1 & 0xFF ); - *ip++ = (char) ( val1 >> 8 ); - *ip++ = (char) ( val2 & 0xFF ); - *ip = (char) ( val2 >> 8 ); + *ip++ = static_cast<char>( val1 & 0xFF ); + *ip++ = static_cast<char>( val1 >> 8 ); + *ip++ = static_cast<char>( val2 & 0xFF ); + *ip = static_cast<char>( val2 >> 8 ); } while( i ); } } @@ -151,7 +151,7 @@ void SbiBuffer::operator +=( sal_Int8 n ) { if( Check( 1 ) ) { - *pCur++ = (char) n; + *pCur++ = static_cast<char>(n); nOff += 1; } } @@ -160,7 +160,7 @@ bool SbiBuffer::operator +=( sal_uInt8 n ) { if( Check( 1 ) ) { - *pCur++ = (char) n; + *pCur++ = static_cast<char>(n); nOff += 1; return true; } @@ -174,8 +174,8 @@ void SbiBuffer::operator +=( sal_Int16 n ) { if( Check( 2 ) ) { - *pCur++ = (char) ( n & 0xFF ); - *pCur++ = (char) ( n >> 8 ); + *pCur++ = static_cast<char>( n & 0xFF ); + *pCur++ = static_cast<char>( n >> 8 ); nOff += 2; } } @@ -184,8 +184,8 @@ bool SbiBuffer::operator +=( sal_uInt16 n ) { if( Check( 2 ) ) { - *pCur++ = (char) ( n & 0xFF ); - *pCur++ = (char) ( n >> 8 ); + *pCur++ = static_cast<char>( n & 0xFF ); + *pCur++ = static_cast<char>( n >> 8 ); nOff += 2; return true; } @@ -212,7 +212,7 @@ bool SbiBuffer::operator +=( sal_uInt32 n ) void SbiBuffer::operator +=( sal_Int32 n ) { - operator +=( (sal_uInt32) n ); + operator +=( static_cast<sal_uInt32>(n) ); } diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx index c46b2618611a..e3615f91f4e7 100644 --- a/basic/source/comp/exprgen.cxx +++ b/basic/source/comp/exprgen.cxx @@ -68,7 +68,7 @@ void SbiExprNode::Gen( SbiCodeGen& rGen, RecursiveMode eRecMode ) rGen.Gen( SbiOpcode::EMPTY_ ); break; case SbxINTEGER: - rGen.Gen( SbiOpcode::CONST_, (short) nVal ); + rGen.Gen( SbiOpcode::CONST_, static_cast<short>(nVal) ); break; case SbxSTRING: nStringId = rGen.GetParser()->aGblStrings.Add( aStrVal ); diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx index ffe7509fe31b..55131fc1c14d 100644 --- a/basic/source/comp/exprnode.cxx +++ b/basic/source/comp/exprnode.cxx @@ -155,7 +155,7 @@ void SbiExprNode::ConvertToIntConstIfPossible() double n; if( nVal >= SbxMININT && nVal <= SbxMAXINT && modf( nVal, &n ) == 0 ) { - nVal = (double) (short) nVal; + nVal = static_cast<double>(static_cast<short>(nVal)); eType = SbxINTEGER; } } @@ -393,15 +393,15 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* pParser) } else nVal = llMod - lrMod * (llMod/lrMod); eType = SbxLONG; break; case AND: - nVal = (double) ( ll & lr ); eType = SbxLONG; break; + nVal = static_cast<double>( ll & lr ); eType = SbxLONG; break; case OR: - nVal = (double) ( ll | lr ); eType = SbxLONG; break; + nVal = static_cast<double>( ll | lr ); eType = SbxLONG; break; case XOR: - nVal = (double) ( ll ^ lr ); eType = SbxLONG; break; + nVal = static_cast<double>( ll ^ lr ); eType = SbxLONG; break; case EQV: - nVal = (double) ( ~ll ^ lr ); eType = SbxLONG; break; + nVal = static_cast<double>( ~ll ^ lr ); eType = SbxLONG; break; case IMP: - nVal = (double) ( ~ll | lr ); eType = SbxLONG; break; + nVal = static_cast<double>( ~ll | lr ); eType = SbxLONG; break; default: break; } @@ -413,7 +413,7 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* pParser) && nVal >= SbxMINLNG && nVal <= SbxMAXLNG ) { // Decimal place away - long n = (long) nVal; + long n = static_cast<long>(nVal); nVal = n; eType = ( n >= SbxMININT && n <= SbxMAXINT ) ? SbxINTEGER : SbxLONG; @@ -453,7 +453,7 @@ void SbiExprNode::FoldConstantsUnaryNode(SbiParser* pParser) pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW ); bError = true; } - nVal = (double) ~((long) nVal); + nVal = static_cast<double>(~static_cast<long>(nVal)); eType = SbxLONG; } break; default: break; diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 6c960170870b..229f415fc3c8 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -886,7 +886,7 @@ short SbiConstExpression::GetShortValue() pParser->Error( ERRCODE_BASIC_OUT_OF_RANGE ); } - return (short) n; + return static_cast<short>(n); } } diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index ff16b016f154..553f9707a060 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -766,7 +766,7 @@ void SbiParser::Option() { if( nVal == 0 || nVal == 1 ) { - nBase = (short) nVal; + nBase = static_cast<short>(nVal); break; } } diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index 2ecb7310d543..8b038834d8c7 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -489,7 +489,7 @@ bool SbiScanner::NextSym() ++nCol; } sal_Int32 ls = static_cast<sal_Int32>(lu); - nVal = (double) ls; + nVal = static_cast<double>(ls); eScanType = ( ls >= SbxMININT && ls <= SbxMAXINT ) ? SbxINTEGER : SbxLONG; if( bOverflow ) GenError( ERRCODE_BASIC_MATH_OVERFLOW ); diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index 6d9afd861021..bef0fdb577d9 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -59,7 +59,7 @@ short SbiStringPool::Add( const OUString& rVal ) } aData.push_back(rVal); - return (short) ++n; + return static_cast<short>(++n); } short SbiStringPool::Add( double n, SbxDataType t ) @@ -67,9 +67,9 @@ short SbiStringPool::Add( double n, SbxDataType t ) char buf[ 40 ]; switch( t ) { - case SbxINTEGER: snprintf( buf, sizeof(buf), "%d", (short) n ); break; - case SbxLONG: snprintf( buf, sizeof(buf), "%ld", (long) n ); break; - case SbxSINGLE: snprintf( buf, sizeof(buf), "%.6g", (float) n ); break; + case SbxINTEGER: snprintf( buf, sizeof(buf), "%d", static_cast<short>(n) ); break; + case SbxLONG: snprintf( buf, sizeof(buf), "%ld", static_cast<long>(n) ); break; + case SbxSINGLE: snprintf( buf, sizeof(buf), "%.6g", static_cast<float>(n) ); break; case SbxDOUBLE: snprintf( buf, sizeof(buf), "%.16g", n ); break; default: break; } @@ -90,7 +90,7 @@ SbiSymPool::~SbiSymPool() SbiSymDef* SbiSymPool::First() { - nCur = (sal_uInt16) -1; + nCur = sal_uInt16(-1); return Next(); } @@ -303,7 +303,7 @@ void SbiSymDef::SetType( SbxDataType t ) sal_Unicode cu = aName[0]; if( cu < 256 ) { - unsigned char ch = (unsigned char)cu; + unsigned char ch = static_cast<unsigned char>(cu); if( ch == '_' ) { ch = 'Z'; diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx index cc1d82ac2347..0751e7de4c21 100644 --- a/basic/source/inc/expr.hxx +++ b/basic/source/inc/expr.hxx @@ -137,7 +137,7 @@ public: SbiSymDef* GetRealVar(); // last variable in x.y.z SbiExprNode* GetRealNode(); // last node in x.y.z const OUString& GetString() { return aStrVal; } - short GetNumber() { return (short)nVal; } + short GetNumber() { return static_cast<short>(nVal); } SbiExprList* GetParameters() { return aVar.pPar; } void Optimize(SbiParser*); // tree matching diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index d1f4206c31c5..05adf06d3049 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -217,7 +217,7 @@ void SbRtl_Error(StarBASIC * pBasic, SbxArray & rPar, bool) } else { - nErr = StarBASIC::GetSfxFromVBError( (sal_uInt16)nCode ); + nErr = StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(nCode) ); } } @@ -788,9 +788,9 @@ void SbRtl_FileLen(StarBASIC *, SbxArray & rPar, bool) DirectoryItem::get( getFullPath( aStr ), aItem ); FileStatus aFileStatus( osl_FileStatus_Mask_FileSize ); aItem.getFileStatus( aFileStatus ); - nLen = (sal_Int32)aFileStatus.getFileSize(); + nLen = static_cast<sal_Int32>(aFileStatus.getFileSize()); } - rPar.Get(0)->PutLong( (long)nLen ); + rPar.Get(0)->PutLong( static_cast<long>(nLen) ); } } @@ -1583,7 +1583,7 @@ void SbRtl_String(StarBASIC *, SbxArray & rPar, bool) } if( rPar.Get(2)->GetType() == SbxINTEGER ) { - aFiller = (sal_Unicode)rPar.Get(2)->GetInteger(); + aFiller = static_cast<sal_Unicode>(rPar.Get(2)->GetInteger()); } else { @@ -1657,7 +1657,7 @@ void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) if ( aStr.getLength() > 1 && aStr[0] == '&' ) { int nRadix = 10; - char aChar = (char)aStr[1]; + char aChar = static_cast<char>(aStr[1]); if ( aChar == 'h' || aChar == 'H' ) { nRadix = 16; @@ -1669,8 +1669,8 @@ void SbRtl_Val(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) if ( nRadix != 10 ) { OString aByteStr(OUStringToOString(aStr, osl_getThreadTextEncoding())); - sal_Int16 nlResult = (sal_Int16)strtol( aByteStr.getStr()+2, &pEndPtr, nRadix); - nResult = (double)nlResult; + sal_Int16 nlResult = static_cast<sal_Int16>(strtol( aByteStr.getStr()+2, &pEndPtr, nRadix)); + nResult = static_cast<double>(nlResult); } } else @@ -1704,17 +1704,17 @@ sal_Int16 implGetDateDay( double aDate ) Date aRefDate( 1, 1, 1900 ); aRefDate.AddDays( aDate ); - sal_Int16 nRet = (sal_Int16)( aRefDate.GetDay() ); + sal_Int16 nRet = static_cast<sal_Int16>( aRefDate.GetDay() ); return nRet; } sal_Int16 implGetDateMonth( double aDate ) { Date aRefDate( 1,1,1900 ); - sal_Int32 nDays = (sal_Int32)aDate; + sal_Int32 nDays = static_cast<sal_Int32>(aDate); nDays -= 2; // standardize: 1.1.1900 => 0.0 aRefDate.AddDays( nDays ); - sal_Int16 nRet = (sal_Int16)( aRefDate.GetMonth() ); + sal_Int16 nRet = static_cast<sal_Int16>( aRefDate.GetMonth() ); return nRet; } @@ -1962,8 +1962,8 @@ void SbRtl_CDateFromIso(StarBASIC *, SbxArray & rPar, bool) } double dDate; - if (!implDateSerial( (sal_Int16)(nSign * aYearStr.toInt32()), - (sal_Int16)aMonthStr.toInt32(), (sal_Int16)aDayStr.toInt32(), bUseTwoDigitYear, false, dDate )) + if (!implDateSerial( static_cast<sal_Int16>(nSign * aYearStr.toInt32()), + static_cast<sal_Int16>(aMonthStr.toInt32()), static_cast<sal_Int16>(aDayStr.toInt32()), bUseTwoDigitYear, false, dDate )) break; rPar.Get(0)->PutDate( dDate ); @@ -2155,8 +2155,8 @@ sal_Int16 implGetHour( double dDate ) { double nFrac = dDate - floor( dDate ); nFrac *= 86400.0; - sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5); - sal_Int16 nHour = (sal_Int16)(nSeconds / 3600); + sal_Int32 nSeconds = static_cast<sal_Int32>(nFrac + 0.5); + sal_Int16 nHour = static_cast<sal_Int16>(nSeconds / 3600); return nHour; } @@ -2205,13 +2205,13 @@ sal_Int16 implGetSecond( double dDate ) { double nFrac = dDate - floor( dDate ); nFrac *= 86400.0; - sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5); - sal_Int16 nTemp = (sal_Int16)(nSeconds / 3600); + sal_Int32 nSeconds = static_cast<sal_Int32>(nFrac + 0.5); + sal_Int16 nTemp = static_cast<sal_Int16>(nSeconds / 3600); nSeconds -= nTemp * 3600; - nTemp = (sal_Int16)(nSeconds / 60); + nTemp = static_cast<sal_Int16>(nSeconds / 60); nSeconds -= nTemp * 60; - sal_Int16 nRet = (sal_Int16)nSeconds; + sal_Int16 nRet = static_cast<sal_Int16>(nSeconds); return nRet; } @@ -2233,12 +2233,12 @@ double Now_Impl() { Date aDate( Date::SYSTEM ); tools::Time aTime( tools::Time::SYSTEM ); - double aSerial = (double)GetDayDiff( aDate ); + double aSerial = static_cast<double>(GetDayDiff( aDate )); long nSeconds = aTime.GetHour(); nSeconds *= 3600; nSeconds += aTime.GetMin() * 60; nSeconds += aTime.GetSec(); - double nDays = ((double)nSeconds) / (24.0*3600.0); + double nDays = static_cast<double>(nSeconds) / (24.0*3600.0); aSerial += nDays; return aSerial; } @@ -2274,7 +2274,7 @@ void SbRtl_Time(StarBASIC *, SbxArray & rPar, bool bWrite) nSeconds *= 3600; nSeconds += aTime.GetMin() * 60; nSeconds += aTime.GetSec(); - double nDays = (double)nSeconds * ( 1.0 / (24.0*3600.0) ); + double nDays = static_cast<double>(nSeconds) * ( 1.0 / (24.0*3600.0) ); Color* pCol; std::shared_ptr<SvNumberFormatter> pFormatter; @@ -2307,7 +2307,7 @@ void SbRtl_Timer(StarBASIC *, SbxArray & rPar, bool) nSeconds *= 3600; nSeconds += aTime.GetMin() * 60; nSeconds += aTime.GetSec(); - rPar.Get(0)->PutDate( (double)nSeconds ); + rPar.Get(0)->PutDate( static_cast<double>(nSeconds) ); } @@ -2316,7 +2316,7 @@ void SbRtl_Date(StarBASIC *, SbxArray & rPar, bool bWrite) if ( !bWrite ) { Date aToday( Date::SYSTEM ); - double nDays = (double)GetDayDiff( aToday ); + double nDays = static_cast<double>(GetDayDiff( aToday )); SbxVariable* pMeth = rPar.Get( 0 ); if( pMeth->IsString() ) { @@ -3059,12 +3059,12 @@ void SbRtl_FileDateTime(StarBASIC *, SbxArray & rPar, bool) aDate = Date( aDT.Day, aDT.Month, aDT.Year ); } - double fSerial = (double)GetDayDiff( aDate ); + double fSerial = static_cast<double>(GetDayDiff( aDate )); long nSeconds = aTime.GetHour(); nSeconds *= 3600; nSeconds += aTime.GetMin() * 60; nSeconds += aTime.GetSec(); - double nDays = ((double)nSeconds) / (24.0*3600.0); + double nDays = static_cast<double>(nSeconds) / (24.0*3600.0); fSerial += nDays; Color* pCol; @@ -3200,7 +3200,7 @@ void SbRtl_Loc(StarBASIC *, SbxArray & rPar, bool) { nPos = pSvStrm->Tell(); } - rPar.Get(0)->PutLong( (sal_Int32)nPos ); + rPar.Get(0)->PutLong( static_cast<sal_Int32>(nPos) ); } } @@ -3225,7 +3225,7 @@ void SbRtl_Lof(StarBASIC *, SbxArray & rPar, bool) sal_uInt64 const nOldPos = pSvStrm->Tell(); sal_uInt64 const nLen = pSvStrm->Seek( STREAM_SEEK_TO_END ); pSvStrm->Seek( nOldPos ); - rPar.Get(0)->PutLong( (sal_Int32)nLen ); + rPar.Get(0)->PutLong( static_cast<sal_Int32>(nLen) ); } } @@ -3233,7 +3233,7 @@ void SbRtl_Lof(StarBASIC *, SbxArray & rPar, bool) void SbRtl_Seek(StarBASIC *, SbxArray & rPar, bool) { // No changes for UCB - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs < 2 || nArgs > 3 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3257,7 +3257,7 @@ void SbRtl_Seek(StarBASIC *, SbxArray & rPar, bool) nPos = nPos / pSbStrm->GetBlockLen(); } nPos++; // Basic counts from 1 - rPar.Get(0)->PutLong( (sal_Int32)nPos ); + rPar.Get(0)->PutLong( static_cast<sal_Int32>(nPos) ); } else // Seek-Statement { @@ -3341,7 +3341,7 @@ void SbRtl_Randomize(StarBASIC *, SbxArray & rPar, bool) } if( rPar.Count() == 2 ) { - int nSeed = (int)rPar.Get(1)->GetInteger(); + int nSeed = static_cast<int>(rPar.Get(1)->GetInteger()); theRandomNumberGenerator::get().global_rng.seed(nSeed); } // without parameter, no need to do anything - RNG is seeded at first use @@ -3545,7 +3545,7 @@ void SbRtl_VarType(StarBASIC *, SbxArray & rPar, bool) else { SbxDataType eType = rPar.Get(1)->GetType(); - rPar.Get(0)->PutInteger( (sal_Int16)eType ); + rPar.Get(0)->PutInteger( static_cast<sal_Int16>(eType) ); } } @@ -3709,7 +3709,7 @@ void SbRtl_Len(StarBASIC *, SbxArray & rPar, bool) void SbRtl_DDEInitiate(StarBASIC *, SbxArray & rPar, bool) { - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs != 3 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3734,7 +3734,7 @@ void SbRtl_DDEInitiate(StarBASIC *, SbxArray & rPar, bool) void SbRtl_DDETerminate(StarBASIC *, SbxArray & rPar, bool) { rPar.Get(0)->PutEmpty(); - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs != 2 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3752,7 +3752,7 @@ void SbRtl_DDETerminate(StarBASIC *, SbxArray & rPar, bool) void SbRtl_DDETerminateAll(StarBASIC *, SbxArray & rPar, bool) { rPar.Get(0)->PutEmpty(); - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs != 1 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3769,7 +3769,7 @@ void SbRtl_DDETerminateAll(StarBASIC *, SbxArray & rPar, bool) void SbRtl_DDERequest(StarBASIC *, SbxArray & rPar, bool) { - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs != 3 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3793,7 +3793,7 @@ void SbRtl_DDERequest(StarBASIC *, SbxArray & rPar, bool) void SbRtl_DDEExecute(StarBASIC *, SbxArray & rPar, bool) { rPar.Get(0)->PutEmpty(); - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs != 3 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3812,7 +3812,7 @@ void SbRtl_DDEExecute(StarBASIC *, SbxArray & rPar, bool) void SbRtl_DDEPoke(StarBASIC *, SbxArray & rPar, bool) { rPar.Get(0)->PutEmpty(); - int nArgs = (int)rPar.Count(); + int nArgs = static_cast<int>(rPar.Count()); if ( nArgs != 4 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -3865,7 +3865,7 @@ void SbRtl_LBound(StarBASIC *, SbxArray & rPar, bool) if( pArr ) { sal_Int32 nLower, nUpper; - short nDim = (nParCount == 3) ? (short)rPar.Get(2)->GetInteger() : 1; + short nDim = (nParCount == 3) ? static_cast<short>(rPar.Get(2)->GetInteger()) : 1; if( !pArr->GetDim32( nDim, nLower, nUpper ) ) StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE ); else @@ -3889,7 +3889,7 @@ void SbRtl_UBound(StarBASIC *, SbxArray & rPar, bool) if( pArr ) { sal_Int32 nLower, nUpper; - short nDim = (nParCount == 3) ? (short)rPar.Get(2)->GetInteger() : 1; + short nDim = (nParCount == 3) ? static_cast<short>(rPar.Get(2)->GetInteger()) : 1; if( !pArr->GetDim32( nDim, nLower, nUpper ) ) StarBASIC::Error( ERRCODE_BASIC_OUT_OF_RANGE ); else @@ -4234,7 +4234,7 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool) MessBoxStyle nWinBits; WinBits nType = 0; // MB_OK if( nArgCount >= 3 ) - nType = (WinBits)rPar.Get(2)->GetInteger(); + nType = static_cast<WinBits>(rPar.Get(2)->GetInteger()); WinBits nStyle = nType; nStyle &= 15; // delete bits 4-16 if( nStyle > 5 ) @@ -4539,7 +4539,7 @@ static long GetDayDiff( const Date& rDate ) sal_Int16 implGetDateYear( double aDate ) { Date aRefDate( 1,1,1900 ); - long nDays = (long) aDate; + long nDays = static_cast<long>(aDate); nDays -= 2; // standardize: 1.1.1900 => 0.0 aRefDate.AddDays( nDays ); sal_Int16 nRet = aRefDate.GetYear(); @@ -4635,7 +4635,7 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, } long nDiffDays = GetDayDiff( aCurDate ); - rdRet = (double)nDiffDays; + rdRet = static_cast<double>(nDiffDays); return true; } @@ -4664,8 +4664,8 @@ sal_Int16 implGetMinute( double dDate ) { double nFrac = dDate - floor( dDate ); nFrac *= 86400.0; - sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5); - sal_Int16 nTemp = (sal_Int16)(nSeconds % 3600); + sal_Int32 nSeconds = static_cast<sal_Int32>(nFrac + 0.5); + sal_Int16 nTemp = static_cast<sal_Int16>(nSeconds % 3600); sal_Int16 nMin = nTemp / 60; return nMin; } diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index f6d404dd548d..aa7d009be0a8 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -366,7 +366,7 @@ void SbRtl_CLng(StarBASIC *, SbxArray & rPar, bool) // JSM void SbRtl_CSng(StarBASIC *, SbxArray & rPar, bool) // JSM { - float nVal = (float)0.0; + float nVal = float(0.0); if ( rPar.Count() == 2 ) { SbxVariable *pSbxVariable = rPar.Get(1); @@ -380,7 +380,7 @@ void SbRtl_CSng(StarBASIC *, SbxArray & rPar, bool) // JSM { StarBASIC::Error( Error ); } - nVal = (float)dVal; + nVal = static_cast<float>(dVal); } else { @@ -504,7 +504,7 @@ void SbRtl_Red(StarBASIC *, SbxArray & rPar, bool) sal_Int32 nRGB = rPar.Get(1)->GetLong(); nRGB &= 0x00FF0000; nRGB >>= 16; - rPar.Get(0)->PutInteger( (sal_Int16)nRGB ); + rPar.Get(0)->PutInteger( static_cast<sal_Int16>(nRGB) ); } } @@ -519,7 +519,7 @@ void SbRtl_Green(StarBASIC *, SbxArray & rPar, bool) sal_Int32 nRGB = rPar.Get(1)->GetLong(); nRGB &= 0x0000FF00; nRGB >>= 8; - rPar.Get(0)->PutInteger( (sal_Int16)nRGB ); + rPar.Get(0)->PutInteger( static_cast<sal_Int16>(nRGB) ); } } @@ -533,7 +533,7 @@ void SbRtl_Blue(StarBASIC *, SbxArray & rPar, bool) { sal_Int32 nRGB = rPar.Get(1)->GetLong(); nRGB &= 0x000000FF; - rPar.Get(0)->PutInteger( (sal_Int16)nRGB ); + rPar.Get(0)->PutInteger( static_cast<sal_Int16>(nRGB) ); } } @@ -574,7 +574,7 @@ void Wait_Impl( bool bDurationBased, SbxArray& rPar ) double dWait = rPar.Get(1)->GetDouble(); double dNow = Now_Impl(); double dSecs = ( dWait - dNow ) * 24.0 * 3600.0; - nWait = (long)( dSecs * 1000 ); // wait in thousands of sec + nWait = static_cast<long>( dSecs * 1000 ); // wait in thousands of sec } else { @@ -1051,7 +1051,7 @@ static bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm, { sal_uInt32 aInt; pStrm->ReadUInt32( aInt ); - rVar.PutInt64( (sal_Int64)aInt ); + rVar.PutInt64( static_cast<sal_Int64>(aInt) ); } break; case SbxSINGLE: @@ -1387,7 +1387,7 @@ void SbRtl_TypeLen(StarBASIC *, SbxArray & rPar, bool) case SbxLPWSTR: case SbxCoreSTRING: case SbxSTRING: - nLen = (sal_Int16)rPar.Get(1)->GetOUString().getLength(); + nLen = static_cast<sal_Int16>(rPar.Get(1)->GetOUString().getLength()); break; default: @@ -1715,7 +1715,7 @@ void SbRtl_WeekdayName(StarBASIC *, SbxArray & rPar, bool) } Sequence< CalendarItem2 > aDaySeq = xCalendar->getDays2(); - sal_Int16 nDayCount = (sal_Int16)aDaySeq.getLength(); + sal_Int16 nDayCount = static_cast<sal_Int16>(aDaySeq.getLength()); sal_Int16 nDay = rPar.Get(1)->GetInteger(); sal_Int16 nFirstDay = 0; if( nParCount == 4 ) @@ -1853,7 +1853,7 @@ inline sal_Int16 limitDate( sal_Int32 n32Year, sal_Int16& rMonth, sal_Int16& rDa rMonth = 1; rDay = 1; } - return (sal_Int16)n32Year; + return static_cast<sal_Int16>(n32Year); } void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool) @@ -1912,12 +1912,12 @@ void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool) if( pInfo->meInterval == INTERVAL_Q ) { nYearsAdd = lNumber / 4; - nMonthAdd = (sal_Int16)( 3 * (lNumber % 4) ); + nMonthAdd = static_cast<sal_Int16>( 3 * (lNumber % 4) ); } else { nYearsAdd = lNumber / 12; - nMonthAdd = (sal_Int16)( lNumber % 12 ); + nMonthAdd = static_cast<sal_Int16>( lNumber % 12 ); } sal_Int32 nTargetYear; @@ -1929,7 +1929,7 @@ void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool) nTargetMonth += 12; nYearsAdd++; } - nTargetYear = (sal_Int32)nYear - nYearsAdd; + nTargetYear = static_cast<sal_Int32>(nYear) - nYearsAdd; } else { @@ -1939,7 +1939,7 @@ void SbRtl_DateAdd(StarBASIC *, SbxArray & rPar, bool) nTargetMonth -= 12; nYearsAdd++; } - nTargetYear = (sal_Int32)nYear + nYearsAdd; + nTargetYear = static_cast<sal_Int32>(nYear) + nYearsAdd; } nTargetYear16 = limitDate( nTargetYear, nTargetMonth, nDay ); /* TODO: should the result be error if the date was limited? It never was. */ @@ -3043,13 +3043,13 @@ void SbRtl_Me(StarBASIC *, SbxArray & rPar, bool) sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam, sal_Int16 nFirstDay ) { Date aRefDate( 1,1,1900 ); - sal_Int32 nDays = (sal_Int32) aDate; + sal_Int32 nDays = static_cast<sal_Int32>(aDate); nDays -= 2; // normalize: 1.1.1900 => 0 aRefDate.AddDays( nDays); DayOfWeek aDay = aRefDate.GetDayOfWeek(); sal_Int16 nDay; if ( aDay != SUNDAY ) - nDay = (sal_Int16)aDay + 2; + nDay = static_cast<sal_Int16>(aDay) + 2; else nDay = 1; // 1 == Sunday diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx index d2d6d26f2425..8822aefba8f3 100644 --- a/basic/source/runtime/props.cxx +++ b/basic/source/runtime/props.cxx @@ -46,7 +46,7 @@ void SbRtl_Err(StarBASIC *, SbxArray & rPar, bool bWrite) { sal_Int32 nVal = rPar.Get( 0 )->GetLong(); if( nVal <= 65535 ) - StarBASIC::Error( StarBASIC::GetSfxFromVBError( (sal_uInt16) nVal ) ); + StarBASIC::Error( StarBASIC::GetSfxFromVBError( static_cast<sal_uInt16>(nVal) ) ); } else rPar.Get( 0 )->PutLong( StarBASIC::GetVBErrorCode( StarBASIC::GetErrBasic() ) ); diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index e4353dba40c5..63fe8c580ad8 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -998,7 +998,7 @@ SbxVariable* SbiRuntime::GetTOS() return new SbxVariable; } #endif - return refExprStk->Get( (sal_uInt16) n ); + return refExprStk->Get( static_cast<sal_uInt16>(n) ); } @@ -2923,7 +2923,7 @@ void SbiRuntime::StepONJUMP( sal_uInt32 nOp1 ) } if( n < 1 || static_cast<sal_uInt32>(n) > nOp1 ) n = static_cast<sal_Int16>( nOp1 + 1 ); - nOp1 = (sal_uInt32) ( reinterpret_cast<const char*>(pCode) - pImg->GetCode() ) + 5 * --n; + nOp1 = static_cast<sal_uInt32>( reinterpret_cast<const char*>(pCode) - pImg->GetCode() ) + 5 * --n; StepJUMP( nOp1 ); } @@ -3798,7 +3798,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) { if( xIndexAccess.is() ) { - sal_uInt32 nParamCount = (sal_uInt32)pPar->Count() - 1; + sal_uInt32 nParamCount = static_cast<sal_uInt32>(pPar->Count()) - 1; if( nParamCount != 1 ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); @@ -4038,7 +4038,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) if( pParam && ( pParam->nFlags & SbxFlagBits::Optional ) ) { // Default value? - sal_uInt16 nDefaultId = (sal_uInt16)(pParam->nUserData & 0x0ffff); + sal_uInt16 nDefaultId = static_cast<sal_uInt16>(pParam->nUserData & 0x0ffff); if( nDefaultId > 0 ) { OUString aDefaultStr = pImg->GetString( nDefaultId ); diff --git a/basic/source/runtime/stdobj1.cxx b/basic/source/runtime/stdobj1.cxx index 6c464cd0af4f..9060fb318bc5 100644 --- a/basic/source/runtime/stdobj1.cxx +++ b/basic/source/runtime/stdobj1.cxx @@ -88,7 +88,7 @@ void SbStdPicture::PropWidth( SbxVariable* pVar, bool bWrite ) aSize = Application::GetAppWindow()->LogicToPixel( aSize, aGraphic.GetPrefMapMode() ); aSize = Application::GetAppWindow()->PixelToLogic( aSize, MapMode( MapUnit::MapTwip ) ); - pVar->PutInteger( (sal_Int16)aSize.Width() ); + pVar->PutInteger( static_cast<sal_Int16>(aSize.Width()) ); } void SbStdPicture::PropHeight( SbxVariable* pVar, bool bWrite ) @@ -103,7 +103,7 @@ void SbStdPicture::PropHeight( SbxVariable* pVar, bool bWrite ) aSize = Application::GetAppWindow()->LogicToPixel( aSize, aGraphic.GetPrefMapMode() ); aSize = Application::GetAppWindow()->PixelToLogic( aSize, MapMode( MapUnit::MapTwip ) ); - pVar->PutInteger( (sal_Int16)aSize.Height() ); + pVar->PutInteger( static_cast<sal_Int16>(aSize.Height()) ); } @@ -192,9 +192,9 @@ void SbStdFont::PropUnderline( SbxVariable* pVar, bool bWrite ) void SbStdFont::PropSize( SbxVariable* pVar, bool bWrite ) { if( bWrite ) - SetSize( (sal_uInt16)pVar->GetInteger() ); + SetSize( static_cast<sal_uInt16>(pVar->GetInteger()) ); else - pVar->PutInteger( (sal_Int16)GetSize() ); + pVar->PutInteger( static_cast<sal_Int16>(GetSize()) ); } void SbStdFont::PropName( SbxVariable* pVar, bool bWrite ) diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index 911a692c1def..a082c1c523e4 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -106,7 +106,7 @@ sal_uInt16 SbxArray::Count() const { sal_uInt32 nCount = mVarEntries.size(); DBG_ASSERT( nCount <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" ); - return (sal_uInt16)nCount; + return static_cast<sal_uInt16>(nCount); } SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx ) @@ -608,8 +608,8 @@ bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const { sal_Int32 rlb32, rub32; bool bRet = GetDim32( n, rlb32, rub32 ); - rub = (short)rub32; - rlb = (short)rlb32; + rub = static_cast<short>(rub32); + rlb = static_cast<short>(rlb32); if( bRet ) { if( rlb32 < -SBX_MAXINDEX || rub32 > SBX_MAXINDEX ) @@ -631,7 +631,7 @@ sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx ) sal_Int32 nIdx = *pIdx++; if( nIdx < rDimension.nLbound || nIdx > rDimension.nUbound ) { - nPos = (sal_uInt32)SBX_MAXINDEX32 + 1; break; + nPos = sal_uInt32(SBX_MAXINDEX32) + 1; break; } nPos = nPos * rDimension.nSize + nIdx - rDimension.nLbound; } @@ -662,7 +662,7 @@ sal_uInt16 SbxDimArray::Offset( const short* pIdx ) SetError( ERRCODE_BASIC_OUT_OF_RANGE ); nPos = 0; } - return (sal_uInt16) nPos; + return static_cast<sal_uInt16>(nPos); } SbxVariable* SbxDimArray::Get( const short* pIdx ) @@ -705,12 +705,12 @@ sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar ) sal_Int32 nIdx = pPar->Get( nOff++ )->GetLong(); if( nIdx < it->nLbound || nIdx > it->nUbound ) { - nPos = (sal_uInt32) SBX_MAXINDEX32+1; + nPos = sal_uInt32(SBX_MAXINDEX32)+1; break; } nPos = nPos * it->nSize + nIdx - it->nLbound; } - if( nPos > (sal_uInt32) SBX_MAXINDEX32 ) + if( nPos > sal_uInt32(SBX_MAXINDEX32) ) { SetError( ERRCODE_BASIC_OUT_OF_RANGE ); nPos = 0; diff --git a/basic/source/sbx/sbxbool.cxx b/basic/source/sbx/sbxbool.cxx index 5ce72334280d..720c63378384 100644 --- a/basic/source/sbx/sbxbool.cxx +++ b/basic/source/sbx/sbxbool.cxx @@ -144,19 +144,19 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) switch( +p->eType ) { case SbxCHAR: - p->nChar = (sal_Unicode) n; break; + p->nChar = static_cast<sal_Unicode>(n); break; case SbxUINT: - p->nByte = (sal_uInt8) n; break; + p->nByte = static_cast<sal_uInt8>(n); break; case SbxINTEGER: case SbxBOOL: p->nInteger = n; break; case SbxLONG: p->nLong = n; break; case SbxULONG: - p->nULong = (sal_uInt32) n; break; + p->nULong = static_cast<sal_uInt32>(n); break; case SbxERROR: case SbxUSHORT: - p->nUShort = (sal_uInt16) n; break; + p->nUShort = static_cast<sal_uInt16>(n); break; case SbxSINGLE: p->nSingle = n; break; case SbxDATE: @@ -164,9 +164,9 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) p->nDouble = n; break; case SbxCURRENCY: case SbxSALINT64: - p->nInt64 = (sal_Int64) n; break; + p->nInt64 = static_cast<sal_Int64>(n); break; case SbxSALUINT64: - p->uInt64 = (sal_uInt64) n; break; + p->uInt64 = static_cast<sal_uInt64>(n); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setInt( n ); @@ -191,19 +191,19 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) break; } case SbxBYREF | SbxCHAR: - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: *p->pInteger = n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: *p->pLong = n; break; case SbxBYREF | SbxULONG: - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSINGLE: *p->pSingle = n; break; case SbxBYREF | SbxDATE: @@ -211,9 +211,9 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) *p->pDouble = n; break; case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: - *p->pnInt64 = (sal_Int64) n; break; + *p->pnInt64 = static_cast<sal_Int64>(n); break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = (sal_uInt64) n; break; + *p->puInt64 = static_cast<sal_uInt64>(n); break; default: SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); } diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx index 2eefb718f026..e125dd023ffc 100644 --- a/basic/source/sbx/sbxbyte.cxx +++ b/basic/source/sbx/sbxbyte.cxx @@ -42,10 +42,10 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) p->nChar; + nRes = static_cast<sal_uInt8>(p->nChar); break; case SbxBYTE: - nRes = (sal_uInt8) p->nByte; break; + nRes = static_cast<sal_uInt8>(p->nByte); break; case SbxINTEGER: case SbxBOOL: if( p->nInteger > SbxMAXBYTE ) @@ -57,16 +57,16 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) p->nInteger; + nRes = static_cast<sal_uInt8>(p->nInteger); break; case SbxERROR: case SbxUSHORT: - if( p->nUShort > (sal_uInt16) SbxMAXBYTE ) + if( p->nUShort > sal_uInt16(SbxMAXBYTE) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXBYTE; } else - nRes = (sal_uInt8) p->nUShort; + nRes = static_cast<sal_uInt8>(p->nUShort); break; case SbxLONG: if( p->nLong > SbxMAXBYTE ) @@ -78,7 +78,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) p->nLong; + nRes = static_cast<sal_uInt8>(p->nLong); break; case SbxULONG: if( p->nULong > SbxMAXBYTE ) @@ -86,7 +86,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXBYTE; } else - nRes = (sal_uInt8) p->nULong; + nRes = static_cast<sal_uInt8>(p->nULong); break; case SbxCURRENCY: case SbxSALINT64: @@ -103,7 +103,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) val; + nRes = static_cast<sal_uInt8>(val); break; } case SbxSALUINT64: @@ -112,7 +112,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXBYTE; } else - nRes = (sal_uInt8) p->uInt64; + nRes = static_cast<sal_uInt8>(p->uInt64); break; case SbxSINGLE: if( p->nSingle > SbxMAXBYTE ) @@ -124,7 +124,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) rtl::math::round( p->nSingle ); + nRes = static_cast<sal_uInt8>(rtl::math::round( p->nSingle )); break; case SbxDATE: case SbxDOUBLE: @@ -150,7 +150,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) rtl::math::round( dVal ); + nRes = static_cast<sal_uInt8>(rtl::math::round( dVal )); break; } case SbxBYREF | SbxSTRING: @@ -173,7 +173,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) ( d + 0.5 ); + nRes = static_cast<sal_uInt8>( d + 0.5 ); } break; case SbxOBJECT: @@ -257,14 +257,14 @@ void ImpPutByte( SbxValues* p, sal_uInt8 n ) break; case SbxCHAR: - p->nChar = (sal_Unicode) n; break; + p->nChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: if( !p->pOUString ) p->pOUString = new OUString; - ImpCvtNum( (double) n, 0, *p->pOUString ); + ImpCvtNum( static_cast<double>(n), 0, *p->pOUString ); break; case SbxOBJECT: { @@ -276,7 +276,7 @@ void ImpPutByte( SbxValues* p, sal_uInt8 n ) break; } case SbxBYREF | SbxCHAR: - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: *p->pByte = n; break; case SbxBYREF | SbxINTEGER: diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx index 6249588b39dc..d5f34e63d297 100644 --- a/basic/source/sbx/sbxchar.cxx +++ b/basic/source/sbx/sbxchar.cxx @@ -39,7 +39,7 @@ start: case SbxCHAR: nRes = p->nChar; break; case SbxBYTE: - nRes = (sal_Unicode) p->nByte; + nRes = static_cast<sal_Unicode>(p->nByte); break; case SbxINTEGER: case SbxBOOL: @@ -48,11 +48,11 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (sal_Unicode) p->nInteger; + nRes = static_cast<sal_Unicode>(p->nInteger); break; case SbxERROR: case SbxUSHORT: - nRes = (sal_Unicode) p->nUShort; + nRes = static_cast<sal_Unicode>(p->nUShort); break; case SbxLONG: if( p->nLong > SbxMAXCHAR ) @@ -64,7 +64,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (sal_Unicode) p->nLong; + nRes = static_cast<sal_Unicode>(p->nLong); break; case SbxULONG: if( p->nULong > SbxMAXCHAR ) @@ -72,7 +72,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXCHAR; } else - nRes = (sal_Unicode) p->nULong; + nRes = static_cast<sal_Unicode>(p->nULong); break; case SbxCURRENCY: case SbxSALINT64: @@ -91,7 +91,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (sal_Unicode) val; + nRes = static_cast<sal_Unicode>(val); break; } case SbxSALUINT64: @@ -100,7 +100,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXCHAR; } else - nRes = (sal_Unicode) p->uInt64; + nRes = static_cast<sal_Unicode>(p->uInt64); break; case SbxSINGLE: if( p->nSingle > SbxMAXCHAR ) @@ -112,7 +112,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (sal_Unicode) rtl::math::round( p->nSingle ); + nRes = static_cast<sal_Unicode>(rtl::math::round( p->nSingle )); break; case SbxDATE: case SbxDOUBLE: @@ -138,7 +138,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (sal_uInt8) rtl::math::round( dVal ); + nRes = static_cast<sal_uInt8>(rtl::math::round( dVal )); break; } case SbxBYREF | SbxSTRING: @@ -159,7 +159,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (sal_Unicode) rtl::math::round( d ); + nRes = static_cast<sal_Unicode>(rtl::math::round( d )); } break; case SbxOBJECT: @@ -269,22 +269,22 @@ start: case SbxBYREF | SbxCHAR: *p->pChar = n; break; case SbxBYREF | SbxBYTE: - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: *p->pInteger = n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: - *p->pLong = (sal_Int32) n; break; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) n; break; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) n; break; + *p->pDouble = static_cast<double>(n); break; case SbxBYREF | SbxCURRENCY: p->nInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx index 71da6cc8bee0..c6a3d956a914 100644 --- a/basic/source/sbx/sbxcoll.cxx +++ b/basic/source/sbx/sbxcoll.cxx @@ -201,9 +201,9 @@ void SbxCollection::CollItem( SbxArray* pPar_ ) else { short n = p->GetInteger(); - if( n >= 1 && n <= (short) pObjs->Count() ) + if( n >= 1 && n <= static_cast<short>(pObjs->Count()) ) { - pRes = pObjs->Get( (sal_uInt16) n - 1 ); + pRes = pObjs->Get( static_cast<sal_uInt16>(n) - 1 ); } } if( !pRes ) @@ -223,10 +223,10 @@ void SbxCollection::CollRemove( SbxArray* pPar_ ) else { short n = pPar_->Get( 1 )->GetInteger(); - if( n < 1 || n > (short) pObjs->Count() ) + if( n < 1 || n > static_cast<short>(pObjs->Count()) ) SetError( ERRCODE_BASIC_BAD_INDEX ); else - Remove( pObjs->Get( (sal_uInt16) n - 1 ) ); + Remove( pObjs->Get( static_cast<sal_uInt16>(n) - 1 ) ); } } diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx index 88d066513be4..8a8fd98a7a6d 100644 --- a/basic/source/sbx/sbxconv.hxx +++ b/basic/source/sbx/sbxconv.hxx @@ -70,12 +70,12 @@ sal_Int64 ImpGetCurrency( const SbxValues* ); void ImpPutCurrency( SbxValues*, const sal_Int64 ); 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); + { if (d > 0) return static_cast<sal_Int64>( d * CURRENCY_FACTOR + 0.5); + else return static_cast<sal_Int64>( d * CURRENCY_FACTOR - 0.5); } inline double ImpCurrencyToDouble( const sal_Int64 r ) - { return (double)r / (double)CURRENCY_FACTOR; } + { return static_cast<double>(r) / double(CURRENCY_FACTOR); } // SBXDEC.CXX diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx index 06a71227bf94..2bbf15d8d353 100644 --- a/basic/source/sbx/sbxcurr.cxx +++ b/basic/source/sbx/sbxcurr.cxx @@ -177,23 +177,23 @@ start: case SbxCURRENCY: nRes = p->nInt64; break; case SbxBYTE: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nByte); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(p->nByte); break; case SbxCHAR: - nRes = (sal_Int64)CURRENCY_FACTOR * reinterpret_cast<sal_Int64>(p->pChar); + nRes = sal_Int64(CURRENCY_FACTOR) * reinterpret_cast<sal_Int64>(p->pChar); break; case SbxBOOL: case SbxINTEGER: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nInteger); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(p->nInteger); break; case SbxUSHORT: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nUShort); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(p->nUShort); break; case SbxLONG: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nLong); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(p->nLong); break; case SbxULONG: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nULong); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(p->nULong); break; case SbxSALINT64: @@ -226,25 +226,25 @@ start: #endif //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 ) + if( p->nSingle * CURRENCY_FACTOR + 0.5 > float(SAL_MAX_INT64) + || p->nSingle * CURRENCY_FACTOR - 0.5 < float(SAL_MIN_INT64) ) { nRes = SAL_MAX_INT64; - if( p->nSingle * CURRENCY_FACTOR - 0.5 < (float)SAL_MIN_INT64 ) + if( p->nSingle * CURRENCY_FACTOR - 0.5 < float(SAL_MIN_INT64) ) nRes = SAL_MIN_INT64; SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); break; } - nRes = ImpDoubleToCurrency( (double)p->nSingle ); + nRes = ImpDoubleToCurrency( static_cast<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 ) + if( p->nDouble * CURRENCY_FACTOR + 0.5 > double(SAL_MAX_INT64) + || p->nDouble * CURRENCY_FACTOR - 0.5 < double(SAL_MIN_INT64) ) { nRes = SAL_MAX_INT64; - if( p->nDouble * CURRENCY_FACTOR - 0.5 < (double)SAL_MIN_INT64 ) + if( p->nDouble * CURRENCY_FACTOR - 0.5 < double(SAL_MIN_INT64) ) nRes = SAL_MIN_INT64; SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); break; @@ -285,18 +285,18 @@ start: } case SbxBYREF | SbxCHAR: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pChar); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(*p->pChar); break; case SbxBYREF | SbxBYTE: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pByte); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(*p->pByte); break; case SbxBYREF | SbxBOOL: case SbxBYREF | SbxINTEGER: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pInteger); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(*p->pInteger); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pUShort); + nRes = sal_Int64(CURRENCY_FACTOR) * static_cast<sal_Int64>(*p->pUShort); break; // from here on had to be tested @@ -353,7 +353,7 @@ start: // from here no longer case SbxSINGLE: - p->nSingle = (float)( r / CURRENCY_FACTOR ); break; + p->nSingle = static_cast<float>( r / CURRENCY_FACTOR ); break; case SbxDATE: case SbxDOUBLE: p->nDouble = ImpCurrencyToDouble( r ); break; @@ -401,7 +401,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); val = SbxMINCHAR; } - *p->pChar = (sal_Unicode) val; break; + *p->pChar = static_cast<sal_Unicode>(val); break; } case SbxBYREF | SbxBYTE: { @@ -414,7 +414,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); val = 0; } - *p->pByte = (sal_uInt8) val; break; + *p->pByte = static_cast<sal_uInt8>(val); break; } case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: @@ -428,7 +428,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); val = SbxMININT; } - *p->pInteger = (sal_uInt16) val; break; + *p->pInteger = static_cast<sal_uInt16>(val); break; } case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: @@ -442,7 +442,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); val = 0; } - *p->pUShort = (sal_uInt16) val; break; + *p->pUShort = static_cast<sal_uInt16>(val); break; } case SbxBYREF | SbxLONG: { @@ -455,7 +455,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); val = SbxMINLNG; } - *p->pLong = (sal_Int32) val; break; + *p->pLong = static_cast<sal_Int32>(val); break; } case SbxBYREF | SbxULONG: { @@ -468,16 +468,16 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); val = 0; } - *p->pULong = (sal_uInt32) val; break; + *p->pULong = static_cast<sal_uInt32>(val); break; } case SbxBYREF | SbxCURRENCY: *p->pnInt64 = r; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = r / CURRENCY_FACTOR; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = (sal_uInt64)r / CURRENCY_FACTOR; break; + *p->puInt64 = static_cast<sal_uInt64>(r) / CURRENCY_FACTOR; break; case SbxBYREF | SbxSINGLE: - p->nSingle = (float)( r / CURRENCY_FACTOR ); break; + p->nSingle = static_cast<float>( r / CURRENCY_FACTOR ); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = ImpCurrencyToDouble( r ); break; diff --git a/basic/source/sbx/sbxdate.cxx b/basic/source/sbx/sbxdate.cxx index a7f8c0ebc147..22afc5635d7c 100644 --- a/basic/source/sbx/sbxdate.cxx +++ b/basic/source/sbx/sbxdate.cxx @@ -62,10 +62,10 @@ double ImpGetDate( const SbxValues* p ) nRes = p->nUShort; break; case SbxLONG: - nRes = (double) p->nLong; + nRes = static_cast<double>(p->nLong); break; case SbxULONG: - nRes = (double) p->nULong; + nRes = static_cast<double>(p->nULong); break; case SbxSINGLE: nRes = p->nSingle; @@ -363,7 +363,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } - *p->pChar = (sal_Unicode) n; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) @@ -374,7 +374,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pByte = (sal_uInt8) n; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: @@ -386,7 +386,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (sal_Int16) n; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: @@ -398,7 +398,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pUShort = (sal_uInt16) n; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) @@ -409,7 +409,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINLNG; } - *p->pLong = (sal_Int32) n; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) @@ -420,7 +420,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pULong = (sal_uInt32) n; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSINGLE: if( n > SbxMAXSNG ) @@ -431,7 +431,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINSNG; } - *p->pSingle = (float) n; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = ImpDoubleToSalInt64( n ); diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx index d7a5abfdb6b6..9ea70832a8e0 100644 --- a/basic/source/sbx/sbxdbl.cxx +++ b/basic/source/sbx/sbxdbl.cxx @@ -218,7 +218,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { @@ -228,7 +228,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -239,7 +239,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -250,7 +250,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { @@ -260,7 +260,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINLNG; } - *p->pLong = (sal_Int32) n; break; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { @@ -270,7 +270,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSINGLE: if( n > SbxMAXSNG ) { @@ -288,7 +288,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINSNG2; } - *p->pSingle = (float) n; break; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = ImpDoubleToSalInt64( n ); break; case SbxBYREF | SbxSALUINT64: diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx index b41bc914df92..183abf2de137 100644 --- a/basic/source/sbx/sbxdec.cxx +++ b/basic/source/sbx/sbxdec.cxx @@ -442,13 +442,13 @@ start: } case SbxSALINT64: { - if( !pnDecRes->setDouble( (double)p->nInt64 ) ) + if( !pnDecRes->setDouble( static_cast<double>(p->nInt64) ) ) SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); break; } case SbxSALUINT64: { - if( !pnDecRes->setDouble( (double)p->uInt64 ) ) + if( !pnDecRes->setDouble( static_cast<double>(p->uInt64) ) ) SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); break; } diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx index 748a083f7d82..6e61a9af0ae3 100644 --- a/basic/source/sbx/sbxform.cxx +++ b/basic/source/sbx/sbxform.cxx @@ -129,7 +129,7 @@ void SbxBasicFormater::AppendDigit( OUStringBuffer& sStrg, short nDigit ) { if( nDigit>=0 && nDigit<=9 ) { - sStrg.append((sal_Unicode)(nDigit+'0')); + sStrg.append(static_cast<sal_Unicode>(nDigit+'0')); } } @@ -243,10 +243,10 @@ void SbxBasicFormater::InitScan( double _dNum ) void SbxBasicFormater::InitExp( double _dNewExp ) { char sBuffer[ MAX_DOUBLE_BUFFER_LENGTH ]; - nNumExp = (short)_dNewExp; + nNumExp = static_cast<short>(_dNewExp); /*int nCount =*/ sprintf( sBuffer,"%+i",nNumExp ); sNumExpStrg = OUString::createFromAscii( sBuffer ); - nExpExp = (short)get_number_of_digits( (double)nNumExp ); + nExpExp = static_cast<short>(get_number_of_digits( static_cast<double>(nNumExp) )); } @@ -270,7 +270,7 @@ short SbxBasicFormater::GetDigitAtPosScan( short nPos, bool& bFoundFirstDigit ) // query of the number's first valid digit --> set flag if( nPos==nNumExp ) bFoundFirstDigit = true; - return (short)(sSciNumStrg[ no ] - '0'); + return static_cast<short>(sSciNumStrg[ no ] - '0'); } short SbxBasicFormater::GetDigitAtPosExpScan( short nPos, bool& bFoundFirstDigit ) @@ -283,7 +283,7 @@ short SbxBasicFormater::GetDigitAtPosExpScan( short nPos, bool& bFoundFirstDigit if( nPos==nExpExp ) bFoundFirstDigit = true; - return (short)(sNumExpStrg[ no ] - '0'); + return static_cast<short>(sNumExpStrg[ no ] - '0'); } // a value for the exponent can be given because the number maybe shall @@ -634,13 +634,13 @@ void SbxBasicFormater::ScanFormatString( double dNumber, dExponent = get_number_of_digits( dNumber ); nExponentPos = 0; nMaxExponentDigit = 0; - nMaxDigit = (short)dExponent; + nMaxDigit = static_cast<short>(dExponent); bDigitPosNegative = false; if( bScientific ) { - dExponent = dExponent - (double)(nNoOfDigitsLeft-1); + dExponent = dExponent - static_cast<double>(nNoOfDigitsLeft-1); nDigitPos = nMaxDigit; - nMaxExponentDigit = (short)get_number_of_digits( dExponent ); + nMaxExponentDigit = static_cast<short>(get_number_of_digits( dExponent )); nExponentPos = nNoOfExponentDigits - 1 - nNoOfOptionalExponentDigits; } else diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx index 97357b6ed6bc..3109f424164c 100644 --- a/basic/source/sbx/sbxint.cxx +++ b/basic/source/sbx/sbxint.cxx @@ -45,12 +45,12 @@ start: nRes = p->nInteger; break; case SbxERROR: case SbxUSHORT: - if( p->nUShort > (sal_uInt16) SbxMAXINT ) + if( p->nUShort > sal_uInt16(SbxMAXINT) ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXINT; } else - nRes = (sal_Int16) p->nUShort; + nRes = static_cast<sal_Int16>(p->nUShort); break; case SbxLONG: if( p->nLong > SbxMAXINT ) @@ -62,7 +62,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMININT; } else - nRes = (sal_Int16) p->nLong; + nRes = static_cast<sal_Int16>(p->nLong); break; case SbxULONG: if( p->nULong > SbxMAXINT ) @@ -70,7 +70,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXINT; } else - nRes = (sal_Int16) p->nULong; + nRes = static_cast<sal_Int16>(p->nULong); break; case SbxSINGLE: if( p->nSingle > SbxMAXINT ) @@ -82,11 +82,11 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMININT; } else - nRes = (sal_Int16) rtl::math::round( p->nSingle ); + nRes = static_cast<sal_Int16>(rtl::math::round( p->nSingle )); break; case SbxCURRENCY: { - sal_Int64 tstVal = (sal_Int64) p->nInt64 / (sal_Int64) CURRENCY_FACTOR; + sal_Int64 tstVal = static_cast<sal_Int64>(p->nInt64) / sal_Int64(CURRENCY_FACTOR); if( tstVal > SbxMAXINT ) { @@ -97,7 +97,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMININT; } else - nRes = (sal_Int16) tstVal; + nRes = static_cast<sal_Int16>(tstVal); break; } case SbxSALINT64: @@ -110,7 +110,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMININT; } else - nRes = (sal_Int16) p->nInt64; + nRes = static_cast<sal_Int16>(p->nInt64); break; case SbxSALUINT64: if( p->uInt64 > SbxMAXINT ) @@ -118,7 +118,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXINT; } else - nRes = (sal_Int16) p->uInt64; + nRes = static_cast<sal_Int16>(p->uInt64); break; case SbxDATE: case SbxDOUBLE: @@ -143,7 +143,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMININT; } else - nRes = (sal_Int16) rtl::math::round( dVal ); + nRes = static_cast<sal_Int16>(rtl::math::round( dVal )); break; } case SbxLPSTR: @@ -166,7 +166,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMININT; } else - nRes = (sal_Int16) rtl::math::round( d ); + nRes = static_cast<sal_Int16>(rtl::math::round( d )); } break; case SbxOBJECT: @@ -264,7 +264,7 @@ start: case SbxBYREF | SbxSTRING: if( !p->pOUString ) p->pOUString = new OUString; - ImpCvtNum( (double) n, 0, *p->pOUString ); + ImpCvtNum( static_cast<double>(n), 0, *p->pOUString ); break; case SbxOBJECT: { @@ -280,7 +280,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } - *p->pChar = (char) n; break; + *p->pChar = static_cast<char>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { @@ -290,7 +290,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: *p->pInteger = n; break; @@ -300,15 +300,15 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: - *p->pLong = (sal_Int32) n; break; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: if( n < 0 ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxCURRENCY: *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: @@ -323,10 +323,10 @@ start: *p->puInt64 = n; break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) n; break; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) n; break; + *p->pDouble = static_cast<double>(n); break; default: SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); @@ -348,7 +348,7 @@ sal_Int64 ImpDoubleToSalInt64( double d ) SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SAL_MIN_INT64; } else - nRes = (sal_Int64) rtl::math::round( d ); + nRes = static_cast<sal_Int64>(rtl::math::round( d )); return nRes; } @@ -364,7 +364,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d ) SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt64) rtl::math::round( d ); + nRes = static_cast<sal_uInt64>(rtl::math::round( d )); return nRes; } @@ -375,7 +375,7 @@ double ImpSalUInt64ToDouble( sal_uInt64 n ) if( n > SAL_MAX_INT64 ) SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); else - d = (double)(sal_Int64) n; + d = static_cast<double>(static_cast<sal_Int64>(n)); return d; } @@ -401,17 +401,17 @@ start: nRes = p->nInteger; break; case SbxERROR: case SbxUSHORT: - nRes = (sal_Int64) p->nUShort; break; + nRes = static_cast<sal_Int64>(p->nUShort); break; case SbxLONG: - nRes = (sal_Int64) p->nLong; break; + nRes = static_cast<sal_Int64>(p->nLong); break; case SbxULONG: - nRes = (sal_Int64) p->nULong; break; + nRes = static_cast<sal_Int64>(p->nULong); break; case SbxSINGLE: - nRes = (sal_Int64) p->nSingle; + nRes = static_cast<sal_Int64>(p->nSingle); break; case SbxDATE: case SbxDOUBLE: - nRes = (sal_Int64) p->nDouble; + nRes = static_cast<sal_Int64>(p->nDouble); break; case SbxCURRENCY: nRes = p->nInt64 / CURRENCY_FACTOR; break; @@ -423,7 +423,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SAL_MAX_INT64; } else - nRes = (sal_Int64) p->uInt64; + nRes = static_cast<sal_Int64>(p->uInt64); break; case SbxBYREF | SbxSTRING: @@ -444,7 +444,7 @@ start: if( ImpScan( *p->pOUString, d, t, nullptr, false ) != ERRCODE_NONE ) nRes = 0; else - nRes = (sal_Int64) d; + nRes = static_cast<sal_Int64>(d); } } break; @@ -531,10 +531,10 @@ start: p = &aTmp; goto start; case SbxSINGLE: - p->nSingle = (float) n; break; + p->nSingle = static_cast<float>(n); break; case SbxDATE: case SbxDOUBLE: - p->nDouble = (double) n; break; + p->nDouble = static_cast<double>(n); break; case SbxBYREF | SbxSTRING: case SbxSTRING: @@ -566,7 +566,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { @@ -576,7 +576,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -587,7 +587,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -598,7 +598,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { @@ -608,7 +608,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINLNG; } - *p->pLong = (sal_Int32) n; break; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { @@ -618,12 +618,12 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) n; break; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) n; break; + *p->pDouble = static_cast<double>(n); break; case SbxBYREF | SbxCURRENCY: *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: @@ -665,14 +665,14 @@ start: case SbxLONG: nRes = p->nLong; break; case SbxULONG: - nRes = (sal_uInt64) p->nULong; break; + nRes = static_cast<sal_uInt64>(p->nULong); break; case SbxSINGLE: - nRes = (sal_uInt64) p->nSingle; break; + nRes = static_cast<sal_uInt64>(p->nSingle); break; case SbxDATE: case SbxDOUBLE: { //TODO overflow check - nRes = (sal_uInt64) p->nDouble; + nRes = static_cast<sal_uInt64>(p->nDouble); break; } case SbxCURRENCY: @@ -683,7 +683,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt64) p->nInt64; + nRes = static_cast<sal_uInt64>(p->nInt64); break; case SbxSALUINT64: nRes = p->uInt64; break; @@ -714,7 +714,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt64) rtl::math::round( d ); + nRes = static_cast<sal_uInt64>(rtl::math::round( d )); } else if( n64 < 0 ) { @@ -841,41 +841,41 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXCHAR; } - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXBYTE; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXINT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXUINT; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXLNG; } - *p->pLong = (sal_Int32) n; break; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: if( n > SbxMAXULNG ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXULNG; } - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSINGLE: - *p->pDouble = (float)ImpSalUInt64ToDouble( n ); break; + *p->pDouble = static_cast<float>(ImpSalUInt64ToDouble( n )); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: @@ -886,7 +886,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SAL_MAX_INT64; } - *p->pnInt64 = ( sal_Int64) ( n * CURRENCY_FACTOR ); break; + *p->pnInt64 = static_cast<sal_Int64>( n * CURRENCY_FACTOR ); break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; case SbxBYREF | SbxSALINT64: @@ -894,7 +894,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pnInt64 = (sal_Int64) n; break; + *p->pnInt64 = static_cast<sal_Int64>(n); break; default: SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx index 1da39a406e88..e9398a47553e 100644 --- a/basic/source/sbx/sbxlng.cxx +++ b/basic/source/sbx/sbxlng.cxx @@ -54,7 +54,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXLNG; } else - nRes = (sal_Int32) p->nULong; + nRes = static_cast<sal_Int32>(p->nULong); break; case SbxSINGLE: if( p->nSingle > SbxMAXLNG ) @@ -66,7 +66,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINLNG; } else - nRes = (sal_Int32) rtl::math::round( p->nSingle ); + nRes = static_cast<sal_Int32>(rtl::math::round( p->nSingle )); break; case SbxSALINT64: nRes = p->nInt64; @@ -77,7 +77,7 @@ start: case SbxCURRENCY: { sal_Int64 tstVal = p->nInt64 / CURRENCY_FACTOR; - nRes = (sal_Int32) tstVal; + nRes = static_cast<sal_Int32>(tstVal); if( tstVal < SbxMINLNG || SbxMAXLNG < tstVal ) SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); if( SbxMAXLNG < tstVal ) nRes = SbxMAXLNG; if( tstVal < SbxMINLNG ) nRes = SbxMINLNG; @@ -107,7 +107,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINLNG; } else - nRes = (sal_Int32) rtl::math::round( dVal ); + nRes = static_cast<sal_Int32>(rtl::math::round( dVal )); break; } case SbxBYREF | SbxSTRING: @@ -130,7 +130,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMINLNG; } else - nRes = (sal_Int32) rtl::math::round( d ); + nRes = static_cast<sal_Int32>(rtl::math::round( d )); } break; case SbxOBJECT: @@ -212,7 +212,7 @@ start: case SbxLONG: p->nLong = n; break; case SbxSINGLE: - p->nSingle = (float) n; break; + p->nSingle = static_cast<float>(n); break; case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; @@ -230,7 +230,7 @@ start: case SbxLPSTR: if( !p->pOUString ) p->pOUString = new OUString; - ImpCvtNum( (double) n, 0, *p->pOUString ); + ImpCvtNum( static_cast<double>(n), 0, *p->pOUString ); break; case SbxOBJECT: { @@ -250,7 +250,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { @@ -260,7 +260,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -271,7 +271,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -282,7 +282,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: *p->pLong = n; break; case SbxBYREF | SbxULONG: @@ -290,7 +290,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pULong = (sal_uInt32) n; break; + *p->pULong = static_cast<sal_uInt32>(n); break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: @@ -302,12 +302,12 @@ start: *p->puInt64 = n; break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) n; break; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) n; break; + *p->pDouble = static_cast<double>(n); break; case SbxBYREF | SbxCURRENCY: - *p->pnInt64 = (sal_Int64)n * (sal_Int64)CURRENCY_FACTOR; break; + *p->pnInt64 = static_cast<sal_Int64>(n) * sal_Int64(CURRENCY_FACTOR); break; default: SbxBase::SetError( ERRCODE_BASIC_CONVERSION ); } diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx index 2e9a723542d6..10e4ada3516d 100644 --- a/basic/source/sbx/sbxscan.cxx +++ b/basic/source/sbx/sbxscan.cxx @@ -258,7 +258,7 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, } if( *p == '&' ) p++; - nVal = (double) l; + nVal = static_cast<double>(l); if( l >= SbxMININT && l <= SbxMAXINT ) eScanType = SbxINTEGER; } @@ -270,7 +270,7 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, SbxDataType& rType, } #endif if( pLen ) - *pLen = (sal_uInt16) ( p - pStart ); + *pLen = static_cast<sal_uInt16>( p - pStart ); if( !bRes ) return ERRCODE_BASIC_CONVERSION; if( bMinus ) @@ -294,7 +294,7 @@ ErrCode SbxValue::ScanNumIntnl( const OUString& rSrc, double& nVal, bool bSingle if( bSingle ) { SbxValues aValues( nVal ); - nVal = (double)ImpGetSingle( &aValues ); // here error at overflow + nVal = static_cast<double>(ImpGetSingle( &aValues )); // here error at overflow } return nRetError; } @@ -365,7 +365,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, { // #41691: also a 0 at bFix *pBuf++ = '0'; - if( nPrec ) *pBuf++ = (char)cDecimalSep; + if( nPrec ) *pBuf++ = static_cast<char>(cDecimalSep); i = -nExp - 1; if( nDig <= 0 ) i = nPrec; while( i-- ) *pBuf++ = '0'; @@ -385,7 +385,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, { if( i < 16 ) { - digit = (int) nNum; + digit = static_cast<int>(nNum); *pBuf++ = sal::static_int_cast< char >(digit + '0'); nNum =( nNum - digit ) * 10.0; } else @@ -395,7 +395,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, { nDec--; if( !nDec ) - *pBuf++ = (char)cDecimalSep; + *pBuf++ = static_cast<char>(cDecimalSep); } } } @@ -550,7 +550,7 @@ static sal_uInt16 printfmtstr( const OUString& rStr, OUString& rRes, const OUStr break; } rRes = aTemp.makeStringAndClear(); - return (sal_uInt16) ( pFmt - pFmtStart ); + return static_cast<sal_uInt16>( pFmt - pFmtStart ); } diff --git a/basic/source/sbx/sbxsng.cxx b/basic/source/sbx/sbxsng.cxx index 11c332c0f39b..f687c930e32a 100644 --- a/basic/source/sbx/sbxsng.cxx +++ b/basic/source/sbx/sbxsng.cxx @@ -45,9 +45,9 @@ start: case SbxUSHORT: nRes = p->nUShort; break; case SbxLONG: - nRes = (float) p->nLong; break; + nRes = static_cast<float>(p->nLong); break; case SbxULONG: - nRes = (float) p->nULong; break; + nRes = static_cast<float>(p->nULong); break; case SbxSINGLE: nRes = p->nSingle; break; case SbxDECIMAL: @@ -67,9 +67,9 @@ start: if( p->eType == SbxCURRENCY ) dVal = ImpCurrencyToDouble( p->nInt64 ); else if( p->eType == SbxSALINT64 ) - dVal = (float) p->nInt64; + dVal = static_cast<float>(p->nInt64); else if( p->eType == SbxSALUINT64 ) - dVal = (float) p->uInt64; + dVal = static_cast<float>(p->uInt64); else dVal = p->nDouble; @@ -95,7 +95,7 @@ start: nRes = static_cast< float >(SbxMINSNG2); } else - nRes = (float) dVal; + nRes = static_cast<float>(dVal); break; } case SbxBYREF | SbxSTRING: @@ -120,7 +120,7 @@ start: nRes = static_cast< float >(SbxMINSNG); } else - nRes = (float) d; + nRes = static_cast<float>(d); } break; case SbxOBJECT: @@ -143,9 +143,9 @@ start: case SbxBYREF | SbxBOOL: nRes = *p->pInteger; break; case SbxBYREF | SbxLONG: - nRes = (float) *p->pLong; break; + nRes = static_cast<float>(*p->pLong); break; case SbxBYREF | SbxULONG: - nRes = (float) *p->pULong; break; + nRes = static_cast<float>(*p->pULong); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: nRes = *p->pUShort; break; @@ -220,7 +220,7 @@ start: { if( !p->pOUString ) p->pOUString = new OUString; - ImpCvtNum( (double) n, 6, *p->pOUString ); + ImpCvtNum( static_cast<double>(n), 6, *p->pOUString ); break; } case SbxOBJECT: @@ -241,7 +241,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMINCHAR; } - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { @@ -251,7 +251,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) @@ -262,7 +262,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMININT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) @@ -273,7 +273,7 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = 0; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: { sal_Int32 i; @@ -312,11 +312,11 @@ start: *p->pSingle = n; break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) n; break; + *p->pDouble = static_cast<double>(n); break; case SbxBYREF | SbxSALINT64: - *p->pnInt64 = (sal_Int64)n; break; + *p->pnInt64 = static_cast<sal_Int64>(n); break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = (sal_uInt64)n; break; + *p->puInt64 = static_cast<sal_uInt64>(n); break; case SbxBYREF | SbxCURRENCY: double d; if( n > SbxMAXCURR ) diff --git a/basic/source/sbx/sbxuint.cxx b/basic/source/sbx/sbxuint.cxx index f28eb2599681..c69931d8368b 100644 --- a/basic/source/sbx/sbxuint.cxx +++ b/basic/source/sbx/sbxuint.cxx @@ -62,7 +62,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt16) p->nLong; + nRes = static_cast<sal_uInt16>(p->nLong); break; case SbxULONG: if( p->nULong > SbxMAXUINT ) @@ -70,7 +70,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXUINT; } else - nRes = (sal_uInt16) p->nULong; + nRes = static_cast<sal_uInt16>(p->nULong); break; case SbxCURRENCY: if( p->nInt64 / CURRENCY_FACTOR > SbxMAXUINT ) @@ -82,7 +82,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt16) (p->nInt64 / CURRENCY_FACTOR); + nRes = static_cast<sal_uInt16>(p->nInt64 / CURRENCY_FACTOR); break; case SbxSALINT64: if( p->nInt64 > SbxMAXUINT ) @@ -94,7 +94,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt16) p->nInt64; + nRes = static_cast<sal_uInt16>(p->nInt64); break; case SbxSALUINT64: if( p->uInt64 > SbxMAXUINT ) @@ -102,7 +102,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = SbxMAXUINT; } else - nRes = (sal_uInt16) p->uInt64; + nRes = static_cast<sal_uInt16>(p->uInt64); break; case SbxSINGLE: if( p->nSingle > SbxMAXUINT ) @@ -114,7 +114,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt16) ( p->nSingle + 0.5 ); + nRes = static_cast<sal_uInt16>( p->nSingle + 0.5 ); break; case SbxDATE: case SbxDOUBLE: @@ -140,7 +140,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt16) ( dVal + 0.5 ); + nRes = static_cast<sal_uInt16>( dVal + 0.5 ); break; } case SbxBYREF | SbxSTRING: @@ -163,7 +163,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt16) ( d + 0.5 ); + nRes = static_cast<sal_uInt16>( d + 0.5 ); } break; case SbxOBJECT: @@ -261,7 +261,7 @@ start: case SbxLPSTR: if( !p->pOUString ) p->pOUString = new OUString; - ImpCvtNum( (double) n, 0, *p->pOUString ); + ImpCvtNum( static_cast<double>(n), 0, *p->pOUString ); break; case SbxOBJECT: { @@ -274,20 +274,20 @@ start: } case SbxBYREF | SbxCHAR: - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXBYTE; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXINT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: *p->pUShort = n; break; diff --git a/basic/source/sbx/sbxulng.cxx b/basic/source/sbx/sbxulng.cxx index ded4fe6d1f64..3e182842515e 100644 --- a/basic/source/sbx/sbxulng.cxx +++ b/basic/source/sbx/sbxulng.cxx @@ -72,7 +72,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt32) ( p->nSingle + 0.5 ); + nRes = static_cast<sal_uInt32>( p->nSingle + 0.5 ); break; case SbxDATE: case SbxDOUBLE: @@ -107,7 +107,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt32) ( dVal + 0.5 ); + nRes = static_cast<sal_uInt32>( dVal + 0.5 ); break; } case SbxBYREF | SbxSTRING: @@ -130,7 +130,7 @@ start: SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt32) ( d + 0.5 ); + nRes = static_cast<sal_uInt32>( d + 0.5 ); } break; case SbxOBJECT: @@ -190,7 +190,7 @@ start: case SbxULONG: p->nULong = n; break; case SbxSINGLE: - p->nSingle = (float) n; break; + p->nSingle = static_cast<float>(n); break; case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; @@ -226,7 +226,7 @@ start: case SbxLPSTR: if( !p->pOUString ) p->pOUString = new OUString; - ImpCvtNum( (double) n, 0, *p->pOUString ); + ImpCvtNum( static_cast<double>(n), 0, *p->pOUString ); break; case SbxOBJECT: { @@ -242,37 +242,37 @@ start: { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXCHAR; } - *p->pChar = (sal_Unicode) n; break; + *p->pChar = static_cast<sal_Unicode>(n); break; case SbxBYREF | SbxBYTE: if( n > SbxMAXBYTE ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXBYTE; } - *p->pByte = (sal_uInt8) n; break; + *p->pByte = static_cast<sal_uInt8>(n); break; case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: if( n > SbxMAXINT ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXINT; } - *p->pInteger = (sal_Int16) n; break; + *p->pInteger = static_cast<sal_Int16>(n); break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( n > SbxMAXUINT ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXUINT; } - *p->pUShort = (sal_uInt16) n; break; + *p->pUShort = static_cast<sal_uInt16>(n); break; case SbxBYREF | SbxLONG: if( n > SbxMAXLNG ) { SbxBase::SetError( ERRCODE_BASIC_MATH_OVERFLOW ); n = SbxMAXLNG; } - *p->pLong = (sal_Int32) n; break; + *p->pLong = static_cast<sal_Int32>(n); break; case SbxBYREF | SbxULONG: *p->pULong = n; break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) n; break; + *p->pSingle = static_cast<float>(n); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 5c53815de4e7..70fdfe31c512 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -313,10 +313,10 @@ bool SbxValue::Get( SbxValues& rRes ) const case SbxCoreSTRING: p->aPic = ImpGetCoreString( &p->aData ); rRes.pOUString = &p->aPic; break; case SbxINT: - rRes.nInt = (int) ImpGetLong( &p->aData ); + rRes.nInt = static_cast<int>(ImpGetLong( &p->aData )); break; case SbxUINT: - rRes.nUInt = (int) ImpGetULong( &p->aData ); + rRes.nUInt = static_cast<int>(ImpGetULong( &p->aData )); break; case SbxOBJECT: if( p->aData.eType == SbxOBJECT ) @@ -453,10 +453,10 @@ bool SbxValue::Put( const SbxValues& rVal ) case SbxLPSTR: case SbxSTRING: ImpPutString( &p->aData, rVal.pOUString ); break; case SbxINT: - ImpPutLong( &p->aData, (sal_Int32) rVal.nInt ); + ImpPutLong( &p->aData, static_cast<sal_Int32>(rVal.nInt) ); break; case SbxUINT: - ImpPutULong( &p->aData, (sal_uInt32) rVal.nUInt ); + ImpPutULong( &p->aData, static_cast<sal_uInt32>(rVal.nUInt) ); break; case SbxOBJECT: if( !p->IsFixed() || p->aData.eType == SbxOBJECT ) @@ -1047,7 +1047,7 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) case SbxMUL: { // first overflow check: see if product will fit - test real value of product (hence 2 curr factors) - double dTest = (double)aL.nInt64 * (double)aR.nInt64 / (double)CURRENCY_FACTOR_SQUARE; + double dTest = static_cast<double>(aL.nInt64) * static_cast<double>(aR.nInt64) / double(CURRENCY_FACTOR_SQUARE); if( dTest < SbxMINCURR || SbxMAXCURR < dTest) { aL.nInt64 = SAL_MAX_INT64; @@ -1056,10 +1056,10 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) break; } // second overflow check: see if unscaled product overflows - if so use doubles - dTest = (double)aL.nInt64 * (double)aR.nInt64; + dTest = static_cast<double>(aL.nInt64) * static_cast<double>(aR.nInt64); if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest) { - aL.nInt64 = (sal_Int64)( dTest / (double)CURRENCY_FACTOR ); + aL.nInt64 = static_cast<sal_Int64>( dTest / double(CURRENCY_FACTOR) ); break; } // precise calc: multiply then scale back (move decimal pt) @@ -1076,17 +1076,17 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) break; } // first overflow check: see if quotient will fit - calc real value of quotient (curr factors cancel) - double dTest = (double)aL.nInt64 / (double)aR.nInt64; + double dTest = static_cast<double>(aL.nInt64) / static_cast<double>(aR.nInt64); if( dTest < SbxMINCURR || SbxMAXCURR < dTest) { SetError( ERRCODE_BASIC_MATH_OVERFLOW ); break; } // second overflow check: see if scaled dividend overflows - if so use doubles - dTest = (double)aL.nInt64 * (double)CURRENCY_FACTOR; + dTest = static_cast<double>(aL.nInt64) * double(CURRENCY_FACTOR); if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest) { - aL.nInt64 = (sal_Int64)(dTest / (double)aR.nInt64); + aL.nInt64 = static_cast<sal_Int64>(dTest / static_cast<double>(aR.nInt64)); break; } // precise calc: scale (move decimal pt) then divide @@ -1097,7 +1097,7 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) case SbxPLUS: { - double dTest = ( (double)aL.nInt64 + (double)aR.nInt64 ) / (double)CURRENCY_FACTOR; + double dTest = ( static_cast<double>(aL.nInt64) + static_cast<double>(aR.nInt64) ) / double(CURRENCY_FACTOR); if( dTest < SbxMINCURR || SbxMAXCURR < dTest) { SetError( ERRCODE_BASIC_MATH_OVERFLOW ); @@ -1109,7 +1109,7 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) case SbxMINUS: { - double dTest = ( (double)aL.nInt64 - (double)aR.nInt64 ) / (double)CURRENCY_FACTOR; + double dTest = ( static_cast<double>(aL.nInt64) - static_cast<double>(aR.nInt64) ) / double(CURRENCY_FACTOR); if( dTest < SbxMINCURR || SbxMAXCURR < dTest) { SetError( ERRCODE_BASIC_MATH_OVERFLOW ); @@ -1382,7 +1382,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) aData.nSingle = 0.0F; return false; } - aData.nSingle = (float) d; + aData.nSingle = static_cast<float>(d); break; } case SbxDATE: @@ -1410,8 +1410,8 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) sal_uInt32 tmpHi = 0; sal_uInt32 tmpLo = 0; r.ReadUInt32( tmpHi ).ReadUInt32( tmpLo ); - aData.nInt64 = ((sal_Int64)tmpHi << 32); - aData.nInt64 |= (sal_Int64)tmpLo; + aData.nInt64 = (static_cast<sal_Int64>(tmpHi) << 32); + aData.nInt64 |= static_cast<sal_Int64>(tmpLo); break; } case SbxSTRING: @@ -1541,7 +1541,7 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) case SbxCURRENCY: { sal_Int32 tmpHi = ( (aData.nInt64 >> 32) & 0xFFFFFFFF ); - sal_Int32 tmpLo = ( sal_Int32 )aData.nInt64; + sal_Int32 tmpLo = static_cast<sal_Int32>(aData.nInt64); r.WriteInt32( tmpHi ).WriteInt32( tmpLo ); break; } diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index d80514fe483a..dba13358febd 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -511,7 +511,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) aTmp.nSingle = 0; return false; } - aTmp.nSingle = (float) d; + aTmp.nSingle = static_cast<float>(d); break; } case SbxDATE: @@ -557,7 +557,7 @@ bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) return false; } pInfo = new SbxInfo; - pInfo->LoadData( rStrm, (sal_uInt16) cMark ); + pInfo->LoadData( rStrm, static_cast<sal_uInt16>(cMark) ); } Broadcast( SfxHintId::BasicDataChanged ); nHash = MakeHashCode( maName ); diff --git a/include/basic/sbxdef.hxx b/include/basic/sbxdef.hxx index 74ae183f50ed..93cad7008f6f 100644 --- a/include/basic/sbxdef.hxx +++ b/include/basic/sbxdef.hxx @@ -181,10 +181,10 @@ namespace o3tl #define SbxMAXBYTE ( 255) #define SbxMAXINT ( 32767) #define SbxMININT (-32768) -#define SbxMAXUINT ((sal_uInt16) 65535) +#define SbxMAXUINT (sal_uInt16(65535)) #define SbxMAXLNG ( 2147483647) -#define SbxMINLNG ((sal_Int32)(-2147483647-1)) -#define SbxMAXULNG ((sal_uInt32) 0xffffffff) +#define SbxMINLNG (sal_Int32(-2147483647-1)) +#define SbxMAXULNG (sal_uInt32(0xffffffff)) // Currency stored as SbxSALINT64 == sal_Int64 // value range limits are ~(2^63 - 1)/10000 |