diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:10:40 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:10:40 +0100 |
commit | 55f07d4daa76503530d96b9c20b53c59bcd5bcf9 (patch) | |
tree | 7ad8a720341e38258dab12597d25616c3bff8807 /vcl/source | |
parent | e235da515af0e2a5d5a0cf80773943b65fdb8f7b (diff) |
More loplugin:cstylecast: vcl
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
loplugin:cstylecast for some more cases" plus
solenv/clang-format/reformat-formatted-files
Change-Id: I363c01a1ae9e863fca4fb4589829492d7280d711
Diffstat (limited to 'vcl/source')
93 files changed, 981 insertions, 982 deletions
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 9089ca51ffd0..c1a02dc27a91 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -1829,7 +1829,7 @@ StyleSettings::SetCursorBlinkTime( sal_uInt64 nBlinkTime ) sal_uInt64 StyleSettings::GetCursorBlinkTime() const { - return (long) mxData->mnCursorBlinkTime; + return static_cast<long>(mxData->mnCursorBlinkTime); } void @@ -2074,10 +2074,10 @@ void StyleSettings::Set3DColors( const Color& rColor ) sal_uLong nRed = mxData->maLightColor.GetRed(); sal_uLong nGreen = mxData->maLightColor.GetGreen(); sal_uLong nBlue = mxData->maLightColor.GetBlue(); - nRed += (sal_uLong)(mxData->maShadowColor.GetRed()); - nGreen += (sal_uLong)(mxData->maShadowColor.GetGreen()); - nBlue += (sal_uLong)(mxData->maShadowColor.GetBlue()); - mxData->maCheckedColor = Color( (sal_uInt8)(nRed/2), (sal_uInt8)(nGreen/2), (sal_uInt8)(nBlue/2) ); + nRed += static_cast<sal_uLong>(mxData->maShadowColor.GetRed()); + nGreen += static_cast<sal_uLong>(mxData->maShadowColor.GetGreen()); + nBlue += static_cast<sal_uLong>(mxData->maShadowColor.GetBlue()); + mxData->maCheckedColor = Color( static_cast<sal_uInt8>(nRed/2), static_cast<sal_uInt8>(nGreen/2), static_cast<sal_uInt8>(nBlue/2) ); } else { @@ -2095,9 +2095,9 @@ void StyleSettings::SetCheckedColorSpecialCase( ) mxData->maCheckedColor = Color( 0xCC, 0xCC, 0xCC ); else { - sal_uInt8 nRed = (sal_uInt8)(((sal_uInt16)mxData->maFaceColor.GetRed() + (sal_uInt16)mxData->maLightColor.GetRed())/2); - sal_uInt8 nGreen = (sal_uInt8)(((sal_uInt16)mxData->maFaceColor.GetGreen() + (sal_uInt16)mxData->maLightColor.GetGreen())/2); - sal_uInt8 nBlue = (sal_uInt8)(((sal_uInt16)mxData->maFaceColor.GetBlue() + (sal_uInt16)mxData->maLightColor.GetBlue())/2); + sal_uInt8 nRed = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxData->maFaceColor.GetRed()) + static_cast<sal_uInt16>(mxData->maLightColor.GetRed()))/2); + sal_uInt8 nGreen = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxData->maFaceColor.GetGreen()) + static_cast<sal_uInt16>(mxData->maLightColor.GetGreen()))/2); + sal_uInt8 nBlue = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxData->maFaceColor.GetBlue()) + static_cast<sal_uInt16>(mxData->maLightColor.GetBlue()))/2); mxData->maCheckedColor = Color( nRed, nGreen, nBlue ); } } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 087710450d2d..800f0be14d96 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -224,7 +224,7 @@ void Application::DeInit() sal_uInt16 Application::GetCommandLineParamCount() { - return (sal_uInt16)osl_getCommandArgCount(); + return static_cast<sal_uInt16>(osl_getCommandArgCount()); } OUString Application::GetCommandLineParam( sal_uInt16 nParam ) @@ -1130,8 +1130,7 @@ OUString Application::GetHWOSConfInfo() OUStringBuffer aDetails; aDetails.append( VclResId(SV_APP_CPUTHREADS) ); - aDetails.append( (sal_Int32) - std::thread::hardware_concurrency() ); + aDetails.append( static_cast<sal_Int32>(std::thread::hardware_concurrency()) ); aDetails.append( "; " ); OUString aVersion; diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index 9141805188dd..b574e5743b09 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -26,11 +26,11 @@ namespace { -#define MAP( cVal0, cVal1, nFrac ) ((sal_uInt8)((((long)(cVal0)<<7)+nFrac*((long)(cVal1)-(cVal0)))>>7)) +#define MAP( cVal0, cVal1, nFrac ) (static_cast<sal_uInt8>(((static_cast<long>(cVal0)<<7)+nFrac*(static_cast<long>(cVal1)-(cVal0)))>>7)) void generateMap(long nW, long nDstW, bool bHMirr, long* pMapIX, long* pMapFX) { - const double fRevScaleX = (nDstW > 1) ? (double) (nW - 1) / (nDstW - 1) : 0.0; + const double fRevScaleX = (nDstW > 1) ? static_cast<double>(nW - 1) / (nDstW - 1) : 0.0; long nTemp = nW - 2; long nTempX = nW - 1; @@ -39,8 +39,8 @@ void generateMap(long nW, long nDstW, bool bHMirr, long* pMapIX, long* pMapFX) double fTemp = nX * fRevScaleX; if (bHMirr) fTemp = nTempX - fTemp; - pMapIX[nX] = MinMax((long) fTemp, 0, nTemp); - pMapFX[nX] = (long) ((fTemp - pMapIX[nX]) * 128.0); + pMapIX[nX] = MinMax(static_cast<long>(fTemp), 0, nTemp); + pMapFX[nX] = static_cast<long>((fTemp - pMapIX[nX]) * 128.0); } } @@ -402,7 +402,7 @@ void scalePallete8bit2(ScaleContext &rCtx, long nStartY, long nEndY) nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -529,7 +529,7 @@ void scalePalleteGeneral2(ScaleContext &rCtx, long nStartY, long nEndY) nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -652,7 +652,7 @@ void scale24bitBGR2(ScaleContext &rCtx, long nStartY, long nEndY) nSumG /= nTotalWeightY; nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -773,7 +773,7 @@ void scale24bitRGB2(ScaleContext &rCtx, long nStartY, long nEndY) nSumG /= nTotalWeightY; nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -899,7 +899,7 @@ void scaleNonPalleteGeneral2(ScaleContext &rCtx, long nStartY, long nEndY) nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index bd03840e34bb..dd4583de0181 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -65,8 +65,8 @@ using namespace css; WB_TOP | WB_VCENTER | WB_BOTTOM | \ WB_WORDBREAK | WB_NOLABEL) -#define STYLE_RADIOBUTTON_MONO ((sal_uInt16)0x0001) // legacy -#define STYLE_CHECKBOX_MONO ((sal_uInt16)0x0001) // legacy +#define STYLE_RADIOBUTTON_MONO (sal_uInt16(0x0001)) // legacy +#define STYLE_CHECKBOX_MONO (sal_uInt16(0x0001)) // legacy class ImplCommonButtonData { diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 02000ff0d7f2..531284cf86eb 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -145,7 +145,7 @@ void ComboBox::ImplCalcEditHeight() { sal_Int32 nLeft, nTop, nRight, nBottom; GetBorder( nLeft, nTop, nRight, nBottom ); - m_pImpl->m_nDDHeight = (sal_uInt16)(m_pImpl->m_pSubEdit->GetTextHeight() + nTop + nBottom + 4); + m_pImpl->m_nDDHeight = static_cast<sal_uInt16>(m_pImpl->m_pSubEdit->GetTextHeight() + nTop + nBottom + 4); if ( !IsDropDownBox() ) m_pImpl->m_nDDHeight += 4; @@ -311,7 +311,7 @@ IMPL_LINK(ComboBox::Impl, ImplAutocompleteHdl, Edit&, rEdit, void) { OUString aFullText = rEdit.GetText(); - OUString aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() ); + OUString aStartText = aFullText.copy( 0, static_cast<sal_Int32>(aSel.Max()) ); sal_Int32 nStart = m_pImplLB->GetCurrentPos(); if ( nStart == LISTBOX_ENTRY_NOTFOUND ) @@ -1127,13 +1127,13 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines if ( !IsDropDownBox() ) { Size aOutSz = m_pImpl->m_pImplLB->GetMainWindow()->GetOutputSizePixel(); - rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1; - rnLines = (sal_uInt16)(aOutSz.Height()/m_pImpl->m_pImplLB->GetEntryHeight()); + rnCols = (nCharWidth > 0) ? static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1; + rnLines = static_cast<sal_uInt16>(aOutSz.Height()/m_pImpl->m_pImplLB->GetEntryHeight()); } else { Size aOutSz = m_pImpl->m_pSubEdit->GetOutputSizePixel(); - rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1; + rnCols = (nCharWidth > 0) ? static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1; rnLines = 1; } } diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 03ceb04adcac..6a512eb4171f 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -110,7 +110,7 @@ ControlLayoutData::ControlLayoutData() : m_pParent( nullptr ) tools::Rectangle ControlLayoutData::GetCharacterBounds( long nIndex ) const { - return (nIndex >= 0 && nIndex < (long) m_aUnicodeBoundRects.size()) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle(); + return (nIndex >= 0 && nIndex < static_cast<long>(m_aUnicodeBoundRects.size())) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle(); } tools::Rectangle Control::GetCharacterBounds( long nIndex ) const diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 7560860de9de..fc8d7299780c 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -489,7 +489,7 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const tools::Rectangl if (nLen) { - if ((size_t) (2 * nLen) > SAL_N_ELEMENTS(nDXBuffer)) + if (static_cast<size_t>(2 * nLen) > SAL_N_ELEMENTS(nDXBuffer)) { pDXBuffer.reset(new long[2 * (nLen + 1)]); pDX = pDXBuffer.get(); @@ -1084,7 +1084,7 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible ) if( !aText.isEmpty() ) { - if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) + if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) { pDXBuffer.reset(new long[2*(aText.getLength()+1)]); pDX = pDXBuffer.get(); @@ -1200,7 +1200,7 @@ sal_Int32 Edit::ImplGetCharPos( const Point& rWindowPos ) const long nDXBuffer[256]; std::unique_ptr<long[]> pDXBuffer; long* pDX = nDXBuffer; - if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) + if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) { pDXBuffer.reset(new long[2*(aText.getLength()+1)]); pDX = pDXBuffer.get(); @@ -2136,7 +2136,7 @@ void Edit::Command( const CommandEvent& rCEvt ) if( !aText.isEmpty() ) { - if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) + if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) { pDXBuffer.reset(new long[2*(aText.getLength()+1)]); pDX = pDXBuffer.get(); diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 220da283ba86..bd341cfe06fd 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -234,7 +234,7 @@ bool ImplNumericGetValue( const OUString& rStr, sal_Int64& rValue, sal_Int64 nNum = aStrNum.makeStringAndClear().toInt64(); sal_Int64 nDenom = aStrDenom.makeStringAndClear().toInt64(); if (nDenom == 0) return false; // Division by zero - double nFrac2Dec = nWholeNum + (double)nNum/nDenom; // Convert to double for floating point precision + double nFrac2Dec = nWholeNum + static_cast<double>(nNum)/nDenom; // Convert to double for floating point precision aStrFrac.append(nFrac2Dec); // Reconvert division result to string and parse nDecPos = aStrFrac.indexOf('.'); @@ -701,7 +701,7 @@ void NumericFormatter::ImplNewFieldValue( sal_Int64 nNewValue ) aSelection.Justify(); OUString aText = GetField()->GetText(); // leave it as is if selected until end - if ( (sal_Int32)aSelection.Max() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) { if ( !aSelection.Len() ) aSelection.Min() = SELECTION_MAX; @@ -1109,13 +1109,13 @@ sal_Int64 MetricField::ConvertValue( sal_Int64 nValue, sal_Int64 mnBaseValue, sa FieldUnit eInUnit, FieldUnit eOutUnit ) { double nDouble = nonValueDoubleToValueDouble( ConvertDoubleValue( - (double)nValue, mnBaseValue, nDecDigits, eInUnit, eOutUnit ) ); + static_cast<double>(nValue), mnBaseValue, nDecDigits, eInUnit, eOutUnit ) ); sal_Int64 nLong ; // caution: precision loss in double cast - if ( nDouble <= (double)SAL_MIN_INT64 ) + if ( nDouble <= double(SAL_MIN_INT64) ) nLong = SAL_MIN_INT64; - else if ( nDouble >= (double)SAL_MAX_INT64 ) + else if ( nDouble >= double(SAL_MAX_INT64) ) nLong = SAL_MAX_INT64; else nLong = static_cast<sal_Int64>( nDouble ); @@ -1299,7 +1299,7 @@ static bool ImplMetricGetValue( const OUString& rStr, double& rValue, sal_Int64 // Recalculate unit // caution: conversion to double loses precision - rValue = MetricField::ConvertDoubleValue( (double)nValue, nBaseValue, nDecDigits, eEntryUnit, eUnit ); + rValue = MetricField::ConvertDoubleValue( static_cast<double>(nValue), nBaseValue, nDecDigits, eEntryUnit, eUnit ); return true; } @@ -1313,11 +1313,11 @@ bool MetricFormatter::ImplMetricReformat( const OUString& rStr, double& rValue, double nTempVal = rValue; // caution: precision loss in double cast if ( nTempVal > GetMax() ) - nTempVal = (double)GetMax(); + nTempVal = static_cast<double>(GetMax()); else if ( nTempVal < GetMin()) - nTempVal = (double)GetMin(); + nTempVal = static_cast<double>(GetMin()); - rOutStr = CreateFieldText( (sal_Int64)nTempVal ); + rOutStr = CreateFieldText( static_cast<sal_Int64>(nTempVal) ); return true; } } @@ -1401,16 +1401,16 @@ sal_Int64 MetricFormatter::GetValue( FieldUnit eOutUnit ) const double nTempValue; // caution: precision loss in double cast if ( !ImplMetricGetValue( GetField()->GetText(), nTempValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ) ) - nTempValue = (double)mnLastValue; + nTempValue = static_cast<double>(mnLastValue); // caution: precision loss in double cast if ( nTempValue > mnMax ) - nTempValue = (double)mnMax; + nTempValue = static_cast<double>(mnMax); else if ( nTempValue < mnMin ) - nTempValue = (double)mnMin; + nTempValue = static_cast<double>(mnMin); // convert to requested units - return MetricField::ConvertValue( (sal_Int64)nTempValue, mnBaseValue, GetDecimalDigits(), meUnit, eOutUnit ); + return MetricField::ConvertValue( static_cast<sal_Int64>(nTempValue), mnBaseValue, GetDecimalDigits(), meUnit, eOutUnit ); } void MetricFormatter::SetValue( sal_Int64 nValue ) @@ -1477,9 +1477,9 @@ void MetricFormatter::Reformat() OUString aStr; // caution: precision loss in double cast - double nTemp = (double)mnLastValue; + double nTemp = static_cast<double>(mnLastValue); bool bOK = ImplMetricReformat( aText, nTemp, aStr ); - mnLastValue = (sal_Int64)nTemp; + mnLastValue = static_cast<sal_Int64>(nTemp); if ( !bOK ) return; @@ -1763,7 +1763,7 @@ sal_Int64 MetricBox::GetValue( sal_Int32 nPos ) const GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ); // convert to previously configured units - sal_Int64 nRetValue = MetricField::ConvertValue( (sal_Int64)nValue, mnBaseValue, GetDecimalDigits(), + sal_Int64 nRetValue = MetricField::ConvertValue( static_cast<sal_Int64>(nValue), mnBaseValue, GetDecimalDigits(), meUnit, FUNIT_NONE ); return nRetValue; diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index ce8aa460484d..015695df2c1f 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -83,7 +83,7 @@ static sal_Unicode* ImplAddNum( sal_Unicode* pBuf, sal_uLong nNumber, int nMinLe sal_Unicode* pTempBuf = aTempBuf; do { - *pTempBuf = (sal_Unicode)(nNumber % 10) + '0'; + *pTempBuf = static_cast<sal_Unicode>(nNumber % 10) + '0'; pTempBuf++; nNumber /= 10; if ( nMinLen ) @@ -1324,7 +1324,7 @@ void DateField::ImplDateSpinArea( bool bUp ) Selection aSelection = GetField()->GetSelection(); aSelection.Justify(); OUString aText( GetText() ); - if ( (sal_Int32)aSelection.Len() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Len()) == aText.getLength() ) ImplDateIncrementDay( aDate, bUp ); else { @@ -1344,7 +1344,7 @@ void DateField::ImplDateSpinArea( bool bUp ) for ( sal_Int8 i = 1; i <= 3; i++ ) { nPos = aText.indexOf( aDateSep, nPos ); - if (nPos < 0 || nPos >= (sal_Int32)aSelection.Max()) + if (nPos < 0 || nPos >= static_cast<sal_Int32>(aSelection.Max())) { nDateArea = i; break; @@ -1585,7 +1585,7 @@ void DateFormatter::ImplNewFieldValue( const Date& rDate ) OUString aText = GetField()->GetText(); // If selected until the end then keep it that way - if ( (sal_Int32)aSelection.Max() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) { if ( !aSelection.Len() ) aSelection.Min() = SELECTION_MAX; @@ -1961,7 +1961,7 @@ static bool ImplCutTimePortion( OUStringBuffer& _rStr, sal_Int32 _nSepPos, bool if ( !ImplIsValidTimePortion( _bSkipInvalidCharacters, sPortion ) ) return false; - *_pPortion = (short)sPortion.toInt32(); + *_pPortion = static_cast<short>(sPortion.toInt32()); return true; } @@ -2030,14 +2030,14 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, nNanoSec = aStr.toString().toInt64(); } else - nSecond = (short)aStr.toString().toInt32(); + nSecond = static_cast<short>(aStr.toString().toInt32()); } else - nMinute = (short)aStr.toString().toInt32(); + nMinute = static_cast<short>(aStr.toString().toInt32()); } else if ( nSepPos < 0 ) { - nSecond = (short)aStr.toString().toInt32(); + nSecond = static_cast<short>(aStr.toString().toInt32()); nMinute += nSecond / 60; nSecond %= 60; nHour += nMinute / 60; @@ -2045,7 +2045,7 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, } else { - nSecond = (short)aStr.copy( 0, nSepPos ).toString().toInt32(); + nSecond = static_cast<short>(aStr.copy( 0, nSepPos ).toString().toInt32()); aStr.remove( 0, nSepPos+1 ); nSepPos = aStr.indexOf( rLocaleDataWrapper.getTimeSep() ); @@ -2054,7 +2054,7 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, if ( nSepPos >= 0 ) { nMinute = nSecond; - nSecond = (short)aStr.copy( 0, nSepPos ).toString().toInt32(); + nSecond = static_cast<short>(aStr.copy( 0, nSepPos ).toString().toInt32()); aStr.remove( 0, nSepPos+1 ); nSepPos = aStr.indexOf( rLocaleDataWrapper.getTimeSep() ); @@ -2064,7 +2064,7 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, { nHour = nMinute; nMinute = nSecond; - nSecond = (short)aStr.copy( 0, nSepPos ).toString().toInt32(); + nSecond = static_cast<short>(aStr.copy( 0, nSepPos ).toString().toInt32()); aStr.remove( 0, nSepPos+1 ); } else @@ -2130,8 +2130,8 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, if ( (nHour == 12) && ( ( aUpperCaseStr.indexOf( "AM" ) >= 0 ) || ( aUpperCaseStr.indexOf( aAMlocalised ) >= 0 ) ) ) nHour = 0; - aTime = tools::Time( (sal_uInt16)nHour, (sal_uInt16)nMinute, (sal_uInt16)nSecond, - (sal_uInt32)nNanoSec ); + aTime = tools::Time( static_cast<sal_uInt16>(nHour), static_cast<sal_uInt16>(nMinute), static_cast<sal_uInt16>(nSecond), + static_cast<sal_uInt32>(nNanoSec) ); } else { @@ -2148,8 +2148,8 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, nNanoSec = nNanoSec < 0 ? -nNanoSec : nNanoSec; } - aTime = tools::Time( (sal_uInt16)nHour, (sal_uInt16)nMinute, (sal_uInt16)nSecond, - (sal_uInt32)nNanoSec ); + aTime = tools::Time( static_cast<sal_uInt16>(nHour), static_cast<sal_uInt16>(nMinute), static_cast<sal_uInt16>(nSecond), + static_cast<sal_uInt32>(nNanoSec) ); if ( bNegative ) aTime = -aTime; } @@ -2364,7 +2364,7 @@ void TimeFormatter::ImplNewFieldValue( const tools::Time& rTime ) OUString aText = GetField()->GetText(); // If selected until the end then keep it that way - if ( (sal_Int32)aSelection.Max() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) { if ( !aSelection.Len() ) aSelection.Min() = SELECTION_MAX; diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 755d12cb22bb..98c88b674cd7 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -541,14 +541,14 @@ void ImplListBoxWindow::ImplCalcMetrics() mnMaxImgTxtWidth= 0; mnMaxImgHeight = 0; - mnTextHeight = (sal_uInt16)GetTextHeight(); + mnTextHeight = static_cast<sal_uInt16>(GetTextHeight()); mnMaxTxtHeight = mnTextHeight + mnBorder; mnMaxHeight = mnMaxTxtHeight; if ( maUserItemSize.Height() > mnMaxHeight ) - mnMaxHeight = (sal_uInt16) maUserItemSize.Height(); + mnMaxHeight = static_cast<sal_uInt16>(maUserItemSize.Height()); if ( maUserItemSize.Width() > mnMaxWidth ) - mnMaxWidth= (sal_uInt16) maUserItemSize.Width(); + mnMaxWidth= static_cast<sal_uInt16>(maUserItemSize.Width()); for ( sal_Int32 n = mpEntryList->GetEntryCount(); n; ) { @@ -637,7 +637,7 @@ void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry ) else { // normal single line case - aMetrics.nTextWidth = (sal_uInt16)GetTextWidth( rEntry.maStr ); + aMetrics.nTextWidth = static_cast<sal_uInt16>(GetTextWidth( rEntry.maStr )); if( aMetrics.nTextWidth > mnMaxTxtWidth ) mnMaxTxtWidth = aMetrics.nTextWidth; aMetrics.nEntryWidth = mnMaxTxtWidth; @@ -647,8 +647,8 @@ void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry ) if ( aMetrics.bImage ) { Size aImgSz = rEntry.maImage.GetSizePixel(); - aMetrics.nImgWidth = (sal_uInt16) CalcZoom( aImgSz.Width() ); - aMetrics.nImgHeight = (sal_uInt16) CalcZoom( aImgSz.Height() ); + aMetrics.nImgWidth = static_cast<sal_uInt16>(CalcZoom( aImgSz.Width() )); + aMetrics.nImgHeight = static_cast<sal_uInt16>(CalcZoom( aImgSz.Height() )); if( aMetrics.nImgWidth > mnMaxImgWidth ) mnMaxImgWidth = aMetrics.nImgWidth; @@ -897,7 +897,7 @@ void ImplListBoxWindow::MouseMove( const MouseEvent& rMEvt ) if( nSelect == LISTBOX_ENTRY_NOTFOUND ) nSelect = mpEntryList->GetEntryCount() - 1; nSelect = std::min( nSelect, GetLastVisibleEntry() ); - nSelect = std::min( nSelect, (sal_Int32) ( mpEntryList->GetEntryCount() - 1 ) ); + nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) ); // Select only visible Entries with MouseMove, otherwise Tracking... if ( IsVisible( nSelect ) && mpEntryList->IsEntrySelectable( nSelect ) && @@ -1230,16 +1230,16 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) { if ( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND ) { - nSelect = std::min( (sal_Int32)(mnCurrentPos+1), (sal_Int32)(mpEntryList->GetEntryCount()-1) ); + nSelect = std::min( static_cast<sal_Int32>(mnCurrentPos+1), static_cast<sal_Int32>(mpEntryList->GetEntryCount()-1) ); if( nSelect >= GetLastVisibleEntry() ) SetTopEntry( mnTop+1 ); } } else { - nSelect = (sal_Int32) ( ( aPt.Y() + mnBorder ) / mnMaxHeight ) + mnTop; + nSelect = static_cast<sal_Int32>( ( aPt.Y() + mnBorder ) / mnMaxHeight ) + mnTop; nSelect = std::min( nSelect, GetLastVisibleEntry() ); - nSelect = std::min( nSelect, (sal_Int32) ( mpEntryList->GetEntryCount() - 1 ) ); + nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) ); } if ( bInside ) @@ -1450,10 +1450,10 @@ bool ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) nTmp += mnTop - 1; if( mnCurrentPos == nTmp && mnCurrentPos != nCount - 1 ) { - long nTmp2 = std::min( (long)(nCount-nCurVis), (long)((long)mnTop+(long)nCurVis-1) ); - nTmp2 = std::max( (long)0 , nTmp2 ); - nTmp = (sal_Int32)(nTmp2+(nCurVis-1) ); - SetTopEntry( (sal_Int32)nTmp2 ); + long nTmp2 = std::min( static_cast<long>(nCount-nCurVis), static_cast<long>(static_cast<long>(mnTop)+static_cast<long>(nCurVis)-1) ); + nTmp2 = std::max( long(0) , nTmp2 ); + nTmp = static_cast<sal_Int32>(nTmp2+(nCurVis-1) ); + SetTopEntry( static_cast<sal_Int32>(nTmp2) ); } // find first selectable starting from nTmp looking backwards nSelect = mpEntryList->FindFirstSelectable( nTmp, false ); @@ -2237,7 +2237,7 @@ IMPL_LINK_NOARG(ImplListBox, LBWindowScrolled, ImplListBoxWindow*, void) IMPL_LINK( ImplListBox, ScrollBarHdl, ScrollBar*, pSB, void ) { - sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); + sal_uInt16 nPos = static_cast<sal_uInt16>(pSB->GetThumbPos()); if( pSB == mpVScrollBar ) SetTopEntry( nPos ); else if( pSB == mpHScrollBar ) @@ -2250,7 +2250,7 @@ void ImplListBox::ImplCheckScrollBars() Size aOutSz = GetOutputSizePixel(); sal_Int32 nEntries = GetEntryList()->GetEntryCount(); - sal_uInt16 nMaxVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight()); + sal_uInt16 nMaxVisEntries = static_cast<sal_uInt16>(aOutSz.Height() / GetEntryHeight()); // vertical ScrollBar if( nEntries > nMaxVisEntries ) @@ -2277,7 +2277,7 @@ void ImplListBox::ImplCheckScrollBars() // horizontal ScrollBar if( mbAutoHScroll ) { - long nWidth = (sal_uInt16) aOutSz.Width(); + long nWidth = static_cast<sal_uInt16>(aOutSz.Width()); if ( mbVScroll ) nWidth -= mpVScrollBar->GetSizePixel().Width(); @@ -2290,7 +2290,7 @@ void ImplListBox::ImplCheckScrollBars() if ( !mbVScroll ) // maybe we do need one now { - nMaxVisEntries = (sal_uInt16) ( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeight() ); + nMaxVisEntries = static_cast<sal_uInt16>( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeight() ); if( nEntries > nMaxVisEntries ) { bArrange = true; @@ -2306,7 +2306,7 @@ void ImplListBox::ImplCheckScrollBars() } // check of the scrolled-out region - sal_uInt16 nMaxLI = (sal_uInt16) (nMaxWidth - nWidth); + sal_uInt16 nMaxLI = static_cast<sal_uInt16>(nMaxWidth - nWidth); if ( nMaxLI < GetLeftIndent() ) SetLeftIndent( nMaxLI ); } @@ -2332,7 +2332,7 @@ void ImplListBox::ImplInitScrollBars() if ( mbVScroll ) { sal_Int32 nEntries = GetEntryList()->GetEntryCount(); - sal_uInt16 nVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight()); + sal_uInt16 nVisEntries = static_cast<sal_uInt16>(aOutSz.Height() / GetEntryHeight()); mpVScrollBar->SetRangeMax( nEntries ); mpVScrollBar->SetVisibleSize( nVisEntries ); mpVScrollBar->SetPageSize( nVisEntries - 1 ); @@ -2341,7 +2341,7 @@ void ImplListBox::ImplInitScrollBars() if ( mbHScroll ) { mpHScrollBar->SetRangeMax( GetMaxEntryWidth() + HORZ_SCROLL ); - mpHScrollBar->SetVisibleSize( (sal_uInt16)aOutSz.Width() ); + mpHScrollBar->SetVisibleSize( static_cast<sal_uInt16>(aOutSz.Width()) ); mpHScrollBar->SetLineSize( HORZ_SCROLL ); mpHScrollBar->SetPageSize( aOutSz.Width() - HORZ_SCROLL ); } diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index 7db757510534..df21ca2b1741 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -98,7 +98,7 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) { sal_Int32 nLeft, nTop, nRight, nBottom; GetBorder( nLeft, nTop, nRight, nBottom ); - mnDDHeight = (sal_uInt16)(GetTextHeight() + nTop + nBottom + 4); + mnDDHeight = static_cast<sal_uInt16>(GetTextHeight() + nTop + nBottom + 4); if( IsNativeWidgetEnabled() && IsNativeControlSupported( ControlType::Listbox, ControlPart::Entire ) ) @@ -413,7 +413,7 @@ void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, Dr else { long nTextHeight = pDev->GetTextHeight(); - sal_uInt16 nLines = ( nTextHeight > 0 ) ? (sal_uInt16)(aSize.Height() / nTextHeight) : 1; + sal_uInt16 nLines = ( nTextHeight > 0 ) ? static_cast<sal_uInt16>(aSize.Height() / nTextHeight) : 1; tools::Rectangle aClip( aPos, aSize ); pDev->IntersectClipRegion( aClip ); @@ -1317,13 +1317,13 @@ void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines if ( !IsDropDownBox() ) { Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel(); - rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth); - rnLines = (sal_uInt16) (aOutSz.Height()/mpImplLB->GetEntryHeight()); + rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth); + rnLines = static_cast<sal_uInt16>(aOutSz.Height()/mpImplLB->GetEntryHeight()); } else { Size aOutSz = mpImplWin->GetOutputSizePixel(); - rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth); + rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth); rnLines = 1; } } diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index 0b538747f1c9..dc15721dc8fa 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -48,8 +48,8 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt { SAL_WARN_IF( nDigits >= 10, "vcl", "LongCurrency may only have 9 decimal places" ); - if ( rNumber.IsZero() || (long)rNumber ) - return rLocaleDataWrapper.getCurr( (long)rNumber, nDigits, rCurrSymbol, bShowThousandSep ); + if ( rNumber.IsZero() || static_cast<long>(rNumber) ) + return rLocaleDataWrapper.getCurr( static_cast<long>(rNumber), nDigits, rCurrSymbol, bShowThousandSep ); BigInt aTmp( ImplPower10( nDigits ) ); BigInt aInteger( rNumber ); @@ -66,7 +66,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if ( rNumber.IsNeg() ) aFraction *= -1; - OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( (long)aFraction, nDigits, rCurrSymbol, bShowThousandSep ); + OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( static_cast<long>(aFraction), nDigits, rCurrSymbol, bShowThousandSep ); while( !aInteger.IsZero() ) { aFraction = aInteger; @@ -75,7 +75,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if( !aInteger.IsZero() ) aFraction += aTmp; - OUString aFractionStr = rLocaleDataWrapper.getNum( (long)aFraction, 0 ); + OUString aFractionStr = rLocaleDataWrapper.getNum( static_cast<long>(aFraction), 0 ); sal_Int32 nSPos = aTemplate.indexOf( '1' ); if (nSPos == -1) diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx index 837158350a36..519353a6a777 100644 --- a/vcl/source/control/prgsbar.cxx +++ b/vcl/source/control/prgsbar.cxx @@ -127,7 +127,7 @@ void ProgressBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt1 mnPrgsWidth = (mnPrgsHeight * 2) / 3; maPos.Y() = PROGRESSBAR_WIN_OFFSET; long nMaxWidth = (aSize.Width() - (PROGRESSBAR_WIN_OFFSET * 2) + PROGRESSBAR_OFFSET); - sal_uInt16 nMaxCount = (sal_uInt16)(nMaxWidth / (mnPrgsWidth+PROGRESSBAR_OFFSET)); + sal_uInt16 nMaxCount = static_cast<sal_uInt16>(nMaxWidth / (mnPrgsWidth+PROGRESSBAR_OFFSET)); if (nMaxCount <= 1) { nMaxCount = 1; diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index ee937aa854d6..2695f6da714b 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -46,20 +46,20 @@ #include "thumbpos.hxx" -#define SCRBAR_DRAW_BTN1 ((sal_uInt16)0x0001) -#define SCRBAR_DRAW_BTN2 ((sal_uInt16)0x0002) -#define SCRBAR_DRAW_PAGE1 ((sal_uInt16)0x0004) -#define SCRBAR_DRAW_PAGE2 ((sal_uInt16)0x0008) -#define SCRBAR_DRAW_THUMB ((sal_uInt16)0x0010) -#define SCRBAR_DRAW_BACKGROUND ((sal_uInt16)0x0020) - -#define SCRBAR_STATE_BTN1_DOWN ((sal_uInt16)0x0001) -#define SCRBAR_STATE_BTN1_DISABLE ((sal_uInt16)0x0002) -#define SCRBAR_STATE_BTN2_DOWN ((sal_uInt16)0x0004) -#define SCRBAR_STATE_BTN2_DISABLE ((sal_uInt16)0x0008) -#define SCRBAR_STATE_PAGE1_DOWN ((sal_uInt16)0x0010) -#define SCRBAR_STATE_PAGE2_DOWN ((sal_uInt16)0x0020) -#define SCRBAR_STATE_THUMB_DOWN ((sal_uInt16)0x0040) +#define SCRBAR_DRAW_BTN1 (sal_uInt16(0x0001)) +#define SCRBAR_DRAW_BTN2 (sal_uInt16(0x0002)) +#define SCRBAR_DRAW_PAGE1 (sal_uInt16(0x0004)) +#define SCRBAR_DRAW_PAGE2 (sal_uInt16(0x0008)) +#define SCRBAR_DRAW_THUMB (sal_uInt16(0x0010)) +#define SCRBAR_DRAW_BACKGROUND (sal_uInt16(0x0020)) + +#define SCRBAR_STATE_BTN1_DOWN (sal_uInt16(0x0001)) +#define SCRBAR_STATE_BTN1_DISABLE (sal_uInt16(0x0002)) +#define SCRBAR_STATE_BTN2_DOWN (sal_uInt16(0x0004)) +#define SCRBAR_STATE_BTN2_DISABLE (sal_uInt16(0x0008)) +#define SCRBAR_STATE_PAGE1_DOWN (sal_uInt16(0x0010)) +#define SCRBAR_STATE_PAGE2_DOWN (sal_uInt16(0x0020)) +#define SCRBAR_STATE_THUMB_DOWN (sal_uInt16(0x0040)) #define SCRBAR_VIEW_STYLE (WB_3DLOOK | WB_HORZ | WB_VERT) diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index 61075e8b89e4..9bcc748fcd7a 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -24,9 +24,9 @@ #include "thumbpos.hxx" -#define SLIDER_STATE_CHANNEL1_DOWN ((sal_uInt16)0x0001) -#define SLIDER_STATE_CHANNEL2_DOWN ((sal_uInt16)0x0002) -#define SLIDER_STATE_THUMB_DOWN ((sal_uInt16)0x0004) +#define SLIDER_STATE_CHANNEL1_DOWN (sal_uInt16(0x0001)) +#define SLIDER_STATE_CHANNEL2_DOWN (sal_uInt16(0x0002)) +#define SLIDER_STATE_THUMB_DOWN (sal_uInt16(0x0004)) #define SLIDER_THUMB_SIZE 9 #define SLIDER_THUMB_HALFSIZE 4 diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index b94acb97f6dc..11d1bb0058ae 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -453,7 +453,7 @@ bool TabControl::ImplPlaceTabs( long nWidth ) nLineHeightAry[i] = nIH*(i-nCurLine-1) + GetItemsOffset().Y(); } - nLinePosAry[nLines+1] = (sal_uInt16)mpTabCtrlData->maItemList.size(); + nLinePosAry[nLines+1] = static_cast<sal_uInt16>(mpTabCtrlData->maItemList.size()); long nDX = 0; long nModDX = 0; @@ -1761,7 +1761,7 @@ void TabControl::EnablePage( sal_uInt16 i_nPageId, bool i_bEnable ) sal_uInt16 TabControl::GetPageCount() const { - return (sal_uInt16)mpTabCtrlData->maItemList.size(); + return static_cast<sal_uInt16>(mpTabCtrlData->maItemList.size()); } sal_uInt16 TabControl::GetPageId( sal_uInt16 nPos ) const @@ -1777,7 +1777,7 @@ sal_uInt16 TabControl::GetPagePos( sal_uInt16 nPageId ) const it != mpTabCtrlData->maItemList.end(); ++it ) { if ( it->mnId == nPageId ) - return (sal_uInt16)(it - mpTabCtrlData->maItemList.begin()); + return static_cast<sal_uInt16>(it - mpTabCtrlData->maItemList.begin()); } return TAB_PAGE_NOTFOUND; @@ -2030,7 +2030,7 @@ tools::Rectangle TabControl::GetCharacterBounds( sal_uInt16 nPageId, long nIndex if( HasLayoutData() ) { - std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( (int)nPageId ); + std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( static_cast<int>(nPageId) ); if( it != mpTabCtrlData->maLayoutPageIdToLine.end() ) { Pair aPair = mpControlData->mpLayoutData->GetLineStartEnd( it->second ); @@ -2063,7 +2063,7 @@ long TabControl::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) co if( aPair.A() <= nIndex && aPair.B() >= nIndex ) { nRet = nIndex - aPair.A(); - rPageId = (sal_uInt16)mpTabCtrlData->maLayoutLineToPageId[ nLine ]; + rPageId = static_cast<sal_uInt16>(mpTabCtrlData->maLayoutLineToPageId[ nLine ]); break; } } diff --git a/vcl/source/control/thumbpos.hxx b/vcl/source/control/thumbpos.hxx index 00e3d3c769eb..1992bd853745 100644 --- a/vcl/source/control/thumbpos.hxx +++ b/vcl/source/control/thumbpos.hxx @@ -14,8 +14,8 @@ inline long ImplMulDiv( long nNumber, long nNumerator, long nDenominator ) { if (!nDenominator) return 0; - double n = ((double)nNumber * (double)nNumerator) / (double)nDenominator; - return (long)n; + double n = (static_cast<double>(nNumber) * static_cast<double>(nNumerator)) / static_cast<double>(nDenominator); + return static_cast<long>(n); } #endif // INCLUDED_VCL_SOURCE_CONTROL_THUMBPOS_HXX diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 5d470d164b97..8d6a54e7cff2 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -1607,9 +1607,9 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uInt32 nPara ) aTmpLine.SetEnd( aTmpLine.GetStart() ); if ( ImpGetAlign() == TxtAlign::Center ) - aTmpLine.SetStartX( (short)(mnMaxTextWidth / 2) ); + aTmpLine.SetStartX( static_cast<short>(mnMaxTextWidth / 2) ); else if ( ImpGetAlign() == TxtAlign::Right ) - aTmpLine.SetStartX( (short)mnMaxTextWidth ); + aTmpLine.SetStartX( static_cast<short>(mnMaxTextWidth) ); else aTmpLine.SetStartX( mpDoc->GetLeftMargin() ); @@ -2272,9 +2272,9 @@ bool TextEngine::CreateLines( sal_uInt32 nPara ) if ( nSpace > 0 ) { if ( ImpGetAlign() == TxtAlign::Center ) - pLine->SetStartX( (sal_uInt16)(nSpace / 2) ); + pLine->SetStartX( static_cast<sal_uInt16>(nSpace / 2) ); else // TxtAlign::Right - pLine->SetStartX( (sal_uInt16)nSpace ); + pLine->SetStartX( static_cast<sal_uInt16>(nSpace) ); } } else diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 6ba271aecbf3..e080dcdb51a8 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -1159,9 +1159,9 @@ TextSelection const & TextView::ImpMoveCursor( const KeyEvent& rKeyEvent ) break; case KEY_PAGEDOWN: aPaM = bCtrl ? CursorEndOfDoc() : PageDown( aPaM ); break; - case KEY_LEFT: aPaM = bCtrl ? CursorWordLeft( aPaM ) : CursorLeft( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCHARACTER : (sal_uInt16)css::i18n::CharacterIteratorMode::SKIPCELL ); + case KEY_LEFT: aPaM = bCtrl ? CursorWordLeft( aPaM ) : CursorLeft( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) : sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); break; - case KEY_RIGHT: aPaM = bCtrl ? CursorWordRight( aPaM ) : CursorRight( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCHARACTER : (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCELL ); + case KEY_RIGHT: aPaM = bCtrl ? CursorWordRight( aPaM ) : CursorRight( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) : sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); break; case css::awt::Key::SELECT_WORD_FORWARD: bSelect = true; @@ -1344,7 +1344,7 @@ TextPaM TextView::ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ) { if ( nDelMode == DELMODE_SIMPLE ) { - aEndPaM = CursorLeft( aEndPaM, (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCHARACTER ); + aEndPaM = CursorLeft( aEndPaM, sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) ); } else if ( nDelMode == DELMODE_RESTOFWORD ) { @@ -1372,7 +1372,7 @@ TextPaM TextView::ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ) { if ( nDelMode == DELMODE_SIMPLE ) { - aEndPaM = CursorRight( aEndPaM, (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCELL ); + aEndPaM = CursorRight( aEndPaM, sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); } else if ( nDelMode == DELMODE_RESTOFWORD ) { @@ -1407,7 +1407,7 @@ TextPaM TextView::CursorUp( const TextPaM& rPaM ) if ( mpImpl->mnTravelXPos == TRAVEL_X_DONTKNOW ) { nX = mpImpl->mpTextEngine->GetEditCursor( rPaM, false ).Left(); - mpImpl->mnTravelXPos = (sal_uInt16)nX+1; + mpImpl->mnTravelXPos = static_cast<sal_uInt16>(nX)+1; } else nX = mpImpl->mnTravelXPos; @@ -1443,7 +1443,7 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM ) if ( mpImpl->mnTravelXPos == TRAVEL_X_DONTKNOW ) { nX = mpImpl->mpTextEngine->GetEditCursor( rPaM, false ).Left(); - mpImpl->mnTravelXPos = (sal_uInt16)nX+1; + mpImpl->mnTravelXPos = static_cast<sal_uInt16>(nX)+1; } else nX = mpImpl->mnTravelXPos; @@ -1611,7 +1611,7 @@ void TextView::ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bSpec } else { - TextPaM aNext = CursorRight( TextPaM( aPaM.GetPara(), aPaM.GetIndex() ), (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCELL ); + TextPaM aNext = CursorRight( TextPaM( aPaM.GetPara(), aPaM.GetIndex() ), sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); aEditCursor.Right() = mpImpl->mpTextEngine->GetEditCursor( aNext, true ).Left(); } } diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 66fb2b058d72..0bc1ea45589b 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -637,8 +637,8 @@ void ImpVclMEdit::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLi static const sal_Unicode sampleChar = { 'x' }; Size aOutSz = mpTextWindow->GetOutputSizePixel(); Size aCharSz( mpTextWindow->GetTextWidth( OUString(sampleChar) ), mpTextWindow->GetTextHeight() ); - rnCols = (sal_uInt16) (aOutSz.Width()/aCharSz.Width()); - rnLines = (sal_uInt16) (aOutSz.Height()/aCharSz.Height()); + rnCols = static_cast<sal_uInt16>(aOutSz.Width()/aCharSz.Width()); + rnLines = static_cast<sal_uInt16>(aOutSz.Height()/aCharSz.Height()); } void ImpVclMEdit::Enable( bool bEnable ) @@ -1384,7 +1384,7 @@ void VclMultiLineEdit::Draw( OutputDevice* pDev, const Point& rPos, const Size& OUString aText = GetText(); Size aTextSz( pDev->GetTextWidth( aText ), pDev->GetTextHeight() ); - sal_uLong nLines = (sal_uLong) (aSize.Height() / aTextSz.Height()); + sal_uLong nLines = static_cast<sal_uLong>(aSize.Height() / aTextSz.Height()); if ( !nLines ) nLines = 1; aTextSz.Height() = nLines*aTextSz.Height(); diff --git a/vcl/source/filter/GraphicNativeTransform.cxx b/vcl/source/filter/GraphicNativeTransform.cxx index 4870e7011649..84ab1d5d4f6d 100644 --- a/vcl/source/filter/GraphicNativeTransform.cxx +++ b/vcl/source/filter/GraphicNativeTransform.cxx @@ -96,11 +96,11 @@ bool GraphicNativeTransform::rotateGeneric(sal_uInt16 aRotation, const OUString& css::uno::Sequence< css::beans::PropertyValue > aFilterData( 3 ); aFilterData[ 0 ].Name = "Interlaced"; - aFilterData[ 0 ].Value <<= (sal_Int32) 0; + aFilterData[ 0 ].Value <<= sal_Int32(0); aFilterData[ 1 ].Name = "Compression"; - aFilterData[ 1 ].Value <<= (sal_Int32) 9; + aFilterData[ 1 ].Value <<= sal_Int32(9); aFilterData[ 2 ].Name = "Quality"; - aFilterData[ 2 ].Value <<= (sal_Int32) 90; + aFilterData[ 2 ].Value <<= sal_Int32(90); sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( aType ); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 062f5ee3701d..970af31dd060 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -287,8 +287,8 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, // Big-Endian: for (int i = 0; i < 4; ++i) { - nFirstLong=(nFirstLong<<8)|(sal_uLong)sFirstBytes[i]; - nSecondLong=(nSecondLong<<8)|(sal_uLong)sFirstBytes[i+4]; + nFirstLong=(nFirstLong<<8)|static_cast<sal_uLong>(sFirstBytes[i]); + nSecondLong=(nSecondLong<<8)|static_cast<sal_uLong>(sFirstBytes[i+4]); } // The following variable is used when bTest == true. It remains false @@ -1957,14 +1957,14 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r else if (nColorCount<=256) nBitsPerPixel=8; else if (nColorCount<=65536) nBitsPerPixel=16; else nBitsPerPixel=24; - nNeededMem=((sal_uLong)aSizePixel.Width()*(sal_uLong)aSizePixel.Height()*nBitsPerPixel+7)/8; + nNeededMem=(static_cast<sal_uLong>(aSizePixel.Width())*static_cast<sal_uLong>(aSizePixel.Height())*nBitsPerPixel+7)/8; // is the image larger than available memory? if (nMaxMem<nNeededMem) { - double fFak=sqrt(((double)nMaxMem)/((double)nNeededMem)); - aSizePixel.Width()=(sal_uLong)(((double)aSizePixel.Width())*fFak); - aSizePixel.Height()=(sal_uLong)(((double)aSizePixel.Height())*fFak); + double fFak=sqrt(static_cast<double>(nMaxMem)/static_cast<double>(nNeededMem)); + aSizePixel.Width()=static_cast<sal_uLong>(static_cast<double>(aSizePixel.Width())*fFak); + aSizePixel.Height()=static_cast<sal_uLong>(static_cast<double>(aSizePixel.Height())*fFak); } aVirDev->SetMapMode(MapMode(MapUnit::MapPixel)); @@ -2107,7 +2107,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r for ( k = 0; k < 4; k++ ) { nChunkType <<= 8; - nChunkType |= (sal_uInt8)aAdditionalChunkSequence[ j ].Name[ k ]; + nChunkType |= static_cast<sal_uInt8>(aAdditionalChunkSequence[ j ].Name[ k ]); } css::uno::Sequence< sal_Int8 > aByteSeq; if ( aAdditionalChunkSequence[ j ].Value >>= aByteSeq ) @@ -2376,7 +2376,7 @@ ErrCode GraphicFilter::compressAsPNG(const Graphic& rGraphic, SvStream& rOutputS { css::uno::Sequence< css::beans::PropertyValue > aFilterData(1); aFilterData[0].Name = "Compression"; - aFilterData[0].Value <<= (sal_uInt32) 9; + aFilterData[0].Value <<= sal_uInt32(9); sal_uInt16 nFilterFormat = GetExportFormatNumberForShortName("PNG"); return ExportGraphic(rGraphic, OUString(), rOutputStream, nFilterFormat, &aFilterData); diff --git a/vcl/source/filter/igif/decode.cxx b/vcl/source/filter/igif/decode.cxx index bbbbee27d10d..63d8b9136116 100644 --- a/vcl/source/filter/igif/decode.cxx +++ b/vcl/source/filter/igif/decode.cxx @@ -51,7 +51,7 @@ GIFLZWDecompressor::GIFLZWDecompressor(sal_uInt8 cDataSize) { pTable[i].pPrev = nullptr; pTable[i].pFirst = pTable.get() + i; - pTable[i].nData = (sal_uInt8) i; + pTable[i].nData = static_cast<sal_uInt8>(i); } memset(pTable.get() + nTableSize, 0, sizeof(GIFLZWTableEntry) * (4098 - nTableSize)); @@ -118,7 +118,7 @@ bool GIFLZWDecompressor::AddToTable( sal_uInt16 nPrevCode, sal_uInt16 nCodeFirst pE->nData = pEntry->nData; nTableSize++; - if ( ( nTableSize == (sal_uInt16) (1 << nCodeSize) ) && ( nTableSize < 4096 ) ) + if ( ( nTableSize == static_cast<sal_uInt16>(1 << nCodeSize) ) && ( nTableSize < 4096 ) ) nCodeSize++; } return true; @@ -138,7 +138,7 @@ bool GIFLZWDecompressor::ProcessOneCode() break; } - nInputBitsBuf |= ( (sal_uLong) pBlockBuf[ nBlockBufPos++ ] ) << nInputBitsBufSize; + nInputBitsBuf |= static_cast<sal_uLong>(pBlockBuf[ nBlockBufPos++ ]) << nInputBitsBufSize; nInputBitsBufSize += 8; } @@ -146,7 +146,7 @@ bool GIFLZWDecompressor::ProcessOneCode() { // fetch code from input buffer nCode = sal::static_int_cast< sal_uInt16 >( - ( (sal_uInt16) nInputBitsBuf ) & ( ~( 0xffff << nCodeSize ) )); + static_cast<sal_uInt16>(nInputBitsBuf) & ( ~( 0xffff << nCodeSize ) )); nInputBitsBuf >>= nCodeSize; nInputBitsBufSize = nInputBitsBufSize - nCodeSize; diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index f35d2d398c19..ea92b3ee1a0c 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -205,7 +205,7 @@ void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, if( pAcc1 ) { - cTransIndex1 = (sal_uInt8) pAcc1->GetBestPaletteIndex( aWhite ); + cTransIndex1 = static_cast<sal_uInt8>(pAcc1->GetBestPaletteIndex( aWhite )); cNonTransIndex1 = cTransIndex1 ? 0 : 1; } else @@ -364,7 +364,7 @@ bool GIFReader::ReadExtension() rIStm.ReadUChar( cByte ); nLoops = cByte; rIStm.ReadUChar( cByte ); - nLoops |= ( (sal_uInt16) cByte << 8 ); + nLoops |= ( static_cast<sal_uInt16>(cByte) << 8 ); rIStm.ReadUChar( cByte ); bStatus = ( cByte == 0 ); @@ -415,7 +415,7 @@ bool GIFReader::ReadExtension() bRet = true; while( cSize && bStatus && !rIStm.eof() ) { - sal_uInt16 nCount = (sal_uInt16) cSize + 1; + sal_uInt16 nCount = static_cast<sal_uInt16>(cSize) + 1; const sal_uInt64 nMaxPossible = rIStm.remainingSize(); if (nCount > nMaxPossible) nCount = nMaxPossible; @@ -537,8 +537,8 @@ void GIFReader::FillImages( const sal_uInt8* pBytes, sal_uLong nCount ) // lines will be copied if interlaced if( nLastInterCount ) { - long nMinY = std::min( (long) nLastImageY + 1, (long) nImageHeight - 1 ); - long nMaxY = std::min( (long) nLastImageY + nLastInterCount, (long) nImageHeight - 1 ); + long nMinY = std::min( static_cast<long>(nLastImageY) + 1, static_cast<long>(nImageHeight) - 1 ); + long nMaxY = std::min( static_cast<long>(nLastImageY) + nLastInterCount, static_cast<long>(nImageHeight) - 1 ); // copy last line read, if lines do not coincide // ( happens at the end of the image ) @@ -589,7 +589,7 @@ void GIFReader::FillImages( const sal_uInt8* pBytes, sal_uLong nCount ) } } - nLastImageY = (sal_uInt16) nT1; + nLastImageY = static_cast<sal_uInt16>(nT1); nYAcc = nT1; } else diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 45e885bece52..d44ec06aa5a3 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -80,36 +80,36 @@ void XBMReader::InitTable() { memset( pHexTable.get(), 0, sizeof( short ) * 256 ); - pHexTable[(int)'0'] = 0; - pHexTable[(int)'1'] = 1; - pHexTable[(int)'2'] = 2; - pHexTable[(int)'3'] = 3; - pHexTable[(int)'4'] = 4; - pHexTable[(int)'5'] = 5; - pHexTable[(int)'6'] = 6; - pHexTable[(int)'7'] = 7; - pHexTable[(int)'8'] = 8; - pHexTable[(int)'9'] = 9; - pHexTable[(int)'A'] = 10; - pHexTable[(int)'B'] = 11; - pHexTable[(int)'C'] = 12; - pHexTable[(int)'D'] = 13; - pHexTable[(int)'E'] = 14; - pHexTable[(int)'F'] = 15; - pHexTable[(int)'X'] = 0; - pHexTable[(int)'a'] = 10; - pHexTable[(int)'b'] = 11; - pHexTable[(int)'c'] = 12; - pHexTable[(int)'d'] = 13; - pHexTable[(int)'e'] = 14; - pHexTable[(int)'f'] = 15; - pHexTable[(int)'x'] = 0; - pHexTable[(int)' '] = -1; - pHexTable[(int)','] = -1; - pHexTable[(int)'}'] = -1; - pHexTable[(int)'\n'] = -1; - pHexTable[(int)'\t'] = -1; - pHexTable[(int)'\0'] = -1; + pHexTable[int('0')] = 0; + pHexTable[int('1')] = 1; + pHexTable[int('2')] = 2; + pHexTable[int('3')] = 3; + pHexTable[int('4')] = 4; + pHexTable[int('5')] = 5; + pHexTable[int('6')] = 6; + pHexTable[int('7')] = 7; + pHexTable[int('8')] = 8; + pHexTable[int('9')] = 9; + pHexTable[int('A')] = 10; + pHexTable[int('B')] = 11; + pHexTable[int('C')] = 12; + pHexTable[int('D')] = 13; + pHexTable[int('E')] = 14; + pHexTable[int('F')] = 15; + pHexTable[int('X')] = 0; + pHexTable[int('a')] = 10; + pHexTable[int('b')] = 11; + pHexTable[int('c')] = 12; + pHexTable[int('d')] = 13; + pHexTable[int('e')] = 14; + pHexTable[int('f')] = 15; + pHexTable[int('x')] = 0; + pHexTable[int(' ')] = -1; + pHexTable[int(',')] = -1; + pHexTable[int('}')] = -1; + pHexTable[int('\n')] = -1; + pHexTable[int('\t')] = -1; + pHexTable[int('\0')] = -1; } OString XBMReader::FindTokenLine( SvStream* pInStm, const char* pTok1, diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index 7c0aecd5fa47..8606491462fd 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -87,8 +87,8 @@ extern "C" boolean fill_input_buffer (j_decompress_ptr cinfo) } WARNMS(cinfo, JWRN_JPEG_EOF); /* Insert a fake EOI marker */ - source->buffer[0] = (JOCTET) 0xFF; - source->buffer[1] = (JOCTET) JPEG_EOI; + source->buffer[0] = JOCTET(0xFF); + source->buffer[1] = JOCTET(JPEG_EOI); nbytes = 2; } @@ -109,17 +109,17 @@ extern "C" void skip_input_data (j_decompress_ptr cinfo, long numberOfBytes) */ if (numberOfBytes > 0) { - while (numberOfBytes > (long) source->pub.bytes_in_buffer) + while (numberOfBytes > static_cast<long>(source->pub.bytes_in_buffer)) { - numberOfBytes -= (long) source->pub.bytes_in_buffer; + numberOfBytes -= static_cast<long>(source->pub.bytes_in_buffer); (void) fill_input_buffer(cinfo); /* note we assume that fill_input_buffer will never return false, * so suspension need not be handled. */ } - source->pub.next_input_byte += (size_t) numberOfBytes; - source->pub.bytes_in_buffer -= (size_t) numberOfBytes; + source->pub.next_input_byte += static_cast<size_t>(numberOfBytes); + source->pub.bytes_in_buffer -= static_cast<size_t>(numberOfBytes); } } @@ -204,7 +204,7 @@ bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam) for( sal_uInt16 n = 0; n < 256; n++ ) { - const sal_uInt8 cGray = (sal_uInt8) n; + const sal_uInt8 cGray = static_cast<sal_uInt8>(n); aGrayPal[ n ] = BitmapColor( cGray, cGray, cGray ); } diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx index e120fc304228..6b4cce3607b1 100644 --- a/vcl/source/filter/jpeg/jpegc.cxx +++ b/vcl/source/filter/jpeg/jpegc.cxx @@ -363,8 +363,8 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream, aOwner.set(&cinfo); jpeg_svstream_dest( &cinfo, pOutputStream ); - cinfo.image_width = (JDIMENSION) nWidth; - cinfo.image_height = (JDIMENSION) nHeight; + cinfo.image_width = static_cast<JDIMENSION>(nWidth); + cinfo.image_height = static_cast<JDIMENSION>(nHeight); if ( bGreys ) { cinfo.input_components = 1; @@ -377,7 +377,7 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream, } jpeg_set_defaults( &cinfo ); - jpeg_set_quality( &cinfo, (int) nQualityPercent, FALSE ); + jpeg_set_quality( &cinfo, static_cast<int>(nQualityPercent), FALSE ); cinfo.density_unit = 1; cinfo.X_density = rPPI.getX(); diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index e3dd3d5231e1..de1060a58698 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -206,8 +206,8 @@ void EMFWriter::ImplWritePlusColor( const Color& rColor, sal_uInt32 nTrans ) sal_uInt32 nAlpha = ((100-nTrans)*0xFF)/100; sal_uInt32 nCol = rColor.GetBlue(); - nCol |= ( (sal_uInt32) rColor.GetGreen() ) << 8; - nCol |= ( (sal_uInt32) rColor.GetRed() ) << 16; + nCol |= static_cast<sal_uInt32>(rColor.GetGreen()) << 8; + nCol |= static_cast<sal_uInt32>(rColor.GetRed()) << 16; nCol |= ( nAlpha << 24 ); m_rStm.WriteUInt32( nCol ); } @@ -562,8 +562,8 @@ void EMFWriter::ImplWriteColor( const Color& rColor ) { sal_uInt32 nCol = rColor.GetRed(); - nCol |= ( (sal_uInt32) rColor.GetGreen() ) << 8; - nCol |= ( (sal_uInt32) rColor.GetBlue() ) << 16; + nCol |= static_cast<sal_uInt32>(rColor.GetGreen()) << 8; + nCol |= static_cast<sal_uInt32>(rColor.GetBlue()) << 16; m_rStm.WriteUInt32( nCol ); } @@ -810,7 +810,7 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, if (nColsUsed) nPalCount = nColsUsed; else - nPalCount = 1 << (sal_uInt32)nBitCount; + nPalCount = 1 << static_cast<sal_uInt32>(nBitCount); } else { @@ -864,7 +864,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c if( nWidth && nNormWidth && ( nWidth != nNormWidth ) ) { - const double fFactor = (double) nWidth / nNormWidth; + const double fFactor = static_cast<double>(nWidth) / nNormWidth; for( i = 0; i < ( nLen - 1 ); i++ ) pDX[ i ] = FRound( pDX[ i ] * fFactor ); @@ -1180,8 +1180,8 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) const Size aSrcSize( aTmpMtf.GetPrefSize() ); const Point aDestPt( pA->GetPoint() ); const Size aDestSize( pA->GetSize() ); - const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0; + const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; long nMoveX, nMoveY; if( fScaleX != 1.0 || fScaleY != 1.0 ) diff --git a/vcl/source/filter/wmf/wmfexternal.cxx b/vcl/source/filter/wmf/wmfexternal.cxx index eda806a3d113..27e490a504e2 100644 --- a/vcl/source/filter/wmf/wmfexternal.cxx +++ b/vcl/source/filter/wmf/wmfexternal.cxx @@ -35,11 +35,11 @@ css::uno::Sequence< css::beans::PropertyValue > WmfExternal::getSequence() const { aSequence.realloc(3); aSequence[0].Name = "Width"; - aSequence[0].Value <<= (sal_Int16)xExt; + aSequence[0].Value <<= static_cast<sal_Int16>(xExt); aSequence[1].Name = "Height"; - aSequence[1].Value <<= (sal_Int16)yExt; + aSequence[1].Value <<= static_cast<sal_Int16>(yExt); aSequence[2].Name = "MapMode"; - aSequence[2].Value <<= (sal_Int16)mapMode; + aSequence[2].Value <<= static_cast<sal_Int16>(mapMode); } return aSequence; diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 723a55ef4414..c50c5da5084b 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -577,10 +577,10 @@ void WMFWriter::TrueExtTextOut( const Point& rPoint, const OUString& rString, sal_Int32 nOriginalTextLen = rString.getLength(); std::unique_ptr<sal_Int16[]> pConvertedDXAry(new sal_Int16[ nOriginalTextLen ]); sal_Int32 j = 0; - pConvertedDXAry[ j++ ] = (sal_Int16)ScaleWidth( pDXAry[ 0 ] ); + pConvertedDXAry[ j++ ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ 0 ] )); for (sal_Int32 i = 1; i < ( nOriginalTextLen - 1 ); ++i) - pConvertedDXAry[ j++ ] = (sal_Int16)ScaleWidth( pDXAry[ i ] - pDXAry[ i - 1 ] ); - pConvertedDXAry[ j ] = (sal_Int16)ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) ); + pConvertedDXAry[ j++ ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ i ] - pDXAry[ i - 1 ] )); + pConvertedDXAry[ j ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) )); for (sal_Int32 i = 0; i < nOriginalTextLen; ++i) { @@ -1214,8 +1214,8 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else { for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) - pDXAry[ i ] = pDXAry[ i ] * (sal_Int32)pA->GetWidth() / nNormSize; - if ( ( nLen <= 1 ) || ( (sal_Int32)pA->GetWidth() == nNormSize ) ) + pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize; + if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) pDXAry.reset(); aSrcLineInfo = LineInfo(); SetAllAttr(); @@ -1421,7 +1421,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else aX += BigInt( aScaleX.GetNumerator()/2 ); aX /= BigInt( aScaleX.GetNumerator() ); - aOrigin.X() = (long)aX + aMM.GetOrigin().X(); + aOrigin.X() = static_cast<long>(aX) + aMM.GetOrigin().X(); BigInt aY( aOrigin.Y() ); aY *= BigInt( aScaleY.GetDenominator() ); if( aOrigin.Y() >= 0 ) @@ -1435,7 +1435,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else aY += BigInt( aScaleY.GetNumerator()/2 ); aY /= BigInt( aScaleY.GetNumerator() ); - aOrigin.Y() = (long)aY + aMM.GetOrigin().Y(); + aOrigin.Y() = static_cast<long>(aY) + aMM.GetOrigin().Y(); aSrcMapMode.SetOrigin( aOrigin ); aScaleX *= aSrcMapMode.GetScaleX(); @@ -1571,8 +1571,8 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) const Size aSrcSize( aTmpMtf.GetPrefSize() ); const Point aDestPt( pA->GetPoint() ); const Size aDestSize( pA->GetSize() ); - const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0; + const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; long nMoveX, nMoveY; aSrcLineInfo = LineInfo(); @@ -1639,7 +1639,7 @@ void WMFWriter::WriteHeader( bool bPlaceable ) { sal_uInt16 nCheckSum, nValue; Size aSize( OutputDevice::LogicToLogic(Size(1,1),MapMode(MapUnit::MapInch), aTargetMapMode) ); - sal_uInt16 nUnitsPerInch = (sal_uInt16) ( ( aSize.Width() + aSize.Height() ) >> 1 ); + sal_uInt16 nUnitsPerInch = static_cast<sal_uInt16>( ( aSize.Width() + aSize.Height() ) >> 1 ); nCheckSum=0; nValue=0xcdd7; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); @@ -1647,8 +1647,8 @@ void WMFWriter::WriteHeader( bool bPlaceable ) nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); - nValue=(sal_uInt16) aTargetSize.Width(); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); - nValue=(sal_uInt16) aTargetSize.Height(); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); + nValue=static_cast<sal_uInt16>(aTargetSize.Width()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); + nValue=static_cast<sal_uInt16>(aTargetSize.Height()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=nUnitsPerInch; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index 40acbb8fb99c..04ebff2a8ffb 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -116,11 +116,11 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchSt // if not bold or requiring emboldening prefer light fonts to bold fonts FontWeight ePatternWeight = rFSD.mbEmbolden ? WEIGHT_NORMAL : rFSD.GetWeight(); - int nReqWeight = (int)ePatternWeight; + int nReqWeight = static_cast<int>(ePatternWeight); if ( ePatternWeight > WEIGHT_MEDIUM ) nReqWeight += 100; - int nGivenWeight = (int)GetWeight(); + int nGivenWeight = static_cast<int>(GetWeight()); if( GetWeight() > WEIGHT_MEDIUM ) nGivenWeight += 100; diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index c6351c228097..5c59f344f87c 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -369,7 +369,7 @@ SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont ) rImplFont.maStyleName = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet()); ReadPair( rIStm, rImplFont.maAverageFontSize ); - rIStm.ReadUInt16( nTmp16 ); rImplFont.SetCharSet( (rtl_TextEncoding) nTmp16 ); + rIStm.ReadUInt16( nTmp16 ); rImplFont.SetCharSet( static_cast<rtl_TextEncoding>(nTmp16) ); rIStm.ReadUInt16( nTmp16 ); rImplFont.SetFamilyType( (FontFamily) nTmp16 ); rIStm.ReadUInt16( nTmp16 ); rImplFont.SetPitch( (FontPitch) nTmp16 ); rIStm.ReadUInt16( nTmp16 ); rImplFont.SetWeight( (FontWeight) nTmp16 ); @@ -419,7 +419,7 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont ) rOStm.WriteUInt16( rImplFont.meUnderline ); rOStm.WriteUInt16( rImplFont.meStrikeout ); rOStm.WriteUInt16( rImplFont.GetItalicNoAsk() ); - rOStm.WriteUInt16( (sal_uInt16)rImplFont.maLanguageTag.getLanguageType( false) ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maLanguageTag.getLanguageType( false)) ); rOStm.WriteUInt16( rImplFont.GetWidthTypeNoAsk() ); rOStm.WriteInt16( rImplFont.mnOrientation ); @@ -431,7 +431,7 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont ) // new in version 2 rOStm.WriteUChar( (sal_uChar)rImplFont.meRelief ); - rOStm.WriteUInt16( (sal_uInt16)rImplFont.maCJKLanguageTag.getLanguageType( false) ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maCJKLanguageTag.getLanguageType( false)) ); rOStm.WriteBool( rImplFont.mbVertical ); rOStm.WriteUInt16( (sal_uInt16)rImplFont.meEmphasisMark ); diff --git a/vcl/source/font/fontcharmap.cxx b/vcl/source/font/fontcharmap.cxx index 8da0e78c05c0..faf3c906bca7 100644 --- a/vcl/source/font/fontcharmap.cxx +++ b/vcl/source/font/fontcharmap.cxx @@ -203,7 +203,7 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult ) pStartGlyphs[i] = (cMinChar + nGlyphDelta) & 0xFFFF; } else { // update the glyphid-array with the glyphs in this range - pStartGlyphs[i] = -(int)aGlyphIdArray.size(); + pStartGlyphs[i] = -static_cast<int>(aGlyphIdArray.size()); const unsigned char* pGlyphIdPtr = pOffsetBase + 2*i + nRangeOffset; const size_t nRemainingSize = pEndValidArea - pGlyphIdPtr; const size_t nMaxPossibleRecords = nRemainingSize/2; diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index cd0b9f8557e9..1351b9167d4b 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -188,7 +188,7 @@ ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData ) : FontAttributes( rFontSelData ) , mnHeight ( rFontSelData.mnHeight ) , mnWidth ( rFontSelData.mnWidth ) - , mnOrientation( (short)(rFontSelData.mnOrientation) ) + , mnOrientation( static_cast<short>(rFontSelData.mnOrientation) ) , mnAscent( 0 ) , mnDescent( 0 ) , mnIntLeading( 0 ) diff --git a/vcl/source/font/fontselect.cxx b/vcl/source/font/fontselect.cxx index cefdcb178b7a..927e1106c5b6 100644 --- a/vcl/source/font/fontselect.cxx +++ b/vcl/source/font/fontselect.cxx @@ -52,7 +52,7 @@ FontSelectPatternAttributes::FontSelectPatternAttributes( const vcl::Font& rFont rFont.GetFontAttributes( *this ); // normalize orientation between 0 and 3600 - if( 3600 <= (unsigned)mnOrientation ) + if( 3600 <= static_cast<unsigned>(mnOrientation) ) { if( mnOrientation >= 0 ) mnOrientation %= 3600; @@ -118,7 +118,7 @@ size_t FontSelectPatternAttributes::hashCode() const nHash += 19 * GetWeight(); nHash += 29 * GetItalic(); nHash += 37 * mnOrientation; - nHash += 41 * (sal_uInt16)meLanguage; + nHash += 41 * static_cast<sal_uInt16>(meLanguage); if( mbVertical ) nHash += 53; return nHash; diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx index 286c13e411ce..3c759cddd067 100644 --- a/vcl/source/fontsubset/cff.cxx +++ b/vcl/source/fontsubset/cff.cxx @@ -279,7 +279,7 @@ private: void convertOneTypeOp(); void convertOneTypeEsc(); void callType2Subr( bool bGlobal, int nSubrNumber); - sal_Int32 getReadOfs() const { return (sal_Int32)(mpReadPtr - mpBasePtr);} + sal_Int32 getReadOfs() const { return static_cast<sal_Int32>(mpReadPtr - mpBasePtr);} const U8* mpBasePtr; const U8* mpBaseEnd; @@ -704,7 +704,7 @@ void CffSubsetterContext::convertOneTypeOp() } if( !(nMaskByte & nMaskBit)) continue; - if( i >= 8*(int)sizeof(mnCntrMask)) + if( i >= 8*int(sizeof(mnCntrMask))) mbIgnoreHints = true; if( mbIgnoreHints) continue; @@ -726,7 +726,7 @@ void CffSubsetterContext::convertOneTypeOp() } if( !(nMaskByte & nMaskBit)) continue; - if( i >= 8*(int)sizeof(nHintMask)) + if( i >= 8*int(sizeof(nHintMask))) mbIgnoreHints = true; if( mbIgnoreHints) continue; @@ -1656,7 +1656,7 @@ inline size_t Type1Emitter::emitRawData(const char* pData, size_t nLength) const inline void Type1Emitter::emitAllRaw() { // writeout raw data - assert( (mpPtr - maBuffer) < (int)sizeof(maBuffer)); + assert( (mpPtr - maBuffer) < int(sizeof(maBuffer))); emitRawData( maBuffer, mpPtr - maBuffer); // reset the raw buffer mpPtr = maBuffer; @@ -1664,7 +1664,7 @@ inline void Type1Emitter::emitAllRaw() inline void Type1Emitter::emitAllHex() { - assert( (mpPtr - maBuffer) < (int)sizeof(maBuffer)); + assert( (mpPtr - maBuffer) < int(sizeof(maBuffer))); for( const char* p = maBuffer; p < mpPtr;) { // convert binary chunk to hex char aHexBuf[0x4000]; diff --git a/vcl/source/fontsubset/fontsubset.cxx b/vcl/source/fontsubset/fontsubset.cxx index deed82e75bf9..c9cfd1213e42 100644 --- a/vcl/source/fontsubset/fontsubset.cxx +++ b/vcl/source/fontsubset/fontsubset.cxx @@ -130,7 +130,7 @@ bool FontSubsetInfo::CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths ) std::vector<sal_uInt16> aShortGlyphIds; aShortGlyphIds.reserve(mnReqGlyphCount); for (int i = 0; i < mnReqGlyphCount; ++i) - aShortGlyphIds.push_back((sal_uInt16)mpReqGlyphIds[i]); + aShortGlyphIds.push_back(static_cast<sal_uInt16>(mpReqGlyphIds[i])); // remove const_cast when sft-subsetter is const-correct sal_uInt8* pEncArray = const_cast<sal_uInt8*>( mpReqEncodedIds ); #endif diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 98cf6998bef0..2393318accc8 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -188,7 +188,7 @@ static sal_uInt32 GetUInt32(const sal_uInt8 *ptr, size_t offset) #define Int32FromMOTA(a) (a) #else static sal_uInt16 Int16FromMOTA(sal_uInt16 a) { - return (sal_uInt16) (((sal_uInt8)(a >> 8)) | ((sal_uInt8)a << 8)); + return static_cast<sal_uInt16>(static_cast<sal_uInt8>(a >> 8) | (static_cast<sal_uInt8>(a) << 8)); } static sal_uInt32 Int32FromMOTA(sal_uInt32 a) { return ((a>>24)&0xFF) | (((a>>8)&0xFF00) | ((a&0xFF00)<<8) | ((a&0xFF)<<24)); @@ -427,7 +427,7 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr i = 0; while (i <= lastPoint) { - pa[i++].flags = (sal_uInt32) (flag = *p++); + pa[i++].flags = static_cast<sal_uInt32>(flag = *p++); if (flag & 8) { /*- repeat flag */ n = *p++; for (j=0; j<n; j++) { @@ -445,15 +445,15 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr for (i = 0; i <= lastPoint; i++) { if (pa[i].flags & 0x02) { if (pa[i].flags & 0x10) { - z += (int) (*p++); + z += static_cast<int>(*p++); } else { - z -= (int) (*p++); + z -= static_cast<int>(*p++); } } else if ( !(pa[i].flags & 0x10)) { z += GetInt16(p, 0); p += 2; } - pa[i].x = (sal_Int16)z; + pa[i].x = static_cast<sal_Int16>(z); } /*- Process the Y coordinate */ @@ -469,7 +469,7 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr z += GetInt16(p, 0); p += 2; } - pa[i].y = (sal_Int16)z; + pa[i].y = static_cast<sal_Int16>(z); } for (i=0; i<numberOfContours; i++) { @@ -563,8 +563,8 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo ptr += 4; } else { if (flags & ARGS_ARE_XY_VALUES) { /* args are signed */ - e = (sal_Int8) *ptr++; - f = (sal_Int8) *ptr++; + e = static_cast<sal_Int8>(*ptr++); + f = static_cast<sal_Int8>(*ptr++); /* printf("ARGS_ARE_XY_VALUES: %d %d\n", e & 0xFF, f & 0xFF); */ } else { /* args are unsigned */ /* printf("!ARGS_ARE_XY_VALUES\n"); */ @@ -618,9 +618,9 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo const sal_uInt16 x = nextComponent[i].x; const sal_uInt16 y = nextComponent[i].y; t = fixedMulDiv(a, x << 16, m) + fixedMulDiv(c, y << 16, m) + sal_Int32(sal_uInt16(e) << 16); - cp.x = (sal_Int16)(fixedMul(t, m) >> 16); + cp.x = static_cast<sal_Int16>(fixedMul(t, m) >> 16); t = fixedMulDiv(b, x << 16, n) + fixedMulDiv(d, y << 16, n) + sal_Int32(sal_uInt16(f) << 16); - cp.y = (sal_Int16)(fixedMul(t, n) >> 16); + cp.y = static_cast<sal_Int16>(fixedMul(t, n) >> 16); myPoints.push_back( cp ); } @@ -809,7 +809,7 @@ static int BSplineToPSPath(ControlPoint const *srcA, int srcCount, PSPathElement } } - if( (nPathCount = (int)aPathList.size()) > 0) + if( (nPathCount = static_cast<int>(aPathList.size())) > 0) { *path = static_cast<PSPathElement*>(calloc(nPathCount, sizeof(PSPathElement))); assert(*path != nullptr); @@ -1069,8 +1069,8 @@ static sal_uInt32 getGlyph2(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize int k = -1; sal_uInt32 ToReturn; - theHighByte = (sal_uInt8)((c >> 8) & 0x00ff); - theLowByte = (sal_uInt8)(c & 0x00ff); + theHighByte = static_cast<sal_uInt8>((c >> 8) & 0x00ff); + theLowByte = static_cast<sal_uInt8>(c & 0x00ff); subHeader2Keys = CMAP2 + 3; subHeader2s = reinterpret_cast<subHeader2 const *>(subHeader2Keys + 256); if(reinterpret_cast<sal_uInt8 const *>(&subHeader2Keys[theHighByte]) - cmap < int(nMaxCmapSize - 2)) @@ -1133,8 +1133,8 @@ static sal_uInt32 getGlyph6(const sal_uInt8 *cmap, sal_uInt32, sal_uInt32 c) { static sal_uInt16 GEbinsearch(sal_uInt16 const *ar, sal_uInt16 length, sal_uInt16 toSearch) { signed int low, high, lastfound = 0xffff; sal_uInt16 res; - if(length == (sal_uInt16)0 || length == (sal_uInt16)0xFFFF) { - return (sal_uInt16)0xFFFF; + if(length == sal_uInt16(0) || length == sal_uInt16(0xFFFF)) { + return sal_uInt16(0xFFFF); } low = 0; high = length - 1; @@ -1148,7 +1148,7 @@ static sal_uInt16 GEbinsearch(sal_uInt16 const *ar, sal_uInt16 length, sal_uInt1 low = ++mid; } } - return (sal_uInt16)lastfound; + return static_cast<sal_uInt16>(lastfound); } static sal_uInt32 getGlyph4(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize, sal_uInt32 c) { @@ -1166,9 +1166,9 @@ static sal_uInt32 getGlyph4(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize segCount = Int16FromMOTA(*(CMAP4 + 3))/2; endCode = CMAP4 + 7; - i = GEbinsearch(endCode, segCount, (sal_uInt16)c); + i = GEbinsearch(endCode, segCount, static_cast<sal_uInt16>(c)); - if (i == (sal_uInt16) 0xFFFF) { + if (i == sal_uInt16(0xFFFF)) { return MISSING_GLYPH_INDEX; } startCode = endCode + segCount + 1; @@ -1262,7 +1262,7 @@ static void FindCmap(TrueTypeFont *ttf) sal_uInt32 offset = GetUInt32(table, nLargestFixedOffsetPos); /* sanity check, cmap must lie within file */ - if( (table - ttf->ptr) + offset > (sal_uInt32)ttf->fsize ) + if( (table - ttf->ptr) + offset > static_cast<sal_uInt32>(ttf->fsize) ) continue; /* Unicode tables in Apple fonts */ @@ -1552,7 +1552,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) assert(t->tlens != nullptr); /* parse the tables */ - for (i=0; i<(int)t->ntables; i++) { + for (i=0; i<static_cast<int>(t->ntables); i++) { int nIndex; tag = GetUInt32(t->ptr + tdoffset + 12, 16 * i); switch( tag ) { @@ -1585,7 +1585,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) } /* Fixup offsets when only a TTC extract was provided */ - if( facenum == (sal_uInt32)~0 ) { + if( facenum == sal_uInt32(~0) ) { sal_uInt8* pHead = const_cast<sal_uInt8*>(t->tables[O_head]); if( !pHead ) return SF_TTFORMAT; @@ -1664,18 +1664,18 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) if( getTable(t, O_glyf) && getTable(t, O_loca) ) /* TTF or TTF-OpenType */ { int k = (getTableSize(t, O_loca) / (indexfmt ? 4 : 2)) - 1; - if( k < (int)t->nglyphs ) /* Hack for broken Chinese fonts */ + if( k < static_cast<int>(t->nglyphs) ) /* Hack for broken Chinese fonts */ t->nglyphs = k; table = getTable(t, O_loca); t->goffsets = static_cast<sal_uInt32 *>(calloc(1+t->nglyphs, sizeof(sal_uInt32))); assert(t->goffsets != nullptr); - for( i = 0; i <= (int)t->nglyphs; ++i ) - t->goffsets[i] = indexfmt ? GetUInt32(table, i << 2) : (sal_uInt32)GetUInt16(table, i << 1) << 1; + for( i = 0; i <= static_cast<int>(t->nglyphs); ++i ) + t->goffsets[i] = indexfmt ? GetUInt32(table, i << 2) : static_cast<sal_uInt32>(GetUInt16(table, i << 1)) << 1; } else if( getTable(t, O_CFF) ) { /* PS-OpenType */ int k = (getTableSize(t, O_CFF) / 2) - 1; /* set a limit here, presumably much lower than the table size, but establishes some sort of physical bound */ - if( k < (int)t->nglyphs ) + if( k < static_cast<int>(t->nglyphs) ) t->nglyphs = k; t->goffsets = static_cast<sal_uInt32 *>(calloc(1+t->nglyphs, sizeof(sal_uInt32))); /* TODO: implement to get subsetting */ @@ -2238,7 +2238,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, sal_uInt16* gID = static_cast<sal_uInt16*>(scalloc(nGlyphs, sizeof(sal_uInt32))); for (i = 0; i < nGlyphs; i++) { - gID[i] = (sal_uInt16)glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); + gID[i] = static_cast<sal_uInt16>(glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf)); } AddTable(ttcr, head); AddTable(ttcr, hhea); AddTable(ttcr, maxp); AddTable(ttcr, cvt); @@ -2250,7 +2250,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, return res; } - fprintf(outf, "%%!PS-TrueTypeFont-%d.%d-%d.%d\n", (int)(ver>>16), (int)(ver & 0xFFFF), (int)(rev>>16), (int)(rev & 0xFFFF)); + fprintf(outf, "%%!PS-TrueTypeFont-%d.%d-%d.%d\n", static_cast<int>(ver>>16), static_cast<int>(ver & 0xFFFF), static_cast<int>(rev>>16), static_cast<int>(rev & 0xFFFF)); fprintf(outf, "%%%%Creator: %s %s %s\n", modname, modver, modextra); fprintf(outf, "%%- Font subset generated from a source font file: '%s'\n", ttf->fname); fprintf(outf, "%%- Original font name: %s\n", ttf->psname); @@ -2268,14 +2268,14 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, for (i = 1; i<nGlyphs; i++) { fprintf(outf, "Encoding %d /glyph%u put\n", encoding[i], gID[i]); } - fprintf(outf, "/XUID [103 0 1 16#%08X %u 16#%08X 16#%08X] def\n", (unsigned int)rtl_crc32(0, ttf->ptr, ttf->fsize), (unsigned int)nGlyphs, (unsigned int)rtl_crc32(0, glyphArray, nGlyphs * 2), (unsigned int)rtl_crc32(0, encoding, nGlyphs)); + fprintf(outf, "/XUID [103 0 1 16#%08X %u 16#%08X 16#%08X] def\n", static_cast<unsigned int>(rtl_crc32(0, ttf->ptr, ttf->fsize)), static_cast<unsigned int>(nGlyphs), static_cast<unsigned int>(rtl_crc32(0, glyphArray, nGlyphs * 2)), static_cast<unsigned int>(rtl_crc32(0, encoding, nGlyphs))); DumpSfnts(outf, sfntP, sfntLen); /* dump charstrings */ fprintf(outf, "/CharStrings %d dict dup begin\n", nGlyphs); fprintf(outf, "/.notdef 0 def\n"); - for (i = 1; i < (int)glyfCount(glyf); i++) { + for (i = 1; i < static_cast<int>(glyfCount(glyf)); i++) { fprintf(outf,"/glyph%d %d def\n", i, i); } fprintf(outf, "end readonly def\n"); @@ -2506,7 +2506,7 @@ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID) } d->glyphID = glyphID; - d->nbytes = (sal_uInt16)((length + 1) & ~1); + d->nbytes = static_cast<sal_uInt16>((length + 1) & ~1); /* now calculate npoints and ncontours */ ControlPoint *cp; @@ -2519,8 +2519,8 @@ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID) if (cp[i].flags & 0x8000) m++; } - d->npoints = (sal_uInt16)n; - d->ncontours = (sal_uInt16)m; + d->npoints = static_cast<sal_uInt16>(n); + d->ncontours = static_cast<sal_uInt16>(m); free(cp); } else { d->npoints = 0; diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index 6ea929cd728d..818f9ffce7da 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -78,26 +78,26 @@ static void PutInt16(sal_Int16 val, sal_uInt8 *ptr, sal_uInt32 offset) { assert(ptr != nullptr); - ptr[offset] = (sal_uInt8)((val >> 8) & 0xFF); - ptr[offset+1] = (sal_uInt8)(val & 0xFF); + ptr[offset] = static_cast<sal_uInt8>((val >> 8) & 0xFF); + ptr[offset+1] = static_cast<sal_uInt8>(val & 0xFF); } static void PutUInt16(sal_uInt16 val, sal_uInt8 *ptr, sal_uInt32 offset) { assert(ptr != nullptr); - ptr[offset] = (sal_uInt8)((val >> 8) & 0xFF); - ptr[offset+1] = (sal_uInt8)(val & 0xFF); + ptr[offset] = static_cast<sal_uInt8>((val >> 8) & 0xFF); + ptr[offset+1] = static_cast<sal_uInt8>(val & 0xFF); } static void PutUInt32(sal_uInt32 val, sal_uInt8 *ptr, sal_uInt32 offset) { assert(ptr != nullptr); - ptr[offset] = (sal_uInt8)((val >> 24) & 0xFF); - ptr[offset+1] = (sal_uInt8)((val >> 16) & 0xFF); - ptr[offset+2] = (sal_uInt8)((val >> 8) & 0xFF); - ptr[offset+3] = (sal_uInt8)(val & 0xFF); + ptr[offset] = static_cast<sal_uInt8>((val >> 24) & 0xFF); + ptr[offset+1] = static_cast<sal_uInt8>((val >> 16) & 0xFF); + ptr[offset+2] = static_cast<sal_uInt8>((val >> 8) & 0xFF); + ptr[offset+3] = static_cast<sal_uInt8>(val & 0xFF); } static int TableEntryCompareF(const void *l, const void *r) @@ -127,7 +127,7 @@ static int NameRecordCompareF(const void *l, const void *r) static sal_uInt32 CheckSum(sal_uInt32 *ptr, sal_uInt32 length) { sal_uInt32 sum = 0; - sal_uInt32 *endptr = ptr + ((length + 3) & (sal_uInt32) ~3) / 4; + sal_uInt32 *endptr = ptr + ((length + 3) & sal_uInt32(~3)) / 4; while (ptr < endptr) sum += *ptr++; @@ -234,7 +234,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) s = offset = 12 + 16 * numTables; for (int i = 0; i < numTables; ++i) { - s += (te[i].length + 3) & (sal_uInt32) ~3; + s += (te[i].length + 3) & sal_uInt32(~3); /* if ((te[i].length & 3) != 0) s += (4 - (te[i].length & 3)) & 3; */ } @@ -258,15 +258,15 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) head = ttf + offset; } - memcpy(ttf+offset, te[i].data, (te[i].length + 3) & (sal_uInt32) ~3 ); - offset += (te[i].length + 3) & (sal_uInt32) ~3; + memcpy(ttf+offset, te[i].data, (te[i].length + 3) & sal_uInt32(~3) ); + offset += (te[i].length + 3) & sal_uInt32(~3); /* if ((te[i].length & 3) != 0) offset += (4 - (te[i].length & 3)) & 3; */ } free(te); p = reinterpret_cast<sal_uInt32 *>(ttf); - for (int i = 0; i < (int)s / 4; ++i) checkSumAdjustment += p[i]; + for (int i = 0; i < static_cast<int>(s) / 4; ++i) checkSumAdjustment += p[i]; PutUInt32(0xB1B0AFBA - checkSumAdjustment, head, 8); *ptr = ttf; @@ -365,7 +365,7 @@ static sal_uInt8 *ttmalloc(sal_uInt32 nbytes) { sal_uInt32 n; - n = (nbytes + 3) & (sal_uInt32) ~3; + n = (nbytes + 3) & sal_uInt32(~3); sal_uInt8* res = static_cast<sal_uInt8*>(calloc(n, 1)); assert(res != nullptr); @@ -470,7 +470,7 @@ static void TrueTypeTableDispose_post(TrueTypeTable *_this) if (p->format == 0x00030000) { /* do nothing */ } else { - fprintf(stderr, "Unsupported format of a 'post' table: %08X.\n", (int)p->format); + fprintf(stderr, "Unsupported format of a 'post' table: %08X.\n", static_cast<int>(p->format)); } free(p); } @@ -606,10 +606,10 @@ static sal_uInt8 *PackCmapType0(CmapSubTable const *s, sal_uInt32 *length) g = 0; for (j = 0; j < s->n; j++) { if (s->xc[j] == i) { - g = (sal_uInt16) s->xg[j]; + g = static_cast<sal_uInt16>(s->xg[j]); } } - p[i] = (sal_uInt8) g; + p[i] = static_cast<sal_uInt8>(g); } *length = 262; return ptr; @@ -623,16 +623,16 @@ static sal_uInt8 *PackCmapType6(CmapSubTable const *s, sal_uInt32 *length) sal_uInt16 g; PutUInt16(6, ptr, 0); - PutUInt16((sal_uInt16)(s->n*2+10), ptr, 2); + PutUInt16(static_cast<sal_uInt16>(s->n*2+10), ptr, 2); PutUInt16(0, ptr, 4); PutUInt16(0, ptr, 6); - PutUInt16((sal_uInt16)(s->n), ptr, 8 ); + PutUInt16(static_cast<sal_uInt16>(s->n), ptr, 8 ); for (i = 0; i < s->n; i++) { g = 0; for (j = 0; j < s->n; j++) { if (s->xc[j] == i) { - g = (sal_uInt16) s->xg[j]; + g = static_cast<sal_uInt16>(s->xg[j]); } } PutUInt16( g, p, 2*i ); @@ -678,12 +678,12 @@ static int GetRawData_cmap(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le _this->rawdata = cmap = ttmalloc(cmapsize); PutUInt16(0, cmap, 0); - PutUInt16((sal_uInt16)t->n, cmap, 2); + PutUInt16(static_cast<sal_uInt16>(t->n), cmap, 2); coffset = 4 + t->n * 8; for (i = 0; i < t->n; i++) { - PutUInt16((sal_uInt16)(t->s[i].id >> 16), cmap + 4, i * 8); - PutUInt16((sal_uInt16)(t->s[i].id & 0xFF), cmap + 4, 2 + i * 8); + PutUInt16(static_cast<sal_uInt16>(t->s[i].id >> 16), cmap + 4, i * 8); + PutUInt16(static_cast<sal_uInt16>(t->s[i].id & 0xFF), cmap + 4, 2 + i * 8); PutUInt32(coffset, cmap + 4, 4 + i * 8); memcpy(cmap + coffset, subtables[i], sizes[i]); free(subtables[i]); @@ -715,7 +715,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le l = static_cast<list>(_this->data); assert(l != nullptr); - if ((n = (sal_Int16)listCount(l)) == 0) return TTCR_NONAMES; + if ((n = static_cast<sal_Int16>(listCount(l))) == 0) return TTCR_NONAMES; NameRecord* nr = static_cast<NameRecord*>(scalloc(n, sizeof(NameRecord))); @@ -739,7 +739,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le PutUInt16(0, name, 0); PutUInt16(n, name, 2); - PutUInt16((sal_uInt16)(6 + 12 * n), name, 4); + PutUInt16(static_cast<sal_uInt16>(6 + 12 * n), name, 4); p1 = name + 6; p2 = p1 + 12 * n; @@ -747,10 +747,10 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le for (i = 0; i < n; i++) { PutUInt16(nr[i].platformID, p1, 0); PutUInt16(nr[i].encodingID, p1, 2); - PutUInt16((sal_uInt16)nr[i].languageID, p1, 4); + PutUInt16(static_cast<sal_uInt16>(nr[i].languageID), p1, 4); PutUInt16(nr[i].nameID, p1, 6); PutUInt16(nr[i].slen, p1, 8); - PutUInt16((sal_uInt16)(p2 - (name + 6 + 12 * n)), p1, 10); + PutUInt16(static_cast<sal_uInt16>(p2 - (name + 6 + 12 * n)), p1, 10); if (nr[i].slen) { memcpy(p2, nr[i].sptr, nr[i].slen); } @@ -763,7 +763,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le _this->rawdata = name; *ptr = name; - *len = (sal_uInt16)nameLen; + *len = static_cast<sal_uInt16>(nameLen); *tag = T_name; /*{int j; for(j=0; j<nameLen; j++) printf("%c", name[j]); }; */ @@ -787,10 +787,10 @@ static int GetRawData_post(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le PutUInt32(p->italicAngle, post, 4); PutUInt16(p->underlinePosition, post, 8); PutUInt16(p->underlineThickness, post, 10); - PutUInt16((sal_uInt16)p->isFixedPitch, post, 12); + PutUInt16(static_cast<sal_uInt16>(p->isFixedPitch), post, 12); ret = TTCR_OK; } else { - fprintf(stderr, "Unrecognized format of a post table: %08X.\n", (int)p->format); + fprintf(stderr, "Unrecognized format of a post table: %08X.\n", static_cast<int>(p->format)); ret = TTCR_POSTFORMAT; } @@ -1150,7 +1150,7 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt assert(table != nullptr); assert(table->tag == T_glyf); - if (!glyphdata) return (sal_uInt32)~0; + if (!glyphdata) return sal_uInt32(~0); std::vector< sal_uInt32 > glyphlist; @@ -1324,7 +1324,7 @@ static void ProcessTables(TrueTypeCreator *tt) } /* printf("X: %d -> %d.\n", index, j); */ - PutUInt16((sal_uInt16) j, ptr, 2); + PutUInt16(static_cast<sal_uInt16>(j), ptr, 2); ptr += 4; @@ -1351,7 +1351,7 @@ static void ProcessTables(TrueTypeCreator *tt) PutUInt32(p1 - glyfPtr, p2, 0); p2 += 4; } else { - PutUInt16((sal_uInt16)((p1 - glyfPtr) >> 1), p2, 0); + PutUInt16(static_cast<sal_uInt16>((p1 - glyfPtr) >> 1), p2, 0); p2 += 2; } p1 += gd->nbytes; @@ -1367,7 +1367,7 @@ static void ProcessTables(TrueTypeCreator *tt) if (indexToLocFormat == 1) { PutUInt32(p1 - glyfPtr, p2, 0); } else { - PutUInt16((sal_uInt16)((p1 - glyfPtr) >> 1), p2, 0); + PutUInt16(static_cast<sal_uInt16>((p1 - glyfPtr) >> 1), p2, 0); } glyf->rawdata = glyfPtr; @@ -1389,7 +1389,7 @@ static void ProcessTables(TrueTypeCreator *tt) maxp = FindTable(tt, T_maxp); sal_uInt8* const pMaxpData = static_cast<sal_uInt8*>(maxp->data); - PutUInt16((sal_uInt16)nGlyphs, pMaxpData, 4); + PutUInt16(static_cast<sal_uInt16>(nGlyphs), pMaxpData, 4); PutUInt16(maxPoints, pMaxpData, 6); PutUInt16(maxContours, pMaxpData, 8); PutUInt16(maxCompositePoints, pMaxpData, 10); @@ -1422,7 +1422,7 @@ static void ProcessTables(TrueTypeCreator *tt) } AddTable(tt, TrueTypeTableNew(T_hmtx, hmtxSize, hmtxPtr)); - PutUInt16((sal_uInt16)(nGlyphs - nlsb), hheaPtr, 34); + PutUInt16(static_cast<sal_uInt16>(nGlyphs - nlsb), hheaPtr, 34); free(hmtxPtr); free(met); } diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 76147a201eb8..c438382df487 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -36,10 +36,10 @@ static inline void decode_hb_tag( const hb_tag_t nTableTag, char *pTagName ) { - pTagName[0] = (char)(nTableTag >> 24); - pTagName[1] = (char)(nTableTag >> 16); - pTagName[2] = (char)(nTableTag >> 8); - pTagName[3] = (char)nTableTag; + pTagName[0] = static_cast<char>(nTableTag >> 24); + pTagName[1] = static_cast<char>(nTableTag >> 16); + pTagName[2] = static_cast<char>(nTableTag >> 8); + pTagName[3] = static_cast<char>(nTableTag); pTagName[4] = 0; } diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index 9281fc101ddb..8e96965e7047 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -54,7 +54,7 @@ BitmapChecksum AnimationBitmap::GetChecksum() const UInt32ToSVBT32( (long) eDisposal, aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - UInt32ToSVBT32( (long) bUserInput, aBT32 ); + UInt32ToSVBT32( static_cast<long>(bUserInput), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); return nCrc; @@ -319,7 +319,7 @@ void Animation::Draw( OutputDevice* pOut, const Point& rDestPt, const Size& rDes void Animation::ImplRestartTimer( sal_uLong nTimeout ) { - maTimer.SetTimeout( std::max( nTimeout, (sal_uLong)(MIN_TIMEOUT + ( mnAnimCount - 1 ) * INC_TIMEOUT) ) * 10 ); + maTimer.SetTimeout( std::max( nTimeout, static_cast<sal_uLong>(MIN_TIMEOUT + ( mnAnimCount - 1 ) * INC_TIMEOUT) ) * 10 ); maTimer.Start(); } diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 373974f0f925..f8b9701350f1 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -96,7 +96,7 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett for( sal_uInt16 nB = 0; nB < 256; nB += 51 ) for( sal_uInt16 nG = 0; nG < 256; nG += 51 ) for( sal_uInt16 nR = 0; nR < 256; nR += 51 ) - aPal[ nActCol++ ] = BitmapColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ); + aPal[ nActCol++ ] = BitmapColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); // Set standard Office colors aPal[ nActCol++ ] = BitmapColor( 0, 184, 255 ); @@ -172,7 +172,7 @@ const BitmapPalette& Bitmap::GetGreyPalette( int nEntries ) aGreyPalette256.SetEntryCount( 256 ); for( sal_uInt16 i = 0; i < 256; i++ ) - aGreyPalette256[ i ] = BitmapColor( (sal_uInt8) i, (sal_uInt8) i, (sal_uInt8) i ); + aGreyPalette256[ i ] = BitmapColor( static_cast<sal_uInt8>(i), static_cast<sal_uInt8>(i), static_cast<sal_uInt8>(i) ); } return aGreyPalette256; @@ -647,7 +647,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) Point aTmpPoint; tools::Rectangle aTmpRectangle( aTmpPoint, aSizePix ); tools::Polygon aPoly( aTmpRectangle ); - aPoly.Rotate( aTmpPoint, (sal_uInt16) nAngle10 ); + aPoly.Rotate( aTmpPoint, static_cast<sal_uInt16>(nAngle10) ); tools::Rectangle aNewBound( aPoly.GetBoundRect() ); const Size aNewSizePix( aNewBound.GetSize() ); @@ -816,13 +816,13 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, for (int i = 0; ( i < nSrcCount ) && ( nNextIndex < nSrcCount ); ++i) { - const BitmapColor& rSrcCol = pSrcAcc->GetPaletteColor( (sal_uInt16) i ); + const BitmapColor& rSrcCol = pSrcAcc->GetPaletteColor( static_cast<sal_uInt16>(i) ); bool bFound = false; for (int j = 0; j < nDstCount; ++j) { - if( rSrcCol == pDstAcc->GetPaletteColor( (sal_uInt16) j ) ) + if( rSrcCol == pDstAcc->GetPaletteColor( static_cast<sal_uInt16>(j) ) ) { bFound = true; break; @@ -830,7 +830,7 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, } if( !bFound ) - pDstAcc->SetPaletteColor( (sal_uInt16) nNextIndex++, rSrcCol ); + pDstAcc->SetPaletteColor( static_cast<sal_uInt16>(nNextIndex++), rSrcCol ); } } } @@ -862,7 +862,7 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, // Create index map for the color table, as the bitmap should be copied // retaining it's color information relatively well for( sal_uInt16 i = 0; i < nCount; i++ ) - pMap[ i ] = (sal_uInt8) pWriteAcc->GetBestPaletteIndex( pReadAcc->GetPaletteColor( i ) ); + pMap[ i ] = static_cast<sal_uInt8>(pWriteAcc->GetBestPaletteIndex( pReadAcc->GetPaletteColor( i ) )); for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ ) for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ ) @@ -1451,7 +1451,7 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) { pAcc->SetPaletteEntryCount( nActColors + 1 ); pAcc->SetPaletteColor( nActColors, rReplaceColor ); - aReplace = BitmapColor( (sal_uInt8) nActColors ); + aReplace = BitmapColor( static_cast<sal_uInt8>(nActColors) ); } else { @@ -1470,7 +1470,7 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) if( !pFlags[ i ] ) { pAcc->SetPaletteColor( i, rReplaceColor ); - aReplace = BitmapColor( (sal_uInt8) i ); + aReplace = BitmapColor( static_cast<sal_uInt8>(i) ); } } } diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 668bf5f23f29..180e4acacbfd 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -37,8 +37,8 @@ #include <octree.hxx> #include <BitmapScaleConvolution.hxx> -#define RGB15( _def_cR, _def_cG, _def_cB ) (((sal_uLong)(_def_cR)<<10)|((sal_uLong)(_def_cG)<<5)|(sal_uLong)(_def_cB)) -#define GAMMA( _def_cVal, _def_InvGamma ) ((sal_uInt8)MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255)) +#define RGB15( _def_cR, _def_cG, _def_cB ) ((static_cast<sal_uLong>(_def_cR)<<10)|(static_cast<sal_uLong>(_def_cG)<<5)|static_cast<sal_uLong>(_def_cB)) +#define GAMMA( _def_cVal, _def_InvGamma ) (static_cast<sal_uInt8>(MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255))) #define CALC_ERRORS \ nTemp = p1T[nX++] >> 12; \ @@ -426,7 +426,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) const sal_uLong nG = *pReadScan++; const sal_uLong nR = *pReadScan++; - *pWriteScan++ = (sal_uInt8) ( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); + *pWriteScan++ = static_cast<sal_uInt8>( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); } } } @@ -446,7 +446,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) const sal_uLong nG = *pReadScan++; const sal_uLong nB = *pReadScan++; - *pWriteScan++ = (sal_uInt8) ( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); + *pWriteScan++ = static_cast<sal_uInt8>( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); } } } @@ -632,7 +632,7 @@ bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color const * pExtColor) for (long nY = 0; nY < nHeight; nY++, nYTmp++) { // first pixel in the line - cIndex = (sal_uInt8) aColorMap.GetBestPaletteIndex(pQLine1[0].ImplGetColor()); + cIndex = static_cast<sal_uInt8>(aColorMap.GetBestPaletteIndex(pQLine1[0].ImplGetColor())); pWriteAcc->SetPixelIndex(nY, 0, cIndex); long nX; @@ -704,8 +704,8 @@ bool Bitmap::ImplConvertGhosted() for( long i = 0, nCount = aNewPal.GetEntryCount(); i < nCount; i++ ) { - const BitmapColor& rOld = pR->GetPaletteColor( (sal_uInt16) i ); - aNewPal[ (sal_uInt16) i ] = BitmapColor( ( rOld.GetRed() >> 1 ) | 0x80, + const BitmapColor& rOld = pR->GetPaletteColor( static_cast<sal_uInt16>(i) ); + aNewPal[ static_cast<sal_uInt16>(i) ] = BitmapColor( ( rOld.GetRed() >> 1 ) | 0x80, ( rOld.GetGreen() >> 1 ) | 0x80, ( rOld.GetBlue() >> 1 ) | 0x80 ); } @@ -868,8 +868,8 @@ bool Bitmap::Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag ) if( aSize.Width() && aSize.Height() ) { - bRet = Scale( (double) rNewSize.Width() / aSize.Width(), - (double) rNewSize.Height() / aSize.Height(), + bRet = Scale( static_cast<double>(rNewSize.Width()) / aSize.Width(), + static_cast<double>(rNewSize.Height()) / aSize.Height(), nScaleFlag ); } else @@ -1030,7 +1030,7 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY { const long nNewWidth1 = nNewWidth - 1; const long nWidth1 = pReadAcc->Width() - 1; - const double fRevScaleX = (double) nWidth1 / nNewWidth1; + const double fRevScaleX = static_cast<double>(nWidth1) / nNewWidth1; std::unique_ptr<long[]> pLutInt(new long[ nNewWidth ]); std::unique_ptr<long[]> pLutFrac(new long[ nNewWidth ]); @@ -1038,9 +1038,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY for( long nX = 0, nTemp = nWidth - 2; nX < nNewWidth; nX++ ) { double fTemp = nX * fRevScaleX; - pLutInt[ nX ] = MinMax( (long) fTemp, 0, nTemp ); + pLutInt[ nX ] = MinMax( static_cast<long>(fTemp), 0, nTemp ); fTemp -= pLutInt[ nX ]; - pLutFrac[ nX ] = (long) ( fTemp * 1024. ); + pLutFrac[ nX ] = static_cast<long>( fTemp * 1024. ); } for( long nY = 0; nY < nHeight; nY++ ) @@ -1089,9 +1089,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY long lXG1 = aCol1.GetGreen() - lXG0; long lXB1 = aCol1.GetBlue() - lXB0; - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0.SetRed( static_cast<sal_uInt8>( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); + aCol0.SetGreen( static_cast<sal_uInt8>( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); + aCol0.SetBlue( static_cast<sal_uInt8>( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); pWriteAcc->SetPixel( nY, nX, aCol0 ); } @@ -1117,7 +1117,7 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY { const long nNewHeight1 = nNewHeight - 1; const long nHeight1 = pReadAcc->Height() - 1; - const double fRevScaleY = (double) nHeight1 / nNewHeight1; + const double fRevScaleY = static_cast<double>(nHeight1) / nNewHeight1; std::unique_ptr<long[]> pLutInt(new long[ nNewHeight ]); std::unique_ptr<long[]> pLutFrac(new long[ nNewHeight ]); @@ -1125,9 +1125,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY for( long nY = 0, nTemp = nHeight - 2; nY < nNewHeight; nY++ ) { double fTemp = nY * fRevScaleY; - pLutInt[ nY ] = MinMax( (long) fTemp, 0, nTemp ); + pLutInt[ nY ] = MinMax( static_cast<long>(fTemp), 0, nTemp ); fTemp -= pLutInt[ nY ]; - pLutFrac[ nY ] = (long) ( fTemp * 1024. ); + pLutFrac[ nY ] = static_cast<long>( fTemp * 1024. ); } // after 1st step, bitmap *is* 24bit format (see above) @@ -1162,9 +1162,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY long lXG1 = aCol1.GetGreen() - lXG0; long lXB1 = aCol1.GetBlue() - lXB0; - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0.SetRed( static_cast<sal_uInt8>( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); + aCol0.SetGreen( static_cast<sal_uInt8>( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); + aCol0.SetBlue( static_cast<sal_uInt8>( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); pWriteAcc->SetPixel( nY, nX, aCol0 ); } @@ -1223,7 +1223,7 @@ bool Bitmap::ImplDitherMatrix() { const sal_uLong nWidth = pReadAcc->Width(); const sal_uLong nHeight = pReadAcc->Height(); - BitmapColor aIndex( (sal_uInt8) 0 ); + BitmapColor aIndex( sal_uInt8(0) ); if( pReadAcc->HasPalette() ) { @@ -1237,7 +1237,7 @@ bool Bitmap::ImplDitherMatrix() const sal_uLong nG = ( nVCLLut[ aCol.GetGreen() ] + nD ) >> 16; const sal_uLong nB = ( nVCLLut[ aCol.GetBlue() ] + nD ) >> 16; - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); pWriteAcc->SetPixel( nY, nX, aIndex ); } } @@ -1254,7 +1254,7 @@ bool Bitmap::ImplDitherMatrix() const sal_uLong nG = ( nVCLLut[ aCol.GetGreen() ] + nD ) >> 16; const sal_uLong nB = ( nVCLLut[ aCol.GetBlue() ] + nD ) >> 16; - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); pWriteAcc->SetPixel( nY, nX, aIndex ); } } @@ -1317,9 +1317,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( 0, nZ ) ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } else @@ -1328,9 +1328,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPixel( 0, nZ ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } @@ -1348,9 +1348,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nZ ) ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } else @@ -1359,9 +1359,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPixel( nY, nZ ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } } @@ -1512,7 +1512,7 @@ bool Bitmap::ReduceColors( sal_uInt16 nColorCount, BmpReduce eReduce ) { bool bRet; - if( GetColorCount() <= (sal_uLong) nColorCount ) + if( GetColorCount() <= static_cast<sal_uLong>(nColorCount) ) bRet = true; else if( nColorCount ) { @@ -1533,7 +1533,7 @@ bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount ) { Bitmap aNewBmp; ScopedReadAccess pRAcc(*this); - const sal_uInt16 nColCount = std::min( nColorCount, (sal_uInt16) 256 ); + const sal_uInt16 nColCount = std::min( nColorCount, sal_uInt16(256) ); sal_uInt16 nBitCount; bool bRet = false; @@ -1658,9 +1658,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) ); - pCountTable[ ( ( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++; + pCountTable[ ( ( static_cast<sal_uInt32>(rCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(rCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(rCol.GetBlue()) >> nRightShiftBits ) ].mnCount++; } } } @@ -1671,9 +1671,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor aCol( pRAcc->GetPixel( nY, nX ) ); - pCountTable[ ( ( ( (sal_uInt32) aCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) aCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++; + pCountTable[ ( ( static_cast<sal_uInt32>(aCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(aCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(aCol.GetBlue()) >> nRightShiftBits ) ].mnCount++; } } } @@ -1685,9 +1685,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( sal_uInt16 n = 0; n < nColCount; n++ ) { const PopularColorCount& rPop = pCountTable[ n ]; - aNewPal[ n ] = BitmapColor( (sal_uInt8) ( ( rPop.mnIndex >> nLeftShiftBits2 ) << nRightShiftBits ), - (sal_uInt8) ( ( ( rPop.mnIndex >> nLeftShiftBits1 ) & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ), - (sal_uInt8) ( ( rPop.mnIndex & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ) ); + aNewPal[ n ] = BitmapColor( static_cast<sal_uInt8>( ( rPop.mnIndex >> nLeftShiftBits2 ) << nRightShiftBits ), + static_cast<sal_uInt8>( ( ( rPop.mnIndex >> nLeftShiftBits1 ) & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ), + static_cast<sal_uInt8>( ( rPop.mnIndex & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ) ); } Bitmap aNewBmp( GetSizePixel(), nBitCount, &aNewPal ); @@ -1695,13 +1695,13 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) if( pWAcc ) { - BitmapColor aDstCol( (sal_uInt8) 0 ); + BitmapColor aDstCol( sal_uInt8(0) ); std::unique_ptr<sal_uInt8[]> pIndexMap(new sal_uInt8[ nTotalColors ]); for( long nR = 0, nIndex = 0; nR < 256; nR += nColorOffset ) for( long nG = 0; nG < 256; nG += nColorOffset ) for( long nB = 0; nB < 256; nB += nColorOffset ) - pIndexMap[ nIndex++ ] = (sal_uInt8) aNewPal.GetBestIndex( BitmapColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ) ); + pIndexMap[ nIndex++ ] = static_cast<sal_uInt8>(aNewPal.GetBestIndex( BitmapColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ) )); if( pRAcc->HasPalette() ) { @@ -1710,9 +1710,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) ); - aDstCol.SetIndex( pIndexMap[ ( ( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ] ); + aDstCol.SetIndex( pIndexMap[ ( ( static_cast<sal_uInt32>(rCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(rCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(rCol.GetBlue()) >> nRightShiftBits ) ] ); pWAcc->SetPixel( nY, nX, aDstCol ); } } @@ -1724,9 +1724,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor aCol( pRAcc->GetPixel( nY, nX ) ); - aDstCol.SetIndex( pIndexMap[ ( ( ( (sal_uInt32) aCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) aCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits ) ] ); + aDstCol.SetIndex( pIndexMap[ ( ( static_cast<sal_uInt32>(aCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(aCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(aCol.GetBlue()) >> nRightShiftBits ) ] ); pWAcc->SetPixel( nY, nX, aDstCol ); } } @@ -1859,10 +1859,10 @@ void Bitmap::ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal, { if( pBuf[ RGB15( nR1, nG1, nB1 ) ] ) { - aCol.SetRed( (sal_uInt8) ( nR1 << 3 ) ); - aCol.SetGreen( (sal_uInt8) ( nG1 << 3 ) ); - aCol.SetBlue( (sal_uInt8) ( nB1 << 3 ) ); - rPal[ (sal_uInt16) rIndex++ ] = aCol; + aCol.SetRed( static_cast<sal_uInt8>( nR1 << 3 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( nG1 << 3 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( nB1 << 3 ) ); + rPal[ static_cast<sal_uInt16>(rIndex++) ] = aCol; } } else @@ -1889,10 +1889,10 @@ void Bitmap::ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal, } } - aCol.SetRed( (sal_uInt8) ( ( nRSum / nPixels ) << 3 ) ); - aCol.SetGreen( (sal_uInt8) ( ( nGSum / nPixels ) << 3 ) ); - aCol.SetBlue( (sal_uInt8) ( ( nBSum / nPixels ) << 3 ) ); - rPal[ (sal_uInt16) rIndex++ ] = aCol; + aCol.SetRed( static_cast<sal_uInt8>( ( nRSum / nPixels ) << 3 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( ( nGSum / nPixels ) << 3 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( ( nBSum / nPixels ) << 3 ) ); + rPal[ static_cast<sal_uInt16>(rIndex++) ] = aCol; } else { @@ -2034,18 +2034,18 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, { if(!msoBrightness) { - cMapR[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fROff ), 0, 255 ); - cMapG[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fGOff ), 0, 255 ); - cMapB[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fBOff ), 0, 255 ); + cMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fROff ), 0, 255 )); + cMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fGOff ), 0, 255 )); + cMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fBOff ), 0, 255 )); } else { // LO simply uses (in a somewhat optimized form) "newcolor = (oldcolor-128)*contrast+brightness+128" // as the formula, i.e. contrast first, brightness afterwards. MSOffice, for whatever weird reason, // use neither first, but apparently it applies half of brightness before contrast and half afterwards. - cMapR[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 ); - cMapG[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 ); - cMapB[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 ); + cMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 )); + cMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 )); + cMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 )); } if( bGamma ) { @@ -2166,9 +2166,9 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess const * pR } BitmapColor aResultColor( - (sal_uInt8) MinMax( aValueRed / aSum, 0, 255 ), - (sal_uInt8) MinMax( aValueGreen / aSum, 0, 255 ), - (sal_uInt8) MinMax( aValueBlue / aSum, 0, 255 ) ); + static_cast<sal_uInt8>(MinMax( aValueRed / aSum, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aValueGreen / aSum, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aValueBlue / aSum, 0, 255 )) ); int nDestX = nSourceY; int nDestY = nSourceX; diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index 554485de13dd..9400f4d61e2b 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -36,7 +36,7 @@ static inline sal_uInt8 lcl_getDuotoneColorComponent( sal_uInt8 base, sal_uInt16 color2 = color2*base/0xFF; color1 = color1*(0xFF-base)/0xFF; - return (sal_uInt8) (color1+color2); + return static_cast<sal_uInt8>(color1+color2); } bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) @@ -209,9 +209,9 @@ bool Bitmap::ImplConvolute3( const long* pMatrix ) nSumB += pTmp[ pColor->GetBlue() ]; // calculate destination color - pWriteAcc->SetPixel( nY, nX, BitmapColor( (sal_uInt8) MinMax( nSumR / nDivisor, 0, 255 ), - (sal_uInt8) MinMax( nSumG / nDivisor, 0, 255 ), - (sal_uInt8) MinMax( nSumB / nDivisor, 0, 255 ) ) ); + pWriteAcc->SetPixel( nY, nX, BitmapColor( static_cast<sal_uInt8>(MinMax( nSumR / nDivisor, 0, 255 )), + static_cast<sal_uInt8>(MinMax( nSumG / nDivisor, 0, 255 )), + static_cast<sal_uInt8>(MinMax( nSumB / nDivisor, 0, 255 )) ) ); } if( ++nY < nHeight ) @@ -371,7 +371,7 @@ bool Bitmap::ImplMedianFilter() MNMX3( nB9, nB2, nB3 ); // set destination color - pWriteAcc->SetPixel( nY, nX, BitmapColor( (sal_uInt8) nR2, (sal_uInt8) nG2, (sal_uInt8) nB2 ) ); + pWriteAcc->SetPixel( nY, nX, BitmapColor( static_cast<sal_uInt8>(nR2), static_cast<sal_uInt8>(nG2), static_cast<sal_uInt8>(nB2) ) ); } if( ++nY < nHeight ) @@ -445,7 +445,7 @@ bool Bitmap::ImplSobelGrey() if( pWriteAcc ) { - BitmapColor aGrey( (sal_uInt8) 0 ); + BitmapColor aGrey( sal_uInt8(0) ); const long nWidth = pWriteAcc->Width(); const long nHeight = pWriteAcc->Height(); const long nMask111 = -1, nMask121 = 0, nMask131 = 1; @@ -515,8 +515,8 @@ bool Bitmap::ImplSobelGrey() nSum1 += nMask331 * nGrey33; nSum2 += nMask332 * nGrey33; - nSum1 = (long) sqrt( (double)( nSum1 * nSum1 + nSum2 * nSum2 ) ); - aGrey.SetIndex( ~(sal_uInt8) SAL_BOUND( nSum1, 0, 255 ) ); + nSum1 = static_cast<long>(sqrt( static_cast<double>( nSum1 * nSum1 + nSum2 * nSum2 ) )); + aGrey.SetIndex( ~static_cast<sal_uInt8>(SAL_BOUND( nSum1, 0, 255 )) ); pWriteAcc->SetPixel( nY, nX, aGrey ); if( nX < ( nWidth - 1 ) ) @@ -571,7 +571,7 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) if( pWriteAcc ) { - BitmapColor aGrey( (sal_uInt8) 0 ); + BitmapColor aGrey( sal_uInt8(0) ); const long nWidth = pWriteAcc->Width(); const long nHeight = pWriteAcc->Height(); long nGrey11, nGrey12, nGrey13; @@ -589,7 +589,7 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) const long nLz = FRound( sin( fElev ) * 255.0 ); const auto nZ2 = ( ( 6 * 255 ) / 4 ) * ( ( 6 * 255 ) / 4 ); const long nNzLz = ( ( 6 * 255 ) / 4 ) * nLz; - const sal_uInt8 cLz = (sal_uInt8) SAL_BOUND( nLz, 0, 255 ); + const sal_uInt8 cLz = static_cast<sal_uInt8>(SAL_BOUND( nLz, 0, 255 )); // fill mapping tables pHMap[ 0 ] = 0; @@ -625,8 +625,8 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) aGrey.SetIndex( 0 ); else { - const double fGrey = nDotL / sqrt( (double)(nNx * nNx + nNy * nNy + nZ2) ); - aGrey.SetIndex( (sal_uInt8) SAL_BOUND( fGrey, 0, 255 ) ); + const double fGrey = nDotL / sqrt( static_cast<double>(nNx * nNx + nNy * nNy + nZ2) ); + aGrey.SetIndex( static_cast<sal_uInt8>(SAL_BOUND( fGrey, 0, 255 )) ); } pWriteAcc->SetPixel( nY, nX, aGrey ); @@ -729,9 +729,9 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) for( sal_uInt16 i = 0; i < 256; i++ ) { BitmapColor& rCol = aSepiaPal[ i ]; - const sal_uInt8 cSepiaValue = (sal_uInt8) ( nSepia * i / 10000 ); + const sal_uInt8 cSepiaValue = static_cast<sal_uInt8>( nSepia * i / 10000 ); - rCol.SetRed( (sal_uInt8) i ); + rCol.SetRed( static_cast<sal_uInt8>(i) ); rCol.SetGreen( cSepiaValue ); rCol.SetBlue( cSepiaValue ); } @@ -741,7 +741,7 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) if( pWriteAcc ) { - BitmapColor aCol( (sal_uInt8) 0 ); + BitmapColor aCol( sal_uInt8(0) ); const long nWidth = pWriteAcc->Width(); const long nHeight = pWriteAcc->Height(); @@ -872,9 +872,9 @@ bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam ) } } - aCol.SetRed( (sal_uInt8) ( nSumR * fArea_1 ) ); - aCol.SetGreen( (sal_uInt8) ( nSumG * fArea_1 ) ); - aCol.SetBlue( (sal_uInt8) ( nSumB * fArea_1 ) ); + aCol.SetRed( static_cast<sal_uInt8>( nSumR * fArea_1 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( nSumG * fArea_1 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( nSumB * fArea_1 ) ); for( nY = nY1; nY <= nY2; nY++ ) for( nX = nX1; nX <= nX2; nX++ ) @@ -905,9 +905,9 @@ bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam ) } } - aCol.SetRed( (sal_uInt8) ( nSumR * fArea_1 ) ); - aCol.SetGreen( (sal_uInt8) ( nSumG * fArea_1 ) ); - aCol.SetBlue( (sal_uInt8) ( nSumB * fArea_1 ) ); + aCol.SetRed( static_cast<sal_uInt8>( nSumR * fArea_1 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( nSumG * fArea_1 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( nSumB * fArea_1 ) ); for( nY = nY1; nY <= nY2; nY++ ) for( nX = nX1; nX <= nX2; nX++ ) @@ -1003,7 +1003,7 @@ bool Bitmap::ImplPopArt() for( n = 0; n < nEntryCount; n++ ) { PopArtEntry& rEntry = pPopArtTable[ n ]; - rEntry.mnIndex = (sal_uInt16) n; + rEntry.mnIndex = static_cast<sal_uInt16>(n); rEntry.mnCount = 0; } @@ -1043,7 +1043,7 @@ bool Bitmap::ImplPopArt() } double* MakeBlurKernel(const double radius, int& rows) { - int intRadius = (int) radius + 1.0; + int intRadius = static_cast<int>(radius) + 1.0; rows = intRadius * 2 + 1; double* matrix = new double[rows]; @@ -1209,9 +1209,9 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) { aColor = pReadAcc->GetColor( y , x ); BitmapColor aResultColor( - (sal_uInt8) MinMax( aColor.GetRed() + (aColor.GetRed() - aColorBlur.GetRed()) * aAmount, 0, 255 ), - (sal_uInt8) MinMax( aColor.GetGreen() + (aColor.GetGreen() - aColorBlur.GetGreen()) * aAmount, 0, 255 ), - (sal_uInt8) MinMax( aColor.GetBlue() + (aColor.GetBlue() - aColorBlur.GetBlue()) * aAmount, 0, 255 ) ); + static_cast<sal_uInt8>(MinMax( aColor.GetRed() + (aColor.GetRed() - aColorBlur.GetRed()) * aAmount, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aColor.GetGreen() + (aColor.GetGreen() - aColorBlur.GetGreen()) * aAmount, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aColor.GetBlue() + (aColor.GetBlue() - aColorBlur.GetBlue()) * aAmount, 0, 255 )) ); pWriteAcc->SetPixel( y, x, aResultColor ); } diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 59e519a83b95..2eb5a2ceb90c 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -306,7 +306,7 @@ BitmapChecksum BitmapEx::GetChecksum() const UInt32ToSVBT32( (long) eTransparent, aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - UInt32ToSVBT32( (long) bAlpha, aBT32 ); + UInt32ToSVBT32( static_cast<long>(bAlpha), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); if( ( TransparentType::Bitmap == eTransparent ) && !aMask.IsEmpty() ) @@ -386,8 +386,8 @@ bool BitmapEx::Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag ) ( rNewSize.Width() != aBitmapSize.Width() || rNewSize.Height() != aBitmapSize.Height() ) ) { - bRet = Scale( (double) rNewSize.Width() / aBitmapSize.Width(), - (double) rNewSize.Height() / aBitmapSize.Height(), + bRet = Scale( static_cast<double>(rNewSize.Width()) / aBitmapSize.Width(), + static_cast<double>(rNewSize.Height()) / aBitmapSize.Height(), nScaleFlag ); } else @@ -696,7 +696,7 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx const & aBitmap, const long aStanda // Draw a rect into virDevice aVirDevice->DrawRect( aRect ); - Point aPointPixel( (long)imgposX, (long)imgposY ); + Point aPointPixel( static_cast<long>(imgposX), static_cast<long>(imgposY) ); aVirDevice->DrawBitmapEx( aPointPixel, aRet ); aRet = aVirDevice->GetBitmapEx( aEmptyPoint, aStdSize ); @@ -1060,11 +1060,11 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else if(ScanlineFormat::N24BitTcBgr == xContent->GetScanlineFormat()) { - for(sal_uInt32 y(0); y < (sal_uInt32)xContent->Height(); y++) + for(sal_uInt32 y(0); y < static_cast<sal_uInt32>(xContent->Height()); y++) { Scanline pScan = xContent->GetScanline(y); - for(sal_uInt32 x(0); x < (sal_uInt32)xContent->Width(); x++) + for(sal_uInt32 x(0); x < static_cast<sal_uInt32>(xContent->Width()); x++) { const basegfx::BColor aBSource( *(pScan + 2)* fConvertColor, @@ -1079,11 +1079,11 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else if(ScanlineFormat::N24BitTcRgb == xContent->GetScanlineFormat()) { - for(sal_uInt32 y(0); y < (sal_uInt32)xContent->Height(); y++) + for(sal_uInt32 y(0); y < static_cast<sal_uInt32>(xContent->Height()); y++) { Scanline pScan = xContent->GetScanline(y); - for(sal_uInt32 x(0); x < (sal_uInt32)xContent->Width(); x++) + for(sal_uInt32 x(0); x < static_cast<sal_uInt32>(xContent->Width()); x++) { const basegfx::BColor aBSource( *pScan * fConvertColor, @@ -1098,15 +1098,15 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else { - for(sal_uInt32 y(0); y < (sal_uInt32)xContent->Height(); y++) + for(sal_uInt32 y(0); y < static_cast<sal_uInt32>(xContent->Height()); y++) { - for(sal_uInt32 x(0); x < (sal_uInt32)xContent->Width(); x++) + for(sal_uInt32 x(0); x < static_cast<sal_uInt32>(xContent->Width()); x++) { const BitmapColor aBMCol(xContent->GetColor(y, x)); const basegfx::BColor aBSource( - (double)aBMCol.GetRed() * fConvertColor, - (double)aBMCol.GetGreen() * fConvertColor, - (double)aBMCol.GetBlue() * fConvertColor); + static_cast<double>(aBMCol.GetRed()) * fConvertColor, + static_cast<double>(aBMCol.GetGreen()) * fConvertColor, + static_cast<double>(aBMCol.GetBlue()) * fConvertColor); const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource)); xContent->SetPixel(y, x, BitmapColor(Color(aBDest))); diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index ff08f629caaa..6a97eebc3cab 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -802,7 +802,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL { if(aHeader.nColsUsed) { - nColors = (sal_uInt16)aHeader.nColsUsed; + nColors = static_cast<sal_uInt16>(aHeader.nColsUsed); } else { @@ -1135,7 +1135,7 @@ bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess const & rAcc, bool bRLE4 ) if ( nCount > 1 ) { - *pTmp++ = (sal_uInt8) nCount; + *pTmp++ = static_cast<sal_uInt8>(nCount); *pTmp++ = ( bRLE4 ? ( ( cPix << 4 ) | cPix ) : cPix ); nBufCount += 2; } @@ -1159,7 +1159,7 @@ bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess const & rAcc, bool bRLE4 ) if ( nCount > 3 ) { *pTmp++ = 0; - *pTmp++ = (sal_uInt8) --nCount; + *pTmp++ = static_cast<sal_uInt8>(--nCount); if( bRLE4 ) { @@ -1395,7 +1395,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead if(bWriteAlpha) { - *pTmp++ = (sal_uInt8)0xff - pAccAlpha->GetPixelIndex( nY, nX ); + *pTmp++ = sal_uInt8(0xff) - pAccAlpha->GetPixelIndex( nY, nX ); } } @@ -1478,8 +1478,8 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess c // especially if maPrefSize is small. Trying to circumvent // that by performing part of the math in floating point. const Size aScale100000(OutputDevice::LogicToLogic(Size(100000, 100000), MapMode(MapUnit::Map100thMM), rBitmap.GetPrefMapMode())); - const double fBmpWidthM((double)rBitmap.GetPrefSize().Width() / aScale100000.Width()); - const double fBmpHeightM((double)rBitmap.GetPrefSize().Height() / aScale100000.Height()); + const double fBmpWidthM(static_cast<double>(rBitmap.GetPrefSize().Width()) / aScale100000.Width()); + const double fBmpHeightM(static_cast<double>(rBitmap.GetPrefSize().Height()) / aScale100000.Height()); if(!basegfx::fTools::equalZero(fBmpWidthM) && !basegfx::fTools::equalZero(fBmpHeightM)) { diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index f4e5a8c187fb..80af9ea8d937 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -54,7 +54,7 @@ using namespace com::sun::star; -#define GAMMA( _def_cVal, _def_InvGamma ) ((sal_uInt8)MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255)) +#define GAMMA( _def_cVal, _def_InvGamma ) (static_cast<sal_uInt8>(MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255))) struct ImplColAdjustParam { @@ -696,8 +696,8 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) { aOffset = aMapVDev->LogicToPixel( aBaseOffset, GetPrefMapMode() ); MapMode aMap( aMapVDev->GetMapMode() ); - aOffset.Width() = static_cast<long>(aOffset.Width() * (double)aMap.GetScaleX()); - aOffset.Height() = static_cast<long>(aOffset.Height() * (double)aMap.GetScaleY()); + aOffset.Width() = static_cast<long>(aOffset.Width() * static_cast<double>(aMap.GetScaleX())); + aOffset.Height() = static_cast<long>(aOffset.Height() * static_cast<double>(aMap.GetScaleY())); } else aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() ); @@ -730,7 +730,7 @@ void GDIMetaFile::Scale( double fScaleX, double fScaleY ) void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY ) { - Scale( (double) rScaleX, (double) rScaleY ); + Scale( static_cast<double>(rScaleX), static_cast<double>(rScaleY) ); } void GDIMetaFile::Clip( const tools::Rectangle& i_rClipRect ) @@ -1150,7 +1150,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction); Hatch aHatch( pAct->GetHatch() ); - aHatch.SetAngle( aHatch.GetAngle() + (sal_uInt16) nAngle10 ); + aHatch.SetAngle( aHatch.GetAngle() + static_cast<sal_uInt16>(nAngle10) ); aMtf.AddAction( new MetaHatchAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), aHatch ) ); } @@ -1240,7 +1240,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction); vcl::Font aFont( pAct->GetFont() ); - aFont.SetOrientation( aFont.GetOrientation() + (sal_uInt16) nAngle10 ); + aFont.SetOrientation( aFont.GetOrientation() + static_cast<sal_uInt16>(nAngle10) ); aMtf.AddAction( new MetaFontAction( aFont ) ); } break; @@ -2133,15 +2133,15 @@ void GDIMetaFile::Adjust( short nLuminancePercent, short nContrastPercent, { if(!msoBrightness) { - aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fROff ), 0, 255 ); - aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fGOff ), 0, 255 ); - aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fBOff ), 0, 255 ); + aColParam.pMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fROff ), 0, 255 )); + aColParam.pMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fGOff ), 0, 255 )); + aColParam.pMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fBOff ), 0, 255 )); } else { - aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 ); - aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 ); - aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 ); + aColParam.pMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 )); + aColParam.pMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 )); + aColParam.pMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 )); } if( bGamma ) { @@ -2198,16 +2198,16 @@ void GDIMetaFile::ReplaceColors( const Color* pSearchColors, const Color* pRepla long nVal; nVal = pSearchColors[ i ].GetRed(); - aColParam.pMinR[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxR[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinR[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L )); + aColParam.pMaxR[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L )); nVal = pSearchColors[ i ].GetGreen(); - aColParam.pMinG[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxG[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinG[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L )); + aColParam.pMaxG[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L )); nVal = pSearchColors[ i ].GetBlue(); - aColParam.pMinB[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxB[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinB[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L )); + aColParam.pMaxB[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L )); } aColParam.pDstCols = pReplaceColors; @@ -2556,7 +2556,7 @@ BitmapChecksum GDIMetaFile::GetChecksum() const } } - sal_uInt8 tmp = (sal_uInt8)rAct.IsClipping(); + sal_uInt8 tmp = static_cast<sal_uInt8>(rAct.IsClipping()); nCrc = vcl_get_checksum(nCrc, &tmp, 1); } else diff --git a/vcl/source/gdi/gradient.cxx b/vcl/source/gdi/gradient.cxx index 191c3852dc74..67b8a02d46b2 100644 --- a/vcl/source/gdi/gradient.cxx +++ b/vcl/source/gdi/gradient.cxx @@ -158,10 +158,10 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB fWidth * fabs( sin( fAngle ) ); fDX = (fDX - fWidth) * 0.5 + 0.5; fDY = (fDY - fHeight) * 0.5 + 0.5; - aRect.Left() -= (long) fDX; - aRect.Right() += (long) fDX; - aRect.Top() -= (long) fDY; - aRect.Bottom() += (long) fDY; + aRect.Left() -= static_cast<long>(fDX); + aRect.Right() += static_cast<long>(fDX); + aRect.Top() -= static_cast<long>(fDY); + aRect.Bottom() += static_cast<long>(fDY); rBoundRect = aRect; rCenter = rRect.Center(); @@ -179,10 +179,10 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB fDX = ( fDX - fWidth ) * 0.5 + 0.5; fDY = ( fDY - fHeight ) * 0.5 + 0.5; - aRect.Left() -= (long) fDX; - aRect.Right() += (long) fDX; - aRect.Top() -= (long) fDY; - aRect.Bottom() += (long) fDY; + aRect.Left() -= static_cast<long>(fDX); + aRect.Right() += static_cast<long>(fDX); + aRect.Top() -= static_cast<long>(fDY); + aRect.Bottom() += static_cast<long>(fDY); } Size aSize( aRect.GetSize() ); @@ -190,21 +190,21 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB if( GetStyle() == GradientStyle::Radial ) { // Calculation of radii for circle - aSize.Width() = (long)(0.5 + sqrt((double)aSize.Width()*(double)aSize.Width() + (double)aSize.Height()*(double)aSize.Height())); + aSize.Width() = static_cast<long>(0.5 + sqrt(static_cast<double>(aSize.Width())*static_cast<double>(aSize.Width()) + static_cast<double>(aSize.Height())*static_cast<double>(aSize.Height()))); aSize.Height() = aSize.Width(); } else if( GetStyle() == GradientStyle::Elliptical ) { // Calculation of radii for ellipse - aSize.Width() = (long)( 0.5 + (double) aSize.Width() * 1.4142 ); - aSize.Height() = (long)( 0.5 + (double) aSize.Height() * 1.4142 ); + aSize.Width() = static_cast<long>( 0.5 + static_cast<double>(aSize.Width()) * 1.4142 ); + aSize.Height() = static_cast<long>( 0.5 + static_cast<double>(aSize.Height()) * 1.4142 ); } // Calculate new centers - long nZWidth = aRect.GetWidth() * (long) GetOfsX() / 100; - long nZHeight = aRect.GetHeight() * (long) GetOfsY() / 100; - long nBorderX = (long) GetBorder() * aSize.Width() / 100; - long nBorderY = (long) GetBorder() * aSize.Height() / 100; + long nZWidth = aRect.GetWidth() * static_cast<long>(GetOfsX()) / 100; + long nZHeight = aRect.GetHeight() * static_cast<long>(GetOfsY()) / 100; + long nBorderX = static_cast<long>(GetBorder()) * aSize.Width() / 100; + long nBorderY = static_cast<long>(GetBorder()) * aSize.Height() / 100; rCenter = Point( aRect.Left() + nZWidth, aRect.Top() + nZHeight ); // Respect borders diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 3477c43e7f33..6b1587a36194 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -41,7 +41,7 @@ void ImplDrawDefault( OutputDevice* pOutDev, const OUString* pText, vcl::Font* pFont, const BitmapEx* pBitmapEx, const Point& rDestPt, const Size& rDestSize ) { - sal_uInt16 nPixel = (sal_uInt16) pOutDev->PixelToLogic( Size( 1, 1 ) ).Width(); + sal_uInt16 nPixel = static_cast<sal_uInt16>(pOutDev->PixelToLogic( Size( 1, 1 ) ).Width()); sal_uInt16 nPixelWidth = nPixel; Point aPoint( rDestPt.X() + nPixelWidth, rDestPt.Y() + nPixelWidth ); Size aSize( rDestSize.Width() - ( nPixelWidth << 1 ), rDestSize.Height() - ( nPixelWidth << 1 ) ); @@ -408,8 +408,8 @@ basegfx::B2DSize Graphic::GetPPI() const const Size aGrfPrefMapModeSize(GetPrefSize()); if (aGrfMap.GetMapUnit() == MapUnit::MapInch) { - nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() ); - nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() ); + nGrfDPIx = aGrfPixelSize.Width() / ( static_cast<double>(aGrfMap.GetScaleX()) * aGrfPrefMapModeSize.Width() ); + nGrfDPIy = aGrfPixelSize.Height() / ( static_cast<double>(aGrfMap.GetScaleY()) * aGrfPrefMapModeSize.Height() ); } else { diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx index ba94f89277c3..99708ce57316 100644 --- a/vcl/source/gdi/impanmvw.cxx +++ b/vcl/source/gdi/impanmvw.cxx @@ -127,13 +127,13 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnm, Point& rPosPix, Size // calculate x scaling if( rAnmSize.Width() > 1 ) - fFactX = (double) ( maSzPix.Width() - 1 ) / ( rAnmSize.Width() - 1 ); + fFactX = static_cast<double>( maSzPix.Width() - 1 ) / ( rAnmSize.Width() - 1 ); else fFactX = 1.0; // calculate y scaling if( rAnmSize.Height() > 1 ) - fFactY = (double) ( maSzPix.Height() - 1 ) / ( rAnmSize.Height() - 1 ); + fFactY = static_cast<double>( maSzPix.Height() - 1 ) / ( rAnmSize.Height() - 1 ); else fFactY = 1.0; @@ -171,7 +171,7 @@ void ImplAnimView::drawToPos( sal_uLong nPos ) std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( pRenderContext->GetClipRegion() ) : nullptr); aVDev->SetOutputSizePixel( maSzPix, false ); - nPos = std::min( nPos, (sal_uLong) mpParent->Count() - 1 ); + nPos = std::min( nPos, static_cast<sal_uLong>(mpParent->Count()) - 1 ); for( sal_uLong i = 0; i <= nPos; i++ ) draw( i, aVDev.get() ); @@ -212,7 +212,7 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev ) Size aSizePix; Size aBmpSizePix; const sal_uLong nLastPos = mpParent->Count() - 1; - const AnimationBitmap& rAnm = mpParent->Get( (sal_uInt16) ( mnActPos = std::min( nPos, nLastPos ) ) ); + const AnimationBitmap& rAnm = mpParent->Get( static_cast<sal_uInt16>( mnActPos = std::min( nPos, nLastPos ) ) ); getPosSize( rAnm, aPosPix, aSizePix ); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index f14e830d2eef..09186dd054bb 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -464,7 +464,7 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT)) { // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT - double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height()); + double fWH(static_cast<double>(aDrawSize.Width()) / static_cast<double>(aDrawSize.Height())); if(fWH <= 1.0) { diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index d172aeae2418..841f1895a970 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -927,7 +927,7 @@ bool ImplGetChain( ImplVectMap* pMap, const Point& rStartPt, ImplChain& rChain if( pMap->IsCont( nTryY, nTryX ) ) { - rChain.ImplAdd( (sal_uInt8) nLastDir ); + rChain.ImplAdd( static_cast<sal_uInt8>(nLastDir) ); pMap->Set( nActY = nTryY, nActX = nTryX, VECT_DONE_INDEX ); nFound = 1; } @@ -944,7 +944,7 @@ bool ImplGetChain( ImplVectMap* pMap, const Point& rStartPt, ImplChain& rChain if( pMap->IsCont( nTryY, nTryX ) ) { - rChain.ImplAdd( (sal_uInt8) nDir ); + rChain.ImplAdd( static_cast<sal_uInt8>(nDir) ); pMap->Set( nActY = nTryY, nActX = nTryX, VECT_DONE_INDEX ); nFound = 1; nLastDir = nDir; diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 24167478f79c..fdb002394662 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -25,8 +25,8 @@ #include <memory> #include <rtl/instance.hxx> -#define JOBSET_FILE364_SYSTEM ((sal_uInt16)0xFFFF) -#define JOBSET_FILE605_SYSTEM ((sal_uInt16)0xFFFE) +#define JOBSET_FILE364_SYSTEM (sal_uInt16(0xFFFF)) +#define JOBSET_FILE605_SYSTEM (sal_uInt16(0xFFFE)) struct ImplOldJobSetupData { @@ -281,8 +281,8 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup ) rJobData.SetDuplexMode( DuplexMode::Unknown ); rJobData.SetPaperBin( SVBT16ToShort( pOldJobData->nPaperBin ) ); rJobData.SetPaperFormat( (Paper)SVBT16ToShort( pOldJobData->nPaperFormat ) ); - rJobData.SetPaperWidth( (long)SVBT32ToUInt32( pOldJobData->nPaperWidth ) ); - rJobData.SetPaperHeight( (long)SVBT32ToUInt32( pOldJobData->nPaperHeight ) ); + rJobData.SetPaperWidth( static_cast<long>(SVBT32ToUInt32( pOldJobData->nPaperWidth )) ); + rJobData.SetPaperHeight( static_cast<long>(SVBT32ToUInt32( pOldJobData->nPaperHeight )) ); if ( rJobData.GetDriverDataLen() ) { const char* pDriverData = reinterpret_cast<const char*>(pOldJobData) + nOldJobDataSize; @@ -348,9 +348,9 @@ SvStream& WriteJobSetup( SvStream& rOStream, const JobSetup& rJobSetup ) UInt32ToSVBT32( rJobData.GetDriverDataLen(), aOldJobData.nDriverDataLen ); ShortToSVBT16( (sal_uInt16)(rJobData.GetOrientation()), aOldJobData.nOrientation ); ShortToSVBT16( rJobData.GetPaperBin(), aOldJobData.nPaperBin ); - ShortToSVBT16( (sal_uInt16)(rJobData.GetPaperFormat()), aOldJobData.nPaperFormat ); - UInt32ToSVBT32( (sal_uLong)(rJobData.GetPaperWidth()), aOldJobData.nPaperWidth ); - UInt32ToSVBT32( (sal_uLong)(rJobData.GetPaperHeight()), aOldJobData.nPaperHeight ); + ShortToSVBT16( static_cast<sal_uInt16>(rJobData.GetPaperFormat()), aOldJobData.nPaperFormat ); + UInt32ToSVBT32( static_cast<sal_uLong>(rJobData.GetPaperWidth()), aOldJobData.nPaperWidth ); + UInt32ToSVBT32( static_cast<sal_uLong>(rJobData.GetPaperHeight()), aOldJobData.nPaperHeight ); ImplOldJobSetupData aOldData; memset( &aOldData, 0, sizeof( aOldData ) ); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 31b7d5fa5da9..ecd91f724d67 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1272,7 +1272,7 @@ void MetaStretchTextAction::Move( long nHorzMove, long nVertMove ) void MetaStretchTextAction::Scale( double fScaleX, double fScaleY ) { ImplScalePoint( maPt, fScaleX, fScaleY ); - mnWidth = (sal_uLong)FRound( mnWidth * fabs(fScaleX) ); + mnWidth = static_cast<sal_uLong>(FRound( mnWidth * fabs(fScaleX) )); } void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -3439,7 +3439,7 @@ void MetaTextLanguageAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { MetaAction::Write(rOStm, pData); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); - rOStm.WriteUInt16( (sal_uInt16)meTextLanguage ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(meTextLanguage) ); } void MetaTextLanguageAction::Read( SvStream& rIStm, ImplMetaReadData* ) diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx index 8e4977650e51..d4eb44eb33c0 100644 --- a/vcl/source/gdi/octree.cxx +++ b/vcl/source/gdi/octree.cxx @@ -204,9 +204,9 @@ void Octree::CreatePalette( NODE* pNode ) if( pNode->bLeaf ) { pNode->nPalIndex = nPalIndex; - aPal[ nPalIndex++ ] = BitmapColor( (sal_uInt8) ( (double) pNode->nRed / pNode->nCount ), - (sal_uInt8) ( (double) pNode->nGreen / pNode->nCount ), - (sal_uInt8) ( (double) pNode->nBlue / pNode->nCount ) ); + aPal[ nPalIndex++ ] = BitmapColor( static_cast<sal_uInt8>( static_cast<double>(pNode->nRed) / pNode->nCount ), + static_cast<sal_uInt8>( static_cast<double>(pNode->nGreen) / pNode->nCount ), + static_cast<sal_uInt8>( static_cast<double>(pNode->nBlue) / pNode->nCount ) ); } else for(OctreeNode* i : pNode->pChild) if( i ) @@ -246,7 +246,7 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) : for( int nIndex = 0; nIndex < nColors; nIndex++ ) { - const BitmapColor& rColor = rPal[ (sal_uInt16) nIndex ]; + const BitmapColor& rColor = rPal[ static_cast<sal_uInt16>(nIndex) ]; const long cRed = rColor.GetRed(); const long cGreen = rColor.GetGreen(); const long cBlue = rColor.GetBlue(); @@ -268,10 +268,10 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) : for( g = 0, gdist = rdist, gxx = cginc; g < nColorMax; gdist += gxx, g++, gxx += xsqr2 ) { for( b = 0, bdist = gdist, bxx = cbinc; b < nColorMax; bdist += bxx, b++, cdp++, crgbp++, bxx += xsqr2 ) - if ( !nIndex || ( (long) *cdp ) > bdist ) + if ( !nIndex || static_cast<long>(*cdp) > bdist ) { *cdp = bdist; - *crgbp = (sal_uInt8) nIndex; + *crgbp = static_cast<sal_uInt8>(nIndex); } } } diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index 8974c6f5a645..4966aec601f2 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -113,7 +113,7 @@ sal_Int32 GlobalSyncData::GetMappedId() */ if( nLinkId >= 0 ) { - if ( (sal_uInt32)nLinkId < mParaIds.size() ) + if ( static_cast<sal_uInt32>(nLinkId) < mParaIds.size() ) nLinkId = mParaIds[ nLinkId ]; else nLinkId = -1; @@ -126,7 +126,7 @@ sal_Int32 GlobalSyncData::GetMappedId() sal_Int32 GlobalSyncData::GetMappedStructId( sal_Int32 nStructId ) { - if ( (sal_uInt32)nStructId < mStructIdMap.size() ) + if ( static_cast<sal_uInt32>(nStructId) < mStructIdMap.size() ) nStructId = mStructIdMap[ nStructId ]; else nStructId = -1; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 854c1107ad9a..89204dad077c 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -550,7 +550,7 @@ static void appendName( const OUString& rStr, OStringBuffer& rBuffer ) else { rBuffer.append( '#' ); - appendHex( (sal_Int8)aStr[i], rBuffer ); + appendHex( static_cast<sal_Int8>(aStr[i]), rBuffer ); } } } @@ -570,7 +570,7 @@ static void appendName( const sal_Char* pStr, OStringBuffer& rBuffer ) else { rBuffer.append( '#' ); - appendHex( (sal_Int8)*pStr, rBuffer ); + appendHex( static_cast<sal_Int8>(*pStr), rBuffer ); } pStr++; } @@ -602,10 +602,10 @@ static void appendLiteralString( const sal_Char* pStr, sal_Int32 nLength, OStrin case ')' : case '\\' : rBuffer.append( "\\" ); - rBuffer.append( (sal_Char) *pStr ); + rBuffer.append( static_cast<sal_Char>(*pStr) ); break; default: - rBuffer.append( (sal_Char) *pStr ); + rBuffer.append( static_cast<sal_Char>(*pStr) ); break; } pStr++; @@ -648,14 +648,14 @@ static void appendDestinationName( const OUString& rString, OStringBuffer& rBuff (aChar >= 'A' && aChar <= 'Z' ) || aChar == '-' ) { - rBuffer.append((sal_Char)aChar); + rBuffer.append(static_cast<sal_Char>(aChar)); } else { sal_Int8 aValueHigh = sal_Int8(aChar >> 8); if(aValueHigh > 0) appendHex( aValueHigh, rBuffer ); - appendHex( (sal_Int8)(aChar & 255 ), rBuffer ); + appendHex( static_cast<sal_Int8>(aChar & 255 ), rBuffer ); } } } @@ -668,8 +668,8 @@ void PDFWriter::AppendUnicodeTextString(const OUString& rString, OStringBuffer& for( int i = 0; i < nLen; i++ ) { sal_Unicode aChar = pStr[i]; - appendHex( (sal_Int8)(aChar >> 8), rBuffer ); - appendHex( (sal_Int8)(aChar & 255 ), rBuffer ); + appendHex( static_cast<sal_Int8>(aChar >> 8), rBuffer ); + appendHex( static_cast<sal_Int8>(aChar & 255 ), rBuffer ); } } @@ -695,7 +695,7 @@ void PDFWriterImpl::createWidgetFieldName( sal_Int32 i_nWidgetIndex, const PDFWr else { aBuffer.append( '#' ); - appendHex( (sal_Int8)aStr[i], aBuffer ); + appendHex( static_cast<sal_Int8>(aStr[i]), aBuffer ); } } @@ -858,8 +858,8 @@ static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrec fValue=-fValue; } - sal_Int64 nInt = (sal_Int64)fValue; - fValue -= (double)nInt; + sal_Int64 nInt = static_cast<sal_Int64>(fValue); + fValue -= static_cast<double>(nInt); // optimizing hardware may lead to a value of 1.0 after the subtraction if( rtl::math::approxEqual(fValue, 1.0) || log10( 1.0-fValue ) <= -nPrecision ) { @@ -869,8 +869,8 @@ static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrec sal_Int64 nFrac = 0; if( fValue ) { - fValue *= pow( 10.0, (double)nPrecision ); - nFrac = (sal_Int64)fValue; + fValue *= pow( 10.0, static_cast<double>(nPrecision) ); + nFrac = static_cast<sal_Int64>(fValue); } if( bNeg && ( nInt || nFrac ) ) rBuffer.append( '-' ); @@ -879,7 +879,7 @@ static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrec { int i; rBuffer.append( '.' ); - sal_Int64 nBound = (sal_Int64)(pow( 10.0, nPrecision - 1.0 )+0.5); + sal_Int64 nBound = static_cast<sal_Int64>(pow( 10.0, nPrecision - 1.0 )+0.5); for ( i = 0; ( i < nPrecision ) && nFrac; i++ ) { sal_Int64 nNumb = nFrac / nBound; @@ -898,15 +898,15 @@ static void appendColor( const Color& rColor, OStringBuffer& rBuffer, bool bConv if( bConvertToGrey ) { sal_uInt8 cByte = rColor.GetLuminance(); - appendDouble( (double)cByte / 255.0, rBuffer ); + appendDouble( static_cast<double>(cByte) / 255.0, rBuffer ); } else { - appendDouble( (double)rColor.GetRed() / 255.0, rBuffer ); + appendDouble( static_cast<double>(rColor.GetRed()) / 255.0, rBuffer ); rBuffer.append( ' ' ); - appendDouble( (double)rColor.GetGreen() / 255.0, rBuffer ); + appendDouble( static_cast<double>(rColor.GetGreen()) / 255.0, rBuffer ); rBuffer.append( ' ' ); - appendDouble( (double)rColor.GetBlue() / 255.0, rBuffer ); + appendDouble( static_cast<double>(rColor.GetBlue()) / 255.0, rBuffer ); } } } @@ -973,8 +973,8 @@ Matrix3::Matrix3() Point Matrix3::transform( const Point& rOrig ) const { - double x = (double)rOrig.X(), y = (double)rOrig.Y(); - return Point( (int)(x*f[0] + y*f[2] + f[4]), (int)(x*f[1] + y*f[3] + f[5]) ); + double x = static_cast<double>(rOrig.X()), y = static_cast<double>(rOrig.Y()); + return Point( static_cast<int>(x*f[0] + y*f[2] + f[4]), static_cast<int>(x*f[1] + y*f[3] + f[5]) ); } void Matrix3::skew( double alpha, double beta ) @@ -1068,7 +1068,7 @@ void Matrix3::append( PDFWriterImpl::PDFPage const & rPage, OStringBuffer& rBuff rBuffer.append( ' ' ); appendDouble( f[3], rBuffer ); rBuffer.append( ' ' ); - rPage.appendPoint( Point( (long)f[4], (long)f[5] ), rBuffer ); + rPage.appendPoint( Point( static_cast<long>(f[4]), static_cast<long>(f[5]) ), rBuffer ); } static void appendResourceMap( OStringBuffer& rBuf, const char* pPrefix, const PDFWriterImpl::ResourceMap& rList ) @@ -1183,7 +1183,7 @@ void PDFWriterImpl::PDFPage::endStream() OStringBuffer aLine; aLine.append( m_nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-m_nBeginStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-m_nBeginStreamPos) ); aLine.append( "\nendobj\n\n" ); m_pWriter->writeBuffer( aLine.getStr(), aLine.getLength() ); } @@ -1249,14 +1249,14 @@ bool PDFWriterImpl::PDFPage::emit(sal_Int32 nParentObject ) if( m_nDuration > 0 ) { aLine.append( "/Dur " ); - aLine.append( (sal_Int32)m_nDuration ); + aLine.append( static_cast<sal_Int32>(m_nDuration) ); aLine.append( "\n" ); } if( m_eTransition != PDFWriter::PageTransition::Regular && m_nTransTime > 0 ) { // transition duration aLine.append( "/Trans<</D " ); - appendDouble( (double)m_nTransTime/1000.0, aLine, 3 ); + appendDouble( static_cast<double>(m_nTransTime)/1000.0, aLine, 3 ); aLine.append( "\n" ); const char *pStyle = nullptr, *pDm = nullptr, *pM = nullptr, *pDi = nullptr; switch( m_eTransition ) @@ -1387,9 +1387,9 @@ void PDFWriterImpl::PDFPage::appendRect( const tools::Rectangle& rRect, OStringB { appendPoint( rRect.BottomLeft() + Point( 0, 1 ), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rRect.GetWidth(), rBuffer, false ); + appendMappedLength( static_cast<sal_Int32>(rRect.GetWidth()), rBuffer, false ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rRect.GetHeight(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rRect.GetHeight()), rBuffer ); rBuffer.append( " re" ); } @@ -1569,7 +1569,7 @@ void PDFWriterImpl::PDFPage::appendMappedLength( double fLength, OStringBuffer& m_pWriter->m_aMapMode, m_pWriter->getReferenceDevice(), Size( 1000, 1000 ) ) ); - fLength *= pixelToPoint((double)(bVertical ? aSize.Height() : aSize.Width()) / 1000.0); + fLength *= pixelToPoint(static_cast<double>(bVertical ? aSize.Height() : aSize.Width()) / 1000.0); appendDouble( fLength, rBuffer, nPrecision ); } @@ -1602,25 +1602,25 @@ bool PDFWriterImpl::PDFPage::appendLineInfo( const LineInfo& rInfo, OStringBuffe rBuffer.append( "[ " ); if( rInfo.GetDashLen() == rInfo.GetDotLen() ) // degraded case { - appendMappedLength( (sal_Int32)rInfo.GetDashLen(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDashLen()), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rInfo.GetDistance(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDistance()), rBuffer ); rBuffer.append( ' ' ); } else { for( int n = 0; n < rInfo.GetDashCount(); n++ ) { - appendMappedLength( (sal_Int32)rInfo.GetDashLen(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDashLen()), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rInfo.GetDistance(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDistance()), rBuffer ); rBuffer.append( ' ' ); } for( int m = 0; m < rInfo.GetDotCount(); m++ ) { - appendMappedLength( (sal_Int32)rInfo.GetDotLen(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDotLen()), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rInfo.GetDistance(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDistance()), rBuffer ); rBuffer.append( ' ' ); } } @@ -1629,7 +1629,7 @@ bool PDFWriterImpl::PDFPage::appendLineInfo( const LineInfo& rInfo, OStringBuffe if( rInfo.GetWidth() > 1 ) { - appendMappedLength( (sal_Int32)rInfo.GetWidth(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetWidth()), rBuffer ); rBuffer.append( " w\n" ); } else if( rInfo.GetWidth() == 0 ) @@ -1849,20 +1849,20 @@ OString PDFWriter::GetDateTime() osl_getLocalTimeFromSystemTime(&aGMT, &aTVal); osl_getDateTimeFromTimeValue(&aTVal, &aDT); aRet.append("D:"); - aRet.append((sal_Char)('0' + ((aDT.Year / 1000) % 10))); - aRet.append((sal_Char)('0' + ((aDT.Year / 100) % 10))); - aRet.append((sal_Char)('0' + ((aDT.Year / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Year % 10))); - aRet.append((sal_Char)('0' + ((aDT.Month / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Month % 10))); - aRet.append((sal_Char)('0' + ((aDT.Day / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Day % 10))); - aRet.append((sal_Char)('0' + ((aDT.Hours / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Hours % 10))); - aRet.append((sal_Char)('0' + ((aDT.Minutes / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Minutes % 10))); - aRet.append((sal_Char)('0' + ((aDT.Seconds / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Seconds % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 1000) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 100) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Year % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Month / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Month % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Day / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Day % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Hours / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Hours % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Minutes / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Minutes % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Seconds / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Seconds % 10))); sal_uInt32 nDelta = 0; if (aGMT.Seconds > aTVal.Seconds) @@ -1880,11 +1880,11 @@ OString PDFWriter::GetDateTime() if (nDelta) { - aRet.append((sal_Char)('0' + ((nDelta / 36000) % 10))); - aRet.append((sal_Char)('0' + ((nDelta / 3600) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 36000) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 3600) % 10))); aRet.append("'"); - aRet.append((sal_Char)('0' + ((nDelta / 600) % 6))); - aRet.append((sal_Char)('0' + ((nDelta / 60) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 600) % 6))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 60) % 10))); } aRet.append( "'" ); @@ -1928,25 +1928,25 @@ void PDFWriterImpl::computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIden // to use the localtime notation only // according to a recommendation in XMP Specification (Jan 2004, page 75) // the Acrobat way seems the right approach - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year/1000)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year/100)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year/1000)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year/100)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year)%10)) ); aCreationMetaDateString.append( "-" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Month/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Month)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Month/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Month)%10)) ); aCreationMetaDateString.append( "-" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Day/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Day)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Day/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Day)%10)) ); aCreationMetaDateString.append( "T" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Hours/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Hours)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Hours/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Hours)%10)) ); aCreationMetaDateString.append( ":" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Minutes/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Minutes)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Minutes/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Minutes)%10)) ); aCreationMetaDateString.append( ":" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Seconds/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Seconds)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Seconds/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Seconds)%10)) ); sal_uInt32 nDelta = 0; if( aGMT.Seconds > aTVal.Seconds ) @@ -1966,11 +1966,11 @@ void PDFWriterImpl::computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIden } if( nDelta ) { - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/36000)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/3600)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/36000)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/3600)%10)) ); aCreationMetaDateString.append( ":" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/600)%6)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/60)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/600)%6)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/60)%10)) ); } aID.append( i_rCString1.getStr(), i_rCString1.getLength() ); @@ -2018,8 +2018,8 @@ inline void PDFWriterImpl::appendUnicodeTextStringEncrypt( const OUString& rInSt for( int i = 0; i < nLen; i++ ) { sal_Unicode aUnChar = pStr[i]; - *pCopy++ = (sal_uInt8)( aUnChar >> 8 ); - *pCopy++ = (sal_uInt8)( aUnChar & 255 ); + *pCopy++ = static_cast<sal_uInt8>( aUnChar >> 8 ); + *pCopy++ = static_cast<sal_uInt8>( aUnChar & 255 ); nChars += 2; } //encrypt in place @@ -2155,7 +2155,7 @@ bool PDFWriterImpl::writeBuffer( const void* pBuffer, sal_uInt64 nBytes ) sal_uInt64 nWritten; if( m_pCodec ) { - m_pCodec->Write( *m_pMemStream, static_cast<const sal_uInt8*>(pBuffer), (sal_uLong)nBytes ); + m_pCodec->Write( *m_pMemStream, static_cast<const sal_uInt8*>(pBuffer), static_cast<sal_uLong>(nBytes) ); nWritten = nBytes; } else @@ -2476,7 +2476,7 @@ OString PDFWriterImpl::emitStructureAttributes( PDFStructureElement& i_rEle ) m_aLinkPropertyMap.find( nLink ); if( link_it != m_aLinkPropertyMap.end() ) nLink = link_it->second; - if( nLink >= 0 && nLink < (sal_Int32)m_aLinks.size() ) + if( nLink >= 0 && nLink < static_cast<sal_Int32>(m_aLinks.size()) ) { // update struct parent of link OStringBuffer aStructParentEntry( 32 ); @@ -2778,10 +2778,10 @@ bool PDFWriterImpl::emitTilings() emitComment( "PDFWriterImpl::emitTilings" ); } - sal_Int32 nX = (sal_Int32)tiling.m_aRectangle.Left(); - sal_Int32 nY = (sal_Int32)tiling.m_aRectangle.Top(); - sal_Int32 nW = (sal_Int32)tiling.m_aRectangle.GetWidth(); - sal_Int32 nH = (sal_Int32)tiling.m_aRectangle.GetHeight(); + sal_Int32 nX = static_cast<sal_Int32>(tiling.m_aRectangle.Left()); + sal_Int32 nY = static_cast<sal_Int32>(tiling.m_aRectangle.Top()); + sal_Int32 nW = static_cast<sal_Int32>(tiling.m_aRectangle.GetWidth()); + sal_Int32 nH = static_cast<sal_Int32>(tiling.m_aRectangle.GetHeight()); if( tiling.m_aCellSize.Width() == 0 ) tiling.m_aCellSize.Width() = nW; if( tiling.m_aCellSize.Height() == 0 ) @@ -2840,7 +2840,7 @@ bool PDFWriterImpl::emitTilings() if( bDeflate ) aTilingObj.append( "/Filter/FlateDecode" ); aTilingObj.append( "/Length " ); - aTilingObj.append( (sal_Int32)nTilingStreamSize ); + aTilingObj.append( static_cast<sal_Int32>(nTilingStreamSize) ); aTilingObj.append( ">>\nstream\n" ); if ( !updateObject( tiling.m_nObject ) ) return false; if ( !writeBuffer( aTilingObj.getStr(), aTilingObj.getLength() ) ) return false; @@ -3008,7 +3008,7 @@ static void appendSubsetName( int nSubsetID, const OUString& rPSName, OStringBuf { int nOffset = (nSubsetID % 26); nSubsetID /= 26; - rBuffer.append( (sal_Char)('A'+nOffset) ); + rBuffer.append( static_cast<sal_Char>('A'+nOffset) ); } rBuffer.append( '+' ); } @@ -3057,18 +3057,18 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 const * pEncoding, { if( nCount ) aContents.append( "endbfchar\n" ); - aContents.append( (sal_Int32)((nMapped-nCount > 100) ? 100 : nMapped-nCount ) ); + aContents.append( static_cast<sal_Int32>((nMapped-nCount > 100) ? 100 : nMapped-nCount ) ); aContents.append( " beginbfchar\n" ); } aContents.append( '<' ); - appendHex( (sal_Int8)pEncoding[n], aContents ); + appendHex( static_cast<sal_Int8>(pEncoding[n]), aContents ); aContents.append( "> <" ); // TODO: handle code points>U+FFFF sal_Int32 nIndex = pEncToUnicodeIndex[n]; for( sal_Int32 j = 0; j < pCodeUnitsPerGlyph[n]; j++ ) { - appendHex( (sal_Int8)(pCodeUnits[nIndex + j] / 256), aContents ); - appendHex( (sal_Int8)(pCodeUnits[nIndex + j] & 255), aContents ); + appendHex( static_cast<sal_Int8>(pCodeUnits[nIndex + j] / 256), aContents ); + appendHex( static_cast<sal_Int8>(pCodeUnits[nIndex + j] & 255), aContents ); } aContents.append( ">\n" ); nCount++; @@ -3099,7 +3099,7 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 const * pEncoding, sal_Int32 nLen = 0; if (!g_bDebugDisableCompression) { - nLen = (sal_Int32)aStream.Tell(); + nLen = static_cast<sal_Int32>(aStream.Tell()); aStream.Seek( 0 ); aLine.append( nLen ); aLine.append( "/Filter/FlateDecode" ); @@ -3154,13 +3154,13 @@ sal_Int32 PDFWriterImpl::emitFontDescriptor( const PhysicalFontFace* pFont, Font aLine.append( "\n" "/FontBBox[" ); // note: Top and Bottom are reversed in VCL and PDF rectangles - aLine.append( (sal_Int32)rInfo.m_aFontBBox.TopLeft().X() ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.TopLeft().X()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)rInfo.m_aFontBBox.TopLeft().Y() ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.TopLeft().Y()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)rInfo.m_aFontBBox.BottomRight().X() ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.BottomRight().X()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)(rInfo.m_aFontBBox.BottomRight().Y()+1) ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.BottomRight().Y()+1) ); aLine.append( "]/ItalicAngle " ); if( pFont->GetItalic() == ITALIC_OBLIQUE || pFont->GetItalic() == ITALIC_NORMAL ) aLine.append( "-30" ); @@ -3168,13 +3168,13 @@ sal_Int32 PDFWriterImpl::emitFontDescriptor( const PhysicalFontFace* pFont, Font aLine.append( "0" ); aLine.append( "\n" "/Ascent " ); - aLine.append( (sal_Int32)rInfo.m_nAscent ); + aLine.append( static_cast<sal_Int32>(rInfo.m_nAscent) ); aLine.append( "\n" "/Descent " ); - aLine.append( (sal_Int32)-rInfo.m_nDescent ); + aLine.append( static_cast<sal_Int32>(-rInfo.m_nDescent) ); aLine.append( "\n" "/CapHeight " ); - aLine.append( (sal_Int32)rInfo.m_nCapHeight ); + aLine.append( static_cast<sal_Int32>(rInfo.m_nCapHeight) ); // According to PDF reference 1.4 StemV is required // seems a tad strange to me, but well ... aLine.append( "\n" @@ -3306,7 +3306,7 @@ bool PDFWriterImpl::emitFonts() sal_uInt64 nStartPos = 0; if( aSubsetInfo.m_nFontType == FontType::SFNT_TTF ) { - aLine.append( (sal_Int32)nLength1 ); + aLine.append( static_cast<sal_Int32>(nLength1) ); aLine.append( ">>\n" "stream\n" ); @@ -3341,14 +3341,14 @@ bool PDFWriterImpl::emitFonts() if ( osl::File::E_None != aFontFile.setPos(osl_Pos_Absolut, 0) ) return false; // get the PFB-segment lengths ThreeInts aSegmentLengths = {0,0,0}; - getPfbSegmentLengths(xBuffer.get(), (int)nBytesRead, aSegmentLengths); + getPfbSegmentLengths(xBuffer.get(), static_cast<int>(nBytesRead), aSegmentLengths); // the lengths below are mandatory for PDF-exported Type1 fonts // because the PFB segment headers get stripped! WhyOhWhy. - aLine.append( (sal_Int32)aSegmentLengths[0] ); + aLine.append( static_cast<sal_Int32>(aSegmentLengths[0]) ); aLine.append( "/Length2 " ); - aLine.append( (sal_Int32)aSegmentLengths[1] ); + aLine.append( static_cast<sal_Int32>(aSegmentLengths[1]) ); aLine.append( "/Length3 " ); - aLine.append( (sal_Int32)aSegmentLengths[2] ); + aLine.append( static_cast<sal_Int32>(aSegmentLengths[2]) ); aLine.append( ">>\n" "stream\n" ); @@ -3385,7 +3385,7 @@ bool PDFWriterImpl::emitFonts() aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndPos-nStartPos) ); + aLine.append( static_cast<sal_Int64>(nEndPos-nStartPos) ); aLine.append( "\nendobj\n\n" ); if ( !writeBuffer( aLine.getStr(), aLine.getLength() ) ) return false; @@ -3408,7 +3408,7 @@ bool PDFWriterImpl::emitFonts() aLine.append( "\n" "/FirstChar 0\n" "/LastChar " ); - aLine.append( (sal_Int32)(nGlyphs-1) ); + aLine.append( static_cast<sal_Int32>(nGlyphs-1) ); aLine.append( "\n" "/Widths[" ); for( int i = 0; i < nGlyphs; i++ ) @@ -3625,7 +3625,7 @@ sal_Int32 PDFWriterImpl::emitOutline() appendUnicodeTextStringEncrypt( rItem.m_aTitle, rItem.m_nObject, aLine ); aLine.append( "\n" ); // Dest is not required - if( rItem.m_nDestID >= 0 && rItem.m_nDestID < (sal_Int32)m_aDests.size() ) + if( rItem.m_nDestID >= 0 && rItem.m_nDestID < static_cast<sal_Int32>(m_aDests.size()) ) { aLine.append( "/Dest" ); appendDest( rItem.m_nDestID, aLine ); @@ -3658,9 +3658,9 @@ sal_Int32 PDFWriterImpl::emitOutline() bool PDFWriterImpl::appendDest( sal_Int32 nDestID, OStringBuffer& rBuffer ) { - if( nDestID < 0 || nDestID >= (sal_Int32)m_aDests.size() ) + if( nDestID < 0 || nDestID >= static_cast<sal_Int32>(m_aDests.size()) ) { - SAL_INFO("vcl.pdfwriter", "ERROR: invalid dest " << (int)nDestID << " requested"); + SAL_INFO("vcl.pdfwriter", "ERROR: invalid dest " << static_cast<int>(nDestID) << " requested"); return false; } @@ -5039,7 +5039,7 @@ bool PDFWriterImpl::emitCatalog() } aLine.append( "]\n" "/Count " ); - aLine.append( (sal_Int32)m_aPages.size() ); + aLine.append( static_cast<sal_Int32>(m_aPages.size()) ); aLine.append( ">>\n" "endobj\n\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -5099,7 +5099,7 @@ bool PDFWriterImpl::emitCatalog() aLine.append( "/PageMode/FullScreen\n" ); //document is opened full screen OStringBuffer aInitPageRef; - if( m_aContext.InitialPage >= 0 && m_aContext.InitialPage < (sal_Int32)m_aPages.size() ) + if( m_aContext.InitialPage >= 0 && m_aContext.InitialPage < static_cast<sal_Int32>(m_aPages.size()) ) { aInitPageRef.append( m_aPages[m_aContext.InitialPage].m_nPageObject ); aInitPageRef.append( " 0 R" ); @@ -5142,7 +5142,7 @@ bool PDFWriterImpl::emitCatalog() aLine.append( aInitPageRef.makeStringAndClear() ); aLine.append( " /XYZ null null " ); if( m_aContext.Zoom >= 50 && m_aContext.Zoom <= 1600 ) - aLine.append( (double)m_aContext.Zoom/100.0 ); + aLine.append( static_cast<double>(m_aContext.Zoom)/100.0 ); else aLine.append( "0" ); aLine.append( "]\n" ); @@ -5391,7 +5391,7 @@ bool PDFWriterImpl::finalizeSignature() //FIXME: Check if hash is calculated from the correct byterange if (osl::File::E_None != m_aFile.read(buffer1.get(), m_nSignatureContentOffset - 1 , bytesRead1) || - bytesRead1 != (sal_uInt64)m_nSignatureContentOffset - 1) + bytesRead1 != static_cast<sal_uInt64>(m_nSignatureContentOffset) - 1) { SAL_WARN("vcl.pdfwriter", "First buffer read failed"); return false; @@ -5402,7 +5402,7 @@ bool PDFWriterImpl::finalizeSignature() if (osl::File::E_None != m_aFile.setPos(osl_Pos_Absolut, m_nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1) || osl::File::E_None != m_aFile.read(buffer2.get(), nLastByteRangeNo, bytesRead2) || - bytesRead2 != (sal_uInt64) nLastByteRangeNo) + bytesRead2 != static_cast<sal_uInt64>(nLastByteRangeNo)) { SAL_WARN("vcl.pdfwriter", "Second buffer read failed"); return false; @@ -5604,7 +5604,7 @@ sal_Int32 PDFWriterImpl::emitOutputIntent() std::vector<unsigned char> aBuffer(nBytesNeeded); cmsSaveProfileToMem(hProfile, &aBuffer[0], &nBytesNeeded); cmsCloseProfile(hProfile); - bool written = writeBuffer( &aBuffer[0], (sal_Int32) aBuffer.size() ); + bool written = writeBuffer( &aBuffer[0], static_cast<sal_Int32>(aBuffer.size()) ); disableStreamEncryption(); endCompression(); sal_uInt64 nEndStreamPos = 0; @@ -5621,7 +5621,7 @@ sal_Int32 PDFWriterImpl::emitOutputIntent() aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-nBeginStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-nBeginStreamPos) ); aLine.append( "\nendobj\n\n" ); if ( !writeBuffer( aLine.getStr(), aLine.getLength() ) ) return 0; aLine.setLength( 0 ); @@ -5875,7 +5875,7 @@ bool PDFWriterImpl::emitTrailer() sal_Int32 nObjects = m_aObjects.size(); OStringBuffer aLine; aLine.append( "0 " ); - aLine.append( (sal_Int32)(nObjects+1) ); + aLine.append( static_cast<sal_Int32>(nObjects+1) ); aLine.append( "\n" ); aLine.append( "0000000000 65535 f \n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -5906,7 +5906,7 @@ bool PDFWriterImpl::emitTrailer() aLine.setLength( 0 ); aLine.append( "trailer\n" "<</Size " ); - aLine.append( (sal_Int32)(nObjects+1) ); + aLine.append( static_cast<sal_Int32>(nObjects+1) ); aLine.append( "/Root " ); aLine.append( m_nCatalogObject ); aLine.append( " 0 R\n" ); @@ -5958,7 +5958,7 @@ bool PDFWriterImpl::emitTrailer() } aLine.append( ">>\n" "startxref\n" ); - aLine.append( (sal_Int64)nXRefOffset ); + aLine.append( static_cast<sal_Int64>(nXRefOffset) ); aLine.append( "\n" "%%EOF\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -6062,9 +6062,9 @@ void PDFWriterImpl::sortWidgets() { SAL_WARN( "vcl.pdfwriter", "wrong number of sorted annotations" ); SAL_INFO("vcl.pdfwriter", "PDFWriterImpl::sortWidgets(): wrong number of sorted assertions " - "on page nr " << (long int)item.first << ", " << - (long int)item.second.aSortedAnnots.size() << " sorted and " << - (long int)nAnnots << " unsorted"); + "on page nr " << static_cast<long int>(item.first) << ", " << + static_cast<long int>(item.second.aSortedAnnots.size()) << " sorted and " << + static_cast<long int>(nAnnots) << " unsorted"); } } @@ -6163,7 +6163,7 @@ bool PDFWriterImpl::emitAdditionalStreams() aLine.setLength( 0 ); aLine.append( nSizeObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-nBeginStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-nBeginStreamPos) ); aLine.append( "\nendobj\n\n" ); if( ! writeBuffer( aLine.getStr(), aLine.getLength() ) ) return false; @@ -6421,19 +6421,19 @@ void PDFWriterImpl::drawVerticalGlyphs( { fDeltaAngle = M_PI/2.0; aDeltaPos.X() = m_pReferenceDevice->GetFontMetric().GetAscent(); - aDeltaPos.Y() = (int)((double)m_pReferenceDevice->GetFontMetric().GetDescent() * fXScale); + aDeltaPos.Y() = static_cast<int>(static_cast<double>(m_pReferenceDevice->GetFontMetric().GetDescent()) * fXScale); fYScale = fXScale; fTempXScale = 1.0; fSkewA = -fSkewB; fSkewB = 0.0; } - aDeltaPos += (m_pReferenceDevice->PixelToLogic( Point( (int)((double)nXOffset/fXScale), 0 ) ) - m_pReferenceDevice->PixelToLogic( Point() ) ); + aDeltaPos += (m_pReferenceDevice->PixelToLogic( Point( static_cast<int>(static_cast<double>(nXOffset)/fXScale), 0 ) ) - m_pReferenceDevice->PixelToLogic( Point() ) ); if( i < rGlyphs.size()-1 ) // #i120627# the text on the Y axis is reversed when export ppt file to PDF format { long nOffsetX = rGlyphs[i+1].m_aPos.X() - rGlyphs[i].m_aPos.X(); long nOffsetY = rGlyphs[i+1].m_aPos.Y() - rGlyphs[i].m_aPos.Y(); - nXOffset += (int)sqrt(double(nOffsetX*nOffsetX + nOffsetY*nOffsetY)); + nXOffset += static_cast<int>(sqrt(double(nOffsetX*nOffsetX + nOffsetY*nOffsetY))); } if( ! rGlyphs[i].m_nGlyphId ) continue; @@ -6544,7 +6544,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( const Point aPrevPos = aMat.transform( rGlyphs[nPos-1].m_aPos ); double fAdvance = aThisPos.X() - aPrevPos.X(); fAdvance *= 1000.0 / nPixelFontHeight; - const sal_Int32 nAdjustment = (sal_Int32)(rGlyphs[nPos-1].m_nNativeWidth - fAdvance + 0.5); + const sal_Int32 nAdjustment = static_cast<sal_Int32>(rGlyphs[nPos-1].m_nNativeWidth - fAdvance + 0.5); if( nAdjustment != 0 ) { // apply individual glyph positioning @@ -6609,8 +6609,8 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool if( aMetric.GetAverageFontWidth() != m_aCurrentPDFState.m_aFont.GetAverageFontWidth() ) { fXScale = - (double)m_aCurrentPDFState.m_aFont.GetAverageFontWidth() / - (double)aMetric.GetAverageFontWidth(); + static_cast<double>(m_aCurrentPDFState.m_aFont.GetAverageFontWidth()) / + static_cast<double>(aMetric.GetAverageFontWidth()); } // force state before GetFontMetric m_pReferenceDevice->ImplNewFont(); @@ -6637,7 +6637,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool while( nAngle < 0 ) nAngle += 3600; nAngle = nAngle % 3600; - double fAngle = (double)nAngle * M_PI / 1800.0; + double fAngle = static_cast<double>(nAngle) * M_PI / 1800.0; Matrix3 aRotScale; aRotScale.scale( fXScale, 1.0 ); @@ -6702,7 +6702,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } else { - double fW = (double)m_aCurrentPDFState.m_aFont.GetFontHeight() / 30.0; + double fW = static_cast<double>(m_aCurrentPDFState.m_aFont.GetFontHeight()) / 30.0; m_aPages.back().appendMappedLength( fW, aLine ); aLine.append ( " w\n" ); } @@ -7285,7 +7285,7 @@ void PDFWriterImpl::drawWaveTextLine( OStringBuffer& aLine, long nWidth, FontLin if ( eTextLine == LINESTYLE_BOLDWAVE ) nLineWidth = 3*nLineWidth; - m_aPages.back().appendMappedLength( (sal_Int32)nLineWidth, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineWidth), aLine ); aLine.append( " w " ); if ( eTextLine == LINESTYLE_DOUBLEWAVE ) @@ -7402,7 +7402,7 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon if ( !nLineHeight ) return; - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine ); aLine.append( " w " ); appendStrokingColor( aColor, aLine ); aLine.append( "\n" ); @@ -7412,7 +7412,7 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon case LINESTYLE_DOTTED: case LINESTYLE_BOLDDOTTED: aLine.append( "[ " ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( " ] 0 d\n" ); break; case LINESTYLE_DASH: @@ -7442,7 +7442,7 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( " ] 0 d\n" ); @@ -7458,11 +7458,11 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( " ] 0 d\n" ); @@ -7473,20 +7473,20 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon } aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " l S\n" ); if ( eTextLine == LINESTYLE_DOUBLE ) { aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " l S\n" ); } @@ -7531,27 +7531,27 @@ void PDFWriterImpl::drawStrikeoutLine( OStringBuffer& aLine, long nWidth, FontSt if ( !nLineHeight ) return; - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine ); aLine.append( " w " ); appendStrokingColor( aColor, aLine ); aLine.append( "\n" ); aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " l S\n" ); if ( eStrikeout == STRIKEOUT_DOUBLE ) { aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " l S\n" ); } @@ -7653,7 +7653,7 @@ void PDFWriterImpl::drawTextLine( const Point& rPos, long nWidth, FontStrikeout aLine.append( "q " ); // rotate and translate matrix - double fAngle = (double)m_aCurrentPDFState.m_aFont.GetOrientation() * M_PI / 1800.0; + double fAngle = static_cast<double>(m_aCurrentPDFState.m_aFont.GetOrientation()) * M_PI / 1800.0; Matrix3 aMat; aMat.rotate( fAngle ); aMat.translate( aPos.X(), aPos.Y() ); @@ -7780,7 +7780,7 @@ void PDFWriterImpl::drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uI m_aPages.back().convertRect( m_aTransparentObjects.back().m_aBoundRect ); m_aTransparentObjects.back().m_nObject = createObject(); m_aTransparentObjects.back().m_nExtGStateObject = createObject(); - m_aTransparentObjects.back().m_fAlpha = (double)(100-nTransparentPercent) / 100.0; + m_aTransparentObjects.back().m_fAlpha = static_cast<double>(100-nTransparentPercent) / 100.0; m_aTransparentObjects.back().m_pContentStream = new SvMemoryStream( 256, 256 ); // create XObject's content stream OStringBuffer aContent( 256 ); @@ -7923,7 +7923,7 @@ void PDFWriterImpl::endTransparencyGroup( const tools::Rectangle& rBoundingBox, // convert rectangle to default user space m_aPages.back().convertRect( m_aTransparentObjects.back().m_aBoundRect ); m_aTransparentObjects.back().m_nObject = createObject(); - m_aTransparentObjects.back().m_fAlpha = (double)(100-nTransparentPercent) / 100.0; + m_aTransparentObjects.back().m_fAlpha = static_cast<double>(100-nTransparentPercent) / 100.0; // get XObject's content stream m_aTransparentObjects.back().m_pContentStream = static_cast<SvMemoryStream*>(endRedirect()); m_aTransparentObjects.back().m_nExtGStateObject = createObject(); @@ -7987,15 +7987,15 @@ void PDFWriterImpl::drawRectangle( const tools::Rectangle& rRect, sal_uInt32 nHo m_aGraphicsStack.front().m_aFillColor == Color( COL_TRANSPARENT ) ) return; - if( nHorzRound > (sal_uInt32)rRect.GetWidth()/2 ) + if( nHorzRound > static_cast<sal_uInt32>(rRect.GetWidth())/2 ) nHorzRound = rRect.GetWidth()/2; - if( nVertRound > (sal_uInt32)rRect.GetHeight()/2 ) + if( nVertRound > static_cast<sal_uInt32>(rRect.GetHeight())/2 ) nVertRound = rRect.GetHeight()/2; Point aPoints[16]; const double kappa = 0.5522847498; - const sal_uInt32 kx = (sal_uInt32)((kappa*(double)nHorzRound)+0.5); - const sal_uInt32 ky = (sal_uInt32)((kappa*(double)nVertRound)+0.5); + const sal_uInt32 kx = static_cast<sal_uInt32>((kappa*static_cast<double>(nHorzRound))+0.5); + const sal_uInt32 ky = static_cast<sal_uInt32>((kappa*static_cast<double>(nVertRound))+0.5); aPoints[1] = Point( rRect.TopLeft().X() + nHorzRound, rRect.TopLeft().Y() ); aPoints[0] = Point( aPoints[1].X() - kx, aPoints[1].Y() ); @@ -8076,8 +8076,8 @@ void PDFWriterImpl::drawEllipse( const tools::Rectangle& rRect ) Point aPoints[12]; const double kappa = 0.5522847498; - const sal_uInt32 kx = (sal_uInt32)((kappa*(double)rRect.GetWidth()/2.0)+0.5); - const sal_uInt32 ky = (sal_uInt32)((kappa*(double)rRect.GetHeight()/2.0)+0.5); + const sal_uInt32 kx = static_cast<sal_uInt32>((kappa*static_cast<double>(rRect.GetWidth())/2.0)+0.5); + const sal_uInt32 ky = static_cast<sal_uInt32>((kappa*static_cast<double>(rRect.GetHeight())/2.0)+0.5); aPoints[1] = Point( rRect.TopLeft().X() + rRect.GetWidth()/2, rRect.TopLeft().Y() ); aPoints[0] = Point( aPoints[1].X() - kx, aPoints[1].Y() ); @@ -8140,16 +8140,16 @@ static double calcAngle( const tools::Rectangle& rRect, const Point& rPoint ) (rRect.Top()+rRect.Bottom()+1)/2); Point aPoint = rPoint - aOrigin; - double fX = (double)aPoint.X(); - double fY = (double)-aPoint.Y(); + double fX = static_cast<double>(aPoint.X()); + double fY = static_cast<double>(-aPoint.Y()); if ((rRect.GetHeight() == 0) || (rRect.GetWidth() == 0)) throw o3tl::divide_by_zero(); if( rRect.GetWidth() > rRect.GetHeight() ) - fY = fY*((double)rRect.GetWidth()/(double)rRect.GetHeight()); + fY = fY*(static_cast<double>(rRect.GetWidth())/static_cast<double>(rRect.GetHeight())); else if( rRect.GetHeight() > rRect.GetWidth() ) - fX = fX*((double)rRect.GetHeight()/(double)rRect.GetWidth()); + fX = fX*(static_cast<double>(rRect.GetHeight())/static_cast<double>(rRect.GetWidth())); return atan2( fY, fX ); } @@ -8168,18 +8168,18 @@ void PDFWriterImpl::drawArc( const tools::Rectangle& rRect, const Point& rStart, double fStopAngle = calcAngle( rRect, rStop ); while( fStopAngle < fStartAngle ) fStopAngle += 2.0*M_PI; - const int nFragments = (int)((fStopAngle-fStartAngle)/(M_PI/2.0))+1; - const double fFragmentDelta = (fStopAngle-fStartAngle)/(double)nFragments; + const int nFragments = static_cast<int>((fStopAngle-fStartAngle)/(M_PI/2.0))+1; + const double fFragmentDelta = (fStopAngle-fStartAngle)/static_cast<double>(nFragments); const double kappa = fabs( 4.0 * (1.0-cos(fFragmentDelta/2.0))/sin(fFragmentDelta/2.0) / 3.0); - const double halfWidth = (double)rRect.GetWidth()/2.0; - const double halfHeight = (double)rRect.GetHeight()/2.0; + const double halfWidth = static_cast<double>(rRect.GetWidth())/2.0; + const double halfHeight = static_cast<double>(rRect.GetHeight())/2.0; const Point aCenter( (rRect.Left()+rRect.Right()+1)/2, (rRect.Top()+rRect.Bottom()+1)/2 ); OStringBuffer aLine( 30*nFragments ); - Point aPoint( (int)(halfWidth * cos(fStartAngle) ), - -(int)(halfHeight * sin(fStartAngle) ) ); + Point aPoint( static_cast<int>(halfWidth * cos(fStartAngle) ), + -static_cast<int>(halfHeight * sin(fStartAngle) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( " m " ); @@ -8187,22 +8187,22 @@ void PDFWriterImpl::drawArc( const tools::Rectangle& rRect, const Point& rStart, { for( int i = 0; i < nFragments; i++ ) { - const double fStartFragment = fStartAngle + (double)i*fFragmentDelta; + const double fStartFragment = fStartAngle + static_cast<double>(i)*fFragmentDelta; const double fStopFragment = fStartFragment + fFragmentDelta; - aPoint = Point( (int)(halfWidth * (cos(fStartFragment) - kappa*sin(fStartFragment) ) ), - -(int)(halfHeight * (sin(fStartFragment) + kappa*cos(fStartFragment) ) ) ); + aPoint = Point( static_cast<int>(halfWidth * (cos(fStartFragment) - kappa*sin(fStartFragment) ) ), + -static_cast<int>(halfHeight * (sin(fStartFragment) + kappa*cos(fStartFragment) ) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( ' ' ); - aPoint = Point( (int)(halfWidth * (cos(fStopFragment) + kappa*sin(fStopFragment) ) ), - -(int)(halfHeight * (sin(fStopFragment) - kappa*cos(fStopFragment) ) ) ); + aPoint = Point( static_cast<int>(halfWidth * (cos(fStopFragment) + kappa*sin(fStopFragment) ) ), + -static_cast<int>(halfHeight * (sin(fStopFragment) - kappa*cos(fStopFragment) ) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( ' ' ); - aPoint = Point( (int)(halfWidth * cos(fStopFragment) ), - -(int)(halfHeight * sin(fStopFragment) ) ); + aPoint = Point( static_cast<int>(halfWidth * cos(fStopFragment) ), + -static_cast<int>(halfHeight * sin(fStopFragment) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( " c\n" ); @@ -8471,7 +8471,7 @@ void PDFWriterImpl::drawPolyLine( const tools::Polygon& rPoly, const PDFWriter:: aBoundRect.Right() += nLW; aBoundRect.Bottom() += nLW; } - endTransparencyGroup( aBoundRect, (sal_uInt16)(100.0*rInfo.m_fTransparency) ); + endTransparencyGroup( aBoundRect, static_cast<sal_uInt16>(100.0*rInfo.m_fTransparency) ); } } @@ -8546,7 +8546,7 @@ void PDFWriterImpl::writeTransparentObject( TransparencyEmit& rObject ) */ aLine.append( "/Length " ); - aLine.append( (sal_Int32)nSize ); + aLine.append( static_cast<sal_Int32>(nSize) ); aLine.append( "\n" ); if( bFlateFilter ) aLine.append( "/Filter/FlateDecode\n" ); @@ -8594,7 +8594,7 @@ void PDFWriterImpl::writeTransparentObject( TransparencyEmit& rObject ) else { rObject.m_pSoftMaskStream->Seek( STREAM_SEEK_TO_END ); - sal_Int32 nMaskSize = (sal_Int32)rObject.m_pSoftMaskStream->Tell(); + sal_Int32 nMaskSize = static_cast<sal_Int32>(rObject.m_pSoftMaskStream->Tell()); rObject.m_pSoftMaskStream->Seek( STREAM_SEEK_TO_BEGIN ); sal_Int32 nMaskObject = createObject(); aLine.append( "/SMask<</Type/Mask/S/Luminosity/G " ); @@ -8692,9 +8692,9 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aLine.append('3'); break; default: - aLine.append( (sal_Int32)aSize.Width() ); + aLine.append( static_cast<sal_Int32>(aSize.Width()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aSize.Height() ); + aLine.append( static_cast<sal_Int32>(aSize.Height()) ); } aLine.append( " ]\n" "/BitsPerSample 8\n" @@ -8768,7 +8768,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-nStartStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-nStartStreamPos) ); aLine.append( "\nendobj\n\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -8825,13 +8825,13 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aPoly[1] = aBoundRect.TopCenter(); aPoly.Rotate( aCenter, 3600 - nAngle ); - aLine.append( (sal_Int32) aPoly[0].X() ); + aLine.append( static_cast<sal_Int32>(aPoly[0].X()) ); aLine.append( " " ); - aLine.append( (sal_Int32) aPoly[0].Y() ); + aLine.append( static_cast<sal_Int32>(aPoly[0].Y()) ); aLine.append( " " ); - aLine.append( (sal_Int32) aPoly[1].X()); + aLine.append( static_cast<sal_Int32>(aPoly[1].X())); aLine.append( " "); - aLine.append( (sal_Int32) aPoly[1].Y()); + aLine.append( static_cast<sal_Int32>(aPoly[1].Y())); aLine.append( " ]\n"); aLine.append("/Extend [true true]\n"); break; @@ -8839,9 +8839,9 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) default: aLine.append("/Domain[ 0 1 0 1 ]\n" "/Matrix[ " ); - aLine.append( (sal_Int32)aSize.Width() ); + aLine.append( static_cast<sal_Int32>(aSize.Width()) ); aLine.append( " 0 0 " ); - aLine.append( (sal_Int32)aSize.Height() ); + aLine.append( static_cast<sal_Int32>(aSize.Height()) ); aLine.append( " 0 0 ]\n"); } aLine.append("/Function " ); @@ -8894,9 +8894,9 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject ) aLine.append( rObject.m_nObject ); aLine.append( " 0 obj\n" "<</Type/XObject/Subtype/Image/Width " ); - aLine.append( (sal_Int32)rObject.m_aID.m_aPixelSize.Width() ); + aLine.append( static_cast<sal_Int32>(rObject.m_aID.m_aPixelSize.Width()) ); aLine.append( " /Height " ); - aLine.append( (sal_Int32)rObject.m_aID.m_aPixelSize.Height() ); + aLine.append( static_cast<sal_Int32>(rObject.m_aID.m_aPixelSize.Height()) ); aLine.append( " /BitsPerComponent 8 " ); if( rObject.m_bTrueColor ) aLine.append( "/ColorSpace/DeviceRGB" ); @@ -9481,9 +9481,9 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.append( rObject.m_nObject ); aLine.append( " 0 obj\n" "<</Type/XObject/Subtype/Image/Width " ); - aLine.append( (sal_Int32)aBitmap.GetSizePixel().Width() ); + aLine.append( static_cast<sal_Int32>(aBitmap.GetSizePixel().Width()) ); aLine.append( "/Height " ); - aLine.append( (sal_Int32)aBitmap.GetSizePixel().Height() ); + aLine.append( static_cast<sal_Int32>(aBitmap.GetSizePixel().Height()) ); aLine.append( "/BitsPerComponent " ); aLine.append( nBitsPerComponent ); aLine.append( "/Length " ); @@ -9498,7 +9498,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) else { aLine.append( "/Filter/CCITTFaxDecode/DecodeParms<</K -1/BlackIs1 true/Columns " ); - aLine.append( (sal_Int32)aBitmap.GetSizePixel().Width() ); + aLine.append( static_cast<sal_Int32>(aBitmap.GetSizePixel().Width()) ); aLine.append( ">>\n" ); } } @@ -9541,7 +9541,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) else { aLine.append( "[ /Indexed/DeviceRGB " ); - aLine.append( (sal_Int32)(pAccess->GetPaletteEntryCount()-1) ); + aLine.append( static_cast<sal_Int32>(pAccess->GetPaletteEntryCount()-1) ); aLine.append( "\n<" ); if( m_aContext.Encryption.Encrypt() ) { @@ -9619,17 +9619,17 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.append( "/Mask[ " ); if( bTrueColor ) { - aLine.append( (sal_Int32)aTransparentColor.GetRed() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetRed()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetRed() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetRed()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetGreen() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetGreen()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetGreen() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetGreen()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetBlue() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetBlue()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetBlue() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetBlue()) ); } else { @@ -9695,7 +9695,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndPos-nStartPos) ); + aLine.append( static_cast<sal_Int64>(nEndPos-nStartPos) ); aLine.append( "\nendobj\n\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -9802,10 +9802,10 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const aLine.append( "q " ); sal_Int32 nCheckWidth = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetWidth(), aLine, false, &nCheckWidth ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rTargetArea.GetWidth()), aLine, false, &nCheckWidth ); aLine.append( " 0 0 " ); sal_Int32 nCheckHeight = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetHeight(), aLine, true, &nCheckHeight ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rTargetArea.GetHeight()), aLine, true, &nCheckHeight ); aLine.append( ' ' ); m_aPages.back().appendPoint( rTargetArea.BottomLeft(), aLine ); aLine.append( " cm\n/Im" ); @@ -9841,10 +9841,10 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize, aLine.append( ' ' ); } sal_Int32 nCheckWidth = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Width(), aLine, false, &nCheckWidth ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rDestSize.Width()), aLine, false, &nCheckWidth ); aLine.append( " 0 0 " ); sal_Int32 nCheckHeight = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Height(), aLine, true, &nCheckHeight ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rDestSize.Height()), aLine, true, &nCheckHeight ); aLine.append( ' ' ); m_aPages.back().appendPoint( rDestPoint + Point( 0, rDestSize.Height()-1 ), aLine ); aLine.append( " cm\n/Im" ); @@ -9989,9 +9989,9 @@ void PDFWriterImpl::drawGradient( const tools::Rectangle& rRect, const Gradient& if( m_aGraphicsStack.front().m_aLineColor != Color( COL_TRANSPARENT ) ) aLine.append( "q " ); aLine.append( "0 0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetWidth(), aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetWidth()), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetHeight(), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetHeight()), aLine ); aLine.append( " re W n\n" ); aLine.append( "/P" ); @@ -10000,9 +10000,9 @@ void PDFWriterImpl::drawGradient( const tools::Rectangle& rRect, const Gradient& if( m_aGraphicsStack.front().m_aLineColor != Color( COL_TRANSPARENT ) ) { aLine.append( "Q 0 0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetWidth(), aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetWidth()), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetHeight(), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetHeight()), aLine ); aLine.append( " re S " ); } aLine.append( "Q\n" ); @@ -10435,7 +10435,7 @@ void PDFWriterImpl::createNote( const tools::Rectangle& rRect, const PDFNote& rN if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return; m_aNotes.emplace_back( ); @@ -10454,7 +10454,7 @@ sal_Int32 PDFWriterImpl::createLink( const tools::Rectangle& rRect, sal_Int32 nP if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; sal_Int32 nRet = m_aLinks.size(); @@ -10500,7 +10500,7 @@ sal_Int32 PDFWriterImpl::createNamedDest( const OUString& sDestName, const tools if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; sal_Int32 nRet = m_aNamedDests.size(); @@ -10521,7 +10521,7 @@ sal_Int32 PDFWriterImpl::createDest( const tools::Rectangle& rRect, sal_Int32 nP if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; sal_Int32 nRet = m_aDests.size(); @@ -10543,9 +10543,9 @@ sal_Int32 PDFWriterImpl::registerDestReference( sal_Int32 nDestId, const tools:: void PDFWriterImpl::setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ) { - if( nLinkId < 0 || nLinkId >= (sal_Int32)m_aLinks.size() ) + if( nLinkId < 0 || nLinkId >= static_cast<sal_Int32>(m_aLinks.size()) ) return; - if( nDestId < 0 || nDestId >= (sal_Int32)m_aDests.size() ) + if( nDestId < 0 || nDestId >= static_cast<sal_Int32>(m_aDests.size()) ) return; m_aLinks[ nLinkId ].m_nDest = nDestId; @@ -10553,7 +10553,7 @@ void PDFWriterImpl::setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ) void PDFWriterImpl::setLinkURL( sal_Int32 nLinkId, const OUString& rURL ) { - if( nLinkId < 0 || nLinkId >= (sal_Int32)m_aLinks.size() ) + if( nLinkId < 0 || nLinkId >= static_cast<sal_Int32>(m_aLinks.size()) ) return; m_aLinks[ nLinkId ].m_nDest = -1; @@ -10612,10 +10612,10 @@ sal_Int32 PDFWriterImpl::createOutlineItem( sal_Int32 nParent, const OUString& r void PDFWriterImpl::setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent ) { - if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) + if( nItem < 1 || nItem >= static_cast<sal_Int32>(m_aOutline.size()) ) return; - if( nNewParent < 0 || nNewParent >= (sal_Int32)m_aOutline.size() || nNewParent == nItem ) + if( nNewParent < 0 || nNewParent >= static_cast<sal_Int32>(m_aOutline.size()) || nNewParent == nItem ) { nNewParent = 0; } @@ -10625,7 +10625,7 @@ void PDFWriterImpl::setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent void PDFWriterImpl::setOutlineItemText( sal_Int32 nItem, const OUString& rText ) { - if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) + if( nItem < 1 || nItem >= static_cast<sal_Int32>(m_aOutline.size()) ) return; m_aOutline[ nItem ].m_aTitle = psp::WhitespaceToSpace( rText ); @@ -10633,9 +10633,9 @@ void PDFWriterImpl::setOutlineItemText( sal_Int32 nItem, const OUString& rText ) void PDFWriterImpl::setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID ) { - if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) // item does not exist + if( nItem < 1 || nItem >= static_cast<sal_Int32>(m_aOutline.size()) ) // item does not exist return; - if( nDestID < 0 || nDestID >= (sal_Int32)m_aDests.size() ) // dest does not exist + if( nDestID < 0 || nDestID >= static_cast<sal_Int32>(m_aDests.size()) ) // dest does not exist return; m_aOutline[nItem].m_nDestID = nDestID; } @@ -11345,7 +11345,7 @@ bool PDFWriterImpl::setStructureAttributeNumerical( enum PDFWriter::StructAttrib else if( m_nCurrentStructElement > 0 && m_bEmitStructure ) SAL_INFO("vcl.pdfwriter", "rejecting setStructureAttributeNumerical( " << getAttributeTag( eAttr ) - << ", " << (int)nValue + << ", " << static_cast<int>(nValue) << " ) on " << getStructureTag( m_aStructure[ m_nCurrentStructElement ].m_eType ) << " (" << m_aStructure[ m_nCurrentStructElement ].m_aAlias.getStr() << ") element"); @@ -11356,7 +11356,7 @@ bool PDFWriterImpl::setStructureAttributeNumerical( enum PDFWriter::StructAttrib void PDFWriterImpl::setStructureBoundingBox( const tools::Rectangle& rRect ) { sal_Int32 nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() || !m_aContext.Tagged ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) || !m_aContext.Tagged ) return; if( m_nCurrentStructElement > 0 && m_bEmitStructure ) @@ -11395,7 +11395,7 @@ void PDFWriterImpl::setAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr ) if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return; m_aPages[ nPageNr ].m_nDuration = nSeconds; @@ -11406,7 +11406,7 @@ void PDFWriterImpl::setPageTransition( PDFWriter::PageTransition eType, sal_uInt if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return; m_aPages[ nPageNr ].m_eTransition = eType; @@ -11510,7 +11510,7 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; bool sigHidden(true); @@ -11577,7 +11577,7 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa rNewWidget.m_eType = PDFWriter::CheckBox; rNewWidget.m_nRadioGroup = rBtn.RadioGroup; - SAL_WARN_IF( nRadioGroupWidget < 0 || nRadioGroupWidget >= (sal_Int32)m_aWidgets.size(), "vcl.pdfwriter", "no radio group parent" ); + SAL_WARN_IF( nRadioGroupWidget < 0 || nRadioGroupWidget >= static_cast<sal_Int32>(m_aWidgets.size()), "vcl.pdfwriter", "no radio group parent" ); PDFWidget& rRadioButton = m_aWidgets[nRadioGroupWidget]; rRadioButton.m_aKids.push_back( rNewWidget.m_nObject ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index c9d38e465cd8..b2890823fad3 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -1084,7 +1084,7 @@ public: Size getCurPageSize() const { Size aSize; - if( m_nCurrentPage >= 0 && m_nCurrentPage < (sal_Int32)m_aPages.size() ) + if( m_nCurrentPage >= 0 && m_nCurrentPage < static_cast<sal_Int32>(m_aPages.size()) ) aSize = Size( m_aPages[ m_nCurrentPage ].m_nPageWidth, m_aPages[ m_nCurrentPage ].m_nPageHeight ); return aSize; } diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 9f9cbc712ef3..a97fa4b22108 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -438,8 +438,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa if ( nMaxBmpDPI > i_rContext.m_nMaxImageResolution ) nMaxBmpDPI = i_rContext.m_nMaxImageResolution; } - const sal_Int32 nPixelX = (sal_Int32)((double)aDstSizeTwip.Width() * (double)nMaxBmpDPI / 1440.0); - const sal_Int32 nPixelY = (sal_Int32)((double)aDstSizeTwip.Height() * (double)nMaxBmpDPI / 1440.0); + const sal_Int32 nPixelX = static_cast<sal_Int32>(static_cast<double>(aDstSizeTwip.Width()) * static_cast<double>(nMaxBmpDPI) / 1440.0); + const sal_Int32 nPixelY = static_cast<sal_Int32>(static_cast<double>(aDstSizeTwip.Height()) * static_cast<double>(nMaxBmpDPI) / 1440.0); if ( nPixelX && nPixelY ) { Size aDstSizePixel( nPixelX, nPixelY ); @@ -458,8 +458,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() ); if ( aMtfOrigin.X() || aMtfOrigin.Y() ) aTmpMtf.Move( -aMtfOrigin.X(), -aMtfOrigin.Y() ); - double fScaleX = (double)aDstSize.Width() / (double)aTmpMtf.GetPrefSize().Width(); - double fScaleY = (double)aDstSize.Height() / (double)aTmpMtf.GetPrefSize().Height(); + double fScaleX = static_cast<double>(aDstSize.Width()) / static_cast<double>(aTmpMtf.GetPrefSize().Width()); + double fScaleY = static_cast<double>(aDstSize.Height()) / static_cast<double>(aTmpMtf.GetPrefSize().Height()); if( fScaleX != 1.0 || fScaleY != 1.0 ) aTmpMtf.Scale( fScaleX, fScaleY ); aTmpMtf.SetPrefMapMode( aMapMode ); @@ -1175,9 +1175,9 @@ void PDFWriterImpl::checkAndEnableStreamEncryption( sal_Int32 nObject ) { m_bEncryptThisStream = true; sal_Int32 i = m_nKeyLength; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)nObject; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 8 ); - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 16 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); // the other location of m_nEncryptionKey is already set to 0, our fixed generation number // do the MD5 hash sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ]; @@ -1194,9 +1194,9 @@ void PDFWriterImpl::enableStringEncryption( sal_Int32 nObject ) if( m_aContext.Encryption.Encrypt() ) { sal_Int32 i = m_nKeyLength; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)nObject; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 8 ); - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 16 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); // the other location of m_nEncryptionKey is already set to 0, our fixed generation number // do the MD5 hash sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ]; @@ -1312,7 +1312,7 @@ void PDFWriterImpl::padPassword( const OUString& i_rPassword, sal_uInt8* o_pPadd sal_Int32 nCurrentChar; for( nCurrentChar = 0; nCurrentChar < nToCopy; nCurrentChar++ ) - o_pPaddedPW[nCurrentChar] = (sal_uInt8)( aString[nCurrentChar] ); + o_pPaddedPW[nCurrentChar] = static_cast<sal_uInt8>( aString[nCurrentChar] ); //pad it with standard byte string sal_Int32 i,y; @@ -1348,10 +1348,10 @@ bool PDFWriterImpl::computeEncryptionKey( EncHashTransporter* i_pTransporter, vc //Step 4 sal_uInt8 nPerm[4]; - nPerm[0] = (sal_uInt8)i_nAccessPermissions; - nPerm[1] = (sal_uInt8)( i_nAccessPermissions >> 8 ); - nPerm[2] = (sal_uInt8)( i_nAccessPermissions >> 16 ); - nPerm[3] = (sal_uInt8)( i_nAccessPermissions >> 24 ); + nPerm[0] = static_cast<sal_uInt8>(i_nAccessPermissions); + nPerm[1] = static_cast<sal_uInt8>( i_nAccessPermissions >> 8 ); + nPerm[2] = static_cast<sal_uInt8>( i_nAccessPermissions >> 16 ); + nPerm[3] = static_cast<sal_uInt8>( i_nAccessPermissions >> 24 ); if( nError == rtl_Digest_E_None ) nError = rtl_digest_updateMD5( aDigest, nPerm , sizeof( nPerm ) ); @@ -1458,7 +1458,7 @@ bool PDFWriterImpl::computeODictionaryValue( const sal_uInt8* i_pPaddedOwnerPass for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1 { for( y = 0; y < sizeof( nLocalKey ); y++ ) - nLocalKey[y] = (sal_uInt8)( nMD5Sum[y] ^ i ); + nLocalKey[y] = static_cast<sal_uInt8>( nMD5Sum[y] ^ i ); rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, nLocalKey, SECUR_128BIT_KEY, nullptr, 0 ); //destination data area, on init can be NULL @@ -1533,7 +1533,7 @@ bool PDFWriterImpl::computeUDictionaryValue( EncHashTransporter* i_pTransporter, for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1 { for( y = 0; y < sizeof( nLocalKey ) ; y++ ) - nLocalKey[y] = (sal_uInt8)( io_rProperties.EncryptionKey[y] ^ i ); + nLocalKey[y] = static_cast<sal_uInt8>( io_rProperties.EncryptionKey[y] ^ i ); rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, nLocalKey, SECUR_128BIT_KEY, // key and key length diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index 2458d0269e76..9037466f1b8c 100644 --- a/vcl/source/gdi/pngread.cxx +++ b/vcl/source/gdi/pngread.cxx @@ -406,8 +406,8 @@ BitmapEx PNGReaderImpl::GetBitmapEx( const Size& rPreviewSizeHint ) mbpHYs = true; // convert into MapUnit::Map100thMM - maPhysSize.Width() = (sal_Int32)( (100000.0 * maOrigSize.Width()) / nXPixelPerMeter ); - maPhysSize.Height() = (sal_Int32)( (100000.0 * maOrigSize.Height()) / nYPixelPerMeter ); + maPhysSize.Width() = static_cast<sal_Int32>( (100000.0 * maOrigSize.Width()) / nXPixelPerMeter ); + maPhysSize.Height() = static_cast<sal_Int32>( (100000.0 * maOrigSize.Height()) / nYPixelPerMeter ); } } } @@ -610,7 +610,7 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint ) if (nMinSizeRequired > mnStreamSize) { SAL_WARN("vcl.gdi", "overlarge png dimensions: " << - maOrigSize.Width() << " x " << maOrigSize.Height() << " depth: " << (int)mnPngDepth << + maOrigSize.Width() << " x " << maOrigSize.Height() << " depth: " << static_cast<int>(mnPngDepth) << " couldn't be supplied by file length " << mnStreamSize << " at least " << nMinSizeRequired << " needed "); return false; } @@ -709,7 +709,7 @@ void PNGReaderImpl::ImplGetGrayPalette( sal_uInt16 nBitDepth ) mxAcc->SetPaletteEntryCount( nPaletteEntryCount ); for ( sal_uInt32 i = 0, nStart = 0; nStart < 256; i++, nStart += nAdd ) - mxAcc->SetPaletteColor( (sal_uInt16)i, BitmapColor( mpColorTable[ nStart ], + mxAcc->SetPaletteColor( static_cast<sal_uInt16>(i), BitmapColor( mpColorTable[ nStart ], mpColorTable[ nStart ], mpColorTable[ nStart ] ) ); } @@ -823,7 +823,7 @@ void PNGReaderImpl::ImplGetGamma() return; sal_uInt32 nGammaValue = ImplReadsal_uInt32(); - double fGamma = ( ( VIEWING_GAMMA / DISPLAY_GAMMA ) * ( (double)nGammaValue / 100000 ) ); + double fGamma = ( ( VIEWING_GAMMA / DISPLAY_GAMMA ) * ( static_cast<double>(nGammaValue) / 100000 ) ); double fInvGamma = ( fGamma <= 0.0 || fGamma > 10.0 ) ? 1.0 : ( 1.0 / fGamma ); if ( fInvGamma != 1.0 ) @@ -832,7 +832,7 @@ void PNGReaderImpl::ImplGetGamma() mpColorTable = new sal_uInt8[ 256 ]; for ( sal_Int32 i = 0; i < 256; i++ ) - mpColorTable[ i ] = (sal_uInt8)(pow((double)i/255.0, fInvGamma) * 255.0 + 0.5); + mpColorTable[ i ] = static_cast<sal_uInt8>(pow(static_cast<double>(i)/255.0, fInvGamma) * 255.0 + 0.5); if ( mbGrayScale ) ImplGetGrayPalette( mnPngDepth ); @@ -850,7 +850,7 @@ void PNGReaderImpl::ImplGetBackground() sal_uInt16 nCol = *maDataIter++; if ( nCol < mxAcc->GetPaletteEntryCount() ) { - mxAcc->Erase( mxAcc->GetPaletteColor( (sal_uInt8)nCol ) ); + mxAcc->Erase( mxAcc->GetPaletteColor( static_cast<sal_uInt8>(nCol) ) ); break; } } @@ -892,12 +892,12 @@ sal_uInt8 PNGReaderImpl::ImplScaleColor() sal_uInt32 nMask = ( ( 1 << mnPngDepth ) - 1 ); sal_uInt16 nCol = ( *maDataIter++ << 8 ); - nCol += *maDataIter++ & (sal_uInt16)nMask; + nCol += *maDataIter++ & static_cast<sal_uInt16>(nMask); if ( mnPngDepth > 8 ) // convert 16bit graphics to 8 nCol >>= 8; - return (sal_uInt8) nCol; + return static_cast<sal_uInt8>(nCol); } // ImplReadIDAT reads as much image data as needed @@ -940,7 +940,7 @@ void PNGReaderImpl::ImplReadIDAT() mnYpos += mnYAdd; } - if ( mnYpos >= (sal_uInt32)maOrigSize.Height() ) + if ( mnYpos >= static_cast<sal_uInt32>(maOrigSize.Height()) ) { if( (mnPass < 7) && mnInterlaceType ) if( ImplPreparePass() ) diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index d5d472be2eeb..eee377547688 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -152,13 +152,13 @@ bool PrinterOptions::ReadFromConfig( bool i_bFile ) if( xSet->getPropertyValue("ReducedGradientMode") >>= nValue ) SetReducedGradientMode( (PrinterGradientMode)nValue ); if( xSet->getPropertyValue("ReducedGradientStepCount") >>= nValue ) - SetReducedGradientStepCount( (sal_uInt16)nValue ); + SetReducedGradientStepCount( static_cast<sal_uInt16>(nValue) ); if( xSet->getPropertyValue("ReduceBitmaps") >>= bValue ) SetReduceBitmaps( bValue ); if( xSet->getPropertyValue("ReducedBitmapMode") >>= nValue ) SetReducedBitmapMode( (PrinterBitmapMode)nValue ); if( xSet->getPropertyValue("ReducedBitmapResolution") >>= nValue ) - SetReducedBitmapResolution( (sal_uInt16)nValue ); + SetReducedBitmapResolution( static_cast<sal_uInt16>(nValue) ); if( xSet->getPropertyValue("ReducedBitmapIncludesTransparency") >>= bValue ) SetReducedBitmapIncludesTransparency( bValue ); if( xSet->getPropertyValue("ConvertToGreyscales") >>= bValue ) @@ -792,10 +792,10 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, // create forward mapping tables for( nX = 0; nX <= nSrcWidth; nX++ ) - pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth ); + pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth ); for( nY = 0; nY <= nSrcHeight; nY++ ) - pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight ); + pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight ); // walk through all rectangles of mask const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel()))); @@ -1535,7 +1535,7 @@ OUString Printer::GetPaperName( Paper ePaper ) (*pSVData->mpPaperNames)[PaperIndex[i]] = VclResId(RID_STR_PAPERNAMES[i]); } - std::unordered_map<int,OUString>::const_iterator it = pSVData->mpPaperNames->find( (int)ePaper ); + std::unordered_map<int,OUString>::const_iterator it = pSVData->mpPaperNames->find( static_cast<int>(ePaper) ); return (it != pSVData->mpPaperNames->end()) ? it->second : OUString(); } diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index e81af9ded1fb..57f0d4e0e4f3 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -1122,8 +1122,8 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, tools::Rectangle aBoundRect( currentItem.aBounds ); aBoundRect.Intersection( aOutputRect ); - const double fBmpArea( (double) aBoundRect.GetWidth() * aBoundRect.GetHeight() ); - const double fOutArea( (double) aOutputRect.GetWidth() * aOutputRect.GetHeight() ); + const double fBmpArea( static_cast<double>(aBoundRect.GetWidth()) * aBoundRect.GetHeight() ); + const double fOutArea( static_cast<double>(aOutputRect.GetWidth()) * aOutputRect.GetHeight() ); // check if output doesn't exceed given size if( bReduceTransparency && bTransparencyAutoMode && ( fBmpArea > ( 0.25 * fOutArea ) ) ) @@ -1350,13 +1350,13 @@ void Printer::DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, { const Color& rStartColor = rGradient.GetStartColor(); const Color& rEndColor = rGradient.GetEndColor(); - const long nR = ( ( (long) rStartColor.GetRed() * rGradient.GetStartIntensity() ) / 100 + - ( (long) rEndColor.GetRed() * rGradient.GetEndIntensity() ) / 100 ) >> 1; - const long nG = ( ( (long) rStartColor.GetGreen() * rGradient.GetStartIntensity() ) / 100 + - ( (long) rEndColor.GetGreen() * rGradient.GetEndIntensity() ) / 100 ) >> 1; - const long nB = ( ( (long) rStartColor.GetBlue() * rGradient.GetStartIntensity() ) / 100 + - ( (long) rEndColor.GetBlue() * rGradient.GetEndIntensity() ) / 100 ) >> 1; - const Color aColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ); + const long nR = ( ( static_cast<long>(rStartColor.GetRed()) * rGradient.GetStartIntensity() ) / 100 + + ( static_cast<long>(rEndColor.GetRed()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; + const long nG = ( ( static_cast<long>(rStartColor.GetGreen()) * rGradient.GetStartIntensity() ) / 100 + + ( static_cast<long>(rEndColor.GetGreen()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; + const long nB = ( ( static_cast<long>(rStartColor.GetBlue()) * rGradient.GetStartIntensity() ) / 100 + + ( static_cast<long>(rEndColor.GetBlue()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; + const Color aColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); pOut->SetLineColor( aColor ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index b8957ae14eb3..07b65564d6c2 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -92,11 +92,11 @@ std::ostream &operator <<(std::ostream& s, ImplLayoutArgs const &rArgs) if (rArgs.mrStr[i] == '\n') s << "\\n"; else if (rArgs.mrStr[i] < ' ' || (rArgs.mrStr[i] >= 0x7F && rArgs.mrStr[i] <= 0xFF)) - s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << (int) rArgs.mrStr[i] << std::setfill(' ') << std::setw(1) << std::dec; + s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(rArgs.mrStr[i]) << std::setfill(' ') << std::setw(1) << std::dec; else if (rArgs.mrStr[i] < 0x7F) - s << (char) rArgs.mrStr[i]; + s << static_cast<char>(rArgs.mrStr[i]); else - s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) rArgs.mrStr[i] << std::setfill(' ') << std::setw(1) << std::dec; + s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(rArgs.mrStr[i]) << std::setfill(' ') << std::setw(1) << std::dec; } if (nLength > lim) s << "..."; @@ -277,7 +277,7 @@ void ImplLayoutRuns::AddRun( int nCharPos0, int nCharPos1, bool bRTL ) bool ImplLayoutRuns::PosIsInRun( int nCharPos ) const { - if( mnRunIndex >= (int)maRuns.size() ) + if( mnRunIndex >= static_cast<int>(maRuns.size()) ) return false; int nMinCharPos = maRuns[ mnRunIndex+0 ]; @@ -324,7 +324,7 @@ bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft ) mnRunIndex = 0; // return false when all runs completed - if( mnRunIndex >= (int)maRuns.size() ) + if( mnRunIndex >= static_cast<int>(maRuns.size()) ) return false; int nRunPos0 = maRuns[ mnRunIndex+0 ]; @@ -345,7 +345,7 @@ bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft ) // advance to next run if current run is completed if( *nCharPos == nRunPos1 ) { - if( (mnRunIndex += 2) >= (int)maRuns.size() ) + if( (mnRunIndex += 2) >= static_cast<int>(maRuns.size()) ) return false; nRunPos0 = maRuns[ mnRunIndex+0 ]; nRunPos1 = maRuns[ mnRunIndex+1 ]; @@ -363,7 +363,7 @@ bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft ) bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLeft ) const { - if( mnRunIndex >= (int)maRuns.size() ) + if( mnRunIndex >= static_cast<int>(maRuns.size()) ) return false; int nRunPos0 = maRuns[ mnRunIndex+0 ]; @@ -794,13 +794,13 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) else // condensed case { // squeeze width by moving glyphs proportionally - double fSqueeze = (double)nNewWidth / nOldWidth; + double fSqueeze = static_cast<double>(nNewWidth) / nOldWidth; if(m_GlyphItems.size() > 1) { for( pGlyphIter = m_GlyphItems.begin(); ++pGlyphIter != pGlyphIterRight;) { int nX = pGlyphIter->maLinearPos.X() - maBasePoint.X(); - nX = (int)(nX * fSqueeze); + nX = static_cast<int>(nX * fSqueeze); pGlyphIter->maLinearPos.X() = nX + maBasePoint.X(); } } @@ -918,7 +918,7 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, } // return zero if no more glyph found - if( nStart >= (int)m_GlyphItems.size() ) + if( nStart >= static_cast<int>(m_GlyphItems.size()) ) return 0; if( pGlyphIter == pGlyphIterEnd ) @@ -937,7 +937,7 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, *(pGlyphs++) = &(*pGlyphIter); // break at end of glyph list - if( ++nStart >= (int)m_GlyphItems.size() ) + if( ++nStart >= static_cast<int>(m_GlyphItems.size()) ) break; // break when enough glyphs if( nCount >= nLen ) @@ -970,7 +970,7 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) { - if( nStart >= (int)m_GlyphItems.size() ) + if( nStart >= static_cast<int>(m_GlyphItems.size()) ) return; std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(); @@ -995,7 +995,7 @@ void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) void GenericSalLayout::DropGlyph( int nStart ) { - if( nStart >= (int)m_GlyphItems.size()) + if( nStart >= static_cast<int>(m_GlyphItems.size())) return; std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(); @@ -1441,7 +1441,7 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi if( pCharWidths[ i ] == 0 ) { DeviceCoordinate w = pCharWidths[ i + nCharCount ]; - w = (DeviceCoordinate)(w * fUnitMul + 0.5); + w = static_cast<DeviceCoordinate>(w * fUnitMul + 0.5); pCharWidths[ i ] = w; } } @@ -1482,7 +1482,7 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co // merge results from current level double fUnitMul = mnUnitsPerPixel; fUnitMul /= mpLayouts[n]->GetUnitsPerPixel(); - nTextWidth = (DeviceCoordinate)(nTextWidth * fUnitMul + 0.5); + nTextWidth = static_cast<DeviceCoordinate>(nTextWidth * fUnitMul + 0.5); if( nMaxWidth < nTextWidth ) nMaxWidth = nTextWidth; if( !pCharWidths ) @@ -1497,7 +1497,7 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co DeviceCoordinate nCharWidth = pTempWidths[i]; if( !nCharWidth ) continue; - nCharWidth = (DeviceCoordinate)(nCharWidth * fUnitMul + 0.5); + nCharWidth = static_cast<DeviceCoordinate>(nCharWidth * fUnitMul + 0.5); pCharWidths[i] = nCharWidth; } } diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index 174eda36c3a4..6b2b8755e2b7 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -50,9 +50,9 @@ static long ImplIndexFromColor( const BitmapColor& rCol ) { #if TC_TO_PAL_COLORS == 4096 - return( ( ( (long) rCol.GetBlue() >> 4) << 8 ) | - ( ( (long) rCol.GetGreen() >> 4 ) << 4 ) | - ( (long) rCol.GetRed() >> 4 ) ); + return( ( ( static_cast<long>(rCol.GetBlue()) >> 4) << 8 ) | + ( ( static_cast<long>(rCol.GetGreen()) >> 4 ) << 4 ) | + ( static_cast<long>(rCol.GetRed()) >> 4 ) ); #elif TC_TO_PAL_COLORS == 32768 @@ -239,7 +239,7 @@ static void ImplTCToPAL( const BitmapBuffer& rSrcBuffer, BitmapBuffer const & rD BitmapColor aCol( sal::static_int_cast<sal_uInt8>(nR << 4), sal::static_int_cast<sal_uInt8>(nG << 4), sal::static_int_cast<sal_uInt8>(nB << 4) ); - pColToPalMap[ ImplIndexFromColor( aCol ) ] = (sal_uInt8) rDstBuffer.maPalette.GetBestIndex( aCol ); + pColToPalMap[ ImplIndexFromColor( aCol ) ] = static_cast<sal_uInt8>(rDstBuffer.maPalette.GetBestIndex( aCol )); } } } @@ -416,7 +416,7 @@ BitmapBuffer* StretchAndConvert( // horizontal mapping table if( (pDstBuffer->mnWidth != rTwoRect.mnSrcWidth) && (pDstBuffer->mnWidth != 0) ) { - const double fFactorX = (double)rTwoRect.mnSrcWidth / pDstBuffer->mnWidth; + const double fFactorX = static_cast<double>(rTwoRect.mnSrcWidth) / pDstBuffer->mnWidth; for (long i = 0; i < pDstBuffer->mnWidth; ++i) pMapX[ i ] = rTwoRect.mnSrcX + static_cast<int>( i * fFactorX ); @@ -430,7 +430,7 @@ BitmapBuffer* StretchAndConvert( // vertical mapping table if( (pDstBuffer->mnHeight != rTwoRect.mnSrcHeight) && (pDstBuffer->mnHeight != 0) ) { - const double fFactorY = (double)rTwoRect.mnSrcHeight / pDstBuffer->mnHeight; + const double fFactorY = static_cast<double>(rTwoRect.mnSrcHeight) / pDstBuffer->mnHeight; for (long i = 0; i < pDstBuffer->mnHeight; ++i) pMapY[ i ] = rTwoRect.mnSrcY + static_cast<int>( i * fFactorY ); diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx index 2f37550c7e22..4ce92b1d932f 100644 --- a/vcl/source/gdi/svmconverter.cxx +++ b/vcl/source/gdi/svmconverter.cxx @@ -81,7 +81,7 @@ bool ImplReadPolyPoly(SvStream& rIStm, tools::PolyPolygon& rPolyPoly) tools::Polygon aPoly; sal_Int32 nPolyCount32(0); rIStm.ReadInt32(nPolyCount32); - sal_uInt16 nPolyCount = (sal_uInt16)nPolyCount32; + sal_uInt16 nPolyCount = static_cast<sal_uInt16>(nPolyCount32); for (sal_uInt16 i = 0; i < nPolyCount && rIStm.good(); ++i) { @@ -129,22 +129,22 @@ void ImplReadColor( SvStream& rIStm, Color& rColor ) { sal_Int16 nVal(0); - rIStm.ReadInt16( nVal ); rColor.SetRed( sal::static_int_cast<sal_uInt8>((sal_uInt16)nVal >> 8) ); - rIStm.ReadInt16( nVal ); rColor.SetGreen( sal::static_int_cast<sal_uInt8>((sal_uInt16)nVal >> 8) ); - rIStm.ReadInt16( nVal ); rColor.SetBlue( sal::static_int_cast<sal_uInt8>((sal_uInt16)nVal >> 8) ); + rIStm.ReadInt16( nVal ); rColor.SetRed( sal::static_int_cast<sal_uInt8>(static_cast<sal_uInt16>(nVal) >> 8) ); + rIStm.ReadInt16( nVal ); rColor.SetGreen( sal::static_int_cast<sal_uInt8>(static_cast<sal_uInt16>(nVal) >> 8) ); + rIStm.ReadInt16( nVal ); rColor.SetBlue( sal::static_int_cast<sal_uInt8>(static_cast<sal_uInt16>(nVal) >> 8) ); } void ImplWriteColor( SvStream& rOStm, const Color& rColor ) { sal_Int16 nVal; - nVal = ( (sal_Int16) rColor.GetRed() << 8 ) | rColor.GetRed(); + nVal = ( static_cast<sal_Int16>(rColor.GetRed()) << 8 ) | rColor.GetRed(); rOStm.WriteInt16( nVal ); - nVal = ( (sal_Int16) rColor.GetGreen() << 8 ) | rColor.GetGreen(); + nVal = ( static_cast<sal_Int16>(rColor.GetGreen()) << 8 ) | rColor.GetGreen(); rOStm.WriteInt16( nVal ); - nVal = ( (sal_Int16) rColor.GetBlue() << 8 ) | rColor.GetBlue(); + nVal = ( static_cast<sal_Int16>(rColor.GetBlue()) << 8 ) | rColor.GetBlue(); rOStm.WriteInt16( nVal ); } @@ -890,7 +890,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rIStm.ReadCharAsBool(bItalic).ReadCharAsBool(bOutline).ReadCharAsBool(bShadow).ReadCharAsBool(bTransparent); aFont.SetFontSize( Size( nWidth, nHeight ) ); - aFont.SetCharSet( (rtl_TextEncoding) nCharSet ); + aFont.SetCharSet( static_cast<rtl_TextEncoding>(nCharSet) ); aFont.SetFamily( (FontFamily) nFamily ); aFont.SetPitch( (FontPitch) nPitch ); aFont.SetAlignment( (FontAlign) nAlign ); @@ -2376,8 +2376,8 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile const & r GDIMetaFile aMtf( rTransMtf ); const Size aSrcSize( rTransMtf.GetPrefSize() ); Point aSrcPt( rTransMtf.GetPrefMapMode().GetOrigin() ); - const double fScaleX = aSrcSize.Width() ? (double) rSize.Width() / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? (double) rSize.Height() / aSrcSize.Height() : 1.0; + const double fScaleX = aSrcSize.Width() ? static_cast<double>(rSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(rSize.Height()) / aSrcSize.Height() : 1.0; long nMoveX, nMoveY; if( fScaleX != 1.0 || fScaleY != 1.0 ) @@ -2511,7 +2511,7 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile const & r { const MetaTextLineAction* pA = static_cast<const MetaTextLineAction*>(pAction); const Point& rStartPt = pA->GetStartPoint(); - const sal_Int32 nWidth = (sal_Int32) pA->GetWidth(); + const sal_Int32 nWidth = static_cast<sal_Int32>(pA->GetWidth()); const FontStrikeout eStrikeout = pA->GetStrikeout(); const FontLineStyle eUnderline = pA->GetUnderline(); sal_uLong nOldPos, nNewPos; diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx index 8920265af010..9a56f52219da 100644 --- a/vcl/source/helper/canvastools.cxx +++ b/vcl/source/helper/canvastools.cxx @@ -124,10 +124,10 @@ namespace vcl { const rendering::ARGBColor& rColor=aARGBColors[x]; rWriteAcc->SetPixelIndex( aRect.Y1, x, - (sal_uInt8) rWriteAcc->GetBestPaletteIndex( + static_cast<sal_uInt8>(rWriteAcc->GetBestPaletteIndex( BitmapColor( toByteColor(rColor.Red), toByteColor(rColor.Green), - toByteColor(rColor.Blue))) ); + toByteColor(rColor.Blue)))) ); rAlphaAcc->SetPixel( aRect.Y1, x, BitmapColor( 255 - toByteColor(rColor.Alpha) )); } @@ -156,10 +156,10 @@ namespace vcl { const rendering::RGBColor& rColor=aRGBColors[x]; rWriteAcc->SetPixelIndex( aRect.Y1, x, - (sal_uInt8) rWriteAcc->GetBestPaletteIndex( + static_cast<sal_uInt8>(rWriteAcc->GetBestPaletteIndex( BitmapColor( toByteColor(rColor.Red), toByteColor(rColor.Green), - toByteColor(rColor.Blue))) ); + toByteColor(rColor.Blue)))) ); } } else diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 4cdca54b65d8..1eaab88e4747 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -125,7 +125,7 @@ vcl::KeyCode AWTKey2VCLKey(const awt::KeyEvent& aAWTKey) bool bMod1 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD1 ) == awt::KeyModifier::MOD1 ); bool bMod2 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD2 ) == awt::KeyModifier::MOD2 ); bool bMod3 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD3 ) == awt::KeyModifier::MOD3 ); - sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode; + sal_uInt16 nKey = static_cast<sal_uInt16>(aAWTKey.KeyCode); return vcl::KeyCode(nKey, bShift, bMod1, bMod2, bMod3); } diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 24b1c5403057..35c5e8098741 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -755,7 +755,7 @@ private: double fTemp = std::abs((nOffset + i) * fReverseScale); pMap[i] = MinMax(nDstLocation + long(fTemp), 0, nSampleRange); - pMapOffset[i] = (long) ((fTemp - pMap[i]) * 128.0); + pMapOffset[i] = static_cast<long>((fTemp - pMap[i]) * 128.0); } } @@ -1344,8 +1344,8 @@ namespace inline sal_uInt8 CalcColor( const sal_uInt8 nSourceColor, const sal_uInt8 nSourceAlpha, const sal_uInt8 nDstAlpha, const sal_uInt8 nResAlpha, const sal_uInt8 nDestColor ) { - int c = nResAlpha ? ( (int)nSourceAlpha*nSourceColor + (int)nDstAlpha*nDestColor - - (int)nDstAlpha*nDestColor*nSourceAlpha/255 ) / (int)nResAlpha : 0; + int c = nResAlpha ? ( static_cast<int>(nSourceAlpha)*nSourceColor + static_cast<int>(nDstAlpha)*nDestColor - + static_cast<int>(nDstAlpha)*nDestColor*nSourceAlpha/255 ) / static_cast<int>(nResAlpha) : 0; return sal_uInt8( c ); } @@ -1370,7 +1370,7 @@ namespace // Co = Cs + Cd*(1-As) // Ad = As + Ad*(1-As) - nResAlpha = (int)nSrcAlpha + (int)nDstAlpha - (int)nDstAlpha*nSrcAlpha/255; + nResAlpha = static_cast<int>(nSrcAlpha) + static_cast<int>(nDstAlpha) - static_cast<int>(nDstAlpha)*nSrcAlpha/255; aDstCol.SetRed( CalcColor( aSrcCol.GetRed(), nSrcAlpha, nDstAlpha, nResAlpha, aDstCol.GetRed() ) ); aDstCol.SetBlue( CalcColor( aSrcCol.GetBlue(), nSrcAlpha, nDstAlpha, nResAlpha, aDstCol.GetBlue() ) ); @@ -1437,12 +1437,12 @@ Bitmap OutputDevice::BlendBitmapWithAlpha( aDstCol = AlphaBlend( nX, nY, nMapX, nMapY, pP, pA, pB.get(), pAlphaW.get(), nResAlpha ); - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16 ] + nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16 ] ) ); pW->SetPixel( nY, nX, aIndex ); - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] + + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] + nVCLGLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] + nVCLBLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] ) ); pAlphaW->SetPixel( nY, nX, aIndex ); @@ -1534,7 +1534,7 @@ Bitmap OutputDevice::BlendBitmap( aDstCol = pB->GetColor( nY, nX ); aDstCol.Merge( pP->GetColor( nMapY, nMapX ), pA->GetPixelIndex( nMapY, nMapX ) ); - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16 ] + nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16 ] ) ); pW->SetPixel( nY, nX, aIndex ); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 077159bebe83..63841a7cacf3 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -421,7 +421,7 @@ void OutputDevice::ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPo tools::Polygon aPoly( SAL_N_ELEMENTS( aAccentPos ) / 2, reinterpret_cast<const Point*>(aAccentPos), aAccentPolyFlags ); - double dScale = ((double)nDotSize)/1000.0; + double dScale = static_cast<double>(nDotSize)/1000.0; aPoly.Scale( dScale, dScale ); tools::Polygon aTemp; aPoly.AdaptiveSubdivide( aTemp ); @@ -1139,9 +1139,9 @@ bool OutputDevice::ImplNewFont() const if( mbMap && !aSize.Width() ) { int nOrigWidth = pFontInstance->mxFontMetric->GetWidth(); - float fStretch = (float)maMapRes.mnMapScNumX * maMapRes.mnMapScDenomY; - fStretch /= (float)maMapRes.mnMapScNumY * maMapRes.mnMapScDenomX; - int nNewWidth = (int)(nOrigWidth * fStretch + 0.5); + float fStretch = static_cast<float>(maMapRes.mnMapScNumX) * maMapRes.mnMapScDenomY; + fStretch /= static_cast<float>(maMapRes.mnMapScNumY) * maMapRes.mnMapScDenomX; + int nNewWidth = static_cast<int>(nOrigWidth * fStretch + 0.5); if( (nNewWidth != nOrigWidth) && (nNewWidth != 0) ) { Size aOrigSize = maFont.GetFontSize(); @@ -1462,7 +1462,7 @@ bool OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const OUString& rSt rVector.push_back( aRect ); } - return (nLen == (int)rVector.size()); + return (nLen == static_cast<int>(rVector.size())); } sal_Int32 OutputDevice::HasGlyphs( const vcl::Font& rTempFont, const OUString& rStr, diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx index c3fbd24664db..c71b420d92ed 100644 --- a/vcl/source/outdev/gradient.cxx +++ b/vcl/source/outdev/gradient.cxx @@ -256,7 +256,7 @@ namespace else if ( nValue > 0xFF ) return 0xFF; else - return (sal_uInt8)nValue; + return static_cast<sal_uInt8>(nValue); } } @@ -328,13 +328,13 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, tools::Polygon aPoly( 4 ); if (fBorder > 0.0) { - nRed = (sal_uInt8)nStartRed; - nGreen = (sal_uInt8)nStartGreen; - nBlue = (sal_uInt8)nStartBlue; + nRed = static_cast<sal_uInt8>(nStartRed); + nGreen = static_cast<sal_uInt8>(nStartGreen); + nBlue = static_cast<sal_uInt8>(nStartBlue); mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); - aBorderRect.Bottom() = (long)( aBorderRect.Top() + fBorder ); + aBorderRect.Bottom() = static_cast<long>( aBorderRect.Top() + fBorder ); aRect.Top() = aBorderRect.Bottom(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -347,7 +347,7 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, if ( !bLinear) { aBorderRect = aMirrorRect; - aBorderRect.Top() = (long) ( aBorderRect.Bottom() - fBorder ); + aBorderRect.Top() = static_cast<long>( aBorderRect.Bottom() - fBorder ); aMirrorRect.Bottom() = aBorderRect.Top(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -374,11 +374,11 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, nSteps = 3; } - double fScanInc = ((double)aRect.GetHeight()) / (double) nSteps; - double fGradientLine = (double)aRect.Top(); - double fMirrorGradientLine = (double) aMirrorRect.Bottom(); + double fScanInc = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps); + double fGradientLine = static_cast<double>(aRect.Top()); + double fMirrorGradientLine = static_cast<double>(aMirrorRect.Bottom()); - const double fStepsMinus1 = ((double)nSteps) - 1.0; + const double fStepsMinus1 = static_cast<double>(nSteps) - 1.0; if ( !bLinear) { nSteps -= 1; // draw middle polygons as one polygon after loop to avoid gap @@ -386,19 +386,19 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, for ( long i = 0; i < nSteps; i++ ) { // linear interpolation of color - const double fAlpha = ((double)i) / fStepsMinus1; - double fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha; - nRed = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartGreen) * (1.0-fAlpha) + ((double)nEndGreen) * fAlpha; - nGreen = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartBlue) * (1.0-fAlpha) + ((double)nEndBlue) * fAlpha; - nBlue = GetGradientColorValue((long)fTempColor); + const double fAlpha = static_cast<double>(i) / fStepsMinus1; + double fTempColor = static_cast<double>(nStartRed) * (1.0-fAlpha) + static_cast<double>(nEndRed) * fAlpha; + nRed = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartGreen) * (1.0-fAlpha) + static_cast<double>(nEndGreen) * fAlpha; + nGreen = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartBlue) * (1.0-fAlpha) + static_cast<double>(nEndBlue) * fAlpha; + nBlue = GetGradientColorValue(static_cast<long>(fTempColor)); mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); // Polygon for this color step - aRect.Top() = (long)( fGradientLine + ((double) i) * fScanInc ); - aRect.Bottom() = (long)( fGradientLine + ( ((double) i) + 1.0 ) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(i) * fScanInc ); + aRect.Bottom() = static_cast<long>( fGradientLine + ( static_cast<double>(i) + 1.0 ) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -409,8 +409,8 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, if ( !bLinear ) { - aMirrorRect.Bottom() = (long)( fMirrorGradientLine - ((double) i) * fScanInc ); - aMirrorRect.Top() = (long)( fMirrorGradientLine - (((double) i) + 1.0)* fScanInc ); + aMirrorRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(i) * fScanInc ); + aMirrorRect.Top() = static_cast<long>( fMirrorGradientLine - (static_cast<double>(i) + 1.0)* fScanInc ); aPoly[0] = aMirrorRect.TopLeft(); aPoly[1] = aMirrorRect.TopRight(); aPoly[2] = aMirrorRect.BottomRight(); @@ -430,8 +430,8 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); - aRect.Top() = (long)( fGradientLine + ((double)nSteps) * fScanInc ); - aRect.Bottom() = (long)( fMirrorGradientLine - ((double) nSteps) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ); + aRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -465,12 +465,12 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, Point aCenter; Color aStartCol( rGradient.GetStartColor() ); Color aEndCol( rGradient.GetEndColor() ); - long nStartRed = ( (long) aStartCol.GetRed() * rGradient.GetStartIntensity() ) / 100; - long nStartGreen = ( (long) aStartCol.GetGreen() * rGradient.GetStartIntensity() ) / 100; - long nStartBlue = ( (long) aStartCol.GetBlue() * rGradient.GetStartIntensity() ) / 100; - long nEndRed = ( (long) aEndCol.GetRed() * rGradient.GetEndIntensity() ) / 100; - long nEndGreen = ( (long) aEndCol.GetGreen() * rGradient.GetEndIntensity() ) / 100; - long nEndBlue = ( (long) aEndCol.GetBlue() * rGradient.GetEndIntensity() ) / 100; + long nStartRed = ( static_cast<long>(aStartCol.GetRed()) * rGradient.GetStartIntensity() ) / 100; + long nStartGreen = ( static_cast<long>(aStartCol.GetGreen()) * rGradient.GetStartIntensity() ) / 100; + long nStartBlue = ( static_cast<long>(aStartCol.GetBlue()) * rGradient.GetStartIntensity() ) / 100; + long nEndRed = ( static_cast<long>(aEndCol.GetRed()) * rGradient.GetEndIntensity() ) / 100; + long nEndGreen = ( static_cast<long>(aEndCol.GetGreen()) * rGradient.GetEndIntensity() ) / 100; + long nEndBlue = ( static_cast<long>(aEndCol.GetBlue()) * rGradient.GetEndIntensity() ) / 100; long nRedSteps = nEndRed - nStartRed; long nGreenSteps = nEndGreen - nStartGreen; long nBlueSteps = nEndBlue - nStartBlue; @@ -503,8 +503,8 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, double fScanTop = aRect.Top(); double fScanRight = aRect.Right(); double fScanBottom = aRect.Bottom(); - double fScanIncX = (double) aRect.GetWidth() / (double) nSteps * 0.5; - double fScanIncY = (double) aRect.GetHeight() / (double) nSteps * 0.5; + double fScanIncX = static_cast<double>(aRect.GetWidth()) / static_cast<double>(nSteps) * 0.5; + double fScanIncY = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps) * 0.5; // all gradients are rendered as nested rectangles which shrink // equally in each dimension - except for 'square' gradients @@ -514,7 +514,7 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, fScanIncY = std::min( fScanIncY, fScanIncX ); fScanIncX = fScanIncY; } - sal_uInt8 nRed = (sal_uInt8) nStartRed, nGreen = (sal_uInt8) nStartGreen, nBlue = (sal_uInt8) nStartBlue; + sal_uInt8 nRed = static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue = static_cast<sal_uInt8>(nStartBlue); bool bPaintLastPolygon( false ); // #107349# Paint last polygon only if loop has generated any output mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); @@ -541,10 +541,10 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, for( long i = 1; i < nSteps; i++ ) { // calculate new Polygon - aRect.Left() = (long)( fScanLeft += fScanIncX ); - aRect.Top() = (long)( fScanTop += fScanIncY ); - aRect.Right() = (long)( fScanRight -= fScanIncX ); - aRect.Bottom() = (long)( fScanBottom -= fScanIncY ); + aRect.Left() = static_cast<long>( fScanLeft += fScanIncX ); + aRect.Top() = static_cast<long>( fScanTop += fScanIncY ); + aRect.Right() = static_cast<long>( fScanRight -= fScanIncX ); + aRect.Bottom() = static_cast<long>( fScanBottom -= fScanIncY ); if( ( aRect.GetWidth() < 2 ) || ( aRect.GetHeight() < 2 ) ) break; @@ -680,13 +680,13 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, tools::Polygon aPoly( 4 ); if (fBorder > 0.0) { - nRed = (sal_uInt8)nStartRed; - nGreen = (sal_uInt8)nStartGreen; - nBlue = (sal_uInt8)nStartBlue; + nRed = static_cast<sal_uInt8>(nStartRed); + nGreen = static_cast<sal_uInt8>(nStartGreen); + nBlue = static_cast<sal_uInt8>(nStartBlue); mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); - aBorderRect.Bottom() = (long)( aBorderRect.Top() + fBorder ); + aBorderRect.Bottom() = static_cast<long>( aBorderRect.Top() + fBorder ); aRect.Top() = aBorderRect.Bottom(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -699,7 +699,7 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, if ( !bLinear) { aBorderRect = aMirrorRect; - aBorderRect.Top() = (long) ( aBorderRect.Bottom() - fBorder ); + aBorderRect.Top() = static_cast<long>( aBorderRect.Bottom() - fBorder ); aMirrorRect.Bottom() = aBorderRect.Top(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -725,11 +725,11 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, nSteps = 3; } - double fScanInc = ((double)aRect.GetHeight()) / (double) nSteps; - double fGradientLine = (double)aRect.Top(); - double fMirrorGradientLine = (double) aMirrorRect.Bottom(); + double fScanInc = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps); + double fGradientLine = static_cast<double>(aRect.Top()); + double fMirrorGradientLine = static_cast<double>(aMirrorRect.Bottom()); - const double fStepsMinus1 = ((double)nSteps) - 1.0; + const double fStepsMinus1 = static_cast<double>(nSteps) - 1.0; if ( !bLinear) { nSteps -= 1; // draw middle polygons as one polygon after loop to avoid gap @@ -737,19 +737,19 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, for ( long i = 0; i < nSteps; i++ ) { // linear interpolation of color - double fAlpha = ((double)i) / fStepsMinus1; - double fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha; - nRed = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartGreen) * (1.0-fAlpha) + ((double)nEndGreen) * fAlpha; - nGreen = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartBlue) * (1.0-fAlpha) + ((double)nEndBlue) * fAlpha; - nBlue = GetGradientColorValue((long)fTempColor); + double fAlpha = static_cast<double>(i) / fStepsMinus1; + double fTempColor = static_cast<double>(nStartRed) * (1.0-fAlpha) + static_cast<double>(nEndRed) * fAlpha; + nRed = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartGreen) * (1.0-fAlpha) + static_cast<double>(nEndGreen) * fAlpha; + nGreen = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartBlue) * (1.0-fAlpha) + static_cast<double>(nEndBlue) * fAlpha; + nBlue = GetGradientColorValue(static_cast<long>(fTempColor)); mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); // Polygon for this color step - aRect.Top() = (long)( fGradientLine + ((double) i) * fScanInc ); - aRect.Bottom() = (long)( fGradientLine + ( ((double) i) + 1.0 ) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(i) * fScanInc ); + aRect.Bottom() = static_cast<long>( fGradientLine + ( static_cast<double>(i) + 1.0 ) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -760,8 +760,8 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, if ( !bLinear ) { - aMirrorRect.Bottom() = (long)( fMirrorGradientLine - ((double) i) * fScanInc ); - aMirrorRect.Top() = (long)( fMirrorGradientLine - (((double) i) + 1.0)* fScanInc ); + aMirrorRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(i) * fScanInc ); + aMirrorRect.Top() = static_cast<long>( fMirrorGradientLine - (static_cast<double>(i) + 1.0)* fScanInc ); aPoly[0] = aMirrorRect.TopLeft(); aPoly[1] = aMirrorRect.TopRight(); aPoly[2] = aMirrorRect.BottomRight(); @@ -781,8 +781,8 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); - aRect.Top() = (long)( fGradientLine + ((double)nSteps) * fScanInc ); - aRect.Bottom() = (long)( fMirrorGradientLine - ((double) nSteps) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ); + aRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -809,12 +809,12 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, Point aCenter; Color aStartCol( rGradient.GetStartColor() ); Color aEndCol( rGradient.GetEndColor() ); - long nStartRed = ( (long) aStartCol.GetRed() * rGradient.GetStartIntensity() ) / 100; - long nStartGreen = ( (long) aStartCol.GetGreen() * rGradient.GetStartIntensity() ) / 100; - long nStartBlue = ( (long) aStartCol.GetBlue() * rGradient.GetStartIntensity() ) / 100; - long nEndRed = ( (long) aEndCol.GetRed() * rGradient.GetEndIntensity() ) / 100; - long nEndGreen = ( (long) aEndCol.GetGreen() * rGradient.GetEndIntensity() ) / 100; - long nEndBlue = ( (long) aEndCol.GetBlue() * rGradient.GetEndIntensity() ) / 100; + long nStartRed = ( static_cast<long>(aStartCol.GetRed()) * rGradient.GetStartIntensity() ) / 100; + long nStartGreen = ( static_cast<long>(aStartCol.GetGreen()) * rGradient.GetStartIntensity() ) / 100; + long nStartBlue = ( static_cast<long>(aStartCol.GetBlue()) * rGradient.GetStartIntensity() ) / 100; + long nEndRed = ( static_cast<long>(aEndCol.GetRed()) * rGradient.GetEndIntensity() ) / 100; + long nEndGreen = ( static_cast<long>(aEndCol.GetGreen()) * rGradient.GetEndIntensity() ) / 100; + long nEndBlue = ( static_cast<long>(aEndCol.GetBlue()) * rGradient.GetEndIntensity() ) / 100; long nRedSteps = nEndRed - nStartRed; long nGreenSteps = nEndGreen - nStartGreen; long nBlueSteps = nEndBlue - nStartBlue; @@ -847,8 +847,8 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, double fScanTop = aRect.Top(); double fScanRight = aRect.Right(); double fScanBottom = aRect.Bottom(); - double fScanIncX = (double) aRect.GetWidth() / (double) nSteps * 0.5; - double fScanIncY = (double) aRect.GetHeight() / (double) nSteps * 0.5; + double fScanIncX = static_cast<double>(aRect.GetWidth()) / static_cast<double>(nSteps) * 0.5; + double fScanIncY = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps) * 0.5; // all gradients are rendered as nested rectangles which shrink // equally in each dimension - except for 'square' gradients @@ -858,7 +858,7 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, fScanIncY = std::min( fScanIncY, fScanIncX ); fScanIncX = fScanIncY; } - sal_uInt8 nRed = (sal_uInt8) nStartRed, nGreen = (sal_uInt8) nStartGreen, nBlue = (sal_uInt8) nStartBlue; + sal_uInt8 nRed = static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue = static_cast<sal_uInt8>(nStartBlue); bool bPaintLastPolygon( false ); // #107349# Paint last polygon only if loop has generated any output mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); @@ -870,10 +870,10 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, for( long i = 1; i < nSteps; i++ ) { // calculate new Polygon - aRect.Left() = (long)( fScanLeft += fScanIncX ); - aRect.Top() = (long)( fScanTop += fScanIncY ); - aRect.Right() = (long)( fScanRight -= fScanIncX ); - aRect.Bottom() = (long)( fScanBottom -= fScanIncY ); + aRect.Left() = static_cast<long>( fScanLeft += fScanIncX ); + aRect.Top() = static_cast<long>( fScanTop += fScanIncY ); + aRect.Right() = static_cast<long>( fScanRight -= fScanIncX ); + aRect.Bottom() = static_cast<long>( fScanBottom -= fScanIncY ); if( ( aRect.GetWidth() < 2 ) || ( aRect.GetHeight() < 2 ) ) break; diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx index 46edae35f790..125672e023b2 100644 --- a/vcl/source/outdev/hatch.cxx +++ b/vcl/source/outdev/hatch.cxx @@ -332,7 +332,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol for( long nPoly = 0, nPolyCount = rPolyPoly.Count(); nPoly < nPolyCount; nPoly++ ) { - const tools::Polygon& rPoly = rPolyPoly[ (sal_uInt16) nPoly ]; + const tools::Polygon& rPoly = rPolyPoly[ static_cast<sal_uInt16>(nPoly) ]; if( rPoly.GetSize() > 1 ) { @@ -340,7 +340,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol for( long i = 1, nCount = rPoly.GetSize(); i <= nCount; i++ ) { - aCurSegment.SetEnd( rPoly[ (sal_uInt16)( i % nCount ) ] ); + aCurSegment.SetEnd( rPoly[ static_cast<sal_uInt16>( i % nCount ) ] ); nAdd = 0; if( rLine.Intersection( aCurSegment, fX, fY ) ) @@ -348,7 +348,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol if( ( fabs( fX - aCurSegment.GetStart().X() ) <= 0.0000001 ) && ( fabs( fY - aCurSegment.GetStart().Y() ) <= 0.0000001 ) ) { - const tools::Line aPrevSegment( rPoly[ (sal_uInt16)( ( i > 1 ) ? ( i - 2 ) : ( nCount - 1 ) ) ], aCurSegment.GetStart() ); + const tools::Line aPrevSegment( rPoly[ static_cast<sal_uInt16>( ( i > 1 ) ? ( i - 2 ) : ( nCount - 1 ) ) ], aCurSegment.GetStart() ); const double fPrevDistance = rLine.GetDistance( aPrevSegment.GetStart() ); const double fCurDistance = rLine.GetDistance( aCurSegment.GetEnd() ); @@ -361,7 +361,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol else if( ( fabs( fX - aCurSegment.GetEnd().X() ) <= 0.0000001 ) && ( fabs( fY - aCurSegment.GetEnd().Y() ) <= 0.0000001 ) ) { - const tools::Line aNextSegment( aCurSegment.GetEnd(), rPoly[ (sal_uInt16)( ( i + 1 ) % nCount ) ] ); + const tools::Line aNextSegment( aCurSegment.GetEnd(), rPoly[ static_cast<sal_uInt16>( ( i + 1 ) % nCount ) ] ); if( ( fabs( rLine.GetDistance( aNextSegment.GetEnd() ) ) <= 0.0000001 ) && ( rLine.GetDistance( aCurSegment.GetStart() ) > 0.0 ) ) diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index b3fffe55a077..9df906196581 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -108,9 +108,9 @@ static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY, if ( !nDenomX ) rThresRes.mnThresPixToLogX = LONG_MAX; else if ( nProductX >= 0 ) - rThresRes.mnThresPixToLogX = (long)(((sal_uLong)LONG_MAX - (sal_uLong)( nProductX/2)) / nDenomX); + rThresRes.mnThresPixToLogX = static_cast<long>((sal_uLong(LONG_MAX) - static_cast<sal_uLong>( nProductX/2)) / nDenomX); else - rThresRes.mnThresPixToLogX = (long)(((sal_uLong)LONG_MAX + (sal_uLong)(-nProductX/2)) / nDenomX); + rThresRes.mnThresPixToLogX = static_cast<long>((sal_uLong(LONG_MAX) + static_cast<sal_uLong>(-nProductX/2)) / nDenomX); } if ( nDPIY && (LONG_MAX / nDPIY < std::abs( rMapRes.mnMapScNumY ) ) ) // #111139# avoid div by zero @@ -133,9 +133,9 @@ static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY, if ( !nDenomY ) rThresRes.mnThresPixToLogY = LONG_MAX; else if ( nProductY >= 0 ) - rThresRes.mnThresPixToLogY = (long)(((sal_uLong)LONG_MAX - (sal_uLong)( nProductY/2)) / nDenomY); + rThresRes.mnThresPixToLogY = static_cast<long>((sal_uLong(LONG_MAX) - static_cast<sal_uLong>( nProductY/2)) / nDenomY); else - rThresRes.mnThresPixToLogY = (long)(((sal_uLong)LONG_MAX + (sal_uLong)(-nProductY/2)) / nDenomY); + rThresRes.mnThresPixToLogY = static_cast<long>((sal_uLong(LONG_MAX) + static_cast<sal_uLong>(-nProductY/2)) / nDenomY); } rThresRes.mnThresLogToPixX /= 2; @@ -275,7 +275,7 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, aX += BigInt(nXNumerator / 2); } aX /= BigInt(nXNumerator); - rMapRes.mnMapOfsX = (long)aX + aOrigin.X(); + rMapRes.mnMapOfsX = static_cast<long>(aX) + aOrigin.X(); BigInt aY( rMapRes.mnMapOfsY ); aY *= BigInt( aScaleY.GetDenominator() ); if( rMapRes.mnMapOfsY >= 0 ) @@ -293,7 +293,7 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, aY += BigInt(nYNumerator / 2); } aY /= BigInt(nYNumerator); - rMapRes.mnMapOfsY = (long)aY + aOrigin.Y(); + rMapRes.mnMapOfsY = static_cast<long>(aY) + aOrigin.Y(); } // calculate scaling factor according to MapMode @@ -366,10 +366,10 @@ static long ImplLogicToPixel( long n, long nDPI, long nMapNum, long nMapDenom, n64 *= nMapNum; n64 *= nDPI; if( nMapDenom == 1 ) - n = (long)n64; + n = static_cast<long>(n64); else { - n = (long)(2 * n64 / nMapDenom); + n = static_cast<long>(2 * n64 / nMapDenom); if( n < 0 ) --n; else ++n; n /= 2; } @@ -397,7 +397,7 @@ static long ImplPixelToLogic( long n, long nDPI, long nMapNum, long nMapDenom, { sal_Int64 n64 = n; n64 *= nMapDenom; - n = (long)(2 * n64 / nDenom); + n = static_cast<long>(2 * n64 / nDenom); } if( n < 0 ) --n; else ++n; return (n / 2); @@ -858,10 +858,10 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const { mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix; - const double fScaleFactorX((double)mnDPIX * (double)maMapRes.mnMapScNumX / (double)maMapRes.mnMapScDenomX); - const double fScaleFactorY((double)mnDPIY * (double)maMapRes.mnMapScNumY / (double)maMapRes.mnMapScDenomY); - const double fZeroPointX(((double)maMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); - const double fZeroPointY(((double)maMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); + const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(maMapRes.mnMapScNumX) / static_cast<double>(maMapRes.mnMapScDenomX)); + const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(maMapRes.mnMapScNumY) / static_cast<double>(maMapRes.mnMapScDenomY)); + const double fZeroPointX((static_cast<double>(maMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX)); + const double fZeroPointY((static_cast<double>(maMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY)); mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX); mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY); @@ -907,10 +907,10 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation( const MapMode& rMapMo basegfx::B2DHomMatrix aTransform; - const double fScaleFactorX((double)mnDPIX * (double)aMapRes.mnMapScNumX / (double)aMapRes.mnMapScDenomX); - const double fScaleFactorY((double)mnDPIY * (double)aMapRes.mnMapScNumY / (double)aMapRes.mnMapScDenomY); - const double fZeroPointX(((double)aMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); - const double fZeroPointY(((double)aMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); + const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(aMapRes.mnMapScNumX) / static_cast<double>(aMapRes.mnMapScDenomX)); + const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(aMapRes.mnMapScNumY) / static_cast<double>(aMapRes.mnMapScDenomY)); + const double fZeroPointX((static_cast<double>(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX)); + const double fZeroPointY((static_cast<double>(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY)); aTransform.set(0, 0, fScaleFactorX); aTransform.set(1, 1, fScaleFactorY); @@ -1563,7 +1563,7 @@ static long fn5( const long n1, a7 /= n8; } // of else - return (long)a7; + return static_cast<long>(a7); } // of if else { @@ -1599,7 +1599,7 @@ static long fn5( const long n1, a7 /= n8; } // of else - return (long)a7; + return static_cast<long>(a7); } // of if else { @@ -1619,7 +1619,7 @@ static long fn5( const long n1, a7 += a9; a7 /= a8; - return (long)a7; + return static_cast<long>(a7); } // of if else { @@ -1656,7 +1656,7 @@ static long fn3( const long n1, const long n2, const long n3 ) a4 += n3 / 2; a4 /= n3; - return (long)a4; + return static_cast<long>(a4); } // of if else { @@ -1826,7 +1826,7 @@ basegfx::B2DHomMatrix OutputDevice::LogicToLogic(const MapMode& rMapModeSource, { ENTER3(eUnitSource, eUnitDest); - const double fScaleFactor((double)nNumerator / (double)nDenominator); + const double fScaleFactor(static_cast<double>(nNumerator) / static_cast<double>(nDenominator)); aTransform.set(0, 0, fScaleFactor); aTransform.set(1, 1, fScaleFactor); } @@ -1923,7 +1923,7 @@ void OutputDevice::SetPixelOffset( const Size& rOffset ) DeviceCoordinate OutputDevice::LogicWidthToDeviceCoordinate( long nWidth ) const { if ( !mbMap ) - return (DeviceCoordinate)nWidth; + return static_cast<DeviceCoordinate>(nWidth); #if VCL_FLOAT_DEVICE_PIXEL return (double)nWidth * maMapRes.mfScaleX * mnDPIX; diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 5066c3b87071..67b2afc471c9 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -382,7 +382,7 @@ sal_uLong OutputDevice::GetColorCount() const { const sal_uInt16 nBitCount = GetBitCount(); - return( ( nBitCount > 31 ) ? ULONG_MAX : ( ( (sal_uLong) 1 ) << nBitCount) ); + return( ( nBitCount > 31 ) ? ULONG_MAX : ( ( sal_uLong(1) ) << nBitCount) ); } css::uno::Reference< css::awt::XGraphics > OutputDevice::CreateUnoGraphics() diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index ace13e036c86..91d051999258 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -363,8 +363,8 @@ BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ) } else { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast<double>( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast<double>( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); @@ -404,8 +404,8 @@ void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect } else { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast<double>( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast<double>( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index aa2d59cca441..e6426fc24278 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1286,7 +1286,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, mpFontInstance->mpConversion->RecodeString( aStr, 0, aStr.getLength() ); pLayoutCache = nullptr; // don't use cache with modified string! } - DeviceCoordinate nPixelWidth = (DeviceCoordinate)nLogicalWidth; + DeviceCoordinate nPixelWidth = static_cast<DeviceCoordinate>(nLogicalWidth); std::unique_ptr<DeviceCoordinate[]> xDXPixelArray; DeviceCoordinate* pDXPixelArray(nullptr); if( nLogicalWidth && mbMap ) @@ -1554,7 +1554,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta if ( nTextHeight ) { long nMaxTextWidth = ImplGetTextLines( aMultiLineInfo, nWidth, aStr, nStyle, _rLayout ); - nLines = (sal_Int32)(nHeight/nTextHeight); + nLines = static_cast<sal_Int32>(nHeight/nTextHeight); nFormatLines = aMultiLineInfo.Count(); if (nLines <= 0) nLines = 1; @@ -1847,7 +1847,7 @@ tools::Rectangle OutputDevice::GetTextRect( const tools::Rectangle& rRect, nFormatLines = aMultiLineInfo.Count(); if ( !nTextHeight ) nTextHeight = 1; - nLines = (sal_uInt16)(aRect.GetHeight()/nTextHeight); + nLines = static_cast<sal_uInt16>(aRect.GetHeight()/nTextHeight); if ( pInfo ) pInfo->mnLineCount = nFormatLines; if ( !nLines ) @@ -2147,7 +2147,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr, /*sal_Bool bRet =*/ GetCaretPositions( aStr, pCaretXArray.get(), nIndex, nLen ); long lc_x1 = pCaretXArray[ 2*(nMnemonicPos - nIndex) ]; long lc_x2 = pCaretXArray[ 2*(nMnemonicPos - nIndex)+1 ]; - nMnemonicWidth = ::abs((int)(lc_x1 - lc_x2)); + nMnemonicWidth = ::abs(static_cast<int>(lc_x1 - lc_x2)); Point aTempPos( std::min(lc_x1,lc_x2), GetFontMetric().GetAscent() ); if( bInvalidPos ) // #106952#, place behind the (last) character @@ -2235,7 +2235,7 @@ long OutputDevice::GetCtrlTextWidth( const OUString& rStr ) const { if ( nMnemonicPos < nIndex ) nIndex--; - else if ( (nMnemonicPos >= nIndex) && ((sal_uLong)nMnemonicPos < (sal_uLong)(nIndex+nLen)) ) + else if ( (nMnemonicPos >= nIndex) && (static_cast<sal_uLong>(nMnemonicPos) < static_cast<sal_uLong>(nIndex+nLen)) ) nLen--; } return GetTextWidth( aStr, nIndex, nLen ); diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index e781a8a9a76e..862d979e020f 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -1006,7 +1006,7 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos ) long nDX = nEndX - nStartX; double nO = atan2( -nEndY + nStartY, ((nDX == 0) ? 0.000000001 : nDX) ); nO /= F_PI1800; - nOrientation = (short)nO; + nOrientation = static_cast<short>(nO); aStartPt.RotateAround( nEndX, nEndY, -nOrientation ); } diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 764389dcbe78..2ad9618ab216 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -182,10 +182,10 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask // create forward mapping tables for( nX = 0; nX <= nSrcWidth; nX++ ) - pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth ); + pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth ); for( nY = 0; nY <= nSrcHeight; nY++ ) - pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight ); + pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight ); // walk through all rectangles of mask const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel()))); @@ -448,7 +448,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, { ScopedVclPtrInstance< VirtualDevice > aVDev(*this, DeviceFormat::BITMASK); const Size aDstSz( aDstRect.GetSize() ); - const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); + const sal_uInt8 cTrans = static_cast<sal_uInt8>(MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 )); if( aDstRect.Left() || aDstRect.Top() ) aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() ); @@ -493,7 +493,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, for( sal_uInt16 i = 0; i < nCount; i++ ) { BitmapColor aCol( rPal[ i ] ); - pMap[ i ] = BitmapColor( (sal_uInt8) rPal.GetBestIndex( aCol.Merge( aFillCol, cTrans ) ) ); + pMap[ i ] = BitmapColor( static_cast<sal_uInt8>(rPal.GetBestIndex( aCol.Merge( aFillCol, cTrans ) )) ); } if( pR->GetScanlineFormat() == ScanlineFormat::N1BitMsbPal && diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx index 801f69af0cd5..d81ea72838ea 100644 --- a/vcl/source/window/accel.cxx +++ b/vcl/source/window/accel.cxx @@ -28,7 +28,7 @@ typedef ::std::map< sal_uLong, ImplAccelEntry* > ImplAccelMap; typedef ::std::vector< ImplAccelEntry* > ImplAccelList; -#define ACCELENTRY_NOTFOUND ((sal_uInt16)0xFFFF) +#define ACCELENTRY_NOTFOUND (sal_uInt16(0xFFFF)) class ImplAccelData { @@ -68,7 +68,7 @@ sal_uInt16 ImplAccelEntryGetIndex( ImplAccelList* pList, sal_uInt16 nId, if ( nId > nCompareId ) nLow = nMid + 1; else - return (sal_uInt16)nMid; + return static_cast<sal_uInt16>(nMid); } } while ( nLow <= nHigh ); @@ -76,9 +76,9 @@ sal_uInt16 ImplAccelEntryGetIndex( ImplAccelList* pList, sal_uInt16 nId, if ( pIndex ) { if ( nId > nCompareId ) - *pIndex = (sal_uInt16)(nMid+1); + *pIndex = static_cast<sal_uInt16>(nMid+1); else - *pIndex = (sal_uInt16)nMid; + *pIndex = static_cast<sal_uInt16>(nMid); } return ACCELENTRY_NOTFOUND; @@ -262,7 +262,7 @@ void Accelerator::InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ) sal_uInt16 Accelerator::GetItemCount() const { - return (sal_uInt16)mpData->maIdList.size(); + return static_cast<sal_uInt16>(mpData->maIdList.size()); } sal_uInt16 Accelerator::GetItemId( sal_uInt16 nPos ) const diff --git a/vcl/source/window/debugevent.cxx b/vcl/source/window/debugevent.cxx index ba8cc2f1a8c2..59889e3720a0 100644 --- a/vcl/source/window/debugevent.cxx +++ b/vcl/source/window/debugevent.cxx @@ -103,7 +103,7 @@ void DebugEventInjector::InjectMenuEvent() std::vector< SalMenuEvent > aIds; CollectMenuItemIds( pMenuBar, aIds ); - SalEvent nEvent = nEvents[ (int)(getRandom() * SAL_N_ELEMENTS( nEvents )) ]; + SalEvent nEvent = nEvents[ static_cast<int>(getRandom() * SAL_N_ELEMENTS( nEvents )) ]; SalMenuEvent aEvent = aIds[ getRandom() * aIds.size() ]; bool bHandled = ImplWindowFrameProc( pSysWin, nEvent, &aEvent); @@ -153,12 +153,12 @@ void DebugEventInjector::InjectTextEvent() } if( getRandom() < 0.05 ) // modifier - aKeyEvent.mnCode |= (sal_uInt16)( getRandom() * KEY_MODIFIERS_MASK ) & KEY_MODIFIERS_MASK; + aKeyEvent.mnCode |= static_cast<sal_uInt16>( getRandom() * KEY_MODIFIERS_MASK ) & KEY_MODIFIERS_MASK; bool bHandled = ImplWindowFrameProc( pWindow, SalEvent::KeyInput, &aKeyEvent); SAL_INFO( "vcl.debugevent", - "Injected key 0x" << std::hex << (int) aKeyEvent.mnCode << std::dec + "Injected key 0x" << std::hex << static_cast<int>(aKeyEvent.mnCode) << std::dec << " -> " << bHandled << " win " << pWindow ); @@ -233,14 +233,14 @@ void DebugEventInjector::InjectKeyNavEdit() aKeyEvent.mnCode = nKey; if (getRandom() < 0.15) // modifier - aKeyEvent.mnCode |= (sal_uInt16)(getRandom() * KEY_MODIFIERS_MASK) & KEY_MODIFIERS_MASK; + aKeyEvent.mnCode |= static_cast<sal_uInt16>(getRandom() * KEY_MODIFIERS_MASK) & KEY_MODIFIERS_MASK; aKeyEvent.mnCharCode = 0x0; // hopefully unused. bool bHandled = ImplWindowFrameProc( pWindow, SalEvent::KeyInput, &aKeyEvent ); SAL_INFO( "vcl.debugevent", - "Injected edit / move key 0x" << std::hex << (int) aKeyEvent.mnCode << std::dec + "Injected edit / move key 0x" << std::hex << static_cast<int>(aKeyEvent.mnCode) << std::dec << " -> " << bHandled << " win " << pWindow ); ImplWindowFrameProc( pWindow, SalEvent::KeyUp, &aKeyEvent ); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index c247a9e50301..abd858860758 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -945,7 +945,7 @@ short Dialog::Execute() long nRet = mpDialogImpl->mnResult; mpDialogImpl->mnResult = -1; - return (short)nRet; + return static_cast<short>(nRet); #else diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 368008bb91d6..7079cd01a79b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -606,7 +606,7 @@ void Menu::Clear() sal_uInt16 Menu::GetItemCount() const { - return (sal_uInt16)pItemList->size(); + return static_cast<sal_uInt16>(pItemList->size()); } sal_uInt16 Menu::ImplGetVisibleItemCount() const @@ -677,7 +677,7 @@ sal_uInt16 Menu::GetItemPos( sal_uInt16 nItemId ) const MenuItemData* pData = pItemList->GetData( nItemId, nPos ); if ( pData ) - return (sal_uInt16)nPos; + return static_cast<sal_uInt16>(nPos); else return MENU_ITEM_NOTFOUND; } @@ -1585,15 +1585,15 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) if( nMaxWidth > nScreenWidth/2 ) nMaxWidth = nScreenWidth/2; - sal_uInt16 gfxExtra = (sal_uInt16) std::max( nExtra, 7L ); // #107710# increase space between checkmarks/images/text - nImgOrChkPos = (sal_uInt16)nExtra; + sal_uInt16 gfxExtra = static_cast<sal_uInt16>(std::max( nExtra, 7L )); // #107710# increase space between checkmarks/images/text + nImgOrChkPos = static_cast<sal_uInt16>(nExtra); long nImgOrChkWidth = 0; if( aMaxSize.Height() > 0 ) // NWF case nImgOrChkWidth = aMaxSize.Height() + nExtra; else // non NWF case nImgOrChkWidth = nFontHeight/2 + gfxExtra; nImgOrChkWidth = std::max( nImgOrChkWidth, aMaxImgSz.Width() + gfxExtra ); - nTextPos = (sal_uInt16)(nImgOrChkPos + nImgOrChkWidth); + nTextPos = static_cast<sal_uInt16>(nImgOrChkPos + nImgOrChkWidth); nTextPos = nTextPos + gfxExtra; aSz.Width() = nTextPos + nMaxWidth + nExtra; @@ -1604,7 +1604,7 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) } else { - nTextPos = (sal_uInt16)(2*nExtra); + nTextPos = static_cast<sal_uInt16>(2*nExtra); aSz.Height() = nFontHeight+6; // get menubar height from native methods if supported @@ -3047,7 +3047,7 @@ long PopupMenu::ImplCalcHeight( sal_uInt16 nEntries ) const sal_uInt16 nFound = 0; for ( size_t n = 0; ( nFound < nEntries ) && ( n < pItemList->size() ); n++ ) { - if ( ImplIsVisible( (sal_uInt16) n ) ) + if ( ImplIsVisible( static_cast<sal_uInt16>(n) ) ) { MenuItemData* pData = pItemList->GetDataFromPos( n ); nHeight += pData->aSz.Height(); diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index cb14f3fba94f..09e176930b96 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -782,7 +782,7 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) sal_uInt16 nLoop = n; if( nCode == KEY_HOME ) - { n = (sal_uInt16)-1; nLoop = n+1; } + { n = sal_uInt16(-1); nLoop = n+1; } if( nCode == KEY_END ) { n = pMenu->GetItemCount(); nLoop = n-1; } @@ -996,7 +996,7 @@ sal_uInt16 MenuBarWindow::ImplFindEntry( const Point& rMousePos ) const { nX += pData->aSz.Width(); if ( nX > rMousePos.X() ) - return (sal_uInt16)n; + return static_cast<sal_uInt16>(n); } } } diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index c66510cf8f1a..b019906f3b0c 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -229,7 +229,7 @@ void MenuFloatingWindow::ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDow { if ( n != nHighlightedItem ) { - ChangeHighlightItem( (sal_uInt16)n, false ); + ChangeHighlightItem( static_cast<sal_uInt16>(n), false ); } bool bAllowNewPopup = true; @@ -250,7 +250,7 @@ void MenuFloatingWindow::ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDow { if ( n != nHighlightedItem ) { - ChangeHighlightItem( (sal_uInt16)n, true ); + ChangeHighlightItem( static_cast<sal_uInt16>(n), true ); } else if ( pItemData->nBits & MenuItemBits::POPUPSELECT ) { @@ -388,7 +388,7 @@ IMPL_LINK( MenuFloatingWindow, ShowHideListener, VclWindowEvent&, rEvent, void ) void MenuFloatingWindow::EnableScrollMenu( bool b ) { bScrollMenu = b; - nScrollerHeight = b ? (sal_uInt16) GetSettings().GetStyleSettings().GetScrollBarSize() /2 : 0; + nScrollerHeight = b ? static_cast<sal_uInt16>(GetSettings().GetStyleSettings().GetScrollBarSize()) /2 : 0; bScrollDown = true; InitMenuClipRegion(*this); } @@ -941,7 +941,7 @@ void MenuFloatingWindow::ImplCursorUpDown( bool bUp, bool bHomeEnd ) } else { - n = (sal_uInt16)-1; + n = sal_uInt16(-1); nLoop = n+1; } } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index b3f2639d9251..c7361e03094c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -147,7 +147,7 @@ void PrintDialog::PrintPreviewWindow::Resize() // quality of the preview, e.g. when its height approaches the number of text lines // find a good scaling factor - double aAspectRatio = aScaledSize.Height() / (double) aScaledSize.Width(); + double aAspectRatio = aScaledSize.Height() / static_cast<double>(aScaledSize.Width()); aScaledSize.Width() = PREVIEW_BITMAP_WIDTH; aScaledSize.Height() = PREVIEW_BITMAP_WIDTH * aAspectRatio; diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx index 7077b800db3a..b256c263204c 100644 --- a/vcl/source/window/scrwnd.cxx +++ b/vcl/source/window/scrwnd.cxx @@ -54,7 +54,7 @@ ImplWheelWindow::ImplWheelWindow( vcl::Window* pParent ) : const bool bVert( nFlags & StartAutoScrollFlags::Vert ); // calculate maximum speed distance - mnMaxWidth = (sal_uLong) ( 0.4 * hypot( (double) aSize.Width(), aSize.Height() ) ); + mnMaxWidth = static_cast<sal_uLong>( 0.4 * hypot( static_cast<double>(aSize.Width()), aSize.Height() ) ); // create wheel window SetTitleType( FloatWinTitleType::NONE ); @@ -193,8 +193,8 @@ void ImplWheelWindow::ImplRecalcScrollValues() // calc current time if( mnMaxWidth ) { - const double fExp = ( (double) mnActDist / mnMaxWidth ) * log10( (double) MAX_TIME / MIN_TIME ); - nCurTime = (sal_uInt64) ( MAX_TIME / pow( 10., fExp ) ); + const double fExp = ( static_cast<double>(mnActDist) / mnMaxWidth ) * log10( double(MAX_TIME) / MIN_TIME ); + nCurTime = static_cast<sal_uInt64>( MAX_TIME / pow( 10., fExp ) ); } else nCurTime = MAX_TIME; @@ -213,22 +213,22 @@ void ImplWheelWindow::ImplRecalcScrollValues() else mnTimeout = ++nMult * nCurTime - mnRepaintTime; - double fValX = (double) mnActDeltaX * nMult; - double fValY = (double) mnActDeltaY * nMult; + double fValX = static_cast<double>(mnActDeltaX) * nMult; + double fValY = static_cast<double>(mnActDeltaY) * nMult; if( fValX > LONG_MAX ) mnActDeltaX = LONG_MAX; else if( fValX < LONG_MIN ) mnActDeltaX = LONG_MIN; else - mnActDeltaX = (long) fValX; + mnActDeltaX = static_cast<long>(fValX); if( fValY > LONG_MAX ) mnActDeltaY = LONG_MAX; else if( fValY < LONG_MIN ) mnActDeltaY = LONG_MIN; else - mnActDeltaY = (long) fValY; + mnActDeltaY = static_cast<long>(fValY); } } } @@ -253,7 +253,7 @@ PointerStyle ImplWheelWindow::ImplGetMousePointer( long nDistX, long nDistY ) } else { - double fAngle = atan2( (double) -nDistY, nDistX ) / F_PI180; + double fAngle = atan2( static_cast<double>(-nDistY), nDistX ) / F_PI180; if( fAngle < 0.0 ) fAngle += 360.; @@ -312,7 +312,7 @@ void ImplWheelWindow::MouseMove( const MouseEvent& rMEvt ) const long nDistX = aMousePos.X() - maCenter.X(); const long nDistY = aMousePos.Y() - maCenter.Y(); - mnActDist = (sal_uLong) hypot( (double) nDistX, nDistY ); + mnActDist = static_cast<sal_uLong>(hypot( static_cast<double>(nDistX), nDistY )); const PointerStyle eActStyle = ImplGetMousePointer( nDistX, nDistY ); const StartAutoScrollFlags nFlags = ImplGetSVData()->maWinData.mnAutoScrollFlags; @@ -376,7 +376,7 @@ IMPL_LINK_NOARG(ImplWheelWindow, ImplScrollHdl, Timer *, void) pWindow->Command( aCEvt ); if( xWin->IsDisposed() ) return; - mnRepaintTime = std::max( tools::Time::GetSystemTicks() - nTime, (sal_uInt64)1 ); + mnRepaintTime = std::max( tools::Time::GetSystemTicks() - nTime, sal_uInt64(1) ); ImplRecalcScrollValues(); } } diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx index e3607daf7b31..23b11f52ffe4 100644 --- a/vcl/source/window/splitwin.cxx +++ b/vcl/source/window/splitwin.cxx @@ -42,10 +42,10 @@ #define SPLITWIN_SPLITSIZEAUTOHIDE 72 #define SPLITWIN_SPLITSIZEFADE 72 -#define SPLIT_HORZ ((sal_uInt16)0x0001) -#define SPLIT_VERT ((sal_uInt16)0x0002) -#define SPLIT_WINDOW ((sal_uInt16)0x0004) -#define SPLIT_NOSPLIT ((sal_uInt16)0x8000) +#define SPLIT_HORZ (sal_uInt16(0x0001)) +#define SPLIT_VERT (sal_uInt16(0x0002)) +#define SPLIT_WINDOW (sal_uInt16(0x0004)) +#define SPLIT_NOSPLIT (sal_uInt16(0x8000)) class ImplSplitItem { @@ -524,7 +524,7 @@ static void ImplCalcSet( ImplSplitSet* pSet, } } // do not compensate rounding errors here - if ( (nAbsItems < (sal_uInt16)(std::abs( nSizeDelta ))) && nSizeWinSize ) + if ( (nAbsItems < static_cast<sal_uInt16>(std::abs( nSizeDelta ))) && nSizeWinSize ) { long nNewSizeWinSize = 0; diff --git a/vcl/source/window/stacking.cxx b/vcl/source/window/stacking.cxx index a3a238ee2c7c..eacf642fd4dd 100644 --- a/vcl/source/window/stacking.cxx +++ b/vcl/source/window/stacking.cxx @@ -625,7 +625,7 @@ bool Window::IsTopWindow() const return false; ImplGetWinData(); - if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0) // still uninitialized + if( mpWindowImpl->mpWinData->mnIsTopWindow == sal_uInt16(~0)) // still uninitialized { // #113722#, cache result of expensive queryInterface call vcl::Window *pThisWin = const_cast<vcl::Window*>(this); diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 11a2480323ff..82f9ab0aae2d 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -929,7 +929,7 @@ void StatusBar::InsertItem( sal_uInt16 nItemId, sal_uLong nWidth, ImplStatusItem* pItem = new ImplStatusItem; pItem->mnId = nItemId; pItem->mnBits = nBits; - pItem->mnWidth = (long)nWidth+nFudge+STATUSBAR_OFFSET; + pItem->mnWidth = static_cast<long>(nWidth)+nFudge+STATUSBAR_OFFSET; pItem->mnOffset = nOffset; pItem->mpUserData = nullptr; pItem->mbVisible = true; @@ -1031,7 +1031,7 @@ void StatusBar::Clear() sal_uInt16 StatusBar::GetItemCount() const { - return (sal_uInt16)mpItemList.size(); + return static_cast<sal_uInt16>(mpItemList.size()); } sal_uInt16 StatusBar::GetItemId( sal_uInt16 nPos ) const diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 28a9924b0203..351a90c8cc2b 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -707,15 +707,15 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData ) if( std::abs(g.nX-aState.mnX) < 2 && std::abs(g.nY-aState.mnY) < 5 ) { long displacement = g.nTopDecoration ? g.nTopDecoration : 20; - if( (unsigned long) (aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > (unsigned long) aDesktop.Right() || - (unsigned long) (aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > (unsigned long) aDesktop.Bottom() ) + if( static_cast<unsigned long>(aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > static_cast<unsigned long>(aDesktop.Right()) || + static_cast<unsigned long>(aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > static_cast<unsigned long>(aDesktop.Bottom()) ) { // displacing would leave screen aState.mnX = g.nLeftDecoration ? g.nLeftDecoration : 10; // should result in (0,0) aState.mnY = displacement; if( bWrapped || - (unsigned long) (aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > (unsigned long) aDesktop.Right() || - (unsigned long) (aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > (unsigned long) aDesktop.Bottom() ) + static_cast<unsigned long>(aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > static_cast<unsigned long>(aDesktop.Right()) || + static_cast<unsigned long>(aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > static_cast<unsigned long>(aDesktop.Bottom()) ) break; // further displacement not possible -> break // avoid endless testing bWrapped = true; @@ -775,11 +775,11 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData ) const SalFrameGeometry& rGeom = pWindow->mpWindowImpl->mpFrame->GetGeometry(); if( nX < 0 ) nX = 0; - if( nX + nWidth > (long) rGeom.nWidth ) + if( nX + nWidth > static_cast<long>(rGeom.nWidth) ) nX = rGeom.nWidth - nWidth; if( nY < 0 ) nY = 0; - if( nY + nHeight > (long) rGeom.nHeight ) + if( nY + nHeight > static_cast<long>(rGeom.nHeight) ) nY = rGeom.nHeight - nHeight; setPosSizePixel( nX, nY, nWidth, nHeight, nPosSize ); maOrgSize = Size( nWidth, nHeight ); diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index d473684fd0bb..aa4e65fab4a2 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -75,12 +75,12 @@ #define TB_WBLINESIZING (WB_SIZEABLE | WB_DOCKABLE | WB_SCROLL) -#define DOCK_LINEHSIZE ((sal_uInt16)0x0001) -#define DOCK_LINEVSIZE ((sal_uInt16)0x0002) -#define DOCK_LINERIGHT ((sal_uInt16)0x1000) -#define DOCK_LINEBOTTOM ((sal_uInt16)0x2000) -#define DOCK_LINELEFT ((sal_uInt16)0x4000) -#define DOCK_LINETOP ((sal_uInt16)0x8000) +#define DOCK_LINEHSIZE (sal_uInt16(0x0001)) +#define DOCK_LINEVSIZE (sal_uInt16(0x0002)) +#define DOCK_LINERIGHT (sal_uInt16(0x1000)) +#define DOCK_LINEBOTTOM (sal_uInt16(0x2000)) +#define DOCK_LINELEFT (sal_uInt16(0x4000)) +#define DOCK_LINETOP (sal_uInt16(0x8000)) #define DOCK_LINEOFFSET 3 class ImplTBDragMgr @@ -266,7 +266,7 @@ void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext, if (eAlign == WindowAlign::Top || eAlign == WindowAlign::Bottom) { - int height = (int) (0.6 * aSz.Height() + 0.5); + int height = static_cast<int>(0.6 * aSz.Height() + 0.5); int i = (aSz.Height() - height) / 2; height += i; while (i <= height) @@ -278,7 +278,7 @@ void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext, } else { - int width = (int) (0.6 * aSz.Width() + 0.5); + int width = static_cast<int>(0.6 * aSz.Width() + 0.5); int i = (aSz.Width() - width) / 2; width += i; while (i <= width) @@ -4360,7 +4360,7 @@ Size ToolBox::CalcPopupWindowSizePixel() else { // no breaks found: use quadratic layout - nLines = (ImplToolItems::size_type) ceil( sqrt( (double) GetItemCount() ) ); + nLines = static_cast<ImplToolItems::size_type>(ceil( sqrt( static_cast<double>(GetItemCount()) ) )); } bool bPopup = mpData->mbAssumePopupMode; diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index a17a7e3a214a..3dc940ecb00e 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -759,7 +759,7 @@ ImplWinData::ImplWinData() : mpFocusRect(nullptr), mpTrackRect(nullptr), mnTrackFlags(ShowTrackFlags::NONE), - mnIsTopWindow((sal_uInt16) ~0), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) + mnIsTopWindow(sal_uInt16(~0)), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mbMouseOver(false), mbEnableNativeWidget(false) { diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 4e38bcaba259..5c8e043da580 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -438,7 +438,7 @@ void Window::SetZoom( const Fraction& rZoom ) inline long WinFloatRound( double fVal ) { - return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) ); + return( fVal > 0.0 ? static_cast<long>( fVal + 0.5 ) : -static_cast<long>( -fVal + 0.5 ) ); } void Window::SetZoomedPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) @@ -663,7 +663,7 @@ static void lcl_HandleScrollHelper( ScrollBar* pScrl, double nN, bool isMultiply else if ( fVal > LONG_MAX ) nNewPos = LONG_MAX; else - nNewPos = (long)fVal; + nNewPos = static_cast<long>(fVal); } pScrl->DoScroll( nNewPos ); diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index ad4c6920a738..4675ea801b3d 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -867,7 +867,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, nVCLEvent = VclEventId::NONE; break; } - KeyEvent aKeyEvent((sal_Unicode)nCharCode, aKeyCode, nRepeat); + KeyEvent aKeyEvent(static_cast<sal_Unicode>(nCharCode), aKeyCode, nRepeat); if (nVCLEvent != VclEventId::NONE && Application::HandleKey(nVCLEvent, pWindow, &aKeyEvent)) return true; } @@ -878,7 +878,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, if( Application::GetSettings().GetMiscSettings().GetEnableLocalizedDecimalSep() ) { OUString aSep( pWindow->GetSettings().GetLocaleDataWrapper().getNumDecimalSep() ); - nCharCode = (sal_uInt16) aSep[0]; + nCharCode = static_cast<sal_uInt16>(aSep[0]); } } @@ -972,7 +972,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, pChildOutDev->HasMirroredGraphics() && pChild->IsRTLEnabled() ) aKeyCode = vcl::KeyCode( aKeyCode.GetCode() == KEY_LEFT ? KEY_RIGHT : KEY_LEFT, aKeyCode.GetModifier() ); - KeyEvent aKeyEvt( (sal_Unicode)nCharCode, aKeyCode, nRepeat ); + KeyEvent aKeyEvt( static_cast<sal_Unicode>(nCharCode), aKeyCode, nRepeat ); NotifyEvent aNotifyEvt( nSVEvent, pChild, &aKeyEvt ); bool bKeyPreNotify = ImplCallPreNotify( aNotifyEvt ); bool bRet = true; |