From 9af8f190ed1bf3f76897ad0c078db16451d6fb69 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 22 Jan 2018 13:11:34 +0100 Subject: More loplugin:cstylecast on Windows Automatic rewrite (of loplugin:cstylecast and loplugin:unnecessaryparen) after cab0427cadddb3aaf1349c66f2fa13a4234ba4b2 "Enable loplugin:cstylecast for some more cases" and a409d32e7f6fc09e041079d6dbc3c927497adfed "More loplugin:cstylecast" Change-Id: Ib3355159dd08333e1b7a8d091caf2069cdcc7862 Reviewed-on: https://gerrit.libreoffice.org/48317 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- avmedia/source/win/window.cxx | 8 +- basic/source/runtime/methods.cxx | 2 +- basic/source/sbx/sbxdec.cxx | 12 +- .../source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx | 2 +- .../source/cpp_uno/msvc_win32_x86-64/except.cxx | 2 +- canvas/source/directx/dx_bitmapcanvashelper.cxx | 2 +- canvas/source/directx/dx_canvashelper.cxx | 2 +- canvas/source/directx/dx_textlayout_drawhelper.cxx | 12 +- canvas/source/directx/dx_vcltools.cxx | 6 +- comphelper/source/misc/mimeconfighelper.cxx | 2 +- .../source/drivers/ado/ACallableStatement.cxx | 4 +- connectivity/source/drivers/ado/AColumn.cxx | 2 +- connectivity/source/drivers/ado/AConnection.cxx | 4 +- .../source/drivers/ado/ADatabaseMetaDataImpl.cxx | 2 +- .../drivers/ado/ADatabaseMetaDataResultSet.cxx | 8 +- connectivity/source/drivers/ado/AResultSet.cxx | 16 +-- connectivity/source/drivers/ado/AStatement.cxx | 2 +- connectivity/source/drivers/ado/Aolevariant.cxx | 14 +- desktop/win32/source/guiloader/genericloader.cxx | 2 +- desktop/win32/source/officeloader/officeloader.cxx | 4 +- .../source/primitive2d/textlayoutdevice.cxx | 6 +- dtrans/source/win32/dnd/source.cxx | 2 +- dtrans/source/win32/dtobj/FmtFilter.cxx | 2 +- embeddedobj/source/msole/olecomponent.cxx | 46 +++--- embeddedobj/source/msole/xdialogcreator.cxx | 10 +- embedserv/source/embed/docholder.cxx | 8 +- embedserv/source/embed/ed_idataobj.cxx | 16 +-- embedserv/source/embed/ed_ipersiststr.cxx | 8 +- embedserv/source/embed/tracker.cxx | 20 +-- extensions/source/activex/SOActiveX.cxx | 6 +- extensions/source/ole/oleobjw.cxx | 16 +-- extensions/source/ole/unoconversionutilities.hxx | 10 +- extensions/source/ole/unoobjw.cxx | 6 +- extensions/source/scanner/scanwin.cxx | 4 +- .../filepicker/VistaFilePickerEventHandler.cxx | 2 +- .../win32/filepicker/VistaFilePickerImpl.cxx | 8 +- fpicker/source/win32/folderpicker/MtaFop.cxx | 2 +- hwpfilter/source/hwpreader.cxx | 2 +- .../plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 4 +- sal/osl/w32/backtrace.cxx | 8 +- sal/osl/w32/dllentry.cxx | 2 +- sal/osl/w32/file.cxx | 6 +- sal/osl/w32/file_dirvol.cxx | 10 +- sal/osl/w32/file_error.cxx | 2 +- sal/osl/w32/file_url.cxx | 4 +- sal/osl/w32/nlsupport.cxx | 6 +- sal/osl/w32/pipe.cxx | 4 +- sal/osl/w32/process.cxx | 12 +- sal/osl/w32/profile.cxx | 2 +- sal/osl/w32/security.cxx | 20 +-- sal/osl/w32/socket.cxx | 22 +-- sal/osl/w32/thread.cxx | 16 +-- sal/osl/w32/time.cxx | 16 +-- sal/qa/osl/security/osl_Security.cxx | 22 +-- sal/rtl/alloc_arena.cxx | 6 +- sal/rtl/alloc_cache.cxx | 2 +- sdext/source/pdfimport/pdfparse/pdfparse.cxx | 4 +- .../source/win32/customactions/sellang/sellang.cxx | 2 +- sfx2/source/appl/shutdowniconw32.cxx | 4 +- shell/source/win32/SysShExec.cxx | 2 +- .../win32/shlxthandler/infotips/infotips.cxx | 2 +- .../source/win32/shlxthandler/ooofilt/propspec.cxx | 2 +- .../win32/shlxthandler/ooofilt/stream_helper.cxx | 6 +- .../win32/shlxthandler/prophdl/propertyhdl.cxx | 2 +- .../win32/shlxthandler/thumbviewer/thumbviewer.cxx | 6 +- .../win32/shlxthandler/util/iso8601_converter.cxx | 12 +- shell/source/win32/zipfile/zipfile.cxx | 6 +- stoc/source/typeconv/convert.cxx | 4 +- svl/source/crypto/cryptosign.cxx | 6 +- svl/source/svdde/ddecli.cxx | 12 +- svl/source/svdde/ddesvr.cxx | 10 +- sw/source/core/txtnode/fntcache.cxx | 2 +- tools/source/datetime/ttime.cxx | 2 +- tools/source/stream/strmwnt.cxx | 4 +- vcl/inc/win/wincomp.hxx | 2 +- vcl/opengl/win/gdiimpl.cxx | 6 +- vcl/source/window/toolbox.cxx | 2 +- vcl/win/app/saldata.cxx | 2 +- vcl/win/app/salinst.cxx | 14 +- vcl/win/app/saltimer.cxx | 2 +- vcl/win/gdi/gdiimpl.cxx | 134 +++++++++--------- vcl/win/gdi/salbmp.cxx | 8 +- vcl/win/gdi/salfont.cxx | 12 +- vcl/win/gdi/salgdi.cxx | 24 ++-- vcl/win/gdi/salprn.cxx | 10 +- vcl/win/gdi/salvd.cxx | 4 +- vcl/win/window/salframe.cxx | 154 ++++++++++----------- vcl/win/window/salmenu.cxx | 2 +- vcl/win/window/salobj.cxx | 26 ++-- .../source/UAccCOM/AccComponentBase.cxx | 4 +- .../source/UAccCOM/AccEditableText.cxx | 18 +-- winaccessibility/source/UAccCOM/EnumVariant.cxx | 2 +- winaccessibility/source/service/AccObject.cxx | 2 +- .../source/service/AccObjectWinManager.cxx | 2 +- .../source/service/AccTopWindowListener.cxx | 2 +- .../source/service/msaaservice_impl.cxx | 2 +- .../xmlsec/mscrypt/sanextension_mscryptimpl.cxx | 4 +- .../mscrypt/securityenvironment_mscryptimpl.cxx | 2 +- .../xmlsec/mscrypt/x509certificate_mscryptimpl.cxx | 2 +- 99 files changed, 488 insertions(+), 488 deletions(-) diff --git a/avmedia/source/win/window.cxx b/avmedia/source/win/window.cxx index 16deeee09a1e..a24682ae03bc 100644 --- a/avmedia/source/win/window.cxx +++ b/avmedia/source/win/window.cxx @@ -235,12 +235,12 @@ void Window::ImplLayoutVideoWindow() { if( aPrefSize.Width > 0 && aPrefSize.Height > 0 && nVideoW > 0 && nVideoH > 0 ) { - double fPrefWH = (double) aPrefSize.Width / aPrefSize.Height; + double fPrefWH = static_cast(aPrefSize.Width) / aPrefSize.Height; - if( fPrefWH < ( (double) nVideoW / nVideoH ) ) - nVideoW = (int)( nVideoH * fPrefWH ); + if( fPrefWH < ( static_cast(nVideoW) / nVideoH ) ) + nVideoW = static_cast( nVideoH * fPrefWH ); else - nVideoH = (int)( nVideoW / fPrefWH ); + nVideoH = static_cast( nVideoW / fPrefWH ); nX = ( nW - nVideoW ) >> 1; nY = ( nH - nVideoH ) >> 1; diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 58c8b35c9cb1..5f53992360ff 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -2938,7 +2938,7 @@ void SbRtl_GetAttr(StarBASIC * pBasic, SbxArray & rPar, bool bWrite) { nRealFlags = 0; } - nFlags = (sal_Int16) nRealFlags; + nFlags = static_cast(nRealFlags); } else { diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx index 183abf2de137..4c9be3546afd 100644 --- a/basic/source/sbx/sbxdec.cxx +++ b/basic/source/sbx/sbxdec.cxx @@ -138,13 +138,13 @@ bool SbxDecimal::isZero() SbxDecimal::CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight ) { HRESULT hResult = VarDecCmp( const_cast(&rLeft.maDec), const_cast(&rRight.maDec) ); - SbxDecimal::CmpResult eRes = (SbxDecimal::CmpResult)hResult; + SbxDecimal::CmpResult eRes = static_cast(hResult); return eRes; } void SbxDecimal::setChar( sal_Unicode val ) { - VarDecFromUI2( (sal_uInt16)val, &maDec ); + VarDecFromUI2( static_cast(val), &maDec ); } void SbxDecimal::setByte( sal_uInt8 val ) @@ -154,12 +154,12 @@ void SbxDecimal::setByte( sal_uInt8 val ) void SbxDecimal::setShort( sal_Int16 val ) { - VarDecFromI2( (short)val, &maDec ); + VarDecFromI2( static_cast(val), &maDec ); } void SbxDecimal::setLong( sal_Int32 val ) { - VarDecFromI4( (long)val, &maDec ); + VarDecFromI4( static_cast(val), &maDec ); } void SbxDecimal::setUShort( sal_uInt16 val ) @@ -186,12 +186,12 @@ bool SbxDecimal::setDouble( double val ) void SbxDecimal::setInt( int val ) { - setLong( (sal_Int32)val ); + setLong( static_cast(val) ); } void SbxDecimal::setUInt( unsigned int val ) { - setULong( (sal_uInt32)val ); + setULong( static_cast(val) ); } bool SbxDecimal::setString( OUString* pOUString ) diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx index 36efe8e17289..7c754a6c37b6 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/cpp2uno.cxx @@ -380,7 +380,7 @@ unsigned char * codeSnippet( sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset ) { - sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex ); + sal_uInt64 nOffsetAndIndex = ( static_cast(nVtableOffset) << 32 ) | static_cast(nFunctionIndex); unsigned char *p = code; // Spill parameters diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx index 640455b8bab9..02d78d740e80 100644 --- a/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx +++ b/bridges/source/cpp_uno/msvc_win32_x86-64/except.cxx @@ -645,7 +645,7 @@ RaiseInfo::RaiseInfo(typelib_TypeDescription * pTD)throw () // Fill pCode with D-Tor code GenerateDestructorTrampoline(pCode, pTD); - _pDtor = (sal_Int32)(reinterpret_cast(pCode) - _codeBase); + _pDtor = static_cast(reinterpret_cast(pCode) - _codeBase); pCodeOffset += codeSnippetSize; // Info count accompanied by type info ptrs: type, base type, base base type, ... diff --git a/canvas/source/directx/dx_bitmapcanvashelper.cxx b/canvas/source/directx/dx_bitmapcanvashelper.cxx index 7e69484935c9..2d4954700e55 100644 --- a/canvas/source/directx/dx_bitmapcanvashelper.cxx +++ b/canvas/source/directx/dx_bitmapcanvashelper.cxx @@ -86,7 +86,7 @@ namespace dxcanvas GraphicsSharedPtr pGraphics( mpTarget->getGraphics() ); Gdiplus::Color aClearColor = hasAlpha() ? - Gdiplus::Color( 0,255,255,255 ) : Gdiplus::Color((Gdiplus::ARGB)Gdiplus::Color::White); + Gdiplus::Color( 0,255,255,255 ) : Gdiplus::Color(Gdiplus::ARGB(Gdiplus::Color::White)); ENSURE_OR_THROW( Gdiplus::Ok == pGraphics->SetCompositingMode( diff --git a/canvas/source/directx/dx_canvashelper.cxx b/canvas/source/directx/dx_canvashelper.cxx index 86222437d090..7fe441f081bf 100644 --- a/canvas/source/directx/dx_canvashelper.cxx +++ b/canvas/source/directx/dx_canvashelper.cxx @@ -146,7 +146,7 @@ namespace dxcanvas if( needOutput() ) { GraphicsSharedPtr pGraphics( mpGraphicsProvider->getGraphics() ); - Gdiplus::Color aClearColor = Gdiplus::Color((Gdiplus::ARGB)Gdiplus::Color::White); + Gdiplus::Color aClearColor = Gdiplus::Color(Gdiplus::ARGB(Gdiplus::Color::White)); ENSURE_OR_THROW( Gdiplus::Ok == pGraphics->SetCompositingMode( diff --git a/canvas/source/directx/dx_textlayout_drawhelper.cxx b/canvas/source/directx/dx_textlayout_drawhelper.cxx index 4edd59cab623..56469e17ee72 100644 --- a/canvas/source/directx/dx_textlayout_drawhelper.cxx +++ b/canvas/source/directx/dx_textlayout_drawhelper.cxx @@ -179,12 +179,12 @@ namespace dxcanvas // set world transform XFORM aXForm; - aXForm.eM11 = (FLOAT)aWorldTransform.get(0, 0); - aXForm.eM12 = (FLOAT)aWorldTransform.get(1, 0); - aXForm.eM21 = (FLOAT)aWorldTransform.get(0, 1); - aXForm.eM22 = (FLOAT)aWorldTransform.get(1, 1); - aXForm.eDx = (FLOAT)aWorldTransform.get(0, 2); - aXForm.eDy = (FLOAT)aWorldTransform.get(1, 2); + aXForm.eM11 = static_cast(aWorldTransform.get(0, 0)); + aXForm.eM12 = static_cast(aWorldTransform.get(1, 0)); + aXForm.eM21 = static_cast(aWorldTransform.get(0, 1)); + aXForm.eM22 = static_cast(aWorldTransform.get(1, 1)); + aXForm.eDx = static_cast(aWorldTransform.get(0, 2)); + aXForm.eDy = static_cast(aWorldTransform.get(1, 2)); // TODO(F3): This is NOT supported on 95/98/ME! SetGraphicsMode(hdc, GM_ADVANCED); diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx index 1efc1e30b174..b8e511a09260 100644 --- a/canvas/source/directx/dx_vcltools.cxx +++ b/canvas/source/directx/dx_vcltools.cxx @@ -223,7 +223,7 @@ namespace dxcanvas // out notion of alpha is // different from the rest // of the world's - *pCurrOutput++ = 255 - (BYTE)*pAScan++; + *pCurrOutput++ = 255 - static_cast(*pAScan++); } } break; @@ -243,7 +243,7 @@ namespace dxcanvas // out notion of alpha is // different from the rest // of the world's - *pCurrOutput++ = 255 - (BYTE)*pAScan++; + *pCurrOutput++ = 255 - static_cast(*pAScan++); } } break; @@ -275,7 +275,7 @@ namespace dxcanvas // out notion of alpha is // different from the rest // of the world's - *pCurrOutput++ = 255 - (BYTE)*pAScan++; + *pCurrOutput++ = 255 - static_cast(*pAScan++); } } break; diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index 7db54fef85a7..91e4c5513eb8 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -670,7 +670,7 @@ SfxFilterFlags MimeConfigurationHelper::GetFilterFlags( const OUString& aFilterN if ( aFilterAny >>= aData ) { SequenceAsHashMap aFilterHM( aData ); - nFlags = static_cast(aFilterHM.getUnpackedValueOrDefault( "Flags", (sal_Int32)0 )); + nFlags = static_cast(aFilterHM.getUnpackedValueOrDefault( "Flags", sal_Int32(0) )); } } } catch( uno::Exception& ) diff --git a/connectivity/source/drivers/ado/ACallableStatement.cxx b/connectivity/source/drivers/ado/ACallableStatement.cxx index 27e6acea428e..d572a8f99d9e 100644 --- a/connectivity/source/drivers/ado/ACallableStatement.cxx +++ b/connectivity/source/drivers/ado/ACallableStatement.cxx @@ -106,7 +106,7 @@ sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) { GET_PARAM() - return (sal_Int64)m_aValue.getCurrency().int64; + return static_cast(m_aValue.getCurrency().int64); } @@ -164,7 +164,7 @@ void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 paramet { pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType())); pParam->put_Direction(adParamOutput); - pParam->put_NumericScale((sal_Int8)scale); + pParam->put_NumericScale(static_cast(scale)); } } diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index 12b671ef115d..962b57aa0a4c 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -146,7 +146,7 @@ void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& r sal_Int32 nVal=0; rValue >>= nVal; if ( !m_IsCurrency ) - m_aColumn.put_NumericScale((sal_Int8)nVal); + m_aColumn.put_NumericScale(static_cast(nVal)); } break; case PROPERTY_ID_ISNULLABLE: diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index 7b98f77b147f..ad02964b85e3 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -435,10 +435,10 @@ void OConnection::buildTypeInfo() sal_Int32 nPos = 1; OExtendedTypeInfo* aInfo = new OExtendedTypeInfo; aInfo->aSimpleType.aTypeName = ADOS::getField(pRecordset,nPos++).get_Value().getString(); - aInfo->eType = (DataTypeEnum)ADOS::getField(pRecordset,nPos++).get_Value().getInt32(); + aInfo->eType = static_cast(ADOS::getField(pRecordset,nPos++).get_Value().getInt32()); if ( aInfo->eType == adWChar && aInfo->aSimpleType.aTypeName == s_sVarChar ) aInfo->eType = adVarWChar; - aInfo->aSimpleType.nType = (sal_Int16)ADOS::MapADOType2Jdbc(aInfo->eType); + aInfo->aSimpleType.nType = static_cast(ADOS::MapADOType2Jdbc(aInfo->eType)); aInfo->aSimpleType.nPrecision = ADOS::getField(pRecordset,nPos++).get_Value().getInt32(); nPos++; // aLiteralPrefix nPos++; // aLiteralSuffix diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx index cadf6fe2c793..8f546fceca92 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx @@ -378,7 +378,7 @@ RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum) if(_eNum & Privilege::DROP) nRight |= adRightDrop; - return (RightsEnum)nRight; + return static_cast(nRight); } void WpADOIndex::Create() diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx index 19f4d9b45749..d787532336a1 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx @@ -211,9 +211,9 @@ sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) if(m_aValue.isNull()) return 0; if ( !m_aValueRange.empty() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) - return (sal_Int8)(*m_aValueRangeIter).second[m_aValue.getInt32()]; + return static_cast((*m_aValueRangeIter).second[m_aValue.getInt32()]); else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) - return (sal_Int8)(*m_aStrValueRangeIter).second[m_aValue.getString()]; + return static_cast((*m_aStrValueRangeIter).second[m_aValue.getString()]); return m_aValue.getInt8(); } @@ -342,9 +342,9 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) return 0; if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) - return (sal_Int16)(*m_aValueRangeIter).second[m_aValue.getInt32()]; + return static_cast((*m_aValueRangeIter).second[m_aValue.getInt32()]); else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end()) - return (sal_Int16)(*m_aStrValueRangeIter).second[m_aValue.getString()]; + return static_cast((*m_aStrValueRangeIter).second[m_aValue.getString()]); return m_aValue.getInt16(); } diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index 2d6c1ece45e8..8c1b6993dabe 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -820,13 +820,13 @@ Any SAL_CALL OResultSet::getBookmark( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if(m_nRowPos < (sal_Int32)m_aBookmarks.size()) // this bookmark was already fetched + if(m_nRowPos < static_cast(m_aBookmarks.size())) // this bookmark was already fetched return makeAny(sal_Int32(m_nRowPos-1)); OLEVariant aVar; m_pRecordSet->get_Bookmark(&aVar); m_aBookmarks.push_back(aVar); - return makeAny((sal_Int32)(m_aBookmarks.size()-1)); + return makeAny(static_cast(m_aBookmarks.size()-1)); } @@ -838,8 +838,8 @@ sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) sal_Int32 nPos = 0; bookmark >>= nPos; - OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector"); - if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size()) + OSL_ENSURE(nPos >= 0 && nPos < static_cast(m_aBookmarks.size()),"Invalid Index for vector"); + if(nPos < 0 || nPos >= static_cast(m_aBookmarks.size())) ::dbtools::throwFunctionSequenceException(*this); return SUCCEEDED(m_pRecordSet->Move(0,m_aBookmarks[nPos])); @@ -854,8 +854,8 @@ sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_I sal_Int32 nPos = 0; bookmark >>= nPos; nPos += rows; - OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector"); - if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size()) + OSL_ENSURE(nPos >= 0 && nPos < static_cast(m_aBookmarks.size()),"Invalid Index for vector"); + if(nPos < 0 || nPos >= static_cast(m_aBookmarks.size())) ::dbtools::throwFunctionSequenceException(*this); return SUCCEEDED(m_pRecordSet->Move(rows,m_aBookmarks[nPos])); } @@ -872,11 +872,11 @@ sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& bookmark1, const Any if(nPos1 == nPos2) // they should be equal return css::sdbcx::CompareBookmark::EQUAL; - OSL_ENSURE((nPos1 >= 0 && nPos1 < (sal_Int32)m_aBookmarks.size()) || (nPos1 >= 0 && nPos2 < (sal_Int32)m_aBookmarks.size()),"Invalid Index for vector"); + OSL_ENSURE((nPos1 >= 0 && nPos1 < static_cast(m_aBookmarks.size())) || (nPos1 >= 0 && nPos2 < static_cast(m_aBookmarks.size())),"Invalid Index for vector"); CompareEnum eNum; m_pRecordSet->CompareBookmarks(m_aBookmarks[nPos1],m_aBookmarks[nPos2],&eNum); - return ((sal_Int32)eNum) - 1; + return static_cast(eNum) - 1; } sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx index 8ffaad54f340..5bdf386468c4 100644 --- a/connectivity/source/drivers/ado/AStatement.cxx +++ b/connectivity/source/drivers/ado/AStatement.cxx @@ -211,7 +211,7 @@ sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType) sal_Int32 prec = -1; OTypeInfo aInfo; - aInfo.nType = (sal_Int16)sqlType; + aInfo.nType = static_cast(sqlType); if (!m_aTypeInfo.empty()) { std::vector::const_iterator aIter = std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo); diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index bc8c9236a623..cd06b31fc7ed 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -116,7 +116,7 @@ OLEVariant::OLEVariant(bool x) { VariantInit(this); vt = VT_BOOL OLEVariant::OLEVariant(sal_Int8 n) { VariantInit(this); vt = VT_I1; bVal = n;} OLEVariant::OLEVariant(sal_Int16 n) { VariantInit(this); vt = VT_I2; intVal = n;} OLEVariant::OLEVariant(sal_Int32 n) { VariantInit(this); vt = VT_I4; lVal = n;} -OLEVariant::OLEVariant(sal_Int64 x) { VariantInit(this); vt = VT_I4; lVal = (LONG)x;} +OLEVariant::OLEVariant(sal_Int64 x) { VariantInit(this); vt = VT_I4; lVal = static_cast(x);} OLEVariant::OLEVariant(const OUString& us) { @@ -312,7 +312,7 @@ void OLEVariant::setArray(SAFEARRAY* pSafeArray, VARTYPE vtType) { HRESULT eRet = VariantClear(this); OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!"); - vt = (VARTYPE)(VT_ARRAY|vtType); + vt = static_cast(VT_ARRAY|vtType); parray = pSafeArray; } @@ -354,7 +354,7 @@ VARIANT_BOOL OLEVariant::VariantBool(bool bEinBoolean) void OLEVariant::CHS() { - cyVal.Lo ^= (sal_uInt32)-1; + cyVal.Lo ^= sal_uInt32(-1); cyVal.Hi ^= -1; cyVal.Lo++; if( !cyVal.Lo ) @@ -365,12 +365,12 @@ void OLEVariant::set(double n) { if( n >= 0 ) { - cyVal.Hi = (sal_Int32)(n / 4294967296.0); - cyVal.Lo = (sal_uInt32)(n - ((double)cyVal.Hi * 4294967296.0)); + cyVal.Hi = static_cast(n / 4294967296.0); + cyVal.Lo = static_cast(n - (static_cast(cyVal.Hi) * 4294967296.0)); } else { - cyVal.Hi = (sal_Int32)(-n / 4294967296.0); - cyVal.Lo = (sal_uInt32)(-n - ((double)cyVal.Hi * 4294967296.0)); + cyVal.Hi = static_cast(-n / 4294967296.0); + cyVal.Lo = static_cast(-n - (static_cast(cyVal.Hi) * 4294967296.0)); CHS(); } } diff --git a/desktop/win32/source/guiloader/genericloader.cxx b/desktop/win32/source/guiloader/genericloader.cxx index 8beb240c0316..193e74bd11b0 100644 --- a/desktop/win32/source/guiloader/genericloader.cxx +++ b/desktop/win32/source/guiloader/genericloader.cxx @@ -33,7 +33,7 @@ static int GenericMain() GetStartupInfoW( &aStartupInfo ); - DWORD dwExitCode = (DWORD)-1; + DWORD dwExitCode = DWORD(-1); PROCESS_INFORMATION aProcessInfo; diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx index 45b94a8e128d..10393741b235 100644 --- a/desktop/win32/source/officeloader/officeloader.cxx +++ b/desktop/win32/source/officeloader/officeloader.cxx @@ -52,7 +52,7 @@ int WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int ) if ((aStartupInfo.dwFlags & STARTF_USESTDHANDLES) == 0) AttachConsole(ATTACH_PARENT_PROCESS); - DWORD dwExitCode = (DWORD)-1; + DWORD dwExitCode = DWORD(-1); BOOL fSuccess = FALSE; LPWSTR lpCommandLine = nullptr; @@ -129,7 +129,7 @@ int WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int ) LocalFree(argv2); } - if ( _ltow( (long)GetCurrentProcessId(),szParentProcessId, 10 ) && bHeadlessMode ) + if ( _ltow( static_cast(GetCurrentProcessId()),szParentProcessId, 10 ) && bHeadlessMode ) SetEnvironmentVariableW( L"ATTACHED_PARENT_PROCESSID", szParentProcessId ); PROCESS_INFORMATION aProcessInfo; diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index bfc9140e8d7c..66090ad2e34e 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -417,8 +417,8 @@ namespace drawinglayer if(aUnscaledFontMetric.GetAverageFontWidth() > 0) { - const double fScaleFactor((double)nWidth / (double)nHeight); - const sal_uInt32 nScaledWidth(basegfx::fround((double)aUnscaledFontMetric.GetAverageFontWidth() * fScaleFactor)); + const double fScaleFactor(static_cast(nWidth) / static_cast(nHeight)); + const sal_uInt32 nScaledWidth(basegfx::fround(static_cast(aUnscaledFontMetric.GetAverageFontWidth()) * fScaleFactor)); aRetval.SetAverageFontWidth(nScaledWidth); } } @@ -470,7 +470,7 @@ namespace drawinglayer if(aUnscaledFontMetric.GetAverageFontWidth() > 0) { - const double fScaleFactor((double)rFont.GetFontSize().getWidth() / (double)aUnscaledFontMetric.GetAverageFontWidth()); + const double fScaleFactor(static_cast(rFont.GetFontSize().getWidth()) / static_cast(aUnscaledFontMetric.GetAverageFontWidth())); o_rSize.setX(fScaleFactor * o_rSize.getY()); } } diff --git a/dtrans/source/win32/dnd/source.cxx b/dtrans/source/win32/dnd/source.cxx index 06c8e4977def..5b1bc1d3d1b3 100644 --- a/dtrans/source/win32/dnd/source.cxx +++ b/dtrans/source/win32/dnd/source.cxx @@ -211,7 +211,7 @@ HRESULT STDMETHODCALLTYPE DragSource::QueryInterface( REFIID riid, void **ppvOb ULONG STDMETHODCALLTYPE DragSource::AddRef() { acquire(); - return (ULONG) m_refCount; + return static_cast(m_refCount); } ULONG STDMETHODCALLTYPE DragSource::Release() diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx index 2931521511fb..1dcc089c7b9d 100644 --- a/dtrans/source/win32/dtobj/FmtFilter.cxx +++ b/dtrans/source/win32/dtobj/FmtFilter.cxx @@ -423,7 +423,7 @@ Sequence< sal_Int8 > WinBITMAPToOOBMP( HBITMAP aHBMP ) pBmp->biPlanes = 1; pBmp->biBitCount = 32; pBmp->biCompression = BI_RGB; - pBmp->biSizeImage = (DWORD)nDataBytes; + pBmp->biSizeImage = static_cast(nDataBytes); pBmp->biXPelsPerMeter = 1000; pBmp->biYPelsPerMeter = 1000; pBmp->biClrUsed = 0; diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 290318a4d109..df3b0131b07b 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -299,11 +299,11 @@ bool OleComponentNative_Impl::ConvertDataForFlavor( const STGMEDIUM& aMedium, // TODO/LATER: the unit size must be calculated correctly *reinterpret_cast( pBuf.get() ) = 0x9ac6cdd7L; - *reinterpret_cast( pBuf.get()+6 ) = ( SHORT ) 0; - *reinterpret_cast( pBuf.get()+8 ) = ( SHORT ) 0; - *reinterpret_cast( pBuf.get()+10 ) = ( SHORT ) pMF->xExt; - *reinterpret_cast( pBuf.get()+12 ) = ( SHORT ) pMF->yExt; - *reinterpret_cast( pBuf.get()+14 ) = ( USHORT ) 2540; + *reinterpret_cast( pBuf.get()+6 ) = SHORT(0); + *reinterpret_cast( pBuf.get()+8 ) = SHORT(0); + *reinterpret_cast( pBuf.get()+10 ) = static_cast(pMF->xExt); + *reinterpret_cast( pBuf.get()+12 ) = static_cast(pMF->yExt); + *reinterpret_cast( pBuf.get()+14 ) = USHORT(2540); if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize - 22, pBuf.get() + 22 ) ) @@ -380,11 +380,11 @@ bool GetClassIDFromSequence_Impl( uno::Sequence< sal_Int8 > const & aSeq, CLSID& { if ( aSeq.getLength() == 16 ) { - aResult.Data1 = ( ( ( ( ( ( sal_uInt8 )aSeq[0] << 8 ) + ( sal_uInt8 )aSeq[1] ) << 8 ) + ( sal_uInt8 )aSeq[2] ) << 8 ) + ( sal_uInt8 )aSeq[3]; - aResult.Data2 = ( ( sal_uInt8 )aSeq[4] << 8 ) + ( sal_uInt8 )aSeq[5]; - aResult.Data3 = ( ( sal_uInt8 )aSeq[6] << 8 ) + ( sal_uInt8 )aSeq[7]; + aResult.Data1 = ( ( ( ( ( static_cast(aSeq[0]) << 8 ) + static_cast(aSeq[1]) ) << 8 ) + static_cast(aSeq[2]) ) << 8 ) + static_cast(aSeq[3]); + aResult.Data2 = ( static_cast(aSeq[4]) << 8 ) + static_cast(aSeq[5]); + aResult.Data3 = ( static_cast(aSeq[6]) << 8 ) + static_cast(aSeq[7]); for( int nInd = 0; nInd < 8; nInd++ ) - aResult.Data4[nInd] = ( sal_uInt8 )aSeq[nInd+8]; + aResult.Data4[nInd] = static_cast(aSeq[nInd+8]); return true; } @@ -994,14 +994,14 @@ awt::Size OleComponent::CalculateWithFactor( const awt::Size& aSize, { awt::Size aResult; - sal_Int64 nWidth = (sal_Int64)aSize.Width * (sal_Int64)aMultiplier.Width / (sal_Int64)aDivisor.Width; - sal_Int64 nHeight = (sal_Int64)aSize.Height * (sal_Int64)aMultiplier.Height / (sal_Int64)aDivisor.Height; + sal_Int64 nWidth = static_cast(aSize.Width) * static_cast(aMultiplier.Width) / static_cast(aDivisor.Width); + sal_Int64 nHeight = static_cast(aSize.Height) * static_cast(aMultiplier.Height) / static_cast(aDivisor.Height); OSL_ENSURE( nWidth < SAL_MAX_INT32 && nWidth > SAL_MIN_INT32 && nHeight < SAL_MAX_INT32 && nHeight > SAL_MIN_INT32, "Unacceptable result size!" ); - aResult.Width = (sal_Int32)nWidth; - aResult.Height = (sal_Int32)nHeight; + aResult.Width = static_cast(nWidth); + aResult.Height = static_cast(nHeight); return aResult; } @@ -1086,7 +1086,7 @@ void OleComponent::SetExtent( const awt::Size& aVisAreaSize, sal_Int64 nAspect ) if ( !m_pNativeImpl->m_pOleObject ) throw embed::WrongStateException(); // TODO: the object is in wrong state - DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects + DWORD nMSAspect = static_cast(nAspect); // first 32 bits are for MS aspects SIZEL aSize = { aVisAreaSize.Width, aVisAreaSize.Height }; HRESULT hr = m_pNativeImpl->m_pOleObject->SetExtent( nMSAspect, &aSize ); @@ -1108,7 +1108,7 @@ awt::Size OleComponent::GetExtent( sal_Int64 nAspect ) if ( !m_pNativeImpl->m_pOleObject ) throw embed::WrongStateException(); // TODO: the object is in wrong state - DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects + DWORD nMSAspect = static_cast(nAspect); // first 32 bits are for MS aspects awt::Size aSize; bool bGotSize = false; @@ -1160,12 +1160,12 @@ awt::Size OleComponent::GetExtent( sal_Int64 nAspect ) break; } - sal_Int64 nX = ( (sal_Int64)abs( pMF->xExt ) ) * nMult / nDiv; - sal_Int64 nY = ( (sal_Int64)abs( pMF->yExt ) ) * nMult / nDiv; + sal_Int64 nX = static_cast(abs( pMF->xExt )) * nMult / nDiv; + sal_Int64 nY = static_cast(abs( pMF->yExt )) * nMult / nDiv; if ( nX < SAL_MAX_INT32 && nY < SAL_MAX_INT32 ) { - aSize.Width = ( sal_Int32 )nX; - aSize.Height = ( sal_Int32 )nY; + aSize.Width = static_cast(nX); + aSize.Height = static_cast(nY); bGotSize = true; } else @@ -1190,7 +1190,7 @@ awt::Size OleComponent::GetCachedExtent( sal_Int64 nAspect ) if ( !m_pNativeImpl->m_pOleObject ) throw embed::WrongStateException(); // TODO: the object is in wrong state - DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects + DWORD nMSAspect = static_cast(nAspect); // first 32 bits are for MS aspects SIZEL aSize; HRESULT hr = m_pNativeImpl->m_pViewObject2->GetExtent( nMSAspect, -1, nullptr, &aSize ); @@ -1216,7 +1216,7 @@ awt::Size OleComponent::GetRecommendedExtent( sal_Int64 nAspect ) if ( !m_pNativeImpl->m_pOleObject ) throw embed::WrongStateException(); // TODO: the object is in wrong state - DWORD nMSAspect = ( DWORD )nAspect; // first 32 bits are for MS aspects + DWORD nMSAspect = static_cast(nAspect); // first 32 bits are for MS aspects SIZEL aSize; HRESULT hr = m_pNativeImpl->m_pOleObject->GetExtent( nMSAspect, &aSize ); if ( FAILED( hr ) ) @@ -1232,8 +1232,8 @@ sal_Int64 OleComponent::GetMiscStatus( sal_Int64 nAspect ) throw embed::WrongStateException(); // TODO: the object is in wrong state DWORD nResult; - m_pNativeImpl->m_pOleObject->GetMiscStatus( ( DWORD )nAspect, &nResult ); - return ( sal_Int64 )nResult; // first 32 bits are for MS flags + m_pNativeImpl->m_pOleObject->GetMiscStatus( static_cast(nAspect), &nResult ); + return static_cast(nResult); // first 32 bits are for MS flags } diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx index d8338cbacfd4..44141b5101f8 100644 --- a/embeddedobj/source/msole/xdialogcreator.cxx +++ b/embeddedobj/source/msole/xdialogcreator.cxx @@ -237,11 +237,11 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceByDia uno::Sequence< sal_Int8 > aMetafile( nBufSize + 22 ); sal_Int8* pBuf = aMetafile.getArray(); *reinterpret_cast( pBuf ) = 0x9ac6cdd7L; - *reinterpret_cast( pBuf+6 ) = ( SHORT ) 0; - *reinterpret_cast( pBuf+8 ) = ( SHORT ) 0; - *reinterpret_cast( pBuf+10 ) = ( SHORT ) pMF->xExt; - *reinterpret_cast( pBuf+12 ) = ( SHORT ) pMF->yExt; - *reinterpret_cast( pBuf+14 ) = ( USHORT ) 2540; + *reinterpret_cast( pBuf+6 ) = SHORT(0); + *reinterpret_cast( pBuf+8 ) = SHORT(0); + *reinterpret_cast( pBuf+10 ) = static_cast(pMF->xExt); + *reinterpret_cast( pBuf+12 ) = static_cast(pMF->yExt); + *reinterpret_cast( pBuf+14 ) = USHORT(2540); if ( nBufSize && nBufSize == GetMetaFileBitsEx( pMF->hMF, nBufSize, pBuf+22 ) ) { diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index 731c453c9cf0..fb333d862a61 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -141,7 +141,7 @@ void DocumentHolder::LoadDocInFrame( bool bPluginMode ) aSeq[nLen-1] = beans::PropertyValue( "PluginMode", -1, - uno::Any((sal_Int16) 3), + uno::Any(sal_Int16(3)), beans::PropertyState_DIRECT_VALUE); } @@ -538,18 +538,18 @@ BOOL DocumentHolder::InPlaceMenuCreate() int help = count-1; // start with 1, because we don't include "File" - WORD pos = (WORD)mgw.width[0]; + WORD pos = static_cast(mgw.width[0]); CopyToOLEMenu(m_nMenuHandle,1,hMenu,pos); mgw.width[1] = 1; // insert object menu here - pos = ((WORD)(mgw.width[0] + mgw.width[1] + mgw.width[2])); + pos = static_cast(mgw.width[0] + mgw.width[1] + mgw.width[2]); for(WORD i = 2; i < help-1; ++i,++pos) CopyToOLEMenu(m_nMenuHandle,i,hMenu,pos); mgw.width[3] = help - 3; // insert help menu - pos = (WORD)(mgw.width[0] + mgw.width[1] + mgw.width[2] + + pos = static_cast(mgw.width[0] + mgw.width[1] + mgw.width[2] + mgw.width[3] + mgw.width[4]); CopyToOLEMenu(m_nMenuHandle,WORD(help),hMenu,pos); mgw.width[5] = 1; diff --git a/embedserv/source/embed/ed_idataobj.cxx b/embedserv/source/embed/ed_idataobj.cxx index c05e9d2def12..11b1709c71c1 100644 --- a/embedserv/source/embed/ed_idataobj.cxx +++ b/embedserv/source/embed/ed_idataobj.cxx @@ -118,8 +118,8 @@ STDMETHODIMP EmbedDocument_Impl::GetData( FORMATETC * pFormatetc, STGMEDIUM * pM } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + CLIPFORMAT cf_embSource = static_cast(RegisterClipboardFormatW( L"Embed Source" )); + CLIPFORMAT cf_embObj = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) ) @@ -157,8 +157,8 @@ STDMETHODIMP EmbedDocument_Impl::GetDataHere( FORMATETC * pFormatetc, STGMEDIUM || pFormatetc->dwAspect == DVASPECT_DOCPRINT ) return DV_E_DVASPECT; - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + CLIPFORMAT cf_embSource = static_cast(RegisterClipboardFormatW( L"Embed Source" )); + CLIPFORMAT cf_embObj = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { @@ -204,8 +204,8 @@ STDMETHODIMP EmbedDocument_Impl::QueryGetData( FORMATETC * pFormatetc ) } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + CLIPFORMAT cf_embSource = static_cast(RegisterClipboardFormatW( L"Embed Source" )); + CLIPFORMAT cf_embObj = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); if ( pFormatetc->cfFormat == cf_embSource || pFormatetc->cfFormat == cf_embObj ) { if ( !( pFormatetc->tymed & TYMED_ISTORAGE ) ) @@ -241,8 +241,8 @@ STDMETHODIMP EmbedDocument_Impl::GetCanonicalFormatEtc( FORMATETC * pFormatetcIn } else { - CLIPFORMAT cf_embSource = (CLIPFORMAT)RegisterClipboardFormatW( L"Embed Source" ); - CLIPFORMAT cf_embObj = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + CLIPFORMAT cf_embSource = static_cast(RegisterClipboardFormatW( L"Embed Source" )); + CLIPFORMAT cf_embObj = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); if ( pFormatetcIn->cfFormat == cf_embSource || pFormatetcIn->cfFormat == cf_embObj ) { pFormatetcOut->tymed = TYMED_ISTORAGE; diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index e60a6b102fed..b863cd8270ef 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -79,7 +79,7 @@ uno::Reference< io::XInputStream > createTempXInStreamFromIStream( hr = pStream->Stat( &aStat, STATFLAG_NONAME ); if ( FAILED( hr ) ) return xResult; - sal_uInt32 nSize = (sal_uInt32)aStat.cbSize.QuadPart; + sal_uInt32 nSize = static_cast(aStat.cbSize.QuadPart); sal_uInt32 nCopied = 0; uno::Sequence< sal_Int8 > aBuffer( nConstBufferSize ); try @@ -423,7 +423,7 @@ STDMETHODIMP EmbedDocument_Impl::InitNew( IStorage *pStg ) if ( hr == S_OK ) { wchar_t const * aCurType = getStorageTypeFromGUID_Impl( &m_guid ); // ??? - CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + CLIPFORMAT cf = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); hr = WriteFmtUserTypeStg( pStg, cf, // ??? const_cast(aCurType) ); @@ -743,7 +743,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( FAILED( hr ) || !m_pMasterStorage ) return E_FAIL; o3tl::u16string_view aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ??? - CLIPFORMAT cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + CLIPFORMAT cf = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? const_cast( o3tl::toW(aCurType.data())) ); @@ -794,7 +794,7 @@ STDMETHODIMP EmbedDocument_Impl::Load( LPCOLESTR pszFileName, DWORD /*dwMode*/ ) if ( hr == S_OK ) { aCurType = getServiceNameFromGUID_Impl( &m_guid ); // ??? - cf = (CLIPFORMAT)RegisterClipboardFormatW( L"Embedded Object" ); + cf = static_cast(RegisterClipboardFormatW( L"Embedded Object" )); hr = WriteFmtUserTypeStg( m_pMasterStorage, cf, // ??? const_cast( o3tl::toW(aCurType.data())) ); diff --git a/embedserv/source/embed/tracker.cxx b/embedserv/source/embed/tracker.cxx index ac7a05857ad1..ba8582c97fad 100644 --- a/embedserv/source/embed/tracker.cxx +++ b/embedserv/source/embed/tracker.cxx @@ -89,7 +89,7 @@ HBRUSH HalftoneBrush() { WORD grayPattern[8]; for (int i = 0; i < 8; i++) - grayPattern[i] = (WORD)(0x5555 << (i & 1)); + grayPattern[i] = static_cast(0x5555 << (i & 1)); HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern); if (grayBitmap != nullptr) { @@ -292,7 +292,7 @@ int Tracker::HitTest(POINT point) const if (PtInRect(&rectTrue,point)) { if ((m_nStyle & (resizeInside|resizeOutside)) != 0) - hitResult = (TrackerHit)HitTestHandles(point); + hitResult = static_cast(HitTestHandles(point)); else hitResult = hitMiddle; } @@ -325,7 +325,7 @@ BOOL Tracker::SetCursor(HWND pWnd, UINT nHitTest) const { // only for trackers with hatchedBorder (ie. in-place resizing) if (m_nStyle & hatchedBorder) - nHandle = (TrackerHit)9; + nHandle = TrackerHit(9); } ::SetCursor(afxCursors[nHandle]); @@ -408,9 +408,9 @@ BOOL Tracker::TrackHandle(int nHandle,HWND hWnd,POINT point,HWND hWndClipTo) rectOld = m_rect; // handle resize cases (and part of move) if (px != nullptr) - *px = (int)(short)LOWORD(msg.lParam) - xDiff; + *px = static_cast(static_cast(LOWORD(msg.lParam))) - xDiff; if (py != nullptr) - *py = (int)(short)HIWORD(msg.lParam) - yDiff; + *py = static_cast(static_cast(HIWORD(msg.lParam))) - yDiff; // handle move case if (nHandle == hitMiddle) @@ -639,7 +639,7 @@ void Tracker::Draw(HDC hDC) const { if (mask & (1<(i), &rect); // FillSolidRect(hDC,rect, RGB(0, 0, 0)); FillRect(hDC,&rect,hbrush); } @@ -741,11 +741,11 @@ int Tracker::NormalizeHit(int nHandle) const const AFX_HANDLEINFO* pHandleInfo = &afxHandleInfo[nHandle]; if (m_rect.right - m_rect.left < 0) { - nHandle = (TrackerHit)pHandleInfo->nInvertX; + nHandle = static_cast(pHandleInfo->nInvertX); pHandleInfo = &afxHandleInfo[nHandle]; } if (m_rect.bottom - m_rect.top < 0) - nHandle = (TrackerHit)pHandleInfo->nInvertY; + nHandle = static_cast(pHandleInfo->nInvertY); return nHandle; } @@ -765,9 +765,9 @@ int Tracker::HitTestHandles(POINT point) const { if (mask & (1<(i), &rect); if (PtInRect(&rect,point)) - return (TrackerHit)i; + return static_cast(i); } } diff --git a/extensions/source/activex/SOActiveX.cxx b/extensions/source/activex/SOActiveX.cxx index c2e1fbb74ca4..cda7fff13df4 100644 --- a/extensions/source/activex/SOActiveX.cxx +++ b/extensions/source/activex/SOActiveX.cxx @@ -566,7 +566,7 @@ HRESULT CSOActiveX::CreateFrameOldWay( HWND hwnd, int width, int height ) if( !SUCCEEDED( hr ) ) return hr; // initialize window - CComVariant aTransparent( (long)0xFFFFFFFF ); + CComVariant aTransparent( long(0xFFFFFFFF) ); hr = ExecuteFunc( mpDispWin, L"setBackground", &aTransparent, 1, &dummyResult ); if( !SUCCEEDED( hr ) ) return hr; @@ -671,7 +671,7 @@ HRESULT CSOActiveX::CallDispatchMethod( OLECHAR const * sUrl, CComVariant aArgs[3]; aArgs[2] = CComVariant( pdispURL ); aArgs[1] = CComVariant( L"" ); - aArgs[0] = CComVariant( (int)0 ); + aArgs[0] = CComVariant( int(0) ); hr = GetIDispByFunc( mpDispFrame, L"queryDispatch", aArgs, @@ -680,7 +680,7 @@ HRESULT CSOActiveX::CallDispatchMethod( OLECHAR const * sUrl, if( !SUCCEEDED( hr ) ) return hr; SAFEARRAY FAR* pPropVals = SafeArrayCreateVector( VT_DISPATCH, 0, count ); - for( long ix = 0; ix < (long)count; ix ++ ) + for( long ix = 0; ix < static_cast(count); ix ++ ) { CComPtr pdispPropVal; hr = GetUnoStruct( L"com.sun.star.beans.PropertyValue", pdispPropVal ); diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index c856992fbc96..91819f0239a6 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -939,7 +939,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdUnoTlb(const OUString& sFunctionName, "[automation bridge]IUnknownWrapper_Impl::" "invokeWithDispIdUnoTlb\n" "Could not create out parameter at index: " + - OUString::number((sal_Int32) i)); + OUString::number(static_cast(i))); } CComPtr pUnk(pParamObject->GetUnknown()); @@ -1020,7 +1020,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdUnoTlb(const OUString& sFunctionName, { if( pMethod->pParams[i].bOut ) { - OutParamIndex[outIndex]= (sal_Int16) i; + OutParamIndex[outIndex]= static_cast(i); Any outAny; if( !bJScriptObject) { @@ -1325,7 +1325,7 @@ uno::Any SAL_CALL IUnknownWrapper_Impl::directInvoke( const OUString& aName, con { throw InvocationTargetException( "[automation bridge] ITypeInfo::GetIDsOfNames returned error " - + OUString::number((sal_Int32) hr, 16), Reference(), Any()); + + OUString::number(static_cast(hr), 16), Reference(), Any()); } } @@ -1693,7 +1693,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, OUStringBuffer buf(256); buf.append("[automation bridge] There are too many arguments for this method"); throw IllegalArgumentException( buf.makeStringAndClear(), - Reference(), (sal_Int16) dispparams.cArgs); + Reference(), static_cast(dispparams.cArgs)); } //Set up the array of DISPIDs (DISPPARAMS::rgdispidNamedArgs) @@ -1775,7 +1775,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, { throw InvocationTargetException( "[automation bridge] ITypeInfo::GetIDsOfNames returned error " - + OUString::number((sal_Int32) hr, 16), Reference(), Any()); + + OUString::number(static_cast(hr), 16), Reference(), Any()); } } @@ -1786,7 +1786,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, arRefArgs = ptrRefArgs.get(); try { - for (i = 0; i < (sal_Int32) dispparams.cArgs; i++) + for (i = 0; i < static_cast(dispparams.cArgs); i++) { revIndex= dispparams.cArgs - i -1; arRefArgs[revIndex].byref=nullptr; @@ -1814,7 +1814,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, buf.append(OUString::number(i)); buf.append(" (index starting at 0)."); throw IllegalArgumentException( buf.makeStringAndClear(), - Reference(), (sal_Int16) i); + Reference(), static_cast(i)); } // Property Put arguments @@ -2008,7 +2008,7 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, } catch (IllegalArgumentException & e) { - e.ArgumentPosition = (sal_Int16)paramIndex; + e.ArgumentPosition = static_cast(paramIndex); throw; } catch (CannotConvertException & e) diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx index 95b0e69cab79..008396ae4f96 100644 --- a/extensions/source/ole/unoconversionutilities.hxx +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -554,15 +554,15 @@ void UnoConversionUtilities::variantToAny( const VARIANTARG* pArg, Any& rAny, throw CannotConvertException( "[automation bridge]UnoConversionUtilities::variantToAny \n" "Cannot convert the value of vartype :\"" + - OUString::number((sal_Int32) var.vt) + + OUString::number(static_cast(var.vt)) + "\" to the expected UNO type of type class: " + - OUString::number((sal_Int32) ptype.getTypeClass()), + OUString::number(static_cast(ptype.getTypeClass())), nullptr, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0); if (bFail) throw IllegalArgumentException( "[automation bridge]UnoConversionUtilities:variantToAny\n" - "The provided VARIANT of type\" " + OUString::number((sal_Int32) var.vt) + + "The provided VARIANT of type\" " + OUString::number(static_cast(var.vt)) + "\" is unappropriate for conversion!", Reference(), -1); } catch (const CannotConvertException &) @@ -630,14 +630,14 @@ void UnoConversionUtilities::anyToVariant(VARIANT* pVariant, const Any& rAny, "Cannot convert the value of type :\"" + rAny.getValueTypeName() + "\" to the expected Automation type of VARTYPE: " + - OUString::number((sal_Int32)type), + OUString::number(static_cast(type)), nullptr, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0); throw BridgeRuntimeError( "[automation bridge]UnoConversionUtilities::anyToVariant \n" "Conversion of any with " + rAny.getValueType().getTypeName() + - " to VARIANT with type: " + OUString::number((sal_Int32) type) + + " to VARIANT with type: " + OUString::number(static_cast(type)) + " failed! Error code: " + OUString::number(hr)); } diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index f3355d2acf21..4ae722cf2111 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -253,11 +253,11 @@ STDMETHODIMP InterfaceOleWrapper_Impl::GetIDsOfNames(REFIID /*riid*/, if (d.flags != 0) { m_MemberInfos.push_back(d); - iter = m_nameToDispIdMap.emplace(exactName, (DISPID)m_MemberInfos.size()).first; + iter = m_nameToDispIdMap.emplace(exactName, static_cast(m_MemberInfos.size())).first; if (exactName != name) { - iter = m_nameToDispIdMap.emplace(name, (DISPID)m_MemberInfos.size()).first; + iter = m_nameToDispIdMap.emplace(name, static_cast(m_MemberInfos.size())).first; } } } @@ -798,7 +798,7 @@ STDMETHODIMP InterfaceOleWrapper_Impl::Invoke(DISPID dispidMember, if( bHandled) return ret; - if ((dispidMember > 0) && ((size_t)dispidMember <= m_MemberInfos.size()) && m_xInvocation.is()) + if ((dispidMember > 0) && (static_cast(dispidMember) <= m_MemberInfos.size()) && m_xInvocation.is()) { MemberInfo d = m_MemberInfos[dispidMember - 1]; DWORD flags = wFlags & d.flags; diff --git a/extensions/source/scanner/scanwin.cxx b/extensions/source/scanner/scanwin.cxx index 02ce3425d01a..052eeebf9271 100644 --- a/extensions/source/scanner/scanwin.cxx +++ b/extensions/source/scanner/scanwin.cxx @@ -58,8 +58,8 @@ using namespace ::com::sun::star; #define PFUNC (*pDSM) #define PTWAINMSG MSG* -#define FIXTODOUBLE( nFix ) ((double)nFix.Whole+(double)nFix.Frac/65536.) -#define FIXTOLONG( nFix ) ((long)floor(FIXTODOUBLE(nFix)+0.5)) +#define FIXTODOUBLE( nFix ) (static_cast(nFix.Whole)+static_cast(nFix.Frac)/65536.) +#define FIXTOLONG( nFix ) (static_cast(floor(FIXTODOUBLE(nFix)+0.5))) #define TWAIN_FUNCNAME "DSM_Entry" #if defined(TWH_64BIT) diff --git a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx index ea7b2cd1ba86..c9071db403f6 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerEventHandler.cxx @@ -249,7 +249,7 @@ public: virtual void doRequest(const RequestRef& rRequest) override { const ::sal_Int32 nEventID = rRequest->getRequest(); - const ::sal_Int16 nControlID = rRequest->getArgumentOrDefault(PROP_CONTROL_ID, (::sal_Int16)0); + const ::sal_Int16 nControlID = rRequest->getArgumentOrDefault(PROP_CONTROL_ID, ::sal_Int16(0)); const css::uno::Reference< css::ui::dialogs::XFilePickerListener > xListener = rRequest->getArgumentOrDefault(PROP_PICKER_LISTENER, css::uno::Reference< css::ui::dialogs::XFilePickerListener >()); if ( ! xListener.is()) diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index 04a7b0530818..759228ffeae3 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -426,8 +426,8 @@ void VistaFilePickerImpl::impl_sta_CreateOpenDialog(const RequestRef& rRequest) iDialog->SetOptions ( nFlags ); - ::sal_Int32 nFeatures = rRequest->getArgumentOrDefault(PROP_FEATURES, (::sal_Int32)0); - ::sal_Int32 nTemplate = rRequest->getArgumentOrDefault(PROP_TEMPLATE_DESCR, (::sal_Int32)0); + ::sal_Int32 nFeatures = rRequest->getArgumentOrDefault(PROP_FEATURES, ::sal_Int32(0)); + ::sal_Int32 nTemplate = rRequest->getArgumentOrDefault(PROP_TEMPLATE_DESCR, ::sal_Int32(0)); impl_sta_enableFeatures(nFeatures, nTemplate); VistaFilePickerEventHandler* pHandlerImpl = static_cast(iHandler.get()); @@ -463,8 +463,8 @@ void VistaFilePickerImpl::impl_sta_CreateSaveDialog(const RequestRef& rRequest) iDialog->SetOptions ( nFlags ); - ::sal_Int32 nFeatures = rRequest->getArgumentOrDefault(PROP_FEATURES, (::sal_Int32)0); - ::sal_Int32 nTemplate = rRequest->getArgumentOrDefault(PROP_TEMPLATE_DESCR, (::sal_Int32)0); + ::sal_Int32 nFeatures = rRequest->getArgumentOrDefault(PROP_FEATURES, ::sal_Int32(0)); + ::sal_Int32 nTemplate = rRequest->getArgumentOrDefault(PROP_TEMPLATE_DESCR, ::sal_Int32(0)); css::uno::Reference xWindow = rRequest->getArgumentOrDefault(PROP_PARENT_WINDOW, css::uno::Reference()); if(xWindow.is()) { diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx index f0cf32b8d0c9..6f8af44c358a 100644 --- a/fpicker/source/win32/folderpicker/MtaFop.cxx +++ b/fpicker/source/win32/folderpicker/MtaFop.cxx @@ -480,7 +480,7 @@ void CMtaFolderPicker::onInitialized( ) SendMessageW( m_hwnd, BFFM_SETSELECTION, - (WPARAM)false, + WPARAM(false), reinterpret_cast(lpiidDisplayDir) ); releaseItemIdList( lpiidDisplayDir ); diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index f4b809f48a33..d20c1b8ea783 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -547,7 +547,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) } #ifdef _WIN32 int j; - for(j = 0 ; j < (int)strlen( dirname ) ; j++) + for(j = 0 ; j < static_cast(strlen( dirname )) ; j++) { if( dirname[j] == '\\' ) buf[j] = '/'; else buf[j] = dirname[j]; diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index ab51add16edb..671ce5634f82 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -531,7 +531,7 @@ static void do_msvcr_magic(OUString const &jvm_dll) if (fread(dos_hdr, st.st_size, 1, f) != 1 || memcmp(dos_hdr, "MZ", 2) != 0 || dos_hdr->e_lfanew < 0 || - dos_hdr->e_lfanew > (LONG) (st.st_size - sizeof(IMAGE_NT_HEADERS))) + dos_hdr->e_lfanew > static_cast(st.st_size - sizeof(IMAGE_NT_HEADERS))) { SAL_WARN("jfw", "analyzing <" << Module << "> failed"); free(dos_hdr); @@ -570,7 +570,7 @@ static void do_msvcr_magic(OUString const &jvm_dll) while (imports <= reinterpret_cast(reinterpret_cast(dos_hdr) + st.st_size - sizeof (IMAGE_IMPORT_DESCRIPTOR)) && imports->Name != 0 && - imports->Name + VAtoPhys < (DWORD) st.st_size) + imports->Name + VAtoPhys < static_cast(st.st_size)) { static OUStringLiteral msvcrts[] = { diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx index e5a6e5873e68..160d4e7d0207 100644 --- a/sal/osl/w32/backtrace.cxx +++ b/sal/osl/w32/backtrace.cxx @@ -61,11 +61,11 @@ OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth) for( sal_uInt32 i = 0; i < nFrames; i++ ) { SymFromAddr( hProcess, reinterpret_cast(aStack[ i ]), nullptr, pSymbol ); - aBuf.append( (sal_Int32)(nFrames - i - 1) ); + aBuf.append( static_cast(nFrames - i - 1) ); aBuf.append( ": " ); aBuf.appendAscii( pSymbol->Name ); aBuf.append( " - 0x" ); - aBuf.append( (sal_Int64)pSymbol->Address, 16 ); + aBuf.append( static_cast(pSymbol->Address), 16 ); aBuf.append( "\n" ); } @@ -107,11 +107,11 @@ OUString sal::backtrace_to_string(BacktraceState* backtraceState) for( int i = 0; i < nFrames; i++ ) { SymFromAddr( hProcess, reinterpret_cast(backtraceState->buffer[ i ]), nullptr, pSymbol ); - aBuf.append( (sal_Int32)(nFrames - i - 1) ); + aBuf.append( static_cast(nFrames - i - 1) ); aBuf.append( ": " ); aBuf.appendAscii( pSymbol->Name ); aBuf.append( " - 0x" ); - aBuf.append( (sal_Int64)pSymbol->Address, 16 ); + aBuf.append( static_cast(pSymbol->Address), 16 ); aBuf.append( "\n" ); } diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx index 77d16e9fb5d4..ffdaeb80dac9 100644 --- a/sal/osl/w32/dllentry.cxx +++ b/sal/osl/w32/dllentry.cxx @@ -216,7 +216,7 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ) { DWORD dwThreadId = 0; - DWORD_PTR dwParentProcessId = (DWORD_PTR)_wtol( szBuffer ); + DWORD_PTR dwParentProcessId = static_cast(_wtol( szBuffer )); if ( dwParentProcessId && GetParentProcessId() == dwParentProcessId ) { diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx index 1a08315742ba..aed1b315bb9e 100644 --- a/sal/osl/w32/file.cxx +++ b/sal/osl/w32/file.cxx @@ -253,7 +253,7 @@ oslFileError FileHandle_Impl::setPos(sal_uInt64 uPos) sal_uInt64 FileHandle_Impl::getSize() const { - LONGLONG bufend = std::max((LONGLONG)0, m_bufptr) + m_buflen; + LONGLONG bufend = std::max(LONGLONG(0), m_bufptr) + m_buflen; return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend)); } @@ -407,7 +407,7 @@ oslFileError FileHandle_Impl::readFileAt( return osl_File_E_None; } - SIZE_T const bytes = std::min(m_buflen - bufpos, (SIZE_T) nBytesRequested); + SIZE_T const bytes = std::min(m_buflen - bufpos, static_cast(nBytesRequested)); memcpy(&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes); nBytesRequested -= bytes; *pBytesRead += bytes; @@ -482,7 +482,7 @@ oslFileError FileHandle_Impl::writeFileAt( m_buflen = sal::static_int_cast< SIZE_T >(uDone); } - SIZE_T const bytes = std::min(m_bufsiz - bufpos, (SIZE_T) nBytesToWrite); + SIZE_T const bytes = std::min(m_bufsiz - bufpos, static_cast(nBytesToWrite)); memcpy(&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes); nBytesToWrite -= bytes; *pBytesWritten += bytes; diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx index d59932e315fc..1ae8d33c0b78 100644 --- a/sal/osl/w32/file_dirvol.cxx +++ b/sal/osl/w32/file_dirvol.cxx @@ -57,7 +57,7 @@ BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime) { __int64 timeValue; - __int64 localTime = cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100; + __int64 localTime = cpTimeVal->Seconds*__int64(10000000)+cpTimeVal->Nanosec/100; osl::detail::setFiletime(FTime, localTime); fSuccess = 0 <= (timeValue= osl::detail::getFiletime(BaseFileTime) + osl::detail::getFiletime(FTime)); if (fSuccess) @@ -89,8 +89,8 @@ BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal) if ( fSuccess ) { - pTimeVal->Seconds = (unsigned long) (Value / 10000000L); - pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100); + pTimeVal->Seconds = static_cast(Value / 10000000L); + pTimeVal->Nanosec = static_cast((Value % 10000000L) * 100); } } return fSuccess; @@ -1630,7 +1630,7 @@ oslFileError SAL_CALL osl_getFileStatus( pStatus->uAttributes = pItemImpl->FindData.dwFileAttributes; pStatus->uValidFields |= osl_FileStatus_Mask_Attributes; - pStatus->uFileSize = (sal_uInt64)pItemImpl->FindData.nFileSizeLow + ((sal_uInt64)pItemImpl->FindData.nFileSizeHigh << 32); + pStatus->uFileSize = static_cast(pItemImpl->FindData.nFileSizeLow) + (static_cast(pItemImpl->FindData.nFileSizeHigh) << 32); pStatus->uValidFields |= osl_FileStatus_Mask_FileSize; if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL ) @@ -1685,7 +1685,7 @@ oslFileError SAL_CALL osl_setFileAttributes( dwFileAttributes = GetFileAttributesW( o3tl::toW(rtl_uString_getStr(ustrSysPath)) ); - if ( (DWORD)-1 != dwFileAttributes ) + if ( DWORD(-1) != dwFileAttributes ) { dwFileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN); diff --git a/sal/osl/w32/file_error.cxx b/sal/osl/w32/file_error.cxx index da71664b6fdb..5336c17fd970 100644 --- a/sal/osl/w32/file_error.cxx +++ b/sal/osl/w32/file_error.cxx @@ -103,7 +103,7 @@ oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError) for (i = 0; i < n; ++i ) { if (dwError == errtable[i].oscode) - return (oslFileError)(errtable[i].errnocode); + return static_cast(errtable[i].errnocode); } /* The error code wasn't in the table. We check for a range of diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx index f89f2033e168..9b5cb51b110a 100644 --- a/sal/osl/w32/file_url.cxx +++ b/sal/osl/w32/file_url.cxx @@ -513,7 +513,7 @@ static bool osl_decodeURL_( rtl_String* strUTF8, rtl_uString** pstrDecodedURL ) aToken[1] = *pSrc++; aToken[2] = 0; - aChar = (sal_Char)strtoul( aToken, nullptr, 16 ); + aChar = static_cast(strtoul( aToken, nullptr, 16 )); /* The chars are path delimiters and must not be encoded */ @@ -575,7 +575,7 @@ static void osl_encodeURL_( rtl_uString *strURL, rtl_String **pstrEncodedURL ) default: if (!( ( cCurrent >= 'a' && cCurrent <= 'z' ) || ( cCurrent >= 'A' && cCurrent <= 'Z' ) || ( cCurrent >= '0' && cCurrent <= '9' ) ) ) { - sprintf( pURLDest, "%%%02X", (unsigned char)cCurrent ); + sprintf( pURLDest, "%%%02X", static_cast(cCurrent) ); pURLDest += 3; break; } diff --git a/sal/osl/w32/nlsupport.cxx b/sal/osl/w32/nlsupport.cxx index 5c937ed6de39..1de8cb780dd1 100644 --- a/sal/osl/w32/nlsupport.cxx +++ b/sal/osl/w32/nlsupport.cxx @@ -56,7 +56,7 @@ struct EnumLocalesParams LCID Locale; }; -static DWORD g_dwTLSLocaleEncId = (DWORD) -1; +static DWORD g_dwTLSLocaleEncId = DWORD(-1); /***************************************************************************** * callback function test @@ -148,14 +148,14 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale ) struct EnumLocalesParams params = { L"", L"", 0 }; /* initialise global TLS id */ - if( (DWORD) -1 == g_dwTLSLocaleEncId ) + if( DWORD(-1) == g_dwTLSLocaleEncId ) { oslMutex globalMutex = * osl_getGlobalMutex(); /* initializing must be thread save */ osl_acquireMutex( globalMutex ); - if( (DWORD) -1 == g_dwTLSLocaleEncId ) + if( DWORD(-1) == g_dwTLSLocaleEncId ) g_dwTLSLocaleEncId = TlsAlloc(); osl_releaseMutex( globalMutex ); diff --git a/sal/osl/w32/pipe.cxx b/sal/osl/w32/pipe.cxx index febc4f19c562..b61526f3edf6 100644 --- a/sal/osl/w32/pipe.cxx +++ b/sal/osl/w32/pipe.cxx @@ -386,7 +386,7 @@ sal_Int32 SAL_CALL osl_receivePipe(oslPipe pPipe, if (lastError == ERROR_PIPE_NOT_CONNECTED) nBytes = 0; else - nBytes = (DWORD) -1; + nBytes = DWORD(-1); pPipe->m_Error = osl_Pipe_E_ConnectionAbort; } @@ -415,7 +415,7 @@ sal_Int32 SAL_CALL osl_sendPipe(oslPipe pPipe, if (GetLastError() == ERROR_PIPE_NOT_CONNECTED) nBytes = 0; else - nBytes = (DWORD) -1; + nBytes = DWORD(-1); pPipe->m_Error = osl_Pipe_E_ConnectionAbort; } diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index e17d43a787a5..897b88a1767e 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -147,7 +147,7 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident) { oslProcessImpl* pProcImpl; HANDLE hProcess = OpenProcess( - STANDARD_RIGHTS_REQUIRED | PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, (DWORD)Ident); + STANDARD_RIGHTS_REQUIRED | PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, static_cast(Ident)); if (hProcess) { @@ -222,7 +222,7 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F lpAddress = static_cast(lpAddress) + Info.RegionSize; } - while (reinterpret_cast(lpAddress) <= (uintptr_t)0x7FFFFFFF); // 2GB address space + while (reinterpret_cast(lpAddress) <= uintptr_t(0x7FFFFFFF)); // 2GB address space pInfo->Fields |= osl_Process_HEAPUSAGE; } @@ -237,12 +237,12 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F __int64 Value; Value = osl::detail::getFiletime(UserTime); - pInfo->UserTime.Seconds = (unsigned long) (Value / 10000000L); - pInfo->UserTime.Nanosec = (unsigned long)((Value % 10000000L) * 100); + pInfo->UserTime.Seconds = static_cast(Value / 10000000L); + pInfo->UserTime.Nanosec = static_cast((Value % 10000000L) * 100); Value = osl::detail::getFiletime(KernelTime); - pInfo->SystemTime.Seconds = (unsigned long) (Value / 10000000L); - pInfo->SystemTime.Nanosec = (unsigned long)((Value % 10000000L) * 100); + pInfo->SystemTime.Seconds = static_cast(Value / 10000000L); + pInfo->SystemTime.Nanosec = static_cast((Value % 10000000L) * 100); pInfo->Fields |= osl_Process_CPUTIMES; } diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx index d4e0ed6e5dbb..b9fd1dc6e646 100644 --- a/sal/osl/w32/profile.cxx +++ b/sal/osl/w32/profile.cxx @@ -1207,7 +1207,7 @@ static bool getLine(osl_TFile* pFile, sal_Char *pszLine, int MaxLen) (pChr < (pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf) - 1)); pChr++); - Max = min((int) (pChr - pFile->m_pReadPtr), MaxLen); + Max = min(static_cast(pChr - pFile->m_pReadPtr), MaxLen); memcpy(pLine, pFile->m_pReadPtr, Max); MaxLen -= Max; pLine += Max; diff --git a/sal/osl/w32/security.cxx b/sal/osl/w32/security.cxx index 986afc83412e..8192dbbb6ded 100644 --- a/sal/osl/w32/security.cxx +++ b/sal/osl/w32/security.cxx @@ -329,21 +329,21 @@ sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent) { dwSidSize+=wsprintfW(o3tl::toW(Ident) + wcslen(o3tl::toW(Ident)), L"0x%02hx%02hx%02hx%02hx%02hx%02hx", - (USHORT)psia->Value[0], - (USHORT)psia->Value[1], - (USHORT)psia->Value[2], - (USHORT)psia->Value[3], - (USHORT)psia->Value[4], - (USHORT)psia->Value[5]); + static_cast(psia->Value[0]), + static_cast(psia->Value[1]), + static_cast(psia->Value[2]), + static_cast(psia->Value[3]), + static_cast(psia->Value[4]), + static_cast(psia->Value[5])); } else { dwSidSize+=wsprintfW(o3tl::toW(Ident) + wcslen(o3tl::toW(Ident)), L"%lu", - (ULONG)(psia->Value[5] ) + - (ULONG)(psia->Value[4] << 8) + - (ULONG)(psia->Value[3] << 16) + - (ULONG)(psia->Value[2] << 24) ); + static_cast(psia->Value[5] ) + + static_cast(psia->Value[4] << 8) + + static_cast(psia->Value[3] << 16) + + static_cast(psia->Value[2] << 24) ); } /* loop through SidSubAuthorities */ diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx index a369d7ab8d87..bf27bba1a04d 100644 --- a/sal/osl/w32/socket.cxx +++ b/sal/osl/w32/socket.cxx @@ -65,18 +65,18 @@ static DWORD FamilyMap[]= { static oslAddrFamily osl_AddrFamilyFromNative(DWORD nativeType) { - oslAddrFamily i= (oslAddrFamily) 0; + oslAddrFamily i= oslAddrFamily(0); while(i != osl_Socket_FamilyInvalid) { if(FamilyMap[i] == nativeType) return i; - i = (oslAddrFamily) ( (int)i + 1); + i = static_cast( static_cast(i) + 1); } return i; } #define FAMILY_FROM_NATIVE(y) osl_AddrFamilyFromNative(y) -#define FAMILY_TO_NATIVE(x) (short)FamilyMap[x] +#define FAMILY_TO_NATIVE(x) static_cast(FamilyMap[x]) static DWORD ProtocolMap[]= { 0, /* osl_Socket_FamilyInet */ @@ -99,12 +99,12 @@ static DWORD TypeMap[]= { static oslSocketType osl_SocketTypeFromNative(DWORD nativeType) { - oslSocketType i= (oslSocketType)0; + oslSocketType i= oslSocketType(0); while(i != osl_Socket_TypeInvalid) { if(TypeMap[i] == nativeType) return i; - i = (oslSocketType)((int)i+1); + i = static_cast(static_cast(i)+1); } return i; } @@ -197,14 +197,14 @@ static int SocketError[]= { static oslSocketError osl_SocketErrorFromNative(int nativeType) { - oslSocketError i= (oslSocketError)0; + oslSocketError i= oslSocketError(0); while(i != osl_Socket_E_InvalidError) { if(SocketError[i] == nativeType) return i; - i = (oslSocketError)( (int) i + 1); + i = static_cast( static_cast(i) + 1); } return i; } @@ -263,7 +263,7 @@ static oslSocketAddr createSocketAddrWithFamily( pInetAddr->sin_family = FAMILY_TO_NATIVE(osl_Socket_FamilyInet); pInetAddr->sin_addr.s_addr = nAddr; - pInetAddr->sin_port = (sal_uInt16)(port&0xffff); + pInetAddr->sin_port = static_cast(port&0xffff); break; } default: @@ -394,7 +394,7 @@ oslSocketAddr SAL_CALL osl_createInetBroadcastAddr ( } oslSocketAddr pAddr = - createSocketAddrWithFamily( osl_Socket_FamilyInet, htons( (sal_uInt16) Port), nAddr ); + createSocketAddrWithFamily( osl_Socket_FamilyInet, htons( static_cast(Port)), nAddr ); return pAddr; } @@ -411,7 +411,7 @@ oslSocketAddr SAL_CALL osl_createInetSocketAddr ( oslSocketAddr pAddr = nullptr; if(Addr != OSL_INADDR_NONE) { - pAddr = createSocketAddrWithFamily( osl_Socket_FamilyInet, htons( (sal_uInt16)Port), Addr ); + pAddr = createSocketAddrWithFamily( osl_Socket_FamilyInet, htons( static_cast(Port)), Addr ); } return pAddr; } @@ -723,7 +723,7 @@ sal_Bool SAL_CALL osl_setInetPortOfSocketAddr ( if (pSystemInetAddr->sin_family != FAMILY_TO_NATIVE(osl_Socket_FamilyInet)) return false; - pSystemInetAddr->sin_port= htons((short)Port); + pSystemInetAddr->sin_port= htons(static_cast(Port)); return true; } diff --git a/sal/osl/w32/thread.cxx b/sal/osl/w32/thread.cxx index 1e347dc3ebd5..716e299f2a50 100644 --- a/sal/osl/w32/thread.cxx +++ b/sal/osl/w32/thread.cxx @@ -134,9 +134,9 @@ oslThreadIdentifier SAL_CALL osl_getThreadIdentifier(oslThread Thread) osl_TThreadImpl* pThreadImpl= static_cast(Thread); if (pThreadImpl != nullptr) - return (oslThreadIdentifier)pThreadImpl->m_ThreadId; + return static_cast(pThreadImpl->m_ThreadId); else - return (oslThreadIdentifier)GetCurrentThreadId(); + return static_cast(GetCurrentThreadId()); } void SAL_CALL osl_destroyThread(oslThread Thread) @@ -366,7 +366,7 @@ void SAL_CALL osl_setThreadName(char const * name) { #pragma pack(pop) info.dwType = 0x1000; info.szName = name; - info.dwThreadID = (DWORD) -1; + info.dwThreadID = DWORD(-1); info.dwFlags = 0; __try { RaiseException( @@ -453,7 +453,7 @@ oslThreadKey SAL_CALL osl_createThreadKey(oslThreadKeyCallbackFunction pCallback if ( pTls ) { pTls->pfnCallback = pCallback; - if ( (DWORD)-1 == (pTls->dwIndex = TlsAlloc()) ) + if ( DWORD(-1) == (pTls->dwIndex = TlsAlloc()) ) { rtl_freeMemory( pTls ); pTls = nullptr; @@ -511,7 +511,7 @@ sal_Bool SAL_CALL osl_setThreadKeyData(oslThreadKey Key, void *pData) return false; } -DWORD g_dwTLSTextEncodingIndex = (DWORD)-1; +DWORD g_dwTLSTextEncodingIndex = DWORD(-1); rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void) { @@ -519,7 +519,7 @@ rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void) rtl_TextEncoding _encoding; BOOL gotACP; - if ( (DWORD)-1 == g_dwTLSTextEncodingIndex ) + if ( DWORD(-1) == g_dwTLSTextEncodingIndex ) g_dwTLSTextEncodingIndex = TlsAlloc(); dwEncoding = reinterpret_cast(TlsGetValue( g_dwTLSTextEncodingIndex )); @@ -529,7 +529,7 @@ rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding(void) if ( !gotACP ) { _encoding = rtl_getTextEncodingFromWindowsCodePage( GetACP() ); - TlsSetValue( g_dwTLSTextEncodingIndex, reinterpret_cast((DWORD_PTR)MAKELONG( _encoding, TRUE )) ); + TlsSetValue( g_dwTLSTextEncodingIndex, reinterpret_cast(static_cast(MAKELONG( _encoding, TRUE ))) ); } return _encoding; @@ -539,7 +539,7 @@ rtl_TextEncoding SAL_CALL osl_setThreadTextEncoding( rtl_TextEncoding Encoding ) { rtl_TextEncoding oldEncoding = osl_getThreadTextEncoding(); - TlsSetValue( g_dwTLSTextEncodingIndex, reinterpret_cast((DWORD_PTR)MAKELONG( Encoding, TRUE)) ); + TlsSetValue( g_dwTLSTextEncodingIndex, reinterpret_cast(static_cast(MAKELONG( Encoding, TRUE))) ); return oldEncoding; } diff --git a/sal/osl/w32/time.cxx b/sal/osl/w32/time.cxx index 51f05ab30a4c..d1284b663fae 100644 --- a/sal/osl/w32/time.cxx +++ b/sal/osl/w32/time.cxx @@ -70,8 +70,8 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal) Value = *reinterpret_cast<__int64 *>(&CurTime) - *reinterpret_cast<__int64 *>(&OffTime); - pTimeVal->Seconds = (unsigned long) (Value / 10000000L); - pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100); + pTimeVal->Seconds = static_cast(Value / 10000000L); + pTimeVal->Nanosec = static_cast((Value % 10000000L) * 100); return true; } @@ -143,9 +143,9 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVa if ( Success== TIME_ZONE_ID_DAYLIGHT ) bias+=aTimeZoneInformation.DaylightBias; - if ( (sal_Int64) pSystemTimeVal->Seconds > ( bias * 60 ) ) + if ( static_cast(pSystemTimeVal->Seconds) > ( bias * 60 ) ) { - pLocalTimeVal->Seconds = (sal_uInt32) (pSystemTimeVal->Seconds - ( bias * 60) ); + pLocalTimeVal->Seconds = static_cast(pSystemTimeVal->Seconds - ( bias * 60) ); pLocalTimeVal->Nanosec = pSystemTimeVal->Nanosec; return true; @@ -170,9 +170,9 @@ sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal if ( Success== TIME_ZONE_ID_DAYLIGHT ) bias+=aTimeZoneInformation.DaylightBias; - if ( (sal_Int64) pLocalTimeVal->Seconds + ( bias * 60 ) > 0 ) + if ( static_cast(pLocalTimeVal->Seconds) + ( bias * 60 ) > 0 ) { - pSystemTimeVal->Seconds = (sal_uInt32) ( pLocalTimeVal->Seconds + ( bias * 60) ); + pSystemTimeVal->Seconds = static_cast( pLocalTimeVal->Seconds + ( bias * 60) ); pSystemTimeVal->Nanosec = pLocalTimeVal->Nanosec; return true; @@ -195,9 +195,9 @@ sal_uInt32 SAL_CALL osl_getGlobalTimer(void) _ftime( ¤tTime ); - nSeconds = (sal_uInt32)( currentTime.time - startTime.time ); + nSeconds = static_cast( currentTime.time - startTime.time ); - return ( nSeconds * 1000 ) + (long)( currentTime.millitm - startTime.millitm ); + return ( nSeconds * 1000 ) + static_cast( currentTime.millitm - startTime.millitm ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 7a1d60b5c780..5d7ebe2905dc 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -488,7 +488,7 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, psia=GetSidIdentifierAuthority(pSid); /* obtain sidsubauthority count */ - dwSubAuthorities=std::min((int) *GetSidSubAuthorityCount(pSid), 5); + dwSubAuthorities=std::min(static_cast(*GetSidSubAuthorityCount(pSid)), 5); /* buffer length: S-SID_REVISION- + identifierauthority- + subauthorities- + NULL */ Ident=static_cast(malloc(88*sizeof(wchar_t))); @@ -501,21 +501,21 @@ void MyTestPlugInImpl::initialize( CPPUNIT_NS::TestFactoryRegistry *, { dwSidSize+=wsprintfW(Ident + wcslen(Ident), L"0x%02hx%02hx%02hx%02hx%02hx%02hx", - (sal_uInt16)psia->Value[0], - (sal_uInt16)psia->Value[1], - (sal_uInt16)psia->Value[2], - (sal_uInt16)psia->Value[3], - (sal_uInt16)psia->Value[4], - (sal_uInt16)psia->Value[5]); + static_cast(psia->Value[0]), + static_cast(psia->Value[1]), + static_cast(psia->Value[2]), + static_cast(psia->Value[3]), + static_cast(psia->Value[4]), + static_cast(psia->Value[5])); } else { dwSidSize+=wsprintfW(Ident + wcslen(Ident), L"%lu", - (sal_uInt32)(psia->Value[5] ) + - (sal_uInt32)(psia->Value[4] << 8) + - (sal_uInt32)(psia->Value[3] << 16) + - (sal_uInt32)(psia->Value[2] << 24) ); + static_cast(psia->Value[5] ) + + static_cast(psia->Value[4] << 8) + + static_cast(psia->Value[3] << 16) + + static_cast(psia->Value[2] << 24) ); } /* loop through SidSubAuthorities */ diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx index 2d1d17c1378b..0ea1a39167ea 100644 --- a/sal/rtl/alloc_arena.cxx +++ b/sal/rtl/alloc_arena.cxx @@ -1062,7 +1062,7 @@ void * rtl_machdep_alloc( #if defined(SAL_UNX) addr = mmap (nullptr, static_cast(size), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); #elif defined(_WIN32) - addr = VirtualAlloc (nullptr, (SIZE_T)size, MEM_COMMIT, PAGE_READWRITE); + addr = VirtualAlloc (nullptr, static_cast(size), MEM_COMMIT, PAGE_READWRITE); #endif /* (SAL_UNX || _WIN32) */ if (addr != MAP_FAILED) @@ -1092,7 +1092,7 @@ void rtl_machdep_free( #if defined(SAL_UNX) (void) munmap(pAddr, nSize); #elif defined(_WIN32) - (void) VirtualFree (pAddr, (SIZE_T)0, MEM_RELEASE); + (void) VirtualFree (pAddr, SIZE_T(0), MEM_RELEASE); #endif /* (SAL_UNX || _WIN32) */ } @@ -1107,7 +1107,7 @@ sal_Size rtl_machdep_pagesize() #elif defined(_WIN32) SYSTEM_INFO info; GetSystemInfo (&info); - return (sal_Size)info.dwPageSize; + return static_cast(info.dwPageSize); #endif /* (SAL_UNX || _WIN32) */ } diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx index a753b2060d20..56357d25ac38 100644 --- a/sal/rtl/alloc_cache.cxx +++ b/sal/rtl/alloc_cache.cxx @@ -1252,7 +1252,7 @@ static void rtl_cache_wsupdate_wait(unsigned int seconds) if (seconds > 0) { RTL_MEMORY_LOCK_RELEASE(&(g_cache_list.m_lock)); - WaitForSingleObject (g_cache_list.m_update_cond, (DWORD)(seconds * 1000)); + WaitForSingleObject (g_cache_list.m_update_cond, static_cast(seconds * 1000)); RTL_MEMORY_LOCK_ACQUIRE(&(g_cache_list.m_lock)); } } diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx index 28f0857986ac..d943f5af9a38 100644 --- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx @@ -555,7 +555,7 @@ PDFEntry* PDFReader::read( const char* pBuffer, unsigned int nLen ) aGrammar, boost::spirit::space_p ); #if OSL_DEBUG_LEVEL > 0 - SAL_INFO("sdext.pdfimport.pdfparse", "parseinfo: stop = " << aInfo.stop << " (buff=" << pBuffer << ", offset = " << aInfo.stop - pBuffer << "), hit = " << (aInfo.hit ? OUString("true") : OUString("false")) << ", full = " << (aInfo.full ? OUString("true") : OUString("false")) << ", length = " << (int)aInfo.length ); + SAL_INFO("sdext.pdfimport.pdfparse", "parseinfo: stop = " << aInfo.stop << " (buff=" << pBuffer << ", offset = " << aInfo.stop - pBuffer << "), hit = " << (aInfo.hit ? OUString("true") : OUString("false")) << ", full = " << (aInfo.full ? OUString("true") : OUString("false")) << ", length = " << static_cast(aInfo.length) ); #endif } catch( const parser_error& rError ) @@ -602,7 +602,7 @@ PDFEntry* PDFReader::read( const char* pFileName ) if( fp ) { fseek( fp, 0, SEEK_END ); - unsigned int nLen = (unsigned int)ftell( fp ); + unsigned int nLen = static_cast(ftell( fp )); fseek( fp, 0, SEEK_SET ); char* pBuf = static_cast(rtl_allocateMemory( nLen )); if( pBuf ) diff --git a/setup_native/source/win32/customactions/sellang/sellang.cxx b/setup_native/source/win32/customactions/sellang/sellang.cxx index 419bf385d02e..aaf8e3ffe7b3 100644 --- a/setup_native/source/win32/customactions/sellang/sellang.cxx +++ b/setup_native/source/win32/customactions/sellang/sellang.cxx @@ -175,7 +175,7 @@ enum_ui_lang_proc (LPTSTR language, LONG_PTR /* unused_lParam */) long langid = strtol(language, nullptr, 16); if (langid > 0xFFFF) return TRUE; - add_ui_lang(langid_to_string((LANGID) langid)); + add_ui_lang(langid_to_string(static_cast(langid))); if (num_ui_langs == SAL_N_ELEMENTS(ui_langs) ) return FALSE; return TRUE; diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index d91b7c3f05b9..01db07340973 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -640,7 +640,7 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis) HBRUSH hbrIcon = CreateSolidBrush( GetSysColor( COLOR_GRAYTEXT ) ); - DrawStateW( lpdis->hDC, hbrIcon, nullptr, reinterpret_cast(hIcon), (WPARAM)0, x, y+(height-cy)/2, 0, 0, DST_ICON | (fDisabled ? (fSelected ? DSS_MONO : DSS_DISABLED) : DSS_NORMAL) ); + DrawStateW( lpdis->hDC, hbrIcon, nullptr, reinterpret_cast(hIcon), WPARAM(0), x, y+(height-cy)/2, 0, 0, DST_ICON | (fDisabled ? (fSelected ? DSS_MONO : DSS_DISABLED) : DSS_NORMAL) ); DeleteObject( hbrIcon ); @@ -663,7 +663,7 @@ void OnDrawItem(HWND /*hwnd*/, LPDRAWITEMSTRUCT lpdis) SIZE size; GetTextExtentPointW( lpdis->hDC, o3tl::toW(pMyItem->text.getStr()), pMyItem->text.getLength(), &size ); - DrawStateW( lpdis->hDC, nullptr, nullptr, reinterpret_cast(pMyItem->text.getStr()), (WPARAM)0, aRect.left, aRect.top + (height - size.cy)/2, 0, 0, DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ); + DrawStateW( lpdis->hDC, nullptr, nullptr, reinterpret_cast(pMyItem->text.getStr()), WPARAM(0), aRect.left, aRect.top + (height - size.cy)/2, 0, 0, DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ); // Restore the original font and colors. DeleteObject( SelectObject( lpdis->hDC, hbrOld ) ); diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx index a4e4d63e5a53..644aa40c687c 100644 --- a/shell/source/win32/SysShExec.cxx +++ b/shell/source/win32/SysShExec.cxx @@ -143,7 +143,7 @@ namespace for ( i = 0; i < ERRTABLESIZE; ++i ) { if ( dwError == errtable[i].oscode ) - return (oslFileError)errtable[i].errnocode; + return static_cast(errtable[i].errnocode); } /* The error code wasn't in the table. We check for a range of */ diff --git a/shell/source/win32/shlxthandler/infotips/infotips.cxx b/shell/source/win32/shlxthandler/infotips/infotips.cxx index 682fb3478eef..088eb8e5a983 100644 --- a/shell/source/win32/shlxthandler/infotips/infotips.cxx +++ b/shell/source/win32/shlxthandler/infotips/infotips.cxx @@ -150,7 +150,7 @@ std::wstring formatSizeOfFile( DWORD dwSize ) char *buffer=nullptr; int decimal, sign; - double dFileSize = (double)dwSize/KB; + double dFileSize = static_cast(dwSize)/KB; buffer = _fcvt( dFileSize, 1, &decimal, &sign ); diff --git a/shell/source/win32/shlxthandler/ooofilt/propspec.cxx b/shell/source/win32/shlxthandler/ooofilt/propspec.cxx index 88a194e9a603..222c9342d9ea 100644 --- a/shell/source/win32/shlxthandler/ooofilt/propspec.cxx +++ b/shell/source/win32/shlxthandler/ooofilt/propspec.cxx @@ -149,7 +149,7 @@ BOOL CFullPropSpec::SetProperty( WCHAR const * wcsProperty ) CoTaskMemFree( _psProperty.lpwstr ); } _psProperty.ulKind = PRSPEC_LPWSTR; - int len = (int) ( (wcslen( wcsProperty ) + 1) * sizeof( WCHAR ) ); + int len = static_cast( (wcslen( wcsProperty ) + 1) * sizeof( WCHAR ) ); _psProperty.lpwstr = static_cast(CoTaskMemAlloc( len )); if ( nullptr != _psProperty.lpwstr ) { diff --git a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx index 3c734be76fe4..0d0e475ef678 100644 --- a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx +++ b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx @@ -59,7 +59,7 @@ unsigned long BufferStream::sread (unsigned char *buf, unsigned long size) if (hr == S_OK) return newsize; else - return (unsigned long)0; + return static_cast(0); } long BufferStream::stell () @@ -72,7 +72,7 @@ long BufferStream::stell () hr = stream->Seek (Move, STREAM_SEEK_CUR, &NewPosition); if (hr == S_OK) - return (long) NewPosition.QuadPart; + return static_cast(NewPosition.QuadPart); else return -1; } @@ -82,7 +82,7 @@ long BufferStream::sseek (long offset, int origin) HRESULT hr; LARGE_INTEGER Move; DWORD dwOrigin; - Move.QuadPart = (__int64)offset; + Move.QuadPart = static_cast<__int64>(offset); switch (origin) { diff --git a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx index dd71a44f2390..655f1c6cadde 100644 --- a/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx +++ b/shell/source/win32/shlxthandler/prophdl/propertyhdl.cxx @@ -285,7 +285,7 @@ void CPropertyHdl::LoadProperties( CMetaInfoReader *pMetaInfoReader ) OutputDebugStringFormatW( L"CPropertyHdl: LoadProperties\n" ); PROPVARIANT propvarValues; - for ( UINT i = 0; i < (UINT)gPropertyMapTableSize; ++i ) + for ( UINT i = 0; i < UINT(gPropertyMapTableSize); ++i ) { PropVariantClear( &propvarValues ); HRESULT hr = GetItemData( pMetaInfoReader, i, &propvarValues); diff --git a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx index 4fe52c351bc9..87a125a21b1a 100644 --- a/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx +++ b/shell/source/win32/shlxthandler/thumbviewer/thumbviewer.cxx @@ -194,7 +194,7 @@ HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Read(void *pv, ULONG cb, ULONG *pcb HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *) { - __int64 size = (__int64) ref_zip_buffer_.size(); + __int64 size = static_cast<__int64>(ref_zip_buffer_.size()); __int64 p = 0; switch (dwOrigin) @@ -202,7 +202,7 @@ HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Seek(LARGE_INTEGER dlibMove, DWORD case STREAM_SEEK_SET: break; case STREAM_SEEK_CUR: - p = (__int64) pos_; + p = static_cast<__int64>(pos_); break; case STREAM_SEEK_END: p = size - 1; @@ -215,7 +215,7 @@ HRESULT STDMETHODCALLTYPE StreamOnZipBuffer::Seek(LARGE_INTEGER dlibMove, DWORD if ( ( p >= 0 ) && (p < size) ) { - pos_ = (size_t) p; + pos_ = static_cast(p); hr = S_OK; } return hr; diff --git a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx index 12ed69e549cf..c55d9513b67c 100644 --- a/shell/source/win32/shlxthandler/util/iso8601_converter.cxx +++ b/shell/source/win32/shlxthandler/util/iso8601_converter.cxx @@ -50,13 +50,13 @@ std::wstring iso8601_date_to_local_date(const std::wstring& isoDate ) { std::string asDateTime = WStringToString( ws8601DateTime ); SYSTEMTIME DateTime; - DateTime.wYear = ( unsigned short )strtol( asDateTime.substr( 0, 4 ).c_str(), nullptr, 10 ); - DateTime.wMonth = ( unsigned short )strtol( asDateTime.substr( 5, 2 ).c_str(), nullptr, 10 ); + DateTime.wYear = static_cast(strtol( asDateTime.substr( 0, 4 ).c_str(), nullptr, 10 )); + DateTime.wMonth = static_cast(strtol( asDateTime.substr( 5, 2 ).c_str(), nullptr, 10 )); DateTime.wDayOfWeek = 0; - DateTime.wDay = ( unsigned short )strtol( asDateTime.substr( 8, 2 ).c_str(), nullptr, 10 ); - DateTime.wHour = ( unsigned short )strtol( asDateTime.substr( 11,2 ).c_str(), nullptr, 10 ); - DateTime.wMinute = ( unsigned short )strtol( asDateTime.substr( 14,2 ).c_str(), nullptr, 10 ); - DateTime.wSecond = ( unsigned short )strtol( asDateTime.substr( 17,2 ).c_str(), nullptr, 10 ); + DateTime.wDay = static_cast(strtol( asDateTime.substr( 8, 2 ).c_str(), nullptr, 10 )); + DateTime.wHour = static_cast(strtol( asDateTime.substr( 11,2 ).c_str(), nullptr, 10 )); + DateTime.wMinute = static_cast(strtol( asDateTime.substr( 14,2 ).c_str(), nullptr, 10 )); + DateTime.wSecond = static_cast(strtol( asDateTime.substr( 17,2 ).c_str(), nullptr, 10 )); DateTime.wMilliseconds = 0; //get Date info from structure diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx index 1a1ee62fe4ec..0cf7f204cf7e 100644 --- a/shell/source/win32/zipfile/zipfile.cxx +++ b/shell/source/win32/zipfile/zipfile.cxx @@ -444,7 +444,7 @@ void ZipFile::GetUncompressedContent( return; m_pStream->sseek(end.cdir_offset, SEEK_SET); CentralDirectoryEntry entry; - while (m_pStream->stell() != -1 && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size) + while (m_pStream->stell() != -1 && static_cast(m_pStream->stell()) < end.cdir_offset + end.cdir_size) { if (!readCentralDirectoryEntry(m_pStream, entry)) return; @@ -516,7 +516,7 @@ ZipFile::DirectoryPtr_t ZipFile::GetDirectory() const return dir; m_pStream->sseek(end.cdir_offset, SEEK_SET); CentralDirectoryEntry entry; - while (m_pStream->stell() != -1 && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size) + while (m_pStream->stell() != -1 && static_cast(m_pStream->stell()) < end.cdir_offset + end.cdir_size) { if (!readCentralDirectoryEntry(m_pStream, entry)) return dir; @@ -555,7 +555,7 @@ long ZipFile::GetFileLongestFileNameLength() const return lmax; m_pStream->sseek(end.cdir_offset, SEEK_SET); CentralDirectoryEntry entry; - while (m_pStream->stell() != -1 && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size) + while (m_pStream->stell() != -1 && static_cast(m_pStream->stell()) < end.cdir_offset + end.cdir_size) { if (!readCentralDirectoryEntry(m_pStream, entry)) return lmax; diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx index e3844d19feda..919a5edc7818 100644 --- a/stoc/source/typeconv/convert.cxx +++ b/stoc/source/typeconv/convert.cxx @@ -64,13 +64,13 @@ static const sal_Int64 SAL_INT64_MIN = /* MS Visual C++ no conversion from unsigned __int64 to double */ #ifdef _MSC_VER -static const double DOUBLE_SAL_UINT64_MAX = ((((double)SAL_INT64_MAX) * 2) + 1); +static const double DOUBLE_SAL_UINT64_MAX = (((double(SAL_INT64_MAX)) * 2) + 1); static inline double unsigned_int64_to_double( sal_uInt64 n ) { sal_uInt64 n2 = (n / 3); n -= (2 * n2); - return (((double)(sal_Int64)n2) * 2.0) + ((double)(sal_Int64)n); + return (static_cast(static_cast(n2)) * 2.0) + static_cast(static_cast(n)); } #else static const double DOUBLE_SAL_UINT64_MAX = diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index e4c9337c2a6a..429468b6e9fa 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -2349,15 +2349,15 @@ bool Signing::Verify(const std::vector& aData, if (rInformation.ouDateTime.isEmpty()) { OUStringBuffer rBuffer; - rBuffer.append((sal_Int32)aDateTime.GetYear()); + rBuffer.append(static_cast(aDateTime.GetYear())); rBuffer.append('-'); if (aDateTime.GetMonth() < 10) rBuffer.append('0'); - rBuffer.append((sal_Int32)aDateTime.GetMonth()); + rBuffer.append(static_cast(aDateTime.GetMonth())); rBuffer.append('-'); if (aDateTime.GetDay() < 10) rBuffer.append('0'); - rBuffer.append((sal_Int32)aDateTime.GetDay()); + rBuffer.append(static_cast(aDateTime.GetDay())); rInformation.ouDateTime = rBuffer.makeStringAndClear(); } break; diff --git a/svl/source/svdde/ddecli.cxx b/svl/source/svdde/ddecli.cxx index c84bb92592de..3faef58aca80 100644 --- a/svl/source/svdde/ddecli.cxx +++ b/svl/source/svdde/ddecli.cxx @@ -84,7 +84,7 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( UINT nCode, UINT nCbType, switch( nCode ) { case XTYP_XACT_COMPLETE: - if( (DWORD)(*iter)->nId == nInfo1 ) + if( static_cast((*iter)->nId) == nInfo1 ) { nCode = (*iter)->nType & (XCLASS_MASK | XTYP_MASK); (*iter)->bBusy = false; @@ -270,7 +270,7 @@ void DdeTransaction::Execute() { HSZ hItem = pName->getHSZ(); void const * pData = aDdeData.getData(); - DWORD nData = (DWORD)aDdeData.getSize(); + DWORD nData = static_cast(aDdeData.getSize()); SotClipboardFormatId nIntFmt = aDdeData.xImp->nFmt; UINT nExtFmt = DdeData::GetExternalFormat( nIntFmt ); DdeInstData* pInst = ImpGetInstData(); @@ -286,8 +286,8 @@ void DdeTransaction::Execute() { HDDEDATA hData = DdeClientTransaction( static_cast(const_cast(pData)), nData, rDde.pImp->hConv, - hItem, nExtFmt, (UINT)nType, - (DWORD)nTime, nullptr ); + hItem, nExtFmt, static_cast(nType), + static_cast(nTime), nullptr ); rDde.pImp->nStatus = DdeGetLastError( pInst->hDdeInstCli ); if( hData && nType == XTYP_REQUEST ) @@ -311,7 +311,7 @@ void DdeTransaction::Execute() DWORD result; HDDEDATA hRet = DdeClientTransaction( static_cast(const_cast(pData)), nData, rDde.pImp->hConv, hItem, nExtFmt, - (UINT)nType, TIMEOUT_ASYNC, + static_cast(nType), TIMEOUT_ASYNC, &result ); nId = result; rDde.pImp->nStatus = hRet ? DMLERR_NO_ERROR @@ -349,7 +349,7 @@ DdeLink::DdeLink( DdeConnection& d, const OUString& aItemName, long n ) DdeLink::~DdeLink() { - nType = (sal_uInt16)XTYP_ADVSTOP; + nType = sal_uInt16(XTYP_ADVSTOP); nTime = 0; } diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index 45098bec4764..e79f26063237 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -530,14 +530,14 @@ bool DdeService::HasCbFormat( sal_uInt16 nFmt ) bool DdeService::HasFormat(SotClipboardFormatId nFmt) { - return HasCbFormat( (sal_uInt16)DdeData::GetExternalFormat( nFmt )); + return HasCbFormat( static_cast(DdeData::GetExternalFormat( nFmt ))); } void DdeService::AddFormat(SotClipboardFormatId nFmt) { sal_uLong nExternalFmt = DdeData::GetExternalFormat( nFmt ); for ( size_t i = 0, n = aFormats.size(); i < n; ++i ) - if ( (sal_uLong) aFormats[ i ] == nExternalFmt ) + if ( static_cast(aFormats[ i ]) == nExternalFmt ) return; aFormats.push_back( nExternalFmt ); } @@ -547,7 +547,7 @@ void DdeService::RemoveFormat(SotClipboardFormatId nFmt) sal_uLong nExternalFmt = DdeData::GetExternalFormat( nFmt ); for ( DdeFormats::iterator it = aFormats.begin(); it != aFormats.end(); ++it ) { - if ( (sal_uLong) *it == nExternalFmt ) + if ( static_cast(*it) == nExternalFmt ) { aFormats.erase( it ); break; @@ -876,7 +876,7 @@ OUString DdeService::Formats() if ( n ) s += "\t"; - switch( (sal_uInt16)f ) + switch( static_cast(f) ) { case CF_TEXT: s += "TEXT"; @@ -887,7 +887,7 @@ OUString DdeService::Formats() default: { WCHAR buf[128]; - GetClipboardFormatNameW( (UINT)f, buf, SAL_N_ELEMENTS(buf) ); + GetClipboardFormatNameW( static_cast(f), buf, SAL_N_ELEMENTS(buf) ); s += o3tl::toU(buf); } break; diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index d29ae9518916..dd13467717a1 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -549,7 +549,7 @@ void SwFntObj::GuessLeading( const SwViewShell& { OSL_ENSURE( m_nPrtAscent < USHRT_MAX, "GuessLeading: PrtAscent-Fault" ); if ( m_nPrtAscent < USHRT_MAX ) - m_nPrtAscent = m_nPrtAscent + (sal_uInt16)(( 2 * nDiff ) / 5); + m_nPrtAscent = m_nPrtAscent + static_cast(( 2 * nDiff ) / 5); } } } diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index 0209c9559089..9d12bb9208e7 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -368,7 +368,7 @@ Time tools::Time::GetUTCOffset() nTempTime += aTimeZone.StandardBias; else if ( nTimeZoneRet == TIME_ZONE_ID_DAYLIGHT ) nTempTime += aTimeZone.DaylightBias; - tools::Time aTime( 0, (sal_uInt16)abs( nTempTime ) ); + tools::Time aTime( 0, static_cast(abs( nTempTime )) ); if ( nTempTime > 0 ) aTime = -aTime; return aTime; diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx index 3b890fbfef1b..0dd1d2f1bd4b 100644 --- a/tools/source/stream/strmwnt.cxx +++ b/tools/source/stream/strmwnt.cxx @@ -87,7 +87,7 @@ static ErrCode GetSvError( DWORD nWntError ) { ERROR_WRITE_PROTECT, SVSTREAM_ACCESS_DENIED }, { ERROR_DISK_FULL, SVSTREAM_DISK_FULL }, - { (DWORD)0xFFFFFFFF, SVSTREAM_GENERALERROR } + { DWORD(0xFFFFFFFF), SVSTREAM_GENERALERROR } }; ErrCode nRetVal = SVSTREAM_GENERALERROR; // default error @@ -100,7 +100,7 @@ static ErrCode GetSvError( DWORD nWntError ) break; } i++; - } while( errArr[i].wnt != (DWORD)0xFFFFFFFF ); + } while( errArr[i].wnt != DWORD(0xFFFFFFFF) ); return nRetVal; } diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx index 4a436fbd309d..05b4800e116a 100644 --- a/vcl/inc/win/wincomp.hxx +++ b/vcl/inc/win/wincomp.hxx @@ -127,7 +127,7 @@ inline BOOL IsMaximized( HWND hWnd ) inline void SetWindowFont( HWND hWnd, HFONT hFont, BOOL bRedraw ) { - SendMessageW( hWnd, WM_SETFONT, reinterpret_cast(hFont), MAKELPARAM((UINT)bRedraw,0) ); + SendMessageW( hWnd, WM_SETFONT, reinterpret_cast(hFont), MAKELPARAM(static_cast(bRedraw),0) ); } inline HFONT GetWindowFont( HWND hWnd ) diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx index b22e9dc78688..8329fbd83b5b 100644 --- a/vcl/opengl/win/gdiimpl.cxx +++ b/vcl/opengl/win/gdiimpl.cxx @@ -509,7 +509,7 @@ bool WinOpenGLContext::ImplInit() 1, // Version Number PFD_SUPPORT_OPENGL, PFD_TYPE_RGBA, // Request An RGBA Format - (BYTE)32, // Select Our Color Depth + BYTE(32), // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored @@ -547,8 +547,8 @@ bool WinOpenGLContext::ImplInit() #if OSL_DEBUG_LEVEL > 0 PIXELFORMATDESCRIPTOR pfd; DescribePixelFormat(m_aGLWin.hDC, WindowPix, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - SAL_WARN("vcl.opengl", "Render Target: Window: " << (int) ((pfd.dwFlags & PFD_DRAW_TO_WINDOW) != 0) << ", Bitmap: " << (int) ((pfd.dwFlags & PFD_DRAW_TO_BITMAP) != 0)); - SAL_WARN("vcl.opengl", "Supports OpenGL: " << (int) ((pfd.dwFlags & PFD_SUPPORT_OPENGL) != 0)); + SAL_WARN("vcl.opengl", "Render Target: Window: " << static_cast((pfd.dwFlags & PFD_DRAW_TO_WINDOW) != 0) << ", Bitmap: " << static_cast((pfd.dwFlags & PFD_DRAW_TO_BITMAP) != 0)); + SAL_WARN("vcl.opengl", "Supports OpenGL: " << static_cast((pfd.dwFlags & PFD_SUPPORT_OPENGL) != 0)); #endif } diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index aa4e65fab4a2..24b8caccc80f 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -5144,7 +5144,7 @@ void ToolBox::ImplDisableFlatButtons() bValue = ((0 == wcsicmp(Data, L"1")) || (0 == wcsicmp(Data, L"true"))); break; case REG_DWORD: - bValue = (bool)(reinterpret_cast(Data)[0]); + bValue = static_cast(reinterpret_cast(Data)[0]); break; } } diff --git a/vcl/win/app/saldata.cxx b/vcl/win/app/saldata.cxx index 0b45716a2980..c71954ea9ca8 100644 --- a/vcl/win/app/saldata.cxx +++ b/vcl/win/app/saldata.cxx @@ -62,7 +62,7 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const char* pStr2 ) c1 += 32; if ( (c2 >= 65) && (c2 <= 90) ) c2 += 32; - nRet = ((sal_Int32)c1)-((sal_Int32)((unsigned char)c2)); + nRet = static_cast(c1)- static_cast(static_cast(c2)); if ( nRet != 0 ) break; diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index 5671361c987b..27f1aa73a57a 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -551,7 +551,7 @@ bool WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) if ( !IsMainThread() ) { bDidWork = SendMessageW( mhComWnd, SAL_MSG_THREADYIELD, - (WPARAM) false, (LPARAM) bHandleAllCurrentEvents ); + WPARAM(false), static_cast(bHandleAllCurrentEvents) ); if ( !bDidWork && bWait ) { maWaitingYieldCond.reset(); @@ -594,7 +594,7 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM wParam, LPARAM lParam, b switch ( nMsg ) { case SAL_MSG_THREADYIELD: - assert( !(bool)wParam ); + assert( !static_cast(wParam) ); nRet = static_cast(ImplSalYield( false, static_cast( lParam ) )); break; @@ -883,7 +883,7 @@ bool WinSalInstance::AnyInput( VclInputFlags nType ) SalFrame* WinSalInstance::CreateChildFrame( SystemParentData* pSystemParentData, SalFrameStyleFlags nSalFrameStyle ) { // to switch to Main-Thread - return reinterpret_cast((sal_IntPtr)SendMessageW( mhComWnd, SAL_MSG_CREATEFRAME, static_cast(nSalFrameStyle), reinterpret_cast(pSystemParentData->hWnd) )); + return reinterpret_cast(static_cast(SendMessageW( mhComWnd, SAL_MSG_CREATEFRAME, static_cast(nSalFrameStyle), reinterpret_cast(pSystemParentData->hWnd) ))); } SalFrame* WinSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nSalFrameStyle ) @@ -894,7 +894,7 @@ SalFrame* WinSalInstance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nSa hWndParent = static_cast(pParent)->mhWnd; else hWndParent = nullptr; - return reinterpret_cast((sal_IntPtr)SendMessageW( mhComWnd, SAL_MSG_CREATEFRAME, static_cast(nSalFrameStyle), reinterpret_cast(hWndParent) )); + return reinterpret_cast(static_cast(SendMessageW( mhComWnd, SAL_MSG_CREATEFRAME, static_cast(nSalFrameStyle), reinterpret_cast(hWndParent) ))); } void WinSalInstance::DestroyFrame( SalFrame* pFrame ) @@ -908,7 +908,7 @@ SalObject* WinSalInstance::CreateObject( SalFrame* pParent, bool /*bShow*/ ) { // to switch to Main-Thread - return reinterpret_cast((sal_IntPtr)SendMessageW( mhComWnd, SAL_MSG_CREATEOBJECT, 0, reinterpret_cast(static_cast(pParent)) )); + return reinterpret_cast(static_cast(SendMessageW( mhComWnd, SAL_MSG_CREATEOBJECT, 0, reinterpret_cast(static_cast(pParent)) ))); } void WinSalInstance::DestroyObject( SalObject* pObject ) @@ -1054,9 +1054,9 @@ OUString WinSalInstance::getOSVersion() VS_FIXEDFILEINFO *vinfo = static_cast(pBlock); OUStringBuffer aVer; aVer.append("Windows "); - aVer.append((sal_Int32)HIWORD(vinfo->dwProductVersionMS)); + aVer.append(static_cast(HIWORD(vinfo->dwProductVersionMS))); aVer.append("."); - aVer.append((sal_Int32)LOWORD(vinfo->dwProductVersionMS)); + aVer.append(static_cast(LOWORD(vinfo->dwProductVersionMS))); return aVer.makeStringAndClear(); } } diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx index d23c7344ef31..c70189be4bba 100644 --- a/vcl/win/app/saltimer.cxx +++ b/vcl/win/app/saltimer.cxx @@ -105,7 +105,7 @@ void WinSalTimer::Start( sal_uLong nMS ) if ( pInst && !pInst->IsMainThread() ) { BOOL const ret = PostMessageW(pInst->mhComWnd, - SAL_MSG_STARTTIMER, 0, (LPARAM) tools::Time::GetSystemTicks() + nMS); + SAL_MSG_STARTTIMER, 0, static_cast(tools::Time::GetSystemTicks()) + nMS); SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!"); } else diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index 314d4a769d41..b34fa84d2f62 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -313,21 +313,21 @@ void WinSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcG (rPosAry.mnSrcHeight == rPosAry.mnDestHeight) ) { BitBlt( mrParent.getHDC(), - (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, - (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, + static_cast(rPosAry.mnDestX), static_cast(rPosAry.mnDestY), + static_cast(rPosAry.mnDestWidth), static_cast(rPosAry.mnDestHeight), hSrcDC, - (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, + static_cast(rPosAry.mnSrcX), static_cast(rPosAry.mnSrcY), nRop ); } else { int nOldStretchMode = SetStretchBltMode( mrParent.getHDC(), STRETCH_DELETESCANS ); StretchBlt( mrParent.getHDC(), - (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, - (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, + static_cast(rPosAry.mnDestX), static_cast(rPosAry.mnDestY), + static_cast(rPosAry.mnDestWidth), static_cast(rPosAry.mnDestHeight), hSrcDC, - (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, - (int)rPosAry.mnSrcWidth, (int)rPosAry.mnSrcHeight, + static_cast(rPosAry.mnSrcX), static_cast(rPosAry.mnSrcY), + static_cast(rPosAry.mnSrcWidth), static_cast(rPosAry.mnSrcHeight), nRop ); SetStretchBltMode( mrParent.getHDC(), nOldStretchMode ); } @@ -398,10 +398,10 @@ void WinSalGraphicsImpl::copyArea( long nDestX, long nDestY, HWND hWnd; // restrict srcRect to this window (calc intersection) - aSrcRect.left = (int)nSrcX; - aSrcRect.top = (int)nSrcY; - aSrcRect.right = aSrcRect.left+(int)nSrcWidth; - aSrcRect.bottom = aSrcRect.top+(int)nSrcHeight; + aSrcRect.left = static_cast(nSrcX); + aSrcRect.top = static_cast(nSrcY); + aSrcRect.right = aSrcRect.left+static_cast(nSrcWidth); + aSrcRect.bottom = aSrcRect.top+static_cast(nSrcHeight); GetClientRect( mrParent.gethWnd(), &aClipRect ); if ( IntersectRect( &aSrcRect, &aSrcRect, &aClipRect ) ) { @@ -507,8 +507,8 @@ void WinSalGraphicsImpl::copyArea( long nDestX, long nDestY, if ( (nRgnType != ERROR) && (nRgnType != NULLREGION) ) { // move the occluded parts to the destination pos - int nOffX = (int)(nDestX-nSrcX); - int nOffY = (int)(nDestY-nSrcY); + int nOffX = static_cast(nDestX-nSrcX); + int nOffY = static_cast(nDestY-nSrcY); OffsetRgn( hInvalidateRgn, nOffX-aPt.x, nOffY-aPt.y ); // by excluding hInvalidateRgn from the system's clip region @@ -525,10 +525,10 @@ void WinSalGraphicsImpl::copyArea( long nDestX, long nDestY, } BitBlt( mrParent.getHDC(), - (int)nDestX, (int)nDestY, - (int)nSrcWidth, (int)nSrcHeight, + static_cast(nDestX), static_cast(nDestY), + static_cast(nSrcWidth), static_cast(nSrcHeight), mrParent.getHDC(), - (int)nSrcX, (int)nSrcY, + static_cast(nSrcX), static_cast(nSrcY), SRCCOPY ); if( bRestoreClipRgn ) @@ -597,10 +597,10 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa const int nOldStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS ); StretchDIBits( hDC, - (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, - (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, - (int)rPosAry.mnSrcX, (int)(pBI->bmiHeader.biHeight - rPosAry.mnSrcHeight - rPosAry.mnSrcY), - (int)rPosAry.mnSrcWidth, (int)rPosAry.mnSrcHeight, + static_cast(rPosAry.mnDestX), static_cast(rPosAry.mnDestY), + static_cast(rPosAry.mnDestWidth), static_cast(rPosAry.mnDestHeight), + static_cast(rPosAry.mnSrcX), static_cast(pBI->bmiHeader.biHeight - rPosAry.mnSrcHeight - rPosAry.mnSrcY), + static_cast(rPosAry.mnSrcWidth), static_cast(rPosAry.mnSrcHeight), pBits, pBI, DIB_RGB_COLORS, nDrawMode ); GlobalUnlock( hDrawDIB ); @@ -640,10 +640,10 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa (rPosAry.mnSrcHeight == rPosAry.mnDestHeight) ) { BitBlt( hDC, - (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, - (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, + static_cast(rPosAry.mnDestX), static_cast(rPosAry.mnDestY), + static_cast(rPosAry.mnDestWidth), static_cast(rPosAry.mnDestHeight), hBmpDC, - (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, + static_cast(rPosAry.mnSrcX), static_cast(rPosAry.mnSrcY), nDrawMode ); } else @@ -651,11 +651,11 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, const WinSalBitmap& rSa const int nOldStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS ); StretchBlt( hDC, - (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, - (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, + static_cast(rPosAry.mnDestX), static_cast(rPosAry.mnDestY), + static_cast(rPosAry.mnDestWidth), static_cast(rPosAry.mnDestHeight), hBmpDC, - (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, - (int)rPosAry.mnSrcWidth, (int)rPosAry.mnSrcHeight, + static_cast(rPosAry.mnSrcX), static_cast(rPosAry.mnSrcY), + static_cast(rPosAry.mnSrcWidth), static_cast(rPosAry.mnSrcHeight), nDrawMode ); SetStretchBltMode( hDC, nOldStretchMode ); @@ -726,10 +726,10 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const WinSalBitmap& rTransparentBitmap = static_cast(rSTransparentBitmap); SalTwoRect aPosAry = rPosAry; - int nDstX = (int)aPosAry.mnDestX; - int nDstY = (int)aPosAry.mnDestY; - int nDstWidth = (int)aPosAry.mnDestWidth; - int nDstHeight = (int)aPosAry.mnDestHeight; + int nDstX = static_cast(aPosAry.mnDestX); + int nDstY = static_cast(aPosAry.mnDestY); + int nDstWidth = static_cast(aPosAry.mnDestWidth); + int nDstHeight = static_cast(aPosAry.mnDestHeight); HDC hDC = mrParent.getHDC(); HBITMAP hMemBitmap = nullptr; HBITMAP hMaskBitmap = nullptr; @@ -798,7 +798,7 @@ bool WinSalGraphicsImpl::drawAlphaRect( long nX, long nY, long nWidth, return false; // can only perform solid fills without XOR. HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1 ); - SetPixel( hMemDC, (int)0, (int)0, mnBrushColor ); + SetPixel( hMemDC, int(0), int(0), mnBrushColor ); BLENDFUNCTION aFunc = { AC_SRC_OVER, @@ -866,7 +866,7 @@ SalBitmap* WinSalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY ) HDC hBmpDC = ImplGetCachedDC( CACHED_HDC_1, hBmpBitmap ); bool bRet; - bRet = BitBlt( hBmpDC, 0, 0, (int) nDX, (int) nDY, hDC, (int) nX, (int) nY, SRCCOPY ) ? TRUE : FALSE; + bRet = BitBlt( hBmpDC, 0, 0, static_cast(nDX), static_cast(nDY), hDC, static_cast(nX), static_cast(nY), SRCCOPY ) ? TRUE : FALSE; ImplReleaseCachedDC( CACHED_HDC_1 ); if( bRet ) @@ -890,7 +890,7 @@ SalBitmap* WinSalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY ) SalColor WinSalGraphicsImpl::getPixel( long nX, long nY ) { - COLORREF aWinCol = ::GetPixel( mrParent.getHDC(), (int) nX, (int) nY ); + COLORREF aWinCol = ::GetPixel( mrParent.getHDC(), static_cast(nX), static_cast(nY) ); if ( CLR_INVALID == aWinCol ) return MAKE_SALCOLOR( 0, 0, 0 ); @@ -909,7 +909,7 @@ void WinSalGraphicsImpl::invert( long nX, long nY, long nWidth, long nHeight, Sa HBRUSH hOldBrush = SelectBrush( mrParent.getHDC(), GetStockBrush( NULL_BRUSH ) ); int nOldROP = SetROP2( mrParent.getHDC(), R2_NOT ); - Rectangle( mrParent.getHDC(), (int)nX, (int)nY, (int)(nX+nWidth), (int)(nY+nHeight) ); + Rectangle( mrParent.getHDC(), static_cast(nX), static_cast(nY), static_cast(nX+nWidth), static_cast(nY+nHeight) ); SetROP2( mrParent.getHDC(), nOldROP ); SelectPen( mrParent.getHDC(), hOldPen ); @@ -935,10 +935,10 @@ void WinSalGraphicsImpl::invert( long nX, long nY, long nWidth, long nHeight, Sa else { RECT aRect; - aRect.left = (int)nX; - aRect.top = (int)nY; - aRect.right = (int)nX+nWidth; - aRect.bottom = (int)nY+nHeight; + aRect.left = static_cast(nX); + aRect.top = static_cast(nY); + aRect.right = static_cast(nX)+nWidth; + aRect.bottom = static_cast(nY)+nHeight; ::InvertRect( mrParent.getHDC(), &aRect ); } } @@ -986,12 +986,12 @@ void WinSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, Sal // for Windows 95 and its maximum number of points if ( nSalFlags & SalInvert::TrackFrame ) { - if ( !Polyline( mrParent.getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) + if ( !Polyline( mrParent.getHDC(), pWinPtAry, static_cast(nPoints) ) && (nPoints > MAX_64KSALPOINTS) ) Polyline( mrParent.getHDC(), pWinPtAry, MAX_64KSALPOINTS ); } else { - if ( !Polygon( mrParent.getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) + if ( !Polygon( mrParent.getHDC(), pWinPtAry, static_cast(nPoints) ) && (nPoints > MAX_64KSALPOINTS) ) Polygon( mrParent.getHDC(), pWinPtAry, MAX_64KSALPOINTS ); } @@ -1009,7 +1009,7 @@ void WinSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, Sal sal_uInt16 WinSalGraphicsImpl::GetBitCount() const { - return (sal_uInt16)GetDeviceCaps( mrParent.getHDC(), BITSPIXEL ); + return static_cast(GetDeviceCaps( mrParent.getHDC(), BITSPIXEL )); } long WinSalGraphicsImpl::GetGraphicsWidth() const @@ -1250,29 +1250,29 @@ bool WinSalGraphicsImpl::setClipRegion( const vcl::Region& i_rClip ) { if(aRectIter->Left() < pBoundRect->left) { - pBoundRect->left = (int)aRectIter->Left(); + pBoundRect->left = static_cast(aRectIter->Left()); } if(aRectIter->Top() < pBoundRect->top) { - pBoundRect->top = (int)aRectIter->Top(); + pBoundRect->top = static_cast(aRectIter->Top()); } if(nRight > pBoundRect->right) { - pBoundRect->right = (int)nRight; + pBoundRect->right = static_cast(nRight); } if(nBottom > pBoundRect->bottom) { - pBoundRect->bottom = (int)nBottom; + pBoundRect->bottom = static_cast(nBottom); } } - pNextClipRect->left = (int)aRectIter->Left(); - pNextClipRect->top = (int)aRectIter->Top(); - pNextClipRect->right = (int)nRight; - pNextClipRect->bottom = (int)nBottom; + pNextClipRect->left = static_cast(aRectIter->Left()); + pNextClipRect->top = static_cast(aRectIter->Top()); + pNextClipRect->right = static_cast(nRight); + pNextClipRect->bottom = static_cast(nBottom); pNextClipRect++; } else @@ -1569,12 +1569,12 @@ void WinSalGraphicsImpl::drawPixelImpl( long nX, long nY, COLORREF crColor ) { HBRUSH hBrush = CreateSolidBrush( crColor ); HBRUSH hOldBrush = SelectBrush( mrParent.getHDC(), hBrush ); - PatBlt( mrParent.getHDC(), (int)nX, (int)nY, (int)1, (int)1, PATINVERT ); + PatBlt( mrParent.getHDC(), static_cast(nX), static_cast(nY), int(1), int(1), PATINVERT ); SelectBrush( mrParent.getHDC(), hOldBrush ); DeleteBrush( hBrush ); } else - SetPixel( mrParent.getHDC(), (int)nX, (int)nY, crColor ); + SetPixel( mrParent.getHDC(), static_cast(nX), static_cast(nY), crColor ); } void WinSalGraphicsImpl::drawPixel( long nX, long nY ) @@ -1598,9 +1598,9 @@ void WinSalGraphicsImpl::drawPixel( long nX, long nY, SalColor nSalColor ) void WinSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 ) { - MoveToEx( mrParent.getHDC(), (int)nX1, (int)nY1, nullptr ); + MoveToEx( mrParent.getHDC(), static_cast(nX1), static_cast(nY1), nullptr ); - LineTo( mrParent.getHDC(), (int)nX2, (int)nY2 ); + LineTo( mrParent.getHDC(), static_cast(nX2), static_cast(nY2) ); // LineTo doesn't draw the last pixel if ( !mrParent.isPrinter() ) @@ -1613,7 +1613,7 @@ void WinSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeight ) { if ( !mrParent.isPrinter() ) { - PatBlt( mrParent.getHDC(), (int)nX, (int)nY, (int)nWidth, (int)nHeight, + PatBlt( mrParent.getHDC(), static_cast(nX), static_cast(nY), static_cast(nWidth), static_cast(nHeight), mbXORMode ? PATINVERT : PATCOPY ); } else @@ -1627,7 +1627,7 @@ void WinSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeight ) } } else - Rectangle( mrParent.getHDC(), (int)nX, (int)nY, (int)(nX+nWidth), (int)(nY+nHeight) ); + Rectangle( mrParent.getHDC(), static_cast(nX), static_cast(nY), static_cast(nX+nWidth), static_cast(nY+nHeight) ); } void WinSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) @@ -1638,7 +1638,7 @@ void WinSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAr POINT const * pWinPtAry = reinterpret_cast(pPtAry); // for Windows 95 and its maximum number of points - if ( !Polyline( mrParent.getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) + if ( !Polyline( mrParent.getHDC(), pWinPtAry, static_cast(nPoints) ) && (nPoints > MAX_64KSALPOINTS) ) Polyline( mrParent.getHDC(), pWinPtAry, MAX_64KSALPOINTS ); // Polyline seems to uses LineTo, which doesn't paint the last pixel (see 87eb8f8ee) @@ -1653,7 +1653,7 @@ void WinSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry POINT const * pWinPtAry = reinterpret_cast(pPtAry); // for Windows 95 and its maximum number of points - if ( !Polygon( mrParent.getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) + if ( !Polygon( mrParent.getHDC(), pWinPtAry, static_cast(nPoints) ) && (nPoints > MAX_64KSALPOINTS) ) Polygon( mrParent.getHDC(), pWinPtAry, MAX_64KSALPOINTS ); } @@ -1671,9 +1671,9 @@ void WinSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pP else pWinPointAry = new UINT[nPoly]; - for ( i = 0; i < (UINT)nPoly; i++ ) + for ( i = 0; i < static_cast(nPoly); i++ ) { - nPoints = (UINT)pPoints[i]+1; + nPoints = static_cast(pPoints[i])+1; pWinPointAry[i] = nPoints; nPolyPolyPoints += nPoints; } @@ -1687,7 +1687,7 @@ void WinSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pP // for NT, we can handover the array directly static_assert( sizeof( POINT ) == sizeof( SalPoint ), "must be the same size" ); UINT n = 0; - for ( i = 0; i < (UINT)nPoly; i++ ) + for ( i = 0; i < static_cast(nPoly); i++ ) { nPoints = pWinPointAry[i]; const SalPoint* pPolyAry = pPtAry[i]; @@ -1696,20 +1696,20 @@ void WinSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pP n += nPoints; } - if ( !PolyPolygon( mrParent.getHDC(), pWinPointAryAry, reinterpret_cast(pWinPointAry), (UINT)nPoly ) && + if ( !PolyPolygon( mrParent.getHDC(), pWinPointAryAry, reinterpret_cast(pWinPointAry), static_cast(nPoly) ) && (nPolyPolyPoints > MAX_64KSALPOINTS) ) { nPolyPolyPoints = 0; nPoly = 0; do { - nPolyPolyPoints += pWinPointAry[(UINT)nPoly]; + nPolyPolyPoints += pWinPointAry[static_cast(nPoly)]; nPoly++; } while ( nPolyPolyPoints < MAX_64KSALPOINTS ); nPoly--; - if ( pWinPointAry[(UINT)nPoly] > MAX_64KSALPOINTS ) - pWinPointAry[(UINT)nPoly] = MAX_64KSALPOINTS; + if ( pWinPointAry[static_cast(nPoly)] > MAX_64KSALPOINTS ) + pWinPointAry[static_cast(nPoly)] = MAX_64KSALPOINTS; if ( nPoly == 1 ) Polygon( mrParent.getHDC(), pWinPointAryAry, *pWinPointAry ); else @@ -1902,7 +1902,7 @@ bool WinSalGraphicsImpl::drawPolyPolygon( const basegfx::B2DPolyPolygon& rPolyPo if(mbBrush && nCount && (fTransparency >= 0.0 && fTransparency < 1.0)) { Gdiplus::Graphics aGraphics(mrParent.getHDC()); - const sal_uInt8 aTrans((sal_uInt8)255 - (sal_uInt8)basegfx::fround(fTransparency * 255.0)); + const sal_uInt8 aTrans(sal_uInt8(255) - static_cast(basegfx::fround(fTransparency * 255.0))); const Gdiplus::Color aTestColor(aTrans, SALCOLOR_RED(maFillColor), SALCOLOR_GREEN(maFillColor), SALCOLOR_BLUE(maFillColor)); const Gdiplus::SolidBrush aSolidBrush(aTestColor.GetValue()); Gdiplus::GraphicsPath aGraphicsPath(Gdiplus::FillModeAlternate); @@ -1968,7 +1968,7 @@ bool WinSalGraphicsImpl::drawPolyLine( if(mbPen && nCount) { Gdiplus::Graphics aGraphics(mrParent.getHDC()); - const sal_uInt8 aTrans = (sal_uInt8)basegfx::fround( 255 * (1.0 - fTransparency) ); + const sal_uInt8 aTrans = static_cast(basegfx::fround( 255 * (1.0 - fTransparency) )); const Gdiplus::Color aTestColor(aTrans, SALCOLOR_RED(maLineColor), SALCOLOR_GREEN(maLineColor), SALCOLOR_BLUE(maLineColor)); Gdiplus::Pen aPen(aTestColor.GetValue(), Gdiplus::REAL(rLineWidths.getX())); Gdiplus::GraphicsPath aGraphicsPath(Gdiplus::FillModeAlternate); diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx index e8110226ce2b..e33005efea6a 100644 --- a/vcl/win/gdi/salbmp.cxx +++ b/vcl/win/gdi/salbmp.cxx @@ -638,7 +638,7 @@ bool WinSalBitmap::Create( const SalBitmap& rSSalBmp, sal_uInt16 nNewBitCount ) if( mhDIB ) { PBITMAPINFO pBI = static_cast(GlobalLock( mhDIB )); - const int nLines = (int) rSalBmp.maSize.Height(); + const int nLines = static_cast(rSalBmp.maSize.Height()); HDC hDC = GetDC( nullptr ); PBYTE pBits = reinterpret_cast(pBI) + pBI->bmiHeader.biSize + ImplGetDIBColorCount( mhDIB ) * sizeof( RGBQUAD ); @@ -707,7 +707,7 @@ sal_uInt16 WinSalBitmap::ImplGetDIBColorCount( HGLOBAL hDIB ) if( pBI->bmiHeader.biBitCount <= 8 ) { if ( pBI->bmiHeader.biClrUsed ) - nColors = (sal_uInt16) pBI->bmiHeader.biClrUsed; + nColors = static_cast(pBI->bmiHeader.biClrUsed); else nColors = 1 << pBI->bmiHeader.biBitCount; } @@ -733,7 +733,7 @@ HGLOBAL WinSalBitmap::ImplCreateDIB( const Size& rSize, sal_uInt16 nBits, const // calculate bitmap size in Bytes const sal_uLong nAlignedWidth4Bytes = AlignedWidth4Bytes( nBits * rSize.Width() ); const sal_uLong nImageSize = nAlignedWidth4Bytes * rSize.Height(); - bool bOverflow = (nImageSize / nAlignedWidth4Bytes) != (sal_uLong) rSize.Height(); + bool bOverflow = (nImageSize / nAlignedWidth4Bytes) != static_cast(rSize.Height()); if( bOverflow ) return hDIB; @@ -872,7 +872,7 @@ BitmapBuffer* WinSalBitmap::AcquireBuffer( BitmapAccessMode /*nMode*/ ) pBuffer->mnWidth = maSize.Width(); pBuffer->mnHeight = maSize.Height(); pBuffer->mnScanlineSize = AlignedWidth4Bytes( maSize.Width() * pBIH->biBitCount ); - pBuffer->mnBitCount = (sal_uInt16) pBIH->biBitCount; + pBuffer->mnBitCount = static_cast(pBIH->biBitCount); if( pBuffer->mnBitCount <= 8 ) { diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 001518bf3e55..809db1b711f7 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -59,7 +59,7 @@ using namespace vcl; inline FIXED FixedFromDouble( double d ) { - const long l = (long) ( d * 65536. ); + const long l = static_cast( d * 65536. ); return *reinterpret_cast(&l); } @@ -172,7 +172,7 @@ bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU // construct a Size structure as the parameter of constructor of class FontSelectPattern const Size aSize( pFace->GetWidth(), pFace->GetHeight() ); // create a FontSelectPattern object for getting s LOGFONT - const FontSelectPattern aFSD( *pFace, aSize, (float)aSize.Height(), 0, false ); + const FontSelectPattern aFSD( *pFace, aSize, static_cast(aSize.Height()), 0, false ); // construct log font LOGFONTW aLogFont; ImplGetLogFontFromFontSelect( mhDC, &aFSD, aLogFont, true ); @@ -346,7 +346,7 @@ static rtl_TextEncoding ImplCharSetToSal( BYTE nCharSet ) if ( nCharSet == OEM_CHARSET ) { - UINT nCP = (sal_uInt16)GetOEMCP(); + UINT nCP = static_cast(GetOEMCP()); switch ( nCP ) { // It is unclear why these two (undefined?) code page numbers are @@ -591,7 +591,7 @@ void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont ) nFontHeight += nDPIY/2; nFontHeight /= nDPIY; rFont.SetFontSize( Size( 0, nFontHeight ) ); - rFont.SetOrientation( (short)rLogFont.lfEscapement ); + rFont.SetOrientation( static_cast(rLogFont.lfEscapement) ); if ( rLogFont.lfItalic ) rFont.SetItalic( ITALIC_NORMAL ); else @@ -790,8 +790,8 @@ void ImplGetLogFontFromFontSelect( HDC hDC, } rLogFont.lfWeight = ImplWeightToWin( pFont->GetWeight() ); - rLogFont.lfHeight = (LONG)-pFont->mnHeight; - rLogFont.lfWidth = (LONG)pFont->mnWidth; + rLogFont.lfHeight = static_cast(-pFont->mnHeight); + rLogFont.lfWidth = static_cast(pFont->mnWidth); rLogFont.lfUnderline = 0; rLogFont.lfStrikeOut = 0; rLogFont.lfItalic = BYTE(pFont->GetItalic() != ITALIC_NONE); diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx index 9d6dcd55ec2b..ffdd874cdd50 100644 --- a/vcl/win/gdi/salgdi.cxx +++ b/vcl/win/gdi/salgdi.cxx @@ -174,10 +174,10 @@ void ImplInitSalGDI() pSalData->mpDitherDiff[ n ] = n - ( n & 248L ); for( n = 0; n < 256; n++ ) - pSalData->mpDitherLow[ n ] = (BYTE) ( n & 248 ); + pSalData->mpDitherLow[ n ] = static_cast( n & 248 ); for( n = 0; n < 256; n++ ) - pSalData->mpDitherHigh[ n ] = (BYTE) std::min( pSalData->mpDitherLow[ n ] + 8, 255 ); + pSalData->mpDitherHigh[ n ] = static_cast(std::min( pSalData->mpDitherLow[ n ] + 8, 255 )); } } else if ( (nRasterCaps & RC_PALETTE) && (nBitCount == 8) ) @@ -192,7 +192,7 @@ void ImplInitSalGDI() // create logical palette pLogPal = reinterpret_cast(new char[ sizeof( LOGPALETTE ) + ( nTotalCount * sizeof( PALETTEENTRY ) ) ]); pLogPal->palVersion = 0x0300; - pLogPal->palNumEntries = (sal_uInt16) nTotalCount; + pLogPal->palNumEntries = static_cast(nTotalCount); pPalEntry = pLogPal->palPalEntry; // Standard colors @@ -246,16 +246,16 @@ void ImplInitSalGDI() pBIH->biBitCount = 8; for( n = 0; n < nDitherPalCount; n++ ) - pColors[ n ] = (short)( n + DITHER_MAX_SYSCOLOR ); + pColors[ n ] = static_cast( n + DITHER_MAX_SYSCOLOR ); for( n = 0; n < 256; n++ ) pSalData->mpDitherDiff[ n ] = n % 51; for( n = 0; n < 256; n++ ) - pSalData->mpDitherLow[ n ] = (BYTE) ( n / 51 ); + pSalData->mpDitherLow[ n ] = static_cast( n / 51 ); for( n = 0; n < 256; n++ ) - pSalData->mpDitherHigh[ n ] = (BYTE)std::min( pSalData->mpDitherLow[ n ] + 1, 5 ); + pSalData->mpDitherHigh[ n ] = static_cast(std::min( pSalData->mpDitherLow[ n ] + 1, 5 )); } // get system color entries @@ -345,9 +345,9 @@ void ImplFreeSalGDI() int ImplIsSysColorEntry( SalColor nSalColor ) { SysColorEntry* pEntry = pFirstSysColor; - const DWORD nTestRGB = (DWORD)RGB( SALCOLOR_RED( nSalColor ), + const DWORD nTestRGB = static_cast(RGB( SALCOLOR_RED( nSalColor ), SALCOLOR_GREEN( nSalColor ), - SALCOLOR_BLUE( nSalColor ) ); + SALCOLOR_BLUE( nSalColor ) )); while ( pEntry ) { @@ -984,7 +984,7 @@ bool WinSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* // #107797# Write out buffer - *reinterpret_cast(const_cast(aBuf.getStr())) = (sal_uInt16)( aBuf.getLength() - 2 ); + *reinterpret_cast(const_cast(aBuf.getStr())) = static_cast( aBuf.getLength() - 2 ); Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), nullptr ); // #107797# Write out EPS transformation code @@ -1003,7 +1003,7 @@ bool WinSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* aBuf.append( nY - ( dM22 * nBoundingBox[3] ) ); aBuf.append( "] concat\n" "%%BeginDocument:\n" ); - *reinterpret_cast(const_cast(aBuf.getStr())) = (sal_uInt16)( aBuf.getLength() - 2 ); + *reinterpret_cast(const_cast(aBuf.getStr())) = static_cast( aBuf.getLength() - 2 ); Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), nullptr ); // #107797# Write out actual EPS content @@ -1017,7 +1017,7 @@ bool WinSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* nDoNow = POSTSCRIPT_BUFSIZE - 2; // the following is based on the string buffer allocation // of size POSTSCRIPT_BUFSIZE at construction time of aBuf - *reinterpret_cast(const_cast(aBuf.getStr())) = (sal_uInt16)nDoNow; + *reinterpret_cast(const_cast(aBuf.getStr())) = static_cast(nDoNow); memcpy( const_cast(aBuf.getStr() + 2), static_cast(pPtr) + nSize - nToDo, nDoNow ); sal_uLong nResult = Escape ( getHDC(), nEscape, nDoNow + 2, aBuf.getStr(), nullptr ); if (!nResult ) @@ -1033,7 +1033,7 @@ bool WinSalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* "count op_count_salWin sub {pop} repeat\n" "countdictstack dict_count_salWin sub {end} repeat\n" "b4_Inc_state_salWin restore\n\n" ); - *reinterpret_cast(const_cast(aBuf.getStr())) = (sal_uInt16)( aBuf.getLength() - 2 ); + *reinterpret_cast(const_cast(aBuf.getStr())) = static_cast( aBuf.getLength() - 2 ); Escape ( getHDC(), nEscape, aBuf.getLength(), aBuf.getStr(), nullptr ); bRetValue = TRUE; } diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx index 59aff3f27448..aa9c5173a1ba 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -328,7 +328,7 @@ static bool ImplTestSalJobSetup( WinSalInfoPrinter const * pPrinter, if ( (pSetupData->GetSystem() == JOBSETUP_SYSTEM_WINDOWS) && (pPrinter->maDriverName == pSetupData->GetDriver()) && (pSetupData->GetDriverDataLen() > sizeof( SalDriverData )) && - (long)(pSetupData->GetDriverDataLen() - pSetupDriverData->mnDriverOffset) == nSysJobSize && + static_cast(pSetupData->GetDriverDataLen() - pSetupDriverData->mnDriverOffset) == nSysJobSize && pSetupDriverData->mnSysSignature == SAL_DRIVERDATA_SYSSIGN ) { if( pDevModeW && @@ -474,7 +474,7 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter const * pPrinter, ImplJobSe { if( pDevModeW->dmDefaultSource == pBins[ i ] ) { - pSetupData->SetPaperBin( (sal_uInt16)i ); + pSetupData->SetPaperBin( static_cast(i) ); break; } } @@ -960,8 +960,8 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter const * pPrinter, const Imp { pDevModeW->dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH; pDevModeW->dmPaperSize = DMPAPER_USER; - pDevModeW->dmPaperWidth = (short)(pSetupData->GetPaperWidth()/10); - pDevModeW->dmPaperLength = (short)(pSetupData->GetPaperHeight()/10); + pDevModeW->dmPaperWidth = static_cast(pSetupData->GetPaperWidth()/10); + pDevModeW->dmPaperLength = static_cast(pSetupData->GetPaperHeight()/10); } if ( pPapers ) @@ -1332,7 +1332,7 @@ static DEVMODEW const * ImplSalSetCopies( DEVMODEW const * pDevMode, sal_uLong n LPDEVMODEW pNewDevMode = static_cast(rtl_allocateMemory( nDevSize )); memcpy( pNewDevMode, pDevMode, nDevSize ); pNewDevMode->dmFields |= DM_COPIES; - pNewDevMode->dmCopies = (short)(sal_uInt16)nCopies; + pNewDevMode->dmCopies = static_cast(static_cast(nCopies)); pNewDevMode->dmFields |= DM_COLLATE; if ( bCollate ) pNewDevMode->dmCollate = DMCOLLATE_TRUE; diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx index 17b32862d52f..6a50509f876b 100644 --- a/vcl/win/gdi/salvd.cxx +++ b/vcl/win/gdi/salvd.cxx @@ -36,14 +36,14 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, if ( nBitCount == 1 ) { - hBitmap = CreateBitmap( (int)nDX, (int)nDY, 1, 1, nullptr ); + hBitmap = CreateBitmap( static_cast(nDX), static_cast(nDY), 1, 1, nullptr ); SAL_WARN_IF( !hBitmap, "vcl", "CreateBitmap failed: " << WindowsErrorString( GetLastError() ) ); ppData = nullptr; } else { if (nBitCount == 0) - nBitCount = (WORD)GetDeviceCaps(hDC, BITSPIXEL); + nBitCount = static_cast(GetDeviceCaps(hDC, BITSPIXEL)); // #146839# Don't use CreateCompatibleBitmap() - there seem to // be build-in limits for those HBITMAPs, at least this fails diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index aedba07f6a5e..22b870bde928 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -123,7 +123,7 @@ bool WinSalFrame::mbInReparent = FALSE; // Macros for support of WM_UNICHAR & Keyman 6.0 //#define Uni_UTF32ToSurrogate1(ch) (((unsigned long) (ch) - 0x10000) / 0x400 + 0xD800) -#define Uni_UTF32ToSurrogate2(ch) (((unsigned long) (ch) - 0x10000) % 0x400 + 0xDC00) +#define Uni_UTF32ToSurrogate2(ch) ((static_cast(ch) - 0x10000) % 0x400 + 0xDC00) #define Uni_SupplementaryPlanesStart 0x10000 static void UpdateFrameGeometry( HWND hWnd, WinSalFrame* pFrame ); @@ -680,7 +680,7 @@ static UINT ImplSalGetWheelScrollLines() if ( hWndMsWheel ) { UINT nGetScrollLinesMsgId = RegisterWindowMessageW( MSH_SCROLL_LINES ); - nScrLines = (UINT)SendMessageW( hWndMsWheel, nGetScrollLinesMsgId, 0, 0 ); + nScrLines = static_cast(SendMessageW( hWndMsWheel, nGetScrollLinesMsgId, 0, 0 )); } if ( !nScrLines ) @@ -988,9 +988,9 @@ SalGraphics* WinSalFrame::AcquireGraphics() mpGraphics2->setHDC(nullptr); } - HDC hDC = reinterpret_cast((sal_IntPtr)SendMessageW( pSalData->mpInstance->mhComWnd, + HDC hDC = reinterpret_cast(static_cast(SendMessageW( pSalData->mpInstance->mhComWnd, SAL_MSG_GETDC, - reinterpret_cast(mhWnd), 0 )); + reinterpret_cast(mhWnd), 0 ))); if ( hDC ) { mpGraphics2->setHDC(hDC); @@ -1278,9 +1278,9 @@ void WinSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, // Calculate window size including the border RECT aWinRect; aWinRect.left = 0; - aWinRect.right = (int)nWidth-1; + aWinRect.right = static_cast(nWidth)-1; aWinRect.top = 0; - aWinRect.bottom = (int)nHeight-1; + aWinRect.bottom = static_cast(nHeight)-1; AdjustWindowRectEx( &aWinRect, GetWindowStyle( mhWnd ), FALSE, GetWindowExStyle( mhWnd ) ); nWidth = aWinRect.right - aWinRect.left + 1; @@ -1431,7 +1431,7 @@ void WinSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, if( !(mnStyle & SalFrameStyleFlags::FLOAT) ) nPosFlags |= SWP_NOZORDER; // do not change z-order - SetWindowPos( mhWnd, HWND_TOP, nX, nY, (int)nWidth, (int)nHeight, nPosFlags ); + SetWindowPos( mhWnd, HWND_TOP, nX, nY, static_cast(nWidth), static_cast(nHeight), nPosFlags ); UpdateFrameGeometry( mhWnd, this ); @@ -1508,9 +1508,9 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs // create a new hwnd with the same styles HWND hWndParent = hNewParentWnd; // forward to main thread - HWND hWnd = reinterpret_cast((sal_IntPtr) SendMessageW( pSalData->mpInstance->mhComWnd, + HWND hWnd = reinterpret_cast(static_cast(SendMessageW( pSalData->mpInstance->mhComWnd, bAsChild ? SAL_MSG_RECREATECHILDHWND : SAL_MSG_RECREATEHWND, - reinterpret_cast(hWndParent), reinterpret_cast(pThis->mhWnd) )); + reinterpret_cast(hWndParent), reinterpret_cast(pThis->mhWnd) ))); // succeeded ? SAL_WARN_IF( !IsWindow( hWnd ), "vcl", "WinSalFrame::SetParent not successful"); @@ -1525,9 +1525,9 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs if( bNeedCacheDC ) { // re-create cached DC - HDC hDC = reinterpret_cast((sal_IntPtr)SendMessageW( pSalData->mpInstance->mhComWnd, + HDC hDC = reinterpret_cast(static_cast(SendMessageW( pSalData->mpInstance->mhComWnd, SAL_MSG_GETDC, - reinterpret_cast(hWnd), 0 )); + reinterpret_cast(hWnd), 0 ))); if ( hDC ) { pThis->mpGraphics2->setHDC(hDC); @@ -1582,7 +1582,7 @@ static void ImplSetParentFrame( WinSalFrame* pThis, HWND hNewParentWnd, bool bAs // Now destroy original HWND in the thread where it was created. SendMessageW( GetSalData()->mpInstance->mhComWnd, - SAL_MSG_DESTROYHWND, (WPARAM) 0, reinterpret_cast(hWndOld)); + SAL_MSG_DESTROYHWND, WPARAM(0), reinterpret_cast(hWndOld)); } void WinSalFrame::SetParent( SalFrame* pNewParent ) @@ -1662,19 +1662,19 @@ void WinSalFrame::SetWindowState( const SalFrameState* pState ) if ( !(pState->mnMask & (WindowStateMask::Width | WindowStateMask::Height)) ) nPosSize |= SWP_NOSIZE; if ( pState->mnMask & WindowStateMask::X ) - nX = (int)pState->mnX - nLeftDeco; + nX = static_cast(pState->mnX) - nLeftDeco; else nX = aWinRect.left; if ( pState->mnMask & WindowStateMask::Y ) - nY = (int)pState->mnY - nTopDeco; + nY = static_cast(pState->mnY) - nTopDeco; else nY = aWinRect.top; if ( pState->mnMask & WindowStateMask::Width ) - nWidth = (int)pState->mnWidth + nLeftDeco + nRightDeco; + nWidth = static_cast(pState->mnWidth) + nLeftDeco + nRightDeco; else nWidth = aWinRect.right-aWinRect.left; if ( pState->mnMask & WindowStateMask::Height ) - nHeight = (int)pState->mnHeight + nTopDeco + nBottomDeco; + nHeight = static_cast(pState->mnHeight) + nTopDeco + nBottomDeco; else nHeight = aWinRect.bottom-aWinRect.top; @@ -2020,7 +2020,7 @@ void WinSalFrame::ToTop( SalFrameToTop nFlags ) // We post this message to avoid deadlocks if ( GetSalData()->mnAppThreadId != GetCurrentThreadId() ) { - BOOL const ret = PostMessageW( mhWnd, SAL_MSG_TOTOP, (WPARAM)nFlags, 0 ); + BOOL const ret = PostMessageW( mhWnd, SAL_MSG_TOTOP, static_cast(nFlags), 0 ); SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!"); } else @@ -2167,8 +2167,8 @@ void WinSalFrame::CaptureMouse( bool bCapture ) void WinSalFrame::SetPointerPos( long nX, long nY ) { POINT aPt; - aPt.x = (int)nX; - aPt.y = (int)nY; + aPt.x = static_cast(nX); + aPt.y = static_cast(nY); ClientToScreen( mhWnd, &aPt ); SetCursorPos( aPt.x, aPt.y ); } @@ -2263,7 +2263,7 @@ static void ImplSalFrameEndExtTextInput( HWND hWnd, EndExtTextInputFlags nFlags void WinSalFrame::EndExtTextInput( EndExtTextInputFlags nFlags ) { // Must be called in the main thread! - SendMessageW( mhWnd, SAL_MSG_ENDEXTTEXTINPUT, (WPARAM)nFlags, 0 ); + SendMessageW( mhWnd, SAL_MSG_ENDEXTTEXTINPUT, static_cast(nFlags), 0 ); } static void ImplGetKeyNameText( LONG lParam, sal_Unicode* pBuf, @@ -2346,21 +2346,21 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) if ( nKeyCode & KEY_MOD1 ) { nSysCode = MapVirtualKeyW( VK_CONTROL, 0 ); - nSysCode = (nSysCode << 16) | (((sal_uLong)1) << 25); + nSysCode = (nSysCode << 16) | ((sal_uLong(1)) << 25); ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Ctrl" ); } if ( nKeyCode & KEY_MOD2 ) { nSysCode = MapVirtualKeyW( VK_MENU, 0 ); - nSysCode = (nSysCode << 16) | (((sal_uLong)1) << 25); + nSysCode = (nSysCode << 16) | ((sal_uLong(1)) << 25); ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Alt" ); } if ( nKeyCode & KEY_SHIFT ) { nSysCode = MapVirtualKeyW( VK_SHIFT, 0 ); - nSysCode = (nSysCode << 16) | (((sal_uLong)1) << 25); + nSysCode = (nSysCode << 16) | ((sal_uLong(1)) << 25); ImplGetKeyNameText( nSysCode, aKeyBuf, nKeyBufLen, nMaxKeyLen, "Shift" ); } @@ -2404,42 +2404,42 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) { case KEY_DOWN: nSysCode = VK_DOWN; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Down"; break; case KEY_UP: nSysCode = VK_UP; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Up"; break; case KEY_LEFT: nSysCode = VK_LEFT; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Left"; break; case KEY_RIGHT: nSysCode = VK_RIGHT; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Right"; break; case KEY_HOME: nSysCode = VK_HOME; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Home"; break; case KEY_END: nSysCode = VK_END; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "End"; break; case KEY_PAGEUP: nSysCode = VK_PRIOR; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Page Up"; break; case KEY_PAGEDOWN: nSysCode = VK_NEXT; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Page Down"; break; case KEY_RETURN: @@ -2464,12 +2464,12 @@ OUString WinSalFrame::GetKeyName( sal_uInt16 nKeyCode ) break; case KEY_INSERT: nSysCode = VK_INSERT; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Insert"; break; case KEY_DELETE: nSysCode = VK_DELETE; - nSysCode2 = (((sal_uLong)1) << 24); + nSysCode2 = ((sal_uLong(1)) << 24); pReplace = "Delete"; break; @@ -2609,7 +2609,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) &nType, reinterpret_cast(aValueBuf), &nValueSize ) == ERROR_SUCCESS ) { if ( nType == REG_SZ ) - aMouseSettings.SetMenuDelay( (sal_uLong)ImplW2I( aValueBuf ) ); + aMouseSettings.SetMenuDelay( static_cast(ImplW2I( aValueBuf )) ); } RegCloseKey( hRegKey ); @@ -2798,11 +2798,11 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) { if ( nType == REG_SZ ) { - nValue = (sal_uLong)ImplW2I( aValueBuf ); + nValue = static_cast(ImplW2I( aValueBuf )); if ( (nValue > 1000) && (nValue < 10000) ) { MiscSettings aMiscSettings = rSettings.GetMiscSettings(); - utl::MiscCfg().SetYear2000( (sal_Int32)(nValue-99) ); + utl::MiscCfg().SetYear2000( static_cast(nValue-99) ); rSettings.SetMiscSettings( aMiscSettings ); } } @@ -2927,23 +2927,23 @@ void WinSalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) else { if ( nX < pBoundRect->left ) - pBoundRect->left = (int)nX; + pBoundRect->left = static_cast(nX); if ( nY < pBoundRect->top ) - pBoundRect->top = (int)nY; + pBoundRect->top = static_cast(nY); if ( nRight > pBoundRect->right ) - pBoundRect->right = (int)nRight; + pBoundRect->right = static_cast(nRight); if ( nBottom > pBoundRect->bottom ) - pBoundRect->bottom = (int)nBottom; + pBoundRect->bottom = static_cast(nBottom); } - pRect->left = (int)nX; - pRect->top = (int)nY; - pRect->right = (int)nRight; - pRect->bottom = (int)nBottom; - if( (mpNextClipRect - reinterpret_cast(&mpClipRgnData->Buffer)) < (int)mpClipRgnData->rdh.nCount ) + pRect->left = static_cast(nX); + pRect->top = static_cast(nY); + pRect->right = static_cast(nRight); + pRect->bottom = static_cast(nBottom); + if( (mpNextClipRect - reinterpret_cast(&mpClipRgnData->Buffer)) < static_cast(mpClipRgnData->rdh.nCount) ) mpNextClipRect++; } @@ -3010,8 +3010,8 @@ static bool ImplHandleMouseMsg( HWND hWnd, UINT nMsg, SalEvent nEvent = SalEvent::NONE; bool bCall = TRUE; - aMouseEvt.mnX = (short)LOWORD( lParam ); - aMouseEvt.mnY = (short)HIWORD( lParam ); + aMouseEvt.mnX = static_cast(LOWORD( lParam )); + aMouseEvt.mnY = static_cast(HIWORD( lParam )); aMouseEvt.mnCode = 0; aMouseEvt.mnTime = GetMessageTime(); @@ -3084,8 +3084,8 @@ static bool ImplHandleMouseMsg( HWND hWnd, UINT nMsg, } // Mouse-Coordinates are relative to the screen POINT aPt; - aPt.x = (short)LOWORD( lParam ); - aPt.y = (short)HIWORD( lParam ); + aPt.x = static_cast(LOWORD( lParam )); + aPt.y = static_cast(HIWORD( lParam )); ScreenToClient( hWnd, &aPt ); aMouseEvt.mnX = aPt.x; aMouseEvt.mnY = aPt.y; @@ -3177,8 +3177,8 @@ static bool ImplHandleWheelMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPar { WORD nWinModCode = LOWORD( wParam ); POINT aWinPt; - aWinPt.x = (short)LOWORD( lParam ); - aWinPt.y = (short)HIWORD( lParam ); + aWinPt.x = static_cast(LOWORD( lParam )); + aWinPt.y = static_cast(HIWORD( lParam )); ScreenToClient( hWnd, &aWinPt ); SalWheelMouseEvent aWheelEvt; @@ -3186,7 +3186,7 @@ static bool ImplHandleWheelMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPar aWheelEvt.mnX = aWinPt.x; aWheelEvt.mnY = aWinPt.y; aWheelEvt.mnCode = 0; - aWheelEvt.mnDelta = (short)HIWORD( wParam ); + aWheelEvt.mnDelta = static_cast(HIWORD( wParam )); aWheelEvt.mnNotchDelta = aWheelEvt.mnDelta/WHEEL_DELTA; if( aWheelEvt.mnNotchDelta == 0 ) { @@ -3242,7 +3242,7 @@ static sal_uInt16 ImplSalGetKeyCode( WPARAM wParam ) else { SalData* pSalData = GetSalData(); - std::map< UINT, sal_uInt16 >::const_iterator it = pSalData->maVKMap.find( (UINT)wParam ); + std::map< UINT, sal_uInt16 >::const_iterator it = pSalData->maVKMap.find( static_cast(wParam) ); if( it != pSalData->maVKMap.end() ) nKeyCode = it->second; else @@ -3273,7 +3273,7 @@ static sal_Unicode ImplGetCharCode( WinSalFrame* pFrame, WPARAM nCharCode ) // We are on Windows NT so we use Unicode FrameProcs and we // get Unicode charcodes directly from Windows - return (sal_Unicode)nCharCode; + return static_cast(nCharCode); } LanguageType WinSalFrame::GetInputLanguage() @@ -3290,7 +3290,7 @@ LanguageType WinSalFrame::GetInputLanguage() bool WinSalFrame::MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) { bool bRet = FALSE; - sal_IntPtr nLangType = (sal_uInt16)aLangType; + sal_IntPtr nLangType = static_cast(aLangType); // just use the passed language identifier, do not try to load additional keyboard support HKL hkl = reinterpret_cast(nLangType); @@ -3439,10 +3439,10 @@ static bool ImplHandleKeyMsg( HWND hWnd, UINT nMsg, nLastVKChar = 0; pFrame->CallCallback( SalEvent::KeyInput, &aKeyEvt ); pFrame->CallCallback( SalEvent::KeyUp, &aKeyEvt ); - wParam = (sal_Unicode) Uni_UTF32ToSurrogate2( wParam ); + wParam = static_cast(Uni_UTF32ToSurrogate2( wParam )); } - aKeyEvt.mnCharCode = (sal_Unicode) wParam; + aKeyEvt.mnCharCode = static_cast(wParam); nLastChar = 0; nLastVKChar = 0; @@ -3660,7 +3660,7 @@ bool ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam ) sal_uInt16 nRepeat = LOWORD( lParam )-1; sal_uInt16 nModCode = 0; - sal_uInt16 cKeyCode = (sal_uInt16)wParam; + sal_uInt16 cKeyCode = static_cast(wParam); // determine modifiers if ( GetKeyState( VK_SHIFT ) & 0x8000 ) @@ -3975,8 +3975,8 @@ static void ImplHandleSizeMsg( HWND hWnd, WPARAM wParam, LPARAM lParam ) { UpdateFrameGeometry( hWnd, pFrame ); - pFrame->mnWidth = (int)LOWORD(lParam); - pFrame->mnHeight = (int)HIWORD(lParam); + pFrame->mnWidth = static_cast(LOWORD(lParam)); + pFrame->mnHeight = static_cast(HIWORD(lParam)); // save state ImplSaveFrameState( pFrame ); // Call Hdl @@ -4394,7 +4394,7 @@ static int ImplMenuChar( HWND, WPARAM wParam, LPARAM lParam ) { int nRet = MNC_IGNORE; HMENU hMenu = reinterpret_cast(lParam); - OUString aMnemonic( "&" + OUStringLiteral1((sal_Unicode) LOWORD(wParam)) ); + OUString aMnemonic( "&" + OUStringLiteral1(static_cast(LOWORD(wParam))) ); aMnemonic = aMnemonic.toAsciiLowerCase(); // we only have ascii mnemonics // search the mnemonic in the current menu @@ -4574,7 +4574,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) GlobalUnlock( hDrawDIB ); HBRUSH hbrIcon = CreateSolidBrush( GetSysColor( COLOR_GRAYTEXT ) ); - DrawStateW( pDI->hDC, hbrIcon, nullptr, reinterpret_cast(hBmp), (WPARAM)0, + DrawStateW( pDI->hDC, hbrIcon, nullptr, reinterpret_cast(hBmp), WPARAM(0), x, y+(lineHeight-bmpSize.Height())/2, bmpSize.Width(), bmpSize.Height(), DST_BITMAP | (fDisabled ? (fSelected ? DSS_MONO : DSS_DISABLED) : DSS_NORMAL) ); @@ -4604,7 +4604,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) if(!DrawStateW( pDI->hDC, nullptr, nullptr, reinterpret_cast(aStr.getStr()), - (WPARAM)0, aRect.left, aRect.top + (lineHeight - strSize.cy)/2, 0, 0, + WPARAM(0), aRect.left, aRect.top + (lineHeight - strSize.cy)/2, 0, 0, DST_PREFIXTEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ) ) SAL_WARN("vcl", "DrawStateW failed: " << WindowsErrorString(GetLastError())); @@ -4621,7 +4621,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam ) // (potential) submenu arrow (tm.tmMaxCharWidth) if(!DrawStateW( pDI->hDC, nullptr, nullptr, reinterpret_cast(aStr.getStr()), - (WPARAM)0, aRect.right-strSizeA.cx-tm.tmMaxCharWidth, aRect.top + (lineHeight - strSizeA.cy)/2, 0, 0, + WPARAM(0), aRect.right-strSizeA.cx-tm.tmMaxCharWidth, aRect.top + (lineHeight - strSizeA.cy)/2, 0, 0, DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ) ) SAL_WARN("vcl", "DrawStateW failed: " << WindowsErrorString(GetLastError())); } @@ -4838,7 +4838,7 @@ static bool ImplHandleSysCommand( HWND hWnd, WPARAM wParam, LPARAM lParam ) HWND hFocusWnd = ::GetFocus(); if ( hFocusWnd && ImplFindSalObject( hFocusWnd ) ) { - char cKeyCode = (char)(unsigned char)LOWORD( lParam ); + char cKeyCode = static_cast(static_cast(LOWORD( lParam ))); // LowerCase if ( (cKeyCode >= 65) && (cKeyCode <= 90) ) cKeyCode += 32; @@ -4985,7 +4985,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, { auto pTextBuf = std::unique_ptr(new WCHAR[nTextLen]); ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); - aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), (sal_Int32)nTextLen ); + aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), static_cast(nTextLen) ); } aEvt.mnCursorPos = aEvt.maText.getLength(); @@ -5011,7 +5011,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, { auto pTextBuf = std::unique_ptr(new WCHAR[nTextLen]); ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); - aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), (sal_Int32)nTextLen ); + aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), static_cast(nTextLen) ); } std::unique_ptr pAttrBuf; @@ -5200,7 +5200,7 @@ static bool ImplHandleAppCommand( HWND hWnd, LPARAM lParam, LRESULT & nRet ) static void ImplHandleIMENotify( HWND hWnd, WPARAM wParam ) { - if ( wParam == (WPARAM)IMN_OPENCANDIDATE ) + if ( wParam == WPARAM(IMN_OPENCANDIDATE) ) { ImplSalYieldMutexAcquireWithWait(); @@ -5241,7 +5241,7 @@ static void ImplHandleIMENotify( HWND hWnd, WPARAM wParam ) ImplSalYieldMutexRelease(); } - else if ( wParam == (WPARAM)IMN_CLOSECANDIDATE ) + else if ( wParam == WPARAM(IMN_CLOSECANDIDATE) ) { ImplSalYieldMutexAcquireWithWait(); WinSalFrame* pFrame = GetWindowPtr( hWnd ); @@ -5426,8 +5426,8 @@ static int ImplSalWheelMousePos( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lPa { POINT aPt; POINT aScreenPt; - aScreenPt.x = (short)LOWORD( lParam ); - aScreenPt.y = (short)HIWORD( lParam ); + aScreenPt.x = static_cast(LOWORD( lParam )); + aScreenPt.y = static_cast(HIWORD( lParam )); // find child window that is at this position HWND hChildWnd; HWND hWheelWnd = hWnd; @@ -5755,11 +5755,11 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP rDef = FALSE; break; case SAL_MSG_TOTOP: - ImplSalToTop( hWnd, (SalFrameToTop)wParam ); + ImplSalToTop( hWnd, static_cast(wParam) ); rDef = FALSE; break; case SAL_MSG_SHOW: - ImplSalShow( hWnd, (bool)wParam, (bool)lParam ); + ImplSalShow( hWnd, static_cast(wParam), static_cast(lParam) ); rDef = FALSE; break; case SAL_MSG_SETINPUTCONTEXT: @@ -5767,7 +5767,7 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP rDef = FALSE; break; case SAL_MSG_ENDEXTTEXTINPUT: - ImplSalFrameEndExtTextInput( hWnd, (EndExtTextInputFlags)wParam ); + ImplSalFrameEndExtTextInput( hWnd, static_cast(wParam) ); rDef = FALSE; break; @@ -5816,17 +5816,17 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP } break; case WM_IME_REQUEST: - if ( (sal_uIntPtr)wParam == IMR_RECONVERTSTRING ) + if ( static_cast(wParam) == IMR_RECONVERTSTRING ) { nRet = ImplHandleIMEReconvertString( hWnd, lParam ); rDef = FALSE; } - else if( (sal_uIntPtr)wParam == IMR_CONFIRMRECONVERTSTRING ) + else if( static_cast(wParam) == IMR_CONFIRMRECONVERTSTRING ) { nRet = ImplHandleIMEConfirmReconvertString( hWnd, lParam ); rDef = FALSE; } - else if ( (sal_uIntPtr)wParam == IMR_QUERYCHARPOSITION ) + else if ( static_cast(wParam) == IMR_QUERYCHARPOSITION ) { if ( ImplSalYieldMutexTryToAcquire() ) { diff --git a/vcl/win/window/salmenu.cxx b/vcl/win/window/salmenu.cxx index 592813759e88..45be022ef23b 100644 --- a/vcl/win/window/salmenu.cxx +++ b/vcl/win/window/salmenu.cxx @@ -189,7 +189,7 @@ void WinSalMenu::InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) void WinSalMenu::RemoveItem( unsigned nPos ) { int num = ::GetMenuItemCount( mhMenu ); - if( num != -1 && nPos < (unsigned)num ) + if( num != -1 && nPos < static_cast(num) ) { WinSalMenuItem *pSalMenuItem = nullptr; diff --git a/vcl/win/window/salobj.cxx b/vcl/win/window/salobj.cxx index 0996e9c5eb13..ad352217ed89 100644 --- a/vcl/win/window/salobj.cxx +++ b/vcl/win/window/salobj.cxx @@ -348,7 +348,7 @@ LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l if ( hWndChild ) { SetWindowPos( hWndChild, - nullptr, 0, 0, (int)LOWORD( lParam ), (int)HIWORD( lParam ), + nullptr, 0, 0, static_cast(LOWORD( lParam )), static_cast(HIWORD( lParam )), SWP_NOZORDER | SWP_NOACTIVATE ); } } @@ -430,10 +430,10 @@ LRESULT CALLBACK SalSysObjChildWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPA // transform coordinates POINT pt; - pt.x = (long) LOWORD( lParam ); - pt.y = (long) HIWORD( lParam ); + pt.x = static_cast(LOWORD( lParam )); + pt.y = static_cast(HIWORD( lParam )); MapWindowPoints( hWnd, hWndParent, &pt, 1 ); - lParam = MAKELPARAM( (WORD) pt.x, (WORD) pt.y ); + lParam = MAKELPARAM( static_cast(pt.x), static_cast(pt.y) ); nRet = SendMessageW( hWndParent, nMsg, wParam, lParam ); rDef = FALSE; @@ -640,22 +640,22 @@ void WinSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight else { if ( nX < pBoundRect->left ) - pBoundRect->left = (int)nX; + pBoundRect->left = static_cast(nX); if ( nY < pBoundRect->top ) - pBoundRect->top = (int)nY; + pBoundRect->top = static_cast(nY); if ( nRight > pBoundRect->right ) - pBoundRect->right = (int)nRight; + pBoundRect->right = static_cast(nRight); if ( nBottom > pBoundRect->bottom ) - pBoundRect->bottom = (int)nBottom; + pBoundRect->bottom = static_cast(nBottom); } - pRect->left = (int)nX; - pRect->top = (int)nY; - pRect->right = (int)nRight; - pRect->bottom = (int)nBottom; + pRect->left = static_cast(nX); + pRect->top = static_cast(nY); + pRect->right = static_cast(nRight); + pRect->bottom = static_cast(nBottom); mpNextClipRect++; } @@ -692,7 +692,7 @@ void WinSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight ) nStyle |= SWP_SHOWWINDOW; } SetWindowPos( mhWnd, nullptr, - (int)nX, (int)nY, (int)nWidth, (int)nHeight, + static_cast(nX), static_cast(nY), static_cast(nWidth), static_cast(nHeight), SWP_NOZORDER | SWP_NOACTIVATE | nStyle ); } diff --git a/winaccessibility/source/UAccCOM/AccComponentBase.cxx b/winaccessibility/source/UAccCOM/AccComponentBase.cxx index 68f800f2c20d..e41123ea33e9 100644 --- a/winaccessibility/source/UAccCOM/AccComponentBase.cxx +++ b/winaccessibility/source/UAccCOM/AccComponentBase.cxx @@ -142,7 +142,7 @@ STDMETHODIMP CAccComponentBase::get_foreground(IA2Color * foreground) { return E_FAIL; } - *foreground = (long)GetXInterface()->getForeground(); + *foreground = static_cast(GetXInterface()->getForeground()); return S_OK; @@ -167,7 +167,7 @@ STDMETHODIMP CAccComponentBase::get_background(IA2Color * background) { return E_FAIL; } - *background = (long)GetXInterface()->getBackground(); + *background = static_cast(GetXInterface()->getBackground()); return S_OK; diff --git a/winaccessibility/source/UAccCOM/AccEditableText.cxx b/winaccessibility/source/UAccCOM/AccEditableText.cxx index 7c5b87171fc7..a53d99b0a935 100644 --- a/winaccessibility/source/UAccCOM/AccEditableText.cxx +++ b/winaccessibility/source/UAccCOM/AccEditableText.cxx @@ -295,7 +295,7 @@ void CAccEditableText::get_AnyFromOLECHAR(const ::rtl::OUString &ouName, const : ouName == "CharFontPitch" ) { // Convert to short. - short nValue = (short)ouValue.toInt32(); + short nValue = static_cast(ouValue.toInt32()); rAny.setValue(&nValue, cppu::UnoType::get()); } else if(ouName == "CharHeight" || @@ -313,7 +313,7 @@ void CAccEditableText::get_AnyFromOLECHAR(const ::rtl::OUString &ouName, const : else if(ouName == "CharPosture" ) { // Convert to FontSlant. - css::awt::FontSlant fontSlant = (css::awt::FontSlant)ouValue.toInt32(); + css::awt::FontSlant fontSlant = static_cast(ouValue.toInt32()); rAny.setValue(&fontSlant, cppu::UnoType::get()); } else if(ouName == "ParaTabStops" ) @@ -346,7 +346,7 @@ void CAccEditableText::get_AnyFromOLECHAR(const ::rtl::OUString &ouName, const : if(posComma != -1) { ouSubValue = ouValue.copy(pos + 9, posComma - pos - 9); - tabStop.Alignment = (css::style::TabAlign)ouSubValue.toInt32(); + tabStop.Alignment = static_cast(ouSubValue.toInt32()); pos = posComma + 1; // DecimalChar. @@ -439,30 +439,30 @@ void CAccEditableText::get_AnyFromOLECHAR(const ::rtl::OUString &ouName, const : if(posComma != -1) { ouSubValue = ouValue.copy(pos + 5, posComma - pos - 5); - lineSpacing.Mode = (sal_Int16)ouSubValue.toInt32(); + lineSpacing.Mode = static_cast(ouSubValue.toInt32()); pos = posComma + 1; pos = ouValue.indexOf("Height=", pos); if(pos != -1) { ouSubValue = ouValue.copy(pos + 7); - lineSpacing.Height = (sal_Int16)ouSubValue.toInt32(); + lineSpacing.Height = static_cast(ouSubValue.toInt32()); } else { - lineSpacing.Height = (sal_Int16)100; // Default height. + lineSpacing.Height = sal_Int16(100); // Default height. } } else { - lineSpacing.Height = (sal_Int16)100; // Default height. + lineSpacing.Height = sal_Int16(100); // Default height. } } else { // Default Mode and Height. - lineSpacing.Mode = (sal_Int16)0; - lineSpacing.Height = (sal_Int16)100; // Default height. + lineSpacing.Mode = sal_Int16(0); + lineSpacing.Height = sal_Int16(100); // Default height. } // Convert to Any object. diff --git a/winaccessibility/source/UAccCOM/EnumVariant.cxx b/winaccessibility/source/UAccCOM/EnumVariant.cxx index ba2d443ca91f..ec21526e2d19 100644 --- a/winaccessibility/source/UAccCOM/EnumVariant.cxx +++ b/winaccessibility/source/UAccCOM/EnumVariant.cxx @@ -103,7 +103,7 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Skip(ULONG cElements) SolarMutexGuard g; m_lCurrent += cElements; - if (m_lCurrent > (long)(m_lLBound+m_pXAccessibleSelection->getSelectedAccessibleChildCount())) + if (m_lCurrent > static_cast(m_lLBound+m_pXAccessibleSelection->getSelectedAccessibleChildCount())) { m_lCurrent = m_lLBound+m_pXAccessibleSelection->getSelectedAccessibleChildCount(); return E_FAIL; diff --git a/winaccessibility/source/service/AccObject.cxx b/winaccessibility/source/service/AccObject.cxx index c72b41c7fa6f..ed0ac90eebb7 100644 --- a/winaccessibility/source/service/AccObject.cxx +++ b/winaccessibility/source/service/AccObject.cxx @@ -367,7 +367,7 @@ void AccObject::UpdateDefaultAction( ) case CHECK_BOX: case TREE_ITEM: case BUTTON_DROPDOWN: - m_pIMAcc->Put_ActionDescription( o3tl::toW(m_xAccActionRef->getAccessibleActionDescription((sal_Int32)0).getStr()) ); + m_pIMAcc->Put_ActionDescription( o3tl::toW(m_xAccActionRef->getAccessibleActionDescription(sal_Int32(0)).getStr()) ); return; } } diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx b/winaccessibility/source/service/AccObjectWinManager.cxx index 4298dff3d4d1..d5557d685539 100644 --- a/winaccessibility/source/service/AccObjectWinManager.cxx +++ b/winaccessibility/source/service/AccObjectWinManager.cxx @@ -1015,7 +1015,7 @@ void AccObjectWinManager::SetRole( XAccessible* pXAcc, long Role ) { AccObject* pAccObj = GetAccObjByXAcc( pXAcc ); if( pAccObj ) - pAccObj->SetRole( (short)Role ); + pAccObj->SetRole( static_cast(Role) ); } /** diff --git a/winaccessibility/source/service/AccTopWindowListener.cxx b/winaccessibility/source/service/AccTopWindowListener.cxx index 5ddb8deffb9a..65b95c6e7bbe 100644 --- a/winaccessibility/source/service/AccTopWindowListener.cxx +++ b/winaccessibility/source/service/AccTopWindowListener.cxx @@ -77,7 +77,7 @@ void AccTopWindowListener::HandleWindowOpened( css::accessibility::XAccessible* AddAllListeners(pAccessible,nullptr,systemdata->hWnd); if( window->GetStyle() & WB_MOVEABLE ) - accManagerAgent.IncreaseState( pAccessible, (unsigned short) -1 /* U_MOVEBLE */ ); + accManagerAgent.IncreaseState( pAccessible, static_cast(-1) /* U_MOVEBLE */ ); short role = pAccessibleContext->getAccessibleRole(); diff --git a/winaccessibility/source/service/msaaservice_impl.cxx b/winaccessibility/source/service/msaaservice_impl.cxx index cc3b92116fdc..95968c4d65ad 100644 --- a/winaccessibility/source/service/msaaservice_impl.cxx +++ b/winaccessibility/source/service/msaaservice_impl.cxx @@ -216,7 +216,7 @@ static void AccessBridgeHandleExistingWindow(const Reference< XMSAAService > &xA */ static void AccessBridgeUpdateOldTopWindows( const Reference< XMSAAService > &xAccMgr ) { - sal_uInt16 nTopWindowCount = (sal_uInt16)Application::GetTopWindowCount(); + sal_uInt16 nTopWindowCount = static_cast(Application::GetTopWindowCount()); for ( sal_uInt16 i = 0; i < nTopWindowCount; i++ ) { diff --git a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx index 54eaafbfc036..4b6ef98cf905 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/sanextension_mscryptimpl.cxx @@ -71,7 +71,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: auto arrCertAltNameEntry = std::unique_ptr(new CertAltNameEntry[subjectName->cAltEntry]); - for (unsigned int i = 0; i < (unsigned int)subjectName->cAltEntry; i++){ + for (unsigned int i = 0; i < static_cast(subjectName->cAltEntry); i++){ PCERT_ALT_NAME_ENTRY pEntry = &subjectName->rgAltEntry[i]; switch(pEntry->dwAltNameChoice) { @@ -84,7 +84,7 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: otherNameProp.Name = OUString::createFromAscii(pOtherName->pszObjId); Sequence< sal_Int8 > otherName( pOtherName->Value.cbData ) ; - for( unsigned int n = 0; n < (unsigned int) pOtherName->Value.cbData ; n ++ ) + for( unsigned int n = 0; n < static_cast(pOtherName->Value.cbData) ; n ++ ) otherName[n] = *( pOtherName->Value.pbData + n ) ; otherNameProp.Value <<= otherName; diff --git a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx index 3ec06fc0182c..45fa3606fd9e 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/securityenvironment_mscryptimpl.cxx @@ -756,7 +756,7 @@ Reference< XCertificate > SecurityEnvironment_MSCryptImpl::createCertificateFrom OString oscert = OUStringToOString( asciiCertificate , RTL_TEXTENCODING_ASCII_US ) ; - chCert = xmlStrndup( reinterpret_cast(oscert.getStr()), ( int )oscert.getLength() ) ; + chCert = xmlStrndup( reinterpret_cast(oscert.getStr()), static_cast(oscert.getLength()) ) ; certSize = xmlSecBase64Decode( chCert, chCert, xmlStrlen( chCert ) ) ; diff --git a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx index 07a769ac99cf..d1e6a7752449 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl.cxx @@ -186,7 +186,7 @@ X509Certificate_MSCryptImpl::~X509Certificate_MSCryptImpl() { //Methods from XCertificate sal_Int16 SAL_CALL X509Certificate_MSCryptImpl::getVersion() { if( m_pCertContext != nullptr && m_pCertContext->pCertInfo != nullptr ) { - return ( char )m_pCertContext->pCertInfo->dwVersion ; + return static_cast(m_pCertContext->pCertInfo->dwVersion) ; } else { return -1 ; } -- cgit