diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:10:40 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:10:40 +0100 |
commit | 55f07d4daa76503530d96b9c20b53c59bcd5bcf9 (patch) | |
tree | 7ad8a720341e38258dab12597d25616c3bff8807 /vcl/unx/generic/dtrans | |
parent | e235da515af0e2a5d5a0cf80773943b65fdb8f7b (diff) |
More loplugin:cstylecast: vcl
auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable
loplugin:cstylecast for some more cases" plus
solenv/clang-format/reformat-formatted-files
Change-Id: I363c01a1ae9e863fca4fb4589829492d7280d711
Diffstat (limited to 'vcl/unx/generic/dtrans')
-rw-r--r-- | vcl/unx/generic/dtrans/X11_selection.cxx | 12 | ||||
-rw-r--r-- | vcl/unx/generic/dtrans/bmp.cxx | 94 |
2 files changed, 53 insertions, 53 deletions
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; |