diff options
Diffstat (limited to 'vcl')
152 files changed, 1423 insertions, 1421 deletions
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index 045859b14262..648577297a0f 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -240,17 +240,17 @@ void SvpSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u if( (nFlags & SAL_FRAME_POSSIZE_WIDTH) != 0 ) { maGeometry.nWidth = nWidth; - if( m_nMaxWidth > 0 && maGeometry.nWidth > (unsigned int)m_nMaxWidth ) + if( m_nMaxWidth > 0 && maGeometry.nWidth > static_cast<unsigned int>(m_nMaxWidth) ) maGeometry.nWidth = m_nMaxWidth; - if( m_nMinWidth > 0 && maGeometry.nWidth < (unsigned int)m_nMinWidth ) + if( m_nMinWidth > 0 && maGeometry.nWidth < static_cast<unsigned int>(m_nMinWidth) ) maGeometry.nWidth = m_nMinWidth; } if( (nFlags & SAL_FRAME_POSSIZE_HEIGHT) != 0 ) { maGeometry.nHeight = nHeight; - if( m_nMaxHeight > 0 && maGeometry.nHeight > (unsigned int)m_nMaxHeight ) + if( m_nMaxHeight > 0 && maGeometry.nHeight > static_cast<unsigned int>(m_nMaxHeight) ) maGeometry.nHeight = m_nMaxHeight; - if( m_nMinHeight > 0 && maGeometry.nHeight < (unsigned int)m_nMinHeight ) + if( m_nMinHeight > 0 && maGeometry.nHeight < static_cast<unsigned int>(m_nMinHeight) ) maGeometry.nHeight = m_nMinHeight; } #ifndef IOS diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 3e3e7babcd44..d2970489980b 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -396,8 +396,8 @@ bool SvpSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, const SalBitmap& rS cairo_pattern_t* maskpattern = cairo_pattern_create_for_surface(mask); cairo_translate(cr, rTR.mnDestX, rTR.mnDestY); - double fXScale = (double)(rTR.mnDestWidth)/rTR.mnSrcWidth; - double fYScale = ((double)rTR.mnDestHeight)/rTR.mnSrcHeight; + double fXScale = static_cast<double>(rTR.mnDestWidth)/rTR.mnSrcWidth; + double fYScale = static_cast<double>(rTR.mnDestHeight)/rTR.mnSrcHeight; cairo_scale(cr, fXScale, fYScale); cairo_set_source_surface(cr, source, -rTR.mnSrcX, -rTR.mnSrcY); @@ -1130,8 +1130,8 @@ static basegfx::B2DRange renderSource(cairo_t* cr, const SalTwoRect& rTR, double fXScale = 1.0f; double fYScale = 1.0f; if (rTR.mnSrcWidth != 0 && rTR.mnSrcHeight != 0) { - fXScale = (double)(rTR.mnDestWidth)/rTR.mnSrcWidth; - fYScale = ((double)rTR.mnDestHeight)/rTR.mnSrcHeight; + fXScale = static_cast<double>(rTR.mnDestWidth)/rTR.mnSrcWidth; + fYScale = static_cast<double>(rTR.mnDestHeight)/rTR.mnSrcHeight; cairo_scale(cr, fXScale, fYScale); } @@ -1279,8 +1279,8 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR, cairo_clip(cr); cairo_translate(cr, rTR.mnDestX, rTR.mnDestY); - double fXScale = (double)(rTR.mnDestWidth)/rTR.mnSrcWidth; - double fYScale = ((double)rTR.mnDestHeight)/rTR.mnSrcHeight; + double fXScale = static_cast<double>(rTR.mnDestWidth)/rTR.mnSrcWidth; + double fYScale = static_cast<double>(rTR.mnDestHeight)/rTR.mnSrcHeight; cairo_scale(cr, fXScale, fYScale); cairo_set_source_surface(cr, aSurface.getSurface(), -rTR.mnSrcX, -rTR.mnSrcY); if ((fXScale != 1.0 && rTR.mnSrcWidth == 1) || (fYScale != 1.0 && rTR.mnSrcHeight == 1)) diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx index 1d3666a79beb..5e0abfb3df75 100644 --- a/vcl/headless/svpprn.cxx +++ b/vcl/headless/svpprn.cxx @@ -56,7 +56,7 @@ static OUString getPdfDir( const PrinterInfo& rInfo ) return aDir; } -inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778)+0.5); } +inline int PtTo10Mu( int nPoints ) { return static_cast<int>((static_cast<double>(nPoints)*35.27777778)+0.5); } static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) { diff --git a/vcl/inc/impoctree.hxx b/vcl/inc/impoctree.hxx index fc63122d3e0f..073720a9e319 100644 --- a/vcl/inc/impoctree.hxx +++ b/vcl/inc/impoctree.hxx @@ -38,9 +38,9 @@ public: } ImpErrorQuad( const BitmapColor& rColor ) - : nRed( (long) rColor.GetRed() << 5 ) - , nGreen( (long) rColor.GetGreen() << 5 ) - , nBlue( (long) rColor.GetBlue() << 5 ) + : nRed( static_cast<long>(rColor.GetRed()) << 5 ) + , nGreen( static_cast<long>(rColor.GetGreen()) << 5 ) + , nBlue( static_cast<long>(rColor.GetBlue()) << 5 ) { } @@ -57,16 +57,16 @@ public: inline void ImpErrorQuad::operator=( const BitmapColor& rColor ) { - nRed = (long) rColor.GetRed() << 5; - nGreen = (long) rColor.GetGreen() << 5; - nBlue = (long) rColor.GetBlue() << 5; + nRed = static_cast<long>(rColor.GetRed()) << 5; + nGreen = static_cast<long>(rColor.GetGreen()) << 5; + nBlue = static_cast<long>(rColor.GetBlue()) << 5; } inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor ) { - nRed -= ( (long) rColor.GetRed() << 5 ); - nGreen -= ( (long) rColor.GetGreen() << 5 ); - nBlue -= ( (long) rColor.GetBlue() << 5 ); + nRed -= ( static_cast<long>(rColor.GetRed()) << 5 ); + nGreen -= ( static_cast<long>(rColor.GetGreen()) << 5 ); + nBlue -= ( static_cast<long>(rColor.GetBlue()) << 5 ); return *this; } @@ -101,9 +101,9 @@ inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad ) inline BitmapColor ImpErrorQuad::ImplGetColor() { - return BitmapColor( (sal_uInt8) ( ( nRed < 0 ? 0L : nRed > 8160 ? 8160L : nRed ) >> 5 ), - (sal_uInt8) ( ( nGreen < 0 ? 0L : nGreen > 8160 ? 8160L : nGreen ) >> 5 ), - (sal_uInt8) ( ( nBlue < 0 ? 0L : nBlue > 8160 ? 8160L : nBlue ) >> 5 ) ); + return BitmapColor( static_cast<sal_uInt8>( ( nRed < 0 ? 0L : nRed > 8160 ? 8160L : nRed ) >> 5 ), + static_cast<sal_uInt8>( ( nGreen < 0 ? 0L : nGreen > 8160 ? 8160L : nGreen ) >> 5 ), + static_cast<sal_uInt8>( ( nBlue < 0 ? 0L : nBlue > 8160 ? 8160L : nBlue ) >> 5 ) ); } class ImpNodeCache diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx index 402275af73a0..cea25b5cfeb0 100644 --- a/vcl/inc/listbox.hxx +++ b/vcl/inc/listbox.hxx @@ -113,7 +113,7 @@ public: long GetAddedHeight( sal_Int32 nEndIndex, sal_Int32 nBeginIndex ) const; long GetEntryHeight( sal_Int32 nPos ) const; - sal_Int32 GetEntryCount() const { return (sal_Int32 )maEntries.size(); } + sal_Int32 GetEntryCount() const { return static_cast<sal_Int32>(maEntries.size()); } bool HasImages() const { return mnImages != 0; } OUString GetEntryText( sal_Int32 nPos ) const; diff --git a/vcl/inc/octree.hxx b/vcl/inc/octree.hxx index 114425befdc7..7665d9321619 100644 --- a/vcl/inc/octree.hxx +++ b/vcl/inc/octree.hxx @@ -75,7 +75,7 @@ public: inline const BitmapPalette& Octree::GetPalette() { - aPal.SetEntryCount( (sal_uInt16) nLeafCount ); + aPal.SetEntryCount( static_cast<sal_uInt16>(nLeafCount) ); nPalIndex = 0; CreatePalette( pTree ); return aPal; @@ -110,9 +110,9 @@ public: inline sal_uInt16 InverseColorMap::GetBestPaletteIndex( const BitmapColor& rColor ) { - return pMap[ ( ( (sal_uLong) rColor.GetRed() >> nBits ) << OCTREE_BITS_1 ) | - ( ( (sal_uLong) rColor.GetGreen() >> nBits ) << OCTREE_BITS ) | - ( (sal_uLong) rColor.GetBlue() >> nBits ) ]; + return pMap[ ( ( static_cast<sal_uLong>(rColor.GetRed()) >> nBits ) << OCTREE_BITS_1 ) | + ( ( static_cast<sal_uLong>(rColor.GetGreen()) >> nBits ) << OCTREE_BITS ) | + ( static_cast<sal_uLong>(rColor.GetBlue()) >> nBits ) ]; } #endif // INCLUDED_VCL_INC_OCTREE_HXX diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx index 652da0177279..766301256f6e 100644 --- a/vcl/inc/salframe.hxx +++ b/vcl/inc/salframe.hxx @@ -90,10 +90,10 @@ typedef sal_uInt64 SalExtStyle; #define SAL_FRAME_EXT_STYLE_DOCMODIFIED SalExtStyle(0x00000002) // Flags for SetPosSize -#define SAL_FRAME_POSSIZE_X ((sal_uInt16)0x0001) -#define SAL_FRAME_POSSIZE_Y ((sal_uInt16)0x0002) -#define SAL_FRAME_POSSIZE_WIDTH ((sal_uInt16)0x0004) -#define SAL_FRAME_POSSIZE_HEIGHT ((sal_uInt16)0x0008) +#define SAL_FRAME_POSSIZE_X (sal_uInt16(0x0001)) +#define SAL_FRAME_POSSIZE_Y (sal_uInt16(0x0002)) +#define SAL_FRAME_POSSIZE_WIDTH (sal_uInt16(0x0004)) +#define SAL_FRAME_POSSIZE_HEIGHT (sal_uInt16(0x0008)) struct SystemParentData; struct ImplSVEvent; diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx index 1538c8e78a25..c8cce972b788 100644 --- a/vcl/inc/salwtype.hxx +++ b/vcl/inc/salwtype.hxx @@ -139,7 +139,7 @@ struct SalPaintEvent {} }; -#define SAL_WHEELMOUSE_EVENT_PAGESCROLL ((sal_uLong)0xFFFFFFFF) +#define SAL_WHEELMOUSE_EVENT_PAGESCROLL (sal_uLong(0xFFFFFFFF)) struct SalWheelMouseEvent { sal_uInt64 mnTime; // Time in ms, when event is created diff --git a/vcl/opengl/framebuffer.cxx b/vcl/opengl/framebuffer.cxx index cb91ea482b79..db957d1a6cd0 100644 --- a/vcl/opengl/framebuffer.cxx +++ b/vcl/opengl/framebuffer.cxx @@ -22,19 +22,19 @@ OpenGLFramebuffer::OpenGLFramebuffer() : { glGenFramebuffers( 1, &mnId ); CHECK_GL_ERROR(); - VCL_GL_INFO( "Created framebuffer " << (int)mnId ); + VCL_GL_INFO( "Created framebuffer " << static_cast<int>(mnId) ); } OpenGLFramebuffer::~OpenGLFramebuffer() { glDeleteFramebuffers( 1, &mnId ); - VCL_GL_INFO( "Deleted framebuffer " << (int)mnId ); + VCL_GL_INFO( "Deleted framebuffer " << static_cast<int>(mnId) ); CHECK_GL_ERROR(); } void OpenGLFramebuffer::Bind(GLenum eTarget) { - VCL_GL_INFO( "Binding framebuffer " << (int)mnId ); + VCL_GL_INFO( "Binding framebuffer " << static_cast<int>(mnId) ); glBindFramebuffer(eTarget, mnId); CHECK_GL_ERROR(); } @@ -66,7 +66,7 @@ void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture ) if( rTexture.Id() == mnAttachedTexture ) return; - VCL_GL_INFO( "Attaching texture " << rTexture.Id() << " to framebuffer " << (int)mnId ); + VCL_GL_INFO( "Attaching texture " << rTexture.Id() << " to framebuffer " << static_cast<int>(mnId) ); mnAttachedTexture = rTexture.Id(); mnWidth = rTexture.GetWidth(); mnHeight = rTexture.GetHeight(); @@ -76,7 +76,7 @@ void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture ) GLuint nStencil = rTexture.StencilId(); if( nStencil ) { - VCL_GL_INFO( "Attaching stencil " << nStencil << " to framebuffer " << (int)mnId ); + VCL_GL_INFO( "Attaching stencil " << nStencil << " to framebuffer " << static_cast<int>(mnId) ); glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, nStencil ); CHECK_GL_ERROR(); diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 110071042519..608b28dbb927 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -2128,8 +2128,8 @@ void OpenGLSalGraphicsImpl::doFlush() mpWindowContext->state().stencil().disable(); #if OSL_DEBUG_LEVEL > 0 // random background glClear - glClearColor((float)rand()/RAND_MAX, (float)rand()/RAND_MAX, - (float)rand()/RAND_MAX, 1.0); + glClearColor(static_cast<float>(rand())/RAND_MAX, static_cast<float>(rand())/RAND_MAX, + static_cast<float>(rand())/RAND_MAX, 1.0); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); CHECK_GL_ERROR(); #endif diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx index 54b71c24cb49..6c3a03df14b4 100644 --- a/vcl/opengl/program.cxx +++ b/vcl/opengl/program.cxx @@ -238,9 +238,9 @@ void OpenGLProgram::SetColor( const OString& rName, SalColor nColor, sal_uInt8 n { GLuint nUniform = GetUniformLocation( rName ); glUniform4f( nUniform, - ((float) SALCOLOR_RED( nColor )) / 255, - ((float) SALCOLOR_GREEN( nColor )) / 255, - ((float) SALCOLOR_BLUE( nColor )) / 255, + static_cast<float>(SALCOLOR_RED( nColor )) / 255, + static_cast<float>(SALCOLOR_GREEN( nColor )) / 255, + static_cast<float>(SALCOLOR_BLUE( nColor )) / 255, (100 - nTransparency) * (1.0 / 100) ); CHECK_GL_ERROR(); @@ -252,9 +252,9 @@ void OpenGLProgram::SetColorf( const OString& rName, SalColor nColor, double fTr { GLuint nUniform = GetUniformLocation( rName ); glUniform4f( nUniform, - ((float) SALCOLOR_RED( nColor )) / 255, - ((float) SALCOLOR_GREEN( nColor )) / 255, - ((float) SALCOLOR_BLUE( nColor )) / 255, + static_cast<float>(SALCOLOR_RED( nColor )) / 255, + static_cast<float>(SALCOLOR_GREEN( nColor )) / 255, + static_cast<float>(SALCOLOR_BLUE( nColor )) / 255, (1.0f - fTransparency) ); CHECK_GL_ERROR(); @@ -266,10 +266,10 @@ void OpenGLProgram::SetColor( const OString& rName, const Color& rColor ) { GLuint nUniform = GetUniformLocation( rName ); glUniform4f( nUniform, - ((float) rColor.GetRed()) / 255, - ((float) rColor.GetGreen()) / 255, - ((float) rColor.GetBlue()) / 255, - 1.0f - ((float) rColor.GetTransparency()) / 255 ); + static_cast<float>(rColor.GetRed()) / 255, + static_cast<float>(rColor.GetGreen()) / 255, + static_cast<float>(rColor.GetBlue()) / 255, + 1.0f - static_cast<float>(rColor.GetTransparency()) / 255 ); CHECK_GL_ERROR(); if( rColor.GetTransparency() > 0 ) @@ -280,9 +280,9 @@ void OpenGLProgram::SetColorWithIntensity( const OString& rName, const Color& rC { GLuint nUniform = GetUniformLocation( rName ); glUniform4f( nUniform, - ((float) rColor.GetRed()) * nFactor / 25500.0, - ((float) rColor.GetGreen()) * nFactor / 25500.0, - ((float) rColor.GetBlue()) * nFactor / 25500.0, + static_cast<float>(rColor.GetRed()) * nFactor / 25500.0, + static_cast<float>(rColor.GetGreen()) * nFactor / 25500.0, + static_cast<float>(rColor.GetBlue()) * nFactor / 25500.0, 1.0f ); CHECK_GL_ERROR(); } @@ -317,10 +317,10 @@ void OpenGLProgram::SetTransform( const basegfx::B2DVector aXRel = rX - rNull; const basegfx::B2DVector aYRel = rY - rNull; const float aValues[] = { - (float) aXRel.getX()/nTexWidth, (float) aXRel.getY()/nTexWidth, 0, 0, - (float) aYRel.getX()/nTexHeight, (float) aYRel.getY()/nTexHeight, 0, 0, + static_cast<float>(aXRel.getX())/nTexWidth, static_cast<float>(aXRel.getY())/nTexWidth, 0, 0, + static_cast<float>(aYRel.getX())/nTexHeight, static_cast<float>(aYRel.getY())/nTexHeight, 0, 0, 0, 0, 1, 0, - (float) rNull.getX(), (float) rNull.getY(), 0, 1 }; + static_cast<float>(rNull.getX()), static_cast<float>(rNull.getY()), 0, 1 }; glm::mat4 aMatrix = glm::make_mat4( aValues ); glUniformMatrix4fv( nUniform, 1, GL_FALSE, glm::value_ptr( aMatrix ) ); CHECK_GL_ERROR(); diff --git a/vcl/opengl/scale.cxx b/vcl/opengl/scale.cxx index 4ff79b65717b..7981a59ef89d 100644 --- a/vcl/opengl/scale.cxx +++ b/vcl/opengl/scale.cxx @@ -140,7 +140,7 @@ bool OpenGLSalBitmap::ImplScaleConvolution( for( sal_uInt32 i = 0; i < 16; i++ ) { - aOffsets[i * 2] = i / (double) mnWidth; + aOffsets[i * 2] = i / static_cast<double>(mnWidth); aOffsets[i * 2 + 1] = 0; } ImplCreateKernel( rScaleX, aKernel, pWeights, nKernelSize ); @@ -164,7 +164,7 @@ bool OpenGLSalBitmap::ImplScaleConvolution( for( sal_uInt32 i = 0; i < 16; i++ ) { aOffsets[i * 2] = 0; - aOffsets[i * 2 + 1] = i / (double) mnHeight; + aOffsets[i * 2 + 1] = i / static_cast<double>(mnHeight); } ImplCreateKernel( rScaleY, aKernel, pWeights, nKernelSize ); pProgram->SetUniform1fv( "kernel", 16, pWeights ); diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx index 86315b48a4b6..615b7c6d9db8 100644 --- a/vcl/opengl/texture.cxx +++ b/vcl/opengl/texture.cxx @@ -365,18 +365,18 @@ void OpenGLTexture::GetCoord( GLfloat* pCoord, const SalTwoRect& rPosAry, bool b return; } - pCoord[0] = pCoord[2] = (maRect.Left() + rPosAry.mnSrcX) / (double) mpImpl->mnWidth; - pCoord[4] = pCoord[6] = (maRect.Left() + rPosAry.mnSrcX + rPosAry.mnSrcWidth) / (double) mpImpl->mnWidth; + pCoord[0] = pCoord[2] = (maRect.Left() + rPosAry.mnSrcX) / static_cast<double>(mpImpl->mnWidth); + pCoord[4] = pCoord[6] = (maRect.Left() + rPosAry.mnSrcX + rPosAry.mnSrcWidth) / static_cast<double>(mpImpl->mnWidth); if( !bInverted ) { - pCoord[3] = pCoord[5] = 1.0f - (maRect.Top() + rPosAry.mnSrcY) / (double) mpImpl->mnHeight; - pCoord[1] = pCoord[7] = 1.0f - (maRect.Top() + rPosAry.mnSrcY + rPosAry.mnSrcHeight) / (double) mpImpl->mnHeight; + pCoord[3] = pCoord[5] = 1.0f - (maRect.Top() + rPosAry.mnSrcY) / static_cast<double>(mpImpl->mnHeight); + pCoord[1] = pCoord[7] = 1.0f - (maRect.Top() + rPosAry.mnSrcY + rPosAry.mnSrcHeight) / static_cast<double>(mpImpl->mnHeight); } else { - pCoord[1] = pCoord[7] = 1.0f - (maRect.Top() + rPosAry.mnSrcY) / (double) mpImpl->mnHeight; - pCoord[3] = pCoord[5] = 1.0f - (maRect.Top() + rPosAry.mnSrcY + rPosAry.mnSrcHeight) / (double) mpImpl->mnHeight; + pCoord[1] = pCoord[7] = 1.0f - (maRect.Top() + rPosAry.mnSrcY) / static_cast<double>(mpImpl->mnHeight); + pCoord[3] = pCoord[5] = 1.0f - (maRect.Top() + rPosAry.mnSrcY + rPosAry.mnSrcHeight) / static_cast<double>(mpImpl->mnHeight); } } @@ -441,10 +441,10 @@ void OpenGLTexture::GetWholeCoord( GLfloat* pCoord ) const { if( GetWidth() != mpImpl->mnWidth || GetHeight() != mpImpl->mnHeight ) { - pCoord[0] = pCoord[2] = maRect.Left() / (double) mpImpl->mnWidth; - pCoord[4] = pCoord[6] = maRect.Right() / (double) mpImpl->mnWidth; - pCoord[3] = pCoord[5] = 1.0f - maRect.Top() / (double) mpImpl->mnHeight; - pCoord[1] = pCoord[7] = 1.0f - maRect.Bottom() / (double) mpImpl->mnHeight; + pCoord[0] = pCoord[2] = maRect.Left() / static_cast<double>(mpImpl->mnWidth); + pCoord[4] = pCoord[6] = maRect.Right() / static_cast<double>(mpImpl->mnWidth); + pCoord[3] = pCoord[5] = 1.0f - maRect.Top() / static_cast<double>(mpImpl->mnHeight); + pCoord[1] = pCoord[7] = 1.0f - maRect.Bottom() / static_cast<double>(mpImpl->mnHeight); } else { diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index d68de41370b3..242969d250f9 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -160,7 +160,7 @@ void checkAndInsert(CRCHash &rHash, sal_uInt64 nCRC, const char *pLocation) aBuf.append(" and "); aBuf.append(it->second); aBuf.append(" hash is 0x"); - aBuf.append((sal_Int64)nCRC, 16); + aBuf.append(static_cast<sal_Int64>(nCRC), 16); CPPUNIT_FAIL(aBuf.toString().getStr()); } rHash[nCRC] = pLocation; diff --git a/vcl/qa/cppunit/font.cxx b/vcl/qa/cppunit/font.cxx index 049e2118fd60..4f1c56ab29d1 100644 --- a/vcl/qa/cppunit/font.cxx +++ b/vcl/qa/cppunit/font.cxx @@ -111,16 +111,16 @@ void VclFontTest::testQuality() { vcl::Font aFont; - CPPUNIT_ASSERT_EQUAL( (int)0, aFont.GetQuality() ); + CPPUNIT_ASSERT_EQUAL( int(0), aFont.GetQuality() ); aFont.SetQuality( 100 ); - CPPUNIT_ASSERT_EQUAL( (int)100, aFont.GetQuality() ); + CPPUNIT_ASSERT_EQUAL( int(100), aFont.GetQuality() ); aFont.IncreaseQualityBy( 50 ); - CPPUNIT_ASSERT_EQUAL( (int)150, aFont.GetQuality() ); + CPPUNIT_ASSERT_EQUAL( int(150), aFont.GetQuality() ); aFont.DecreaseQualityBy( 100 ); - CPPUNIT_ASSERT_EQUAL( (int)50, aFont.GetQuality() ); + CPPUNIT_ASSERT_EQUAL( int(50), aFont.GetQuality() ); } diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx index e9e3817cd161..f4381df1d115 100644 --- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx +++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx @@ -110,11 +110,11 @@ void VclFiltersTest::checkExportImport(const OUString& aFilterShortName) css::uno::Sequence< css::beans::PropertyValue > aFilterData( 3 ); aFilterData[ 0 ].Name = "Interlaced"; - aFilterData[ 0 ].Value <<= (sal_Int32) 0; + aFilterData[ 0 ].Value <<= sal_Int32(0); aFilterData[ 1 ].Name = "Compression"; - aFilterData[ 1 ].Value <<= (sal_Int32) 1; + aFilterData[ 1 ].Value <<= sal_Int32(1); aFilterData[ 2 ].Name = "Quality"; - aFilterData[ 2 ].Value <<= (sal_Int32) 90; + aFilterData[ 2 ].Value <<= sal_Int32(90); sal_uInt16 aFilterType = mGraphicFilter.GetExportFormatNumberForShortName(aFilterShortName); mGraphicFilter.ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData ); diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx index 67b0c0c87a22..802f2591ccfe 100644 --- a/vcl/qt5/Qt5Instance_Print.cxx +++ b/vcl/qt5/Qt5Instance_Print.cxx @@ -56,7 +56,10 @@ static OUString getPdfDir(const PrinterInfo& rInfo) return aDir; } -inline int PtTo10Mu(int nPoints) { return (int)((((double)nPoints) * 35.27777778) + 0.5); } +inline int PtTo10Mu(int nPoints) +{ + return static_cast<int>((static_cast<double>(nPoints) * 35.27777778) + 0.5); +} static void copyJobDataToJobSetup(ImplJobSetup* pJobSetup, JobData& rData) { diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 526662b15c34..6b082eef1c1f 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -107,8 +107,8 @@ void Qt5Widget::handleMouseButtonEvent(QMouseEvent* pEvent, bool bReleased) } aEvent.mnTime = pEvent->timestamp(); - aEvent.mnX = (long)pEvent->pos().x(); - aEvent.mnY = (long)pEvent->pos().y(); + aEvent.mnX = static_cast<long>(pEvent->pos().x()); + aEvent.mnY = static_cast<long>(pEvent->pos().y()); aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons()); SalEvent nEventType; diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 9089ca51ffd0..c1a02dc27a91 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -1829,7 +1829,7 @@ StyleSettings::SetCursorBlinkTime( sal_uInt64 nBlinkTime ) sal_uInt64 StyleSettings::GetCursorBlinkTime() const { - return (long) mxData->mnCursorBlinkTime; + return static_cast<long>(mxData->mnCursorBlinkTime); } void @@ -2074,10 +2074,10 @@ void StyleSettings::Set3DColors( const Color& rColor ) sal_uLong nRed = mxData->maLightColor.GetRed(); sal_uLong nGreen = mxData->maLightColor.GetGreen(); sal_uLong nBlue = mxData->maLightColor.GetBlue(); - nRed += (sal_uLong)(mxData->maShadowColor.GetRed()); - nGreen += (sal_uLong)(mxData->maShadowColor.GetGreen()); - nBlue += (sal_uLong)(mxData->maShadowColor.GetBlue()); - mxData->maCheckedColor = Color( (sal_uInt8)(nRed/2), (sal_uInt8)(nGreen/2), (sal_uInt8)(nBlue/2) ); + nRed += static_cast<sal_uLong>(mxData->maShadowColor.GetRed()); + nGreen += static_cast<sal_uLong>(mxData->maShadowColor.GetGreen()); + nBlue += static_cast<sal_uLong>(mxData->maShadowColor.GetBlue()); + mxData->maCheckedColor = Color( static_cast<sal_uInt8>(nRed/2), static_cast<sal_uInt8>(nGreen/2), static_cast<sal_uInt8>(nBlue/2) ); } else { @@ -2095,9 +2095,9 @@ void StyleSettings::SetCheckedColorSpecialCase( ) mxData->maCheckedColor = Color( 0xCC, 0xCC, 0xCC ); else { - sal_uInt8 nRed = (sal_uInt8)(((sal_uInt16)mxData->maFaceColor.GetRed() + (sal_uInt16)mxData->maLightColor.GetRed())/2); - sal_uInt8 nGreen = (sal_uInt8)(((sal_uInt16)mxData->maFaceColor.GetGreen() + (sal_uInt16)mxData->maLightColor.GetGreen())/2); - sal_uInt8 nBlue = (sal_uInt8)(((sal_uInt16)mxData->maFaceColor.GetBlue() + (sal_uInt16)mxData->maLightColor.GetBlue())/2); + sal_uInt8 nRed = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxData->maFaceColor.GetRed()) + static_cast<sal_uInt16>(mxData->maLightColor.GetRed()))/2); + sal_uInt8 nGreen = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxData->maFaceColor.GetGreen()) + static_cast<sal_uInt16>(mxData->maLightColor.GetGreen()))/2); + sal_uInt8 nBlue = static_cast<sal_uInt8>((static_cast<sal_uInt16>(mxData->maFaceColor.GetBlue()) + static_cast<sal_uInt16>(mxData->maLightColor.GetBlue()))/2); mxData->maCheckedColor = Color( nRed, nGreen, nBlue ); } } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 087710450d2d..800f0be14d96 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -224,7 +224,7 @@ void Application::DeInit() sal_uInt16 Application::GetCommandLineParamCount() { - return (sal_uInt16)osl_getCommandArgCount(); + return static_cast<sal_uInt16>(osl_getCommandArgCount()); } OUString Application::GetCommandLineParam( sal_uInt16 nParam ) @@ -1130,8 +1130,7 @@ OUString Application::GetHWOSConfInfo() OUStringBuffer aDetails; aDetails.append( VclResId(SV_APP_CPUTHREADS) ); - aDetails.append( (sal_Int32) - std::thread::hardware_concurrency() ); + aDetails.append( static_cast<sal_Int32>(std::thread::hardware_concurrency()) ); aDetails.append( "; " ); OUString aVersion; diff --git a/vcl/source/bitmap/bitmapscalesuper.cxx b/vcl/source/bitmap/bitmapscalesuper.cxx index 9141805188dd..b574e5743b09 100644 --- a/vcl/source/bitmap/bitmapscalesuper.cxx +++ b/vcl/source/bitmap/bitmapscalesuper.cxx @@ -26,11 +26,11 @@ namespace { -#define MAP( cVal0, cVal1, nFrac ) ((sal_uInt8)((((long)(cVal0)<<7)+nFrac*((long)(cVal1)-(cVal0)))>>7)) +#define MAP( cVal0, cVal1, nFrac ) (static_cast<sal_uInt8>(((static_cast<long>(cVal0)<<7)+nFrac*(static_cast<long>(cVal1)-(cVal0)))>>7)) void generateMap(long nW, long nDstW, bool bHMirr, long* pMapIX, long* pMapFX) { - const double fRevScaleX = (nDstW > 1) ? (double) (nW - 1) / (nDstW - 1) : 0.0; + const double fRevScaleX = (nDstW > 1) ? static_cast<double>(nW - 1) / (nDstW - 1) : 0.0; long nTemp = nW - 2; long nTempX = nW - 1; @@ -39,8 +39,8 @@ void generateMap(long nW, long nDstW, bool bHMirr, long* pMapIX, long* pMapFX) double fTemp = nX * fRevScaleX; if (bHMirr) fTemp = nTempX - fTemp; - pMapIX[nX] = MinMax((long) fTemp, 0, nTemp); - pMapFX[nX] = (long) ((fTemp - pMapIX[nX]) * 128.0); + pMapIX[nX] = MinMax(static_cast<long>(fTemp), 0, nTemp); + pMapFX[nX] = static_cast<long>((fTemp - pMapIX[nX]) * 128.0); } } @@ -402,7 +402,7 @@ void scalePallete8bit2(ScaleContext &rCtx, long nStartY, long nEndY) nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -529,7 +529,7 @@ void scalePalleteGeneral2(ScaleContext &rCtx, long nStartY, long nEndY) nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -652,7 +652,7 @@ void scale24bitBGR2(ScaleContext &rCtx, long nStartY, long nEndY) nSumG /= nTotalWeightY; nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -773,7 +773,7 @@ void scale24bitRGB2(ScaleContext &rCtx, long nStartY, long nEndY) nSumG /= nTotalWeightY; nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } @@ -899,7 +899,7 @@ void scaleNonPalleteGeneral2(ScaleContext &rCtx, long nStartY, long nEndY) nSumB /= nTotalWeightY; } - BitmapColor aColRes((sal_uInt8)nSumR, (sal_uInt8)nSumG, (sal_uInt8)nSumB); + BitmapColor aColRes(static_cast<sal_uInt8>(nSumR), static_cast<sal_uInt8>(nSumG), static_cast<sal_uInt8>(nSumB)); rCtx.mpDest->SetPixel( nY, nXDst++, aColRes ); } } diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index bd03840e34bb..dd4583de0181 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -65,8 +65,8 @@ using namespace css; WB_TOP | WB_VCENTER | WB_BOTTOM | \ WB_WORDBREAK | WB_NOLABEL) -#define STYLE_RADIOBUTTON_MONO ((sal_uInt16)0x0001) // legacy -#define STYLE_CHECKBOX_MONO ((sal_uInt16)0x0001) // legacy +#define STYLE_RADIOBUTTON_MONO (sal_uInt16(0x0001)) // legacy +#define STYLE_CHECKBOX_MONO (sal_uInt16(0x0001)) // legacy class ImplCommonButtonData { diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 02000ff0d7f2..531284cf86eb 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -145,7 +145,7 @@ void ComboBox::ImplCalcEditHeight() { sal_Int32 nLeft, nTop, nRight, nBottom; GetBorder( nLeft, nTop, nRight, nBottom ); - m_pImpl->m_nDDHeight = (sal_uInt16)(m_pImpl->m_pSubEdit->GetTextHeight() + nTop + nBottom + 4); + m_pImpl->m_nDDHeight = static_cast<sal_uInt16>(m_pImpl->m_pSubEdit->GetTextHeight() + nTop + nBottom + 4); if ( !IsDropDownBox() ) m_pImpl->m_nDDHeight += 4; @@ -311,7 +311,7 @@ IMPL_LINK(ComboBox::Impl, ImplAutocompleteHdl, Edit&, rEdit, void) { OUString aFullText = rEdit.GetText(); - OUString aStartText = aFullText.copy( 0, (sal_Int32)aSel.Max() ); + OUString aStartText = aFullText.copy( 0, static_cast<sal_Int32>(aSel.Max()) ); sal_Int32 nStart = m_pImplLB->GetCurrentPos(); if ( nStart == LISTBOX_ENTRY_NOTFOUND ) @@ -1127,13 +1127,13 @@ void ComboBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines if ( !IsDropDownBox() ) { Size aOutSz = m_pImpl->m_pImplLB->GetMainWindow()->GetOutputSizePixel(); - rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1; - rnLines = (sal_uInt16)(aOutSz.Height()/m_pImpl->m_pImplLB->GetEntryHeight()); + rnCols = (nCharWidth > 0) ? static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1; + rnLines = static_cast<sal_uInt16>(aOutSz.Height()/m_pImpl->m_pImplLB->GetEntryHeight()); } else { Size aOutSz = m_pImpl->m_pSubEdit->GetOutputSizePixel(); - rnCols = (nCharWidth > 0) ? (sal_uInt16)(aOutSz.Width()/nCharWidth) : 1; + rnCols = (nCharWidth > 0) ? static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth) : 1; rnLines = 1; } } diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 03ceb04adcac..6a512eb4171f 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -110,7 +110,7 @@ ControlLayoutData::ControlLayoutData() : m_pParent( nullptr ) tools::Rectangle ControlLayoutData::GetCharacterBounds( long nIndex ) const { - return (nIndex >= 0 && nIndex < (long) m_aUnicodeBoundRects.size()) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle(); + return (nIndex >= 0 && nIndex < static_cast<long>(m_aUnicodeBoundRects.size())) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle(); } tools::Rectangle Control::GetCharacterBounds( long nIndex ) const diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 7560860de9de..fc8d7299780c 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -489,7 +489,7 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const tools::Rectangl if (nLen) { - if ((size_t) (2 * nLen) > SAL_N_ELEMENTS(nDXBuffer)) + if (static_cast<size_t>(2 * nLen) > SAL_N_ELEMENTS(nDXBuffer)) { pDXBuffer.reset(new long[2 * (nLen + 1)]); pDX = pDXBuffer.get(); @@ -1084,7 +1084,7 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible ) if( !aText.isEmpty() ) { - if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) + if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) { pDXBuffer.reset(new long[2*(aText.getLength()+1)]); pDX = pDXBuffer.get(); @@ -1200,7 +1200,7 @@ sal_Int32 Edit::ImplGetCharPos( const Point& rWindowPos ) const long nDXBuffer[256]; std::unique_ptr<long[]> pDXBuffer; long* pDX = nDXBuffer; - if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) + if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) { pDXBuffer.reset(new long[2*(aText.getLength()+1)]); pDX = pDXBuffer.get(); @@ -2136,7 +2136,7 @@ void Edit::Command( const CommandEvent& rCEvt ) if( !aText.isEmpty() ) { - if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) + if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) ) { pDXBuffer.reset(new long[2*(aText.getLength()+1)]); pDX = pDXBuffer.get(); diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 220da283ba86..bd341cfe06fd 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -234,7 +234,7 @@ bool ImplNumericGetValue( const OUString& rStr, sal_Int64& rValue, sal_Int64 nNum = aStrNum.makeStringAndClear().toInt64(); sal_Int64 nDenom = aStrDenom.makeStringAndClear().toInt64(); if (nDenom == 0) return false; // Division by zero - double nFrac2Dec = nWholeNum + (double)nNum/nDenom; // Convert to double for floating point precision + double nFrac2Dec = nWholeNum + static_cast<double>(nNum)/nDenom; // Convert to double for floating point precision aStrFrac.append(nFrac2Dec); // Reconvert division result to string and parse nDecPos = aStrFrac.indexOf('.'); @@ -701,7 +701,7 @@ void NumericFormatter::ImplNewFieldValue( sal_Int64 nNewValue ) aSelection.Justify(); OUString aText = GetField()->GetText(); // leave it as is if selected until end - if ( (sal_Int32)aSelection.Max() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) { if ( !aSelection.Len() ) aSelection.Min() = SELECTION_MAX; @@ -1109,13 +1109,13 @@ sal_Int64 MetricField::ConvertValue( sal_Int64 nValue, sal_Int64 mnBaseValue, sa FieldUnit eInUnit, FieldUnit eOutUnit ) { double nDouble = nonValueDoubleToValueDouble( ConvertDoubleValue( - (double)nValue, mnBaseValue, nDecDigits, eInUnit, eOutUnit ) ); + static_cast<double>(nValue), mnBaseValue, nDecDigits, eInUnit, eOutUnit ) ); sal_Int64 nLong ; // caution: precision loss in double cast - if ( nDouble <= (double)SAL_MIN_INT64 ) + if ( nDouble <= double(SAL_MIN_INT64) ) nLong = SAL_MIN_INT64; - else if ( nDouble >= (double)SAL_MAX_INT64 ) + else if ( nDouble >= double(SAL_MAX_INT64) ) nLong = SAL_MAX_INT64; else nLong = static_cast<sal_Int64>( nDouble ); @@ -1299,7 +1299,7 @@ static bool ImplMetricGetValue( const OUString& rStr, double& rValue, sal_Int64 // Recalculate unit // caution: conversion to double loses precision - rValue = MetricField::ConvertDoubleValue( (double)nValue, nBaseValue, nDecDigits, eEntryUnit, eUnit ); + rValue = MetricField::ConvertDoubleValue( static_cast<double>(nValue), nBaseValue, nDecDigits, eEntryUnit, eUnit ); return true; } @@ -1313,11 +1313,11 @@ bool MetricFormatter::ImplMetricReformat( const OUString& rStr, double& rValue, double nTempVal = rValue; // caution: precision loss in double cast if ( nTempVal > GetMax() ) - nTempVal = (double)GetMax(); + nTempVal = static_cast<double>(GetMax()); else if ( nTempVal < GetMin()) - nTempVal = (double)GetMin(); + nTempVal = static_cast<double>(GetMin()); - rOutStr = CreateFieldText( (sal_Int64)nTempVal ); + rOutStr = CreateFieldText( static_cast<sal_Int64>(nTempVal) ); return true; } } @@ -1401,16 +1401,16 @@ sal_Int64 MetricFormatter::GetValue( FieldUnit eOutUnit ) const double nTempValue; // caution: precision loss in double cast if ( !ImplMetricGetValue( GetField()->GetText(), nTempValue, mnBaseValue, GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ) ) - nTempValue = (double)mnLastValue; + nTempValue = static_cast<double>(mnLastValue); // caution: precision loss in double cast if ( nTempValue > mnMax ) - nTempValue = (double)mnMax; + nTempValue = static_cast<double>(mnMax); else if ( nTempValue < mnMin ) - nTempValue = (double)mnMin; + nTempValue = static_cast<double>(mnMin); // convert to requested units - return MetricField::ConvertValue( (sal_Int64)nTempValue, mnBaseValue, GetDecimalDigits(), meUnit, eOutUnit ); + return MetricField::ConvertValue( static_cast<sal_Int64>(nTempValue), mnBaseValue, GetDecimalDigits(), meUnit, eOutUnit ); } void MetricFormatter::SetValue( sal_Int64 nValue ) @@ -1477,9 +1477,9 @@ void MetricFormatter::Reformat() OUString aStr; // caution: precision loss in double cast - double nTemp = (double)mnLastValue; + double nTemp = static_cast<double>(mnLastValue); bool bOK = ImplMetricReformat( aText, nTemp, aStr ); - mnLastValue = (sal_Int64)nTemp; + mnLastValue = static_cast<sal_Int64>(nTemp); if ( !bOK ) return; @@ -1763,7 +1763,7 @@ sal_Int64 MetricBox::GetValue( sal_Int32 nPos ) const GetDecimalDigits(), ImplGetLocaleDataWrapper(), meUnit ); // convert to previously configured units - sal_Int64 nRetValue = MetricField::ConvertValue( (sal_Int64)nValue, mnBaseValue, GetDecimalDigits(), + sal_Int64 nRetValue = MetricField::ConvertValue( static_cast<sal_Int64>(nValue), mnBaseValue, GetDecimalDigits(), meUnit, FUNIT_NONE ); return nRetValue; diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index ce8aa460484d..015695df2c1f 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -83,7 +83,7 @@ static sal_Unicode* ImplAddNum( sal_Unicode* pBuf, sal_uLong nNumber, int nMinLe sal_Unicode* pTempBuf = aTempBuf; do { - *pTempBuf = (sal_Unicode)(nNumber % 10) + '0'; + *pTempBuf = static_cast<sal_Unicode>(nNumber % 10) + '0'; pTempBuf++; nNumber /= 10; if ( nMinLen ) @@ -1324,7 +1324,7 @@ void DateField::ImplDateSpinArea( bool bUp ) Selection aSelection = GetField()->GetSelection(); aSelection.Justify(); OUString aText( GetText() ); - if ( (sal_Int32)aSelection.Len() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Len()) == aText.getLength() ) ImplDateIncrementDay( aDate, bUp ); else { @@ -1344,7 +1344,7 @@ void DateField::ImplDateSpinArea( bool bUp ) for ( sal_Int8 i = 1; i <= 3; i++ ) { nPos = aText.indexOf( aDateSep, nPos ); - if (nPos < 0 || nPos >= (sal_Int32)aSelection.Max()) + if (nPos < 0 || nPos >= static_cast<sal_Int32>(aSelection.Max())) { nDateArea = i; break; @@ -1585,7 +1585,7 @@ void DateFormatter::ImplNewFieldValue( const Date& rDate ) OUString aText = GetField()->GetText(); // If selected until the end then keep it that way - if ( (sal_Int32)aSelection.Max() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) { if ( !aSelection.Len() ) aSelection.Min() = SELECTION_MAX; @@ -1961,7 +1961,7 @@ static bool ImplCutTimePortion( OUStringBuffer& _rStr, sal_Int32 _nSepPos, bool if ( !ImplIsValidTimePortion( _bSkipInvalidCharacters, sPortion ) ) return false; - *_pPortion = (short)sPortion.toInt32(); + *_pPortion = static_cast<short>(sPortion.toInt32()); return true; } @@ -2030,14 +2030,14 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, nNanoSec = aStr.toString().toInt64(); } else - nSecond = (short)aStr.toString().toInt32(); + nSecond = static_cast<short>(aStr.toString().toInt32()); } else - nMinute = (short)aStr.toString().toInt32(); + nMinute = static_cast<short>(aStr.toString().toInt32()); } else if ( nSepPos < 0 ) { - nSecond = (short)aStr.toString().toInt32(); + nSecond = static_cast<short>(aStr.toString().toInt32()); nMinute += nSecond / 60; nSecond %= 60; nHour += nMinute / 60; @@ -2045,7 +2045,7 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, } else { - nSecond = (short)aStr.copy( 0, nSepPos ).toString().toInt32(); + nSecond = static_cast<short>(aStr.copy( 0, nSepPos ).toString().toInt32()); aStr.remove( 0, nSepPos+1 ); nSepPos = aStr.indexOf( rLocaleDataWrapper.getTimeSep() ); @@ -2054,7 +2054,7 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, if ( nSepPos >= 0 ) { nMinute = nSecond; - nSecond = (short)aStr.copy( 0, nSepPos ).toString().toInt32(); + nSecond = static_cast<short>(aStr.copy( 0, nSepPos ).toString().toInt32()); aStr.remove( 0, nSepPos+1 ); nSepPos = aStr.indexOf( rLocaleDataWrapper.getTimeSep() ); @@ -2064,7 +2064,7 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, { nHour = nMinute; nMinute = nSecond; - nSecond = (short)aStr.copy( 0, nSepPos ).toString().toInt32(); + nSecond = static_cast<short>(aStr.copy( 0, nSepPos ).toString().toInt32()); aStr.remove( 0, nSepPos+1 ); } else @@ -2130,8 +2130,8 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, if ( (nHour == 12) && ( ( aUpperCaseStr.indexOf( "AM" ) >= 0 ) || ( aUpperCaseStr.indexOf( aAMlocalised ) >= 0 ) ) ) nHour = 0; - aTime = tools::Time( (sal_uInt16)nHour, (sal_uInt16)nMinute, (sal_uInt16)nSecond, - (sal_uInt32)nNanoSec ); + aTime = tools::Time( static_cast<sal_uInt16>(nHour), static_cast<sal_uInt16>(nMinute), static_cast<sal_uInt16>(nSecond), + static_cast<sal_uInt32>(nNanoSec) ); } else { @@ -2148,8 +2148,8 @@ static bool ImplTimeGetValue( const OUString& rStr, tools::Time& rTime, nNanoSec = nNanoSec < 0 ? -nNanoSec : nNanoSec; } - aTime = tools::Time( (sal_uInt16)nHour, (sal_uInt16)nMinute, (sal_uInt16)nSecond, - (sal_uInt32)nNanoSec ); + aTime = tools::Time( static_cast<sal_uInt16>(nHour), static_cast<sal_uInt16>(nMinute), static_cast<sal_uInt16>(nSecond), + static_cast<sal_uInt32>(nNanoSec) ); if ( bNegative ) aTime = -aTime; } @@ -2364,7 +2364,7 @@ void TimeFormatter::ImplNewFieldValue( const tools::Time& rTime ) OUString aText = GetField()->GetText(); // If selected until the end then keep it that way - if ( (sal_Int32)aSelection.Max() == aText.getLength() ) + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) { if ( !aSelection.Len() ) aSelection.Min() = SELECTION_MAX; diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 755d12cb22bb..98c88b674cd7 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -541,14 +541,14 @@ void ImplListBoxWindow::ImplCalcMetrics() mnMaxImgTxtWidth= 0; mnMaxImgHeight = 0; - mnTextHeight = (sal_uInt16)GetTextHeight(); + mnTextHeight = static_cast<sal_uInt16>(GetTextHeight()); mnMaxTxtHeight = mnTextHeight + mnBorder; mnMaxHeight = mnMaxTxtHeight; if ( maUserItemSize.Height() > mnMaxHeight ) - mnMaxHeight = (sal_uInt16) maUserItemSize.Height(); + mnMaxHeight = static_cast<sal_uInt16>(maUserItemSize.Height()); if ( maUserItemSize.Width() > mnMaxWidth ) - mnMaxWidth= (sal_uInt16) maUserItemSize.Width(); + mnMaxWidth= static_cast<sal_uInt16>(maUserItemSize.Width()); for ( sal_Int32 n = mpEntryList->GetEntryCount(); n; ) { @@ -637,7 +637,7 @@ void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry ) else { // normal single line case - aMetrics.nTextWidth = (sal_uInt16)GetTextWidth( rEntry.maStr ); + aMetrics.nTextWidth = static_cast<sal_uInt16>(GetTextWidth( rEntry.maStr )); if( aMetrics.nTextWidth > mnMaxTxtWidth ) mnMaxTxtWidth = aMetrics.nTextWidth; aMetrics.nEntryWidth = mnMaxTxtWidth; @@ -647,8 +647,8 @@ void ImplListBoxWindow::ImplUpdateEntryMetrics( ImplEntryType& rEntry ) if ( aMetrics.bImage ) { Size aImgSz = rEntry.maImage.GetSizePixel(); - aMetrics.nImgWidth = (sal_uInt16) CalcZoom( aImgSz.Width() ); - aMetrics.nImgHeight = (sal_uInt16) CalcZoom( aImgSz.Height() ); + aMetrics.nImgWidth = static_cast<sal_uInt16>(CalcZoom( aImgSz.Width() )); + aMetrics.nImgHeight = static_cast<sal_uInt16>(CalcZoom( aImgSz.Height() )); if( aMetrics.nImgWidth > mnMaxImgWidth ) mnMaxImgWidth = aMetrics.nImgWidth; @@ -897,7 +897,7 @@ void ImplListBoxWindow::MouseMove( const MouseEvent& rMEvt ) if( nSelect == LISTBOX_ENTRY_NOTFOUND ) nSelect = mpEntryList->GetEntryCount() - 1; nSelect = std::min( nSelect, GetLastVisibleEntry() ); - nSelect = std::min( nSelect, (sal_Int32) ( mpEntryList->GetEntryCount() - 1 ) ); + nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) ); // Select only visible Entries with MouseMove, otherwise Tracking... if ( IsVisible( nSelect ) && mpEntryList->IsEntrySelectable( nSelect ) && @@ -1230,16 +1230,16 @@ void ImplListBoxWindow::Tracking( const TrackingEvent& rTEvt ) { if ( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND ) { - nSelect = std::min( (sal_Int32)(mnCurrentPos+1), (sal_Int32)(mpEntryList->GetEntryCount()-1) ); + nSelect = std::min( static_cast<sal_Int32>(mnCurrentPos+1), static_cast<sal_Int32>(mpEntryList->GetEntryCount()-1) ); if( nSelect >= GetLastVisibleEntry() ) SetTopEntry( mnTop+1 ); } } else { - nSelect = (sal_Int32) ( ( aPt.Y() + mnBorder ) / mnMaxHeight ) + mnTop; + nSelect = static_cast<sal_Int32>( ( aPt.Y() + mnBorder ) / mnMaxHeight ) + mnTop; nSelect = std::min( nSelect, GetLastVisibleEntry() ); - nSelect = std::min( nSelect, (sal_Int32) ( mpEntryList->GetEntryCount() - 1 ) ); + nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) ); } if ( bInside ) @@ -1450,10 +1450,10 @@ bool ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt ) nTmp += mnTop - 1; if( mnCurrentPos == nTmp && mnCurrentPos != nCount - 1 ) { - long nTmp2 = std::min( (long)(nCount-nCurVis), (long)((long)mnTop+(long)nCurVis-1) ); - nTmp2 = std::max( (long)0 , nTmp2 ); - nTmp = (sal_Int32)(nTmp2+(nCurVis-1) ); - SetTopEntry( (sal_Int32)nTmp2 ); + long nTmp2 = std::min( static_cast<long>(nCount-nCurVis), static_cast<long>(static_cast<long>(mnTop)+static_cast<long>(nCurVis)-1) ); + nTmp2 = std::max( long(0) , nTmp2 ); + nTmp = static_cast<sal_Int32>(nTmp2+(nCurVis-1) ); + SetTopEntry( static_cast<sal_Int32>(nTmp2) ); } // find first selectable starting from nTmp looking backwards nSelect = mpEntryList->FindFirstSelectable( nTmp, false ); @@ -2237,7 +2237,7 @@ IMPL_LINK_NOARG(ImplListBox, LBWindowScrolled, ImplListBoxWindow*, void) IMPL_LINK( ImplListBox, ScrollBarHdl, ScrollBar*, pSB, void ) { - sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); + sal_uInt16 nPos = static_cast<sal_uInt16>(pSB->GetThumbPos()); if( pSB == mpVScrollBar ) SetTopEntry( nPos ); else if( pSB == mpHScrollBar ) @@ -2250,7 +2250,7 @@ void ImplListBox::ImplCheckScrollBars() Size aOutSz = GetOutputSizePixel(); sal_Int32 nEntries = GetEntryList()->GetEntryCount(); - sal_uInt16 nMaxVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight()); + sal_uInt16 nMaxVisEntries = static_cast<sal_uInt16>(aOutSz.Height() / GetEntryHeight()); // vertical ScrollBar if( nEntries > nMaxVisEntries ) @@ -2277,7 +2277,7 @@ void ImplListBox::ImplCheckScrollBars() // horizontal ScrollBar if( mbAutoHScroll ) { - long nWidth = (sal_uInt16) aOutSz.Width(); + long nWidth = static_cast<sal_uInt16>(aOutSz.Width()); if ( mbVScroll ) nWidth -= mpVScrollBar->GetSizePixel().Width(); @@ -2290,7 +2290,7 @@ void ImplListBox::ImplCheckScrollBars() if ( !mbVScroll ) // maybe we do need one now { - nMaxVisEntries = (sal_uInt16) ( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeight() ); + nMaxVisEntries = static_cast<sal_uInt16>( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeight() ); if( nEntries > nMaxVisEntries ) { bArrange = true; @@ -2306,7 +2306,7 @@ void ImplListBox::ImplCheckScrollBars() } // check of the scrolled-out region - sal_uInt16 nMaxLI = (sal_uInt16) (nMaxWidth - nWidth); + sal_uInt16 nMaxLI = static_cast<sal_uInt16>(nMaxWidth - nWidth); if ( nMaxLI < GetLeftIndent() ) SetLeftIndent( nMaxLI ); } @@ -2332,7 +2332,7 @@ void ImplListBox::ImplInitScrollBars() if ( mbVScroll ) { sal_Int32 nEntries = GetEntryList()->GetEntryCount(); - sal_uInt16 nVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight()); + sal_uInt16 nVisEntries = static_cast<sal_uInt16>(aOutSz.Height() / GetEntryHeight()); mpVScrollBar->SetRangeMax( nEntries ); mpVScrollBar->SetVisibleSize( nVisEntries ); mpVScrollBar->SetPageSize( nVisEntries - 1 ); @@ -2341,7 +2341,7 @@ void ImplListBox::ImplInitScrollBars() if ( mbHScroll ) { mpHScrollBar->SetRangeMax( GetMaxEntryWidth() + HORZ_SCROLL ); - mpHScrollBar->SetVisibleSize( (sal_uInt16)aOutSz.Width() ); + mpHScrollBar->SetVisibleSize( static_cast<sal_uInt16>(aOutSz.Width()) ); mpHScrollBar->SetLineSize( HORZ_SCROLL ); mpHScrollBar->SetPageSize( aOutSz.Width() - HORZ_SCROLL ); } diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index 7db757510534..df21ca2b1741 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -98,7 +98,7 @@ void ListBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) { sal_Int32 nLeft, nTop, nRight, nBottom; GetBorder( nLeft, nTop, nRight, nBottom ); - mnDDHeight = (sal_uInt16)(GetTextHeight() + nTop + nBottom + 4); + mnDDHeight = static_cast<sal_uInt16>(GetTextHeight() + nTop + nBottom + 4); if( IsNativeWidgetEnabled() && IsNativeControlSupported( ControlType::Listbox, ControlPart::Entire ) ) @@ -413,7 +413,7 @@ void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, Dr else { long nTextHeight = pDev->GetTextHeight(); - sal_uInt16 nLines = ( nTextHeight > 0 ) ? (sal_uInt16)(aSize.Height() / nTextHeight) : 1; + sal_uInt16 nLines = ( nTextHeight > 0 ) ? static_cast<sal_uInt16>(aSize.Height() / nTextHeight) : 1; tools::Rectangle aClip( aPos, aSize ); pDev->IntersectClipRegion( aClip ); @@ -1317,13 +1317,13 @@ void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines if ( !IsDropDownBox() ) { Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel(); - rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth); - rnLines = (sal_uInt16) (aOutSz.Height()/mpImplLB->GetEntryHeight()); + rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth); + rnLines = static_cast<sal_uInt16>(aOutSz.Height()/mpImplLB->GetEntryHeight()); } else { Size aOutSz = mpImplWin->GetOutputSizePixel(); - rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth); + rnCols = static_cast<sal_uInt16>(aOutSz.Width()/nCharWidth); rnLines = 1; } } diff --git a/vcl/source/control/longcurr.cxx b/vcl/source/control/longcurr.cxx index 0b538747f1c9..dc15721dc8fa 100644 --- a/vcl/source/control/longcurr.cxx +++ b/vcl/source/control/longcurr.cxx @@ -48,8 +48,8 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt { SAL_WARN_IF( nDigits >= 10, "vcl", "LongCurrency may only have 9 decimal places" ); - if ( rNumber.IsZero() || (long)rNumber ) - return rLocaleDataWrapper.getCurr( (long)rNumber, nDigits, rCurrSymbol, bShowThousandSep ); + if ( rNumber.IsZero() || static_cast<long>(rNumber) ) + return rLocaleDataWrapper.getCurr( static_cast<long>(rNumber), nDigits, rCurrSymbol, bShowThousandSep ); BigInt aTmp( ImplPower10( nDigits ) ); BigInt aInteger( rNumber ); @@ -66,7 +66,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if ( rNumber.IsNeg() ) aFraction *= -1; - OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( (long)aFraction, nDigits, rCurrSymbol, bShowThousandSep ); + OUStringBuffer aTemplate = rLocaleDataWrapper.getCurr( static_cast<long>(aFraction), nDigits, rCurrSymbol, bShowThousandSep ); while( !aInteger.IsZero() ) { aFraction = aInteger; @@ -75,7 +75,7 @@ OUString ImplGetCurr( const LocaleDataWrapper& rLocaleDataWrapper, const BigInt if( !aInteger.IsZero() ) aFraction += aTmp; - OUString aFractionStr = rLocaleDataWrapper.getNum( (long)aFraction, 0 ); + OUString aFractionStr = rLocaleDataWrapper.getNum( static_cast<long>(aFraction), 0 ); sal_Int32 nSPos = aTemplate.indexOf( '1' ); if (nSPos == -1) diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx index 837158350a36..519353a6a777 100644 --- a/vcl/source/control/prgsbar.cxx +++ b/vcl/source/control/prgsbar.cxx @@ -127,7 +127,7 @@ void ProgressBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt1 mnPrgsWidth = (mnPrgsHeight * 2) / 3; maPos.Y() = PROGRESSBAR_WIN_OFFSET; long nMaxWidth = (aSize.Width() - (PROGRESSBAR_WIN_OFFSET * 2) + PROGRESSBAR_OFFSET); - sal_uInt16 nMaxCount = (sal_uInt16)(nMaxWidth / (mnPrgsWidth+PROGRESSBAR_OFFSET)); + sal_uInt16 nMaxCount = static_cast<sal_uInt16>(nMaxWidth / (mnPrgsWidth+PROGRESSBAR_OFFSET)); if (nMaxCount <= 1) { nMaxCount = 1; diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index ee937aa854d6..2695f6da714b 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -46,20 +46,20 @@ #include "thumbpos.hxx" -#define SCRBAR_DRAW_BTN1 ((sal_uInt16)0x0001) -#define SCRBAR_DRAW_BTN2 ((sal_uInt16)0x0002) -#define SCRBAR_DRAW_PAGE1 ((sal_uInt16)0x0004) -#define SCRBAR_DRAW_PAGE2 ((sal_uInt16)0x0008) -#define SCRBAR_DRAW_THUMB ((sal_uInt16)0x0010) -#define SCRBAR_DRAW_BACKGROUND ((sal_uInt16)0x0020) - -#define SCRBAR_STATE_BTN1_DOWN ((sal_uInt16)0x0001) -#define SCRBAR_STATE_BTN1_DISABLE ((sal_uInt16)0x0002) -#define SCRBAR_STATE_BTN2_DOWN ((sal_uInt16)0x0004) -#define SCRBAR_STATE_BTN2_DISABLE ((sal_uInt16)0x0008) -#define SCRBAR_STATE_PAGE1_DOWN ((sal_uInt16)0x0010) -#define SCRBAR_STATE_PAGE2_DOWN ((sal_uInt16)0x0020) -#define SCRBAR_STATE_THUMB_DOWN ((sal_uInt16)0x0040) +#define SCRBAR_DRAW_BTN1 (sal_uInt16(0x0001)) +#define SCRBAR_DRAW_BTN2 (sal_uInt16(0x0002)) +#define SCRBAR_DRAW_PAGE1 (sal_uInt16(0x0004)) +#define SCRBAR_DRAW_PAGE2 (sal_uInt16(0x0008)) +#define SCRBAR_DRAW_THUMB (sal_uInt16(0x0010)) +#define SCRBAR_DRAW_BACKGROUND (sal_uInt16(0x0020)) + +#define SCRBAR_STATE_BTN1_DOWN (sal_uInt16(0x0001)) +#define SCRBAR_STATE_BTN1_DISABLE (sal_uInt16(0x0002)) +#define SCRBAR_STATE_BTN2_DOWN (sal_uInt16(0x0004)) +#define SCRBAR_STATE_BTN2_DISABLE (sal_uInt16(0x0008)) +#define SCRBAR_STATE_PAGE1_DOWN (sal_uInt16(0x0010)) +#define SCRBAR_STATE_PAGE2_DOWN (sal_uInt16(0x0020)) +#define SCRBAR_STATE_THUMB_DOWN (sal_uInt16(0x0040)) #define SCRBAR_VIEW_STYLE (WB_3DLOOK | WB_HORZ | WB_VERT) diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index 61075e8b89e4..9bcc748fcd7a 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -24,9 +24,9 @@ #include "thumbpos.hxx" -#define SLIDER_STATE_CHANNEL1_DOWN ((sal_uInt16)0x0001) -#define SLIDER_STATE_CHANNEL2_DOWN ((sal_uInt16)0x0002) -#define SLIDER_STATE_THUMB_DOWN ((sal_uInt16)0x0004) +#define SLIDER_STATE_CHANNEL1_DOWN (sal_uInt16(0x0001)) +#define SLIDER_STATE_CHANNEL2_DOWN (sal_uInt16(0x0002)) +#define SLIDER_STATE_THUMB_DOWN (sal_uInt16(0x0004)) #define SLIDER_THUMB_SIZE 9 #define SLIDER_THUMB_HALFSIZE 4 diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index b94acb97f6dc..11d1bb0058ae 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -453,7 +453,7 @@ bool TabControl::ImplPlaceTabs( long nWidth ) nLineHeightAry[i] = nIH*(i-nCurLine-1) + GetItemsOffset().Y(); } - nLinePosAry[nLines+1] = (sal_uInt16)mpTabCtrlData->maItemList.size(); + nLinePosAry[nLines+1] = static_cast<sal_uInt16>(mpTabCtrlData->maItemList.size()); long nDX = 0; long nModDX = 0; @@ -1761,7 +1761,7 @@ void TabControl::EnablePage( sal_uInt16 i_nPageId, bool i_bEnable ) sal_uInt16 TabControl::GetPageCount() const { - return (sal_uInt16)mpTabCtrlData->maItemList.size(); + return static_cast<sal_uInt16>(mpTabCtrlData->maItemList.size()); } sal_uInt16 TabControl::GetPageId( sal_uInt16 nPos ) const @@ -1777,7 +1777,7 @@ sal_uInt16 TabControl::GetPagePos( sal_uInt16 nPageId ) const it != mpTabCtrlData->maItemList.end(); ++it ) { if ( it->mnId == nPageId ) - return (sal_uInt16)(it - mpTabCtrlData->maItemList.begin()); + return static_cast<sal_uInt16>(it - mpTabCtrlData->maItemList.begin()); } return TAB_PAGE_NOTFOUND; @@ -2030,7 +2030,7 @@ tools::Rectangle TabControl::GetCharacterBounds( sal_uInt16 nPageId, long nIndex if( HasLayoutData() ) { - std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( (int)nPageId ); + std::unordered_map< int, int >::const_iterator it = mpTabCtrlData->maLayoutPageIdToLine.find( static_cast<int>(nPageId) ); if( it != mpTabCtrlData->maLayoutPageIdToLine.end() ) { Pair aPair = mpControlData->mpLayoutData->GetLineStartEnd( it->second ); @@ -2063,7 +2063,7 @@ long TabControl::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) co if( aPair.A() <= nIndex && aPair.B() >= nIndex ) { nRet = nIndex - aPair.A(); - rPageId = (sal_uInt16)mpTabCtrlData->maLayoutLineToPageId[ nLine ]; + rPageId = static_cast<sal_uInt16>(mpTabCtrlData->maLayoutLineToPageId[ nLine ]); break; } } diff --git a/vcl/source/control/thumbpos.hxx b/vcl/source/control/thumbpos.hxx index 00e3d3c769eb..1992bd853745 100644 --- a/vcl/source/control/thumbpos.hxx +++ b/vcl/source/control/thumbpos.hxx @@ -14,8 +14,8 @@ inline long ImplMulDiv( long nNumber, long nNumerator, long nDenominator ) { if (!nDenominator) return 0; - double n = ((double)nNumber * (double)nNumerator) / (double)nDenominator; - return (long)n; + double n = (static_cast<double>(nNumber) * static_cast<double>(nNumerator)) / static_cast<double>(nDenominator); + return static_cast<long>(n); } #endif // INCLUDED_VCL_SOURCE_CONTROL_THUMBPOS_HXX diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 5d470d164b97..8d6a54e7cff2 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -1607,9 +1607,9 @@ void TextEngine::CreateAndInsertEmptyLine( sal_uInt32 nPara ) aTmpLine.SetEnd( aTmpLine.GetStart() ); if ( ImpGetAlign() == TxtAlign::Center ) - aTmpLine.SetStartX( (short)(mnMaxTextWidth / 2) ); + aTmpLine.SetStartX( static_cast<short>(mnMaxTextWidth / 2) ); else if ( ImpGetAlign() == TxtAlign::Right ) - aTmpLine.SetStartX( (short)mnMaxTextWidth ); + aTmpLine.SetStartX( static_cast<short>(mnMaxTextWidth) ); else aTmpLine.SetStartX( mpDoc->GetLeftMargin() ); @@ -2272,9 +2272,9 @@ bool TextEngine::CreateLines( sal_uInt32 nPara ) if ( nSpace > 0 ) { if ( ImpGetAlign() == TxtAlign::Center ) - pLine->SetStartX( (sal_uInt16)(nSpace / 2) ); + pLine->SetStartX( static_cast<sal_uInt16>(nSpace / 2) ); else // TxtAlign::Right - pLine->SetStartX( (sal_uInt16)nSpace ); + pLine->SetStartX( static_cast<sal_uInt16>(nSpace) ); } } else diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 6ba271aecbf3..e080dcdb51a8 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -1159,9 +1159,9 @@ TextSelection const & TextView::ImpMoveCursor( const KeyEvent& rKeyEvent ) break; case KEY_PAGEDOWN: aPaM = bCtrl ? CursorEndOfDoc() : PageDown( aPaM ); break; - case KEY_LEFT: aPaM = bCtrl ? CursorWordLeft( aPaM ) : CursorLeft( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCHARACTER : (sal_uInt16)css::i18n::CharacterIteratorMode::SKIPCELL ); + case KEY_LEFT: aPaM = bCtrl ? CursorWordLeft( aPaM ) : CursorLeft( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) : sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); break; - case KEY_RIGHT: aPaM = bCtrl ? CursorWordRight( aPaM ) : CursorRight( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCHARACTER : (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCELL ); + case KEY_RIGHT: aPaM = bCtrl ? CursorWordRight( aPaM ) : CursorRight( aPaM, aTranslatedKeyEvent.GetKeyCode().IsMod2() ? sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) : sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); break; case css::awt::Key::SELECT_WORD_FORWARD: bSelect = true; @@ -1344,7 +1344,7 @@ TextPaM TextView::ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ) { if ( nDelMode == DELMODE_SIMPLE ) { - aEndPaM = CursorLeft( aEndPaM, (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCHARACTER ); + aEndPaM = CursorLeft( aEndPaM, sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) ); } else if ( nDelMode == DELMODE_RESTOFWORD ) { @@ -1372,7 +1372,7 @@ TextPaM TextView::ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ) { if ( nDelMode == DELMODE_SIMPLE ) { - aEndPaM = CursorRight( aEndPaM, (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCELL ); + aEndPaM = CursorRight( aEndPaM, sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); } else if ( nDelMode == DELMODE_RESTOFWORD ) { @@ -1407,7 +1407,7 @@ TextPaM TextView::CursorUp( const TextPaM& rPaM ) if ( mpImpl->mnTravelXPos == TRAVEL_X_DONTKNOW ) { nX = mpImpl->mpTextEngine->GetEditCursor( rPaM, false ).Left(); - mpImpl->mnTravelXPos = (sal_uInt16)nX+1; + mpImpl->mnTravelXPos = static_cast<sal_uInt16>(nX)+1; } else nX = mpImpl->mnTravelXPos; @@ -1443,7 +1443,7 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM ) if ( mpImpl->mnTravelXPos == TRAVEL_X_DONTKNOW ) { nX = mpImpl->mpTextEngine->GetEditCursor( rPaM, false ).Left(); - mpImpl->mnTravelXPos = (sal_uInt16)nX+1; + mpImpl->mnTravelXPos = static_cast<sal_uInt16>(nX)+1; } else nX = mpImpl->mnTravelXPos; @@ -1611,7 +1611,7 @@ void TextView::ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bSpec } else { - TextPaM aNext = CursorRight( TextPaM( aPaM.GetPara(), aPaM.GetIndex() ), (sal_uInt16) css::i18n::CharacterIteratorMode::SKIPCELL ); + TextPaM aNext = CursorRight( TextPaM( aPaM.GetPara(), aPaM.GetIndex() ), sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) ); aEditCursor.Right() = mpImpl->mpTextEngine->GetEditCursor( aNext, true ).Left(); } } diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 66fb2b058d72..0bc1ea45589b 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -637,8 +637,8 @@ void ImpVclMEdit::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLi static const sal_Unicode sampleChar = { 'x' }; Size aOutSz = mpTextWindow->GetOutputSizePixel(); Size aCharSz( mpTextWindow->GetTextWidth( OUString(sampleChar) ), mpTextWindow->GetTextHeight() ); - rnCols = (sal_uInt16) (aOutSz.Width()/aCharSz.Width()); - rnLines = (sal_uInt16) (aOutSz.Height()/aCharSz.Height()); + rnCols = static_cast<sal_uInt16>(aOutSz.Width()/aCharSz.Width()); + rnLines = static_cast<sal_uInt16>(aOutSz.Height()/aCharSz.Height()); } void ImpVclMEdit::Enable( bool bEnable ) @@ -1384,7 +1384,7 @@ void VclMultiLineEdit::Draw( OutputDevice* pDev, const Point& rPos, const Size& OUString aText = GetText(); Size aTextSz( pDev->GetTextWidth( aText ), pDev->GetTextHeight() ); - sal_uLong nLines = (sal_uLong) (aSize.Height() / aTextSz.Height()); + sal_uLong nLines = static_cast<sal_uLong>(aSize.Height() / aTextSz.Height()); if ( !nLines ) nLines = 1; aTextSz.Height() = nLines*aTextSz.Height(); diff --git a/vcl/source/filter/GraphicNativeTransform.cxx b/vcl/source/filter/GraphicNativeTransform.cxx index 4870e7011649..84ab1d5d4f6d 100644 --- a/vcl/source/filter/GraphicNativeTransform.cxx +++ b/vcl/source/filter/GraphicNativeTransform.cxx @@ -96,11 +96,11 @@ bool GraphicNativeTransform::rotateGeneric(sal_uInt16 aRotation, const OUString& css::uno::Sequence< css::beans::PropertyValue > aFilterData( 3 ); aFilterData[ 0 ].Name = "Interlaced"; - aFilterData[ 0 ].Value <<= (sal_Int32) 0; + aFilterData[ 0 ].Value <<= sal_Int32(0); aFilterData[ 1 ].Name = "Compression"; - aFilterData[ 1 ].Value <<= (sal_Int32) 9; + aFilterData[ 1 ].Value <<= sal_Int32(9); aFilterData[ 2 ].Name = "Quality"; - aFilterData[ 2 ].Value <<= (sal_Int32) 90; + aFilterData[ 2 ].Value <<= sal_Int32(90); sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( aType ); diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 062f5ee3701d..970af31dd060 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -287,8 +287,8 @@ static bool ImpPeekGraphicFormat( SvStream& rStream, OUString& rFormatExtension, // Big-Endian: for (int i = 0; i < 4; ++i) { - nFirstLong=(nFirstLong<<8)|(sal_uLong)sFirstBytes[i]; - nSecondLong=(nSecondLong<<8)|(sal_uLong)sFirstBytes[i+4]; + nFirstLong=(nFirstLong<<8)|static_cast<sal_uLong>(sFirstBytes[i]); + nSecondLong=(nSecondLong<<8)|static_cast<sal_uLong>(sFirstBytes[i+4]); } // The following variable is used when bTest == true. It remains false @@ -1957,14 +1957,14 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r else if (nColorCount<=256) nBitsPerPixel=8; else if (nColorCount<=65536) nBitsPerPixel=16; else nBitsPerPixel=24; - nNeededMem=((sal_uLong)aSizePixel.Width()*(sal_uLong)aSizePixel.Height()*nBitsPerPixel+7)/8; + nNeededMem=(static_cast<sal_uLong>(aSizePixel.Width())*static_cast<sal_uLong>(aSizePixel.Height())*nBitsPerPixel+7)/8; // is the image larger than available memory? if (nMaxMem<nNeededMem) { - double fFak=sqrt(((double)nMaxMem)/((double)nNeededMem)); - aSizePixel.Width()=(sal_uLong)(((double)aSizePixel.Width())*fFak); - aSizePixel.Height()=(sal_uLong)(((double)aSizePixel.Height())*fFak); + double fFak=sqrt(static_cast<double>(nMaxMem)/static_cast<double>(nNeededMem)); + aSizePixel.Width()=static_cast<sal_uLong>(static_cast<double>(aSizePixel.Width())*fFak); + aSizePixel.Height()=static_cast<sal_uLong>(static_cast<double>(aSizePixel.Height())*fFak); } aVirDev->SetMapMode(MapMode(MapUnit::MapPixel)); @@ -2107,7 +2107,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r for ( k = 0; k < 4; k++ ) { nChunkType <<= 8; - nChunkType |= (sal_uInt8)aAdditionalChunkSequence[ j ].Name[ k ]; + nChunkType |= static_cast<sal_uInt8>(aAdditionalChunkSequence[ j ].Name[ k ]); } css::uno::Sequence< sal_Int8 > aByteSeq; if ( aAdditionalChunkSequence[ j ].Value >>= aByteSeq ) @@ -2376,7 +2376,7 @@ ErrCode GraphicFilter::compressAsPNG(const Graphic& rGraphic, SvStream& rOutputS { css::uno::Sequence< css::beans::PropertyValue > aFilterData(1); aFilterData[0].Name = "Compression"; - aFilterData[0].Value <<= (sal_uInt32) 9; + aFilterData[0].Value <<= sal_uInt32(9); sal_uInt16 nFilterFormat = GetExportFormatNumberForShortName("PNG"); return ExportGraphic(rGraphic, OUString(), rOutputStream, nFilterFormat, &aFilterData); diff --git a/vcl/source/filter/igif/decode.cxx b/vcl/source/filter/igif/decode.cxx index bbbbee27d10d..63d8b9136116 100644 --- a/vcl/source/filter/igif/decode.cxx +++ b/vcl/source/filter/igif/decode.cxx @@ -51,7 +51,7 @@ GIFLZWDecompressor::GIFLZWDecompressor(sal_uInt8 cDataSize) { pTable[i].pPrev = nullptr; pTable[i].pFirst = pTable.get() + i; - pTable[i].nData = (sal_uInt8) i; + pTable[i].nData = static_cast<sal_uInt8>(i); } memset(pTable.get() + nTableSize, 0, sizeof(GIFLZWTableEntry) * (4098 - nTableSize)); @@ -118,7 +118,7 @@ bool GIFLZWDecompressor::AddToTable( sal_uInt16 nPrevCode, sal_uInt16 nCodeFirst pE->nData = pEntry->nData; nTableSize++; - if ( ( nTableSize == (sal_uInt16) (1 << nCodeSize) ) && ( nTableSize < 4096 ) ) + if ( ( nTableSize == static_cast<sal_uInt16>(1 << nCodeSize) ) && ( nTableSize < 4096 ) ) nCodeSize++; } return true; @@ -138,7 +138,7 @@ bool GIFLZWDecompressor::ProcessOneCode() break; } - nInputBitsBuf |= ( (sal_uLong) pBlockBuf[ nBlockBufPos++ ] ) << nInputBitsBufSize; + nInputBitsBuf |= static_cast<sal_uLong>(pBlockBuf[ nBlockBufPos++ ]) << nInputBitsBufSize; nInputBitsBufSize += 8; } @@ -146,7 +146,7 @@ bool GIFLZWDecompressor::ProcessOneCode() { // fetch code from input buffer nCode = sal::static_int_cast< sal_uInt16 >( - ( (sal_uInt16) nInputBitsBuf ) & ( ~( 0xffff << nCodeSize ) )); + static_cast<sal_uInt16>(nInputBitsBuf) & ( ~( 0xffff << nCodeSize ) )); nInputBitsBuf >>= nCodeSize; nInputBitsBufSize = nInputBitsBufSize - nCodeSize; diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index f35d2d398c19..ea92b3ee1a0c 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -205,7 +205,7 @@ void GIFReader::CreateBitmaps( long nWidth, long nHeight, BitmapPalette* pPal, if( pAcc1 ) { - cTransIndex1 = (sal_uInt8) pAcc1->GetBestPaletteIndex( aWhite ); + cTransIndex1 = static_cast<sal_uInt8>(pAcc1->GetBestPaletteIndex( aWhite )); cNonTransIndex1 = cTransIndex1 ? 0 : 1; } else @@ -364,7 +364,7 @@ bool GIFReader::ReadExtension() rIStm.ReadUChar( cByte ); nLoops = cByte; rIStm.ReadUChar( cByte ); - nLoops |= ( (sal_uInt16) cByte << 8 ); + nLoops |= ( static_cast<sal_uInt16>(cByte) << 8 ); rIStm.ReadUChar( cByte ); bStatus = ( cByte == 0 ); @@ -415,7 +415,7 @@ bool GIFReader::ReadExtension() bRet = true; while( cSize && bStatus && !rIStm.eof() ) { - sal_uInt16 nCount = (sal_uInt16) cSize + 1; + sal_uInt16 nCount = static_cast<sal_uInt16>(cSize) + 1; const sal_uInt64 nMaxPossible = rIStm.remainingSize(); if (nCount > nMaxPossible) nCount = nMaxPossible; @@ -537,8 +537,8 @@ void GIFReader::FillImages( const sal_uInt8* pBytes, sal_uLong nCount ) // lines will be copied if interlaced if( nLastInterCount ) { - long nMinY = std::min( (long) nLastImageY + 1, (long) nImageHeight - 1 ); - long nMaxY = std::min( (long) nLastImageY + nLastInterCount, (long) nImageHeight - 1 ); + long nMinY = std::min( static_cast<long>(nLastImageY) + 1, static_cast<long>(nImageHeight) - 1 ); + long nMaxY = std::min( static_cast<long>(nLastImageY) + nLastInterCount, static_cast<long>(nImageHeight) - 1 ); // copy last line read, if lines do not coincide // ( happens at the end of the image ) @@ -589,7 +589,7 @@ void GIFReader::FillImages( const sal_uInt8* pBytes, sal_uLong nCount ) } } - nLastImageY = (sal_uInt16) nT1; + nLastImageY = static_cast<sal_uInt16>(nT1); nYAcc = nT1; } else diff --git a/vcl/source/filter/ixbm/xbmread.cxx b/vcl/source/filter/ixbm/xbmread.cxx index 45e885bece52..d44ec06aa5a3 100644 --- a/vcl/source/filter/ixbm/xbmread.cxx +++ b/vcl/source/filter/ixbm/xbmread.cxx @@ -80,36 +80,36 @@ void XBMReader::InitTable() { memset( pHexTable.get(), 0, sizeof( short ) * 256 ); - pHexTable[(int)'0'] = 0; - pHexTable[(int)'1'] = 1; - pHexTable[(int)'2'] = 2; - pHexTable[(int)'3'] = 3; - pHexTable[(int)'4'] = 4; - pHexTable[(int)'5'] = 5; - pHexTable[(int)'6'] = 6; - pHexTable[(int)'7'] = 7; - pHexTable[(int)'8'] = 8; - pHexTable[(int)'9'] = 9; - pHexTable[(int)'A'] = 10; - pHexTable[(int)'B'] = 11; - pHexTable[(int)'C'] = 12; - pHexTable[(int)'D'] = 13; - pHexTable[(int)'E'] = 14; - pHexTable[(int)'F'] = 15; - pHexTable[(int)'X'] = 0; - pHexTable[(int)'a'] = 10; - pHexTable[(int)'b'] = 11; - pHexTable[(int)'c'] = 12; - pHexTable[(int)'d'] = 13; - pHexTable[(int)'e'] = 14; - pHexTable[(int)'f'] = 15; - pHexTable[(int)'x'] = 0; - pHexTable[(int)' '] = -1; - pHexTable[(int)','] = -1; - pHexTable[(int)'}'] = -1; - pHexTable[(int)'\n'] = -1; - pHexTable[(int)'\t'] = -1; - pHexTable[(int)'\0'] = -1; + pHexTable[int('0')] = 0; + pHexTable[int('1')] = 1; + pHexTable[int('2')] = 2; + pHexTable[int('3')] = 3; + pHexTable[int('4')] = 4; + pHexTable[int('5')] = 5; + pHexTable[int('6')] = 6; + pHexTable[int('7')] = 7; + pHexTable[int('8')] = 8; + pHexTable[int('9')] = 9; + pHexTable[int('A')] = 10; + pHexTable[int('B')] = 11; + pHexTable[int('C')] = 12; + pHexTable[int('D')] = 13; + pHexTable[int('E')] = 14; + pHexTable[int('F')] = 15; + pHexTable[int('X')] = 0; + pHexTable[int('a')] = 10; + pHexTable[int('b')] = 11; + pHexTable[int('c')] = 12; + pHexTable[int('d')] = 13; + pHexTable[int('e')] = 14; + pHexTable[int('f')] = 15; + pHexTable[int('x')] = 0; + pHexTable[int(' ')] = -1; + pHexTable[int(',')] = -1; + pHexTable[int('}')] = -1; + pHexTable[int('\n')] = -1; + pHexTable[int('\t')] = -1; + pHexTable[int('\0')] = -1; } OString XBMReader::FindTokenLine( SvStream* pInStm, const char* pTok1, diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index 7c0aecd5fa47..8606491462fd 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -87,8 +87,8 @@ extern "C" boolean fill_input_buffer (j_decompress_ptr cinfo) } WARNMS(cinfo, JWRN_JPEG_EOF); /* Insert a fake EOI marker */ - source->buffer[0] = (JOCTET) 0xFF; - source->buffer[1] = (JOCTET) JPEG_EOI; + source->buffer[0] = JOCTET(0xFF); + source->buffer[1] = JOCTET(JPEG_EOI); nbytes = 2; } @@ -109,17 +109,17 @@ extern "C" void skip_input_data (j_decompress_ptr cinfo, long numberOfBytes) */ if (numberOfBytes > 0) { - while (numberOfBytes > (long) source->pub.bytes_in_buffer) + while (numberOfBytes > static_cast<long>(source->pub.bytes_in_buffer)) { - numberOfBytes -= (long) source->pub.bytes_in_buffer; + numberOfBytes -= static_cast<long>(source->pub.bytes_in_buffer); (void) fill_input_buffer(cinfo); /* note we assume that fill_input_buffer will never return false, * so suspension need not be handled. */ } - source->pub.next_input_byte += (size_t) numberOfBytes; - source->pub.bytes_in_buffer -= (size_t) numberOfBytes; + source->pub.next_input_byte += static_cast<size_t>(numberOfBytes); + source->pub.bytes_in_buffer -= static_cast<size_t>(numberOfBytes); } } @@ -204,7 +204,7 @@ bool JPEGReader::CreateBitmap(JPEGCreateBitmapParam const & rParam) for( sal_uInt16 n = 0; n < 256; n++ ) { - const sal_uInt8 cGray = (sal_uInt8) n; + const sal_uInt8 cGray = static_cast<sal_uInt8>(n); aGrayPal[ n ] = BitmapColor( cGray, cGray, cGray ); } diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx index e120fc304228..6b4cce3607b1 100644 --- a/vcl/source/filter/jpeg/jpegc.cxx +++ b/vcl/source/filter/jpeg/jpegc.cxx @@ -363,8 +363,8 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream, aOwner.set(&cinfo); jpeg_svstream_dest( &cinfo, pOutputStream ); - cinfo.image_width = (JDIMENSION) nWidth; - cinfo.image_height = (JDIMENSION) nHeight; + cinfo.image_width = static_cast<JDIMENSION>(nWidth); + cinfo.image_height = static_cast<JDIMENSION>(nHeight); if ( bGreys ) { cinfo.input_components = 1; @@ -377,7 +377,7 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream, } jpeg_set_defaults( &cinfo ); - jpeg_set_quality( &cinfo, (int) nQualityPercent, FALSE ); + jpeg_set_quality( &cinfo, static_cast<int>(nQualityPercent), FALSE ); cinfo.density_unit = 1; cinfo.X_density = rPPI.getX(); diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index e3dd3d5231e1..de1060a58698 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -206,8 +206,8 @@ void EMFWriter::ImplWritePlusColor( const Color& rColor, sal_uInt32 nTrans ) sal_uInt32 nAlpha = ((100-nTrans)*0xFF)/100; sal_uInt32 nCol = rColor.GetBlue(); - nCol |= ( (sal_uInt32) rColor.GetGreen() ) << 8; - nCol |= ( (sal_uInt32) rColor.GetRed() ) << 16; + nCol |= static_cast<sal_uInt32>(rColor.GetGreen()) << 8; + nCol |= static_cast<sal_uInt32>(rColor.GetRed()) << 16; nCol |= ( nAlpha << 24 ); m_rStm.WriteUInt32( nCol ); } @@ -562,8 +562,8 @@ void EMFWriter::ImplWriteColor( const Color& rColor ) { sal_uInt32 nCol = rColor.GetRed(); - nCol |= ( (sal_uInt32) rColor.GetGreen() ) << 8; - nCol |= ( (sal_uInt32) rColor.GetBlue() ) << 16; + nCol |= static_cast<sal_uInt32>(rColor.GetGreen()) << 8; + nCol |= static_cast<sal_uInt32>(rColor.GetBlue()) << 16; m_rStm.WriteUInt32( nCol ); } @@ -810,7 +810,7 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, if (nColsUsed) nPalCount = nColsUsed; else - nPalCount = 1 << (sal_uInt32)nBitCount; + nPalCount = 1 << static_cast<sal_uInt32>(nBitCount); } else { @@ -864,7 +864,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c if( nWidth && nNormWidth && ( nWidth != nNormWidth ) ) { - const double fFactor = (double) nWidth / nNormWidth; + const double fFactor = static_cast<double>(nWidth) / nNormWidth; for( i = 0; i < ( nLen - 1 ); i++ ) pDX[ i ] = FRound( pDX[ i ] * fFactor ); @@ -1180,8 +1180,8 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) const Size aSrcSize( aTmpMtf.GetPrefSize() ); const Point aDestPt( pA->GetPoint() ); const Size aDestSize( pA->GetSize() ); - const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0; + const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; long nMoveX, nMoveY; if( fScaleX != 1.0 || fScaleY != 1.0 ) diff --git a/vcl/source/filter/wmf/wmfexternal.cxx b/vcl/source/filter/wmf/wmfexternal.cxx index eda806a3d113..27e490a504e2 100644 --- a/vcl/source/filter/wmf/wmfexternal.cxx +++ b/vcl/source/filter/wmf/wmfexternal.cxx @@ -35,11 +35,11 @@ css::uno::Sequence< css::beans::PropertyValue > WmfExternal::getSequence() const { aSequence.realloc(3); aSequence[0].Name = "Width"; - aSequence[0].Value <<= (sal_Int16)xExt; + aSequence[0].Value <<= static_cast<sal_Int16>(xExt); aSequence[1].Name = "Height"; - aSequence[1].Value <<= (sal_Int16)yExt; + aSequence[1].Value <<= static_cast<sal_Int16>(yExt); aSequence[2].Name = "MapMode"; - aSequence[2].Value <<= (sal_Int16)mapMode; + aSequence[2].Value <<= static_cast<sal_Int16>(mapMode); } return aSequence; diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 723a55ef4414..c50c5da5084b 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -577,10 +577,10 @@ void WMFWriter::TrueExtTextOut( const Point& rPoint, const OUString& rString, sal_Int32 nOriginalTextLen = rString.getLength(); std::unique_ptr<sal_Int16[]> pConvertedDXAry(new sal_Int16[ nOriginalTextLen ]); sal_Int32 j = 0; - pConvertedDXAry[ j++ ] = (sal_Int16)ScaleWidth( pDXAry[ 0 ] ); + pConvertedDXAry[ j++ ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ 0 ] )); for (sal_Int32 i = 1; i < ( nOriginalTextLen - 1 ); ++i) - pConvertedDXAry[ j++ ] = (sal_Int16)ScaleWidth( pDXAry[ i ] - pDXAry[ i - 1 ] ); - pConvertedDXAry[ j ] = (sal_Int16)ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) ); + pConvertedDXAry[ j++ ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ i ] - pDXAry[ i - 1 ] )); + pConvertedDXAry[ j ] = static_cast<sal_Int16>(ScaleWidth( pDXAry[ nOriginalTextLen - 2 ] / ( nOriginalTextLen - 1 ) )); for (sal_Int32 i = 0; i < nOriginalTextLen; ++i) { @@ -1214,8 +1214,8 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else { for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) - pDXAry[ i ] = pDXAry[ i ] * (sal_Int32)pA->GetWidth() / nNormSize; - if ( ( nLen <= 1 ) || ( (sal_Int32)pA->GetWidth() == nNormSize ) ) + pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize; + if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) pDXAry.reset(); aSrcLineInfo = LineInfo(); SetAllAttr(); @@ -1421,7 +1421,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else aX += BigInt( aScaleX.GetNumerator()/2 ); aX /= BigInt( aScaleX.GetNumerator() ); - aOrigin.X() = (long)aX + aMM.GetOrigin().X(); + aOrigin.X() = static_cast<long>(aX) + aMM.GetOrigin().X(); BigInt aY( aOrigin.Y() ); aY *= BigInt( aScaleY.GetDenominator() ); if( aOrigin.Y() >= 0 ) @@ -1435,7 +1435,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) else aY += BigInt( aScaleY.GetNumerator()/2 ); aY /= BigInt( aScaleY.GetNumerator() ); - aOrigin.Y() = (long)aY + aMM.GetOrigin().Y(); + aOrigin.Y() = static_cast<long>(aY) + aMM.GetOrigin().Y(); aSrcMapMode.SetOrigin( aOrigin ); aScaleX *= aSrcMapMode.GetScaleX(); @@ -1571,8 +1571,8 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) const Size aSrcSize( aTmpMtf.GetPrefSize() ); const Point aDestPt( pA->GetPoint() ); const Size aDestSize( pA->GetSize() ); - const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0; + const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; long nMoveX, nMoveY; aSrcLineInfo = LineInfo(); @@ -1639,7 +1639,7 @@ void WMFWriter::WriteHeader( bool bPlaceable ) { sal_uInt16 nCheckSum, nValue; Size aSize( OutputDevice::LogicToLogic(Size(1,1),MapMode(MapUnit::MapInch), aTargetMapMode) ); - sal_uInt16 nUnitsPerInch = (sal_uInt16) ( ( aSize.Width() + aSize.Height() ) >> 1 ); + sal_uInt16 nUnitsPerInch = static_cast<sal_uInt16>( ( aSize.Width() + aSize.Height() ) >> 1 ); nCheckSum=0; nValue=0xcdd7; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); @@ -1647,8 +1647,8 @@ void WMFWriter::WriteHeader( bool bPlaceable ) nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); - nValue=(sal_uInt16) aTargetSize.Width(); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); - nValue=(sal_uInt16) aTargetSize.Height(); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); + nValue=static_cast<sal_uInt16>(aTargetSize.Width()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); + nValue=static_cast<sal_uInt16>(aTargetSize.Height()); nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=nUnitsPerInch; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); nValue=0x0000; nCheckSum^=nValue; pWMF->WriteUInt16( nValue ); diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index 40acbb8fb99c..04ebff2a8ffb 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -116,11 +116,11 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchSt // if not bold or requiring emboldening prefer light fonts to bold fonts FontWeight ePatternWeight = rFSD.mbEmbolden ? WEIGHT_NORMAL : rFSD.GetWeight(); - int nReqWeight = (int)ePatternWeight; + int nReqWeight = static_cast<int>(ePatternWeight); if ( ePatternWeight > WEIGHT_MEDIUM ) nReqWeight += 100; - int nGivenWeight = (int)GetWeight(); + int nGivenWeight = static_cast<int>(GetWeight()); if( GetWeight() > WEIGHT_MEDIUM ) nGivenWeight += 100; diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index c6351c228097..5c59f344f87c 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -369,7 +369,7 @@ SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont ) rImplFont.maStyleName = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet()); ReadPair( rIStm, rImplFont.maAverageFontSize ); - rIStm.ReadUInt16( nTmp16 ); rImplFont.SetCharSet( (rtl_TextEncoding) nTmp16 ); + rIStm.ReadUInt16( nTmp16 ); rImplFont.SetCharSet( static_cast<rtl_TextEncoding>(nTmp16) ); rIStm.ReadUInt16( nTmp16 ); rImplFont.SetFamilyType( (FontFamily) nTmp16 ); rIStm.ReadUInt16( nTmp16 ); rImplFont.SetPitch( (FontPitch) nTmp16 ); rIStm.ReadUInt16( nTmp16 ); rImplFont.SetWeight( (FontWeight) nTmp16 ); @@ -419,7 +419,7 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont ) rOStm.WriteUInt16( rImplFont.meUnderline ); rOStm.WriteUInt16( rImplFont.meStrikeout ); rOStm.WriteUInt16( rImplFont.GetItalicNoAsk() ); - rOStm.WriteUInt16( (sal_uInt16)rImplFont.maLanguageTag.getLanguageType( false) ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maLanguageTag.getLanguageType( false)) ); rOStm.WriteUInt16( rImplFont.GetWidthTypeNoAsk() ); rOStm.WriteInt16( rImplFont.mnOrientation ); @@ -431,7 +431,7 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont ) // new in version 2 rOStm.WriteUChar( (sal_uChar)rImplFont.meRelief ); - rOStm.WriteUInt16( (sal_uInt16)rImplFont.maCJKLanguageTag.getLanguageType( false) ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplFont.maCJKLanguageTag.getLanguageType( false)) ); rOStm.WriteBool( rImplFont.mbVertical ); rOStm.WriteUInt16( (sal_uInt16)rImplFont.meEmphasisMark ); diff --git a/vcl/source/font/fontcharmap.cxx b/vcl/source/font/fontcharmap.cxx index 8da0e78c05c0..faf3c906bca7 100644 --- a/vcl/source/font/fontcharmap.cxx +++ b/vcl/source/font/fontcharmap.cxx @@ -203,7 +203,7 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult ) pStartGlyphs[i] = (cMinChar + nGlyphDelta) & 0xFFFF; } else { // update the glyphid-array with the glyphs in this range - pStartGlyphs[i] = -(int)aGlyphIdArray.size(); + pStartGlyphs[i] = -static_cast<int>(aGlyphIdArray.size()); const unsigned char* pGlyphIdPtr = pOffsetBase + 2*i + nRangeOffset; const size_t nRemainingSize = pEndValidArea - pGlyphIdPtr; const size_t nMaxPossibleRecords = nRemainingSize/2; diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index cd0b9f8557e9..1351b9167d4b 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -188,7 +188,7 @@ ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData ) : FontAttributes( rFontSelData ) , mnHeight ( rFontSelData.mnHeight ) , mnWidth ( rFontSelData.mnWidth ) - , mnOrientation( (short)(rFontSelData.mnOrientation) ) + , mnOrientation( static_cast<short>(rFontSelData.mnOrientation) ) , mnAscent( 0 ) , mnDescent( 0 ) , mnIntLeading( 0 ) diff --git a/vcl/source/font/fontselect.cxx b/vcl/source/font/fontselect.cxx index cefdcb178b7a..927e1106c5b6 100644 --- a/vcl/source/font/fontselect.cxx +++ b/vcl/source/font/fontselect.cxx @@ -52,7 +52,7 @@ FontSelectPatternAttributes::FontSelectPatternAttributes( const vcl::Font& rFont rFont.GetFontAttributes( *this ); // normalize orientation between 0 and 3600 - if( 3600 <= (unsigned)mnOrientation ) + if( 3600 <= static_cast<unsigned>(mnOrientation) ) { if( mnOrientation >= 0 ) mnOrientation %= 3600; @@ -118,7 +118,7 @@ size_t FontSelectPatternAttributes::hashCode() const nHash += 19 * GetWeight(); nHash += 29 * GetItalic(); nHash += 37 * mnOrientation; - nHash += 41 * (sal_uInt16)meLanguage; + nHash += 41 * static_cast<sal_uInt16>(meLanguage); if( mbVertical ) nHash += 53; return nHash; diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx index 286c13e411ce..3c759cddd067 100644 --- a/vcl/source/fontsubset/cff.cxx +++ b/vcl/source/fontsubset/cff.cxx @@ -279,7 +279,7 @@ private: void convertOneTypeOp(); void convertOneTypeEsc(); void callType2Subr( bool bGlobal, int nSubrNumber); - sal_Int32 getReadOfs() const { return (sal_Int32)(mpReadPtr - mpBasePtr);} + sal_Int32 getReadOfs() const { return static_cast<sal_Int32>(mpReadPtr - mpBasePtr);} const U8* mpBasePtr; const U8* mpBaseEnd; @@ -704,7 +704,7 @@ void CffSubsetterContext::convertOneTypeOp() } if( !(nMaskByte & nMaskBit)) continue; - if( i >= 8*(int)sizeof(mnCntrMask)) + if( i >= 8*int(sizeof(mnCntrMask))) mbIgnoreHints = true; if( mbIgnoreHints) continue; @@ -726,7 +726,7 @@ void CffSubsetterContext::convertOneTypeOp() } if( !(nMaskByte & nMaskBit)) continue; - if( i >= 8*(int)sizeof(nHintMask)) + if( i >= 8*int(sizeof(nHintMask))) mbIgnoreHints = true; if( mbIgnoreHints) continue; @@ -1656,7 +1656,7 @@ inline size_t Type1Emitter::emitRawData(const char* pData, size_t nLength) const inline void Type1Emitter::emitAllRaw() { // writeout raw data - assert( (mpPtr - maBuffer) < (int)sizeof(maBuffer)); + assert( (mpPtr - maBuffer) < int(sizeof(maBuffer))); emitRawData( maBuffer, mpPtr - maBuffer); // reset the raw buffer mpPtr = maBuffer; @@ -1664,7 +1664,7 @@ inline void Type1Emitter::emitAllRaw() inline void Type1Emitter::emitAllHex() { - assert( (mpPtr - maBuffer) < (int)sizeof(maBuffer)); + assert( (mpPtr - maBuffer) < int(sizeof(maBuffer))); for( const char* p = maBuffer; p < mpPtr;) { // convert binary chunk to hex char aHexBuf[0x4000]; diff --git a/vcl/source/fontsubset/fontsubset.cxx b/vcl/source/fontsubset/fontsubset.cxx index deed82e75bf9..c9cfd1213e42 100644 --- a/vcl/source/fontsubset/fontsubset.cxx +++ b/vcl/source/fontsubset/fontsubset.cxx @@ -130,7 +130,7 @@ bool FontSubsetInfo::CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths ) std::vector<sal_uInt16> aShortGlyphIds; aShortGlyphIds.reserve(mnReqGlyphCount); for (int i = 0; i < mnReqGlyphCount; ++i) - aShortGlyphIds.push_back((sal_uInt16)mpReqGlyphIds[i]); + aShortGlyphIds.push_back(static_cast<sal_uInt16>(mpReqGlyphIds[i])); // remove const_cast when sft-subsetter is const-correct sal_uInt8* pEncArray = const_cast<sal_uInt8*>( mpReqEncodedIds ); #endif diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 98cf6998bef0..2393318accc8 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -188,7 +188,7 @@ static sal_uInt32 GetUInt32(const sal_uInt8 *ptr, size_t offset) #define Int32FromMOTA(a) (a) #else static sal_uInt16 Int16FromMOTA(sal_uInt16 a) { - return (sal_uInt16) (((sal_uInt8)(a >> 8)) | ((sal_uInt8)a << 8)); + return static_cast<sal_uInt16>(static_cast<sal_uInt8>(a >> 8) | (static_cast<sal_uInt8>(a) << 8)); } static sal_uInt32 Int32FromMOTA(sal_uInt32 a) { return ((a>>24)&0xFF) | (((a>>8)&0xFF00) | ((a&0xFF00)<<8) | ((a&0xFF)<<24)); @@ -427,7 +427,7 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr i = 0; while (i <= lastPoint) { - pa[i++].flags = (sal_uInt32) (flag = *p++); + pa[i++].flags = static_cast<sal_uInt32>(flag = *p++); if (flag & 8) { /*- repeat flag */ n = *p++; for (j=0; j<n; j++) { @@ -445,15 +445,15 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr for (i = 0; i <= lastPoint; i++) { if (pa[i].flags & 0x02) { if (pa[i].flags & 0x10) { - z += (int) (*p++); + z += static_cast<int>(*p++); } else { - z -= (int) (*p++); + z -= static_cast<int>(*p++); } } else if ( !(pa[i].flags & 0x10)) { z += GetInt16(p, 0); p += 2; } - pa[i].x = (sal_Int16)z; + pa[i].x = static_cast<sal_Int16>(z); } /*- Process the Y coordinate */ @@ -469,7 +469,7 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr z += GetInt16(p, 0); p += 2; } - pa[i].y = (sal_Int16)z; + pa[i].y = static_cast<sal_Int16>(z); } for (i=0; i<numberOfContours; i++) { @@ -563,8 +563,8 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo ptr += 4; } else { if (flags & ARGS_ARE_XY_VALUES) { /* args are signed */ - e = (sal_Int8) *ptr++; - f = (sal_Int8) *ptr++; + e = static_cast<sal_Int8>(*ptr++); + f = static_cast<sal_Int8>(*ptr++); /* printf("ARGS_ARE_XY_VALUES: %d %d\n", e & 0xFF, f & 0xFF); */ } else { /* args are unsigned */ /* printf("!ARGS_ARE_XY_VALUES\n"); */ @@ -618,9 +618,9 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo const sal_uInt16 x = nextComponent[i].x; const sal_uInt16 y = nextComponent[i].y; t = fixedMulDiv(a, x << 16, m) + fixedMulDiv(c, y << 16, m) + sal_Int32(sal_uInt16(e) << 16); - cp.x = (sal_Int16)(fixedMul(t, m) >> 16); + cp.x = static_cast<sal_Int16>(fixedMul(t, m) >> 16); t = fixedMulDiv(b, x << 16, n) + fixedMulDiv(d, y << 16, n) + sal_Int32(sal_uInt16(f) << 16); - cp.y = (sal_Int16)(fixedMul(t, n) >> 16); + cp.y = static_cast<sal_Int16>(fixedMul(t, n) >> 16); myPoints.push_back( cp ); } @@ -809,7 +809,7 @@ static int BSplineToPSPath(ControlPoint const *srcA, int srcCount, PSPathElement } } - if( (nPathCount = (int)aPathList.size()) > 0) + if( (nPathCount = static_cast<int>(aPathList.size())) > 0) { *path = static_cast<PSPathElement*>(calloc(nPathCount, sizeof(PSPathElement))); assert(*path != nullptr); @@ -1069,8 +1069,8 @@ static sal_uInt32 getGlyph2(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize int k = -1; sal_uInt32 ToReturn; - theHighByte = (sal_uInt8)((c >> 8) & 0x00ff); - theLowByte = (sal_uInt8)(c & 0x00ff); + theHighByte = static_cast<sal_uInt8>((c >> 8) & 0x00ff); + theLowByte = static_cast<sal_uInt8>(c & 0x00ff); subHeader2Keys = CMAP2 + 3; subHeader2s = reinterpret_cast<subHeader2 const *>(subHeader2Keys + 256); if(reinterpret_cast<sal_uInt8 const *>(&subHeader2Keys[theHighByte]) - cmap < int(nMaxCmapSize - 2)) @@ -1133,8 +1133,8 @@ static sal_uInt32 getGlyph6(const sal_uInt8 *cmap, sal_uInt32, sal_uInt32 c) { static sal_uInt16 GEbinsearch(sal_uInt16 const *ar, sal_uInt16 length, sal_uInt16 toSearch) { signed int low, high, lastfound = 0xffff; sal_uInt16 res; - if(length == (sal_uInt16)0 || length == (sal_uInt16)0xFFFF) { - return (sal_uInt16)0xFFFF; + if(length == sal_uInt16(0) || length == sal_uInt16(0xFFFF)) { + return sal_uInt16(0xFFFF); } low = 0; high = length - 1; @@ -1148,7 +1148,7 @@ static sal_uInt16 GEbinsearch(sal_uInt16 const *ar, sal_uInt16 length, sal_uInt1 low = ++mid; } } - return (sal_uInt16)lastfound; + return static_cast<sal_uInt16>(lastfound); } static sal_uInt32 getGlyph4(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize, sal_uInt32 c) { @@ -1166,9 +1166,9 @@ static sal_uInt32 getGlyph4(const sal_uInt8 *cmap, const sal_uInt32 nMaxCmapSize segCount = Int16FromMOTA(*(CMAP4 + 3))/2; endCode = CMAP4 + 7; - i = GEbinsearch(endCode, segCount, (sal_uInt16)c); + i = GEbinsearch(endCode, segCount, static_cast<sal_uInt16>(c)); - if (i == (sal_uInt16) 0xFFFF) { + if (i == sal_uInt16(0xFFFF)) { return MISSING_GLYPH_INDEX; } startCode = endCode + segCount + 1; @@ -1262,7 +1262,7 @@ static void FindCmap(TrueTypeFont *ttf) sal_uInt32 offset = GetUInt32(table, nLargestFixedOffsetPos); /* sanity check, cmap must lie within file */ - if( (table - ttf->ptr) + offset > (sal_uInt32)ttf->fsize ) + if( (table - ttf->ptr) + offset > static_cast<sal_uInt32>(ttf->fsize) ) continue; /* Unicode tables in Apple fonts */ @@ -1552,7 +1552,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) assert(t->tlens != nullptr); /* parse the tables */ - for (i=0; i<(int)t->ntables; i++) { + for (i=0; i<static_cast<int>(t->ntables); i++) { int nIndex; tag = GetUInt32(t->ptr + tdoffset + 12, 16 * i); switch( tag ) { @@ -1585,7 +1585,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) } /* Fixup offsets when only a TTC extract was provided */ - if( facenum == (sal_uInt32)~0 ) { + if( facenum == sal_uInt32(~0) ) { sal_uInt8* pHead = const_cast<sal_uInt8*>(t->tables[O_head]); if( !pHead ) return SF_TTFORMAT; @@ -1664,18 +1664,18 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) if( getTable(t, O_glyf) && getTable(t, O_loca) ) /* TTF or TTF-OpenType */ { int k = (getTableSize(t, O_loca) / (indexfmt ? 4 : 2)) - 1; - if( k < (int)t->nglyphs ) /* Hack for broken Chinese fonts */ + if( k < static_cast<int>(t->nglyphs) ) /* Hack for broken Chinese fonts */ t->nglyphs = k; table = getTable(t, O_loca); t->goffsets = static_cast<sal_uInt32 *>(calloc(1+t->nglyphs, sizeof(sal_uInt32))); assert(t->goffsets != nullptr); - for( i = 0; i <= (int)t->nglyphs; ++i ) - t->goffsets[i] = indexfmt ? GetUInt32(table, i << 2) : (sal_uInt32)GetUInt16(table, i << 1) << 1; + for( i = 0; i <= static_cast<int>(t->nglyphs); ++i ) + t->goffsets[i] = indexfmt ? GetUInt32(table, i << 2) : static_cast<sal_uInt32>(GetUInt16(table, i << 1)) << 1; } else if( getTable(t, O_CFF) ) { /* PS-OpenType */ int k = (getTableSize(t, O_CFF) / 2) - 1; /* set a limit here, presumably much lower than the table size, but establishes some sort of physical bound */ - if( k < (int)t->nglyphs ) + if( k < static_cast<int>(t->nglyphs) ) t->nglyphs = k; t->goffsets = static_cast<sal_uInt32 *>(calloc(1+t->nglyphs, sizeof(sal_uInt32))); /* TODO: implement to get subsetting */ @@ -2238,7 +2238,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, sal_uInt16* gID = static_cast<sal_uInt16*>(scalloc(nGlyphs, sizeof(sal_uInt32))); for (i = 0; i < nGlyphs; i++) { - gID[i] = (sal_uInt16)glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); + gID[i] = static_cast<sal_uInt16>(glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf)); } AddTable(ttcr, head); AddTable(ttcr, hhea); AddTable(ttcr, maxp); AddTable(ttcr, cvt); @@ -2250,7 +2250,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, return res; } - fprintf(outf, "%%!PS-TrueTypeFont-%d.%d-%d.%d\n", (int)(ver>>16), (int)(ver & 0xFFFF), (int)(rev>>16), (int)(rev & 0xFFFF)); + fprintf(outf, "%%!PS-TrueTypeFont-%d.%d-%d.%d\n", static_cast<int>(ver>>16), static_cast<int>(ver & 0xFFFF), static_cast<int>(rev>>16), static_cast<int>(rev & 0xFFFF)); fprintf(outf, "%%%%Creator: %s %s %s\n", modname, modver, modextra); fprintf(outf, "%%- Font subset generated from a source font file: '%s'\n", ttf->fname); fprintf(outf, "%%- Original font name: %s\n", ttf->psname); @@ -2268,14 +2268,14 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, for (i = 1; i<nGlyphs; i++) { fprintf(outf, "Encoding %d /glyph%u put\n", encoding[i], gID[i]); } - fprintf(outf, "/XUID [103 0 1 16#%08X %u 16#%08X 16#%08X] def\n", (unsigned int)rtl_crc32(0, ttf->ptr, ttf->fsize), (unsigned int)nGlyphs, (unsigned int)rtl_crc32(0, glyphArray, nGlyphs * 2), (unsigned int)rtl_crc32(0, encoding, nGlyphs)); + fprintf(outf, "/XUID [103 0 1 16#%08X %u 16#%08X 16#%08X] def\n", static_cast<unsigned int>(rtl_crc32(0, ttf->ptr, ttf->fsize)), static_cast<unsigned int>(nGlyphs), static_cast<unsigned int>(rtl_crc32(0, glyphArray, nGlyphs * 2)), static_cast<unsigned int>(rtl_crc32(0, encoding, nGlyphs))); DumpSfnts(outf, sfntP, sfntLen); /* dump charstrings */ fprintf(outf, "/CharStrings %d dict dup begin\n", nGlyphs); fprintf(outf, "/.notdef 0 def\n"); - for (i = 1; i < (int)glyfCount(glyf); i++) { + for (i = 1; i < static_cast<int>(glyfCount(glyf)); i++) { fprintf(outf,"/glyph%d %d def\n", i, i); } fprintf(outf, "end readonly def\n"); @@ -2506,7 +2506,7 @@ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID) } d->glyphID = glyphID; - d->nbytes = (sal_uInt16)((length + 1) & ~1); + d->nbytes = static_cast<sal_uInt16>((length + 1) & ~1); /* now calculate npoints and ncontours */ ControlPoint *cp; @@ -2519,8 +2519,8 @@ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID) if (cp[i].flags & 0x8000) m++; } - d->npoints = (sal_uInt16)n; - d->ncontours = (sal_uInt16)m; + d->npoints = static_cast<sal_uInt16>(n); + d->ncontours = static_cast<sal_uInt16>(m); free(cp); } else { d->npoints = 0; diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index 6ea929cd728d..818f9ffce7da 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -78,26 +78,26 @@ static void PutInt16(sal_Int16 val, sal_uInt8 *ptr, sal_uInt32 offset) { assert(ptr != nullptr); - ptr[offset] = (sal_uInt8)((val >> 8) & 0xFF); - ptr[offset+1] = (sal_uInt8)(val & 0xFF); + ptr[offset] = static_cast<sal_uInt8>((val >> 8) & 0xFF); + ptr[offset+1] = static_cast<sal_uInt8>(val & 0xFF); } static void PutUInt16(sal_uInt16 val, sal_uInt8 *ptr, sal_uInt32 offset) { assert(ptr != nullptr); - ptr[offset] = (sal_uInt8)((val >> 8) & 0xFF); - ptr[offset+1] = (sal_uInt8)(val & 0xFF); + ptr[offset] = static_cast<sal_uInt8>((val >> 8) & 0xFF); + ptr[offset+1] = static_cast<sal_uInt8>(val & 0xFF); } static void PutUInt32(sal_uInt32 val, sal_uInt8 *ptr, sal_uInt32 offset) { assert(ptr != nullptr); - ptr[offset] = (sal_uInt8)((val >> 24) & 0xFF); - ptr[offset+1] = (sal_uInt8)((val >> 16) & 0xFF); - ptr[offset+2] = (sal_uInt8)((val >> 8) & 0xFF); - ptr[offset+3] = (sal_uInt8)(val & 0xFF); + ptr[offset] = static_cast<sal_uInt8>((val >> 24) & 0xFF); + ptr[offset+1] = static_cast<sal_uInt8>((val >> 16) & 0xFF); + ptr[offset+2] = static_cast<sal_uInt8>((val >> 8) & 0xFF); + ptr[offset+3] = static_cast<sal_uInt8>(val & 0xFF); } static int TableEntryCompareF(const void *l, const void *r) @@ -127,7 +127,7 @@ static int NameRecordCompareF(const void *l, const void *r) static sal_uInt32 CheckSum(sal_uInt32 *ptr, sal_uInt32 length) { sal_uInt32 sum = 0; - sal_uInt32 *endptr = ptr + ((length + 3) & (sal_uInt32) ~3) / 4; + sal_uInt32 *endptr = ptr + ((length + 3) & sal_uInt32(~3)) / 4; while (ptr < endptr) sum += *ptr++; @@ -234,7 +234,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) s = offset = 12 + 16 * numTables; for (int i = 0; i < numTables; ++i) { - s += (te[i].length + 3) & (sal_uInt32) ~3; + s += (te[i].length + 3) & sal_uInt32(~3); /* if ((te[i].length & 3) != 0) s += (4 - (te[i].length & 3)) & 3; */ } @@ -258,15 +258,15 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) head = ttf + offset; } - memcpy(ttf+offset, te[i].data, (te[i].length + 3) & (sal_uInt32) ~3 ); - offset += (te[i].length + 3) & (sal_uInt32) ~3; + memcpy(ttf+offset, te[i].data, (te[i].length + 3) & sal_uInt32(~3) ); + offset += (te[i].length + 3) & sal_uInt32(~3); /* if ((te[i].length & 3) != 0) offset += (4 - (te[i].length & 3)) & 3; */ } free(te); p = reinterpret_cast<sal_uInt32 *>(ttf); - for (int i = 0; i < (int)s / 4; ++i) checkSumAdjustment += p[i]; + for (int i = 0; i < static_cast<int>(s) / 4; ++i) checkSumAdjustment += p[i]; PutUInt32(0xB1B0AFBA - checkSumAdjustment, head, 8); *ptr = ttf; @@ -365,7 +365,7 @@ static sal_uInt8 *ttmalloc(sal_uInt32 nbytes) { sal_uInt32 n; - n = (nbytes + 3) & (sal_uInt32) ~3; + n = (nbytes + 3) & sal_uInt32(~3); sal_uInt8* res = static_cast<sal_uInt8*>(calloc(n, 1)); assert(res != nullptr); @@ -470,7 +470,7 @@ static void TrueTypeTableDispose_post(TrueTypeTable *_this) if (p->format == 0x00030000) { /* do nothing */ } else { - fprintf(stderr, "Unsupported format of a 'post' table: %08X.\n", (int)p->format); + fprintf(stderr, "Unsupported format of a 'post' table: %08X.\n", static_cast<int>(p->format)); } free(p); } @@ -606,10 +606,10 @@ static sal_uInt8 *PackCmapType0(CmapSubTable const *s, sal_uInt32 *length) g = 0; for (j = 0; j < s->n; j++) { if (s->xc[j] == i) { - g = (sal_uInt16) s->xg[j]; + g = static_cast<sal_uInt16>(s->xg[j]); } } - p[i] = (sal_uInt8) g; + p[i] = static_cast<sal_uInt8>(g); } *length = 262; return ptr; @@ -623,16 +623,16 @@ static sal_uInt8 *PackCmapType6(CmapSubTable const *s, sal_uInt32 *length) sal_uInt16 g; PutUInt16(6, ptr, 0); - PutUInt16((sal_uInt16)(s->n*2+10), ptr, 2); + PutUInt16(static_cast<sal_uInt16>(s->n*2+10), ptr, 2); PutUInt16(0, ptr, 4); PutUInt16(0, ptr, 6); - PutUInt16((sal_uInt16)(s->n), ptr, 8 ); + PutUInt16(static_cast<sal_uInt16>(s->n), ptr, 8 ); for (i = 0; i < s->n; i++) { g = 0; for (j = 0; j < s->n; j++) { if (s->xc[j] == i) { - g = (sal_uInt16) s->xg[j]; + g = static_cast<sal_uInt16>(s->xg[j]); } } PutUInt16( g, p, 2*i ); @@ -678,12 +678,12 @@ static int GetRawData_cmap(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le _this->rawdata = cmap = ttmalloc(cmapsize); PutUInt16(0, cmap, 0); - PutUInt16((sal_uInt16)t->n, cmap, 2); + PutUInt16(static_cast<sal_uInt16>(t->n), cmap, 2); coffset = 4 + t->n * 8; for (i = 0; i < t->n; i++) { - PutUInt16((sal_uInt16)(t->s[i].id >> 16), cmap + 4, i * 8); - PutUInt16((sal_uInt16)(t->s[i].id & 0xFF), cmap + 4, 2 + i * 8); + PutUInt16(static_cast<sal_uInt16>(t->s[i].id >> 16), cmap + 4, i * 8); + PutUInt16(static_cast<sal_uInt16>(t->s[i].id & 0xFF), cmap + 4, 2 + i * 8); PutUInt32(coffset, cmap + 4, 4 + i * 8); memcpy(cmap + coffset, subtables[i], sizes[i]); free(subtables[i]); @@ -715,7 +715,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le l = static_cast<list>(_this->data); assert(l != nullptr); - if ((n = (sal_Int16)listCount(l)) == 0) return TTCR_NONAMES; + if ((n = static_cast<sal_Int16>(listCount(l))) == 0) return TTCR_NONAMES; NameRecord* nr = static_cast<NameRecord*>(scalloc(n, sizeof(NameRecord))); @@ -739,7 +739,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le PutUInt16(0, name, 0); PutUInt16(n, name, 2); - PutUInt16((sal_uInt16)(6 + 12 * n), name, 4); + PutUInt16(static_cast<sal_uInt16>(6 + 12 * n), name, 4); p1 = name + 6; p2 = p1 + 12 * n; @@ -747,10 +747,10 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le for (i = 0; i < n; i++) { PutUInt16(nr[i].platformID, p1, 0); PutUInt16(nr[i].encodingID, p1, 2); - PutUInt16((sal_uInt16)nr[i].languageID, p1, 4); + PutUInt16(static_cast<sal_uInt16>(nr[i].languageID), p1, 4); PutUInt16(nr[i].nameID, p1, 6); PutUInt16(nr[i].slen, p1, 8); - PutUInt16((sal_uInt16)(p2 - (name + 6 + 12 * n)), p1, 10); + PutUInt16(static_cast<sal_uInt16>(p2 - (name + 6 + 12 * n)), p1, 10); if (nr[i].slen) { memcpy(p2, nr[i].sptr, nr[i].slen); } @@ -763,7 +763,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le _this->rawdata = name; *ptr = name; - *len = (sal_uInt16)nameLen; + *len = static_cast<sal_uInt16>(nameLen); *tag = T_name; /*{int j; for(j=0; j<nameLen; j++) printf("%c", name[j]); }; */ @@ -787,10 +787,10 @@ static int GetRawData_post(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le PutUInt32(p->italicAngle, post, 4); PutUInt16(p->underlinePosition, post, 8); PutUInt16(p->underlineThickness, post, 10); - PutUInt16((sal_uInt16)p->isFixedPitch, post, 12); + PutUInt16(static_cast<sal_uInt16>(p->isFixedPitch), post, 12); ret = TTCR_OK; } else { - fprintf(stderr, "Unrecognized format of a post table: %08X.\n", (int)p->format); + fprintf(stderr, "Unrecognized format of a post table: %08X.\n", static_cast<int>(p->format)); ret = TTCR_POSTFORMAT; } @@ -1150,7 +1150,7 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt assert(table != nullptr); assert(table->tag == T_glyf); - if (!glyphdata) return (sal_uInt32)~0; + if (!glyphdata) return sal_uInt32(~0); std::vector< sal_uInt32 > glyphlist; @@ -1324,7 +1324,7 @@ static void ProcessTables(TrueTypeCreator *tt) } /* printf("X: %d -> %d.\n", index, j); */ - PutUInt16((sal_uInt16) j, ptr, 2); + PutUInt16(static_cast<sal_uInt16>(j), ptr, 2); ptr += 4; @@ -1351,7 +1351,7 @@ static void ProcessTables(TrueTypeCreator *tt) PutUInt32(p1 - glyfPtr, p2, 0); p2 += 4; } else { - PutUInt16((sal_uInt16)((p1 - glyfPtr) >> 1), p2, 0); + PutUInt16(static_cast<sal_uInt16>((p1 - glyfPtr) >> 1), p2, 0); p2 += 2; } p1 += gd->nbytes; @@ -1367,7 +1367,7 @@ static void ProcessTables(TrueTypeCreator *tt) if (indexToLocFormat == 1) { PutUInt32(p1 - glyfPtr, p2, 0); } else { - PutUInt16((sal_uInt16)((p1 - glyfPtr) >> 1), p2, 0); + PutUInt16(static_cast<sal_uInt16>((p1 - glyfPtr) >> 1), p2, 0); } glyf->rawdata = glyfPtr; @@ -1389,7 +1389,7 @@ static void ProcessTables(TrueTypeCreator *tt) maxp = FindTable(tt, T_maxp); sal_uInt8* const pMaxpData = static_cast<sal_uInt8*>(maxp->data); - PutUInt16((sal_uInt16)nGlyphs, pMaxpData, 4); + PutUInt16(static_cast<sal_uInt16>(nGlyphs), pMaxpData, 4); PutUInt16(maxPoints, pMaxpData, 6); PutUInt16(maxContours, pMaxpData, 8); PutUInt16(maxCompositePoints, pMaxpData, 10); @@ -1422,7 +1422,7 @@ static void ProcessTables(TrueTypeCreator *tt) } AddTable(tt, TrueTypeTableNew(T_hmtx, hmtxSize, hmtxPtr)); - PutUInt16((sal_uInt16)(nGlyphs - nlsb), hheaPtr, 34); + PutUInt16(static_cast<sal_uInt16>(nGlyphs - nlsb), hheaPtr, 34); free(hmtxPtr); free(met); } diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 76147a201eb8..c438382df487 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -36,10 +36,10 @@ static inline void decode_hb_tag( const hb_tag_t nTableTag, char *pTagName ) { - pTagName[0] = (char)(nTableTag >> 24); - pTagName[1] = (char)(nTableTag >> 16); - pTagName[2] = (char)(nTableTag >> 8); - pTagName[3] = (char)nTableTag; + pTagName[0] = static_cast<char>(nTableTag >> 24); + pTagName[1] = static_cast<char>(nTableTag >> 16); + pTagName[2] = static_cast<char>(nTableTag >> 8); + pTagName[3] = static_cast<char>(nTableTag); pTagName[4] = 0; } diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index 9281fc101ddb..8e96965e7047 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -54,7 +54,7 @@ BitmapChecksum AnimationBitmap::GetChecksum() const UInt32ToSVBT32( (long) eDisposal, aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - UInt32ToSVBT32( (long) bUserInput, aBT32 ); + UInt32ToSVBT32( static_cast<long>(bUserInput), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); return nCrc; @@ -319,7 +319,7 @@ void Animation::Draw( OutputDevice* pOut, const Point& rDestPt, const Size& rDes void Animation::ImplRestartTimer( sal_uLong nTimeout ) { - maTimer.SetTimeout( std::max( nTimeout, (sal_uLong)(MIN_TIMEOUT + ( mnAnimCount - 1 ) * INC_TIMEOUT) ) * 10 ); + maTimer.SetTimeout( std::max( nTimeout, static_cast<sal_uLong>(MIN_TIMEOUT + ( mnAnimCount - 1 ) * INC_TIMEOUT) ) * 10 ); maTimer.Start(); } diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx index 373974f0f925..f8b9701350f1 100644 --- a/vcl/source/gdi/bitmap.cxx +++ b/vcl/source/gdi/bitmap.cxx @@ -96,7 +96,7 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett for( sal_uInt16 nB = 0; nB < 256; nB += 51 ) for( sal_uInt16 nG = 0; nG < 256; nG += 51 ) for( sal_uInt16 nR = 0; nR < 256; nR += 51 ) - aPal[ nActCol++ ] = BitmapColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ); + aPal[ nActCol++ ] = BitmapColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); // Set standard Office colors aPal[ nActCol++ ] = BitmapColor( 0, 184, 255 ); @@ -172,7 +172,7 @@ const BitmapPalette& Bitmap::GetGreyPalette( int nEntries ) aGreyPalette256.SetEntryCount( 256 ); for( sal_uInt16 i = 0; i < 256; i++ ) - aGreyPalette256[ i ] = BitmapColor( (sal_uInt8) i, (sal_uInt8) i, (sal_uInt8) i ); + aGreyPalette256[ i ] = BitmapColor( static_cast<sal_uInt8>(i), static_cast<sal_uInt8>(i), static_cast<sal_uInt8>(i) ); } return aGreyPalette256; @@ -647,7 +647,7 @@ bool Bitmap::Rotate( long nAngle10, const Color& rFillColor ) Point aTmpPoint; tools::Rectangle aTmpRectangle( aTmpPoint, aSizePix ); tools::Polygon aPoly( aTmpRectangle ); - aPoly.Rotate( aTmpPoint, (sal_uInt16) nAngle10 ); + aPoly.Rotate( aTmpPoint, static_cast<sal_uInt16>(nAngle10) ); tools::Rectangle aNewBound( aPoly.GetBoundRect() ); const Size aNewSizePix( aNewBound.GetSize() ); @@ -816,13 +816,13 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, for (int i = 0; ( i < nSrcCount ) && ( nNextIndex < nSrcCount ); ++i) { - const BitmapColor& rSrcCol = pSrcAcc->GetPaletteColor( (sal_uInt16) i ); + const BitmapColor& rSrcCol = pSrcAcc->GetPaletteColor( static_cast<sal_uInt16>(i) ); bool bFound = false; for (int j = 0; j < nDstCount; ++j) { - if( rSrcCol == pDstAcc->GetPaletteColor( (sal_uInt16) j ) ) + if( rSrcCol == pDstAcc->GetPaletteColor( static_cast<sal_uInt16>(j) ) ) { bFound = true; break; @@ -830,7 +830,7 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, } if( !bFound ) - pDstAcc->SetPaletteColor( (sal_uInt16) nNextIndex++, rSrcCol ); + pDstAcc->SetPaletteColor( static_cast<sal_uInt16>(nNextIndex++), rSrcCol ); } } } @@ -862,7 +862,7 @@ bool Bitmap::CopyPixel( const tools::Rectangle& rRectDst, // Create index map for the color table, as the bitmap should be copied // retaining it's color information relatively well for( sal_uInt16 i = 0; i < nCount; i++ ) - pMap[ i ] = (sal_uInt8) pWriteAcc->GetBestPaletteIndex( pReadAcc->GetPaletteColor( i ) ); + pMap[ i ] = static_cast<sal_uInt8>(pWriteAcc->GetBestPaletteIndex( pReadAcc->GetPaletteColor( i ) )); for( long nSrcY = aRectSrc.Top(); nSrcY < nSrcEndY; nSrcY++, nDstY++ ) for( long nSrcX = aRectSrc.Left(), nDstX = aRectDst.Left(); nSrcX < nSrcEndX; nSrcX++, nDstX++ ) @@ -1451,7 +1451,7 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) { pAcc->SetPaletteEntryCount( nActColors + 1 ); pAcc->SetPaletteColor( nActColors, rReplaceColor ); - aReplace = BitmapColor( (sal_uInt8) nActColors ); + aReplace = BitmapColor( static_cast<sal_uInt8>(nActColors) ); } else { @@ -1470,7 +1470,7 @@ bool Bitmap::Replace( const Bitmap& rMask, const Color& rReplaceColor ) if( !pFlags[ i ] ) { pAcc->SetPaletteColor( i, rReplaceColor ); - aReplace = BitmapColor( (sal_uInt8) i ); + aReplace = BitmapColor( static_cast<sal_uInt8>(i) ); } } } diff --git a/vcl/source/gdi/bitmap3.cxx b/vcl/source/gdi/bitmap3.cxx index 668bf5f23f29..180e4acacbfd 100644 --- a/vcl/source/gdi/bitmap3.cxx +++ b/vcl/source/gdi/bitmap3.cxx @@ -37,8 +37,8 @@ #include <octree.hxx> #include <BitmapScaleConvolution.hxx> -#define RGB15( _def_cR, _def_cG, _def_cB ) (((sal_uLong)(_def_cR)<<10)|((sal_uLong)(_def_cG)<<5)|(sal_uLong)(_def_cB)) -#define GAMMA( _def_cVal, _def_InvGamma ) ((sal_uInt8)MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255)) +#define RGB15( _def_cR, _def_cG, _def_cB ) ((static_cast<sal_uLong>(_def_cR)<<10)|(static_cast<sal_uLong>(_def_cG)<<5)|static_cast<sal_uLong>(_def_cB)) +#define GAMMA( _def_cVal, _def_InvGamma ) (static_cast<sal_uInt8>(MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255))) #define CALC_ERRORS \ nTemp = p1T[nX++] >> 12; \ @@ -426,7 +426,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) const sal_uLong nG = *pReadScan++; const sal_uLong nR = *pReadScan++; - *pWriteScan++ = (sal_uInt8) ( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); + *pWriteScan++ = static_cast<sal_uInt8>( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); } } } @@ -446,7 +446,7 @@ bool Bitmap::ImplMakeGreyscales( sal_uInt16 nGreys ) const sal_uLong nG = *pReadScan++; const sal_uLong nB = *pReadScan++; - *pWriteScan++ = (sal_uInt8) ( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); + *pWriteScan++ = static_cast<sal_uInt8>( ( nB * 28UL + nG * 151UL + nR * 77UL ) >> nShift ); } } } @@ -632,7 +632,7 @@ bool Bitmap::ImplConvertDown(sal_uInt16 nBitCount, Color const * pExtColor) for (long nY = 0; nY < nHeight; nY++, nYTmp++) { // first pixel in the line - cIndex = (sal_uInt8) aColorMap.GetBestPaletteIndex(pQLine1[0].ImplGetColor()); + cIndex = static_cast<sal_uInt8>(aColorMap.GetBestPaletteIndex(pQLine1[0].ImplGetColor())); pWriteAcc->SetPixelIndex(nY, 0, cIndex); long nX; @@ -704,8 +704,8 @@ bool Bitmap::ImplConvertGhosted() for( long i = 0, nCount = aNewPal.GetEntryCount(); i < nCount; i++ ) { - const BitmapColor& rOld = pR->GetPaletteColor( (sal_uInt16) i ); - aNewPal[ (sal_uInt16) i ] = BitmapColor( ( rOld.GetRed() >> 1 ) | 0x80, + const BitmapColor& rOld = pR->GetPaletteColor( static_cast<sal_uInt16>(i) ); + aNewPal[ static_cast<sal_uInt16>(i) ] = BitmapColor( ( rOld.GetRed() >> 1 ) | 0x80, ( rOld.GetGreen() >> 1 ) | 0x80, ( rOld.GetBlue() >> 1 ) | 0x80 ); } @@ -868,8 +868,8 @@ bool Bitmap::Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag ) if( aSize.Width() && aSize.Height() ) { - bRet = Scale( (double) rNewSize.Width() / aSize.Width(), - (double) rNewSize.Height() / aSize.Height(), + bRet = Scale( static_cast<double>(rNewSize.Width()) / aSize.Width(), + static_cast<double>(rNewSize.Height()) / aSize.Height(), nScaleFlag ); } else @@ -1030,7 +1030,7 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY { const long nNewWidth1 = nNewWidth - 1; const long nWidth1 = pReadAcc->Width() - 1; - const double fRevScaleX = (double) nWidth1 / nNewWidth1; + const double fRevScaleX = static_cast<double>(nWidth1) / nNewWidth1; std::unique_ptr<long[]> pLutInt(new long[ nNewWidth ]); std::unique_ptr<long[]> pLutFrac(new long[ nNewWidth ]); @@ -1038,9 +1038,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY for( long nX = 0, nTemp = nWidth - 2; nX < nNewWidth; nX++ ) { double fTemp = nX * fRevScaleX; - pLutInt[ nX ] = MinMax( (long) fTemp, 0, nTemp ); + pLutInt[ nX ] = MinMax( static_cast<long>(fTemp), 0, nTemp ); fTemp -= pLutInt[ nX ]; - pLutFrac[ nX ] = (long) ( fTemp * 1024. ); + pLutFrac[ nX ] = static_cast<long>( fTemp * 1024. ); } for( long nY = 0; nY < nHeight; nY++ ) @@ -1089,9 +1089,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY long lXG1 = aCol1.GetGreen() - lXG0; long lXB1 = aCol1.GetBlue() - lXB0; - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0.SetRed( static_cast<sal_uInt8>( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); + aCol0.SetGreen( static_cast<sal_uInt8>( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); + aCol0.SetBlue( static_cast<sal_uInt8>( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); pWriteAcc->SetPixel( nY, nX, aCol0 ); } @@ -1117,7 +1117,7 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY { const long nNewHeight1 = nNewHeight - 1; const long nHeight1 = pReadAcc->Height() - 1; - const double fRevScaleY = (double) nHeight1 / nNewHeight1; + const double fRevScaleY = static_cast<double>(nHeight1) / nNewHeight1; std::unique_ptr<long[]> pLutInt(new long[ nNewHeight ]); std::unique_ptr<long[]> pLutFrac(new long[ nNewHeight ]); @@ -1125,9 +1125,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY for( long nY = 0, nTemp = nHeight - 2; nY < nNewHeight; nY++ ) { double fTemp = nY * fRevScaleY; - pLutInt[ nY ] = MinMax( (long) fTemp, 0, nTemp ); + pLutInt[ nY ] = MinMax( static_cast<long>(fTemp), 0, nTemp ); fTemp -= pLutInt[ nY ]; - pLutFrac[ nY ] = (long) ( fTemp * 1024. ); + pLutFrac[ nY ] = static_cast<long>( fTemp * 1024. ); } // after 1st step, bitmap *is* 24bit format (see above) @@ -1162,9 +1162,9 @@ bool Bitmap::ImplScaleInterpolate( const double& rScaleX, const double& rScaleY long lXG1 = aCol1.GetGreen() - lXG0; long lXB1 = aCol1.GetBlue() - lXB0; - aCol0.SetRed( (sal_uInt8) ( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); - aCol0.SetGreen( (sal_uInt8) ( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); - aCol0.SetBlue( (sal_uInt8) ( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); + aCol0.SetRed( static_cast<sal_uInt8>( ( lXR1 * nTemp + ( lXR0 << 10 ) ) >> 10 ) ); + aCol0.SetGreen( static_cast<sal_uInt8>( ( lXG1 * nTemp + ( lXG0 << 10 ) ) >> 10 ) ); + aCol0.SetBlue( static_cast<sal_uInt8>( ( lXB1 * nTemp + ( lXB0 << 10 ) ) >> 10 ) ); pWriteAcc->SetPixel( nY, nX, aCol0 ); } @@ -1223,7 +1223,7 @@ bool Bitmap::ImplDitherMatrix() { const sal_uLong nWidth = pReadAcc->Width(); const sal_uLong nHeight = pReadAcc->Height(); - BitmapColor aIndex( (sal_uInt8) 0 ); + BitmapColor aIndex( sal_uInt8(0) ); if( pReadAcc->HasPalette() ) { @@ -1237,7 +1237,7 @@ bool Bitmap::ImplDitherMatrix() const sal_uLong nG = ( nVCLLut[ aCol.GetGreen() ] + nD ) >> 16; const sal_uLong nB = ( nVCLLut[ aCol.GetBlue() ] + nD ) >> 16; - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); pWriteAcc->SetPixel( nY, nX, aIndex ); } } @@ -1254,7 +1254,7 @@ bool Bitmap::ImplDitherMatrix() const sal_uLong nG = ( nVCLLut[ aCol.GetGreen() ] + nD ) >> 16; const sal_uLong nB = ( nVCLLut[ aCol.GetBlue() ] + nD ) >> 16; - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ nR ] + nVCLGLut[ nG ] + nVCLBLut[ nB ] ) ); pWriteAcc->SetPixel( nY, nX, aIndex ); } } @@ -1317,9 +1317,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( 0, nZ ) ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } else @@ -1328,9 +1328,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPixel( 0, nZ ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } @@ -1348,9 +1348,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPaletteColor( pReadAcc->GetPixelIndex( nY, nZ ) ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } else @@ -1359,9 +1359,9 @@ bool Bitmap::ImplDitherFloyd() { aColor = pReadAcc->GetPixel( nY, nZ ); - *pTmp++ = (long) aColor.GetBlue() << 12; - *pTmp++ = (long) aColor.GetGreen() << 12; - *pTmp++ = (long) aColor.GetRed() << 12; + *pTmp++ = static_cast<long>(aColor.GetBlue()) << 12; + *pTmp++ = static_cast<long>(aColor.GetGreen()) << 12; + *pTmp++ = static_cast<long>(aColor.GetRed()) << 12; } } } @@ -1512,7 +1512,7 @@ bool Bitmap::ReduceColors( sal_uInt16 nColorCount, BmpReduce eReduce ) { bool bRet; - if( GetColorCount() <= (sal_uLong) nColorCount ) + if( GetColorCount() <= static_cast<sal_uLong>(nColorCount) ) bRet = true; else if( nColorCount ) { @@ -1533,7 +1533,7 @@ bool Bitmap::ImplReduceSimple( sal_uInt16 nColorCount ) { Bitmap aNewBmp; ScopedReadAccess pRAcc(*this); - const sal_uInt16 nColCount = std::min( nColorCount, (sal_uInt16) 256 ); + const sal_uInt16 nColCount = std::min( nColorCount, sal_uInt16(256) ); sal_uInt16 nBitCount; bool bRet = false; @@ -1658,9 +1658,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) ); - pCountTable[ ( ( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++; + pCountTable[ ( ( static_cast<sal_uInt32>(rCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(rCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(rCol.GetBlue()) >> nRightShiftBits ) ].mnCount++; } } } @@ -1671,9 +1671,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor aCol( pRAcc->GetPixel( nY, nX ) ); - pCountTable[ ( ( ( (sal_uInt32) aCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) aCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits ) ].mnCount++; + pCountTable[ ( ( static_cast<sal_uInt32>(aCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(aCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(aCol.GetBlue()) >> nRightShiftBits ) ].mnCount++; } } } @@ -1685,9 +1685,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( sal_uInt16 n = 0; n < nColCount; n++ ) { const PopularColorCount& rPop = pCountTable[ n ]; - aNewPal[ n ] = BitmapColor( (sal_uInt8) ( ( rPop.mnIndex >> nLeftShiftBits2 ) << nRightShiftBits ), - (sal_uInt8) ( ( ( rPop.mnIndex >> nLeftShiftBits1 ) & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ), - (sal_uInt8) ( ( rPop.mnIndex & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ) ); + aNewPal[ n ] = BitmapColor( static_cast<sal_uInt8>( ( rPop.mnIndex >> nLeftShiftBits2 ) << nRightShiftBits ), + static_cast<sal_uInt8>( ( ( rPop.mnIndex >> nLeftShiftBits1 ) & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ), + static_cast<sal_uInt8>( ( rPop.mnIndex & ( nColorsPerComponent - 1 ) ) << nRightShiftBits ) ); } Bitmap aNewBmp( GetSizePixel(), nBitCount, &aNewPal ); @@ -1695,13 +1695,13 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) if( pWAcc ) { - BitmapColor aDstCol( (sal_uInt8) 0 ); + BitmapColor aDstCol( sal_uInt8(0) ); std::unique_ptr<sal_uInt8[]> pIndexMap(new sal_uInt8[ nTotalColors ]); for( long nR = 0, nIndex = 0; nR < 256; nR += nColorOffset ) for( long nG = 0; nG < 256; nG += nColorOffset ) for( long nB = 0; nB < 256; nB += nColorOffset ) - pIndexMap[ nIndex++ ] = (sal_uInt8) aNewPal.GetBestIndex( BitmapColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ) ); + pIndexMap[ nIndex++ ] = static_cast<sal_uInt8>(aNewPal.GetBestIndex( BitmapColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ) )); if( pRAcc->HasPalette() ) { @@ -1710,9 +1710,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor& rCol = pRAcc->GetPaletteColor( pRAcc->GetPixelIndex( nY, nX ) ); - aDstCol.SetIndex( pIndexMap[ ( ( ( (sal_uInt32) rCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) rCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) rCol.GetBlue() ) >> nRightShiftBits ) ] ); + aDstCol.SetIndex( pIndexMap[ ( ( static_cast<sal_uInt32>(rCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(rCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(rCol.GetBlue()) >> nRightShiftBits ) ] ); pWAcc->SetPixel( nY, nX, aDstCol ); } } @@ -1724,9 +1724,9 @@ bool Bitmap::ImplReducePopular( sal_uInt16 nColCount ) for( long nX = 0; nX < nWidth; nX++ ) { const BitmapColor aCol( pRAcc->GetPixel( nY, nX ) ); - aDstCol.SetIndex( pIndexMap[ ( ( ( (sal_uInt32) aCol.GetRed() ) >> nRightShiftBits ) << nLeftShiftBits2 ) | - ( ( ( (sal_uInt32) aCol.GetGreen() ) >> nRightShiftBits ) << nLeftShiftBits1 ) | - ( ( (sal_uInt32) aCol.GetBlue() ) >> nRightShiftBits ) ] ); + aDstCol.SetIndex( pIndexMap[ ( ( static_cast<sal_uInt32>(aCol.GetRed()) >> nRightShiftBits ) << nLeftShiftBits2 ) | + ( ( static_cast<sal_uInt32>(aCol.GetGreen()) >> nRightShiftBits ) << nLeftShiftBits1 ) | + ( static_cast<sal_uInt32>(aCol.GetBlue()) >> nRightShiftBits ) ] ); pWAcc->SetPixel( nY, nX, aDstCol ); } } @@ -1859,10 +1859,10 @@ void Bitmap::ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal, { if( pBuf[ RGB15( nR1, nG1, nB1 ) ] ) { - aCol.SetRed( (sal_uInt8) ( nR1 << 3 ) ); - aCol.SetGreen( (sal_uInt8) ( nG1 << 3 ) ); - aCol.SetBlue( (sal_uInt8) ( nB1 << 3 ) ); - rPal[ (sal_uInt16) rIndex++ ] = aCol; + aCol.SetRed( static_cast<sal_uInt8>( nR1 << 3 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( nG1 << 3 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( nB1 << 3 ) ); + rPal[ static_cast<sal_uInt16>(rIndex++) ] = aCol; } } else @@ -1889,10 +1889,10 @@ void Bitmap::ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal, } } - aCol.SetRed( (sal_uInt8) ( ( nRSum / nPixels ) << 3 ) ); - aCol.SetGreen( (sal_uInt8) ( ( nGSum / nPixels ) << 3 ) ); - aCol.SetBlue( (sal_uInt8) ( ( nBSum / nPixels ) << 3 ) ); - rPal[ (sal_uInt16) rIndex++ ] = aCol; + aCol.SetRed( static_cast<sal_uInt8>( ( nRSum / nPixels ) << 3 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( ( nGSum / nPixels ) << 3 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( ( nBSum / nPixels ) << 3 ) ); + rPal[ static_cast<sal_uInt16>(rIndex++) ] = aCol; } else { @@ -2034,18 +2034,18 @@ bool Bitmap::Adjust( short nLuminancePercent, short nContrastPercent, { if(!msoBrightness) { - cMapR[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fROff ), 0, 255 ); - cMapG[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fGOff ), 0, 255 ); - cMapB[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fBOff ), 0, 255 ); + cMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fROff ), 0, 255 )); + cMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fGOff ), 0, 255 )); + cMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fBOff ), 0, 255 )); } else { // LO simply uses (in a somewhat optimized form) "newcolor = (oldcolor-128)*contrast+brightness+128" // as the formula, i.e. contrast first, brightness afterwards. MSOffice, for whatever weird reason, // use neither first, but apparently it applies half of brightness before contrast and half afterwards. - cMapR[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 ); - cMapG[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 ); - cMapB[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 ); + cMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 )); + cMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 )); + cMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 )); } if( bGamma ) { @@ -2166,9 +2166,9 @@ bool Bitmap::ImplConvolutionPass(Bitmap& aNewBitmap, BitmapReadAccess const * pR } BitmapColor aResultColor( - (sal_uInt8) MinMax( aValueRed / aSum, 0, 255 ), - (sal_uInt8) MinMax( aValueGreen / aSum, 0, 255 ), - (sal_uInt8) MinMax( aValueBlue / aSum, 0, 255 ) ); + static_cast<sal_uInt8>(MinMax( aValueRed / aSum, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aValueGreen / aSum, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aValueBlue / aSum, 0, 255 )) ); int nDestX = nSourceY; int nDestY = nSourceX; diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index 554485de13dd..9400f4d61e2b 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -36,7 +36,7 @@ static inline sal_uInt8 lcl_getDuotoneColorComponent( sal_uInt8 base, sal_uInt16 color2 = color2*base/0xFF; color1 = color1*(0xFF-base)/0xFF; - return (sal_uInt8) (color1+color2); + return static_cast<sal_uInt8>(color1+color2); } bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) @@ -209,9 +209,9 @@ bool Bitmap::ImplConvolute3( const long* pMatrix ) nSumB += pTmp[ pColor->GetBlue() ]; // calculate destination color - pWriteAcc->SetPixel( nY, nX, BitmapColor( (sal_uInt8) MinMax( nSumR / nDivisor, 0, 255 ), - (sal_uInt8) MinMax( nSumG / nDivisor, 0, 255 ), - (sal_uInt8) MinMax( nSumB / nDivisor, 0, 255 ) ) ); + pWriteAcc->SetPixel( nY, nX, BitmapColor( static_cast<sal_uInt8>(MinMax( nSumR / nDivisor, 0, 255 )), + static_cast<sal_uInt8>(MinMax( nSumG / nDivisor, 0, 255 )), + static_cast<sal_uInt8>(MinMax( nSumB / nDivisor, 0, 255 )) ) ); } if( ++nY < nHeight ) @@ -371,7 +371,7 @@ bool Bitmap::ImplMedianFilter() MNMX3( nB9, nB2, nB3 ); // set destination color - pWriteAcc->SetPixel( nY, nX, BitmapColor( (sal_uInt8) nR2, (sal_uInt8) nG2, (sal_uInt8) nB2 ) ); + pWriteAcc->SetPixel( nY, nX, BitmapColor( static_cast<sal_uInt8>(nR2), static_cast<sal_uInt8>(nG2), static_cast<sal_uInt8>(nB2) ) ); } if( ++nY < nHeight ) @@ -445,7 +445,7 @@ bool Bitmap::ImplSobelGrey() if( pWriteAcc ) { - BitmapColor aGrey( (sal_uInt8) 0 ); + BitmapColor aGrey( sal_uInt8(0) ); const long nWidth = pWriteAcc->Width(); const long nHeight = pWriteAcc->Height(); const long nMask111 = -1, nMask121 = 0, nMask131 = 1; @@ -515,8 +515,8 @@ bool Bitmap::ImplSobelGrey() nSum1 += nMask331 * nGrey33; nSum2 += nMask332 * nGrey33; - nSum1 = (long) sqrt( (double)( nSum1 * nSum1 + nSum2 * nSum2 ) ); - aGrey.SetIndex( ~(sal_uInt8) SAL_BOUND( nSum1, 0, 255 ) ); + nSum1 = static_cast<long>(sqrt( static_cast<double>( nSum1 * nSum1 + nSum2 * nSum2 ) )); + aGrey.SetIndex( ~static_cast<sal_uInt8>(SAL_BOUND( nSum1, 0, 255 )) ); pWriteAcc->SetPixel( nY, nX, aGrey ); if( nX < ( nWidth - 1 ) ) @@ -571,7 +571,7 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) if( pWriteAcc ) { - BitmapColor aGrey( (sal_uInt8) 0 ); + BitmapColor aGrey( sal_uInt8(0) ); const long nWidth = pWriteAcc->Width(); const long nHeight = pWriteAcc->Height(); long nGrey11, nGrey12, nGrey13; @@ -589,7 +589,7 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) const long nLz = FRound( sin( fElev ) * 255.0 ); const auto nZ2 = ( ( 6 * 255 ) / 4 ) * ( ( 6 * 255 ) / 4 ); const long nNzLz = ( ( 6 * 255 ) / 4 ) * nLz; - const sal_uInt8 cLz = (sal_uInt8) SAL_BOUND( nLz, 0, 255 ); + const sal_uInt8 cLz = static_cast<sal_uInt8>(SAL_BOUND( nLz, 0, 255 )); // fill mapping tables pHMap[ 0 ] = 0; @@ -625,8 +625,8 @@ bool Bitmap::ImplEmbossGrey( const BmpFilterParam* pFilterParam ) aGrey.SetIndex( 0 ); else { - const double fGrey = nDotL / sqrt( (double)(nNx * nNx + nNy * nNy + nZ2) ); - aGrey.SetIndex( (sal_uInt8) SAL_BOUND( fGrey, 0, 255 ) ); + const double fGrey = nDotL / sqrt( static_cast<double>(nNx * nNx + nNy * nNy + nZ2) ); + aGrey.SetIndex( static_cast<sal_uInt8>(SAL_BOUND( fGrey, 0, 255 )) ); } pWriteAcc->SetPixel( nY, nX, aGrey ); @@ -729,9 +729,9 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) for( sal_uInt16 i = 0; i < 256; i++ ) { BitmapColor& rCol = aSepiaPal[ i ]; - const sal_uInt8 cSepiaValue = (sal_uInt8) ( nSepia * i / 10000 ); + const sal_uInt8 cSepiaValue = static_cast<sal_uInt8>( nSepia * i / 10000 ); - rCol.SetRed( (sal_uInt8) i ); + rCol.SetRed( static_cast<sal_uInt8>(i) ); rCol.SetGreen( cSepiaValue ); rCol.SetBlue( cSepiaValue ); } @@ -741,7 +741,7 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) if( pWriteAcc ) { - BitmapColor aCol( (sal_uInt8) 0 ); + BitmapColor aCol( sal_uInt8(0) ); const long nWidth = pWriteAcc->Width(); const long nHeight = pWriteAcc->Height(); @@ -872,9 +872,9 @@ bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam ) } } - aCol.SetRed( (sal_uInt8) ( nSumR * fArea_1 ) ); - aCol.SetGreen( (sal_uInt8) ( nSumG * fArea_1 ) ); - aCol.SetBlue( (sal_uInt8) ( nSumB * fArea_1 ) ); + aCol.SetRed( static_cast<sal_uInt8>( nSumR * fArea_1 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( nSumG * fArea_1 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( nSumB * fArea_1 ) ); for( nY = nY1; nY <= nY2; nY++ ) for( nX = nX1; nX <= nX2; nX++ ) @@ -905,9 +905,9 @@ bool Bitmap::ImplMosaic( const BmpFilterParam* pFilterParam ) } } - aCol.SetRed( (sal_uInt8) ( nSumR * fArea_1 ) ); - aCol.SetGreen( (sal_uInt8) ( nSumG * fArea_1 ) ); - aCol.SetBlue( (sal_uInt8) ( nSumB * fArea_1 ) ); + aCol.SetRed( static_cast<sal_uInt8>( nSumR * fArea_1 ) ); + aCol.SetGreen( static_cast<sal_uInt8>( nSumG * fArea_1 ) ); + aCol.SetBlue( static_cast<sal_uInt8>( nSumB * fArea_1 ) ); for( nY = nY1; nY <= nY2; nY++ ) for( nX = nX1; nX <= nX2; nX++ ) @@ -1003,7 +1003,7 @@ bool Bitmap::ImplPopArt() for( n = 0; n < nEntryCount; n++ ) { PopArtEntry& rEntry = pPopArtTable[ n ]; - rEntry.mnIndex = (sal_uInt16) n; + rEntry.mnIndex = static_cast<sal_uInt16>(n); rEntry.mnCount = 0; } @@ -1043,7 +1043,7 @@ bool Bitmap::ImplPopArt() } double* MakeBlurKernel(const double radius, int& rows) { - int intRadius = (int) radius + 1.0; + int intRadius = static_cast<int>(radius) + 1.0; rows = intRadius * 2 + 1; double* matrix = new double[rows]; @@ -1209,9 +1209,9 @@ bool Bitmap::ImplSeparableUnsharpenFilter(const double radius) { aColor = pReadAcc->GetColor( y , x ); BitmapColor aResultColor( - (sal_uInt8) MinMax( aColor.GetRed() + (aColor.GetRed() - aColorBlur.GetRed()) * aAmount, 0, 255 ), - (sal_uInt8) MinMax( aColor.GetGreen() + (aColor.GetGreen() - aColorBlur.GetGreen()) * aAmount, 0, 255 ), - (sal_uInt8) MinMax( aColor.GetBlue() + (aColor.GetBlue() - aColorBlur.GetBlue()) * aAmount, 0, 255 ) ); + static_cast<sal_uInt8>(MinMax( aColor.GetRed() + (aColor.GetRed() - aColorBlur.GetRed()) * aAmount, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aColor.GetGreen() + (aColor.GetGreen() - aColorBlur.GetGreen()) * aAmount, 0, 255 )), + static_cast<sal_uInt8>(MinMax( aColor.GetBlue() + (aColor.GetBlue() - aColorBlur.GetBlue()) * aAmount, 0, 255 )) ); pWriteAcc->SetPixel( y, x, aResultColor ); } diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 59e519a83b95..2eb5a2ceb90c 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -306,7 +306,7 @@ BitmapChecksum BitmapEx::GetChecksum() const UInt32ToSVBT32( (long) eTransparent, aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); - UInt32ToSVBT32( (long) bAlpha, aBT32 ); + UInt32ToSVBT32( static_cast<long>(bAlpha), aBT32 ); nCrc = vcl_get_checksum( nCrc, aBT32, 4 ); if( ( TransparentType::Bitmap == eTransparent ) && !aMask.IsEmpty() ) @@ -386,8 +386,8 @@ bool BitmapEx::Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag ) ( rNewSize.Width() != aBitmapSize.Width() || rNewSize.Height() != aBitmapSize.Height() ) ) { - bRet = Scale( (double) rNewSize.Width() / aBitmapSize.Width(), - (double) rNewSize.Height() / aBitmapSize.Height(), + bRet = Scale( static_cast<double>(rNewSize.Width()) / aBitmapSize.Width(), + static_cast<double>(rNewSize.Height()) / aBitmapSize.Height(), nScaleFlag ); } else @@ -696,7 +696,7 @@ BitmapEx BitmapEx:: AutoScaleBitmap(BitmapEx const & aBitmap, const long aStanda // Draw a rect into virDevice aVirDevice->DrawRect( aRect ); - Point aPointPixel( (long)imgposX, (long)imgposY ); + Point aPointPixel( static_cast<long>(imgposX), static_cast<long>(imgposY) ); aVirDevice->DrawBitmapEx( aPointPixel, aRet ); aRet = aVirDevice->GetBitmapEx( aEmptyPoint, aStdSize ); @@ -1060,11 +1060,11 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else if(ScanlineFormat::N24BitTcBgr == xContent->GetScanlineFormat()) { - for(sal_uInt32 y(0); y < (sal_uInt32)xContent->Height(); y++) + for(sal_uInt32 y(0); y < static_cast<sal_uInt32>(xContent->Height()); y++) { Scanline pScan = xContent->GetScanline(y); - for(sal_uInt32 x(0); x < (sal_uInt32)xContent->Width(); x++) + for(sal_uInt32 x(0); x < static_cast<sal_uInt32>(xContent->Width()); x++) { const basegfx::BColor aBSource( *(pScan + 2)* fConvertColor, @@ -1079,11 +1079,11 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else if(ScanlineFormat::N24BitTcRgb == xContent->GetScanlineFormat()) { - for(sal_uInt32 y(0); y < (sal_uInt32)xContent->Height(); y++) + for(sal_uInt32 y(0); y < static_cast<sal_uInt32>(xContent->Height()); y++) { Scanline pScan = xContent->GetScanline(y); - for(sal_uInt32 x(0); x < (sal_uInt32)xContent->Width(); x++) + for(sal_uInt32 x(0); x < static_cast<sal_uInt32>(xContent->Width()); x++) { const basegfx::BColor aBSource( *pScan * fConvertColor, @@ -1098,15 +1098,15 @@ BitmapEx BitmapEx::ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorMod } else { - for(sal_uInt32 y(0); y < (sal_uInt32)xContent->Height(); y++) + for(sal_uInt32 y(0); y < static_cast<sal_uInt32>(xContent->Height()); y++) { - for(sal_uInt32 x(0); x < (sal_uInt32)xContent->Width(); x++) + for(sal_uInt32 x(0); x < static_cast<sal_uInt32>(xContent->Width()); x++) { const BitmapColor aBMCol(xContent->GetColor(y, x)); const basegfx::BColor aBSource( - (double)aBMCol.GetRed() * fConvertColor, - (double)aBMCol.GetGreen() * fConvertColor, - (double)aBMCol.GetBlue() * fConvertColor); + static_cast<double>(aBMCol.GetRed()) * fConvertColor, + static_cast<double>(aBMCol.GetGreen()) * fConvertColor, + static_cast<double>(aBMCol.GetBlue()) * fConvertColor); const basegfx::BColor aBDest(rModifier->getModifiedColor(aBSource)); xContent->SetPixel(y, x, BitmapColor(Color(aBDest))); diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx index ff08f629caaa..6a97eebc3cab 100644 --- a/vcl/source/gdi/dibtools.cxx +++ b/vcl/source/gdi/dibtools.cxx @@ -802,7 +802,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL { if(aHeader.nColsUsed) { - nColors = (sal_uInt16)aHeader.nColsUsed; + nColors = static_cast<sal_uInt16>(aHeader.nColsUsed); } else { @@ -1135,7 +1135,7 @@ bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess const & rAcc, bool bRLE4 ) if ( nCount > 1 ) { - *pTmp++ = (sal_uInt8) nCount; + *pTmp++ = static_cast<sal_uInt8>(nCount); *pTmp++ = ( bRLE4 ? ( ( cPix << 4 ) | cPix ) : cPix ); nBufCount += 2; } @@ -1159,7 +1159,7 @@ bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess const & rAcc, bool bRLE4 ) if ( nCount > 3 ) { *pTmp++ = 0; - *pTmp++ = (sal_uInt8) --nCount; + *pTmp++ = static_cast<sal_uInt8>(--nCount); if( bRLE4 ) { @@ -1395,7 +1395,7 @@ bool ImplWriteDIBBits(SvStream& rOStm, BitmapReadAccess const & rAcc, BitmapRead if(bWriteAlpha) { - *pTmp++ = (sal_uInt8)0xff - pAccAlpha->GetPixelIndex( nY, nX ); + *pTmp++ = sal_uInt8(0xff) - pAccAlpha->GetPixelIndex( nY, nX ); } } @@ -1478,8 +1478,8 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess c // especially if maPrefSize is small. Trying to circumvent // that by performing part of the math in floating point. const Size aScale100000(OutputDevice::LogicToLogic(Size(100000, 100000), MapMode(MapUnit::Map100thMM), rBitmap.GetPrefMapMode())); - const double fBmpWidthM((double)rBitmap.GetPrefSize().Width() / aScale100000.Width()); - const double fBmpHeightM((double)rBitmap.GetPrefSize().Height() / aScale100000.Height()); + const double fBmpWidthM(static_cast<double>(rBitmap.GetPrefSize().Width()) / aScale100000.Width()); + const double fBmpHeightM(static_cast<double>(rBitmap.GetPrefSize().Height()) / aScale100000.Height()); if(!basegfx::fTools::equalZero(fBmpWidthM) && !basegfx::fTools::equalZero(fBmpHeightM)) { diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index f4e5a8c187fb..80af9ea8d937 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -54,7 +54,7 @@ using namespace com::sun::star; -#define GAMMA( _def_cVal, _def_InvGamma ) ((sal_uInt8)MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255)) +#define GAMMA( _def_cVal, _def_InvGamma ) (static_cast<sal_uInt8>(MinMax(FRound(pow( _def_cVal/255.0,_def_InvGamma)*255.0),0,255))) struct ImplColAdjustParam { @@ -696,8 +696,8 @@ void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY ) { aOffset = aMapVDev->LogicToPixel( aBaseOffset, GetPrefMapMode() ); MapMode aMap( aMapVDev->GetMapMode() ); - aOffset.Width() = static_cast<long>(aOffset.Width() * (double)aMap.GetScaleX()); - aOffset.Height() = static_cast<long>(aOffset.Height() * (double)aMap.GetScaleY()); + aOffset.Width() = static_cast<long>(aOffset.Width() * static_cast<double>(aMap.GetScaleX())); + aOffset.Height() = static_cast<long>(aOffset.Height() * static_cast<double>(aMap.GetScaleY())); } else aOffset = OutputDevice::LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev->GetMapMode() ); @@ -730,7 +730,7 @@ void GDIMetaFile::Scale( double fScaleX, double fScaleY ) void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY ) { - Scale( (double) rScaleX, (double) rScaleY ); + Scale( static_cast<double>(rScaleX), static_cast<double>(rScaleY) ); } void GDIMetaFile::Clip( const tools::Rectangle& i_rClipRect ) @@ -1150,7 +1150,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) MetaHatchAction* pAct = static_cast<MetaHatchAction*>(pAction); Hatch aHatch( pAct->GetHatch() ); - aHatch.SetAngle( aHatch.GetAngle() + (sal_uInt16) nAngle10 ); + aHatch.SetAngle( aHatch.GetAngle() + static_cast<sal_uInt16>(nAngle10) ); aMtf.AddAction( new MetaHatchAction( ImplGetRotatedPolyPolygon( pAct->GetPolyPolygon(), aRotAnchor, aRotOffset, fSin, fCos ), aHatch ) ); } @@ -1240,7 +1240,7 @@ void GDIMetaFile::Rotate( long nAngle10 ) MetaFontAction* pAct = static_cast<MetaFontAction*>(pAction); vcl::Font aFont( pAct->GetFont() ); - aFont.SetOrientation( aFont.GetOrientation() + (sal_uInt16) nAngle10 ); + aFont.SetOrientation( aFont.GetOrientation() + static_cast<sal_uInt16>(nAngle10) ); aMtf.AddAction( new MetaFontAction( aFont ) ); } break; @@ -2133,15 +2133,15 @@ void GDIMetaFile::Adjust( short nLuminancePercent, short nContrastPercent, { if(!msoBrightness) { - aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fROff ), 0, 255 ); - aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fGOff ), 0, 255 ); - aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( nX * fM + fBOff ), 0, 255 ); + aColParam.pMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fROff ), 0, 255 )); + aColParam.pMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fGOff ), 0, 255 )); + aColParam.pMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( nX * fM + fBOff ), 0, 255 )); } else { - aColParam.pMapR[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 ); - aColParam.pMapG[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 ); - aColParam.pMapB[ nX ] = (sal_uInt8) MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 ); + aColParam.pMapR[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fROff/2-128) * fM + 128 + fROff/2 ), 0, 255 )); + aColParam.pMapG[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fGOff/2-128) * fM + 128 + fGOff/2 ), 0, 255 )); + aColParam.pMapB[ nX ] = static_cast<sal_uInt8>(MinMax( FRound( (nX+fBOff/2-128) * fM + 128 + fBOff/2 ), 0, 255 )); } if( bGamma ) { @@ -2198,16 +2198,16 @@ void GDIMetaFile::ReplaceColors( const Color* pSearchColors, const Color* pRepla long nVal; nVal = pSearchColors[ i ].GetRed(); - aColParam.pMinR[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxR[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinR[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L )); + aColParam.pMaxR[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L )); nVal = pSearchColors[ i ].GetGreen(); - aColParam.pMinG[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxG[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinG[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L )); + aColParam.pMaxG[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L )); nVal = pSearchColors[ i ].GetBlue(); - aColParam.pMinB[ i ] = (sal_uLong) std::max( nVal, 0L ); - aColParam.pMaxB[ i ] = (sal_uLong) std::min( nVal, 255L ); + aColParam.pMinB[ i ] = static_cast<sal_uLong>(std::max( nVal, 0L )); + aColParam.pMaxB[ i ] = static_cast<sal_uLong>(std::min( nVal, 255L )); } aColParam.pDstCols = pReplaceColors; @@ -2556,7 +2556,7 @@ BitmapChecksum GDIMetaFile::GetChecksum() const } } - sal_uInt8 tmp = (sal_uInt8)rAct.IsClipping(); + sal_uInt8 tmp = static_cast<sal_uInt8>(rAct.IsClipping()); nCrc = vcl_get_checksum(nCrc, &tmp, 1); } else diff --git a/vcl/source/gdi/gradient.cxx b/vcl/source/gdi/gradient.cxx index 191c3852dc74..67b8a02d46b2 100644 --- a/vcl/source/gdi/gradient.cxx +++ b/vcl/source/gdi/gradient.cxx @@ -158,10 +158,10 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB fWidth * fabs( sin( fAngle ) ); fDX = (fDX - fWidth) * 0.5 + 0.5; fDY = (fDY - fHeight) * 0.5 + 0.5; - aRect.Left() -= (long) fDX; - aRect.Right() += (long) fDX; - aRect.Top() -= (long) fDY; - aRect.Bottom() += (long) fDY; + aRect.Left() -= static_cast<long>(fDX); + aRect.Right() += static_cast<long>(fDX); + aRect.Top() -= static_cast<long>(fDY); + aRect.Bottom() += static_cast<long>(fDY); rBoundRect = aRect; rCenter = rRect.Center(); @@ -179,10 +179,10 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB fDX = ( fDX - fWidth ) * 0.5 + 0.5; fDY = ( fDY - fHeight ) * 0.5 + 0.5; - aRect.Left() -= (long) fDX; - aRect.Right() += (long) fDX; - aRect.Top() -= (long) fDY; - aRect.Bottom() += (long) fDY; + aRect.Left() -= static_cast<long>(fDX); + aRect.Right() += static_cast<long>(fDX); + aRect.Top() -= static_cast<long>(fDY); + aRect.Bottom() += static_cast<long>(fDY); } Size aSize( aRect.GetSize() ); @@ -190,21 +190,21 @@ void Gradient::GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle& rB if( GetStyle() == GradientStyle::Radial ) { // Calculation of radii for circle - aSize.Width() = (long)(0.5 + sqrt((double)aSize.Width()*(double)aSize.Width() + (double)aSize.Height()*(double)aSize.Height())); + aSize.Width() = static_cast<long>(0.5 + sqrt(static_cast<double>(aSize.Width())*static_cast<double>(aSize.Width()) + static_cast<double>(aSize.Height())*static_cast<double>(aSize.Height()))); aSize.Height() = aSize.Width(); } else if( GetStyle() == GradientStyle::Elliptical ) { // Calculation of radii for ellipse - aSize.Width() = (long)( 0.5 + (double) aSize.Width() * 1.4142 ); - aSize.Height() = (long)( 0.5 + (double) aSize.Height() * 1.4142 ); + aSize.Width() = static_cast<long>( 0.5 + static_cast<double>(aSize.Width()) * 1.4142 ); + aSize.Height() = static_cast<long>( 0.5 + static_cast<double>(aSize.Height()) * 1.4142 ); } // Calculate new centers - long nZWidth = aRect.GetWidth() * (long) GetOfsX() / 100; - long nZHeight = aRect.GetHeight() * (long) GetOfsY() / 100; - long nBorderX = (long) GetBorder() * aSize.Width() / 100; - long nBorderY = (long) GetBorder() * aSize.Height() / 100; + long nZWidth = aRect.GetWidth() * static_cast<long>(GetOfsX()) / 100; + long nZHeight = aRect.GetHeight() * static_cast<long>(GetOfsY()) / 100; + long nBorderX = static_cast<long>(GetBorder()) * aSize.Width() / 100; + long nBorderY = static_cast<long>(GetBorder()) * aSize.Height() / 100; rCenter = Point( aRect.Left() + nZWidth, aRect.Top() + nZHeight ); // Respect borders diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 3477c43e7f33..6b1587a36194 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -41,7 +41,7 @@ void ImplDrawDefault( OutputDevice* pOutDev, const OUString* pText, vcl::Font* pFont, const BitmapEx* pBitmapEx, const Point& rDestPt, const Size& rDestSize ) { - sal_uInt16 nPixel = (sal_uInt16) pOutDev->PixelToLogic( Size( 1, 1 ) ).Width(); + sal_uInt16 nPixel = static_cast<sal_uInt16>(pOutDev->PixelToLogic( Size( 1, 1 ) ).Width()); sal_uInt16 nPixelWidth = nPixel; Point aPoint( rDestPt.X() + nPixelWidth, rDestPt.Y() + nPixelWidth ); Size aSize( rDestSize.Width() - ( nPixelWidth << 1 ), rDestSize.Height() - ( nPixelWidth << 1 ) ); @@ -408,8 +408,8 @@ basegfx::B2DSize Graphic::GetPPI() const const Size aGrfPrefMapModeSize(GetPrefSize()); if (aGrfMap.GetMapUnit() == MapUnit::MapInch) { - nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() ); - nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() ); + nGrfDPIx = aGrfPixelSize.Width() / ( static_cast<double>(aGrfMap.GetScaleX()) * aGrfPrefMapModeSize.Width() ); + nGrfDPIy = aGrfPixelSize.Height() / ( static_cast<double>(aGrfMap.GetScaleY()) * aGrfPrefMapModeSize.Height() ); } else { diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx index ba94f89277c3..99708ce57316 100644 --- a/vcl/source/gdi/impanmvw.cxx +++ b/vcl/source/gdi/impanmvw.cxx @@ -127,13 +127,13 @@ void ImplAnimView::getPosSize( const AnimationBitmap& rAnm, Point& rPosPix, Size // calculate x scaling if( rAnmSize.Width() > 1 ) - fFactX = (double) ( maSzPix.Width() - 1 ) / ( rAnmSize.Width() - 1 ); + fFactX = static_cast<double>( maSzPix.Width() - 1 ) / ( rAnmSize.Width() - 1 ); else fFactX = 1.0; // calculate y scaling if( rAnmSize.Height() > 1 ) - fFactY = (double) ( maSzPix.Height() - 1 ) / ( rAnmSize.Height() - 1 ); + fFactY = static_cast<double>( maSzPix.Height() - 1 ) / ( rAnmSize.Height() - 1 ); else fFactY = 1.0; @@ -171,7 +171,7 @@ void ImplAnimView::drawToPos( sal_uLong nPos ) std::unique_ptr<vcl::Region> xOldClip(!maClip.IsNull() ? new vcl::Region( pRenderContext->GetClipRegion() ) : nullptr); aVDev->SetOutputSizePixel( maSzPix, false ); - nPos = std::min( nPos, (sal_uLong) mpParent->Count() - 1 ); + nPos = std::min( nPos, static_cast<sal_uLong>(mpParent->Count()) - 1 ); for( sal_uLong i = 0; i <= nPos; i++ ) draw( i, aVDev.get() ); @@ -212,7 +212,7 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* pVDev ) Size aSizePix; Size aBmpSizePix; const sal_uLong nLastPos = mpParent->Count() - 1; - const AnimationBitmap& rAnm = mpParent->Get( (sal_uInt16) ( mnActPos = std::min( nPos, nLastPos ) ) ); + const AnimationBitmap& rAnm = mpParent->Get( static_cast<sal_uInt16>( mnActPos = std::min( nPos, nLastPos ) ) ); getPosSize( rAnm, aPosPix, aSizePix ); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index f14e830d2eef..09186dd054bb 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -464,7 +464,7 @@ Bitmap ImpGraphic::ImplGetBitmap(const GraphicConversionParameters& rParameters) && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT)) { // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT - double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height()); + double fWH(static_cast<double>(aDrawSize.Width()) / static_cast<double>(aDrawSize.Height())); if(fWH <= 1.0) { diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index d172aeae2418..841f1895a970 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -927,7 +927,7 @@ bool ImplGetChain( ImplVectMap* pMap, const Point& rStartPt, ImplChain& rChain if( pMap->IsCont( nTryY, nTryX ) ) { - rChain.ImplAdd( (sal_uInt8) nLastDir ); + rChain.ImplAdd( static_cast<sal_uInt8>(nLastDir) ); pMap->Set( nActY = nTryY, nActX = nTryX, VECT_DONE_INDEX ); nFound = 1; } @@ -944,7 +944,7 @@ bool ImplGetChain( ImplVectMap* pMap, const Point& rStartPt, ImplChain& rChain if( pMap->IsCont( nTryY, nTryX ) ) { - rChain.ImplAdd( (sal_uInt8) nDir ); + rChain.ImplAdd( static_cast<sal_uInt8>(nDir) ); pMap->Set( nActY = nTryY, nActX = nTryX, VECT_DONE_INDEX ); nFound = 1; nLastDir = nDir; diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 24167478f79c..fdb002394662 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -25,8 +25,8 @@ #include <memory> #include <rtl/instance.hxx> -#define JOBSET_FILE364_SYSTEM ((sal_uInt16)0xFFFF) -#define JOBSET_FILE605_SYSTEM ((sal_uInt16)0xFFFE) +#define JOBSET_FILE364_SYSTEM (sal_uInt16(0xFFFF)) +#define JOBSET_FILE605_SYSTEM (sal_uInt16(0xFFFE)) struct ImplOldJobSetupData { @@ -281,8 +281,8 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup ) rJobData.SetDuplexMode( DuplexMode::Unknown ); rJobData.SetPaperBin( SVBT16ToShort( pOldJobData->nPaperBin ) ); rJobData.SetPaperFormat( (Paper)SVBT16ToShort( pOldJobData->nPaperFormat ) ); - rJobData.SetPaperWidth( (long)SVBT32ToUInt32( pOldJobData->nPaperWidth ) ); - rJobData.SetPaperHeight( (long)SVBT32ToUInt32( pOldJobData->nPaperHeight ) ); + rJobData.SetPaperWidth( static_cast<long>(SVBT32ToUInt32( pOldJobData->nPaperWidth )) ); + rJobData.SetPaperHeight( static_cast<long>(SVBT32ToUInt32( pOldJobData->nPaperHeight )) ); if ( rJobData.GetDriverDataLen() ) { const char* pDriverData = reinterpret_cast<const char*>(pOldJobData) + nOldJobDataSize; @@ -348,9 +348,9 @@ SvStream& WriteJobSetup( SvStream& rOStream, const JobSetup& rJobSetup ) UInt32ToSVBT32( rJobData.GetDriverDataLen(), aOldJobData.nDriverDataLen ); ShortToSVBT16( (sal_uInt16)(rJobData.GetOrientation()), aOldJobData.nOrientation ); ShortToSVBT16( rJobData.GetPaperBin(), aOldJobData.nPaperBin ); - ShortToSVBT16( (sal_uInt16)(rJobData.GetPaperFormat()), aOldJobData.nPaperFormat ); - UInt32ToSVBT32( (sal_uLong)(rJobData.GetPaperWidth()), aOldJobData.nPaperWidth ); - UInt32ToSVBT32( (sal_uLong)(rJobData.GetPaperHeight()), aOldJobData.nPaperHeight ); + ShortToSVBT16( static_cast<sal_uInt16>(rJobData.GetPaperFormat()), aOldJobData.nPaperFormat ); + UInt32ToSVBT32( static_cast<sal_uLong>(rJobData.GetPaperWidth()), aOldJobData.nPaperWidth ); + UInt32ToSVBT32( static_cast<sal_uLong>(rJobData.GetPaperHeight()), aOldJobData.nPaperHeight ); ImplOldJobSetupData aOldData; memset( &aOldData, 0, sizeof( aOldData ) ); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 31b7d5fa5da9..ecd91f724d67 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1272,7 +1272,7 @@ void MetaStretchTextAction::Move( long nHorzMove, long nVertMove ) void MetaStretchTextAction::Scale( double fScaleX, double fScaleY ) { ImplScalePoint( maPt, fScaleX, fScaleY ); - mnWidth = (sal_uLong)FRound( mnWidth * fabs(fScaleX) ); + mnWidth = static_cast<sal_uLong>(FRound( mnWidth * fabs(fScaleX) )); } void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) @@ -3439,7 +3439,7 @@ void MetaTextLanguageAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { MetaAction::Write(rOStm, pData); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); - rOStm.WriteUInt16( (sal_uInt16)meTextLanguage ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(meTextLanguage) ); } void MetaTextLanguageAction::Read( SvStream& rIStm, ImplMetaReadData* ) diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx index 8e4977650e51..d4eb44eb33c0 100644 --- a/vcl/source/gdi/octree.cxx +++ b/vcl/source/gdi/octree.cxx @@ -204,9 +204,9 @@ void Octree::CreatePalette( NODE* pNode ) if( pNode->bLeaf ) { pNode->nPalIndex = nPalIndex; - aPal[ nPalIndex++ ] = BitmapColor( (sal_uInt8) ( (double) pNode->nRed / pNode->nCount ), - (sal_uInt8) ( (double) pNode->nGreen / pNode->nCount ), - (sal_uInt8) ( (double) pNode->nBlue / pNode->nCount ) ); + aPal[ nPalIndex++ ] = BitmapColor( static_cast<sal_uInt8>( static_cast<double>(pNode->nRed) / pNode->nCount ), + static_cast<sal_uInt8>( static_cast<double>(pNode->nGreen) / pNode->nCount ), + static_cast<sal_uInt8>( static_cast<double>(pNode->nBlue) / pNode->nCount ) ); } else for(OctreeNode* i : pNode->pChild) if( i ) @@ -246,7 +246,7 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) : for( int nIndex = 0; nIndex < nColors; nIndex++ ) { - const BitmapColor& rColor = rPal[ (sal_uInt16) nIndex ]; + const BitmapColor& rColor = rPal[ static_cast<sal_uInt16>(nIndex) ]; const long cRed = rColor.GetRed(); const long cGreen = rColor.GetGreen(); const long cBlue = rColor.GetBlue(); @@ -268,10 +268,10 @@ InverseColorMap::InverseColorMap( const BitmapPalette& rPal ) : for( g = 0, gdist = rdist, gxx = cginc; g < nColorMax; gdist += gxx, g++, gxx += xsqr2 ) { for( b = 0, bdist = gdist, bxx = cbinc; b < nColorMax; bdist += bxx, b++, cdp++, crgbp++, bxx += xsqr2 ) - if ( !nIndex || ( (long) *cdp ) > bdist ) + if ( !nIndex || static_cast<long>(*cdp) > bdist ) { *cdp = bdist; - *crgbp = (sal_uInt8) nIndex; + *crgbp = static_cast<sal_uInt8>(nIndex); } } } diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index 8974c6f5a645..4966aec601f2 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -113,7 +113,7 @@ sal_Int32 GlobalSyncData::GetMappedId() */ if( nLinkId >= 0 ) { - if ( (sal_uInt32)nLinkId < mParaIds.size() ) + if ( static_cast<sal_uInt32>(nLinkId) < mParaIds.size() ) nLinkId = mParaIds[ nLinkId ]; else nLinkId = -1; @@ -126,7 +126,7 @@ sal_Int32 GlobalSyncData::GetMappedId() sal_Int32 GlobalSyncData::GetMappedStructId( sal_Int32 nStructId ) { - if ( (sal_uInt32)nStructId < mStructIdMap.size() ) + if ( static_cast<sal_uInt32>(nStructId) < mStructIdMap.size() ) nStructId = mStructIdMap[ nStructId ]; else nStructId = -1; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 854c1107ad9a..89204dad077c 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -550,7 +550,7 @@ static void appendName( const OUString& rStr, OStringBuffer& rBuffer ) else { rBuffer.append( '#' ); - appendHex( (sal_Int8)aStr[i], rBuffer ); + appendHex( static_cast<sal_Int8>(aStr[i]), rBuffer ); } } } @@ -570,7 +570,7 @@ static void appendName( const sal_Char* pStr, OStringBuffer& rBuffer ) else { rBuffer.append( '#' ); - appendHex( (sal_Int8)*pStr, rBuffer ); + appendHex( static_cast<sal_Int8>(*pStr), rBuffer ); } pStr++; } @@ -602,10 +602,10 @@ static void appendLiteralString( const sal_Char* pStr, sal_Int32 nLength, OStrin case ')' : case '\\' : rBuffer.append( "\\" ); - rBuffer.append( (sal_Char) *pStr ); + rBuffer.append( static_cast<sal_Char>(*pStr) ); break; default: - rBuffer.append( (sal_Char) *pStr ); + rBuffer.append( static_cast<sal_Char>(*pStr) ); break; } pStr++; @@ -648,14 +648,14 @@ static void appendDestinationName( const OUString& rString, OStringBuffer& rBuff (aChar >= 'A' && aChar <= 'Z' ) || aChar == '-' ) { - rBuffer.append((sal_Char)aChar); + rBuffer.append(static_cast<sal_Char>(aChar)); } else { sal_Int8 aValueHigh = sal_Int8(aChar >> 8); if(aValueHigh > 0) appendHex( aValueHigh, rBuffer ); - appendHex( (sal_Int8)(aChar & 255 ), rBuffer ); + appendHex( static_cast<sal_Int8>(aChar & 255 ), rBuffer ); } } } @@ -668,8 +668,8 @@ void PDFWriter::AppendUnicodeTextString(const OUString& rString, OStringBuffer& for( int i = 0; i < nLen; i++ ) { sal_Unicode aChar = pStr[i]; - appendHex( (sal_Int8)(aChar >> 8), rBuffer ); - appendHex( (sal_Int8)(aChar & 255 ), rBuffer ); + appendHex( static_cast<sal_Int8>(aChar >> 8), rBuffer ); + appendHex( static_cast<sal_Int8>(aChar & 255 ), rBuffer ); } } @@ -695,7 +695,7 @@ void PDFWriterImpl::createWidgetFieldName( sal_Int32 i_nWidgetIndex, const PDFWr else { aBuffer.append( '#' ); - appendHex( (sal_Int8)aStr[i], aBuffer ); + appendHex( static_cast<sal_Int8>(aStr[i]), aBuffer ); } } @@ -858,8 +858,8 @@ static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrec fValue=-fValue; } - sal_Int64 nInt = (sal_Int64)fValue; - fValue -= (double)nInt; + sal_Int64 nInt = static_cast<sal_Int64>(fValue); + fValue -= static_cast<double>(nInt); // optimizing hardware may lead to a value of 1.0 after the subtraction if( rtl::math::approxEqual(fValue, 1.0) || log10( 1.0-fValue ) <= -nPrecision ) { @@ -869,8 +869,8 @@ static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrec sal_Int64 nFrac = 0; if( fValue ) { - fValue *= pow( 10.0, (double)nPrecision ); - nFrac = (sal_Int64)fValue; + fValue *= pow( 10.0, static_cast<double>(nPrecision) ); + nFrac = static_cast<sal_Int64>(fValue); } if( bNeg && ( nInt || nFrac ) ) rBuffer.append( '-' ); @@ -879,7 +879,7 @@ static void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrec { int i; rBuffer.append( '.' ); - sal_Int64 nBound = (sal_Int64)(pow( 10.0, nPrecision - 1.0 )+0.5); + sal_Int64 nBound = static_cast<sal_Int64>(pow( 10.0, nPrecision - 1.0 )+0.5); for ( i = 0; ( i < nPrecision ) && nFrac; i++ ) { sal_Int64 nNumb = nFrac / nBound; @@ -898,15 +898,15 @@ static void appendColor( const Color& rColor, OStringBuffer& rBuffer, bool bConv if( bConvertToGrey ) { sal_uInt8 cByte = rColor.GetLuminance(); - appendDouble( (double)cByte / 255.0, rBuffer ); + appendDouble( static_cast<double>(cByte) / 255.0, rBuffer ); } else { - appendDouble( (double)rColor.GetRed() / 255.0, rBuffer ); + appendDouble( static_cast<double>(rColor.GetRed()) / 255.0, rBuffer ); rBuffer.append( ' ' ); - appendDouble( (double)rColor.GetGreen() / 255.0, rBuffer ); + appendDouble( static_cast<double>(rColor.GetGreen()) / 255.0, rBuffer ); rBuffer.append( ' ' ); - appendDouble( (double)rColor.GetBlue() / 255.0, rBuffer ); + appendDouble( static_cast<double>(rColor.GetBlue()) / 255.0, rBuffer ); } } } @@ -973,8 +973,8 @@ Matrix3::Matrix3() Point Matrix3::transform( const Point& rOrig ) const { - double x = (double)rOrig.X(), y = (double)rOrig.Y(); - return Point( (int)(x*f[0] + y*f[2] + f[4]), (int)(x*f[1] + y*f[3] + f[5]) ); + double x = static_cast<double>(rOrig.X()), y = static_cast<double>(rOrig.Y()); + return Point( static_cast<int>(x*f[0] + y*f[2] + f[4]), static_cast<int>(x*f[1] + y*f[3] + f[5]) ); } void Matrix3::skew( double alpha, double beta ) @@ -1068,7 +1068,7 @@ void Matrix3::append( PDFWriterImpl::PDFPage const & rPage, OStringBuffer& rBuff rBuffer.append( ' ' ); appendDouble( f[3], rBuffer ); rBuffer.append( ' ' ); - rPage.appendPoint( Point( (long)f[4], (long)f[5] ), rBuffer ); + rPage.appendPoint( Point( static_cast<long>(f[4]), static_cast<long>(f[5]) ), rBuffer ); } static void appendResourceMap( OStringBuffer& rBuf, const char* pPrefix, const PDFWriterImpl::ResourceMap& rList ) @@ -1183,7 +1183,7 @@ void PDFWriterImpl::PDFPage::endStream() OStringBuffer aLine; aLine.append( m_nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-m_nBeginStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-m_nBeginStreamPos) ); aLine.append( "\nendobj\n\n" ); m_pWriter->writeBuffer( aLine.getStr(), aLine.getLength() ); } @@ -1249,14 +1249,14 @@ bool PDFWriterImpl::PDFPage::emit(sal_Int32 nParentObject ) if( m_nDuration > 0 ) { aLine.append( "/Dur " ); - aLine.append( (sal_Int32)m_nDuration ); + aLine.append( static_cast<sal_Int32>(m_nDuration) ); aLine.append( "\n" ); } if( m_eTransition != PDFWriter::PageTransition::Regular && m_nTransTime > 0 ) { // transition duration aLine.append( "/Trans<</D " ); - appendDouble( (double)m_nTransTime/1000.0, aLine, 3 ); + appendDouble( static_cast<double>(m_nTransTime)/1000.0, aLine, 3 ); aLine.append( "\n" ); const char *pStyle = nullptr, *pDm = nullptr, *pM = nullptr, *pDi = nullptr; switch( m_eTransition ) @@ -1387,9 +1387,9 @@ void PDFWriterImpl::PDFPage::appendRect( const tools::Rectangle& rRect, OStringB { appendPoint( rRect.BottomLeft() + Point( 0, 1 ), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rRect.GetWidth(), rBuffer, false ); + appendMappedLength( static_cast<sal_Int32>(rRect.GetWidth()), rBuffer, false ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rRect.GetHeight(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rRect.GetHeight()), rBuffer ); rBuffer.append( " re" ); } @@ -1569,7 +1569,7 @@ void PDFWriterImpl::PDFPage::appendMappedLength( double fLength, OStringBuffer& m_pWriter->m_aMapMode, m_pWriter->getReferenceDevice(), Size( 1000, 1000 ) ) ); - fLength *= pixelToPoint((double)(bVertical ? aSize.Height() : aSize.Width()) / 1000.0); + fLength *= pixelToPoint(static_cast<double>(bVertical ? aSize.Height() : aSize.Width()) / 1000.0); appendDouble( fLength, rBuffer, nPrecision ); } @@ -1602,25 +1602,25 @@ bool PDFWriterImpl::PDFPage::appendLineInfo( const LineInfo& rInfo, OStringBuffe rBuffer.append( "[ " ); if( rInfo.GetDashLen() == rInfo.GetDotLen() ) // degraded case { - appendMappedLength( (sal_Int32)rInfo.GetDashLen(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDashLen()), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rInfo.GetDistance(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDistance()), rBuffer ); rBuffer.append( ' ' ); } else { for( int n = 0; n < rInfo.GetDashCount(); n++ ) { - appendMappedLength( (sal_Int32)rInfo.GetDashLen(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDashLen()), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rInfo.GetDistance(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDistance()), rBuffer ); rBuffer.append( ' ' ); } for( int m = 0; m < rInfo.GetDotCount(); m++ ) { - appendMappedLength( (sal_Int32)rInfo.GetDotLen(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDotLen()), rBuffer ); rBuffer.append( ' ' ); - appendMappedLength( (sal_Int32)rInfo.GetDistance(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetDistance()), rBuffer ); rBuffer.append( ' ' ); } } @@ -1629,7 +1629,7 @@ bool PDFWriterImpl::PDFPage::appendLineInfo( const LineInfo& rInfo, OStringBuffe if( rInfo.GetWidth() > 1 ) { - appendMappedLength( (sal_Int32)rInfo.GetWidth(), rBuffer ); + appendMappedLength( static_cast<sal_Int32>(rInfo.GetWidth()), rBuffer ); rBuffer.append( " w\n" ); } else if( rInfo.GetWidth() == 0 ) @@ -1849,20 +1849,20 @@ OString PDFWriter::GetDateTime() osl_getLocalTimeFromSystemTime(&aGMT, &aTVal); osl_getDateTimeFromTimeValue(&aTVal, &aDT); aRet.append("D:"); - aRet.append((sal_Char)('0' + ((aDT.Year / 1000) % 10))); - aRet.append((sal_Char)('0' + ((aDT.Year / 100) % 10))); - aRet.append((sal_Char)('0' + ((aDT.Year / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Year % 10))); - aRet.append((sal_Char)('0' + ((aDT.Month / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Month % 10))); - aRet.append((sal_Char)('0' + ((aDT.Day / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Day % 10))); - aRet.append((sal_Char)('0' + ((aDT.Hours / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Hours % 10))); - aRet.append((sal_Char)('0' + ((aDT.Minutes / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Minutes % 10))); - aRet.append((sal_Char)('0' + ((aDT.Seconds / 10) % 10))); - aRet.append((sal_Char)('0' + (aDT.Seconds % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 1000) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 100) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Year / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Year % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Month / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Month % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Day / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Day % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Hours / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Hours % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Minutes / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Minutes % 10))); + aRet.append(static_cast<sal_Char>('0' + ((aDT.Seconds / 10) % 10))); + aRet.append(static_cast<sal_Char>('0' + (aDT.Seconds % 10))); sal_uInt32 nDelta = 0; if (aGMT.Seconds > aTVal.Seconds) @@ -1880,11 +1880,11 @@ OString PDFWriter::GetDateTime() if (nDelta) { - aRet.append((sal_Char)('0' + ((nDelta / 36000) % 10))); - aRet.append((sal_Char)('0' + ((nDelta / 3600) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 36000) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 3600) % 10))); aRet.append("'"); - aRet.append((sal_Char)('0' + ((nDelta / 600) % 6))); - aRet.append((sal_Char)('0' + ((nDelta / 60) % 10))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 600) % 6))); + aRet.append(static_cast<sal_Char>('0' + ((nDelta / 60) % 10))); } aRet.append( "'" ); @@ -1928,25 +1928,25 @@ void PDFWriterImpl::computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIden // to use the localtime notation only // according to a recommendation in XMP Specification (Jan 2004, page 75) // the Acrobat way seems the right approach - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year/1000)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year/100)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Year)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year/1000)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year/100)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Year)%10)) ); aCreationMetaDateString.append( "-" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Month/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Month)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Month/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Month)%10)) ); aCreationMetaDateString.append( "-" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Day/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Day)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Day/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Day)%10)) ); aCreationMetaDateString.append( "T" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Hours/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Hours)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Hours/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Hours)%10)) ); aCreationMetaDateString.append( ":" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Minutes/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Minutes)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Minutes/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Minutes)%10)) ); aCreationMetaDateString.append( ":" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Seconds/10)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((aDT.Seconds)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Seconds/10)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((aDT.Seconds)%10)) ); sal_uInt32 nDelta = 0; if( aGMT.Seconds > aTVal.Seconds ) @@ -1966,11 +1966,11 @@ void PDFWriterImpl::computeDocumentIdentifier( std::vector< sal_uInt8 >& o_rIden } if( nDelta ) { - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/36000)%10)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/3600)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/36000)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/3600)%10)) ); aCreationMetaDateString.append( ":" ); - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/600)%6)) ); - aCreationMetaDateString.append( (sal_Char)('0' + ((nDelta/60)%10)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/600)%6)) ); + aCreationMetaDateString.append( static_cast<sal_Char>('0' + ((nDelta/60)%10)) ); } aID.append( i_rCString1.getStr(), i_rCString1.getLength() ); @@ -2018,8 +2018,8 @@ inline void PDFWriterImpl::appendUnicodeTextStringEncrypt( const OUString& rInSt for( int i = 0; i < nLen; i++ ) { sal_Unicode aUnChar = pStr[i]; - *pCopy++ = (sal_uInt8)( aUnChar >> 8 ); - *pCopy++ = (sal_uInt8)( aUnChar & 255 ); + *pCopy++ = static_cast<sal_uInt8>( aUnChar >> 8 ); + *pCopy++ = static_cast<sal_uInt8>( aUnChar & 255 ); nChars += 2; } //encrypt in place @@ -2155,7 +2155,7 @@ bool PDFWriterImpl::writeBuffer( const void* pBuffer, sal_uInt64 nBytes ) sal_uInt64 nWritten; if( m_pCodec ) { - m_pCodec->Write( *m_pMemStream, static_cast<const sal_uInt8*>(pBuffer), (sal_uLong)nBytes ); + m_pCodec->Write( *m_pMemStream, static_cast<const sal_uInt8*>(pBuffer), static_cast<sal_uLong>(nBytes) ); nWritten = nBytes; } else @@ -2476,7 +2476,7 @@ OString PDFWriterImpl::emitStructureAttributes( PDFStructureElement& i_rEle ) m_aLinkPropertyMap.find( nLink ); if( link_it != m_aLinkPropertyMap.end() ) nLink = link_it->second; - if( nLink >= 0 && nLink < (sal_Int32)m_aLinks.size() ) + if( nLink >= 0 && nLink < static_cast<sal_Int32>(m_aLinks.size()) ) { // update struct parent of link OStringBuffer aStructParentEntry( 32 ); @@ -2778,10 +2778,10 @@ bool PDFWriterImpl::emitTilings() emitComment( "PDFWriterImpl::emitTilings" ); } - sal_Int32 nX = (sal_Int32)tiling.m_aRectangle.Left(); - sal_Int32 nY = (sal_Int32)tiling.m_aRectangle.Top(); - sal_Int32 nW = (sal_Int32)tiling.m_aRectangle.GetWidth(); - sal_Int32 nH = (sal_Int32)tiling.m_aRectangle.GetHeight(); + sal_Int32 nX = static_cast<sal_Int32>(tiling.m_aRectangle.Left()); + sal_Int32 nY = static_cast<sal_Int32>(tiling.m_aRectangle.Top()); + sal_Int32 nW = static_cast<sal_Int32>(tiling.m_aRectangle.GetWidth()); + sal_Int32 nH = static_cast<sal_Int32>(tiling.m_aRectangle.GetHeight()); if( tiling.m_aCellSize.Width() == 0 ) tiling.m_aCellSize.Width() = nW; if( tiling.m_aCellSize.Height() == 0 ) @@ -2840,7 +2840,7 @@ bool PDFWriterImpl::emitTilings() if( bDeflate ) aTilingObj.append( "/Filter/FlateDecode" ); aTilingObj.append( "/Length " ); - aTilingObj.append( (sal_Int32)nTilingStreamSize ); + aTilingObj.append( static_cast<sal_Int32>(nTilingStreamSize) ); aTilingObj.append( ">>\nstream\n" ); if ( !updateObject( tiling.m_nObject ) ) return false; if ( !writeBuffer( aTilingObj.getStr(), aTilingObj.getLength() ) ) return false; @@ -3008,7 +3008,7 @@ static void appendSubsetName( int nSubsetID, const OUString& rPSName, OStringBuf { int nOffset = (nSubsetID % 26); nSubsetID /= 26; - rBuffer.append( (sal_Char)('A'+nOffset) ); + rBuffer.append( static_cast<sal_Char>('A'+nOffset) ); } rBuffer.append( '+' ); } @@ -3057,18 +3057,18 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 const * pEncoding, { if( nCount ) aContents.append( "endbfchar\n" ); - aContents.append( (sal_Int32)((nMapped-nCount > 100) ? 100 : nMapped-nCount ) ); + aContents.append( static_cast<sal_Int32>((nMapped-nCount > 100) ? 100 : nMapped-nCount ) ); aContents.append( " beginbfchar\n" ); } aContents.append( '<' ); - appendHex( (sal_Int8)pEncoding[n], aContents ); + appendHex( static_cast<sal_Int8>(pEncoding[n]), aContents ); aContents.append( "> <" ); // TODO: handle code points>U+FFFF sal_Int32 nIndex = pEncToUnicodeIndex[n]; for( sal_Int32 j = 0; j < pCodeUnitsPerGlyph[n]; j++ ) { - appendHex( (sal_Int8)(pCodeUnits[nIndex + j] / 256), aContents ); - appendHex( (sal_Int8)(pCodeUnits[nIndex + j] & 255), aContents ); + appendHex( static_cast<sal_Int8>(pCodeUnits[nIndex + j] / 256), aContents ); + appendHex( static_cast<sal_Int8>(pCodeUnits[nIndex + j] & 255), aContents ); } aContents.append( ">\n" ); nCount++; @@ -3099,7 +3099,7 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 const * pEncoding, sal_Int32 nLen = 0; if (!g_bDebugDisableCompression) { - nLen = (sal_Int32)aStream.Tell(); + nLen = static_cast<sal_Int32>(aStream.Tell()); aStream.Seek( 0 ); aLine.append( nLen ); aLine.append( "/Filter/FlateDecode" ); @@ -3154,13 +3154,13 @@ sal_Int32 PDFWriterImpl::emitFontDescriptor( const PhysicalFontFace* pFont, Font aLine.append( "\n" "/FontBBox[" ); // note: Top and Bottom are reversed in VCL and PDF rectangles - aLine.append( (sal_Int32)rInfo.m_aFontBBox.TopLeft().X() ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.TopLeft().X()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)rInfo.m_aFontBBox.TopLeft().Y() ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.TopLeft().Y()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)rInfo.m_aFontBBox.BottomRight().X() ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.BottomRight().X()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)(rInfo.m_aFontBBox.BottomRight().Y()+1) ); + aLine.append( static_cast<sal_Int32>(rInfo.m_aFontBBox.BottomRight().Y()+1) ); aLine.append( "]/ItalicAngle " ); if( pFont->GetItalic() == ITALIC_OBLIQUE || pFont->GetItalic() == ITALIC_NORMAL ) aLine.append( "-30" ); @@ -3168,13 +3168,13 @@ sal_Int32 PDFWriterImpl::emitFontDescriptor( const PhysicalFontFace* pFont, Font aLine.append( "0" ); aLine.append( "\n" "/Ascent " ); - aLine.append( (sal_Int32)rInfo.m_nAscent ); + aLine.append( static_cast<sal_Int32>(rInfo.m_nAscent) ); aLine.append( "\n" "/Descent " ); - aLine.append( (sal_Int32)-rInfo.m_nDescent ); + aLine.append( static_cast<sal_Int32>(-rInfo.m_nDescent) ); aLine.append( "\n" "/CapHeight " ); - aLine.append( (sal_Int32)rInfo.m_nCapHeight ); + aLine.append( static_cast<sal_Int32>(rInfo.m_nCapHeight) ); // According to PDF reference 1.4 StemV is required // seems a tad strange to me, but well ... aLine.append( "\n" @@ -3306,7 +3306,7 @@ bool PDFWriterImpl::emitFonts() sal_uInt64 nStartPos = 0; if( aSubsetInfo.m_nFontType == FontType::SFNT_TTF ) { - aLine.append( (sal_Int32)nLength1 ); + aLine.append( static_cast<sal_Int32>(nLength1) ); aLine.append( ">>\n" "stream\n" ); @@ -3341,14 +3341,14 @@ bool PDFWriterImpl::emitFonts() if ( osl::File::E_None != aFontFile.setPos(osl_Pos_Absolut, 0) ) return false; // get the PFB-segment lengths ThreeInts aSegmentLengths = {0,0,0}; - getPfbSegmentLengths(xBuffer.get(), (int)nBytesRead, aSegmentLengths); + getPfbSegmentLengths(xBuffer.get(), static_cast<int>(nBytesRead), aSegmentLengths); // the lengths below are mandatory for PDF-exported Type1 fonts // because the PFB segment headers get stripped! WhyOhWhy. - aLine.append( (sal_Int32)aSegmentLengths[0] ); + aLine.append( static_cast<sal_Int32>(aSegmentLengths[0]) ); aLine.append( "/Length2 " ); - aLine.append( (sal_Int32)aSegmentLengths[1] ); + aLine.append( static_cast<sal_Int32>(aSegmentLengths[1]) ); aLine.append( "/Length3 " ); - aLine.append( (sal_Int32)aSegmentLengths[2] ); + aLine.append( static_cast<sal_Int32>(aSegmentLengths[2]) ); aLine.append( ">>\n" "stream\n" ); @@ -3385,7 +3385,7 @@ bool PDFWriterImpl::emitFonts() aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndPos-nStartPos) ); + aLine.append( static_cast<sal_Int64>(nEndPos-nStartPos) ); aLine.append( "\nendobj\n\n" ); if ( !writeBuffer( aLine.getStr(), aLine.getLength() ) ) return false; @@ -3408,7 +3408,7 @@ bool PDFWriterImpl::emitFonts() aLine.append( "\n" "/FirstChar 0\n" "/LastChar " ); - aLine.append( (sal_Int32)(nGlyphs-1) ); + aLine.append( static_cast<sal_Int32>(nGlyphs-1) ); aLine.append( "\n" "/Widths[" ); for( int i = 0; i < nGlyphs; i++ ) @@ -3625,7 +3625,7 @@ sal_Int32 PDFWriterImpl::emitOutline() appendUnicodeTextStringEncrypt( rItem.m_aTitle, rItem.m_nObject, aLine ); aLine.append( "\n" ); // Dest is not required - if( rItem.m_nDestID >= 0 && rItem.m_nDestID < (sal_Int32)m_aDests.size() ) + if( rItem.m_nDestID >= 0 && rItem.m_nDestID < static_cast<sal_Int32>(m_aDests.size()) ) { aLine.append( "/Dest" ); appendDest( rItem.m_nDestID, aLine ); @@ -3658,9 +3658,9 @@ sal_Int32 PDFWriterImpl::emitOutline() bool PDFWriterImpl::appendDest( sal_Int32 nDestID, OStringBuffer& rBuffer ) { - if( nDestID < 0 || nDestID >= (sal_Int32)m_aDests.size() ) + if( nDestID < 0 || nDestID >= static_cast<sal_Int32>(m_aDests.size()) ) { - SAL_INFO("vcl.pdfwriter", "ERROR: invalid dest " << (int)nDestID << " requested"); + SAL_INFO("vcl.pdfwriter", "ERROR: invalid dest " << static_cast<int>(nDestID) << " requested"); return false; } @@ -5039,7 +5039,7 @@ bool PDFWriterImpl::emitCatalog() } aLine.append( "]\n" "/Count " ); - aLine.append( (sal_Int32)m_aPages.size() ); + aLine.append( static_cast<sal_Int32>(m_aPages.size()) ); aLine.append( ">>\n" "endobj\n\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -5099,7 +5099,7 @@ bool PDFWriterImpl::emitCatalog() aLine.append( "/PageMode/FullScreen\n" ); //document is opened full screen OStringBuffer aInitPageRef; - if( m_aContext.InitialPage >= 0 && m_aContext.InitialPage < (sal_Int32)m_aPages.size() ) + if( m_aContext.InitialPage >= 0 && m_aContext.InitialPage < static_cast<sal_Int32>(m_aPages.size()) ) { aInitPageRef.append( m_aPages[m_aContext.InitialPage].m_nPageObject ); aInitPageRef.append( " 0 R" ); @@ -5142,7 +5142,7 @@ bool PDFWriterImpl::emitCatalog() aLine.append( aInitPageRef.makeStringAndClear() ); aLine.append( " /XYZ null null " ); if( m_aContext.Zoom >= 50 && m_aContext.Zoom <= 1600 ) - aLine.append( (double)m_aContext.Zoom/100.0 ); + aLine.append( static_cast<double>(m_aContext.Zoom)/100.0 ); else aLine.append( "0" ); aLine.append( "]\n" ); @@ -5391,7 +5391,7 @@ bool PDFWriterImpl::finalizeSignature() //FIXME: Check if hash is calculated from the correct byterange if (osl::File::E_None != m_aFile.read(buffer1.get(), m_nSignatureContentOffset - 1 , bytesRead1) || - bytesRead1 != (sal_uInt64)m_nSignatureContentOffset - 1) + bytesRead1 != static_cast<sal_uInt64>(m_nSignatureContentOffset) - 1) { SAL_WARN("vcl.pdfwriter", "First buffer read failed"); return false; @@ -5402,7 +5402,7 @@ bool PDFWriterImpl::finalizeSignature() if (osl::File::E_None != m_aFile.setPos(osl_Pos_Absolut, m_nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1) || osl::File::E_None != m_aFile.read(buffer2.get(), nLastByteRangeNo, bytesRead2) || - bytesRead2 != (sal_uInt64) nLastByteRangeNo) + bytesRead2 != static_cast<sal_uInt64>(nLastByteRangeNo)) { SAL_WARN("vcl.pdfwriter", "Second buffer read failed"); return false; @@ -5604,7 +5604,7 @@ sal_Int32 PDFWriterImpl::emitOutputIntent() std::vector<unsigned char> aBuffer(nBytesNeeded); cmsSaveProfileToMem(hProfile, &aBuffer[0], &nBytesNeeded); cmsCloseProfile(hProfile); - bool written = writeBuffer( &aBuffer[0], (sal_Int32) aBuffer.size() ); + bool written = writeBuffer( &aBuffer[0], static_cast<sal_Int32>(aBuffer.size()) ); disableStreamEncryption(); endCompression(); sal_uInt64 nEndStreamPos = 0; @@ -5621,7 +5621,7 @@ sal_Int32 PDFWriterImpl::emitOutputIntent() aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-nBeginStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-nBeginStreamPos) ); aLine.append( "\nendobj\n\n" ); if ( !writeBuffer( aLine.getStr(), aLine.getLength() ) ) return 0; aLine.setLength( 0 ); @@ -5875,7 +5875,7 @@ bool PDFWriterImpl::emitTrailer() sal_Int32 nObjects = m_aObjects.size(); OStringBuffer aLine; aLine.append( "0 " ); - aLine.append( (sal_Int32)(nObjects+1) ); + aLine.append( static_cast<sal_Int32>(nObjects+1) ); aLine.append( "\n" ); aLine.append( "0000000000 65535 f \n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -5906,7 +5906,7 @@ bool PDFWriterImpl::emitTrailer() aLine.setLength( 0 ); aLine.append( "trailer\n" "<</Size " ); - aLine.append( (sal_Int32)(nObjects+1) ); + aLine.append( static_cast<sal_Int32>(nObjects+1) ); aLine.append( "/Root " ); aLine.append( m_nCatalogObject ); aLine.append( " 0 R\n" ); @@ -5958,7 +5958,7 @@ bool PDFWriterImpl::emitTrailer() } aLine.append( ">>\n" "startxref\n" ); - aLine.append( (sal_Int64)nXRefOffset ); + aLine.append( static_cast<sal_Int64>(nXRefOffset) ); aLine.append( "\n" "%%EOF\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -6062,9 +6062,9 @@ void PDFWriterImpl::sortWidgets() { SAL_WARN( "vcl.pdfwriter", "wrong number of sorted annotations" ); SAL_INFO("vcl.pdfwriter", "PDFWriterImpl::sortWidgets(): wrong number of sorted assertions " - "on page nr " << (long int)item.first << ", " << - (long int)item.second.aSortedAnnots.size() << " sorted and " << - (long int)nAnnots << " unsorted"); + "on page nr " << static_cast<long int>(item.first) << ", " << + static_cast<long int>(item.second.aSortedAnnots.size()) << " sorted and " << + static_cast<long int>(nAnnots) << " unsorted"); } } @@ -6163,7 +6163,7 @@ bool PDFWriterImpl::emitAdditionalStreams() aLine.setLength( 0 ); aLine.append( nSizeObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-nBeginStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-nBeginStreamPos) ); aLine.append( "\nendobj\n\n" ); if( ! writeBuffer( aLine.getStr(), aLine.getLength() ) ) return false; @@ -6421,19 +6421,19 @@ void PDFWriterImpl::drawVerticalGlyphs( { fDeltaAngle = M_PI/2.0; aDeltaPos.X() = m_pReferenceDevice->GetFontMetric().GetAscent(); - aDeltaPos.Y() = (int)((double)m_pReferenceDevice->GetFontMetric().GetDescent() * fXScale); + aDeltaPos.Y() = static_cast<int>(static_cast<double>(m_pReferenceDevice->GetFontMetric().GetDescent()) * fXScale); fYScale = fXScale; fTempXScale = 1.0; fSkewA = -fSkewB; fSkewB = 0.0; } - aDeltaPos += (m_pReferenceDevice->PixelToLogic( Point( (int)((double)nXOffset/fXScale), 0 ) ) - m_pReferenceDevice->PixelToLogic( Point() ) ); + aDeltaPos += (m_pReferenceDevice->PixelToLogic( Point( static_cast<int>(static_cast<double>(nXOffset)/fXScale), 0 ) ) - m_pReferenceDevice->PixelToLogic( Point() ) ); if( i < rGlyphs.size()-1 ) // #i120627# the text on the Y axis is reversed when export ppt file to PDF format { long nOffsetX = rGlyphs[i+1].m_aPos.X() - rGlyphs[i].m_aPos.X(); long nOffsetY = rGlyphs[i+1].m_aPos.Y() - rGlyphs[i].m_aPos.Y(); - nXOffset += (int)sqrt(double(nOffsetX*nOffsetX + nOffsetY*nOffsetY)); + nXOffset += static_cast<int>(sqrt(double(nOffsetX*nOffsetX + nOffsetY*nOffsetY))); } if( ! rGlyphs[i].m_nGlyphId ) continue; @@ -6544,7 +6544,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( const Point aPrevPos = aMat.transform( rGlyphs[nPos-1].m_aPos ); double fAdvance = aThisPos.X() - aPrevPos.X(); fAdvance *= 1000.0 / nPixelFontHeight; - const sal_Int32 nAdjustment = (sal_Int32)(rGlyphs[nPos-1].m_nNativeWidth - fAdvance + 0.5); + const sal_Int32 nAdjustment = static_cast<sal_Int32>(rGlyphs[nPos-1].m_nNativeWidth - fAdvance + 0.5); if( nAdjustment != 0 ) { // apply individual glyph positioning @@ -6609,8 +6609,8 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool if( aMetric.GetAverageFontWidth() != m_aCurrentPDFState.m_aFont.GetAverageFontWidth() ) { fXScale = - (double)m_aCurrentPDFState.m_aFont.GetAverageFontWidth() / - (double)aMetric.GetAverageFontWidth(); + static_cast<double>(m_aCurrentPDFState.m_aFont.GetAverageFontWidth()) / + static_cast<double>(aMetric.GetAverageFontWidth()); } // force state before GetFontMetric m_pReferenceDevice->ImplNewFont(); @@ -6637,7 +6637,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool while( nAngle < 0 ) nAngle += 3600; nAngle = nAngle % 3600; - double fAngle = (double)nAngle * M_PI / 1800.0; + double fAngle = static_cast<double>(nAngle) * M_PI / 1800.0; Matrix3 aRotScale; aRotScale.scale( fXScale, 1.0 ); @@ -6702,7 +6702,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } else { - double fW = (double)m_aCurrentPDFState.m_aFont.GetFontHeight() / 30.0; + double fW = static_cast<double>(m_aCurrentPDFState.m_aFont.GetFontHeight()) / 30.0; m_aPages.back().appendMappedLength( fW, aLine ); aLine.append ( " w\n" ); } @@ -7285,7 +7285,7 @@ void PDFWriterImpl::drawWaveTextLine( OStringBuffer& aLine, long nWidth, FontLin if ( eTextLine == LINESTYLE_BOLDWAVE ) nLineWidth = 3*nLineWidth; - m_aPages.back().appendMappedLength( (sal_Int32)nLineWidth, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineWidth), aLine ); aLine.append( " w " ); if ( eTextLine == LINESTYLE_DOUBLEWAVE ) @@ -7402,7 +7402,7 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon if ( !nLineHeight ) return; - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine ); aLine.append( " w " ); appendStrokingColor( aColor, aLine ); aLine.append( "\n" ); @@ -7412,7 +7412,7 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon case LINESTYLE_DOTTED: case LINESTYLE_BOLDDOTTED: aLine.append( "[ " ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( " ] 0 d\n" ); break; case LINESTYLE_DASH: @@ -7442,7 +7442,7 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( " ] 0 d\n" ); @@ -7458,11 +7458,11 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine, false ); aLine.append( ' ' ); m_aPages.back().appendMappedLength( nVoidLength, aLine, false ); aLine.append( " ] 0 d\n" ); @@ -7473,20 +7473,20 @@ void PDFWriterImpl::drawStraightTextLine( OStringBuffer& aLine, long nWidth, Fon } aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " l S\n" ); if ( eTextLine == LINESTYLE_DOUBLE ) { aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " l S\n" ); } @@ -7531,27 +7531,27 @@ void PDFWriterImpl::drawStrikeoutLine( OStringBuffer& aLine, long nWidth, FontSt if ( !nLineHeight ) return; - m_aPages.back().appendMappedLength( (sal_Int32)nLineHeight, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nLineHeight), aLine ); aLine.append( " w " ); appendStrokingColor( aColor, aLine ); aLine.append( "\n" ); aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos), aLine ); aLine.append( " l S\n" ); if ( eStrikeout == STRIKEOUT_DOUBLE ) { aLine.append( "0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " m " ); - m_aPages.back().appendMappedLength( (sal_Int32)nWidth, aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(nWidth), aLine ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)(-nLinePos2-nLineHeight), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(-nLinePos2-nLineHeight), aLine ); aLine.append( " l S\n" ); } @@ -7653,7 +7653,7 @@ void PDFWriterImpl::drawTextLine( const Point& rPos, long nWidth, FontStrikeout aLine.append( "q " ); // rotate and translate matrix - double fAngle = (double)m_aCurrentPDFState.m_aFont.GetOrientation() * M_PI / 1800.0; + double fAngle = static_cast<double>(m_aCurrentPDFState.m_aFont.GetOrientation()) * M_PI / 1800.0; Matrix3 aMat; aMat.rotate( fAngle ); aMat.translate( aPos.X(), aPos.Y() ); @@ -7780,7 +7780,7 @@ void PDFWriterImpl::drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uI m_aPages.back().convertRect( m_aTransparentObjects.back().m_aBoundRect ); m_aTransparentObjects.back().m_nObject = createObject(); m_aTransparentObjects.back().m_nExtGStateObject = createObject(); - m_aTransparentObjects.back().m_fAlpha = (double)(100-nTransparentPercent) / 100.0; + m_aTransparentObjects.back().m_fAlpha = static_cast<double>(100-nTransparentPercent) / 100.0; m_aTransparentObjects.back().m_pContentStream = new SvMemoryStream( 256, 256 ); // create XObject's content stream OStringBuffer aContent( 256 ); @@ -7923,7 +7923,7 @@ void PDFWriterImpl::endTransparencyGroup( const tools::Rectangle& rBoundingBox, // convert rectangle to default user space m_aPages.back().convertRect( m_aTransparentObjects.back().m_aBoundRect ); m_aTransparentObjects.back().m_nObject = createObject(); - m_aTransparentObjects.back().m_fAlpha = (double)(100-nTransparentPercent) / 100.0; + m_aTransparentObjects.back().m_fAlpha = static_cast<double>(100-nTransparentPercent) / 100.0; // get XObject's content stream m_aTransparentObjects.back().m_pContentStream = static_cast<SvMemoryStream*>(endRedirect()); m_aTransparentObjects.back().m_nExtGStateObject = createObject(); @@ -7987,15 +7987,15 @@ void PDFWriterImpl::drawRectangle( const tools::Rectangle& rRect, sal_uInt32 nHo m_aGraphicsStack.front().m_aFillColor == Color( COL_TRANSPARENT ) ) return; - if( nHorzRound > (sal_uInt32)rRect.GetWidth()/2 ) + if( nHorzRound > static_cast<sal_uInt32>(rRect.GetWidth())/2 ) nHorzRound = rRect.GetWidth()/2; - if( nVertRound > (sal_uInt32)rRect.GetHeight()/2 ) + if( nVertRound > static_cast<sal_uInt32>(rRect.GetHeight())/2 ) nVertRound = rRect.GetHeight()/2; Point aPoints[16]; const double kappa = 0.5522847498; - const sal_uInt32 kx = (sal_uInt32)((kappa*(double)nHorzRound)+0.5); - const sal_uInt32 ky = (sal_uInt32)((kappa*(double)nVertRound)+0.5); + const sal_uInt32 kx = static_cast<sal_uInt32>((kappa*static_cast<double>(nHorzRound))+0.5); + const sal_uInt32 ky = static_cast<sal_uInt32>((kappa*static_cast<double>(nVertRound))+0.5); aPoints[1] = Point( rRect.TopLeft().X() + nHorzRound, rRect.TopLeft().Y() ); aPoints[0] = Point( aPoints[1].X() - kx, aPoints[1].Y() ); @@ -8076,8 +8076,8 @@ void PDFWriterImpl::drawEllipse( const tools::Rectangle& rRect ) Point aPoints[12]; const double kappa = 0.5522847498; - const sal_uInt32 kx = (sal_uInt32)((kappa*(double)rRect.GetWidth()/2.0)+0.5); - const sal_uInt32 ky = (sal_uInt32)((kappa*(double)rRect.GetHeight()/2.0)+0.5); + const sal_uInt32 kx = static_cast<sal_uInt32>((kappa*static_cast<double>(rRect.GetWidth())/2.0)+0.5); + const sal_uInt32 ky = static_cast<sal_uInt32>((kappa*static_cast<double>(rRect.GetHeight())/2.0)+0.5); aPoints[1] = Point( rRect.TopLeft().X() + rRect.GetWidth()/2, rRect.TopLeft().Y() ); aPoints[0] = Point( aPoints[1].X() - kx, aPoints[1].Y() ); @@ -8140,16 +8140,16 @@ static double calcAngle( const tools::Rectangle& rRect, const Point& rPoint ) (rRect.Top()+rRect.Bottom()+1)/2); Point aPoint = rPoint - aOrigin; - double fX = (double)aPoint.X(); - double fY = (double)-aPoint.Y(); + double fX = static_cast<double>(aPoint.X()); + double fY = static_cast<double>(-aPoint.Y()); if ((rRect.GetHeight() == 0) || (rRect.GetWidth() == 0)) throw o3tl::divide_by_zero(); if( rRect.GetWidth() > rRect.GetHeight() ) - fY = fY*((double)rRect.GetWidth()/(double)rRect.GetHeight()); + fY = fY*(static_cast<double>(rRect.GetWidth())/static_cast<double>(rRect.GetHeight())); else if( rRect.GetHeight() > rRect.GetWidth() ) - fX = fX*((double)rRect.GetHeight()/(double)rRect.GetWidth()); + fX = fX*(static_cast<double>(rRect.GetHeight())/static_cast<double>(rRect.GetWidth())); return atan2( fY, fX ); } @@ -8168,18 +8168,18 @@ void PDFWriterImpl::drawArc( const tools::Rectangle& rRect, const Point& rStart, double fStopAngle = calcAngle( rRect, rStop ); while( fStopAngle < fStartAngle ) fStopAngle += 2.0*M_PI; - const int nFragments = (int)((fStopAngle-fStartAngle)/(M_PI/2.0))+1; - const double fFragmentDelta = (fStopAngle-fStartAngle)/(double)nFragments; + const int nFragments = static_cast<int>((fStopAngle-fStartAngle)/(M_PI/2.0))+1; + const double fFragmentDelta = (fStopAngle-fStartAngle)/static_cast<double>(nFragments); const double kappa = fabs( 4.0 * (1.0-cos(fFragmentDelta/2.0))/sin(fFragmentDelta/2.0) / 3.0); - const double halfWidth = (double)rRect.GetWidth()/2.0; - const double halfHeight = (double)rRect.GetHeight()/2.0; + const double halfWidth = static_cast<double>(rRect.GetWidth())/2.0; + const double halfHeight = static_cast<double>(rRect.GetHeight())/2.0; const Point aCenter( (rRect.Left()+rRect.Right()+1)/2, (rRect.Top()+rRect.Bottom()+1)/2 ); OStringBuffer aLine( 30*nFragments ); - Point aPoint( (int)(halfWidth * cos(fStartAngle) ), - -(int)(halfHeight * sin(fStartAngle) ) ); + Point aPoint( static_cast<int>(halfWidth * cos(fStartAngle) ), + -static_cast<int>(halfHeight * sin(fStartAngle) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( " m " ); @@ -8187,22 +8187,22 @@ void PDFWriterImpl::drawArc( const tools::Rectangle& rRect, const Point& rStart, { for( int i = 0; i < nFragments; i++ ) { - const double fStartFragment = fStartAngle + (double)i*fFragmentDelta; + const double fStartFragment = fStartAngle + static_cast<double>(i)*fFragmentDelta; const double fStopFragment = fStartFragment + fFragmentDelta; - aPoint = Point( (int)(halfWidth * (cos(fStartFragment) - kappa*sin(fStartFragment) ) ), - -(int)(halfHeight * (sin(fStartFragment) + kappa*cos(fStartFragment) ) ) ); + aPoint = Point( static_cast<int>(halfWidth * (cos(fStartFragment) - kappa*sin(fStartFragment) ) ), + -static_cast<int>(halfHeight * (sin(fStartFragment) + kappa*cos(fStartFragment) ) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( ' ' ); - aPoint = Point( (int)(halfWidth * (cos(fStopFragment) + kappa*sin(fStopFragment) ) ), - -(int)(halfHeight * (sin(fStopFragment) - kappa*cos(fStopFragment) ) ) ); + aPoint = Point( static_cast<int>(halfWidth * (cos(fStopFragment) + kappa*sin(fStopFragment) ) ), + -static_cast<int>(halfHeight * (sin(fStopFragment) - kappa*cos(fStopFragment) ) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( ' ' ); - aPoint = Point( (int)(halfWidth * cos(fStopFragment) ), - -(int)(halfHeight * sin(fStopFragment) ) ); + aPoint = Point( static_cast<int>(halfWidth * cos(fStopFragment) ), + -static_cast<int>(halfHeight * sin(fStopFragment) ) ); aPoint += aCenter; m_aPages.back().appendPoint( aPoint, aLine ); aLine.append( " c\n" ); @@ -8471,7 +8471,7 @@ void PDFWriterImpl::drawPolyLine( const tools::Polygon& rPoly, const PDFWriter:: aBoundRect.Right() += nLW; aBoundRect.Bottom() += nLW; } - endTransparencyGroup( aBoundRect, (sal_uInt16)(100.0*rInfo.m_fTransparency) ); + endTransparencyGroup( aBoundRect, static_cast<sal_uInt16>(100.0*rInfo.m_fTransparency) ); } } @@ -8546,7 +8546,7 @@ void PDFWriterImpl::writeTransparentObject( TransparencyEmit& rObject ) */ aLine.append( "/Length " ); - aLine.append( (sal_Int32)nSize ); + aLine.append( static_cast<sal_Int32>(nSize) ); aLine.append( "\n" ); if( bFlateFilter ) aLine.append( "/Filter/FlateDecode\n" ); @@ -8594,7 +8594,7 @@ void PDFWriterImpl::writeTransparentObject( TransparencyEmit& rObject ) else { rObject.m_pSoftMaskStream->Seek( STREAM_SEEK_TO_END ); - sal_Int32 nMaskSize = (sal_Int32)rObject.m_pSoftMaskStream->Tell(); + sal_Int32 nMaskSize = static_cast<sal_Int32>(rObject.m_pSoftMaskStream->Tell()); rObject.m_pSoftMaskStream->Seek( STREAM_SEEK_TO_BEGIN ); sal_Int32 nMaskObject = createObject(); aLine.append( "/SMask<</Type/Mask/S/Luminosity/G " ); @@ -8692,9 +8692,9 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aLine.append('3'); break; default: - aLine.append( (sal_Int32)aSize.Width() ); + aLine.append( static_cast<sal_Int32>(aSize.Width()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aSize.Height() ); + aLine.append( static_cast<sal_Int32>(aSize.Height()) ); } aLine.append( " ]\n" "/BitsPerSample 8\n" @@ -8768,7 +8768,7 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndStreamPos-nStartStreamPos) ); + aLine.append( static_cast<sal_Int64>(nEndStreamPos-nStartStreamPos) ); aLine.append( "\nendobj\n\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -8825,13 +8825,13 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) aPoly[1] = aBoundRect.TopCenter(); aPoly.Rotate( aCenter, 3600 - nAngle ); - aLine.append( (sal_Int32) aPoly[0].X() ); + aLine.append( static_cast<sal_Int32>(aPoly[0].X()) ); aLine.append( " " ); - aLine.append( (sal_Int32) aPoly[0].Y() ); + aLine.append( static_cast<sal_Int32>(aPoly[0].Y()) ); aLine.append( " " ); - aLine.append( (sal_Int32) aPoly[1].X()); + aLine.append( static_cast<sal_Int32>(aPoly[1].X())); aLine.append( " "); - aLine.append( (sal_Int32) aPoly[1].Y()); + aLine.append( static_cast<sal_Int32>(aPoly[1].Y())); aLine.append( " ]\n"); aLine.append("/Extend [true true]\n"); break; @@ -8839,9 +8839,9 @@ bool PDFWriterImpl::writeGradientFunction( GradientEmit const & rObject ) default: aLine.append("/Domain[ 0 1 0 1 ]\n" "/Matrix[ " ); - aLine.append( (sal_Int32)aSize.Width() ); + aLine.append( static_cast<sal_Int32>(aSize.Width()) ); aLine.append( " 0 0 " ); - aLine.append( (sal_Int32)aSize.Height() ); + aLine.append( static_cast<sal_Int32>(aSize.Height()) ); aLine.append( " 0 0 ]\n"); } aLine.append("/Function " ); @@ -8894,9 +8894,9 @@ void PDFWriterImpl::writeJPG( JPGEmit& rObject ) aLine.append( rObject.m_nObject ); aLine.append( " 0 obj\n" "<</Type/XObject/Subtype/Image/Width " ); - aLine.append( (sal_Int32)rObject.m_aID.m_aPixelSize.Width() ); + aLine.append( static_cast<sal_Int32>(rObject.m_aID.m_aPixelSize.Width()) ); aLine.append( " /Height " ); - aLine.append( (sal_Int32)rObject.m_aID.m_aPixelSize.Height() ); + aLine.append( static_cast<sal_Int32>(rObject.m_aID.m_aPixelSize.Height()) ); aLine.append( " /BitsPerComponent 8 " ); if( rObject.m_bTrueColor ) aLine.append( "/ColorSpace/DeviceRGB" ); @@ -9481,9 +9481,9 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.append( rObject.m_nObject ); aLine.append( " 0 obj\n" "<</Type/XObject/Subtype/Image/Width " ); - aLine.append( (sal_Int32)aBitmap.GetSizePixel().Width() ); + aLine.append( static_cast<sal_Int32>(aBitmap.GetSizePixel().Width()) ); aLine.append( "/Height " ); - aLine.append( (sal_Int32)aBitmap.GetSizePixel().Height() ); + aLine.append( static_cast<sal_Int32>(aBitmap.GetSizePixel().Height()) ); aLine.append( "/BitsPerComponent " ); aLine.append( nBitsPerComponent ); aLine.append( "/Length " ); @@ -9498,7 +9498,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) else { aLine.append( "/Filter/CCITTFaxDecode/DecodeParms<</K -1/BlackIs1 true/Columns " ); - aLine.append( (sal_Int32)aBitmap.GetSizePixel().Width() ); + aLine.append( static_cast<sal_Int32>(aBitmap.GetSizePixel().Width()) ); aLine.append( ">>\n" ); } } @@ -9541,7 +9541,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) else { aLine.append( "[ /Indexed/DeviceRGB " ); - aLine.append( (sal_Int32)(pAccess->GetPaletteEntryCount()-1) ); + aLine.append( static_cast<sal_Int32>(pAccess->GetPaletteEntryCount()-1) ); aLine.append( "\n<" ); if( m_aContext.Encryption.Encrypt() ) { @@ -9619,17 +9619,17 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.append( "/Mask[ " ); if( bTrueColor ) { - aLine.append( (sal_Int32)aTransparentColor.GetRed() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetRed()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetRed() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetRed()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetGreen() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetGreen()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetGreen() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetGreen()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetBlue() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetBlue()) ); aLine.append( ' ' ); - aLine.append( (sal_Int32)aTransparentColor.GetBlue() ); + aLine.append( static_cast<sal_Int32>(aTransparentColor.GetBlue()) ); } else { @@ -9695,7 +9695,7 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask ) aLine.setLength( 0 ); aLine.append( nStreamLengthObject ); aLine.append( " 0 obj\n" ); - aLine.append( (sal_Int64)(nEndPos-nStartPos) ); + aLine.append( static_cast<sal_Int64>(nEndPos-nStartPos) ); aLine.append( "\nendobj\n\n" ); CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) ); @@ -9802,10 +9802,10 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const aLine.append( "q " ); sal_Int32 nCheckWidth = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetWidth(), aLine, false, &nCheckWidth ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rTargetArea.GetWidth()), aLine, false, &nCheckWidth ); aLine.append( " 0 0 " ); sal_Int32 nCheckHeight = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetHeight(), aLine, true, &nCheckHeight ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rTargetArea.GetHeight()), aLine, true, &nCheckHeight ); aLine.append( ' ' ); m_aPages.back().appendPoint( rTargetArea.BottomLeft(), aLine ); aLine.append( " cm\n/Im" ); @@ -9841,10 +9841,10 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize, aLine.append( ' ' ); } sal_Int32 nCheckWidth = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Width(), aLine, false, &nCheckWidth ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rDestSize.Width()), aLine, false, &nCheckWidth ); aLine.append( " 0 0 " ); sal_Int32 nCheckHeight = 0; - m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Height(), aLine, true, &nCheckHeight ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rDestSize.Height()), aLine, true, &nCheckHeight ); aLine.append( ' ' ); m_aPages.back().appendPoint( rDestPoint + Point( 0, rDestSize.Height()-1 ), aLine ); aLine.append( " cm\n/Im" ); @@ -9989,9 +9989,9 @@ void PDFWriterImpl::drawGradient( const tools::Rectangle& rRect, const Gradient& if( m_aGraphicsStack.front().m_aLineColor != Color( COL_TRANSPARENT ) ) aLine.append( "q " ); aLine.append( "0 0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetWidth(), aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetWidth()), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetHeight(), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetHeight()), aLine ); aLine.append( " re W n\n" ); aLine.append( "/P" ); @@ -10000,9 +10000,9 @@ void PDFWriterImpl::drawGradient( const tools::Rectangle& rRect, const Gradient& if( m_aGraphicsStack.front().m_aLineColor != Color( COL_TRANSPARENT ) ) { aLine.append( "Q 0 0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetWidth(), aLine, false ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetWidth()), aLine, false ); aLine.append( ' ' ); - m_aPages.back().appendMappedLength( (sal_Int32)rRect.GetHeight(), aLine ); + m_aPages.back().appendMappedLength( static_cast<sal_Int32>(rRect.GetHeight()), aLine ); aLine.append( " re S " ); } aLine.append( "Q\n" ); @@ -10435,7 +10435,7 @@ void PDFWriterImpl::createNote( const tools::Rectangle& rRect, const PDFNote& rN if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return; m_aNotes.emplace_back( ); @@ -10454,7 +10454,7 @@ sal_Int32 PDFWriterImpl::createLink( const tools::Rectangle& rRect, sal_Int32 nP if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; sal_Int32 nRet = m_aLinks.size(); @@ -10500,7 +10500,7 @@ sal_Int32 PDFWriterImpl::createNamedDest( const OUString& sDestName, const tools if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; sal_Int32 nRet = m_aNamedDests.size(); @@ -10521,7 +10521,7 @@ sal_Int32 PDFWriterImpl::createDest( const tools::Rectangle& rRect, sal_Int32 nP if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; sal_Int32 nRet = m_aDests.size(); @@ -10543,9 +10543,9 @@ sal_Int32 PDFWriterImpl::registerDestReference( sal_Int32 nDestId, const tools:: void PDFWriterImpl::setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ) { - if( nLinkId < 0 || nLinkId >= (sal_Int32)m_aLinks.size() ) + if( nLinkId < 0 || nLinkId >= static_cast<sal_Int32>(m_aLinks.size()) ) return; - if( nDestId < 0 || nDestId >= (sal_Int32)m_aDests.size() ) + if( nDestId < 0 || nDestId >= static_cast<sal_Int32>(m_aDests.size()) ) return; m_aLinks[ nLinkId ].m_nDest = nDestId; @@ -10553,7 +10553,7 @@ void PDFWriterImpl::setLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ) void PDFWriterImpl::setLinkURL( sal_Int32 nLinkId, const OUString& rURL ) { - if( nLinkId < 0 || nLinkId >= (sal_Int32)m_aLinks.size() ) + if( nLinkId < 0 || nLinkId >= static_cast<sal_Int32>(m_aLinks.size()) ) return; m_aLinks[ nLinkId ].m_nDest = -1; @@ -10612,10 +10612,10 @@ sal_Int32 PDFWriterImpl::createOutlineItem( sal_Int32 nParent, const OUString& r void PDFWriterImpl::setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent ) { - if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) + if( nItem < 1 || nItem >= static_cast<sal_Int32>(m_aOutline.size()) ) return; - if( nNewParent < 0 || nNewParent >= (sal_Int32)m_aOutline.size() || nNewParent == nItem ) + if( nNewParent < 0 || nNewParent >= static_cast<sal_Int32>(m_aOutline.size()) || nNewParent == nItem ) { nNewParent = 0; } @@ -10625,7 +10625,7 @@ void PDFWriterImpl::setOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent void PDFWriterImpl::setOutlineItemText( sal_Int32 nItem, const OUString& rText ) { - if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) + if( nItem < 1 || nItem >= static_cast<sal_Int32>(m_aOutline.size()) ) return; m_aOutline[ nItem ].m_aTitle = psp::WhitespaceToSpace( rText ); @@ -10633,9 +10633,9 @@ void PDFWriterImpl::setOutlineItemText( sal_Int32 nItem, const OUString& rText ) void PDFWriterImpl::setOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID ) { - if( nItem < 1 || nItem >= (sal_Int32)m_aOutline.size() ) // item does not exist + if( nItem < 1 || nItem >= static_cast<sal_Int32>(m_aOutline.size()) ) // item does not exist return; - if( nDestID < 0 || nDestID >= (sal_Int32)m_aDests.size() ) // dest does not exist + if( nDestID < 0 || nDestID >= static_cast<sal_Int32>(m_aDests.size()) ) // dest does not exist return; m_aOutline[nItem].m_nDestID = nDestID; } @@ -11345,7 +11345,7 @@ bool PDFWriterImpl::setStructureAttributeNumerical( enum PDFWriter::StructAttrib else if( m_nCurrentStructElement > 0 && m_bEmitStructure ) SAL_INFO("vcl.pdfwriter", "rejecting setStructureAttributeNumerical( " << getAttributeTag( eAttr ) - << ", " << (int)nValue + << ", " << static_cast<int>(nValue) << " ) on " << getStructureTag( m_aStructure[ m_nCurrentStructElement ].m_eType ) << " (" << m_aStructure[ m_nCurrentStructElement ].m_aAlias.getStr() << ") element"); @@ -11356,7 +11356,7 @@ bool PDFWriterImpl::setStructureAttributeNumerical( enum PDFWriter::StructAttrib void PDFWriterImpl::setStructureBoundingBox( const tools::Rectangle& rRect ) { sal_Int32 nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() || !m_aContext.Tagged ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) || !m_aContext.Tagged ) return; if( m_nCurrentStructElement > 0 && m_bEmitStructure ) @@ -11395,7 +11395,7 @@ void PDFWriterImpl::setAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr ) if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return; m_aPages[ nPageNr ].m_nDuration = nSeconds; @@ -11406,7 +11406,7 @@ void PDFWriterImpl::setPageTransition( PDFWriter::PageTransition eType, sal_uInt if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return; m_aPages[ nPageNr ].m_eTransition = eType; @@ -11510,7 +11510,7 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa if( nPageNr < 0 ) nPageNr = m_nCurrentPage; - if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() ) + if( nPageNr < 0 || nPageNr >= static_cast<sal_Int32>(m_aPages.size()) ) return -1; bool sigHidden(true); @@ -11577,7 +11577,7 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa rNewWidget.m_eType = PDFWriter::CheckBox; rNewWidget.m_nRadioGroup = rBtn.RadioGroup; - SAL_WARN_IF( nRadioGroupWidget < 0 || nRadioGroupWidget >= (sal_Int32)m_aWidgets.size(), "vcl.pdfwriter", "no radio group parent" ); + SAL_WARN_IF( nRadioGroupWidget < 0 || nRadioGroupWidget >= static_cast<sal_Int32>(m_aWidgets.size()), "vcl.pdfwriter", "no radio group parent" ); PDFWidget& rRadioButton = m_aWidgets[nRadioGroupWidget]; rRadioButton.m_aKids.push_back( rNewWidget.m_nObject ); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index c9d38e465cd8..b2890823fad3 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -1084,7 +1084,7 @@ public: Size getCurPageSize() const { Size aSize; - if( m_nCurrentPage >= 0 && m_nCurrentPage < (sal_Int32)m_aPages.size() ) + if( m_nCurrentPage >= 0 && m_nCurrentPage < static_cast<sal_Int32>(m_aPages.size()) ) aSize = Size( m_aPages[ m_nCurrentPage ].m_nPageWidth, m_aPages[ m_nCurrentPage ].m_nPageHeight ); return aSize; } diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 9f9cbc712ef3..a97fa4b22108 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -438,8 +438,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa if ( nMaxBmpDPI > i_rContext.m_nMaxImageResolution ) nMaxBmpDPI = i_rContext.m_nMaxImageResolution; } - const sal_Int32 nPixelX = (sal_Int32)((double)aDstSizeTwip.Width() * (double)nMaxBmpDPI / 1440.0); - const sal_Int32 nPixelY = (sal_Int32)((double)aDstSizeTwip.Height() * (double)nMaxBmpDPI / 1440.0); + const sal_Int32 nPixelX = static_cast<sal_Int32>(static_cast<double>(aDstSizeTwip.Width()) * static_cast<double>(nMaxBmpDPI) / 1440.0); + const sal_Int32 nPixelY = static_cast<sal_Int32>(static_cast<double>(aDstSizeTwip.Height()) * static_cast<double>(nMaxBmpDPI) / 1440.0); if ( nPixelX && nPixelY ) { Size aDstSizePixel( nPixelX, nPixelY ); @@ -458,8 +458,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa Point aMtfOrigin( aTmpMtf.GetPrefMapMode().GetOrigin() ); if ( aMtfOrigin.X() || aMtfOrigin.Y() ) aTmpMtf.Move( -aMtfOrigin.X(), -aMtfOrigin.Y() ); - double fScaleX = (double)aDstSize.Width() / (double)aTmpMtf.GetPrefSize().Width(); - double fScaleY = (double)aDstSize.Height() / (double)aTmpMtf.GetPrefSize().Height(); + double fScaleX = static_cast<double>(aDstSize.Width()) / static_cast<double>(aTmpMtf.GetPrefSize().Width()); + double fScaleY = static_cast<double>(aDstSize.Height()) / static_cast<double>(aTmpMtf.GetPrefSize().Height()); if( fScaleX != 1.0 || fScaleY != 1.0 ) aTmpMtf.Scale( fScaleX, fScaleY ); aTmpMtf.SetPrefMapMode( aMapMode ); @@ -1175,9 +1175,9 @@ void PDFWriterImpl::checkAndEnableStreamEncryption( sal_Int32 nObject ) { m_bEncryptThisStream = true; sal_Int32 i = m_nKeyLength; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)nObject; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 8 ); - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 16 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); // the other location of m_nEncryptionKey is already set to 0, our fixed generation number // do the MD5 hash sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ]; @@ -1194,9 +1194,9 @@ void PDFWriterImpl::enableStringEncryption( sal_Int32 nObject ) if( m_aContext.Encryption.Encrypt() ) { sal_Int32 i = m_nKeyLength; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)nObject; - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 8 ); - m_aContext.Encryption.EncryptionKey[i++] = (sal_uInt8)( nObject >> 16 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>(nObject); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 8 ); + m_aContext.Encryption.EncryptionKey[i++] = static_cast<sal_uInt8>( nObject >> 16 ); // the other location of m_nEncryptionKey is already set to 0, our fixed generation number // do the MD5 hash sal_uInt8 nMD5Sum[ RTL_DIGEST_LENGTH_MD5 ]; @@ -1312,7 +1312,7 @@ void PDFWriterImpl::padPassword( const OUString& i_rPassword, sal_uInt8* o_pPadd sal_Int32 nCurrentChar; for( nCurrentChar = 0; nCurrentChar < nToCopy; nCurrentChar++ ) - o_pPaddedPW[nCurrentChar] = (sal_uInt8)( aString[nCurrentChar] ); + o_pPaddedPW[nCurrentChar] = static_cast<sal_uInt8>( aString[nCurrentChar] ); //pad it with standard byte string sal_Int32 i,y; @@ -1348,10 +1348,10 @@ bool PDFWriterImpl::computeEncryptionKey( EncHashTransporter* i_pTransporter, vc //Step 4 sal_uInt8 nPerm[4]; - nPerm[0] = (sal_uInt8)i_nAccessPermissions; - nPerm[1] = (sal_uInt8)( i_nAccessPermissions >> 8 ); - nPerm[2] = (sal_uInt8)( i_nAccessPermissions >> 16 ); - nPerm[3] = (sal_uInt8)( i_nAccessPermissions >> 24 ); + nPerm[0] = static_cast<sal_uInt8>(i_nAccessPermissions); + nPerm[1] = static_cast<sal_uInt8>( i_nAccessPermissions >> 8 ); + nPerm[2] = static_cast<sal_uInt8>( i_nAccessPermissions >> 16 ); + nPerm[3] = static_cast<sal_uInt8>( i_nAccessPermissions >> 24 ); if( nError == rtl_Digest_E_None ) nError = rtl_digest_updateMD5( aDigest, nPerm , sizeof( nPerm ) ); @@ -1458,7 +1458,7 @@ bool PDFWriterImpl::computeODictionaryValue( const sal_uInt8* i_pPaddedOwnerPass for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1 { for( y = 0; y < sizeof( nLocalKey ); y++ ) - nLocalKey[y] = (sal_uInt8)( nMD5Sum[y] ^ i ); + nLocalKey[y] = static_cast<sal_uInt8>( nMD5Sum[y] ^ i ); rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, nLocalKey, SECUR_128BIT_KEY, nullptr, 0 ); //destination data area, on init can be NULL @@ -1533,7 +1533,7 @@ bool PDFWriterImpl::computeUDictionaryValue( EncHashTransporter* i_pTransporter, for( i = 1; i <= 19; i++ ) // do it 19 times, start with 1 { for( y = 0; y < sizeof( nLocalKey ) ; y++ ) - nLocalKey[y] = (sal_uInt8)( io_rProperties.EncryptionKey[y] ^ i ); + nLocalKey[y] = static_cast<sal_uInt8>( io_rProperties.EncryptionKey[y] ^ i ); rtl_cipher_initARCFOUR( aCipher, rtl_Cipher_DirectionEncode, nLocalKey, SECUR_128BIT_KEY, // key and key length diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index 2458d0269e76..9037466f1b8c 100644 --- a/vcl/source/gdi/pngread.cxx +++ b/vcl/source/gdi/pngread.cxx @@ -406,8 +406,8 @@ BitmapEx PNGReaderImpl::GetBitmapEx( const Size& rPreviewSizeHint ) mbpHYs = true; // convert into MapUnit::Map100thMM - maPhysSize.Width() = (sal_Int32)( (100000.0 * maOrigSize.Width()) / nXPixelPerMeter ); - maPhysSize.Height() = (sal_Int32)( (100000.0 * maOrigSize.Height()) / nYPixelPerMeter ); + maPhysSize.Width() = static_cast<sal_Int32>( (100000.0 * maOrigSize.Width()) / nXPixelPerMeter ); + maPhysSize.Height() = static_cast<sal_Int32>( (100000.0 * maOrigSize.Height()) / nYPixelPerMeter ); } } } @@ -610,7 +610,7 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint ) if (nMinSizeRequired > mnStreamSize) { SAL_WARN("vcl.gdi", "overlarge png dimensions: " << - maOrigSize.Width() << " x " << maOrigSize.Height() << " depth: " << (int)mnPngDepth << + maOrigSize.Width() << " x " << maOrigSize.Height() << " depth: " << static_cast<int>(mnPngDepth) << " couldn't be supplied by file length " << mnStreamSize << " at least " << nMinSizeRequired << " needed "); return false; } @@ -709,7 +709,7 @@ void PNGReaderImpl::ImplGetGrayPalette( sal_uInt16 nBitDepth ) mxAcc->SetPaletteEntryCount( nPaletteEntryCount ); for ( sal_uInt32 i = 0, nStart = 0; nStart < 256; i++, nStart += nAdd ) - mxAcc->SetPaletteColor( (sal_uInt16)i, BitmapColor( mpColorTable[ nStart ], + mxAcc->SetPaletteColor( static_cast<sal_uInt16>(i), BitmapColor( mpColorTable[ nStart ], mpColorTable[ nStart ], mpColorTable[ nStart ] ) ); } @@ -823,7 +823,7 @@ void PNGReaderImpl::ImplGetGamma() return; sal_uInt32 nGammaValue = ImplReadsal_uInt32(); - double fGamma = ( ( VIEWING_GAMMA / DISPLAY_GAMMA ) * ( (double)nGammaValue / 100000 ) ); + double fGamma = ( ( VIEWING_GAMMA / DISPLAY_GAMMA ) * ( static_cast<double>(nGammaValue) / 100000 ) ); double fInvGamma = ( fGamma <= 0.0 || fGamma > 10.0 ) ? 1.0 : ( 1.0 / fGamma ); if ( fInvGamma != 1.0 ) @@ -832,7 +832,7 @@ void PNGReaderImpl::ImplGetGamma() mpColorTable = new sal_uInt8[ 256 ]; for ( sal_Int32 i = 0; i < 256; i++ ) - mpColorTable[ i ] = (sal_uInt8)(pow((double)i/255.0, fInvGamma) * 255.0 + 0.5); + mpColorTable[ i ] = static_cast<sal_uInt8>(pow(static_cast<double>(i)/255.0, fInvGamma) * 255.0 + 0.5); if ( mbGrayScale ) ImplGetGrayPalette( mnPngDepth ); @@ -850,7 +850,7 @@ void PNGReaderImpl::ImplGetBackground() sal_uInt16 nCol = *maDataIter++; if ( nCol < mxAcc->GetPaletteEntryCount() ) { - mxAcc->Erase( mxAcc->GetPaletteColor( (sal_uInt8)nCol ) ); + mxAcc->Erase( mxAcc->GetPaletteColor( static_cast<sal_uInt8>(nCol) ) ); break; } } @@ -892,12 +892,12 @@ sal_uInt8 PNGReaderImpl::ImplScaleColor() sal_uInt32 nMask = ( ( 1 << mnPngDepth ) - 1 ); sal_uInt16 nCol = ( *maDataIter++ << 8 ); - nCol += *maDataIter++ & (sal_uInt16)nMask; + nCol += *maDataIter++ & static_cast<sal_uInt16>(nMask); if ( mnPngDepth > 8 ) // convert 16bit graphics to 8 nCol >>= 8; - return (sal_uInt8) nCol; + return static_cast<sal_uInt8>(nCol); } // ImplReadIDAT reads as much image data as needed @@ -940,7 +940,7 @@ void PNGReaderImpl::ImplReadIDAT() mnYpos += mnYAdd; } - if ( mnYpos >= (sal_uInt32)maOrigSize.Height() ) + if ( mnYpos >= static_cast<sal_uInt32>(maOrigSize.Height()) ) { if( (mnPass < 7) && mnInterlaceType ) if( ImplPreparePass() ) diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index d5d472be2eeb..eee377547688 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -152,13 +152,13 @@ bool PrinterOptions::ReadFromConfig( bool i_bFile ) if( xSet->getPropertyValue("ReducedGradientMode") >>= nValue ) SetReducedGradientMode( (PrinterGradientMode)nValue ); if( xSet->getPropertyValue("ReducedGradientStepCount") >>= nValue ) - SetReducedGradientStepCount( (sal_uInt16)nValue ); + SetReducedGradientStepCount( static_cast<sal_uInt16>(nValue) ); if( xSet->getPropertyValue("ReduceBitmaps") >>= bValue ) SetReduceBitmaps( bValue ); if( xSet->getPropertyValue("ReducedBitmapMode") >>= nValue ) SetReducedBitmapMode( (PrinterBitmapMode)nValue ); if( xSet->getPropertyValue("ReducedBitmapResolution") >>= nValue ) - SetReducedBitmapResolution( (sal_uInt16)nValue ); + SetReducedBitmapResolution( static_cast<sal_uInt16>(nValue) ); if( xSet->getPropertyValue("ReducedBitmapIncludesTransparency") >>= bValue ) SetReducedBitmapIncludesTransparency( bValue ); if( xSet->getPropertyValue("ConvertToGreyscales") >>= bValue ) @@ -792,10 +792,10 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, // create forward mapping tables for( nX = 0; nX <= nSrcWidth; nX++ ) - pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth ); + pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth ); for( nY = 0; nY <= nSrcHeight; nY++ ) - pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight ); + pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight ); // walk through all rectangles of mask const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel()))); @@ -1535,7 +1535,7 @@ OUString Printer::GetPaperName( Paper ePaper ) (*pSVData->mpPaperNames)[PaperIndex[i]] = VclResId(RID_STR_PAPERNAMES[i]); } - std::unordered_map<int,OUString>::const_iterator it = pSVData->mpPaperNames->find( (int)ePaper ); + std::unordered_map<int,OUString>::const_iterator it = pSVData->mpPaperNames->find( static_cast<int>(ePaper) ); return (it != pSVData->mpPaperNames->end()) ? it->second : OUString(); } diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index e81af9ded1fb..57f0d4e0e4f3 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -1122,8 +1122,8 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, tools::Rectangle aBoundRect( currentItem.aBounds ); aBoundRect.Intersection( aOutputRect ); - const double fBmpArea( (double) aBoundRect.GetWidth() * aBoundRect.GetHeight() ); - const double fOutArea( (double) aOutputRect.GetWidth() * aOutputRect.GetHeight() ); + const double fBmpArea( static_cast<double>(aBoundRect.GetWidth()) * aBoundRect.GetHeight() ); + const double fOutArea( static_cast<double>(aOutputRect.GetWidth()) * aOutputRect.GetHeight() ); // check if output doesn't exceed given size if( bReduceTransparency && bTransparencyAutoMode && ( fBmpArea > ( 0.25 * fOutArea ) ) ) @@ -1350,13 +1350,13 @@ void Printer::DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, { const Color& rStartColor = rGradient.GetStartColor(); const Color& rEndColor = rGradient.GetEndColor(); - const long nR = ( ( (long) rStartColor.GetRed() * rGradient.GetStartIntensity() ) / 100 + - ( (long) rEndColor.GetRed() * rGradient.GetEndIntensity() ) / 100 ) >> 1; - const long nG = ( ( (long) rStartColor.GetGreen() * rGradient.GetStartIntensity() ) / 100 + - ( (long) rEndColor.GetGreen() * rGradient.GetEndIntensity() ) / 100 ) >> 1; - const long nB = ( ( (long) rStartColor.GetBlue() * rGradient.GetStartIntensity() ) / 100 + - ( (long) rEndColor.GetBlue() * rGradient.GetEndIntensity() ) / 100 ) >> 1; - const Color aColor( (sal_uInt8) nR, (sal_uInt8) nG, (sal_uInt8) nB ); + const long nR = ( ( static_cast<long>(rStartColor.GetRed()) * rGradient.GetStartIntensity() ) / 100 + + ( static_cast<long>(rEndColor.GetRed()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; + const long nG = ( ( static_cast<long>(rStartColor.GetGreen()) * rGradient.GetStartIntensity() ) / 100 + + ( static_cast<long>(rEndColor.GetGreen()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; + const long nB = ( ( static_cast<long>(rStartColor.GetBlue()) * rGradient.GetStartIntensity() ) / 100 + + ( static_cast<long>(rEndColor.GetBlue()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; + const Color aColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); pOut->SetLineColor( aColor ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index b8957ae14eb3..07b65564d6c2 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -92,11 +92,11 @@ std::ostream &operator <<(std::ostream& s, ImplLayoutArgs const &rArgs) if (rArgs.mrStr[i] == '\n') s << "\\n"; else if (rArgs.mrStr[i] < ' ' || (rArgs.mrStr[i] >= 0x7F && rArgs.mrStr[i] <= 0xFF)) - s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << (int) rArgs.mrStr[i] << std::setfill(' ') << std::setw(1) << std::dec; + s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(rArgs.mrStr[i]) << std::setfill(' ') << std::setw(1) << std::dec; else if (rArgs.mrStr[i] < 0x7F) - s << (char) rArgs.mrStr[i]; + s << static_cast<char>(rArgs.mrStr[i]); else - s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) rArgs.mrStr[i] << std::setfill(' ') << std::setw(1) << std::dec; + s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(rArgs.mrStr[i]) << std::setfill(' ') << std::setw(1) << std::dec; } if (nLength > lim) s << "..."; @@ -277,7 +277,7 @@ void ImplLayoutRuns::AddRun( int nCharPos0, int nCharPos1, bool bRTL ) bool ImplLayoutRuns::PosIsInRun( int nCharPos ) const { - if( mnRunIndex >= (int)maRuns.size() ) + if( mnRunIndex >= static_cast<int>(maRuns.size()) ) return false; int nMinCharPos = maRuns[ mnRunIndex+0 ]; @@ -324,7 +324,7 @@ bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft ) mnRunIndex = 0; // return false when all runs completed - if( mnRunIndex >= (int)maRuns.size() ) + if( mnRunIndex >= static_cast<int>(maRuns.size()) ) return false; int nRunPos0 = maRuns[ mnRunIndex+0 ]; @@ -345,7 +345,7 @@ bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft ) // advance to next run if current run is completed if( *nCharPos == nRunPos1 ) { - if( (mnRunIndex += 2) >= (int)maRuns.size() ) + if( (mnRunIndex += 2) >= static_cast<int>(maRuns.size()) ) return false; nRunPos0 = maRuns[ mnRunIndex+0 ]; nRunPos1 = maRuns[ mnRunIndex+1 ]; @@ -363,7 +363,7 @@ bool ImplLayoutRuns::GetNextPos( int* nCharPos, bool* bRightToLeft ) bool ImplLayoutRuns::GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRightToLeft ) const { - if( mnRunIndex >= (int)maRuns.size() ) + if( mnRunIndex >= static_cast<int>(maRuns.size()) ) return false; int nRunPos0 = maRuns[ mnRunIndex+0 ]; @@ -794,13 +794,13 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) else // condensed case { // squeeze width by moving glyphs proportionally - double fSqueeze = (double)nNewWidth / nOldWidth; + double fSqueeze = static_cast<double>(nNewWidth) / nOldWidth; if(m_GlyphItems.size() > 1) { for( pGlyphIter = m_GlyphItems.begin(); ++pGlyphIter != pGlyphIterRight;) { int nX = pGlyphIter->maLinearPos.X() - maBasePoint.X(); - nX = (int)(nX * fSqueeze); + nX = static_cast<int>(nX * fSqueeze); pGlyphIter->maLinearPos.X() = nX + maBasePoint.X(); } } @@ -918,7 +918,7 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, } // return zero if no more glyph found - if( nStart >= (int)m_GlyphItems.size() ) + if( nStart >= static_cast<int>(m_GlyphItems.size()) ) return 0; if( pGlyphIter == pGlyphIterEnd ) @@ -937,7 +937,7 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, *(pGlyphs++) = &(*pGlyphIter); // break at end of glyph list - if( ++nStart >= (int)m_GlyphItems.size() ) + if( ++nStart >= static_cast<int>(m_GlyphItems.size()) ) break; // break when enough glyphs if( nCount >= nLen ) @@ -970,7 +970,7 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) { - if( nStart >= (int)m_GlyphItems.size() ) + if( nStart >= static_cast<int>(m_GlyphItems.size()) ) return; std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(); @@ -995,7 +995,7 @@ void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) void GenericSalLayout::DropGlyph( int nStart ) { - if( nStart >= (int)m_GlyphItems.size()) + if( nStart >= static_cast<int>(m_GlyphItems.size())) return; std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(); @@ -1441,7 +1441,7 @@ sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordi if( pCharWidths[ i ] == 0 ) { DeviceCoordinate w = pCharWidths[ i + nCharCount ]; - w = (DeviceCoordinate)(w * fUnitMul + 0.5); + w = static_cast<DeviceCoordinate>(w * fUnitMul + 0.5); pCharWidths[ i ] = w; } } @@ -1482,7 +1482,7 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co // merge results from current level double fUnitMul = mnUnitsPerPixel; fUnitMul /= mpLayouts[n]->GetUnitsPerPixel(); - nTextWidth = (DeviceCoordinate)(nTextWidth * fUnitMul + 0.5); + nTextWidth = static_cast<DeviceCoordinate>(nTextWidth * fUnitMul + 0.5); if( nMaxWidth < nTextWidth ) nMaxWidth = nTextWidth; if( !pCharWidths ) @@ -1497,7 +1497,7 @@ DeviceCoordinate MultiSalLayout::FillDXArray( DeviceCoordinate* pCharWidths ) co DeviceCoordinate nCharWidth = pTempWidths[i]; if( !nCharWidth ) continue; - nCharWidth = (DeviceCoordinate)(nCharWidth * fUnitMul + 0.5); + nCharWidth = static_cast<DeviceCoordinate>(nCharWidth * fUnitMul + 0.5); pCharWidths[i] = nCharWidth; } } diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index 174eda36c3a4..6b2b8755e2b7 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -50,9 +50,9 @@ static long ImplIndexFromColor( const BitmapColor& rCol ) { #if TC_TO_PAL_COLORS == 4096 - return( ( ( (long) rCol.GetBlue() >> 4) << 8 ) | - ( ( (long) rCol.GetGreen() >> 4 ) << 4 ) | - ( (long) rCol.GetRed() >> 4 ) ); + return( ( ( static_cast<long>(rCol.GetBlue()) >> 4) << 8 ) | + ( ( static_cast<long>(rCol.GetGreen()) >> 4 ) << 4 ) | + ( static_cast<long>(rCol.GetRed()) >> 4 ) ); #elif TC_TO_PAL_COLORS == 32768 @@ -239,7 +239,7 @@ static void ImplTCToPAL( const BitmapBuffer& rSrcBuffer, BitmapBuffer const & rD BitmapColor aCol( sal::static_int_cast<sal_uInt8>(nR << 4), sal::static_int_cast<sal_uInt8>(nG << 4), sal::static_int_cast<sal_uInt8>(nB << 4) ); - pColToPalMap[ ImplIndexFromColor( aCol ) ] = (sal_uInt8) rDstBuffer.maPalette.GetBestIndex( aCol ); + pColToPalMap[ ImplIndexFromColor( aCol ) ] = static_cast<sal_uInt8>(rDstBuffer.maPalette.GetBestIndex( aCol )); } } } @@ -416,7 +416,7 @@ BitmapBuffer* StretchAndConvert( // horizontal mapping table if( (pDstBuffer->mnWidth != rTwoRect.mnSrcWidth) && (pDstBuffer->mnWidth != 0) ) { - const double fFactorX = (double)rTwoRect.mnSrcWidth / pDstBuffer->mnWidth; + const double fFactorX = static_cast<double>(rTwoRect.mnSrcWidth) / pDstBuffer->mnWidth; for (long i = 0; i < pDstBuffer->mnWidth; ++i) pMapX[ i ] = rTwoRect.mnSrcX + static_cast<int>( i * fFactorX ); @@ -430,7 +430,7 @@ BitmapBuffer* StretchAndConvert( // vertical mapping table if( (pDstBuffer->mnHeight != rTwoRect.mnSrcHeight) && (pDstBuffer->mnHeight != 0) ) { - const double fFactorY = (double)rTwoRect.mnSrcHeight / pDstBuffer->mnHeight; + const double fFactorY = static_cast<double>(rTwoRect.mnSrcHeight) / pDstBuffer->mnHeight; for (long i = 0; i < pDstBuffer->mnHeight; ++i) pMapY[ i ] = rTwoRect.mnSrcY + static_cast<int>( i * fFactorY ); diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx index 2f37550c7e22..4ce92b1d932f 100644 --- a/vcl/source/gdi/svmconverter.cxx +++ b/vcl/source/gdi/svmconverter.cxx @@ -81,7 +81,7 @@ bool ImplReadPolyPoly(SvStream& rIStm, tools::PolyPolygon& rPolyPoly) tools::Polygon aPoly; sal_Int32 nPolyCount32(0); rIStm.ReadInt32(nPolyCount32); - sal_uInt16 nPolyCount = (sal_uInt16)nPolyCount32; + sal_uInt16 nPolyCount = static_cast<sal_uInt16>(nPolyCount32); for (sal_uInt16 i = 0; i < nPolyCount && rIStm.good(); ++i) { @@ -129,22 +129,22 @@ void ImplReadColor( SvStream& rIStm, Color& rColor ) { sal_Int16 nVal(0); - rIStm.ReadInt16( nVal ); rColor.SetRed( sal::static_int_cast<sal_uInt8>((sal_uInt16)nVal >> 8) ); - rIStm.ReadInt16( nVal ); rColor.SetGreen( sal::static_int_cast<sal_uInt8>((sal_uInt16)nVal >> 8) ); - rIStm.ReadInt16( nVal ); rColor.SetBlue( sal::static_int_cast<sal_uInt8>((sal_uInt16)nVal >> 8) ); + rIStm.ReadInt16( nVal ); rColor.SetRed( sal::static_int_cast<sal_uInt8>(static_cast<sal_uInt16>(nVal) >> 8) ); + rIStm.ReadInt16( nVal ); rColor.SetGreen( sal::static_int_cast<sal_uInt8>(static_cast<sal_uInt16>(nVal) >> 8) ); + rIStm.ReadInt16( nVal ); rColor.SetBlue( sal::static_int_cast<sal_uInt8>(static_cast<sal_uInt16>(nVal) >> 8) ); } void ImplWriteColor( SvStream& rOStm, const Color& rColor ) { sal_Int16 nVal; - nVal = ( (sal_Int16) rColor.GetRed() << 8 ) | rColor.GetRed(); + nVal = ( static_cast<sal_Int16>(rColor.GetRed()) << 8 ) | rColor.GetRed(); rOStm.WriteInt16( nVal ); - nVal = ( (sal_Int16) rColor.GetGreen() << 8 ) | rColor.GetGreen(); + nVal = ( static_cast<sal_Int16>(rColor.GetGreen()) << 8 ) | rColor.GetGreen(); rOStm.WriteInt16( nVal ); - nVal = ( (sal_Int16) rColor.GetBlue() << 8 ) | rColor.GetBlue(); + nVal = ( static_cast<sal_Int16>(rColor.GetBlue()) << 8 ) | rColor.GetBlue(); rOStm.WriteInt16( nVal ); } @@ -890,7 +890,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rIStm.ReadCharAsBool(bItalic).ReadCharAsBool(bOutline).ReadCharAsBool(bShadow).ReadCharAsBool(bTransparent); aFont.SetFontSize( Size( nWidth, nHeight ) ); - aFont.SetCharSet( (rtl_TextEncoding) nCharSet ); + aFont.SetCharSet( static_cast<rtl_TextEncoding>(nCharSet) ); aFont.SetFamily( (FontFamily) nFamily ); aFont.SetPitch( (FontPitch) nPitch ); aFont.SetAlignment( (FontAlign) nAlign ); @@ -2376,8 +2376,8 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile const & r GDIMetaFile aMtf( rTransMtf ); const Size aSrcSize( rTransMtf.GetPrefSize() ); Point aSrcPt( rTransMtf.GetPrefMapMode().GetOrigin() ); - const double fScaleX = aSrcSize.Width() ? (double) rSize.Width() / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? (double) rSize.Height() / aSrcSize.Height() : 1.0; + const double fScaleX = aSrcSize.Width() ? static_cast<double>(rSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(rSize.Height()) / aSrcSize.Height() : 1.0; long nMoveX, nMoveY; if( fScaleX != 1.0 || fScaleY != 1.0 ) @@ -2511,7 +2511,7 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile const & r { const MetaTextLineAction* pA = static_cast<const MetaTextLineAction*>(pAction); const Point& rStartPt = pA->GetStartPoint(); - const sal_Int32 nWidth = (sal_Int32) pA->GetWidth(); + const sal_Int32 nWidth = static_cast<sal_Int32>(pA->GetWidth()); const FontStrikeout eStrikeout = pA->GetStrikeout(); const FontLineStyle eUnderline = pA->GetUnderline(); sal_uLong nOldPos, nNewPos; diff --git a/vcl/source/helper/canvastools.cxx b/vcl/source/helper/canvastools.cxx index 8920265af010..9a56f52219da 100644 --- a/vcl/source/helper/canvastools.cxx +++ b/vcl/source/helper/canvastools.cxx @@ -124,10 +124,10 @@ namespace vcl { const rendering::ARGBColor& rColor=aARGBColors[x]; rWriteAcc->SetPixelIndex( aRect.Y1, x, - (sal_uInt8) rWriteAcc->GetBestPaletteIndex( + static_cast<sal_uInt8>(rWriteAcc->GetBestPaletteIndex( BitmapColor( toByteColor(rColor.Red), toByteColor(rColor.Green), - toByteColor(rColor.Blue))) ); + toByteColor(rColor.Blue)))) ); rAlphaAcc->SetPixel( aRect.Y1, x, BitmapColor( 255 - toByteColor(rColor.Alpha) )); } @@ -156,10 +156,10 @@ namespace vcl { const rendering::RGBColor& rColor=aRGBColors[x]; rWriteAcc->SetPixelIndex( aRect.Y1, x, - (sal_uInt8) rWriteAcc->GetBestPaletteIndex( + static_cast<sal_uInt8>(rWriteAcc->GetBestPaletteIndex( BitmapColor( toByteColor(rColor.Red), toByteColor(rColor.Green), - toByteColor(rColor.Blue))) ); + toByteColor(rColor.Blue)))) ); } } else diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx index 4cdca54b65d8..1eaab88e4747 100644 --- a/vcl/source/helper/commandinfoprovider.cxx +++ b/vcl/source/helper/commandinfoprovider.cxx @@ -125,7 +125,7 @@ vcl::KeyCode AWTKey2VCLKey(const awt::KeyEvent& aAWTKey) bool bMod1 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD1 ) == awt::KeyModifier::MOD1 ); bool bMod2 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD2 ) == awt::KeyModifier::MOD2 ); bool bMod3 = ((aAWTKey.Modifiers & awt::KeyModifier::MOD3 ) == awt::KeyModifier::MOD3 ); - sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode; + sal_uInt16 nKey = static_cast<sal_uInt16>(aAWTKey.KeyCode); return vcl::KeyCode(nKey, bShift, bMod1, bMod2, bMod3); } diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 24b1c5403057..35c5e8098741 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -755,7 +755,7 @@ private: double fTemp = std::abs((nOffset + i) * fReverseScale); pMap[i] = MinMax(nDstLocation + long(fTemp), 0, nSampleRange); - pMapOffset[i] = (long) ((fTemp - pMap[i]) * 128.0); + pMapOffset[i] = static_cast<long>((fTemp - pMap[i]) * 128.0); } } @@ -1344,8 +1344,8 @@ namespace inline sal_uInt8 CalcColor( const sal_uInt8 nSourceColor, const sal_uInt8 nSourceAlpha, const sal_uInt8 nDstAlpha, const sal_uInt8 nResAlpha, const sal_uInt8 nDestColor ) { - int c = nResAlpha ? ( (int)nSourceAlpha*nSourceColor + (int)nDstAlpha*nDestColor - - (int)nDstAlpha*nDestColor*nSourceAlpha/255 ) / (int)nResAlpha : 0; + int c = nResAlpha ? ( static_cast<int>(nSourceAlpha)*nSourceColor + static_cast<int>(nDstAlpha)*nDestColor - + static_cast<int>(nDstAlpha)*nDestColor*nSourceAlpha/255 ) / static_cast<int>(nResAlpha) : 0; return sal_uInt8( c ); } @@ -1370,7 +1370,7 @@ namespace // Co = Cs + Cd*(1-As) // Ad = As + Ad*(1-As) - nResAlpha = (int)nSrcAlpha + (int)nDstAlpha - (int)nDstAlpha*nSrcAlpha/255; + nResAlpha = static_cast<int>(nSrcAlpha) + static_cast<int>(nDstAlpha) - static_cast<int>(nDstAlpha)*nSrcAlpha/255; aDstCol.SetRed( CalcColor( aSrcCol.GetRed(), nSrcAlpha, nDstAlpha, nResAlpha, aDstCol.GetRed() ) ); aDstCol.SetBlue( CalcColor( aSrcCol.GetBlue(), nSrcAlpha, nDstAlpha, nResAlpha, aDstCol.GetBlue() ) ); @@ -1437,12 +1437,12 @@ Bitmap OutputDevice::BlendBitmapWithAlpha( aDstCol = AlphaBlend( nX, nY, nMapX, nMapY, pP, pA, pB.get(), pAlphaW.get(), nResAlpha ); - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16 ] + nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16 ] ) ); pW->SetPixel( nY, nX, aIndex ); - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] + + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] + nVCLGLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] + nVCLBLut[ ( nVCLLut[ 255-nResAlpha ] + nD ) >> 16 ] ) ); pAlphaW->SetPixel( nY, nX, aIndex ); @@ -1534,7 +1534,7 @@ Bitmap OutputDevice::BlendBitmap( aDstCol = pB->GetColor( nY, nX ); aDstCol.Merge( pP->GetColor( nMapY, nMapX ), pA->GetPixelIndex( nMapY, nMapX ) ); - aIndex.SetIndex( (sal_uInt8) ( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + + aIndex.SetIndex( static_cast<sal_uInt8>( nVCLRLut[ ( nVCLLut[ aDstCol.GetRed() ] + nD ) >> 16 ] + nVCLGLut[ ( nVCLLut[ aDstCol.GetGreen() ] + nD ) >> 16 ] + nVCLBLut[ ( nVCLLut[ aDstCol.GetBlue() ] + nD ) >> 16 ] ) ); pW->SetPixel( nY, nX, aIndex ); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 077159bebe83..63841a7cacf3 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -421,7 +421,7 @@ void OutputDevice::ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPo tools::Polygon aPoly( SAL_N_ELEMENTS( aAccentPos ) / 2, reinterpret_cast<const Point*>(aAccentPos), aAccentPolyFlags ); - double dScale = ((double)nDotSize)/1000.0; + double dScale = static_cast<double>(nDotSize)/1000.0; aPoly.Scale( dScale, dScale ); tools::Polygon aTemp; aPoly.AdaptiveSubdivide( aTemp ); @@ -1139,9 +1139,9 @@ bool OutputDevice::ImplNewFont() const if( mbMap && !aSize.Width() ) { int nOrigWidth = pFontInstance->mxFontMetric->GetWidth(); - float fStretch = (float)maMapRes.mnMapScNumX * maMapRes.mnMapScDenomY; - fStretch /= (float)maMapRes.mnMapScNumY * maMapRes.mnMapScDenomX; - int nNewWidth = (int)(nOrigWidth * fStretch + 0.5); + float fStretch = static_cast<float>(maMapRes.mnMapScNumX) * maMapRes.mnMapScDenomY; + fStretch /= static_cast<float>(maMapRes.mnMapScNumY) * maMapRes.mnMapScDenomX; + int nNewWidth = static_cast<int>(nOrigWidth * fStretch + 0.5); if( (nNewWidth != nOrigWidth) && (nNewWidth != 0) ) { Size aOrigSize = maFont.GetFontSize(); @@ -1462,7 +1462,7 @@ bool OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const OUString& rSt rVector.push_back( aRect ); } - return (nLen == (int)rVector.size()); + return (nLen == static_cast<int>(rVector.size())); } sal_Int32 OutputDevice::HasGlyphs( const vcl::Font& rTempFont, const OUString& rStr, diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx index c3fbd24664db..c71b420d92ed 100644 --- a/vcl/source/outdev/gradient.cxx +++ b/vcl/source/outdev/gradient.cxx @@ -256,7 +256,7 @@ namespace else if ( nValue > 0xFF ) return 0xFF; else - return (sal_uInt8)nValue; + return static_cast<sal_uInt8>(nValue); } } @@ -328,13 +328,13 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, tools::Polygon aPoly( 4 ); if (fBorder > 0.0) { - nRed = (sal_uInt8)nStartRed; - nGreen = (sal_uInt8)nStartGreen; - nBlue = (sal_uInt8)nStartBlue; + nRed = static_cast<sal_uInt8>(nStartRed); + nGreen = static_cast<sal_uInt8>(nStartGreen); + nBlue = static_cast<sal_uInt8>(nStartBlue); mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); - aBorderRect.Bottom() = (long)( aBorderRect.Top() + fBorder ); + aBorderRect.Bottom() = static_cast<long>( aBorderRect.Top() + fBorder ); aRect.Top() = aBorderRect.Bottom(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -347,7 +347,7 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, if ( !bLinear) { aBorderRect = aMirrorRect; - aBorderRect.Top() = (long) ( aBorderRect.Bottom() - fBorder ); + aBorderRect.Top() = static_cast<long>( aBorderRect.Bottom() - fBorder ); aMirrorRect.Bottom() = aBorderRect.Top(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -374,11 +374,11 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, nSteps = 3; } - double fScanInc = ((double)aRect.GetHeight()) / (double) nSteps; - double fGradientLine = (double)aRect.Top(); - double fMirrorGradientLine = (double) aMirrorRect.Bottom(); + double fScanInc = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps); + double fGradientLine = static_cast<double>(aRect.Top()); + double fMirrorGradientLine = static_cast<double>(aMirrorRect.Bottom()); - const double fStepsMinus1 = ((double)nSteps) - 1.0; + const double fStepsMinus1 = static_cast<double>(nSteps) - 1.0; if ( !bLinear) { nSteps -= 1; // draw middle polygons as one polygon after loop to avoid gap @@ -386,19 +386,19 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, for ( long i = 0; i < nSteps; i++ ) { // linear interpolation of color - const double fAlpha = ((double)i) / fStepsMinus1; - double fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha; - nRed = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartGreen) * (1.0-fAlpha) + ((double)nEndGreen) * fAlpha; - nGreen = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartBlue) * (1.0-fAlpha) + ((double)nEndBlue) * fAlpha; - nBlue = GetGradientColorValue((long)fTempColor); + const double fAlpha = static_cast<double>(i) / fStepsMinus1; + double fTempColor = static_cast<double>(nStartRed) * (1.0-fAlpha) + static_cast<double>(nEndRed) * fAlpha; + nRed = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartGreen) * (1.0-fAlpha) + static_cast<double>(nEndGreen) * fAlpha; + nGreen = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartBlue) * (1.0-fAlpha) + static_cast<double>(nEndBlue) * fAlpha; + nBlue = GetGradientColorValue(static_cast<long>(fTempColor)); mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); // Polygon for this color step - aRect.Top() = (long)( fGradientLine + ((double) i) * fScanInc ); - aRect.Bottom() = (long)( fGradientLine + ( ((double) i) + 1.0 ) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(i) * fScanInc ); + aRect.Bottom() = static_cast<long>( fGradientLine + ( static_cast<double>(i) + 1.0 ) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -409,8 +409,8 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, if ( !bLinear ) { - aMirrorRect.Bottom() = (long)( fMirrorGradientLine - ((double) i) * fScanInc ); - aMirrorRect.Top() = (long)( fMirrorGradientLine - (((double) i) + 1.0)* fScanInc ); + aMirrorRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(i) * fScanInc ); + aMirrorRect.Top() = static_cast<long>( fMirrorGradientLine - (static_cast<double>(i) + 1.0)* fScanInc ); aPoly[0] = aMirrorRect.TopLeft(); aPoly[1] = aMirrorRect.TopRight(); aPoly[2] = aMirrorRect.BottomRight(); @@ -430,8 +430,8 @@ void OutputDevice::DrawLinearGradient( const tools::Rectangle& rRect, mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); - aRect.Top() = (long)( fGradientLine + ((double)nSteps) * fScanInc ); - aRect.Bottom() = (long)( fMirrorGradientLine - ((double) nSteps) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ); + aRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -465,12 +465,12 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, Point aCenter; Color aStartCol( rGradient.GetStartColor() ); Color aEndCol( rGradient.GetEndColor() ); - long nStartRed = ( (long) aStartCol.GetRed() * rGradient.GetStartIntensity() ) / 100; - long nStartGreen = ( (long) aStartCol.GetGreen() * rGradient.GetStartIntensity() ) / 100; - long nStartBlue = ( (long) aStartCol.GetBlue() * rGradient.GetStartIntensity() ) / 100; - long nEndRed = ( (long) aEndCol.GetRed() * rGradient.GetEndIntensity() ) / 100; - long nEndGreen = ( (long) aEndCol.GetGreen() * rGradient.GetEndIntensity() ) / 100; - long nEndBlue = ( (long) aEndCol.GetBlue() * rGradient.GetEndIntensity() ) / 100; + long nStartRed = ( static_cast<long>(aStartCol.GetRed()) * rGradient.GetStartIntensity() ) / 100; + long nStartGreen = ( static_cast<long>(aStartCol.GetGreen()) * rGradient.GetStartIntensity() ) / 100; + long nStartBlue = ( static_cast<long>(aStartCol.GetBlue()) * rGradient.GetStartIntensity() ) / 100; + long nEndRed = ( static_cast<long>(aEndCol.GetRed()) * rGradient.GetEndIntensity() ) / 100; + long nEndGreen = ( static_cast<long>(aEndCol.GetGreen()) * rGradient.GetEndIntensity() ) / 100; + long nEndBlue = ( static_cast<long>(aEndCol.GetBlue()) * rGradient.GetEndIntensity() ) / 100; long nRedSteps = nEndRed - nStartRed; long nGreenSteps = nEndGreen - nStartGreen; long nBlueSteps = nEndBlue - nStartBlue; @@ -503,8 +503,8 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, double fScanTop = aRect.Top(); double fScanRight = aRect.Right(); double fScanBottom = aRect.Bottom(); - double fScanIncX = (double) aRect.GetWidth() / (double) nSteps * 0.5; - double fScanIncY = (double) aRect.GetHeight() / (double) nSteps * 0.5; + double fScanIncX = static_cast<double>(aRect.GetWidth()) / static_cast<double>(nSteps) * 0.5; + double fScanIncY = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps) * 0.5; // all gradients are rendered as nested rectangles which shrink // equally in each dimension - except for 'square' gradients @@ -514,7 +514,7 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, fScanIncY = std::min( fScanIncY, fScanIncX ); fScanIncX = fScanIncY; } - sal_uInt8 nRed = (sal_uInt8) nStartRed, nGreen = (sal_uInt8) nStartGreen, nBlue = (sal_uInt8) nStartBlue; + sal_uInt8 nRed = static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue = static_cast<sal_uInt8>(nStartBlue); bool bPaintLastPolygon( false ); // #107349# Paint last polygon only if loop has generated any output mpGraphics->SetFillColor( MAKE_SALCOLOR( nRed, nGreen, nBlue ) ); @@ -541,10 +541,10 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, for( long i = 1; i < nSteps; i++ ) { // calculate new Polygon - aRect.Left() = (long)( fScanLeft += fScanIncX ); - aRect.Top() = (long)( fScanTop += fScanIncY ); - aRect.Right() = (long)( fScanRight -= fScanIncX ); - aRect.Bottom() = (long)( fScanBottom -= fScanIncY ); + aRect.Left() = static_cast<long>( fScanLeft += fScanIncX ); + aRect.Top() = static_cast<long>( fScanTop += fScanIncY ); + aRect.Right() = static_cast<long>( fScanRight -= fScanIncX ); + aRect.Bottom() = static_cast<long>( fScanBottom -= fScanIncY ); if( ( aRect.GetWidth() < 2 ) || ( aRect.GetHeight() < 2 ) ) break; @@ -680,13 +680,13 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, tools::Polygon aPoly( 4 ); if (fBorder > 0.0) { - nRed = (sal_uInt8)nStartRed; - nGreen = (sal_uInt8)nStartGreen; - nBlue = (sal_uInt8)nStartBlue; + nRed = static_cast<sal_uInt8>(nStartRed); + nGreen = static_cast<sal_uInt8>(nStartGreen); + nBlue = static_cast<sal_uInt8>(nStartBlue); mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); - aBorderRect.Bottom() = (long)( aBorderRect.Top() + fBorder ); + aBorderRect.Bottom() = static_cast<long>( aBorderRect.Top() + fBorder ); aRect.Top() = aBorderRect.Bottom(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -699,7 +699,7 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, if ( !bLinear) { aBorderRect = aMirrorRect; - aBorderRect.Top() = (long) ( aBorderRect.Bottom() - fBorder ); + aBorderRect.Top() = static_cast<long>( aBorderRect.Bottom() - fBorder ); aMirrorRect.Bottom() = aBorderRect.Top(); aPoly[0] = aBorderRect.TopLeft(); aPoly[1] = aBorderRect.TopRight(); @@ -725,11 +725,11 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, nSteps = 3; } - double fScanInc = ((double)aRect.GetHeight()) / (double) nSteps; - double fGradientLine = (double)aRect.Top(); - double fMirrorGradientLine = (double) aMirrorRect.Bottom(); + double fScanInc = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps); + double fGradientLine = static_cast<double>(aRect.Top()); + double fMirrorGradientLine = static_cast<double>(aMirrorRect.Bottom()); - const double fStepsMinus1 = ((double)nSteps) - 1.0; + const double fStepsMinus1 = static_cast<double>(nSteps) - 1.0; if ( !bLinear) { nSteps -= 1; // draw middle polygons as one polygon after loop to avoid gap @@ -737,19 +737,19 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, for ( long i = 0; i < nSteps; i++ ) { // linear interpolation of color - double fAlpha = ((double)i) / fStepsMinus1; - double fTempColor = ((double)nStartRed) * (1.0-fAlpha) + ((double)nEndRed) * fAlpha; - nRed = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartGreen) * (1.0-fAlpha) + ((double)nEndGreen) * fAlpha; - nGreen = GetGradientColorValue((long)fTempColor); - fTempColor = ((double)nStartBlue) * (1.0-fAlpha) + ((double)nEndBlue) * fAlpha; - nBlue = GetGradientColorValue((long)fTempColor); + double fAlpha = static_cast<double>(i) / fStepsMinus1; + double fTempColor = static_cast<double>(nStartRed) * (1.0-fAlpha) + static_cast<double>(nEndRed) * fAlpha; + nRed = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartGreen) * (1.0-fAlpha) + static_cast<double>(nEndGreen) * fAlpha; + nGreen = GetGradientColorValue(static_cast<long>(fTempColor)); + fTempColor = static_cast<double>(nStartBlue) * (1.0-fAlpha) + static_cast<double>(nEndBlue) * fAlpha; + nBlue = GetGradientColorValue(static_cast<long>(fTempColor)); mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); // Polygon for this color step - aRect.Top() = (long)( fGradientLine + ((double) i) * fScanInc ); - aRect.Bottom() = (long)( fGradientLine + ( ((double) i) + 1.0 ) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(i) * fScanInc ); + aRect.Bottom() = static_cast<long>( fGradientLine + ( static_cast<double>(i) + 1.0 ) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -760,8 +760,8 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, if ( !bLinear ) { - aMirrorRect.Bottom() = (long)( fMirrorGradientLine - ((double) i) * fScanInc ); - aMirrorRect.Top() = (long)( fMirrorGradientLine - (((double) i) + 1.0)* fScanInc ); + aMirrorRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(i) * fScanInc ); + aMirrorRect.Top() = static_cast<long>( fMirrorGradientLine - (static_cast<double>(i) + 1.0)* fScanInc ); aPoly[0] = aMirrorRect.TopLeft(); aPoly[1] = aMirrorRect.TopRight(); aPoly[2] = aMirrorRect.BottomRight(); @@ -781,8 +781,8 @@ void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); - aRect.Top() = (long)( fGradientLine + ((double)nSteps) * fScanInc ); - aRect.Bottom() = (long)( fMirrorGradientLine - ((double) nSteps) * fScanInc ); + aRect.Top() = static_cast<long>( fGradientLine + static_cast<double>(nSteps) * fScanInc ); + aRect.Bottom() = static_cast<long>( fMirrorGradientLine - static_cast<double>(nSteps) * fScanInc ); aPoly[0] = aRect.TopLeft(); aPoly[1] = aRect.TopRight(); aPoly[2] = aRect.BottomRight(); @@ -809,12 +809,12 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, Point aCenter; Color aStartCol( rGradient.GetStartColor() ); Color aEndCol( rGradient.GetEndColor() ); - long nStartRed = ( (long) aStartCol.GetRed() * rGradient.GetStartIntensity() ) / 100; - long nStartGreen = ( (long) aStartCol.GetGreen() * rGradient.GetStartIntensity() ) / 100; - long nStartBlue = ( (long) aStartCol.GetBlue() * rGradient.GetStartIntensity() ) / 100; - long nEndRed = ( (long) aEndCol.GetRed() * rGradient.GetEndIntensity() ) / 100; - long nEndGreen = ( (long) aEndCol.GetGreen() * rGradient.GetEndIntensity() ) / 100; - long nEndBlue = ( (long) aEndCol.GetBlue() * rGradient.GetEndIntensity() ) / 100; + long nStartRed = ( static_cast<long>(aStartCol.GetRed()) * rGradient.GetStartIntensity() ) / 100; + long nStartGreen = ( static_cast<long>(aStartCol.GetGreen()) * rGradient.GetStartIntensity() ) / 100; + long nStartBlue = ( static_cast<long>(aStartCol.GetBlue()) * rGradient.GetStartIntensity() ) / 100; + long nEndRed = ( static_cast<long>(aEndCol.GetRed()) * rGradient.GetEndIntensity() ) / 100; + long nEndGreen = ( static_cast<long>(aEndCol.GetGreen()) * rGradient.GetEndIntensity() ) / 100; + long nEndBlue = ( static_cast<long>(aEndCol.GetBlue()) * rGradient.GetEndIntensity() ) / 100; long nRedSteps = nEndRed - nStartRed; long nGreenSteps = nEndGreen - nStartGreen; long nBlueSteps = nEndBlue - nStartBlue; @@ -847,8 +847,8 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, double fScanTop = aRect.Top(); double fScanRight = aRect.Right(); double fScanBottom = aRect.Bottom(); - double fScanIncX = (double) aRect.GetWidth() / (double) nSteps * 0.5; - double fScanIncY = (double) aRect.GetHeight() / (double) nSteps * 0.5; + double fScanIncX = static_cast<double>(aRect.GetWidth()) / static_cast<double>(nSteps) * 0.5; + double fScanIncY = static_cast<double>(aRect.GetHeight()) / static_cast<double>(nSteps) * 0.5; // all gradients are rendered as nested rectangles which shrink // equally in each dimension - except for 'square' gradients @@ -858,7 +858,7 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, fScanIncY = std::min( fScanIncY, fScanIncX ); fScanIncX = fScanIncY; } - sal_uInt8 nRed = (sal_uInt8) nStartRed, nGreen = (sal_uInt8) nStartGreen, nBlue = (sal_uInt8) nStartBlue; + sal_uInt8 nRed = static_cast<sal_uInt8>(nStartRed), nGreen = static_cast<sal_uInt8>(nStartGreen), nBlue = static_cast<sal_uInt8>(nStartBlue); bool bPaintLastPolygon( false ); // #107349# Paint last polygon only if loop has generated any output mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); @@ -870,10 +870,10 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, for( long i = 1; i < nSteps; i++ ) { // calculate new Polygon - aRect.Left() = (long)( fScanLeft += fScanIncX ); - aRect.Top() = (long)( fScanTop += fScanIncY ); - aRect.Right() = (long)( fScanRight -= fScanIncX ); - aRect.Bottom() = (long)( fScanBottom -= fScanIncY ); + aRect.Left() = static_cast<long>( fScanLeft += fScanIncX ); + aRect.Top() = static_cast<long>( fScanTop += fScanIncY ); + aRect.Right() = static_cast<long>( fScanRight -= fScanIncX ); + aRect.Bottom() = static_cast<long>( fScanBottom -= fScanIncY ); if( ( aRect.GetWidth() < 2 ) || ( aRect.GetHeight() < 2 ) ) break; diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx index 46edae35f790..125672e023b2 100644 --- a/vcl/source/outdev/hatch.cxx +++ b/vcl/source/outdev/hatch.cxx @@ -332,7 +332,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol for( long nPoly = 0, nPolyCount = rPolyPoly.Count(); nPoly < nPolyCount; nPoly++ ) { - const tools::Polygon& rPoly = rPolyPoly[ (sal_uInt16) nPoly ]; + const tools::Polygon& rPoly = rPolyPoly[ static_cast<sal_uInt16>(nPoly) ]; if( rPoly.GetSize() > 1 ) { @@ -340,7 +340,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol for( long i = 1, nCount = rPoly.GetSize(); i <= nCount; i++ ) { - aCurSegment.SetEnd( rPoly[ (sal_uInt16)( i % nCount ) ] ); + aCurSegment.SetEnd( rPoly[ static_cast<sal_uInt16>( i % nCount ) ] ); nAdd = 0; if( rLine.Intersection( aCurSegment, fX, fY ) ) @@ -348,7 +348,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol if( ( fabs( fX - aCurSegment.GetStart().X() ) <= 0.0000001 ) && ( fabs( fY - aCurSegment.GetStart().Y() ) <= 0.0000001 ) ) { - const tools::Line aPrevSegment( rPoly[ (sal_uInt16)( ( i > 1 ) ? ( i - 2 ) : ( nCount - 1 ) ) ], aCurSegment.GetStart() ); + const tools::Line aPrevSegment( rPoly[ static_cast<sal_uInt16>( ( i > 1 ) ? ( i - 2 ) : ( nCount - 1 ) ) ], aCurSegment.GetStart() ); const double fPrevDistance = rLine.GetDistance( aPrevSegment.GetStart() ); const double fCurDistance = rLine.GetDistance( aCurSegment.GetEnd() ); @@ -361,7 +361,7 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol else if( ( fabs( fX - aCurSegment.GetEnd().X() ) <= 0.0000001 ) && ( fabs( fY - aCurSegment.GetEnd().Y() ) <= 0.0000001 ) ) { - const tools::Line aNextSegment( aCurSegment.GetEnd(), rPoly[ (sal_uInt16)( ( i + 1 ) % nCount ) ] ); + const tools::Line aNextSegment( aCurSegment.GetEnd(), rPoly[ static_cast<sal_uInt16>( ( i + 1 ) % nCount ) ] ); if( ( fabs( rLine.GetDistance( aNextSegment.GetEnd() ) ) <= 0.0000001 ) && ( rLine.GetDistance( aCurSegment.GetStart() ) > 0.0 ) ) diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index b3fffe55a077..9df906196581 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -108,9 +108,9 @@ static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY, if ( !nDenomX ) rThresRes.mnThresPixToLogX = LONG_MAX; else if ( nProductX >= 0 ) - rThresRes.mnThresPixToLogX = (long)(((sal_uLong)LONG_MAX - (sal_uLong)( nProductX/2)) / nDenomX); + rThresRes.mnThresPixToLogX = static_cast<long>((sal_uLong(LONG_MAX) - static_cast<sal_uLong>( nProductX/2)) / nDenomX); else - rThresRes.mnThresPixToLogX = (long)(((sal_uLong)LONG_MAX + (sal_uLong)(-nProductX/2)) / nDenomX); + rThresRes.mnThresPixToLogX = static_cast<long>((sal_uLong(LONG_MAX) + static_cast<sal_uLong>(-nProductX/2)) / nDenomX); } if ( nDPIY && (LONG_MAX / nDPIY < std::abs( rMapRes.mnMapScNumY ) ) ) // #111139# avoid div by zero @@ -133,9 +133,9 @@ static void ImplCalcBigIntThreshold( long nDPIX, long nDPIY, if ( !nDenomY ) rThresRes.mnThresPixToLogY = LONG_MAX; else if ( nProductY >= 0 ) - rThresRes.mnThresPixToLogY = (long)(((sal_uLong)LONG_MAX - (sal_uLong)( nProductY/2)) / nDenomY); + rThresRes.mnThresPixToLogY = static_cast<long>((sal_uLong(LONG_MAX) - static_cast<sal_uLong>( nProductY/2)) / nDenomY); else - rThresRes.mnThresPixToLogY = (long)(((sal_uLong)LONG_MAX + (sal_uLong)(-nProductY/2)) / nDenomY); + rThresRes.mnThresPixToLogY = static_cast<long>((sal_uLong(LONG_MAX) + static_cast<sal_uLong>(-nProductY/2)) / nDenomY); } rThresRes.mnThresLogToPixX /= 2; @@ -275,7 +275,7 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, aX += BigInt(nXNumerator / 2); } aX /= BigInt(nXNumerator); - rMapRes.mnMapOfsX = (long)aX + aOrigin.X(); + rMapRes.mnMapOfsX = static_cast<long>(aX) + aOrigin.X(); BigInt aY( rMapRes.mnMapOfsY ); aY *= BigInt( aScaleY.GetDenominator() ); if( rMapRes.mnMapOfsY >= 0 ) @@ -293,7 +293,7 @@ static void ImplCalcMapResolution( const MapMode& rMapMode, aY += BigInt(nYNumerator / 2); } aY /= BigInt(nYNumerator); - rMapRes.mnMapOfsY = (long)aY + aOrigin.Y(); + rMapRes.mnMapOfsY = static_cast<long>(aY) + aOrigin.Y(); } // calculate scaling factor according to MapMode @@ -366,10 +366,10 @@ static long ImplLogicToPixel( long n, long nDPI, long nMapNum, long nMapDenom, n64 *= nMapNum; n64 *= nDPI; if( nMapDenom == 1 ) - n = (long)n64; + n = static_cast<long>(n64); else { - n = (long)(2 * n64 / nMapDenom); + n = static_cast<long>(2 * n64 / nMapDenom); if( n < 0 ) --n; else ++n; n /= 2; } @@ -397,7 +397,7 @@ static long ImplPixelToLogic( long n, long nDPI, long nMapNum, long nMapDenom, { sal_Int64 n64 = n; n64 *= nMapDenom; - n = (long)(2 * n64 / nDenom); + n = static_cast<long>(2 * n64 / nDenom); } if( n < 0 ) --n; else ++n; return (n / 2); @@ -858,10 +858,10 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation() const { mpOutDevData->mpViewTransform = new basegfx::B2DHomMatrix; - const double fScaleFactorX((double)mnDPIX * (double)maMapRes.mnMapScNumX / (double)maMapRes.mnMapScDenomX); - const double fScaleFactorY((double)mnDPIY * (double)maMapRes.mnMapScNumY / (double)maMapRes.mnMapScDenomY); - const double fZeroPointX(((double)maMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); - const double fZeroPointY(((double)maMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); + const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(maMapRes.mnMapScNumX) / static_cast<double>(maMapRes.mnMapScDenomX)); + const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(maMapRes.mnMapScNumY) / static_cast<double>(maMapRes.mnMapScDenomY)); + const double fZeroPointX((static_cast<double>(maMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX)); + const double fZeroPointY((static_cast<double>(maMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY)); mpOutDevData->mpViewTransform->set(0, 0, fScaleFactorX); mpOutDevData->mpViewTransform->set(1, 1, fScaleFactorY); @@ -907,10 +907,10 @@ basegfx::B2DHomMatrix OutputDevice::GetViewTransformation( const MapMode& rMapMo basegfx::B2DHomMatrix aTransform; - const double fScaleFactorX((double)mnDPIX * (double)aMapRes.mnMapScNumX / (double)aMapRes.mnMapScDenomX); - const double fScaleFactorY((double)mnDPIY * (double)aMapRes.mnMapScNumY / (double)aMapRes.mnMapScDenomY); - const double fZeroPointX(((double)aMapRes.mnMapOfsX * fScaleFactorX) + (double)mnOutOffOrigX); - const double fZeroPointY(((double)aMapRes.mnMapOfsY * fScaleFactorY) + (double)mnOutOffOrigY); + const double fScaleFactorX(static_cast<double>(mnDPIX) * static_cast<double>(aMapRes.mnMapScNumX) / static_cast<double>(aMapRes.mnMapScDenomX)); + const double fScaleFactorY(static_cast<double>(mnDPIY) * static_cast<double>(aMapRes.mnMapScNumY) / static_cast<double>(aMapRes.mnMapScDenomY)); + const double fZeroPointX((static_cast<double>(aMapRes.mnMapOfsX) * fScaleFactorX) + static_cast<double>(mnOutOffOrigX)); + const double fZeroPointY((static_cast<double>(aMapRes.mnMapOfsY) * fScaleFactorY) + static_cast<double>(mnOutOffOrigY)); aTransform.set(0, 0, fScaleFactorX); aTransform.set(1, 1, fScaleFactorY); @@ -1563,7 +1563,7 @@ static long fn5( const long n1, a7 /= n8; } // of else - return (long)a7; + return static_cast<long>(a7); } // of if else { @@ -1599,7 +1599,7 @@ static long fn5( const long n1, a7 /= n8; } // of else - return (long)a7; + return static_cast<long>(a7); } // of if else { @@ -1619,7 +1619,7 @@ static long fn5( const long n1, a7 += a9; a7 /= a8; - return (long)a7; + return static_cast<long>(a7); } // of if else { @@ -1656,7 +1656,7 @@ static long fn3( const long n1, const long n2, const long n3 ) a4 += n3 / 2; a4 /= n3; - return (long)a4; + return static_cast<long>(a4); } // of if else { @@ -1826,7 +1826,7 @@ basegfx::B2DHomMatrix OutputDevice::LogicToLogic(const MapMode& rMapModeSource, { ENTER3(eUnitSource, eUnitDest); - const double fScaleFactor((double)nNumerator / (double)nDenominator); + const double fScaleFactor(static_cast<double>(nNumerator) / static_cast<double>(nDenominator)); aTransform.set(0, 0, fScaleFactor); aTransform.set(1, 1, fScaleFactor); } @@ -1923,7 +1923,7 @@ void OutputDevice::SetPixelOffset( const Size& rOffset ) DeviceCoordinate OutputDevice::LogicWidthToDeviceCoordinate( long nWidth ) const { if ( !mbMap ) - return (DeviceCoordinate)nWidth; + return static_cast<DeviceCoordinate>(nWidth); #if VCL_FLOAT_DEVICE_PIXEL return (double)nWidth * maMapRes.mfScaleX * mnDPIX; diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 5066c3b87071..67b2afc471c9 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -382,7 +382,7 @@ sal_uLong OutputDevice::GetColorCount() const { const sal_uInt16 nBitCount = GetBitCount(); - return( ( nBitCount > 31 ) ? ULONG_MAX : ( ( (sal_uLong) 1 ) << nBitCount) ); + return( ( nBitCount > 31 ) ? ULONG_MAX : ( ( sal_uLong(1) ) << nBitCount) ); } css::uno::Reference< css::awt::XGraphics > OutputDevice::CreateUnoGraphics() diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index ace13e036c86..91d051999258 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -363,8 +363,8 @@ BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ) } else { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast<double>( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast<double>( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); @@ -404,8 +404,8 @@ void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect } else { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? (double) ( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? (double) ( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast<double>( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast<double>( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index aa2d59cca441..e6426fc24278 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1286,7 +1286,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, mpFontInstance->mpConversion->RecodeString( aStr, 0, aStr.getLength() ); pLayoutCache = nullptr; // don't use cache with modified string! } - DeviceCoordinate nPixelWidth = (DeviceCoordinate)nLogicalWidth; + DeviceCoordinate nPixelWidth = static_cast<DeviceCoordinate>(nLogicalWidth); std::unique_ptr<DeviceCoordinate[]> xDXPixelArray; DeviceCoordinate* pDXPixelArray(nullptr); if( nLogicalWidth && mbMap ) @@ -1554,7 +1554,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta if ( nTextHeight ) { long nMaxTextWidth = ImplGetTextLines( aMultiLineInfo, nWidth, aStr, nStyle, _rLayout ); - nLines = (sal_Int32)(nHeight/nTextHeight); + nLines = static_cast<sal_Int32>(nHeight/nTextHeight); nFormatLines = aMultiLineInfo.Count(); if (nLines <= 0) nLines = 1; @@ -1847,7 +1847,7 @@ tools::Rectangle OutputDevice::GetTextRect( const tools::Rectangle& rRect, nFormatLines = aMultiLineInfo.Count(); if ( !nTextHeight ) nTextHeight = 1; - nLines = (sal_uInt16)(aRect.GetHeight()/nTextHeight); + nLines = static_cast<sal_uInt16>(aRect.GetHeight()/nTextHeight); if ( pInfo ) pInfo->mnLineCount = nFormatLines; if ( !nLines ) @@ -2147,7 +2147,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr, /*sal_Bool bRet =*/ GetCaretPositions( aStr, pCaretXArray.get(), nIndex, nLen ); long lc_x1 = pCaretXArray[ 2*(nMnemonicPos - nIndex) ]; long lc_x2 = pCaretXArray[ 2*(nMnemonicPos - nIndex)+1 ]; - nMnemonicWidth = ::abs((int)(lc_x1 - lc_x2)); + nMnemonicWidth = ::abs(static_cast<int>(lc_x1 - lc_x2)); Point aTempPos( std::min(lc_x1,lc_x2), GetFontMetric().GetAscent() ); if( bInvalidPos ) // #106952#, place behind the (last) character @@ -2235,7 +2235,7 @@ long OutputDevice::GetCtrlTextWidth( const OUString& rStr ) const { if ( nMnemonicPos < nIndex ) nIndex--; - else if ( (nMnemonicPos >= nIndex) && ((sal_uLong)nMnemonicPos < (sal_uLong)(nIndex+nLen)) ) + else if ( (nMnemonicPos >= nIndex) && (static_cast<sal_uLong>(nMnemonicPos) < static_cast<sal_uLong>(nIndex+nLen)) ) nLen--; } return GetTextWidth( aStr, nIndex, nLen ); diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index e781a8a9a76e..862d979e020f 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -1006,7 +1006,7 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos ) long nDX = nEndX - nStartX; double nO = atan2( -nEndY + nStartY, ((nDX == 0) ? 0.000000001 : nDX) ); nO /= F_PI1800; - nOrientation = (short)nO; + nOrientation = static_cast<short>(nO); aStartPt.RotateAround( nEndX, nEndY, -nOrientation ); } diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index 764389dcbe78..2ad9618ab216 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -182,10 +182,10 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask // create forward mapping tables for( nX = 0; nX <= nSrcWidth; nX++ ) - pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth ); + pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth ); for( nY = 0; nY <= nSrcHeight; nY++ ) - pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight ); + pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight ); // walk through all rectangles of mask const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel()))); @@ -448,7 +448,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, { ScopedVclPtrInstance< VirtualDevice > aVDev(*this, DeviceFormat::BITMASK); const Size aDstSz( aDstRect.GetSize() ); - const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 ); + const sal_uInt8 cTrans = static_cast<sal_uInt8>(MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 )); if( aDstRect.Left() || aDstRect.Top() ) aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() ); @@ -493,7 +493,7 @@ void OutputDevice::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, for( sal_uInt16 i = 0; i < nCount; i++ ) { BitmapColor aCol( rPal[ i ] ); - pMap[ i ] = BitmapColor( (sal_uInt8) rPal.GetBestIndex( aCol.Merge( aFillCol, cTrans ) ) ); + pMap[ i ] = BitmapColor( static_cast<sal_uInt8>(rPal.GetBestIndex( aCol.Merge( aFillCol, cTrans ) )) ); } if( pR->GetScanlineFormat() == ScanlineFormat::N1BitMsbPal && diff --git a/vcl/source/window/accel.cxx b/vcl/source/window/accel.cxx index 801f69af0cd5..d81ea72838ea 100644 --- a/vcl/source/window/accel.cxx +++ b/vcl/source/window/accel.cxx @@ -28,7 +28,7 @@ typedef ::std::map< sal_uLong, ImplAccelEntry* > ImplAccelMap; typedef ::std::vector< ImplAccelEntry* > ImplAccelList; -#define ACCELENTRY_NOTFOUND ((sal_uInt16)0xFFFF) +#define ACCELENTRY_NOTFOUND (sal_uInt16(0xFFFF)) class ImplAccelData { @@ -68,7 +68,7 @@ sal_uInt16 ImplAccelEntryGetIndex( ImplAccelList* pList, sal_uInt16 nId, if ( nId > nCompareId ) nLow = nMid + 1; else - return (sal_uInt16)nMid; + return static_cast<sal_uInt16>(nMid); } } while ( nLow <= nHigh ); @@ -76,9 +76,9 @@ sal_uInt16 ImplAccelEntryGetIndex( ImplAccelList* pList, sal_uInt16 nId, if ( pIndex ) { if ( nId > nCompareId ) - *pIndex = (sal_uInt16)(nMid+1); + *pIndex = static_cast<sal_uInt16>(nMid+1); else - *pIndex = (sal_uInt16)nMid; + *pIndex = static_cast<sal_uInt16>(nMid); } return ACCELENTRY_NOTFOUND; @@ -262,7 +262,7 @@ void Accelerator::InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ) sal_uInt16 Accelerator::GetItemCount() const { - return (sal_uInt16)mpData->maIdList.size(); + return static_cast<sal_uInt16>(mpData->maIdList.size()); } sal_uInt16 Accelerator::GetItemId( sal_uInt16 nPos ) const diff --git a/vcl/source/window/debugevent.cxx b/vcl/source/window/debugevent.cxx index ba8cc2f1a8c2..59889e3720a0 100644 --- a/vcl/source/window/debugevent.cxx +++ b/vcl/source/window/debugevent.cxx @@ -103,7 +103,7 @@ void DebugEventInjector::InjectMenuEvent() std::vector< SalMenuEvent > aIds; CollectMenuItemIds( pMenuBar, aIds ); - SalEvent nEvent = nEvents[ (int)(getRandom() * SAL_N_ELEMENTS( nEvents )) ]; + SalEvent nEvent = nEvents[ static_cast<int>(getRandom() * SAL_N_ELEMENTS( nEvents )) ]; SalMenuEvent aEvent = aIds[ getRandom() * aIds.size() ]; bool bHandled = ImplWindowFrameProc( pSysWin, nEvent, &aEvent); @@ -153,12 +153,12 @@ void DebugEventInjector::InjectTextEvent() } if( getRandom() < 0.05 ) // modifier - aKeyEvent.mnCode |= (sal_uInt16)( getRandom() * KEY_MODIFIERS_MASK ) & KEY_MODIFIERS_MASK; + aKeyEvent.mnCode |= static_cast<sal_uInt16>( getRandom() * KEY_MODIFIERS_MASK ) & KEY_MODIFIERS_MASK; bool bHandled = ImplWindowFrameProc( pWindow, SalEvent::KeyInput, &aKeyEvent); SAL_INFO( "vcl.debugevent", - "Injected key 0x" << std::hex << (int) aKeyEvent.mnCode << std::dec + "Injected key 0x" << std::hex << static_cast<int>(aKeyEvent.mnCode) << std::dec << " -> " << bHandled << " win " << pWindow ); @@ -233,14 +233,14 @@ void DebugEventInjector::InjectKeyNavEdit() aKeyEvent.mnCode = nKey; if (getRandom() < 0.15) // modifier - aKeyEvent.mnCode |= (sal_uInt16)(getRandom() * KEY_MODIFIERS_MASK) & KEY_MODIFIERS_MASK; + aKeyEvent.mnCode |= static_cast<sal_uInt16>(getRandom() * KEY_MODIFIERS_MASK) & KEY_MODIFIERS_MASK; aKeyEvent.mnCharCode = 0x0; // hopefully unused. bool bHandled = ImplWindowFrameProc( pWindow, SalEvent::KeyInput, &aKeyEvent ); SAL_INFO( "vcl.debugevent", - "Injected edit / move key 0x" << std::hex << (int) aKeyEvent.mnCode << std::dec + "Injected edit / move key 0x" << std::hex << static_cast<int>(aKeyEvent.mnCode) << std::dec << " -> " << bHandled << " win " << pWindow ); ImplWindowFrameProc( pWindow, SalEvent::KeyUp, &aKeyEvent ); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index c247a9e50301..abd858860758 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -945,7 +945,7 @@ short Dialog::Execute() long nRet = mpDialogImpl->mnResult; mpDialogImpl->mnResult = -1; - return (short)nRet; + return static_cast<short>(nRet); #else diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 368008bb91d6..7079cd01a79b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -606,7 +606,7 @@ void Menu::Clear() sal_uInt16 Menu::GetItemCount() const { - return (sal_uInt16)pItemList->size(); + return static_cast<sal_uInt16>(pItemList->size()); } sal_uInt16 Menu::ImplGetVisibleItemCount() const @@ -677,7 +677,7 @@ sal_uInt16 Menu::GetItemPos( sal_uInt16 nItemId ) const MenuItemData* pData = pItemList->GetData( nItemId, nPos ); if ( pData ) - return (sal_uInt16)nPos; + return static_cast<sal_uInt16>(nPos); else return MENU_ITEM_NOTFOUND; } @@ -1585,15 +1585,15 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) if( nMaxWidth > nScreenWidth/2 ) nMaxWidth = nScreenWidth/2; - sal_uInt16 gfxExtra = (sal_uInt16) std::max( nExtra, 7L ); // #107710# increase space between checkmarks/images/text - nImgOrChkPos = (sal_uInt16)nExtra; + sal_uInt16 gfxExtra = static_cast<sal_uInt16>(std::max( nExtra, 7L )); // #107710# increase space between checkmarks/images/text + nImgOrChkPos = static_cast<sal_uInt16>(nExtra); long nImgOrChkWidth = 0; if( aMaxSize.Height() > 0 ) // NWF case nImgOrChkWidth = aMaxSize.Height() + nExtra; else // non NWF case nImgOrChkWidth = nFontHeight/2 + gfxExtra; nImgOrChkWidth = std::max( nImgOrChkWidth, aMaxImgSz.Width() + gfxExtra ); - nTextPos = (sal_uInt16)(nImgOrChkPos + nImgOrChkWidth); + nTextPos = static_cast<sal_uInt16>(nImgOrChkPos + nImgOrChkWidth); nTextPos = nTextPos + gfxExtra; aSz.Width() = nTextPos + nMaxWidth + nExtra; @@ -1604,7 +1604,7 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) } else { - nTextPos = (sal_uInt16)(2*nExtra); + nTextPos = static_cast<sal_uInt16>(2*nExtra); aSz.Height() = nFontHeight+6; // get menubar height from native methods if supported @@ -3047,7 +3047,7 @@ long PopupMenu::ImplCalcHeight( sal_uInt16 nEntries ) const sal_uInt16 nFound = 0; for ( size_t n = 0; ( nFound < nEntries ) && ( n < pItemList->size() ); n++ ) { - if ( ImplIsVisible( (sal_uInt16) n ) ) + if ( ImplIsVisible( static_cast<sal_uInt16>(n) ) ) { MenuItemData* pData = pItemList->GetDataFromPos( n ); nHeight += pData->aSz.Height(); diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index cb14f3fba94f..09e176930b96 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -782,7 +782,7 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) sal_uInt16 nLoop = n; if( nCode == KEY_HOME ) - { n = (sal_uInt16)-1; nLoop = n+1; } + { n = sal_uInt16(-1); nLoop = n+1; } if( nCode == KEY_END ) { n = pMenu->GetItemCount(); nLoop = n-1; } @@ -996,7 +996,7 @@ sal_uInt16 MenuBarWindow::ImplFindEntry( const Point& rMousePos ) const { nX += pData->aSz.Width(); if ( nX > rMousePos.X() ) - return (sal_uInt16)n; + return static_cast<sal_uInt16>(n); } } } diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index c66510cf8f1a..b019906f3b0c 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -229,7 +229,7 @@ void MenuFloatingWindow::ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDow { if ( n != nHighlightedItem ) { - ChangeHighlightItem( (sal_uInt16)n, false ); + ChangeHighlightItem( static_cast<sal_uInt16>(n), false ); } bool bAllowNewPopup = true; @@ -250,7 +250,7 @@ void MenuFloatingWindow::ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDow { if ( n != nHighlightedItem ) { - ChangeHighlightItem( (sal_uInt16)n, true ); + ChangeHighlightItem( static_cast<sal_uInt16>(n), true ); } else if ( pItemData->nBits & MenuItemBits::POPUPSELECT ) { @@ -388,7 +388,7 @@ IMPL_LINK( MenuFloatingWindow, ShowHideListener, VclWindowEvent&, rEvent, void ) void MenuFloatingWindow::EnableScrollMenu( bool b ) { bScrollMenu = b; - nScrollerHeight = b ? (sal_uInt16) GetSettings().GetStyleSettings().GetScrollBarSize() /2 : 0; + nScrollerHeight = b ? static_cast<sal_uInt16>(GetSettings().GetStyleSettings().GetScrollBarSize()) /2 : 0; bScrollDown = true; InitMenuClipRegion(*this); } @@ -941,7 +941,7 @@ void MenuFloatingWindow::ImplCursorUpDown( bool bUp, bool bHomeEnd ) } else { - n = (sal_uInt16)-1; + n = sal_uInt16(-1); nLoop = n+1; } } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index b3f2639d9251..c7361e03094c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -147,7 +147,7 @@ void PrintDialog::PrintPreviewWindow::Resize() // quality of the preview, e.g. when its height approaches the number of text lines // find a good scaling factor - double aAspectRatio = aScaledSize.Height() / (double) aScaledSize.Width(); + double aAspectRatio = aScaledSize.Height() / static_cast<double>(aScaledSize.Width()); aScaledSize.Width() = PREVIEW_BITMAP_WIDTH; aScaledSize.Height() = PREVIEW_BITMAP_WIDTH * aAspectRatio; diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx index 7077b800db3a..b256c263204c 100644 --- a/vcl/source/window/scrwnd.cxx +++ b/vcl/source/window/scrwnd.cxx @@ -54,7 +54,7 @@ ImplWheelWindow::ImplWheelWindow( vcl::Window* pParent ) : const bool bVert( nFlags & StartAutoScrollFlags::Vert ); // calculate maximum speed distance - mnMaxWidth = (sal_uLong) ( 0.4 * hypot( (double) aSize.Width(), aSize.Height() ) ); + mnMaxWidth = static_cast<sal_uLong>( 0.4 * hypot( static_cast<double>(aSize.Width()), aSize.Height() ) ); // create wheel window SetTitleType( FloatWinTitleType::NONE ); @@ -193,8 +193,8 @@ void ImplWheelWindow::ImplRecalcScrollValues() // calc current time if( mnMaxWidth ) { - const double fExp = ( (double) mnActDist / mnMaxWidth ) * log10( (double) MAX_TIME / MIN_TIME ); - nCurTime = (sal_uInt64) ( MAX_TIME / pow( 10., fExp ) ); + const double fExp = ( static_cast<double>(mnActDist) / mnMaxWidth ) * log10( double(MAX_TIME) / MIN_TIME ); + nCurTime = static_cast<sal_uInt64>( MAX_TIME / pow( 10., fExp ) ); } else nCurTime = MAX_TIME; @@ -213,22 +213,22 @@ void ImplWheelWindow::ImplRecalcScrollValues() else mnTimeout = ++nMult * nCurTime - mnRepaintTime; - double fValX = (double) mnActDeltaX * nMult; - double fValY = (double) mnActDeltaY * nMult; + double fValX = static_cast<double>(mnActDeltaX) * nMult; + double fValY = static_cast<double>(mnActDeltaY) * nMult; if( fValX > LONG_MAX ) mnActDeltaX = LONG_MAX; else if( fValX < LONG_MIN ) mnActDeltaX = LONG_MIN; else - mnActDeltaX = (long) fValX; + mnActDeltaX = static_cast<long>(fValX); if( fValY > LONG_MAX ) mnActDeltaY = LONG_MAX; else if( fValY < LONG_MIN ) mnActDeltaY = LONG_MIN; else - mnActDeltaY = (long) fValY; + mnActDeltaY = static_cast<long>(fValY); } } } @@ -253,7 +253,7 @@ PointerStyle ImplWheelWindow::ImplGetMousePointer( long nDistX, long nDistY ) } else { - double fAngle = atan2( (double) -nDistY, nDistX ) / F_PI180; + double fAngle = atan2( static_cast<double>(-nDistY), nDistX ) / F_PI180; if( fAngle < 0.0 ) fAngle += 360.; @@ -312,7 +312,7 @@ void ImplWheelWindow::MouseMove( const MouseEvent& rMEvt ) const long nDistX = aMousePos.X() - maCenter.X(); const long nDistY = aMousePos.Y() - maCenter.Y(); - mnActDist = (sal_uLong) hypot( (double) nDistX, nDistY ); + mnActDist = static_cast<sal_uLong>(hypot( static_cast<double>(nDistX), nDistY )); const PointerStyle eActStyle = ImplGetMousePointer( nDistX, nDistY ); const StartAutoScrollFlags nFlags = ImplGetSVData()->maWinData.mnAutoScrollFlags; @@ -376,7 +376,7 @@ IMPL_LINK_NOARG(ImplWheelWindow, ImplScrollHdl, Timer *, void) pWindow->Command( aCEvt ); if( xWin->IsDisposed() ) return; - mnRepaintTime = std::max( tools::Time::GetSystemTicks() - nTime, (sal_uInt64)1 ); + mnRepaintTime = std::max( tools::Time::GetSystemTicks() - nTime, sal_uInt64(1) ); ImplRecalcScrollValues(); } } diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx index e3607daf7b31..23b11f52ffe4 100644 --- a/vcl/source/window/splitwin.cxx +++ b/vcl/source/window/splitwin.cxx @@ -42,10 +42,10 @@ #define SPLITWIN_SPLITSIZEAUTOHIDE 72 #define SPLITWIN_SPLITSIZEFADE 72 -#define SPLIT_HORZ ((sal_uInt16)0x0001) -#define SPLIT_VERT ((sal_uInt16)0x0002) -#define SPLIT_WINDOW ((sal_uInt16)0x0004) -#define SPLIT_NOSPLIT ((sal_uInt16)0x8000) +#define SPLIT_HORZ (sal_uInt16(0x0001)) +#define SPLIT_VERT (sal_uInt16(0x0002)) +#define SPLIT_WINDOW (sal_uInt16(0x0004)) +#define SPLIT_NOSPLIT (sal_uInt16(0x8000)) class ImplSplitItem { @@ -524,7 +524,7 @@ static void ImplCalcSet( ImplSplitSet* pSet, } } // do not compensate rounding errors here - if ( (nAbsItems < (sal_uInt16)(std::abs( nSizeDelta ))) && nSizeWinSize ) + if ( (nAbsItems < static_cast<sal_uInt16>(std::abs( nSizeDelta ))) && nSizeWinSize ) { long nNewSizeWinSize = 0; diff --git a/vcl/source/window/stacking.cxx b/vcl/source/window/stacking.cxx index a3a238ee2c7c..eacf642fd4dd 100644 --- a/vcl/source/window/stacking.cxx +++ b/vcl/source/window/stacking.cxx @@ -625,7 +625,7 @@ bool Window::IsTopWindow() const return false; ImplGetWinData(); - if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0) // still uninitialized + if( mpWindowImpl->mpWinData->mnIsTopWindow == sal_uInt16(~0)) // still uninitialized { // #113722#, cache result of expensive queryInterface call vcl::Window *pThisWin = const_cast<vcl::Window*>(this); diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 11a2480323ff..82f9ab0aae2d 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -929,7 +929,7 @@ void StatusBar::InsertItem( sal_uInt16 nItemId, sal_uLong nWidth, ImplStatusItem* pItem = new ImplStatusItem; pItem->mnId = nItemId; pItem->mnBits = nBits; - pItem->mnWidth = (long)nWidth+nFudge+STATUSBAR_OFFSET; + pItem->mnWidth = static_cast<long>(nWidth)+nFudge+STATUSBAR_OFFSET; pItem->mnOffset = nOffset; pItem->mpUserData = nullptr; pItem->mbVisible = true; @@ -1031,7 +1031,7 @@ void StatusBar::Clear() sal_uInt16 StatusBar::GetItemCount() const { - return (sal_uInt16)mpItemList.size(); + return static_cast<sal_uInt16>(mpItemList.size()); } sal_uInt16 StatusBar::GetItemId( sal_uInt16 nPos ) const diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 28a9924b0203..351a90c8cc2b 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -707,15 +707,15 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData ) if( std::abs(g.nX-aState.mnX) < 2 && std::abs(g.nY-aState.mnY) < 5 ) { long displacement = g.nTopDecoration ? g.nTopDecoration : 20; - if( (unsigned long) (aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > (unsigned long) aDesktop.Right() || - (unsigned long) (aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > (unsigned long) aDesktop.Bottom() ) + if( static_cast<unsigned long>(aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > static_cast<unsigned long>(aDesktop.Right()) || + static_cast<unsigned long>(aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > static_cast<unsigned long>(aDesktop.Bottom()) ) { // displacing would leave screen aState.mnX = g.nLeftDecoration ? g.nLeftDecoration : 10; // should result in (0,0) aState.mnY = displacement; if( bWrapped || - (unsigned long) (aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > (unsigned long) aDesktop.Right() || - (unsigned long) (aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > (unsigned long) aDesktop.Bottom() ) + static_cast<unsigned long>(aState.mnX + displacement + aState.mnWidth + g.nRightDecoration) > static_cast<unsigned long>(aDesktop.Right()) || + static_cast<unsigned long>(aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration) > static_cast<unsigned long>(aDesktop.Bottom()) ) break; // further displacement not possible -> break // avoid endless testing bWrapped = true; @@ -775,11 +775,11 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData ) const SalFrameGeometry& rGeom = pWindow->mpWindowImpl->mpFrame->GetGeometry(); if( nX < 0 ) nX = 0; - if( nX + nWidth > (long) rGeom.nWidth ) + if( nX + nWidth > static_cast<long>(rGeom.nWidth) ) nX = rGeom.nWidth - nWidth; if( nY < 0 ) nY = 0; - if( nY + nHeight > (long) rGeom.nHeight ) + if( nY + nHeight > static_cast<long>(rGeom.nHeight) ) nY = rGeom.nHeight - nHeight; setPosSizePixel( nX, nY, nWidth, nHeight, nPosSize ); maOrgSize = Size( nWidth, nHeight ); diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index d473684fd0bb..aa4e65fab4a2 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -75,12 +75,12 @@ #define TB_WBLINESIZING (WB_SIZEABLE | WB_DOCKABLE | WB_SCROLL) -#define DOCK_LINEHSIZE ((sal_uInt16)0x0001) -#define DOCK_LINEVSIZE ((sal_uInt16)0x0002) -#define DOCK_LINERIGHT ((sal_uInt16)0x1000) -#define DOCK_LINEBOTTOM ((sal_uInt16)0x2000) -#define DOCK_LINELEFT ((sal_uInt16)0x4000) -#define DOCK_LINETOP ((sal_uInt16)0x8000) +#define DOCK_LINEHSIZE (sal_uInt16(0x0001)) +#define DOCK_LINEVSIZE (sal_uInt16(0x0002)) +#define DOCK_LINERIGHT (sal_uInt16(0x1000)) +#define DOCK_LINEBOTTOM (sal_uInt16(0x2000)) +#define DOCK_LINELEFT (sal_uInt16(0x4000)) +#define DOCK_LINETOP (sal_uInt16(0x8000)) #define DOCK_LINEOFFSET 3 class ImplTBDragMgr @@ -266,7 +266,7 @@ void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext, if (eAlign == WindowAlign::Top || eAlign == WindowAlign::Bottom) { - int height = (int) (0.6 * aSz.Height() + 0.5); + int height = static_cast<int>(0.6 * aSz.Height() + 0.5); int i = (aSz.Height() - height) / 2; height += i; while (i <= height) @@ -278,7 +278,7 @@ void ToolBox::ImplDrawGrip(vcl::RenderContext& rRenderContext, } else { - int width = (int) (0.6 * aSz.Width() + 0.5); + int width = static_cast<int>(0.6 * aSz.Width() + 0.5); int i = (aSz.Width() - width) / 2; width += i; while (i <= width) @@ -4360,7 +4360,7 @@ Size ToolBox::CalcPopupWindowSizePixel() else { // no breaks found: use quadratic layout - nLines = (ImplToolItems::size_type) ceil( sqrt( (double) GetItemCount() ) ); + nLines = static_cast<ImplToolItems::size_type>(ceil( sqrt( static_cast<double>(GetItemCount()) ) )); } bool bPopup = mpData->mbAssumePopupMode; diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index a17a7e3a214a..3dc940ecb00e 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -759,7 +759,7 @@ ImplWinData::ImplWinData() : mpFocusRect(nullptr), mpTrackRect(nullptr), mnTrackFlags(ShowTrackFlags::NONE), - mnIsTopWindow((sal_uInt16) ~0), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) + mnIsTopWindow(sal_uInt16(~0)), // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow()) mbMouseOver(false), mbEnableNativeWidget(false) { diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 4e38bcaba259..5c8e043da580 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -438,7 +438,7 @@ void Window::SetZoom( const Fraction& rZoom ) inline long WinFloatRound( double fVal ) { - return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) ); + return( fVal > 0.0 ? static_cast<long>( fVal + 0.5 ) : -static_cast<long>( -fVal + 0.5 ) ); } void Window::SetZoomedPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) @@ -663,7 +663,7 @@ static void lcl_HandleScrollHelper( ScrollBar* pScrl, double nN, bool isMultiply else if ( fVal > LONG_MAX ) nNewPos = LONG_MAX; else - nNewPos = (long)fVal; + nNewPos = static_cast<long>(fVal); } pScrl->DoScroll( nNewPos ); diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index ad4c6920a738..4675ea801b3d 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -867,7 +867,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, nVCLEvent = VclEventId::NONE; break; } - KeyEvent aKeyEvent((sal_Unicode)nCharCode, aKeyCode, nRepeat); + KeyEvent aKeyEvent(static_cast<sal_Unicode>(nCharCode), aKeyCode, nRepeat); if (nVCLEvent != VclEventId::NONE && Application::HandleKey(nVCLEvent, pWindow, &aKeyEvent)) return true; } @@ -878,7 +878,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, if( Application::GetSettings().GetMiscSettings().GetEnableLocalizedDecimalSep() ) { OUString aSep( pWindow->GetSettings().GetLocaleDataWrapper().getNumDecimalSep() ); - nCharCode = (sal_uInt16) aSep[0]; + nCharCode = static_cast<sal_uInt16>(aSep[0]); } } @@ -972,7 +972,7 @@ static bool ImplHandleKey( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, pChildOutDev->HasMirroredGraphics() && pChild->IsRTLEnabled() ) aKeyCode = vcl::KeyCode( aKeyCode.GetCode() == KEY_LEFT ? KEY_RIGHT : KEY_LEFT, aKeyCode.GetModifier() ); - KeyEvent aKeyEvt( (sal_Unicode)nCharCode, aKeyCode, nRepeat ); + KeyEvent aKeyEvt( static_cast<sal_Unicode>(nCharCode), aKeyCode, nRepeat ); NotifyEvent aNotifyEvt( nSVEvent, pChild, &aKeyEvt ); bool bKeyPreNotify = ImplCallPreNotify( aNotifyEvt ); bool bRet = true; diff --git a/vcl/unx/generic/app/i18n_cb.cxx b/vcl/unx/generic/app/i18n_cb.cxx index b56922f82f40..b62f5306de04 100644 --- a/vcl/unx/generic/app/i18n_cb.cxx +++ b/vcl/unx/generic/app/i18n_cb.cxx @@ -83,13 +83,13 @@ Preedit_DeleteText(preedit_text_t *ptext, int from, int howmuch) int to = from + howmuch; - if (to == (int)ptext->nLength) + if (to == static_cast<int>(ptext->nLength)) { // delete from the end of the text ptext->nLength = from; } else - if (to < (int)ptext->nLength) + if (to < static_cast<int>(ptext->nLength)) { // cut out of the middle of the text memmove( static_cast<void*>(ptext->pUnicodeBuffer + from), @@ -121,7 +121,7 @@ enlarge_buffer ( preedit_text_t *ptext, int nnewlimit ) { size_t nnewsize = ptext->nSize; - while ( nnewsize <= (size_t)nnewlimit ) + while ( nnewsize <= static_cast<size_t>(nnewlimit) ) nnewsize *= 2; ptext->nSize = nnewsize; @@ -228,7 +228,7 @@ void Preedit_UpdateAttributes ( preedit_text_t* ptext, XIMFeedback const * feedback, int from, int amount ) { - if ( (from + amount) > (int)ptext->nLength ) + if ( (from + amount) > static_cast<int>(ptext->nLength) ) { // XXX this indicates an error, are we out of sync ? fprintf (stderr, "Preedit_UpdateAttributes( %i + %i > %i )\n", diff --git a/vcl/unx/generic/app/i18n_keysym.cxx b/vcl/unx/generic/app/i18n_keysym.cxx index fa263f20577b..9fdbe9eae3b3 100644 --- a/vcl/unx/generic/app/i18n_keysym.cxx +++ b/vcl/unx/generic/app/i18n_keysym.cxx @@ -324,7 +324,7 @@ KeysymToUnicode (KeySym nKeySym) // strip off group indicator and iso10646 plane // FIXME can't handle chars from surrogate area. if (! (nKeySym & 0x00ff0000) ) - return (sal_Unicode)(nKeySym & 0x0000ffff); + return static_cast<sal_Unicode>(nKeySym & 0x0000ffff); } // legacy keysyms, switch to appropriate codeset else diff --git a/vcl/unx/generic/app/i18n_status.cxx b/vcl/unx/generic/app/i18n_status.cxx index 81ce3a5450b2..301e7f85622e 100644 --- a/vcl/unx/generic/app/i18n_status.cxx +++ b/vcl/unx/generic/app/i18n_status.cxx @@ -195,7 +195,7 @@ Point XIMStatusWindow::updatePosition() int x, y; ::Window aChild; XTranslateCoordinates( static_cast<Display*>(pParentEnvData->pDisplay), - (::Window)pParentEnvData->aShellWindow, + static_cast<::Window>(pParentEnvData->aShellWindow), vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetRootWindow( vcl_sal::getSalDisplay(GetGenericUnixSalData())->GetDefaultXScreen() ), 0, 0, &x, &y, @@ -267,7 +267,7 @@ IMPL_LINK_NOARG(XIMStatusWindow, DelayedShowHdl, void*, void) if( m_bDelayedShow ) { XRaiseWindow( static_cast<Display*>(pData->pDisplay), - (::Window)pData->aShellWindow ); + static_cast<::Window>(pData->aShellWindow) ); } } diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index a0330bb7c1d8..767cf81aa239 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -94,16 +94,16 @@ inline const char *GetAtomName( Display *d, Atom a ) { return Null( XGetAtomName( d, a ) ); } inline double Hypothenuse( long w, long h ) -{ return sqrt( (double)((w*w)+(h*h)) ); } +{ return sqrt( static_cast<double>((w*w)+(h*h)) ); } #endif inline int ColorDiff( int r, int g, int b ) { return (r*r)+(g*g)+(b*b); } inline int ColorDiff( SalColor c1, int r, int g, int b ) -{ return ColorDiff( (int)SALCOLOR_RED (c1)-r, - (int)SALCOLOR_GREEN(c1)-g, - (int)SALCOLOR_BLUE (c1)-b ); } +{ return ColorDiff( static_cast<int>(SALCOLOR_RED (c1))-r, + static_cast<int>(SALCOLOR_GREEN(c1))-g, + static_cast<int>(SALCOLOR_BLUE (c1))-b ); } static int sal_Shift( Pixel nMask ) { @@ -588,7 +588,7 @@ void SalDisplay::Init() if( pValStr != nullptr ) { const OString aValStr( pValStr ); - const long nDPI = (long) aValStr.toDouble(); + const long nDPI = static_cast<long>(aValStr.toDouble()); // guard against insane resolution if( sal_ValidDPI(nDPI) ) { @@ -605,8 +605,8 @@ void SalDisplay::Init() long xDPI = 96; long yDPI = 96; if (m_aScreens.size() == 1) { - xDPI = (long)round(DisplayWidth(pDisp_, 0)*25.4/DisplayWidthMM(pDisp_, 0)); - yDPI = (long)round(DisplayHeight(pDisp_, 0)*25.4/DisplayHeightMM(pDisp_, 0)); + xDPI = static_cast<long>(round(DisplayWidth(pDisp_, 0)*25.4/DisplayWidthMM(pDisp_, 0))); + yDPI = static_cast<long>(round(DisplayHeight(pDisp_, 0)*25.4/DisplayHeightMM(pDisp_, 0))); // if either is invalid set it equal to the other if (!sal_ValidDPI(xDPI) && sal_ValidDPI(yDPI)) xDPI = yDPI; @@ -1026,22 +1026,22 @@ sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const sal_uInt16 nKey = 0; if( XK_a <= keysym && XK_z >= keysym ) - nKey = (sal_uInt16)(KEY_A + (keysym - XK_a)); + nKey = static_cast<sal_uInt16>(KEY_A + (keysym - XK_a)); else if( XK_A <= keysym && XK_Z >= keysym ) - nKey = (sal_uInt16)(KEY_A + (keysym - XK_A)); + nKey = static_cast<sal_uInt16>(KEY_A + (keysym - XK_A)); else if( XK_0 <= keysym && XK_9 >= keysym ) - nKey = (sal_uInt16)(KEY_0 + (keysym - XK_0)); + nKey = static_cast<sal_uInt16>(KEY_0 + (keysym - XK_0)); else if( IsModifierKey( keysym ) ) ; else if( IsKeypadKey( keysym ) ) { if( (keysym >= XK_KP_0) && (keysym <= XK_KP_9) ) { - nKey = (sal_uInt16)(KEY_0 + (keysym - XK_KP_0)); + nKey = static_cast<sal_uInt16>(KEY_0 + (keysym - XK_KP_0)); *pcPrintable = '0' + nKey - KEY_0; } else if( IsPFKey( keysym ) ) - nKey = (sal_uInt16)(KEY_F1 + (keysym - XK_KP_F1)); + nKey = static_cast<sal_uInt16>(KEY_F1 + (keysym - XK_KP_F1)); else switch( keysym ) { case XK_KP_Space: @@ -1120,7 +1120,7 @@ sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const if( bNumLockFromXS_ ) { if( keysym >= XK_F1 && keysym <= XK_F26 ) - nKey = (sal_uInt16)(KEY_F1 + keysym - XK_F1); + nKey = static_cast<sal_uInt16>(KEY_F1 + keysym - XK_F1); } else switch( keysym ) { @@ -1189,7 +1189,7 @@ sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const break; default: if( keysym >= XK_F1 && keysym <= XK_F26 ) - nKey = (sal_uInt16)(KEY_F1 + keysym - XK_F1); + nKey = static_cast<sal_uInt16>(KEY_F1 + keysym - XK_F1); break; } } @@ -1463,7 +1463,7 @@ KeySym SalDisplay::GetKeySym( XKeyEvent *pEvent, if ( (XK_space <= nKeySym) && (XK_asciitilde >= nKeySym) ) { *pLen = 1; - pPrintable[ 0 ] = (char)nKeySym; + pPrintable[ 0 ] = static_cast<char>(nKeySym); } break; case XLookupBoth: @@ -1869,7 +1869,7 @@ int SalDisplay::CaptureMouse( SalFrame *pCapture ) if( !pEnv || !*pEnv ) { int ret = XGrabPointer( GetDisplay(), - (::Window)pEnvData->aWindow, + static_cast<::Window>(pEnvData->aWindow), False, PointerMotionMask| ButtonPressMask|ButtonReleaseMask, GrabModeAsync, @@ -2455,7 +2455,7 @@ SalVisual::~SalVisual() SalColor SalVisual::GetTCColor( Pixel nPixel ) const { if( SALCOLOR == eRGBMode_ ) - return (SalColor)nPixel; + return static_cast<SalColor>(nPixel); if( SALCOLORREVERSE == eRGBMode_ ) return MAKE_SALCOLOR( (nPixel & 0x0000FF), @@ -2488,11 +2488,11 @@ SalColor SalVisual::GetTCColor( Pixel nPixel ) const Pixel SalVisual::GetTCPixel( SalColor nSalColor ) const { if( SALCOLOR == eRGBMode_ ) - return (Pixel)nSalColor; + return static_cast<Pixel>(nSalColor); - Pixel r = (Pixel)SALCOLOR_RED( nSalColor ); - Pixel g = (Pixel)SALCOLOR_GREEN( nSalColor ); - Pixel b = (Pixel)SALCOLOR_BLUE( nSalColor ); + Pixel r = static_cast<Pixel>(SALCOLOR_RED( nSalColor )); + Pixel g = static_cast<Pixel>(SALCOLOR_GREEN( nSalColor )); + Pixel b = static_cast<Pixel>(SALCOLOR_BLUE( nSalColor )); if( SALCOLORREVERSE == eRGBMode_ ) return (b << 16) | (g << 8) | r; @@ -2612,7 +2612,7 @@ SalColormap::SalColormap( sal_uInt16 nDepth ) &aVI ) ) { aVI.visual = new Visual; - aVI.visualid = (VisualID)0; // beware of temporary destructor below + aVI.visualid = VisualID(0); // beware of temporary destructor below aVI.screen = 0; aVI.depth = nDepth; aVI.c_class = TrueColor; @@ -2667,7 +2667,7 @@ SalColormap::SalColormap( sal_uInt16 nDepth ) m_aVisual = SalVisual( &aVI ); // give ownership of constructed Visual() to m_aVisual // see SalVisual destructor - m_aVisual.visualid = (VisualID)-1; + m_aVisual.visualid = VisualID(-1); m_aVisual.screen = -1; } else diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index 56e06f691c66..b21f35cdb8ab 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -455,7 +455,7 @@ NetWMAdaptor::NetWMAdaptor( SalDisplay* pSalDisplay ) : &nBytesLeft, &pProperty ) == 0 - && nItems == 4*(unsigned)m_nDesktops + && nItems == 4*static_cast<unsigned>(m_nDesktops) ) { m_aWMWorkAreas = ::std::vector< tools::Rectangle > ( m_nDesktops ); @@ -996,7 +996,7 @@ void WMAdaptor::setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const int nBytes = aProp.nitems ? aProp.nitems : aTitle.getLength(); const SystemEnvData* pEnv = pFrame->GetSystemData(); XChangeProperty( m_pDisplay, - (::Window)pEnv->aShellWindow, + static_cast<::Window>(pEnv->aShellWindow), XA_WM_NAME, nType, nFormat, @@ -1004,7 +1004,7 @@ void WMAdaptor::setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const pData, nBytes ); XChangeProperty( m_pDisplay, - (::Window)pEnv->aShellWindow, + static_cast<::Window>(pEnv->aShellWindow), XA_WM_ICON_NAME, nType, nFormat, @@ -1012,7 +1012,7 @@ void WMAdaptor::setWMName( X11SalFrame* pFrame, const OUString& rWMName ) const pData, nBytes ); XChangeProperty( m_pDisplay, - (::Window)pEnv->aShellWindow, + static_cast<::Window>(pEnv->aShellWindow), m_aWMAtoms[ WM_LOCALE_NAME ], XA_STRING, 8, @@ -1038,7 +1038,7 @@ void NetWMAdaptor::setWMName( X11SalFrame* pFrame, const OUString& rWMName ) con const SystemEnvData* pEnv = pFrame->GetSystemData(); if( m_aWMAtoms[ NET_WM_NAME ] ) XChangeProperty( m_pDisplay, - (::Window)pEnv->aShellWindow, + static_cast<::Window>(pEnv->aShellWindow), m_aWMAtoms[ NET_WM_NAME ], m_aWMAtoms[ UTF8_STRING ], 8, @@ -1047,7 +1047,7 @@ void NetWMAdaptor::setWMName( X11SalFrame* pFrame, const OUString& rWMName ) con aTitle.getLength() ); if( m_aWMAtoms[ NET_WM_ICON_NAME ] ) XChangeProperty( m_pDisplay, - (::Window)pEnv->aShellWindow, + static_cast<::Window>(pEnv->aShellWindow), m_aWMAtoms[ NET_WM_ICON_NAME ], m_aWMAtoms[ UTF8_STRING ], 8, @@ -2234,7 +2234,7 @@ void WMAdaptor::setPID( X11SalFrame const * i_pFrame ) const { if( m_aWMAtoms[NET_WM_PID] ) { - long nPID = (long)getpid(); + long nPID = static_cast<long>(getpid()); XChangeProperty( m_pDisplay, i_pFrame->GetShellWindow(), m_aWMAtoms[NET_WM_PID], @@ -2261,7 +2261,7 @@ void WMAdaptor::answerPing( X11SalFrame const * i_pFrame, XClientMessageEvent co { if( m_aWMAtoms[NET_WM_PING] && i_pEvent->message_type == m_aWMAtoms[ WM_PROTOCOLS ] && - (Atom)i_pEvent->data.l[0] == m_aWMAtoms[ NET_WM_PING ] ) + static_cast<Atom>(i_pEvent->data.l[0]) == m_aWMAtoms[ NET_WM_PING ] ) { XEvent aEvent; aEvent.xclient = *i_pEvent; diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index b85a144ccacb..605670ff3b7a 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -1428,12 +1428,12 @@ bool SelectionManager::sendData( SelectionAdaptor* pAdaptor, // handle colormap request if( target == XA_COLORMAP ) - nValue = (XID)pPixmap->getColormap(); + nValue = static_cast<XID>(pPixmap->getColormap()); else if( target == XA_VISUALID ) - nValue = (XID)pPixmap->getVisualID(); + nValue = static_cast<XID>(pPixmap->getVisualID()); else if( target == XA_PIXMAP || target == XA_BITMAP ) { - nValue = (XID)pPixmap->getPixmap(); + nValue = static_cast<XID>(pPixmap->getPixmap()); if( nValue == None ) { // first conversion @@ -1459,13 +1459,13 @@ bool SelectionManager::sendData( SelectionAdaptor* pAdaptor, // get pixmap again since clearing the guard could have invalidated // the pixmap in another thread pPixmap = getPixmapHolder( selection ); - nValue = (XID)pPixmap->setBitmapData( reinterpret_cast<const sal_uInt8*>(aData.getConstArray()) ); + nValue = static_cast<XID>(pPixmap->setBitmapData( reinterpret_cast<const sal_uInt8*>(aData.getConstArray()) )); } if( nValue == None ) return false; } if( target == XA_BITMAP ) - nValue = (XID)pPixmap->getBitmap(); + nValue = static_cast<XID>(pPixmap->getBitmap()); } XChangeProperty( m_pDisplay, @@ -1609,7 +1609,7 @@ bool SelectionManager::handleSelectionRequest( XSelectionRequestEvent& rRequest } else if( rRequest.target == m_nTIMESTAMPAtom ) { - long nTimeStamp = (long)m_aSelections[rRequest.selection]->m_nOrigTimestamp; + long nTimeStamp = static_cast<long>(m_aSelections[rRequest.selection]->m_nOrigTimestamp); XChangeProperty( m_pDisplay, rRequest.requestor, rRequest.property, XA_INTEGER, 32, PropModeReplace, reinterpret_cast<unsigned char*>(&nTimeStamp), 1 ); aNotify.xselection.property = rRequest.property; diff --git a/vcl/unx/generic/dtrans/bmp.cxx b/vcl/unx/generic/dtrans/bmp.cxx index ccc610cf6416..c72e93100eb4 100644 --- a/vcl/unx/generic/dtrans/bmp.cxx +++ b/vcl/unx/generic/dtrans/bmp.cxx @@ -160,13 +160,13 @@ static sal_uInt8* X11_getPaletteBmpFromImage( pBuffer[ 1 ] = 'M'; writeLE( nHeaderSize, pBuffer+10 ); - writeLE( (sal_uInt32)40, pBuffer+14 ); - writeLE( (sal_uInt32)pImage->width, pBuffer+18 ); - writeLE( (sal_uInt32)pImage->height, pBuffer+22 ); - writeLE( (sal_uInt16)1, pBuffer+26 ); + writeLE( sal_uInt32(40), pBuffer+14 ); + writeLE( static_cast<sal_uInt32>(pImage->width), pBuffer+18 ); + writeLE( static_cast<sal_uInt32>(pImage->height), pBuffer+22 ); + writeLE( sal_uInt16(1), pBuffer+26 ); writeLE( nBitCount, pBuffer+28 ); - writeLE( (sal_uInt32)(DisplayWidth(pDisplay,DefaultScreen(pDisplay))*1000/DisplayWidthMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+38); - writeLE( (sal_uInt32)(DisplayHeight(pDisplay,DefaultScreen(pDisplay))*1000/DisplayHeightMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+42); + writeLE( static_cast<sal_uInt32>(DisplayWidth(pDisplay,DefaultScreen(pDisplay))*1000/DisplayWidthMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+38); + writeLE( static_cast<sal_uInt32>(DisplayHeight(pDisplay,DefaultScreen(pDisplay))*1000/DisplayHeightMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+42); writeLE( nColors, pBuffer+46 ); writeLE( nColors, pBuffer+50 ); @@ -181,9 +181,9 @@ static sal_uInt8* X11_getPaletteBmpFromImage( XQueryColors( pDisplay, aColormap, aColors, nColors ); for( sal_uInt32 i = 0; i < nColors; i++ ) { - pBuffer[ 54 + i*4 ] = (sal_uInt8)(aColors[i].blue >> 8); - pBuffer[ 55 + i*4 ] = (sal_uInt8)(aColors[i].green >> 8); - pBuffer[ 56 + i*4 ] = (sal_uInt8)(aColors[i].red >> 8); + pBuffer[ 54 + i*4 ] = static_cast<sal_uInt8>(aColors[i].blue >> 8); + pBuffer[ 55 + i*4 ] = static_cast<sal_uInt8>(aColors[i].green >> 8); + pBuffer[ 56 + i*4 ] = static_cast<sal_uInt8>(aColors[i].red >> 8); } // done @@ -273,17 +273,17 @@ static sal_uInt8* X11_getTCBmpFromImage( { unsigned long nPixel = XGetPixel( pImage, x, y ); - sal_uInt8 nValue = (sal_uInt8)doRightShift( nPixel&aVInfo.blue_mask, nBlueShift); + sal_uInt8 nValue = static_cast<sal_uInt8>(doRightShift( nPixel&aVInfo.blue_mask, nBlueShift)); if( nBlueShift2 ) nValue |= (nValue >> nBlueShift2 ); *pScanline++ = nValue; - nValue = (sal_uInt8)doRightShift( nPixel&aVInfo.green_mask, nGreenShift); + nValue = static_cast<sal_uInt8>(doRightShift( nPixel&aVInfo.green_mask, nGreenShift)); if( nGreenShift2 ) nValue |= (nValue >> nGreenShift2 ); *pScanline++ = nValue; - nValue = (sal_uInt8)doRightShift( nPixel&aVInfo.red_mask, nRedShift); + nValue = static_cast<sal_uInt8>(doRightShift( nPixel&aVInfo.red_mask, nRedShift)); if( nRedShift2 ) nValue |= (nValue >> nRedShift2 ); *pScanline++ = nValue; @@ -295,13 +295,13 @@ static sal_uInt8* X11_getTCBmpFromImage( pBuffer[ 1 ] = 'M'; writeLE( nHeaderSize, pBuffer+10 ); - writeLE( (sal_uInt32)40, pBuffer+14 ); - writeLE( (sal_uInt32)pImage->width, pBuffer+18 ); - writeLE( (sal_uInt32)pImage->height, pBuffer+22 ); - writeLE( (sal_uInt16)1, pBuffer+26 ); - writeLE( (sal_uInt16)24, pBuffer+28 ); - writeLE( (sal_uInt32)(DisplayWidth(pDisplay,DefaultScreen(pDisplay))*1000/DisplayWidthMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+38); - writeLE( (sal_uInt32)(DisplayHeight(pDisplay,DefaultScreen(pDisplay))*1000/DisplayHeightMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+42); + writeLE( sal_uInt32(40), pBuffer+14 ); + writeLE( static_cast<sal_uInt32>(pImage->width), pBuffer+18 ); + writeLE( static_cast<sal_uInt32>(pImage->height), pBuffer+22 ); + writeLE( sal_uInt16(1), pBuffer+26 ); + writeLE( sal_uInt16(24), pBuffer+28 ); + writeLE( static_cast<sal_uInt32>(DisplayWidth(pDisplay,DefaultScreen(pDisplay))*1000/DisplayWidthMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+38); + writeLE( static_cast<sal_uInt32>(DisplayHeight(pDisplay,DefaultScreen(pDisplay))*1000/DisplayHeightMM(pDisplay,DefaultScreen(pDisplay))), pBuffer+42); // done @@ -407,9 +407,9 @@ PixmapHolder::PixmapHolder( Display* pDisplay ) getShift( m_aInfo.green_mask, m_nGreenShift, nGreenSig, m_nGreenShift2 ); getShift( m_aInfo.blue_mask, m_nBlueShift, nBlueSig, m_nBlueShift2 ); - m_nBlueShift2Mask = m_nBlueShift2 ? ~((unsigned long)((1<<m_nBlueShift2)-1)) : ~0L; - m_nGreenShift2Mask = m_nGreenShift2 ? ~((unsigned long)((1<<m_nGreenShift2)-1)) : ~0L; - m_nRedShift2Mask = m_nRedShift2 ? ~((unsigned long)((1<<m_nRedShift2)-1)) : ~0L; + m_nBlueShift2Mask = m_nBlueShift2 ? ~static_cast<unsigned long>((1<<m_nBlueShift2)-1) : ~0L; + m_nGreenShift2Mask = m_nGreenShift2 ? ~static_cast<unsigned long>((1<<m_nGreenShift2)-1) : ~0L; + m_nRedShift2Mask = m_nRedShift2 ? ~static_cast<unsigned long>((1<<m_nRedShift2)-1) : ~0L; } } @@ -424,15 +424,15 @@ PixmapHolder::~PixmapHolder() unsigned long PixmapHolder::getTCPixel( sal_uInt8 r, sal_uInt8 g, sal_uInt8 b ) const { unsigned long nPixel = 0; - unsigned long nValue = (unsigned long)b; + unsigned long nValue = static_cast<unsigned long>(b); nValue &= m_nBlueShift2Mask; nPixel |= doLeftShift( nValue, m_nBlueShift ); - nValue = (unsigned long)g; + nValue = static_cast<unsigned long>(g); nValue &= m_nGreenShift2Mask; nPixel |= doLeftShift( nValue, m_nGreenShift ); - nValue = (unsigned long)r; + nValue = static_cast<unsigned long>(r); nValue &= m_nRedShift2Mask; nPixel |= doLeftShift( nValue, m_nRedShift ); @@ -457,17 +457,17 @@ void PixmapHolder::setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage //so, using a byte-swapping pattern which coverity doesn't //detect as such //http://security.coverity.com/blog/2014/Apr/on-detecting-heartbleed-with-static-analysis.html - aPalette[i].red = ((unsigned short)pData[42 + i*4]); + aPalette[i].red = static_cast<unsigned short>(pData[42 + i*4]); aPalette[i].red <<= 8; - aPalette[i].red |= ((unsigned short)pData[42 + i*4]); + aPalette[i].red |= static_cast<unsigned short>(pData[42 + i*4]); - aPalette[i].green = ((unsigned short)pData[41 + i*4]); + aPalette[i].green = static_cast<unsigned short>(pData[41 + i*4]); aPalette[i].green <<= 8; - aPalette[i].green |= ((unsigned short)pData[41 + i*4]); + aPalette[i].green |= static_cast<unsigned short>(pData[41 + i*4]); - aPalette[i].blue = ((unsigned short)pData[40 + i*4]); + aPalette[i].blue = static_cast<unsigned short>(pData[40 + i*4]); aPalette[i].blue <<= 8; - aPalette[i].blue |= ((unsigned short)pData[40 + i*4]); + aPalette[i].blue |= static_cast<unsigned short>(pData[40 + i*4]); XAllocColor( m_pDisplay, m_aColormap, aPalette+i ); } else @@ -507,11 +507,11 @@ void PixmapHolder::setBitmapDataPalette( const sal_uInt8* pData, XImage* pImage case 1: nCol = (pScanline[ x/8 ] & (0x80 >> (x&7))) != 0 ? 0 : 1; break; case 4: if( x & 1 ) - nCol = (int)(pScanline[ x/2 ] >> 4); + nCol = static_cast<int>(pScanline[ x/2 ] >> 4); else - nCol = (int)(pScanline[ x/2 ] & 0x0f); + nCol = static_cast<int>(pScanline[ x/2 ] & 0x0f); break; - case 8: nCol = (int)pScanline[x]; + case 8: nCol = static_cast<int>(pScanline[x]); } XPutPixel( pImage, x, y, aPalette[nCol].pixel ); } @@ -547,14 +547,14 @@ void PixmapHolder::setBitmapDataTCDither( const sal_uInt8* pData, XImage* pImage int nColors = 1 << m_aInfo.depth; int i; for( i = 0; i < nColors; i++ ) - aRealPalette[i].pixel = (unsigned long)i; + aRealPalette[i].pixel = static_cast<unsigned long>(i); XQueryColors( m_pDisplay, m_aColormap, aRealPalette, nColors ); for( i = 0; i < nColors; i++ ) { sal_uInt8 nIndex = - 36*(sal_uInt8)(aRealPalette[i].red/10923) + - 6*(sal_uInt8)(aRealPalette[i].green/10923) + - (sal_uInt8)(aRealPalette[i].blue/10923); + 36*static_cast<sal_uInt8>(aRealPalette[i].red/10923) + + 6*static_cast<sal_uInt8>(aRealPalette[i].green/10923) + + static_cast<sal_uInt8>(aRealPalette[i].blue/10923); if( aPalette[nIndex].pixel == 0 ) aPalette[nIndex] = aRealPalette[i]; } @@ -572,10 +572,10 @@ void PixmapHolder::setBitmapDataTCDither( const sal_uInt8* pData, XImage* pImage nScanlineSize += 4; } - for( int y = 0; y < (int)nHeight; y++ ) + for( int y = 0; y < static_cast<int>(nHeight); y++ ) { - const sal_uInt8* pScanline = pBMData + (nHeight-1-(sal_uInt32)y)*nScanlineSize; - for( int x = 0; x < (int)nWidth; x++ ) + const sal_uInt8* pScanline = pBMData + (nHeight-1-static_cast<sal_uInt32>(y))*nScanlineSize; + for( int x = 0; x < static_cast<int>(nWidth); x++ ) { sal_uInt8 b = pScanline[3*x]; sal_uInt8 g = pScanline[3*x+1]; @@ -604,10 +604,10 @@ void PixmapHolder::setBitmapDataTC( const sal_uInt8* pData, XImage* pImage ) nScanlineSize += 4; } - for( int y = 0; y < (int)nHeight; y++ ) + for( int y = 0; y < static_cast<int>(nHeight); y++ ) { - const sal_uInt8* pScanline = pBMData + (nHeight-1-(sal_uInt32)y)*nScanlineSize; - for( int x = 0; x < (int)nWidth; x++ ) + const sal_uInt8* pScanline = pBMData + (nHeight-1-static_cast<sal_uInt32>(y))*nScanlineSize; + for( int x = 0; x < static_cast<int>(nWidth); x++ ) { unsigned long nPixel = getTCPixel( pScanline[3*x+2], pScanline[3*x+1], pScanline[3*x] ); XPutPixel( pImage, x, y, nPixel ); @@ -627,7 +627,7 @@ bool PixmapHolder::needsConversion( const sal_uInt8* pData ) if( m_aInfo.c_class != TrueColor ) return true; } - else if( nDepth != (sal_uInt32)m_aInfo.depth ) + else if( nDepth != static_cast<sal_uInt32>(m_aInfo.depth) ) { if( m_aInfo.c_class != TrueColor ) return true; @@ -668,8 +668,8 @@ Pixmap PixmapHolder::setBitmapData( const sal_uInt8* pData ) if( m_aPixmap != None ) { XImage aImage; - aImage.width = (int)nWidth; - aImage.height = (int)nHeight; + aImage.width = static_cast<int>(nWidth); + aImage.height = static_cast<int>(nHeight); aImage.xoffset = 0; aImage.format = ZPixmap; aImage.data = nullptr; diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index d1743dd47c74..0f14242a5150 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -84,8 +84,8 @@ using namespace com::sun::star::lang; inline sal_uInt16 getUInt16BE( const sal_uInt8*& pBuffer ) { - sal_uInt16 nRet = (sal_uInt16)pBuffer[1] | - (((sal_uInt16)pBuffer[0]) << 8); + sal_uInt16 nRet = static_cast<sal_uInt16>(pBuffer[1]) | + (static_cast<sal_uInt16>(pBuffer[0]) << 8); pBuffer+=2; return nRet; } @@ -363,7 +363,7 @@ OUString PrintFontManager::convertSfntName( void* pRecord ) OUStringBuffer aName( pNameRecord->slen/2 ); const sal_uInt8* pNameBuffer = pNameRecord->sptr; for(int n = 0; n < pNameRecord->slen/2; n++ ) - aName.append( (sal_Unicode)getUInt16BE( pNameBuffer ) ); + aName.append( static_cast<sal_Unicode>(getUInt16BE( pNameBuffer )) ); aValue = aName.makeStringAndClear(); } else if( pNameRecord->platformID == 3 ) @@ -380,7 +380,7 @@ OUString PrintFontManager::convertSfntName( void* pRecord ) const sal_uInt8* pNameBuffer = pNameRecord->sptr; for(int n = 0; n < pNameRecord->slen/2; n++ ) { - sal_Unicode aCode = (sal_Unicode)getUInt16BE( pNameBuffer ); + sal_Unicode aCode = static_cast<sal_Unicode>(getUInt16BE( pNameBuffer )); sal_Char aChar = aCode >> 8; if( aChar ) aName.append( aChar ); @@ -531,7 +531,7 @@ void PrintFontManager::analyzeSfntFamilyName( void const * pTTFont, ::std::vecto } else if (pNameRecords[i].platformID == 1) { - AppleLanguageId aAppleId = static_cast<AppleLanguageId>((sal_uInt16)pNameRecords[i].languageID); + AppleLanguageId aAppleId = static_cast<AppleLanguageId>(static_cast<sal_uInt16>(pNameRecords[i].languageID)); LanguageTag aApple(makeLanguageTagFromAppleLanguageId(aAppleId)); if (aApple == aSystem) nMatch = 8000; @@ -1009,10 +1009,10 @@ bool PrintFontManager::createFontSubset( else { SAL_WARN_IF( (pGlyphIds[i] & 0x007f0000), "vcl", "overlong glyph id" ); - SAL_WARN_IF( (int)pNewEncoding[i] >= nGlyphs, "vcl", "encoding wrong" ); + SAL_WARN_IF( static_cast<int>(pNewEncoding[i]) >= nGlyphs, "vcl", "encoding wrong" ); SAL_WARN_IF( pEnc[pNewEncoding[i]] != 0 || pGID[pNewEncoding[i]] != 0, "vcl", "duplicate encoded glyph" ); pEnc[ pNewEncoding[i] ] = pNewEncoding[i]; - pGID[ pNewEncoding[i] ] = (sal_uInt16)pGlyphIds[ i ]; + pGID[ pNewEncoding[i] ] = static_cast<sal_uInt16>(pGlyphIds[ i ]); pOldIndex[ pNewEncoding[i] ] = i; nChar++; } @@ -1164,13 +1164,13 @@ void PrintFontManager::getGlyphWidths( fontID nFont, break; cOld = c; #if 1 // TODO: remove when sal_Unicode covers all of unicode - if (c > (sal_Unicode)~0) + if (c > sal_Unicode(~0)) break; #endif // get the matching glyph index const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex(c); // update the requested map - rUnicodeEnc[(sal_Unicode)c] = aGlyphId; + rUnicodeEnc[static_cast<sal_Unicode>(c)] = aGlyphId; } } } @@ -1186,7 +1186,7 @@ SAL_DLLPUBLIC_EXPORT const char * unit_online_get_fonts(void) PrintFontManager &rMgr = PrintFontManager::get(); rMgr.getFontList(aFontIDs); OStringBuffer aBuf; - aBuf.append( (sal_Int32)aFontIDs.size() ); + aBuf.append( static_cast<sal_Int32>(aFontIDs.size()) ); aBuf.append( " PS fonts.\n" ); for( auto nId : aFontIDs ) { diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx index b8e3fb4cc9d4..870b53b5232b 100644 --- a/vcl/unx/generic/gdi/gdiimpl.cxx +++ b/vcl/unx/generic/gdi/gdiimpl.cxx @@ -77,8 +77,8 @@ public: { for (sal_uLong i = 0; i < nPoints; ++i) { - Points_[i].x = (short)p[i].mnX; - Points_[i].y = (short)p[i].mnY; + Points_[i].x = static_cast<short>(p[i].mnX); + Points_[i].y = static_cast<short>(p[i].mnY); } Points_[nPoints] = Points_[0]; // close polyline } @@ -1023,10 +1023,10 @@ bool X11SalGraphicsImpl::setClipRegion( const vcl::Region& i_rClip ) { XRectangle aRect; - aRect.x = (short)aRectIter->Left(); - aRect.y = (short)aRectIter->Top(); - aRect.width = (unsigned short)nW; - aRect.height = (unsigned short)nH; + aRect.x = static_cast<short>(aRectIter->Left()); + aRect.y = static_cast<short>(aRectIter->Top()); + aRect.width = static_cast<unsigned short>(nW); + aRect.height = static_cast<unsigned short>(nH); XUnionRectWithRegion(&aRect, mrParent.mpClipRegion, mrParent.mpClipRegion); } } @@ -1132,13 +1132,13 @@ void X11SalGraphicsImpl::SetROPLineColor( SalROPColor nROPColor ) switch( nROPColor ) { case SalROPColor::N0 : // 0 - mnPenPixel = (Pixel)0; + mnPenPixel = Pixel(0); break; case SalROPColor::N1 : // 1 - mnPenPixel = (Pixel)(1 << mrParent.GetVisual().GetDepth()) - 1; + mnPenPixel = static_cast<Pixel>(1 << mrParent.GetVisual().GetDepth()) - 1; break; case SalROPColor::Invert : // 2 - mnPenPixel = (Pixel)(1 << mrParent.GetVisual().GetDepth()) - 1; + mnPenPixel = static_cast<Pixel>(1 << mrParent.GetVisual().GetDepth()) - 1; break; } mnPenColor = mrParent.GetColormap().GetColor( mnPenPixel ); @@ -1150,13 +1150,13 @@ void X11SalGraphicsImpl::SetROPFillColor( SalROPColor nROPColor ) switch( nROPColor ) { case SalROPColor::N0 : // 0 - mnBrushPixel = (Pixel)0; + mnBrushPixel = Pixel(0); break; case SalROPColor::N1 : // 1 - mnBrushPixel = (Pixel)(1 << mrParent.GetVisual().GetDepth()) - 1; + mnBrushPixel = static_cast<Pixel>(1 << mrParent.GetVisual().GetDepth()) - 1; break; case SalROPColor::Invert : // 2 - mnBrushPixel = (Pixel)(1 << mrParent.GetVisual().GetDepth()) - 1; + mnBrushPixel = static_cast<Pixel>(1 << mrParent.GetVisual().GetDepth()) - 1; break; } mbDitherBrush = false; diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx index d599a39aaf1d..69ca5b041d11 100644 --- a/vcl/unx/generic/gdi/salbmp.cxx +++ b/vcl/unx/generic/gdi/salbmp.cxx @@ -376,7 +376,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB( else if( aSrcBuf.mnBitCount <= 8 ) { const SalColormap& rColMap = pSalDisp->GetColormap( nScreen ); - const sal_uInt16 nCols = std::min((sal_uLong)rColMap.GetUsed(), + const sal_uInt16 nCols = std::min(static_cast<sal_uLong>(rColMap.GetUsed()), sal_uLong(1) << nDrawableDepth); rPal.SetEntryCount( nCols ); @@ -538,8 +538,8 @@ XImage* X11SalBitmap::ImplCreateXImage( else if( pImage->depth <= 8 ) { const SalColormap& rColMap = pSalDisp->GetColormap( nScreen ); - const sal_uInt16 nCols = std::min( (sal_uLong)rColMap.GetUsed() - , (sal_uLong)(1 << pImage->depth) + const sal_uInt16 nCols = std::min( static_cast<sal_uLong>(rColMap.GetUsed()) + , static_cast<sal_uLong>(1 << pImage->depth) ); xPal.reset(new BitmapPalette( nCols )); diff --git a/vcl/unx/generic/gdi/salvd.cxx b/vcl/unx/generic/gdi/salvd.cxx index e506cd8a0d23..09367e1e8a25 100644 --- a/vcl/unx/generic/gdi/salvd.cxx +++ b/vcl/unx/generic/gdi/salvd.cxx @@ -128,8 +128,8 @@ X11SalVirtualDevice::X11SalVirtualDevice(SalGraphics const * pGraphics, long &nD break; nScreen++; } - nDX_ = (long)w; - nDY_ = (long)h; + nDX_ = static_cast<long>(w); + nDY_ = static_cast<long>(h); nDX = nDX_; nDY = nDY_; m_nXScreen = SalX11Screen( nScreen ); diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 863867ef7a20..cde05411a659 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -398,7 +398,7 @@ FreetypeFont::FreetypeFont( const FontSelectPattern& rFSD, FreetypeFontInfo* pFI mnWidth = rFSD.mnWidth; if( !mnWidth ) mnWidth = rFSD.mnHeight; - mfStretch = (double)mnWidth / rFSD.mnHeight; + mfStretch = static_cast<double>(mnWidth) / rFSD.mnHeight; // sanity check (e.g. #i66394#, #i66244#, #66537#) if( (mnWidth < 0) || (mfStretch > +64.0) || (mfStretch < -64.0) ) return; @@ -586,12 +586,12 @@ void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const { // left bStretched = (mfStretch != 1.0); - aVector.x = (FT_Pos)(+rMetrics.descender * mfStretch); + aVector.x = static_cast<FT_Pos>(+rMetrics.descender * mfStretch); aVector.y = -rMetrics.ascender; - aMatrix.xx = (FT_Pos)(-mnSin / mfStretch); - aMatrix.yy = (FT_Pos)(-mnSin * mfStretch); - aMatrix.xy = (FT_Pos)(-mnCos * mfStretch); - aMatrix.yx = (FT_Pos)(+mnCos / mfStretch); + aMatrix.xx = static_cast<FT_Pos>(-mnSin / mfStretch); + aMatrix.yy = static_cast<FT_Pos>(-mnSin * mfStretch); + aMatrix.xy = static_cast<FT_Pos>(-mnCos * mfStretch); + aMatrix.yx = static_cast<FT_Pos>(+mnCos / mfStretch); } if( pGlyphFT->format != FT_GLYPH_FORMAT_BITMAP ) diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index 46b785c85328..aaff8d36535f 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -92,7 +92,7 @@ size_t GlyphCache::IFSD_Hash::operator()( const FontSelectPattern& rFontSelData nHash += size_t(rFontSelData.mbVertical); nHash += rFontSelData.GetItalic(); nHash += rFontSelData.GetWeight(); - nHash += (sal_uInt16)rFontSelData.meLanguage; + nHash += static_cast<sal_uInt16>(rFontSelData.meLanguage); return nHash; } diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx index 7fff8756b3c1..b906345bafc0 100644 --- a/vcl/unx/generic/print/bitmap_gfx.cxx +++ b/vcl/unx/generic/print/bitmap_gfx.cxx @@ -313,7 +313,7 @@ LZWEncoder::LZWEncoder(osl::File* pOutputFile) : mpTable[i].mpBrother = nullptr; mpTable[i].mpFirstChild = nullptr; mpTable[i].mnCode = i; - mpTable[i].mnValue = (sal_uInt8)mpTable[i].mnCode; + mpTable[i].mnValue = static_cast<sal_uInt8>(mpTable[i].mnCode); } mpPrefix = nullptr; @@ -336,12 +336,12 @@ LZWEncoder::WriteBits (sal_uInt16 nCode, sal_uInt16 nCodeLen) mnOffset -= nCodeLen; while (mnOffset < 24) { - WriteAscii ((sal_uInt8)(mdwShift >> 24)); + WriteAscii (static_cast<sal_uInt8>(mdwShift >> 24)); mdwShift <<= 8; mnOffset += 8; } if (nCode == 257 && mnOffset != 32) - WriteAscii ((sal_uInt8)(mdwShift >> 24)); + WriteAscii (static_cast<sal_uInt8>(mdwShift >> 24)); } void @@ -384,7 +384,7 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte ) } else { - if(mnTableSize == (sal_uInt16)((1 << mnCodeSize) - 1)) + if(mnTableSize == static_cast<sal_uInt16>((1 << mnCodeSize) - 1)) mnCodeSize++; p = mpTable.data() + (mnTableSize++); @@ -409,15 +409,15 @@ void PrinterGfx::DrawBitmap (const tools::Rectangle& rDest, const tools::Rectangle& rSrc, const PrinterBmp& rBitmap) { - double fScaleX = (double)rDest.GetWidth(); - double fScaleY = (double)rDest.GetHeight(); + double fScaleX = static_cast<double>(rDest.GetWidth()); + double fScaleY = static_cast<double>(rDest.GetHeight()); if(rSrc.GetWidth() > 0) { - fScaleX = (double)rDest.GetWidth() / (double)rSrc.GetWidth(); + fScaleX = static_cast<double>(rDest.GetWidth()) / static_cast<double>(rSrc.GetWidth()); } if(rSrc.GetHeight() > 0) { - fScaleY = (double)rDest.GetHeight() / (double)rSrc.GetHeight(); + fScaleY = static_cast<double>(rDest.GetHeight()) / static_cast<double>(rSrc.GetHeight()); } PSGSave (); PSTranslate (rDest.BottomLeft()); diff --git a/vcl/unx/generic/print/common_gfx.cxx b/vcl/unx/generic/print/common_gfx.cxx index 887c4370d356..b0bad19cc41b 100644 --- a/vcl/unx/generic/print/common_gfx.cxx +++ b/vcl/unx/generic/print/common_gfx.cxx @@ -75,8 +75,8 @@ PrinterGfx::Init (const JobData& rData) mbColor = rData.m_nColorDevice ? ( rData.m_nColorDevice != -1 ) : ( rData.m_pParser == nullptr || rData.m_pParser->isColorDevice() ); int nRes = rData.m_aContext.getRenderResolution(); mnDpi = nRes; - mfScaleX = 72.0 / (double)mnDpi; - mfScaleY = 72.0 / (double)mnDpi; + mfScaleX = 72.0 / static_cast<double>(mnDpi); + mfScaleY = 72.0 / static_cast<double>(mnDpi); const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( rData.m_aPrinterName ) ); mbUploadPS42Fonts = rInfo.m_pParser && rInfo.m_pParser->isType42Capable(); } @@ -226,7 +226,7 @@ PrinterGfx::JoinVerticalClipRectangles( std::list< tools::Rectangle >::iterator& nNewDX = aPoint.X() - aLastPoint.X(); nNewDY = aPoint.Y() - aLastPoint.Y(); if( nNewDX != 0 && - (double)nNewDY/(double)nNewDX == (double)nDY/(double)nDX ) + static_cast<double>(nNewDY)/static_cast<double>(nNewDX) == double(nDY)/double(nDX) ) continue; } PSBinLineTo (aPoint, rOldPoint, rColumn); @@ -245,7 +245,7 @@ PrinterGfx::JoinVerticalClipRectangles( std::list< tools::Rectangle >::iterator& nNewDX = aPoint.X() - aLastPoint.X(); nNewDY = aPoint.Y() - aLastPoint.Y(); if( nNewDX != 0 && - (double)nNewDY/(double)nNewDX == (double)nDY/(double)nDX ) + static_cast<double>(nNewDY)/static_cast<double>(nNewDX) == double(nDY)/double(nDX) ) continue; } PSBinLineTo (aPoint, rOldPoint, rColumn); @@ -696,20 +696,20 @@ PrinterGfx::PSSetColor () if( mbColor ) { nChar = psp::getValueOfDouble (pBuffer, - (double)rColor.GetRed() / 255.0, 5); + static_cast<double>(rColor.GetRed()) / 255.0, 5); nChar += psp::appendStr (" ", pBuffer + nChar); nChar += psp::getValueOfDouble (pBuffer + nChar, - (double)rColor.GetGreen() / 255.0, 5); + static_cast<double>(rColor.GetGreen()) / 255.0, 5); nChar += psp::appendStr (" ", pBuffer + nChar); nChar += psp::getValueOfDouble (pBuffer + nChar, - (double)rColor.GetBlue() / 255.0, 5); + static_cast<double>(rColor.GetBlue()) / 255.0, 5); nChar += psp::appendStr (" setrgbcolor\n", pBuffer + nChar ); } else { Color aColor( rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue() ); sal_uInt8 nCol = aColor.GetLuminance(); - nChar = psp::getValueOfDouble( pBuffer, (double)nCol / 255.0, 5 ); + nChar = psp::getValueOfDouble( pBuffer, static_cast<double>(nCol) / 255.0, 5 ); nChar += psp::appendStr( " setgray\n", pBuffer + nChar ); } @@ -784,7 +784,7 @@ PrinterGfx::PSSetFont () nChar += psp::appendStr ( " [", pSetFont + nChar); nChar += psp::getValueOf (nTextWidth, pSetFont + nChar); nChar += psp::appendStr (" 0 ", pSetFont + nChar); - nChar += psp::getValueOfDouble (pSetFont + nChar, 0.27*(double)nTextWidth, 3 ); + nChar += psp::getValueOfDouble (pSetFont + nChar, 0.27*static_cast<double>(nTextWidth), 3 ); nChar += psp::appendStr ( " ", pSetFont + nChar); nChar += psp::getValueOf (-nTextHeight, pSetFont + nChar); @@ -929,7 +929,7 @@ PrinterGfx::PSBinPath (const Point& rCurrent, Point& rOld, // build the command, it is a char with bit represention 000cxxyy // c represents the char, xx and yy repr. the field width of the dx and dy shift, // dx and dy represent the number of bytes to read after the opcode - sal_Char cCmd = (eType == lineto ? (sal_Char)0x00 : (sal_Char)0x10); + sal_Char cCmd = (eType == lineto ? sal_Char(0x00) : sal_Char(0x10)); switch (nYPrec) { case 2: break; @@ -1002,7 +1002,7 @@ PrinterGfx::PSHexString (const unsigned char* pString, sal_Int16 nLen) WritePS (mpPageBody, pHexString, nChar); nChar = 0; } - nChar += psp::getHexValueOf ((sal_Int32)pString[i], pHexString + nChar); + nChar += psp::getHexValueOf (static_cast<sal_Int32>(pString[i]), pHexString + nChar); } nChar += psp::appendStr (">\n", pHexString + nChar); @@ -1030,7 +1030,7 @@ PrinterGfx::PSShowGlyph (const unsigned char nGlyphId) nLW = maVirtualStatus.mnTextHeight; else nLW = nLW < maVirtualStatus.mnTextHeight ? nLW : maVirtualStatus.mnTextHeight; - psp::getValueOfDouble( pBuffer, (double)nLW / 30.0 ); + psp::getValueOfDouble( pBuffer, static_cast<double>(nLW) / 30.0 ); } // dispatch to the drawing method @@ -1107,10 +1107,10 @@ PrinterGfx::DrawEPS( const tools::Rectangle& rBoundingBox, void* pPtr, sal_uInt3 if( fLeft != fRight && fTop != fBottom ) { - double fScaleX = (double)rBoundingBox.GetWidth()/(fRight-fLeft); - double fScaleY = -(double)rBoundingBox.GetHeight()/(fTop-fBottom); - Point aTranslatePoint( (int)(rBoundingBox.Left()-fLeft*fScaleX), - (int)(rBoundingBox.Bottom()+1-fBottom*fScaleY) ); + double fScaleX = static_cast<double>(rBoundingBox.GetWidth())/(fRight-fLeft); + double fScaleY = -static_cast<double>(rBoundingBox.GetHeight())/(fTop-fBottom); + Point aTranslatePoint( static_cast<int>(rBoundingBox.Left()-fLeft*fScaleX), + static_cast<int>(rBoundingBox.Bottom()+1-fBottom*fScaleY) ); // prepare EPS WritePS( mpPageBody, "/b4_Inc_state save def\n" diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 63013b1188b4..77abd94f6cbf 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -147,9 +147,9 @@ namespace } } -inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778)+0.5); } +inline int PtTo10Mu( int nPoints ) { return static_cast<int>((static_cast<double>(nPoints)*35.27777778)+0.5); } -inline int TenMuToPt( int nUnits ) { return (int)((((double)nUnits)/35.27777778)+0.5); } +inline int TenMuToPt( int nUnits ) { return static_cast<int>((static_cast<double>(nUnits)/35.27777778)+0.5); } static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) { @@ -764,7 +764,7 @@ OUString PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_ if( aData.m_pParser ) { const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( OUString("InputSlot") ): nullptr; - if( ! pKey || nPaperBin >= (sal_uInt16)pKey->countValues() ) + if( ! pKey || nPaperBin >= static_cast<sal_uInt16>(pKey->countValues()) ) aRet = aData.m_pParser->getDefaultInputSlot(); else { diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index 7d52960f12b0..d53d68756aa9 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -631,9 +631,9 @@ void GenPspGraphics::SetFont( const FontSelectPattern *pEntry, int nFallbackLeve if( eItalic != ITALIC_NORMAL && eItalic != ITALIC_OBLIQUE ) bArtItalic = true; } - int nWeight = (int)pEntry->GetWeight(); - int nRealWeight = (int)m_pPrinterGfx->GetFontMgr().getFontWeight( nID ); - if( nRealWeight <= (int)WEIGHT_MEDIUM && nWeight > (int)WEIGHT_MEDIUM ) + int nWeight = static_cast<int>(pEntry->GetWeight()); + int nRealWeight = static_cast<int>(m_pPrinterGfx->GetFontMgr().getFontWeight( nID )); + if( nRealWeight <= int(WEIGHT_MEDIUM) && nWeight > int(WEIGHT_MEDIUM) ) { bArtBold = true; } diff --git a/vcl/unx/generic/print/printerjob.cxx b/vcl/unx/generic/print/printerjob.cxx index d1eac841c92c..76ed433834d3 100644 --- a/vcl/unx/generic/print/printerjob.cxx +++ b/vcl/unx/generic/print/printerjob.cxx @@ -418,15 +418,15 @@ PrinterJob::EndJob() OStringBuffer aTrailer(512); aTrailer.append( "%%Trailer\n" ); aTrailer.append( "%%BoundingBox: 0 0 " ); - aTrailer.append( (sal_Int32)mnMaxWidthPt ); + aTrailer.append( static_cast<sal_Int32>(mnMaxWidthPt) ); aTrailer.append( " " ); - aTrailer.append( (sal_Int32)mnMaxHeightPt ); + aTrailer.append( static_cast<sal_Int32>(mnMaxHeightPt) ); if( mnLandscapes > mnPortraits ) aTrailer.append("\n%%Orientation: Landscape"); else aTrailer.append("\n%%Orientation: Portrait"); aTrailer.append( "\n%%Pages: " ); - aTrailer.append( (sal_Int32)maPageVector.size() ); + aTrailer.append( static_cast<sal_Int32>(maPageVector.size()) ); aTrailer.append( "\n%%EOF\n" ); WritePS (mpJobTrailer, aTrailer.getStr()); @@ -561,8 +561,8 @@ PrinterJob::InitPaperSize (const JobData& rJobSetup) mnTMarginPt = nUpper; mnBMarginPt = nLower; - mfXScale = 72.0 / (double)mnResolution; - mfYScale = -1.0 * 72.0 / (double)mnResolution; + mfXScale = 72.0 / static_cast<double>(mnResolution); + mfYScale = -1.0 * 72.0 / static_cast<double>(mnResolution); } void @@ -570,7 +570,7 @@ PrinterJob::StartPage (const JobData& rJobSetup) { InitPaperSize (rJobSetup); - OUString aPageNo = OUString::number ((sal_Int32)maPageVector.size()+1); // sequential page number must start with 1 + OUString aPageNo = OUString::number (static_cast<sal_Int32>(maPageVector.size())+1); // sequential page number must start with 1 OUString aExt = aPageNo + ".ps"; osl::File* pPageHeader = CreateSpoolFile ( "psp_pghead", aExt); @@ -689,7 +689,7 @@ static bool writeFeature( osl::File* pFile, const PPDKey* pKey, const PPDValue* aFeature.append( "\n} stopped cleartomark\n" ); sal_uInt64 nWritten = 0; return !(pFile->write( aFeature.getStr(), aFeature.getLength(), nWritten ) - || nWritten != (sal_uInt64)aFeature.getLength()); + || nWritten != static_cast<sal_uInt64>(aFeature.getLength())); } bool PrinterJob::writeFeatureList( osl::File* pFile, const JobData& rJob, bool bDocumentSetup ) diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index fc62e0590988..8611141b424b 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -72,9 +72,9 @@ namespace psp { size_t operator()(const css::lang::Locale& rLocale) const { return - (size_t)rLocale.Language.hashCode() - ^ (size_t)rLocale.Country.hashCode() - ^ (size_t)rLocale.Variant.hashCode() + static_cast<size_t>(rLocale.Language.hashCode()) + ^ static_cast<size_t>(rLocale.Country.hashCode()) + ^ static_cast<size_t>(rLocale.Variant.hashCode()) ; } }; @@ -896,7 +896,7 @@ void PPDParser::insertKey( const OUString& rKey, PPDKey* pKey ) const PPDKey* PPDParser::getKey( int n ) const { - return ((unsigned int)n < m_aOrderedKeys.size() && n >= 0) ? m_aOrderedKeys[n] : nullptr; + return (static_cast<unsigned int>(n) < m_aOrderedKeys.size() && n >= 0) ? m_aOrderedKeys[n] : nullptr; } const PPDKey* PPDParser::getKey( const OUString& rKey ) const @@ -1442,10 +1442,10 @@ bool PPDParser::getMargins( aArea = m_pPaperDimensions->getValue( nPDim )->m_aValue; PDWidth = StringToDouble( GetCommandLineToken( 0, aArea ) ); PDHeight = StringToDouble( GetCommandLineToken( 1, aArea ) ); - rLeft = (int)(ImLLx + 0.5); - rLower = (int)(ImLLy + 0.5); - rUpper = (int)(PDHeight - ImURy + 0.5); - rRight = (int)(PDWidth - ImURx + 0.5); + rLeft = static_cast<int>(ImLLx + 0.5); + rLower = static_cast<int>(ImLLy + 0.5); + rUpper = static_cast<int>(PDHeight - ImURy + 0.5); + rRight = static_cast<int>(PDWidth - ImURx + 0.5); return true; } @@ -1468,8 +1468,8 @@ bool PPDParser::getPaperDimension( OUString aArea = m_pPaperDimensions->getValue( nPDim )->m_aValue; PDWidth = StringToDouble( GetCommandLineToken( 0, aArea ) ); PDHeight = StringToDouble( GetCommandLineToken( 1, aArea ) ); - rHeight = (int)(PDHeight + 0.5); - rWidth = (int)(PDWidth + 0.5); + rHeight = static_cast<int>(PDHeight + 0.5); + rWidth = static_cast<int>(PDWidth + 0.5); return true; } @@ -1487,8 +1487,8 @@ OUString PPDParser::matchPaper( int nWidth, int nHeight ) const OUString aArea = m_pPaperDimensions->getValue( i )->m_aValue; double PDWidth = StringToDouble( GetCommandLineToken( 0, aArea ) ); double PDHeight = StringToDouble( GetCommandLineToken( 1, aArea ) ); - PDWidth /= (double)nWidth; - PDHeight /= (double)nHeight; + PDWidth /= static_cast<double>(nWidth); + PDHeight /= static_cast<double>(nHeight); if( PDWidth >= 0.9 && PDWidth <= 1.1 && PDHeight >= 0.9 && PDHeight <= 1.1 ) { @@ -1596,7 +1596,7 @@ PPDKey::~PPDKey() const PPDValue* PPDKey::getValue( int n ) const { - return ((unsigned int)n < m_aOrderedValues.size() && n >= 0) ? m_aOrderedValues[n] : nullptr; + return (static_cast<unsigned int>(n) < m_aOrderedValues.size() && n >= 0) ? m_aOrderedValues[n] : nullptr; } const PPDValue* PPDKey::getValue( const OUString& rOption ) const diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 8d489cbe46c9..5833463f354a 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -548,8 +548,8 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() ); x = rGeom.nX; y = rGeom.nY; - if( x+(int)w+40 <= (int)aScreenSize.Width() && - y+(int)h+40 <= (int)aScreenSize.Height() + if( x+static_cast<int>(w)+40 <= static_cast<int>(aScreenSize.Width()) && + y+static_cast<int>(h)+40 <= static_cast<int>(aScreenSize.Height()) ) { y += 40; @@ -1301,8 +1301,8 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate ) if( maGeometry.nWidth > 0 && maGeometry.nHeight > 0 - && ( nWidth_ != (int)maGeometry.nWidth - || nHeight_ != (int)maGeometry.nHeight ) ) + && ( nWidth_ != static_cast<int>(maGeometry.nWidth) + || nHeight_ != static_cast<int>(maGeometry.nHeight) ) ) { nWidth_ = maGeometry.nWidth; nHeight_ = maGeometry.nHeight; @@ -1569,15 +1569,15 @@ void X11SalFrame::Center( ) else { // center the window relative to the top level frame - nX = (nScreenWidth - (int)maGeometry.nWidth ) / 2 + nScreenX; - nY = (nScreenHeight - (int)maGeometry.nHeight) / 2 + nScreenY; + nX = (nScreenWidth - static_cast<int>(maGeometry.nWidth) ) / 2 + nScreenX; + nY = (nScreenHeight - static_cast<int>(maGeometry.nHeight)) / 2 + nScreenY; } } else { // center the window relative to screen - nX = (nRealScreenWidth - (int)maGeometry.nWidth ) / 2 + nScreenX; - nY = (nRealScreenHeight - (int)maGeometry.nHeight) / 2 + nScreenY; + nX = (nRealScreenWidth - static_cast<int>(maGeometry.nWidth) ) / 2 + nScreenX; + nY = (nRealScreenHeight - static_cast<int>(maGeometry.nHeight)) / 2 + nScreenY; } nX = nX < 0 ? 0 : nX; nY = nY < 0 ? 0 : nY; @@ -1773,14 +1773,14 @@ void X11SalFrame::SetWindowState( const SalFrameState *pState ) } // adjust position so that frame fits onto screen - if( aPosSize.Right()+(long)aGeom.nRightDecoration > aScreenSize.Width()-1 ) - aPosSize.Move( aScreenSize.Width() - aPosSize.Right() - (long)aGeom.nRightDecoration, 0 ); - if( aPosSize.Bottom()+(long)aGeom.nBottomDecoration > aScreenSize.Height()-1 ) - aPosSize.Move( 0, aScreenSize.Height() - aPosSize.Bottom() - (long)aGeom.nBottomDecoration ); - if( aPosSize.Left() < (long)aGeom.nLeftDecoration ) - aPosSize.Move( (long)aGeom.nLeftDecoration - aPosSize.Left(), 0 ); - if( aPosSize.Top() < (long)aGeom.nTopDecoration ) - aPosSize.Move( 0, (long)aGeom.nTopDecoration - aPosSize.Top() ); + if( aPosSize.Right()+static_cast<long>(aGeom.nRightDecoration) > aScreenSize.Width()-1 ) + aPosSize.Move( aScreenSize.Width() - aPosSize.Right() - static_cast<long>(aGeom.nRightDecoration), 0 ); + if( aPosSize.Bottom()+static_cast<long>(aGeom.nBottomDecoration) > aScreenSize.Height()-1 ) + aPosSize.Move( 0, aScreenSize.Height() - aPosSize.Bottom() - static_cast<long>(aGeom.nBottomDecoration) ); + if( aPosSize.Left() < static_cast<long>(aGeom.nLeftDecoration) ) + aPosSize.Move( static_cast<long>(aGeom.nLeftDecoration) - aPosSize.Left(), 0 ); + if( aPosSize.Top() < static_cast<long>(aGeom.nTopDecoration) ) + aPosSize.Move( 0, static_cast<long>(aGeom.nTopDecoration) - aPosSize.Top() ); } SetPosSize( 0, 0, aPosSize.GetWidth(), aPosSize.GetHeight(), SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT ); @@ -1963,7 +1963,7 @@ void X11SalFrame::SetPosSize( const tools::Rectangle &rPosSize ) bool bSized = false; if( values.x != maGeometry.nX || values.y != maGeometry.nY ) bMoved = true; - if( values.width != (int)maGeometry.nWidth || values.height != (int)maGeometry.nHeight ) + if( values.width != static_cast<int>(maGeometry.nWidth) || values.height != static_cast<int>(maGeometry.nHeight) ) bSized = true; // do net set WMNormalHints for .. @@ -2213,9 +2213,9 @@ void X11SalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen ) } else { - if( nScreen < 0 || nScreen >= (int)GetDisplay()->GetXScreenCount() ) + if( nScreen < 0 || nScreen >= static_cast<int>(GetDisplay()->GetXScreenCount()) ) nScreen = m_nXScreen.getXScreen(); - if( nScreen != (int)m_nXScreen.getXScreen() ) + if( nScreen != static_cast<int>(m_nXScreen.getXScreen()) ) { bool bVisible = bMapped_; if( mbFullScreen ) @@ -2689,8 +2689,8 @@ bool X11SalFrame::HandleMouseEvent( XEvent *pEvent ) if( nVisibleFloats > 0 && mpParent ) { Cursor aCursor = mpParent->GetCursor(); - if( pEvent->xmotion.x >= 0 && pEvent->xmotion.x < (int)maGeometry.nWidth && - pEvent->xmotion.y >= 0 && pEvent->xmotion.y < (int)maGeometry.nHeight ) + if( pEvent->xmotion.x >= 0 && pEvent->xmotion.x < static_cast<int>(maGeometry.nWidth) && + pEvent->xmotion.y >= 0 && pEvent->xmotion.y < static_cast<int>(maGeometry.nHeight) ) aCursor = None; XChangeActivePointerGrab( GetXDisplay(), @@ -2718,9 +2718,9 @@ bool X11SalFrame::HandleMouseEvent( XEvent *pEvent ) if( pFrame->IsFloatGrabWindow() && pFrame->bMapped_ && pEvent->xbutton.x_root >= pFrame->maGeometry.nX && - pEvent->xbutton.x_root < pFrame->maGeometry.nX + (int)pFrame->maGeometry.nWidth && + pEvent->xbutton.x_root < pFrame->maGeometry.nX + static_cast<int>(pFrame->maGeometry.nWidth) && pEvent->xbutton.y_root >= pFrame->maGeometry.nY && - pEvent->xbutton.y_root < pFrame->maGeometry.nY + (int)pFrame->maGeometry.nHeight ) + pEvent->xbutton.y_root < pFrame->maGeometry.nY + static_cast<int>(pFrame->maGeometry.nHeight) ) { bInside = true; break; @@ -3582,7 +3582,7 @@ bool X11SalFrame::HandleSizeEvent( XConfigureEvent *pEvent ) nHeight_ = pEvent->height; bool bMoved = ( pEvent->x != maGeometry.nX || pEvent->y != maGeometry.nY ); - bool bSized = ( pEvent->width != (int)maGeometry.nWidth || pEvent->height != (int)maGeometry.nHeight ); + bool bSized = ( pEvent->width != static_cast<int>(maGeometry.nWidth) || pEvent->height != static_cast<int>(maGeometry.nHeight) ); maGeometry.nX = pEvent->x; maGeometry.nY = pEvent->y; @@ -3849,18 +3849,18 @@ bool X11SalFrame::HandleClientMessage( XClientMessageEvent *pEvent ) } else if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::WM_PROTOCOLS ) ) { - if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::NET_WM_PING ) ) + if( static_cast<Atom>(pEvent->data.l[0]) == rWMAdaptor.getAtom( WMAdaptor::NET_WM_PING ) ) rWMAdaptor.answerPing( this, pEvent ); else if( ! ( nStyle_ & SalFrameStyleFlags::PLUG ) && ! (( nStyle_ & SalFrameStyleFlags::FLOAT ) && (nStyle_ & SalFrameStyleFlags::OWNERDRAWDECORATION)) ) { - if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_DELETE_WINDOW ) ) + if( static_cast<Atom>(pEvent->data.l[0]) == rWMAdaptor.getAtom( WMAdaptor::WM_DELETE_WINDOW ) ) { Close(); return true; } - else if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_TAKE_FOCUS ) ) + else if( static_cast<Atom>(pEvent->data.l[0]) == rWMAdaptor.getAtom( WMAdaptor::WM_TAKE_FOCUS ) ) { // do nothing, we set the input focus in ToTop() if necessary #if OSL_DEBUG_LEVEL > 1 diff --git a/vcl/unx/generic/window/salobj.cxx b/vcl/unx/generic/window/salobj.cxx index 425bec45ec26..203c1d3bb794 100644 --- a/vcl/unx/generic/window/salobj.cxx +++ b/vcl/unx/generic/window/salobj.cxx @@ -62,7 +62,7 @@ X11SalObject* X11SalObject::CreateObject( SalFrame* pParent, SystemWindowData* p SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); const SystemEnvData* pEnv = pParent->GetSystemData(); Display* pDisp = pSalDisp->GetDisplay(); - ::Window aObjectParent = (::Window)pEnv->aWindow; + ::Window aObjectParent = static_cast<::Window>(pEnv->aWindow); // find out on which screen that window is XWindowAttributes aParentAttr; @@ -200,10 +200,10 @@ SalClipRegion::UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) { XRectangle& aRect = ClipRectangleList[numClipRectangles]; - aRect.x = (short) nX; - aRect.y = (short) nY; - aRect.width = (unsigned short) nWidth; - aRect.height= (unsigned short) nHeight; + aRect.x = static_cast<short>(nX); + aRect.y = static_cast<short>(nY); + aRect.width = static_cast<unsigned short>(nWidth); + aRect.height= static_cast<unsigned short>(nHeight); numClipRectangles++; } @@ -236,7 +236,7 @@ X11SalObject::~X11SalObject() GetGenericUnixSalData()->ErrorTrapPush(); const SystemEnvData* pEnv = mpParent->GetSystemData(); - ::Window aObjectParent = (::Window)pEnv->aWindow; + ::Window aObjectParent = static_cast<::Window>(pEnv->aWindow); XSetWindowBackgroundPixmap(static_cast<Display*>(maSystemChildData.pDisplay), aObjectParent, None); if ( maSecondary ) XDestroyWindow( static_cast<Display*>(maSystemChildData.pDisplay), maSecondary ); @@ -468,7 +468,7 @@ void X11SalObject::SetLeaveEnterBackgrounds(const css::uno::Sequence<css::uno::A SalDisplay* pSalDisp = vcl_sal::getSalDisplay(GetGenericUnixSalData()); const SystemEnvData* pEnv = mpParent->GetSystemData(); Display* pDisp = pSalDisp->GetDisplay(); - ::Window aObjectParent = (::Window)pEnv->aWindow; + ::Window aObjectParent = static_cast<::Window>(pEnv->aWindow); bool bFreePixmap = false; Pixmap aPixmap = None; diff --git a/vcl/unx/gtk/a11y/atkaction.cxx b/vcl/unx/gtk/a11y/atkaction.cxx index ad8e3a789038..620e34d928aa 100644 --- a/vcl/unx/gtk/a11y/atkaction.cxx +++ b/vcl/unx/gtk/a11y/atkaction.cxx @@ -177,7 +177,7 @@ appendKeyStrokes(OStringBuffer& rBuffer, const uno::Sequence< awt::KeyStroke >& rBuffer.append("<Alt>"); if( ( rKeyStrokes[i].KeyCode >= awt::Key::A ) && ( rKeyStrokes[i].KeyCode <= awt::Key::Z ) ) - rBuffer.append( (sal_Char) ( 'a' + ( rKeyStrokes[i].KeyCode - awt::Key::A ) ) ); + rBuffer.append( static_cast<sal_Char>( 'a' + ( rKeyStrokes[i].KeyCode - awt::Key::A ) ) ); else { sal_Char c = '\0'; @@ -229,7 +229,7 @@ action_wrapper_get_keybinding (AtkAction *action, { OStringBuffer aRet; - sal_Int32 nmax = std::min( xBinding->getAccessibleKeyBindingCount(), (sal_Int32) 3 ); + sal_Int32 nmax = std::min( xBinding->getAccessibleKeyBindingCount(), sal_Int32(3) ); for( sal_Int32 n = 0; n < nmax; n++ ) { appendKeyStrokes( aRet, xBinding->getAccessibleKeyBinding( n ) ); diff --git a/vcl/unx/gtk/a11y/atklistener.cxx b/vcl/unx/gtk/a11y/atklistener.cxx index 117b02b7e145..82f18a58a217 100644 --- a/vcl/unx/gtk/a11y/atklistener.cxx +++ b/vcl/unx/gtk/a11y/atklistener.cxx @@ -576,16 +576,16 @@ void AtkListener::notifyEvent( const accessibility::AccessibleEventObject& aEven g_object_set_data( G_OBJECT(atk_obj), "ooo::text_changed::delete", &aDeletedText); g_signal_emit_by_name( atk_obj, "text_changed::delete", - (gint) aDeletedText.SegmentStart, - (gint)( aDeletedText.SegmentEnd - aDeletedText.SegmentStart ) ); + static_cast<gint>(aDeletedText.SegmentStart), + static_cast<gint>( aDeletedText.SegmentEnd - aDeletedText.SegmentStart ) ); g_object_steal_data( G_OBJECT(atk_obj), "ooo::text_changed::delete" ); } if( aEvent.NewValue >>= aInsertedText ) g_signal_emit_by_name( atk_obj, "text_changed::insert", - (gint) aInsertedText.SegmentStart, - (gint)( aInsertedText.SegmentEnd - aInsertedText.SegmentStart ) ); + static_cast<gint>(aInsertedText.SegmentStart), + static_cast<gint>( aInsertedText.SegmentEnd - aInsertedText.SegmentStart ) ); break; } diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx index 840106a6d5db..a8c7c8e3cdae 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.cxx +++ b/vcl/unx/gtk/a11y/atktextattributes.cxx @@ -174,7 +174,7 @@ static inline double toPoint(sal_Int16 n) { // 100th mm -> pt - return (double) (n * 72) / 2540; + return static_cast<double>(n * 72) / 2540; } /*****************************************************************************/ @@ -290,7 +290,7 @@ String2Color( uno::Any& rAny, const gchar * value ) if( 3 != sscanf( value, "%d,%d,%d", &red, &green, &blue ) ) return false; - sal_Int32 nColor = (sal_Int32) blue | ( (sal_Int32) green << 8 ) | ( ( sal_Int32 ) red << 16 ); + sal_Int32 nColor = static_cast<sal_Int32>(blue) | ( static_cast<sal_Int32>(green) << 8 ) | ( static_cast<sal_Int32>(red) << 16 ); rAny <<= nColor; return true; } @@ -575,7 +575,7 @@ UnitString2CMM( uno::Any& rAny, const gchar * value ) fValue = fValue * 100; - rAny <<= (sal_Int32) fValue; + rAny <<= static_cast<sal_Int32>(fValue); return true; } @@ -615,7 +615,7 @@ String2Bool( uno::Any& rAny, const gchar * value ) static gchar* Scale2String( const uno::Any& rAny ) { - return g_strdup_printf( "%g", (double) (rAny.get< sal_Int16 > ()) / 100 ); + return g_strdup_printf( "%g", static_cast<double>(rAny.get< sal_Int16 > ()) / 100 ); } static bool @@ -626,7 +626,7 @@ String2Scale( uno::Any& rAny, const gchar * value ) if( 1 != sscanf( value, "%lg", &dval ) ) return false; - rAny <<= (sal_Int16) (dval * 100); + rAny <<= static_cast<sal_Int16>(dval * 100); return true; } diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx index 5b7e89bd78af..7ad94e9d443a 100644 --- a/vcl/unx/gtk/a11y/atkutil.cxx +++ b/vcl/unx/gtk/a11y/atkutil.cxx @@ -485,7 +485,7 @@ static void create_wrapper_for_child( static void handle_toolbox_buttonchange(VclWindowEvent const *pEvent) { vcl::Window* pWindow = pEvent->GetWindow(); - sal_Int32 index = (sal_Int32)reinterpret_cast<sal_IntPtr>(pEvent->GetData()); + sal_Int32 index = static_cast<sal_Int32>(reinterpret_cast<sal_IntPtr>(pEvent->GetData())); if( pWindow && pWindow->IsReallyVisible() ) { diff --git a/vcl/unx/gtk/glomenu.cxx b/vcl/unx/gtk/glomenu.cxx index 2547c36c1649..06dadee7c59d 100644 --- a/vcl/unx/gtk/glomenu.cxx +++ b/vcl/unx/gtk/glomenu.cxx @@ -106,7 +106,7 @@ gint g_lo_menu_get_n_items_from_section (GLOMenu *menu, gint section) { - g_return_val_if_fail (0 <= section && section < (gint) menu->items->len, 0); + g_return_val_if_fail (0 <= section && section < static_cast<gint>(menu->items->len), 0); GLOMenu *model = g_lo_menu_get_section (menu, section); @@ -152,7 +152,7 @@ g_lo_menu_insert_in_section (GLOMenu *menu, const gchar *label) { g_return_if_fail (G_IS_LO_MENU (menu)); - g_return_if_fail (0 <= section && section < (gint) menu->items->len); + g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len)); GLOMenu *model = g_lo_menu_get_section (menu, section); @@ -179,7 +179,7 @@ g_lo_menu_set_attribute_value (GLOMenu *menu, g_return_if_fail (attribute != nullptr); g_return_if_fail (valid_attribute_name (attribute)); - if (position >= (gint) menu->items->len) + if (position >= static_cast<gint>(menu->items->len)) return; struct item menu_item = g_array_index (menu->items, struct item, position); @@ -478,7 +478,7 @@ g_lo_menu_set_link (GLOMenu *menu, g_return_if_fail (link != nullptr); g_return_if_fail (valid_attribute_name (link)); - if (position < 0 || position >= (gint) menu->items->len) + if (position < 0 || position >= static_cast<gint>(menu->items->len)) position = menu->items->len - 1; struct item menu_item = g_array_index (menu->items, struct item, position); @@ -497,7 +497,7 @@ g_lo_menu_insert_section (GLOMenu *menu, { g_return_if_fail (G_IS_LO_MENU (menu)); - if (position < 0 || position > (gint) menu->items->len) + if (position < 0 || position > static_cast<gint>(menu->items->len)) position = menu->items->len; struct item menu_item; @@ -540,13 +540,13 @@ g_lo_menu_new_submenu_in_item_in_section (GLOMenu *menu, gint position) { g_return_if_fail (G_IS_LO_MENU (menu)); - g_return_if_fail (0 <= section && section < (gint) menu->items->len); + g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len)); GLOMenu* model = g_lo_menu_get_section (menu, section); g_return_if_fail (model != nullptr); - if (0 <= position && position < (gint) model->items->len) { + if (0 <= position && position < static_cast<gint>(model->items->len)) { GMenuModel* submenu = G_MENU_MODEL (g_lo_menu_new()); g_lo_menu_set_link (model, position, G_MENU_LINK_SUBMENU, submenu); @@ -565,7 +565,7 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu, gint position) { g_return_val_if_fail (G_IS_LO_MENU (menu), nullptr); - g_return_val_if_fail (0 <= section && section < (gint) menu->items->len, nullptr); + g_return_val_if_fail (0 <= section && section < static_cast<gint>(menu->items->len), nullptr); GLOMenu *model = g_lo_menu_get_section (menu, section); @@ -573,7 +573,7 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu, GLOMenu *submenu = nullptr; - if (0 <= position && position < (gint) model->items->len) + if (0 <= position && position < static_cast<gint>(model->items->len)) submenu = G_LO_MENU (G_MENU_MODEL_CLASS (g_lo_menu_parent_class) ->get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU)); //submenu = g_menu_model_get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU); @@ -624,7 +624,7 @@ g_lo_menu_remove (GLOMenu *menu, gint position) { g_return_if_fail (G_IS_LO_MENU (menu)); - g_return_if_fail (0 <= position && position < (gint) menu->items->len); + g_return_if_fail (0 <= position && position < static_cast<gint>(menu->items->len)); g_lo_menu_clear_item (&g_array_index (menu->items, struct item, position)); g_array_remove_index (menu->items, position); @@ -637,7 +637,7 @@ g_lo_menu_remove_from_section (GLOMenu *menu, gint position) { g_return_if_fail (G_IS_LO_MENU (menu)); - g_return_if_fail (0 <= section && section < (gint) menu->items->len); + g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len)); GLOMenu *model = g_lo_menu_get_section (menu, section); diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx index c6f5925da80f..7c9a3d1e0fbc 100644 --- a/vcl/unx/gtk/gtkdata.cxx +++ b/vcl/unx/gtk/gtkdata.cxx @@ -683,7 +683,7 @@ extern "C" { nDeltaSec -= 1; } // if the clock changes backwards we need to cope ... - if( (unsigned long) nDeltaSec > 1 + ( pTSource->pInstance->m_nTimeoutMS / 1000 ) ) + if( static_cast<unsigned long>(nDeltaSec) > 1 + ( pTSource->pInstance->m_nTimeoutMS / 1000 ) ) { sal_gtk_timeout_defer( pTSource ); return TRUE; diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index 4b840923a971..959e387633ec 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -67,7 +67,7 @@ extern "C" if( gtk_major_version < 2 || // very unlikely sanity check ( gtk_major_version == 2 && gtk_minor_version < 4 ) ) { - g_warning("require a newer gtk than %d.%d for gdk_threads_set_lock_functions", (int) gtk_major_version, gtk_minor_version); + g_warning("require a newer gtk than %d.%d for gdk_threads_set_lock_functions", static_cast<int>(gtk_major_version), gtk_minor_version); return nullptr; } diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx index a55f582ab921..96618d1c0af1 100644 --- a/vcl/unx/gtk/gtksalframe.cxx +++ b/vcl/unx/gtk/gtksalframe.cxx @@ -1322,7 +1322,7 @@ void GtkSalFrame::Init( SystemParentData* pSysData ) { XReparentWindow( getDisplay()->GetDisplay(), widget_get_xid(m_pWindow), - (::Window)pSysData->aWindow, + static_cast<::Window>(pSysData->aWindow), 0, 0 ); } } @@ -1432,8 +1432,8 @@ void GtkSalFrame::Center() if( m_pParent ) { - nX = ((long)m_pParent->maGeometry.nWidth - (long)maGeometry.nWidth)/2; - nY = ((long)m_pParent->maGeometry.nHeight - (long)maGeometry.nHeight)/2; + nX = (static_cast<long>(m_pParent->maGeometry.nWidth) - static_cast<long>(maGeometry.nWidth))/2; + nY = (static_cast<long>(m_pParent->maGeometry.nHeight) - static_cast<long>(maGeometry.nHeight))/2; } else { @@ -1450,8 +1450,8 @@ void GtkSalFrame::Center() GdkRectangle aMonitor; gdk_screen_get_monitor_geometry( pScreen, nMonitor, &aMonitor ); - nX = aMonitor.x + (aMonitor.width - (long)maGeometry.nWidth)/2; - nY = aMonitor.y + (aMonitor.height - (long)maGeometry.nHeight)/2; + nX = aMonitor.x + (aMonitor.width - static_cast<long>(maGeometry.nWidth))/2; + nY = aMonitor.y + (aMonitor.height - static_cast<long>(maGeometry.nHeight))/2; } SetPosSize( nX, nY, 0, 0, SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ); } @@ -1694,7 +1694,7 @@ void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u { m_bDefaultSize = false; - if( (unsigned long)nWidth != maGeometry.nWidth || (unsigned long)nHeight != maGeometry.nHeight ) + if( static_cast<unsigned long>(nWidth) != maGeometry.nWidth || static_cast<unsigned long>(nHeight) != maGeometry.nHeight ) bSized = true; maGeometry.nWidth = nWidth; maGeometry.nHeight = nHeight; @@ -1894,7 +1894,7 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, SetType eType, tools::Rect GdkScreen *pScreen = nullptr; GdkRectangle aNewMonitor; - bool bSpanAllScreens = nNewScreen == (unsigned int)-1; + bool bSpanAllScreens = nNewScreen == static_cast<unsigned int>(-1); m_bSpanMonitorsWhenFullscreen = bSpanAllScreens && getDisplay()->getSystem()->GetDisplayScreenCount() > 1; if (m_bSpanMonitorsWhenFullscreen) //span all screens @@ -2477,7 +2477,7 @@ void GtkSalFrame::createNewWindow( ::Window aNewParent, bool bXEmbed, SalX11Scre if( bWasVisible ) Show( false ); - if( (int)nXScreen.getXScreen() >= getDisplay()->GetXScreenCount() ) + if( static_cast<int>(nXScreen.getXScreen()) >= getDisplay()->GetXScreenCount() ) nXScreen = m_nXScreen; SystemParentData aParentData; @@ -2708,8 +2708,8 @@ gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer default: return false; } aEvent.mnTime = pEvent->time; - aEvent.mnX = (long)pEvent->x_root - pThis->maGeometry.nX; - aEvent.mnY = (long)pEvent->y_root - pThis->maGeometry.nY; + aEvent.mnX = static_cast<long>(pEvent->x_root) - pThis->maGeometry.nX; + aEvent.mnY = static_cast<long>(pEvent->y_root) - pThis->maGeometry.nY; aEvent.mnCode = GetMouseModCode( pEvent->state ); bool bClosePopups = false; @@ -2758,8 +2758,8 @@ gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer if( ! aDel.isDeleted() ) { - int frame_x = (int)(pEvent->x_root - pEvent->x); - int frame_y = (int)(pEvent->y_root - pEvent->y); + int frame_x = static_cast<int>(pEvent->x_root - pEvent->x); + int frame_y = static_cast<int>(pEvent->y_root - pEvent->y); if( frame_x != pThis->maGeometry.nX || frame_y != pThis->maGeometry.nY ) { pThis->maGeometry.nX = frame_x; @@ -2789,8 +2789,8 @@ gboolean GtkSalFrame::signalScroll(GtkWidget*, GdkEvent* pInEvent, gpointer fram bool bNeg = (rEvent.direction == GDK_SCROLL_DOWN || rEvent.direction == GDK_SCROLL_RIGHT ); SalWheelMouseEvent aEvent; aEvent.mnTime = rEvent.time; - aEvent.mnX = (sal_uLong)rEvent.x; - aEvent.mnY = (sal_uLong)rEvent.y; + aEvent.mnX = static_cast<sal_uLong>(rEvent.x); + aEvent.mnY = static_cast<sal_uLong>(rEvent.y); aEvent.mnDelta = bNeg ? -120 : 120; aEvent.mnNotchDelta = bNeg ? -1 : 1; aEvent.mnScrollLines = nLines; @@ -2811,8 +2811,8 @@ gboolean GtkSalFrame::signalMotion( GtkWidget*, GdkEventMotion* pEvent, gpointer SalMouseEvent aEvent; aEvent.mnTime = pEvent->time; - aEvent.mnX = (long)pEvent->x_root - pThis->maGeometry.nX; - aEvent.mnY = (long)pEvent->y_root - pThis->maGeometry.nY; + aEvent.mnX = static_cast<long>(pEvent->x_root) - pThis->maGeometry.nX; + aEvent.mnY = static_cast<long>(pEvent->y_root) - pThis->maGeometry.nY; aEvent.mnCode = GetMouseModCode( pEvent->state ); aEvent.mnButton = 0; @@ -2825,8 +2825,8 @@ gboolean GtkSalFrame::signalMotion( GtkWidget*, GdkEventMotion* pEvent, gpointer if( ! aDel.isDeleted() ) { - int frame_x = (int)(pEvent->x_root - pEvent->x); - int frame_y = (int)(pEvent->y_root - pEvent->y); + int frame_x = static_cast<int>(pEvent->x_root - pEvent->x); + int frame_y = static_cast<int>(pEvent->y_root - pEvent->y); if( frame_x != pThis->maGeometry.nX || frame_y != pThis->maGeometry.nY ) { pThis->maGeometry.nX = frame_x; @@ -2851,8 +2851,8 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); SalMouseEvent aEvent; aEvent.mnTime = pEvent->time; - aEvent.mnX = (long)pEvent->x_root - pThis->maGeometry.nX; - aEvent.mnY = (long)pEvent->y_root - pThis->maGeometry.nY; + aEvent.mnX = static_cast<long>(pEvent->x_root) - pThis->maGeometry.nX; + aEvent.mnY = static_cast<long>(pEvent->y_root) - pThis->maGeometry.nY; aEvent.mnCode = GetMouseModCode( pEvent->state ); aEvent.mnButton = 0; @@ -2915,7 +2915,7 @@ gboolean GtkSalFrame::signalConfigure( GtkWidget*, GdkEventConfigure* pEvent, gp */ if( pThis->m_bFullscreen || (pThis->m_nStyle & (SalFrameStyleFlags::SIZEABLE | SalFrameStyleFlags::PLUG)) == SalFrameStyleFlags::SIZEABLE ) { - if( pEvent->width != (int)pThis->maGeometry.nWidth || pEvent->height != (int)pThis->maGeometry.nHeight ) + if( pEvent->width != static_cast<int>(pThis->maGeometry.nWidth) || pEvent->height != static_cast<int>(pThis->maGeometry.nHeight) ) { bSized = true; pThis->maGeometry.nWidth = pEvent->width; @@ -3026,8 +3026,8 @@ gboolean GtkSalFrame::signalMap( GtkWidget *pWidget, GdkEvent*, gpointer frame ) if (osl::FileBase::getSystemPathFromFileURL(sProgramURL, sProgram) == osl::File::E_None) { OString sFinalProgram(OUStringToOString(sProgram, osl_getThreadTextEncoding()) - + " " + OString::number((int)GDK_WINDOW_XID(gdkwin)) - + " " + OString::number((int)pThis->m_bSpanMonitorsWhenFullscreen)); + + " " + OString::number(static_cast<int>(GDK_WINDOW_XID(gdkwin))) + + " " + OString::number(static_cast<int>(pThis->m_bSpanMonitorsWhenFullscreen))); OString sDisplay(getDisplayString()); if (!sDisplay.isEmpty()) { @@ -3641,7 +3641,7 @@ void GtkSalFrame::IMHandler::signalIMPreeditChanged( GtkIMContext*, gpointer im_ pThis->m_aInputEvent.mnCursorPos = nCursorPos; pThis->m_aInputEvent.mnCursorFlags = 0; - pThis->m_aInputFlags = std::vector<ExtTextInputAttr>( std::max( 1, (int)pThis->m_aInputEvent.maText.getLength() ), ExtTextInputAttr::NONE ); + pThis->m_aInputFlags = std::vector<ExtTextInputAttr>( std::max( 1, static_cast<int>(pThis->m_aInputEvent.maText.getLength()) ), ExtTextInputAttr::NONE ); PangoAttrIterator *iter = pango_attr_list_get_iterator(pAttrs); do diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 4aaaacf14ec5..8fd2ea29636a 100644 --- a/vcl/unx/gtk/gtksalmenu.cxx +++ b/vcl/unx/gtk/gtksalmenu.cxx @@ -62,7 +62,7 @@ void RemoveSpareItemsFromNativeMenu( GLOMenu* pMenu, GList** pOldCommandList, un { sal_Int32 nSectionItems = g_lo_menu_get_n_items_from_section( pMenu, nSection ); - while ( nSectionItems > (sal_Int32) nValidItems ) + while ( nSectionItems > static_cast<sal_Int32>(nValidItems) ) { gchar* aCommand = g_lo_menu_get_command_from_item_in_section( pMenu, nSection, --nSectionItems ); @@ -247,7 +247,7 @@ void GtkSalMenu::ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries) sal_Int32 validItems = 0; sal_Int32 nItem; - for ( nItem = 0; nItem < ( sal_Int32 ) GetItemCount(); nItem++ ) { + for ( nItem = 0; nItem < static_cast<sal_Int32>(GetItemCount()); nItem++ ) { if ( !IsItemVisible( nItem ) ) continue; diff --git a/vcl/unx/gtk/gtksys.cxx b/vcl/unx/gtk/gtksys.cxx index 928755f4dbe4..98411f2f039f 100644 --- a/vcl/unx/gtk/gtksys.cxx +++ b/vcl/unx/gtk/gtksys.cxx @@ -277,7 +277,7 @@ int GtkSalSystem::ShowNativeDialog (const OUString& rTitle, const OUString& rMes GtkDialog *pDialog = GTK_DIALOG ( g_object_new (GTK_TYPE_MESSAGE_DIALOG, "title", aTitle.getStr(), - "message-type", (int)GTK_MESSAGE_WARNING, + "message-type", int(GTK_MESSAGE_WARNING), "text", aMessage.getStr(), nullptr)); int nButton = 0; diff --git a/vcl/unx/gtk/salnativewidgets-gtk.cxx b/vcl/unx/gtk/salnativewidgets-gtk.cxx index 61aff29038ef..71bfcdff5d2e 100644 --- a/vcl/unx/gtk/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/salnativewidgets-gtk.cxx @@ -2579,10 +2579,10 @@ bool GtkSalGraphics::NWPaintGTKComboBox( GdkDrawable* gdkDrawable, aEditBoxRect.SetPos( Point( x + buttonRect.GetWidth() , y ) ); #define ARROW_EXTENT 0.7 - arrowRect.SetSize( Size( (gint)(MIN_ARROW_SIZE * ARROW_EXTENT), - (gint)(MIN_ARROW_SIZE * ARROW_EXTENT) ) ); - arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2), - buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) ); + arrowRect.SetSize( Size( gint(MIN_ARROW_SIZE * ARROW_EXTENT), + gint(MIN_ARROW_SIZE * ARROW_EXTENT) ) ); + arrowRect.SetPos( Point( buttonRect.Left() + static_cast<gint>((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2), + buttonRect.Top() + static_cast<gint>((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) ); for( std::vector< tools::Rectangle >::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it ) { diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx index 1c6e8e2c5e11..fd5b47f0b626 100644 --- a/vcl/unx/gtk3/gtk3gtkdata.cxx +++ b/vcl/unx/gtk3/gtk3gtkdata.cxx @@ -643,7 +643,7 @@ extern "C" { nDeltaSec -= 1; } // if the clock changes backwards we need to cope ... - if( (unsigned long) nDeltaSec > 1 + ( pTSource->pInstance->m_nTimeoutMS / 1000 ) ) + if( static_cast<unsigned long>(nDeltaSec) > 1 + ( pTSource->pInstance->m_nTimeoutMS / 1000 ) ) { sal_gtk_timeout_defer( pTSource ); return TRUE; diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 43f4094ac5b3..d465fa01ef1b 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -1800,7 +1800,7 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, SetType eType, tools::Rect GdkScreen *pScreen = nullptr; GdkRectangle aNewMonitor; - bool bSpanAllScreens = nNewScreen == (unsigned int)-1; + bool bSpanAllScreens = nNewScreen == static_cast<unsigned int>(-1); m_bSpanMonitorsWhenFullscreen = bSpanAllScreens && getDisplay()->getSystem()->GetDisplayScreenCount() > 1; gint nMonitor = -1; if (m_bSpanMonitorsWhenFullscreen) //span all screens @@ -2595,8 +2595,8 @@ gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer if (!aDel.isDeleted()) { - int frame_x = (int)(pEvent->x_root - pEvent->x); - int frame_y = (int)(pEvent->y_root - pEvent->y); + int frame_x = static_cast<int>(pEvent->x_root - pEvent->x); + int frame_y = static_cast<int>(pEvent->y_root - pEvent->y); if (pThis->m_bGeometryIsProvisional || frame_x != pThis->maGeometry.nX || frame_y != pThis->maGeometry.nY) { pThis->m_bGeometryIsProvisional = false; @@ -2611,8 +2611,8 @@ gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer if (!aDel.isDeleted()) { aEvent.mnTime = pEvent->time; - aEvent.mnX = (long)pEvent->x_root - pThis->maGeometry.nX; - aEvent.mnY = (long)pEvent->y_root - pThis->maGeometry.nY; + aEvent.mnX = static_cast<long>(pEvent->x_root) - pThis->maGeometry.nX; + aEvent.mnY = static_cast<long>(pEvent->y_root) - pThis->maGeometry.nY; aEvent.mnCode = GetMouseModCode( pEvent->state ); if( AllSettings::GetLayoutRTL() ) @@ -2648,11 +2648,11 @@ IMPL_LINK_NOARG(GtkSalFrame, AsyncScroll, Timer *, void) GdkEvent* pEvent = m_aPendingScrollEvents.back(); aEvent.mnTime = pEvent->scroll.time; - aEvent.mnX = (sal_uLong)pEvent->scroll.x; + aEvent.mnX = static_cast<sal_uLong>(pEvent->scroll.x); // --- RTL --- (mirror mouse pos) if (AllSettings::GetLayoutRTL()) aEvent.mnX = maGeometry.nWidth - 1 - aEvent.mnX; - aEvent.mnY = (sal_uLong)pEvent->scroll.y; + aEvent.mnY = static_cast<sal_uLong>(pEvent->scroll.y); aEvent.mnCode = GetMouseModCode( pEvent->scroll.state ); double delta_x(0.0), delta_y(0.0); @@ -2716,11 +2716,11 @@ gboolean GtkSalFrame::signalScroll(GtkWidget*, GdkEvent* pInEvent, gpointer fram SalWheelMouseEvent aEvent; aEvent.mnTime = rEvent.time; - aEvent.mnX = (sal_uLong)rEvent.x; + aEvent.mnX = static_cast<sal_uLong>(rEvent.x); // --- RTL --- (mirror mouse pos) if (AllSettings::GetLayoutRTL()) aEvent.mnX = pThis->maGeometry.nWidth - 1 - aEvent.mnX; - aEvent.mnY = (sal_uLong)rEvent.y; + aEvent.mnY = static_cast<sal_uLong>(rEvent.y); aEvent.mnCode = GetMouseModCode(rEvent.state); switch (rEvent.direction) @@ -2817,8 +2817,8 @@ gboolean GtkSalFrame::signalMotion( GtkWidget*, GdkEventMotion* pEvent, gpointer vcl::DeletionListener aDel( pThis ); - int frame_x = (int)(pEvent->x_root - pEvent->x); - int frame_y = (int)(pEvent->y_root - pEvent->y); + int frame_x = static_cast<int>(pEvent->x_root - pEvent->x); + int frame_y = static_cast<int>(pEvent->y_root - pEvent->y); if (pThis->m_bGeometryIsProvisional || frame_x != pThis->maGeometry.nX || frame_y != pThis->maGeometry.nY) { pThis->m_bGeometryIsProvisional = false; @@ -2833,8 +2833,8 @@ gboolean GtkSalFrame::signalMotion( GtkWidget*, GdkEventMotion* pEvent, gpointer { SalMouseEvent aEvent; aEvent.mnTime = pEvent->time; - aEvent.mnX = (long)pEvent->x_root - pThis->maGeometry.nX; - aEvent.mnY = (long)pEvent->y_root - pThis->maGeometry.nY; + aEvent.mnX = static_cast<long>(pEvent->x_root) - pThis->maGeometry.nX; + aEvent.mnY = static_cast<long>(pEvent->y_root) - pThis->maGeometry.nY; aEvent.mnCode = GetMouseModCode( pEvent->state ); aEvent.mnButton = 0; @@ -2862,8 +2862,8 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame); SalMouseEvent aEvent; aEvent.mnTime = pEvent->time; - aEvent.mnX = (long)pEvent->x_root - pThis->maGeometry.nX; - aEvent.mnY = (long)pEvent->y_root - pThis->maGeometry.nY; + aEvent.mnX = static_cast<long>(pEvent->x_root) - pThis->maGeometry.nX; + aEvent.mnY = static_cast<long>(pEvent->y_root) - pThis->maGeometry.nY; aEvent.mnCode = GetMouseModCode( pEvent->state ); aEvent.mnButton = 0; @@ -3930,7 +3930,7 @@ void GtkSalFrame::IMHandler::signalIMPreeditChanged( GtkIMContext*, gpointer im_ pThis->m_aInputEvent.mnCursorPos = nCursorPos; pThis->m_aInputEvent.mnCursorFlags = 0; - pThis->m_aInputFlags = std::vector<ExtTextInputAttr>( std::max( 1, (int)pThis->m_aInputEvent.maText.getLength() ), ExtTextInputAttr::NONE ); + pThis->m_aInputFlags = std::vector<ExtTextInputAttr>( std::max( 1, static_cast<int>(pThis->m_aInputEvent.maText.getLength()) ), ExtTextInputAttr::NONE ); PangoAttrIterator *iter = pango_attr_list_get_iterator(pAttrs); do diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index d605eaf241cd..a1dd2e557cbe 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -1232,8 +1232,8 @@ void GtkSalGraphics::PaintCombobox( GtkStateFlags flags, cairo_t *cr, } arrowRect.SetSize(Size(arrow_width, arrow_height)); - arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2), - buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) ); + arrowRect.SetPos( Point( buttonRect.Left() + static_cast<gint>((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2), + buttonRect.Top() + static_cast<gint>((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) ); tools::Rectangle aRect(Point(0, 0), Size(areaRect.GetWidth(), areaRect.GetHeight())); @@ -2769,7 +2769,7 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar ************************************************************************/ static inline ::Color getColor( const GdkRGBA& rCol ) { - return ::Color( (int)(rCol.red * 0xFFFF) >> 8, (int)(rCol.green * 0xFFFF) >> 8, (int)(rCol.blue * 0xFFFF) >> 8 ); + return ::Color( static_cast<int>(rCol.red * 0xFFFF) >> 8, static_cast<int>(rCol.green * 0xFFFF) >> 8, static_cast<int>(rCol.blue * 0xFFFF) >> 8 ); } static vcl::Font getFont(GtkStyleContext* pStyle, const css::lang::Locale& rLocale) diff --git a/vcl/unx/x11/x11sys.cxx b/vcl/unx/x11/x11sys.cxx index fd1b08c43b0d..50471e8fc06f 100644 --- a/vcl/unx/x11/x11sys.cxx +++ b/vcl/unx/x11/x11sys.cxx @@ -102,9 +102,9 @@ int X11SalSystem::ShowNativeDialog( const OUString& rTitle, const OUString& rMes aWarn->AddButton( button, nButton+1, (nButton == 0) ? ButtonDialogFlags::Default : ButtonDialogFlags::NONE ); nButton++; } - aWarn->SetFocusButton( (sal_uInt16)1 ); + aWarn->SetFocusButton( sal_uInt16(1) ); - nRet = ((int)aWarn->Execute()) - 1; + nRet = static_cast<int>(aWarn->Execute()) - 1; // normalize behaviour, actually this should never happen if( nRet < -1 || nRet >= int(rButtons.size()) ) diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index 8957a89480cb..0b44e408cce6 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -109,43 +109,43 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { GDIMetaFile aGDIMetaFile; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) ReadWindowMetafile(aFileStream, aGDIMetaFile); + ret = static_cast<int>(ReadWindowMetafile(aFileStream, aGDIMetaFile)); } else if (strcmp(argv[2], "jpg") == 0) { Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) ImportJPEG(aFileStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr); + ret = static_cast<int>(ImportJPEG(aFileStream, aGraphic, GraphicFilterImportFlags::NONE, nullptr)); } else if (strcmp(argv[2], "gif") == 0) { SvFileStream aFileStream(out, StreamMode::READ); Graphic aGraphic; - ret = (int) ImportGIF(aFileStream, aGraphic); + ret = static_cast<int>(ImportGIF(aFileStream, aGraphic)); } else if (strcmp(argv[2], "xbm") == 0) { Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) ImportXBM(aFileStream, aGraphic); + ret = static_cast<int>(ImportXBM(aFileStream, aGraphic)); } else if (strcmp(argv[2], "xpm") == 0) { Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) ImportXPM(aFileStream, aGraphic); + ret = static_cast<int>(ImportXPM(aFileStream, aGraphic)); } else if (strcmp(argv[2], "png") == 0) { SvFileStream aFileStream(out, StreamMode::READ); vcl::PNGReader aReader(aFileStream); - ret = (int) !!aReader.Read(); + ret = static_cast<int>(!!aReader.Read()); } else if (strcmp(argv[2], "bmp") == 0) { Bitmap aTarget; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) ReadDIB(aTarget, aFileStream, true); + ret = static_cast<int>(ReadDIB(aTarget, aFileStream, true)); } else if (strcmp(argv[2], "svm") == 0) { @@ -167,7 +167,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "dxf") == 0) { @@ -182,7 +182,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "met") == 0) { @@ -197,7 +197,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if ((strcmp(argv[2], "pbm") == 0) || strcmp(argv[2], "ppm") == 0) { @@ -212,7 +212,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "psd") == 0) { @@ -227,7 +227,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "eps") == 0) { @@ -242,7 +242,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "pct") == 0) { @@ -257,7 +257,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "pcx") == 0) { @@ -272,7 +272,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "ras") == 0) { @@ -287,7 +287,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "tga") == 0) { @@ -302,7 +302,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if (strcmp(argv[2], "tif") == 0) { @@ -317,7 +317,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) } Graphic aGraphic; SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream, aGraphic, nullptr); + ret = static_cast<int>((*pfnImport)(aFileStream, aGraphic, nullptr)); } else if ((strcmp(argv[2], "doc") == 0) || (strcmp(argv[2], "ww8") == 0)) { @@ -331,7 +331,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "ww6") == 0) { @@ -345,7 +345,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "ww2") == 0) { @@ -359,7 +359,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "rtf") == 0) { @@ -373,7 +373,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "html") == 0) { @@ -387,7 +387,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "fodt") == 0) { @@ -401,7 +401,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "docx") == 0) { @@ -415,7 +415,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "fods") == 0) { @@ -429,7 +429,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "xlsx") == 0) { @@ -443,7 +443,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "fodp") == 0) { @@ -457,7 +457,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "pptx") == 0) { @@ -471,7 +471,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "xls") == 0) { @@ -485,7 +485,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "wks") == 0) { @@ -499,7 +499,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "hwp") == 0) { @@ -513,7 +513,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "602") == 0) { @@ -527,7 +527,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "lwp") == 0) { @@ -541,7 +541,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "ppt") == 0) { @@ -555,7 +555,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "cgm") == 0) { @@ -569,7 +569,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "qpw") == 0) { @@ -583,7 +583,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "dif") == 0) { @@ -597,7 +597,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "sc-rtf") == 0) { @@ -611,7 +611,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "slk") == 0) { @@ -625,7 +625,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "ole") == 0) { @@ -639,7 +639,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "mml") == 0) { @@ -653,7 +653,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } else if (strcmp(argv[2], "mtp") == 0) { @@ -667,7 +667,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) aLibrary.release(); } SvFileStream aFileStream(out, StreamMode::READ); - ret = (int) (*pfnImport)(aFileStream); + ret = static_cast<int>((*pfnImport)(aFileStream)); } #endif } diff --git a/vcl/workben/icontest.cxx b/vcl/workben/icontest.cxx index 08524157f906..0806ddcaf98c 100644 --- a/vcl/workben/icontest.cxx +++ b/vcl/workben/icontest.cxx @@ -52,8 +52,8 @@ namespace { { TimeValue aValue; osl_getSystemTime(&aValue); - return (double)aValue.Seconds + - (double)aValue.Nanosec / (1000*1000*1000); + return static_cast<double>(aValue.Seconds) + + static_cast<double>(aValue.Nanosec) / (1000*1000*1000); } } @@ -103,9 +103,9 @@ void MyWorkWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan std::cout << "==> Paint! " << mnPaintCount++ << " (vcl) " << GetSizePixel() << " " << getTimeNow() - mnStartTime << std::endl; Size aGraphicSize( maGraphic.GetSizePixel() ); - float aspect = ((float) aGraphicSize.Width()) / aGraphicSize.Height(); + float aspect = static_cast<float>(aGraphicSize.Width()) / aGraphicSize.Height(); Size aSize; - if( aspect >= ((float) WIDTH) / HEIGHT ) + if( aspect >= (float(WIDTH)) / HEIGHT ) aSize = Size( WIDTH, HEIGHT/aspect ); else aSize = Size( WIDTH * aspect, HEIGHT ); diff --git a/vcl/workben/outdevgrind.cxx b/vcl/workben/outdevgrind.cxx index 60d5c61db837..79e025ad3b79 100644 --- a/vcl/workben/outdevgrind.cxx +++ b/vcl/workben/outdevgrind.cxx @@ -561,7 +561,7 @@ void setupMethodStubs( functor_vector_type& res ) add(res, "DrawTransparent", [&] (OutputDevice * pDev) { - return pDev->DrawTransparent(aPoly3, (sal_uInt16)50); + return pDev->DrawTransparent(aPoly3, sal_uInt16(50)); }); /* void DrawTransparent( const GDIMetaFile& rMtf, @@ -596,8 +596,8 @@ void grindFunc( OutputDevice& rTarget, fprintf( stdout, "Duration: %d ms (%d repetitions)\tOperation: %s\tSetup: %s\n", - (int)(osl_getGlobalTimer() - nStartTime), - (int)nTurns, + static_cast<int>(osl_getGlobalTimer() - nStartTime), + static_cast<int>(nTurns), iter->first, pMsg ); } diff --git a/vcl/workben/svptest.cxx b/vcl/workben/svptest.cxx index b107ccdca990..21a6a86d20fe 100644 --- a/vcl/workben/svptest.cxx +++ b/vcl/workben/svptest.cxx @@ -107,13 +107,13 @@ MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) : { for( int nY = 0; nY < 256; nY++ ) { - double fRed = 255.0-1.5*sqrt((double)(nX*nX+nY*nY)); + double fRed = 255.0-1.5*sqrt(static_cast<double>(nX*nX+nY*nY)); if( fRed < 0.0 ) fRed = 0.0; - double fGreen = 255.0-1.5*sqrt((double)((255-nX)*(255-nX)+nY*nY)); + double fGreen = 255.0-1.5*sqrt(static_cast<double>((255-nX)*(255-nX)+nY*nY)); if( fGreen < 0.0 ) fGreen = 0.0; - double fBlue = 255.0-1.5*sqrt((double)((128-nX)*(128-nX)+(255-nY)*(255-nY))); + double fBlue = 255.0-1.5*sqrt(static_cast<double>((128-nX)*(128-nX)+(255-nY)*(255-nY))); if( fBlue < 0.0 ) fBlue = 0.0; pAcc->SetPixel( nY, nX, BitmapColor( sal_uInt8(fRed), sal_uInt8(fGreen), sal_uInt8(fBlue) ) ); @@ -141,7 +141,7 @@ static Point project( const Point& rPoint ) //double y2 = y1 * cos( angle_z ) - x1 * sin( angle_z ); double z2 = z1; - return Point( (sal_Int32)x2, (sal_Int32)z2 ); + return Point( static_cast<sal_Int32>(x2), static_cast<sal_Int32>(z2) ); } static Color approachColor( const Color& rFrom, const Color& rTo ) @@ -310,11 +310,11 @@ void MyWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rR rRenderContext.DrawLine(project(aP1) + aCenter, project(aP2) + aCenter, aLineInfo); - aPoint.X() = (int)((((double)aP1.X())*cosd - ((double)aP1.Y())*sind)*factor); - aPoint.Y() = (int)((((double)aP1.Y())*cosd + ((double)aP1.X())*sind)*factor); + aPoint.X() = static_cast<int>((static_cast<double>(aP1.X())*cosd - static_cast<double>(aP1.Y())*sind)*factor); + aPoint.Y() = static_cast<int>((static_cast<double>(aP1.Y())*cosd + static_cast<double>(aP1.X())*sind)*factor); aP1 = aPoint; - aPoint.X() = (int)((((double)aP2.X())*cosd - ((double)aP2.Y())*sind)*factor); - aPoint.Y() = (int)((((double)aP2.Y())*cosd + ((double)aP2.X())*sind)*factor); + aPoint.X() = static_cast<int>((static_cast<double>(aP2.X())*cosd - static_cast<double>(aP2.Y())*sind)*factor); + aPoint.Y() = static_cast<int>((static_cast<double>(aP2.Y())*cosd + static_cast<double>(aP2.X())*sind)*factor); aP2 = aPoint; } rRenderContext.Pop(); diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index fdc1f9b85098..f94414b380d2 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -71,8 +71,8 @@ namespace { { TimeValue aValue; osl_getSystemTime(&aValue); - return (double)aValue.Seconds * 1000 + - (double)aValue.Nanosec / (1000*1000); + return static_cast<double>(aValue.Seconds) * 1000 + + static_cast<double>(aValue.Nanosec) / (1000*1000); } } @@ -1087,7 +1087,7 @@ public: { ScopedVclPtr<VirtualDevice> pNested; - if ((int)eType < RENDER_AS_BITMAPEX) + if (static_cast<int>(eType) < RENDER_AS_BITMAPEX) pNested = VclPtr<VirtualDevice>::Create(rDev).get(); else pNested = VclPtr<VirtualDevice>::Create(rDev,DeviceFormat::DEFAULT,DeviceFormat::DEFAULT).get(); @@ -1244,16 +1244,16 @@ public: switch (i % 4) { case 2: - aTransform.shearX((double)((i >> 2) % 8) / 8); - aTransform.shearY((double)((i >> 4) % 8) / 8); + aTransform.shearX(static_cast<double>((i >> 2) % 8) / 8); + aTransform.shearY(static_cast<double>((i >> 4) % 8) / 8); break; case 3: aTransform.translate(-aSize.Width()/2, -aSize.Height()/2); aTransform.rotate(i); if (i & 0x100) { - aTransform.shearX((double)((i >> 2) % 8) / 8); - aTransform.shearY((double)((i >> 4) % 8) / 8); + aTransform.shearX(static_cast<double>((i >> 2) % 8) / 8); + aTransform.shearY(static_cast<double>((i >> 4) % 8) / 8); } aTransform.translate(aSize.Width()/2, aSize.Height()/2); break; @@ -1313,9 +1313,9 @@ public: { BitmapColor aColW = pAccW->GetPixel(y,x); BitmapColor aColB = pAccB->GetPixel(y,x); - long nAR = (long)(aColW.GetRed() - aColB.GetRed()); // (1-a) - long nAG = (long)(aColW.GetGreen() - aColB.GetGreen()); // (1-a) - long nAB = (long)(aColW.GetBlue() - aColB.GetBlue()); // (1-a) + long nAR = static_cast<long>(aColW.GetRed() - aColB.GetRed()); // (1-a) + long nAG = static_cast<long>(aColW.GetGreen() - aColB.GetGreen()); // (1-a) + long nAB = static_cast<long>(aColW.GetBlue() - aColB.GetBlue()); // (1-a) #define CLAMP(a,b,c) (((a)<=(b))?(b):(((a)>=(c))?(c):(a))) @@ -1324,7 +1324,7 @@ public: nInverseAlpha = CLAMP(nInverseAlpha, 0, 255); long nAlpha = 255 - nInverseAlpha; - pMaskAcc->SetPixel(y,x,BitmapColor((sal_Int8)CLAMP(nInverseAlpha,0,255))); + pMaskAcc->SetPixel(y,x,BitmapColor(static_cast<sal_Int8>(CLAMP(nInverseAlpha,0,255)))); // now recover the pixels long nR = (aColW.GetRed() + aColB.GetRed() - nInverseAlpha) * 128; long nG = (aColW.GetGreen() + aColB.GetGreen() - nInverseAlpha) * 128; @@ -1338,9 +1338,9 @@ public: nR /= nAlpha; nG /= nAlpha; nB /= nAlpha; } pRecAcc->SetPixel(y,x,BitmapColor( - (sal_uInt8)CLAMP(nR,0,255), - (sal_uInt8)CLAMP(nG,0,255), - (sal_uInt8)CLAMP(nB,0,255))); + static_cast<sal_uInt8>(CLAMP(nR,0,255)), + static_cast<sal_uInt8>(CLAMP(nG,0,255)), + static_cast<sal_uInt8>(CLAMP(nB,0,255)))); #undef CLAMP } } @@ -1693,7 +1693,7 @@ void DemoRenderer::selectRenderer(const OUString &rName ) int DemoRenderer::selectNextRenderer() { mnSelectedRenderer++; - if (mnSelectedRenderer == (signed) maRenderers.size()) + if (mnSelectedRenderer == static_cast<signed>(maRenderers.size())) mnSelectedRenderer = -1; Invalidate(); return mnSelectedRenderer; |