diff options
-rw-r--r-- | include/tools/b3dtrans.hxx | 2 | ||||
-rw-r--r-- | include/tools/bigint.hxx | 6 | ||||
-rw-r--r-- | include/tools/color.hxx | 6 | ||||
-rw-r--r-- | include/tools/colordata.hxx | 14 | ||||
-rw-r--r-- | include/tools/gen.hxx | 2 | ||||
-rw-r--r-- | include/tools/solar.h | 24 | ||||
-rw-r--r-- | include/tools/vcompat.hxx | 8 | ||||
-rw-r--r-- | tools/qa/cppunit/test_fract.cxx | 2 | ||||
-rw-r--r-- | tools/source/datetime/tdate.cxx | 16 | ||||
-rw-r--r-- | tools/source/datetime/ttime.cxx | 2 | ||||
-rw-r--r-- | tools/source/generic/b3dtrans.cxx | 8 | ||||
-rw-r--r-- | tools/source/generic/bigint.cxx | 102 | ||||
-rw-r--r-- | tools/source/generic/color.cxx | 46 | ||||
-rw-r--r-- | tools/source/generic/point.cxx | 4 | ||||
-rw-r--r-- | tools/source/generic/poly.cxx | 26 | ||||
-rw-r--r-- | tools/source/inet/inetmsg.cxx | 2 | ||||
-rw-r--r-- | tools/source/memtools/mempool.cxx | 2 | ||||
-rw-r--r-- | tools/source/ref/globname.cxx | 30 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 48 | ||||
-rw-r--r-- | tools/source/stream/strmunx.cxx | 12 | ||||
-rw-r--r-- | tools/source/zcodec/zcodec.cxx | 6 |
21 files changed, 184 insertions, 184 deletions
diff --git a/include/tools/b3dtrans.hxx b/include/tools/b3dtrans.hxx index 97b353f0c941..8dcd57e6da26 100644 --- a/include/tools/b3dtrans.hxx +++ b/include/tools/b3dtrans.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_TOOLS_B3DTRANS_HXX #define INCLUDED_TOOLS_B3DTRANS_HXX -#define ZBUFFER_DEPTH_RANGE ((double)(256L * 256L * 256L)) +#define ZBUFFER_DEPTH_RANGE (double(256L * 256L * 256L)) #include <basegfx/matrix/b3dhommatrix.hxx> #include <basegfx/range/b3drange.hxx> diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx index 928ee7b77746..90fe56c8abce 100644 --- a/include/tools/bigint.hxx +++ b/include/tools/bigint.hxx @@ -132,7 +132,7 @@ public: inline BigInt::operator sal_Int16() const { if ( !bIsBig && nVal >= SAL_MIN_INT16 && nVal <= SAL_MAX_INT16 ) - return (sal_Int16)nVal; + return static_cast<sal_Int16>(nVal); assert(false && "out of range"); return 0; } @@ -140,7 +140,7 @@ inline BigInt::operator sal_Int16() const inline BigInt::operator sal_uInt16() const { if ( !bIsBig && nVal >= 0 && nVal <= SAL_MAX_UINT16 ) - return (sal_uInt16)nVal; + return static_cast<sal_uInt16>(nVal); assert(false && "out of range"); return 0; } @@ -156,7 +156,7 @@ inline BigInt::operator sal_Int32() const inline BigInt::operator sal_uInt32() const { if ( !bIsBig && nVal >= 0 ) - return (sal_uInt32)nVal; + return static_cast<sal_uInt32>(nVal); assert(false && "out of range"); return 0; } diff --git a/include/tools/color.hxx b/include/tools/color.hxx index 1d0d239d5af5..5e1b603aa461 100644 --- a/include/tools/color.hxx +++ b/include/tools/color.hxx @@ -157,13 +157,13 @@ public: inline void Color::SetRed( sal_uInt8 nRed ) { mnColor &= 0xFF00FFFF; - mnColor |= ((sal_uInt32)nRed)<<16; + mnColor |= static_cast<sal_uInt32>(nRed)<<16; } inline void Color::SetGreen( sal_uInt8 nGreen ) { mnColor &= 0xFFFF00FF; - mnColor |= ((sal_uInt16)nGreen)<<8; + mnColor |= static_cast<sal_uInt16>(nGreen)<<8; } inline void Color::SetBlue( sal_uInt8 nBlue ) @@ -175,7 +175,7 @@ inline void Color::SetBlue( sal_uInt8 nBlue ) inline void Color::SetTransparency( sal_uInt8 nTransparency ) { mnColor &= 0x00FFFFFF; - mnColor |= ((sal_uInt32)nTransparency)<<24; + mnColor |= static_cast<sal_uInt32>(nTransparency)<<24; } inline bool Color::IsRGBEqual( const Color& rColor ) const diff --git a/include/tools/colordata.hxx b/include/tools/colordata.hxx index 6008d0c0fc24..b77dea1af881 100644 --- a/include/tools/colordata.hxx +++ b/include/tools/colordata.hxx @@ -35,11 +35,11 @@ constexpr ColorData RGB_COLORDATA(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) { return sal_uInt32(b) | (sal_uInt32(g) << 8) | (sal_uInt32(r) << 16); } -#define COLORDATA_RED( n ) ((sal_uInt8)((n)>>16)) -#define COLORDATA_GREEN( n ) ((sal_uInt8)(((sal_uInt16)(n)) >> 8)) -#define COLORDATA_BLUE( n ) ((sal_uInt8)(n)) -#define COLORDATA_TRANSPARENCY( n ) ((sal_uInt8)((n)>>24)) -#define COLORDATA_RGB( n ) ((ColorData)((n) & 0x00FFFFFF)) +#define COLORDATA_RED( n ) (static_cast<sal_uInt8>((n)>>16)) +#define COLORDATA_GREEN( n ) (static_cast<sal_uInt8>((static_cast<sal_uInt16>(n)) >> 8)) +#define COLORDATA_BLUE( n ) (static_cast<sal_uInt8>(n)) +#define COLORDATA_TRANSPARENCY( n ) (static_cast<sal_uInt8>((n)>>24)) +#define COLORDATA_RGB( n ) (static_cast<ColorData>((n) & 0x00FFFFFF)) #define COL_BLACK RGB_COLORDATA( 0x00, 0x00, 0x00 ) #define COL_BLUE RGB_COLORDATA( 0x00, 0x00, 0x80 ) @@ -63,7 +63,7 @@ constexpr ColorData RGB_COLORDATA(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) { #define COL_YELLOW_HIGHLIGHT RGB_COLORDATA( 0xFF, 0xF2, 0x00 ) #define COL_WHITE RGB_COLORDATA( 0xFF, 0xFF, 0xFF ) #define COL_TRANSPARENT TRGB_COLORDATA( 0xFF, 0xFF, 0xFF, 0xFF ) -#define COL_AUTO (ColorData)0xFFFFFFFF +#define COL_AUTO ColorData(0xFFFFFFFF) #define COL_AUTHOR1_DARK RGB_COLORDATA(198, 146, 0) #define COL_AUTHOR1_NORMAL RGB_COLORDATA(255, 255, 158) #define COL_AUTHOR1_LIGHT RGB_COLORDATA(255, 255, 195) @@ -94,7 +94,7 @@ constexpr ColorData RGB_COLORDATA(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) { constexpr sal_uInt8 ColorChannelMerge(sal_uInt8 nDst, sal_uInt8 nSrc, sal_uInt8 nSrcTrans) { - return (sal_uInt8) ((((sal_Int32)nDst-nSrc)*nSrcTrans+((nSrc<<8)|nDst))>>8); + return static_cast<sal_uInt8>(((static_cast<sal_Int32>(nDst)-nSrc)*nSrcTrans+((nSrc<<8)|nDst))>>8); }; #endif diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 2db20125d499..1f72a32078bb 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -327,7 +327,7 @@ inline std::basic_ostream<charT, traits> & operator <<( } // Rectangle -#define RECT_EMPTY ((short)-32767) +#define RECT_EMPTY (short(-32767)) #define RECT_MAX LONG_MAX #define RECT_MIN LONG_MIN diff --git a/include/tools/solar.h b/include/tools/solar.h index a1b10d6e9f01..9ee55c4ad5de 100644 --- a/include/tools/solar.h +++ b/include/tools/solar.h @@ -47,13 +47,13 @@ typedef sal_uInt8 SVBT64[8]; #ifdef __cplusplus inline sal_uInt16 SVBT16ToShort( const SVBT16 p ) { return static_cast<sal_uInt16> - ((sal_uInt16)p[0] - + ((sal_uInt16)p[1] << 8)); } + (static_cast<sal_uInt16>(p[0]) + + (static_cast<sal_uInt16>(p[1]) << 8)); } inline sal_uInt32 SVBT32ToUInt32 ( const SVBT32 p ) { return static_cast<sal_uInt32> - ((sal_uInt32)p[0] - + ((sal_uInt32)p[1] << 8) - + ((sal_uInt32)p[2] << 16) - + ((sal_uInt32)p[3] << 24)); } + (static_cast<sal_uInt32>(p[0]) + + (static_cast<sal_uInt32>(p[1]) << 8) + + (static_cast<sal_uInt32>(p[2]) << 16) + + (static_cast<sal_uInt32>(p[3]) << 24)); } #if defined OSL_LITENDIAN inline double SVBT64ToDouble( const SVBT64 p ) { double n; reinterpret_cast<sal_uInt8*>(&n)[0] = p[0]; @@ -78,12 +78,12 @@ inline double SVBT64ToDouble( const SVBT64 p ) { double n; return n; } #endif -inline void ShortToSVBT16( sal_uInt16 n, SVBT16 p ) { p[0] = (sal_uInt8) n; - p[1] = (sal_uInt8)(n >> 8); } -inline void UInt32ToSVBT32 ( sal_uInt32 n, SVBT32 p ) { p[0] = (sal_uInt8) n; - p[1] = (sal_uInt8)(n >> 8); - p[2] = (sal_uInt8)(n >> 16); - p[3] = (sal_uInt8)(n >> 24); } +inline void ShortToSVBT16( sal_uInt16 n, SVBT16 p ) { p[0] = static_cast<sal_uInt8>(n); + p[1] = static_cast<sal_uInt8>(n >> 8); } +inline void UInt32ToSVBT32 ( sal_uInt32 n, SVBT32 p ) { p[0] = static_cast<sal_uInt8>(n); + p[1] = static_cast<sal_uInt8>(n >> 8); + p[2] = static_cast<sal_uInt8>(n >> 16); + p[3] = static_cast<sal_uInt8>(n >> 24); } #if defined OSL_LITENDIAN inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = reinterpret_cast<sal_uInt8*>(&n)[0]; p[1] = reinterpret_cast<sal_uInt8*>(&n)[1]; diff --git a/include/tools/vcompat.hxx b/include/tools/vcompat.hxx index 0adf6913ea86..85e3b1d44240 100644 --- a/include/tools/vcompat.hxx +++ b/include/tools/vcompat.hxx @@ -24,10 +24,10 @@ inline sal_uInt32 COMPAT_FORMAT( char char1, char char2, char char3, char char4 ) { return - ((sal_uInt32)char1) | - (((sal_uInt32)char2) << 8) | - (((sal_uInt32)char3) << 16) | - (((sal_uInt32)char4) << 24); + static_cast<sal_uInt32>(char1) | + (static_cast<sal_uInt32>(char2) << 8) | + (static_cast<sal_uInt32>(char3) << 16) | + (static_cast<sal_uInt32>(char4) << 24); }; class SvStream; diff --git a/tools/qa/cppunit/test_fract.cxx b/tools/qa/cppunit/test_fract.cxx index 83794340ed51..774427915392 100644 --- a/tools/qa/cppunit/test_fract.cxx +++ b/tools/qa/cppunit/test_fract.cxx @@ -36,7 +36,7 @@ public: { const Fraction aFract(1082130431,1073741824); CPPUNIT_ASSERT_MESSAGE( "Fraction #1 not approximately equal to 1.007812499068677", - rtl::math::approxEqual((double)aFract,1.007812499068677) ); + rtl::math::approxEqual(static_cast<double>(aFract),1.007812499068677) ); Fraction aFract2( aFract ); aFract2.ReduceInaccurate(8); diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx index 93cf49b0ce9c..f6073b85451e 100644 --- a/tools/source/datetime/tdate.cxx +++ b/tools/source/datetime/tdate.cxx @@ -340,13 +340,13 @@ sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay, sal_Int16 nMinimumNumberOfDaysInWeek ) const { short nWeek; - short n1WDay = (short)Date( 1, 1, GetYear() ).GetDayOfWeek(); - short nDayOfYear = (short)GetDayOfYear(); + short n1WDay = static_cast<short>(Date( 1, 1, GetYear() ).GetDayOfWeek()); + short nDayOfYear = static_cast<short>(GetDayOfYear()); // weekdays start at 0, thus decrement one nDayOfYear--; // account for StartDay - n1WDay = (n1WDay+(7-(short)eStartDay)) % 7; + n1WDay = (n1WDay+(7-static_cast<short>(eStartDay))) % 7; if (nMinimumNumberOfDaysInWeek < 1 || 7 < nMinimumNumberOfDaysInWeek) { @@ -363,9 +363,9 @@ sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay, nWeek = 1; else if ( nWeek == 53 ) { - short nDaysInYear = (short)GetDaysInYear(); - short nDaysNextYear = (short)Date( 1, 1, GetNextYear() ).GetDayOfWeek(); - nDaysNextYear = (nDaysNextYear+(7-(short)eStartDay)) % 7; + short nDaysInYear = static_cast<short>(GetDaysInYear()); + short nDaysNextYear = static_cast<short>(Date( 1, 1, GetNextYear() ).GetDayOfWeek()); + nDaysNextYear = (nDaysNextYear+(7-static_cast<short>(eStartDay))) % 7; if ( nDayOfYear > (nDaysInYear-nDaysNextYear-1) ) nWeek = 1; } @@ -413,13 +413,13 @@ sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay, // == still the same week! sal_Int32 nTempDays = GetAsNormalizedDays(); - nTempDays += 6 - (GetDayOfWeek()+(7-(short)eStartDay)) % 7; + nTempDays += 6 - (GetDayOfWeek()+(7-static_cast<short>(eStartDay))) % 7; nWeek = lcl_DaysToDate( nTempDays ).GetWeekOfYear( eStartDay, nMinimumNumberOfDaysInWeek ); } } } - return (sal_uInt16)nWeek; + return static_cast<sal_uInt16>(nWeek); } sal_uInt16 Date::GetDaysInMonth() const diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index cf8108306e06..d74c7659235f 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -407,7 +407,7 @@ Time tools::Time::GetUTCOffset() } nTempTime = abs( nCacheSecOffset ); - tools::Time aTime( 0, (sal_uInt16)nTempTime ); + tools::Time aTime( 0, static_cast<sal_uInt16>(nTempTime) ); if ( nCacheSecOffset < 0 ) aTime = -aTime; return aTime; diff --git a/tools/source/generic/b3dtrans.cxx b/tools/source/generic/b3dtrans.cxx index 1162f24993f6..f2210705112a 100644 --- a/tools/source/generic/b3dtrans.cxx +++ b/tools/source/generic/b3dtrans.cxx @@ -214,8 +214,8 @@ void B3dTransformationSet::CalcViewport() if(GetRatio() != 0.0) { // Compute current aspect ratio of boundaries - double fBoundWidth = (double)(maViewportRectangle.GetWidth() + 1); - double fBoundHeight = (double)(maViewportRectangle.GetHeight() + 1); + double fBoundWidth = static_cast<double>(maViewportRectangle.GetWidth() + 1); + double fBoundHeight = static_cast<double>(maViewportRectangle.GetHeight() + 1); double fActRatio = 1; double fFactor; @@ -270,8 +270,8 @@ void B3dTransformationSet::CalcViewport() // fill parameters for ViewportTransformation // Translation - maTranslate.setX((double)maSetBound.Left() + ((maSetBound.GetWidth() - 1) / 2.0)); - maTranslate.setY((double)maSetBound.Top() + ((maSetBound.GetHeight() - 1) / 2.0)); + maTranslate.setX(static_cast<double>(maSetBound.Left()) + ((maSetBound.GetWidth() - 1) / 2.0)); + maTranslate.setY(static_cast<double>(maSetBound.Top()) + ((maSetBound.GetHeight() - 1) / 2.0)); maTranslate.setZ(ZBUFFER_DEPTH_RANGE / 2.0); // Scaling diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index 6fa9a2c472f0..e80a513496c4 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -65,8 +65,8 @@ void BigInt::MakeBigInt( const BigInt& rVal ) nTmp = nVal; } - nNum[0] = (sal_uInt16)(nTmp & 0xffffL); - nNum[1] = (sal_uInt16)(nTmp >> 16); + nNum[0] = static_cast<sal_uInt16>(nTmp & 0xffffL); + nNum[1] = static_cast<sal_uInt16>(nTmp >> 16); if ( nTmp & 0xffff0000L ) nLen = 2; else @@ -88,7 +88,7 @@ void BigInt::Normalize() else if ( nNum[1] & 0x8000 ) return; else - nVal = ((sal_Int32)nNum[1] << 16) + nNum[0]; + nVal = (static_cast<sal_Int32>(nNum[1]) << 16) + nNum[0]; bIsBig = false; @@ -109,9 +109,9 @@ void BigInt::Mult( const BigInt &rVal, sal_uInt16 nMul ) sal_uInt16 nK = 0; for ( int i = 0; i < rVal.nLen; i++ ) { - sal_uInt32 nTmp = (sal_uInt32)rVal.nNum[i] * (sal_uInt32)nMul + nK; - nK = (sal_uInt16)(nTmp >> 16); - nNum[i] = (sal_uInt16)nTmp; + sal_uInt32 nTmp = static_cast<sal_uInt32>(rVal.nNum[i]) * static_cast<sal_uInt32>(nMul) + nK; + nK = static_cast<sal_uInt16>(nTmp >> 16); + nNum[i] = static_cast<sal_uInt16>(nTmp); } if ( nK ) @@ -131,11 +131,11 @@ void BigInt::Div( sal_uInt16 nDiv, sal_uInt16& rRem ) sal_uInt32 nK = 0; for ( int i = nLen - 1; i >= 0; i-- ) { - sal_uInt32 nTmp = (sal_uInt32)nNum[i] + (nK << 16); - nNum[i] = (sal_uInt16)(nTmp / nDiv); + sal_uInt32 nTmp = static_cast<sal_uInt32>(nNum[i]) + (nK << 16); + nNum[i] = static_cast<sal_uInt16>(nTmp / nDiv); nK = nTmp % nDiv; } - rRem = (sal_uInt16)nK; + rRem = static_cast<sal_uInt16>(nK); if ( nNum[nLen-1] == 0 ) nLen -= 1; @@ -181,12 +181,12 @@ void BigInt::AddLong( BigInt& rB, BigInt& rErg ) sal_Int32 k; sal_Int32 nZ = 0; for (i = 0, k = 0; i < len; i++) { - nZ = (sal_Int32)nNum[i] + (sal_Int32)rB.nNum[i] + k; + nZ = static_cast<sal_Int32>(nNum[i]) + static_cast<sal_Int32>(rB.nNum[i]) + k; if (nZ & 0xff0000L) k = 1; else k = 0; - rErg.nNum[i] = (sal_uInt16)(nZ & 0xffffL); + rErg.nNum[i] = static_cast<sal_uInt16>(nZ & 0xffffL); } // If an overflow occurred, add to solution if (nZ & 0xff0000L) // or if(k) @@ -241,12 +241,12 @@ void BigInt::SubLong( BigInt& rB, BigInt& rErg ) { for (i = 0, k = 0; i < len; i++) { - nZ = (sal_Int32)nNum[i] - (sal_Int32)rB.nNum[i] + k; + nZ = static_cast<sal_Int32>(nNum[i]) - static_cast<sal_Int32>(rB.nNum[i]) + k; if (nZ < 0) k = -1; else k = 0; - rErg.nNum[i] = (sal_uInt16)(nZ & 0xffffL); + rErg.nNum[i] = static_cast<sal_uInt16>(nZ & 0xffffL); } rErg.bIsNeg = bIsNeg; } @@ -254,12 +254,12 @@ void BigInt::SubLong( BigInt& rB, BigInt& rErg ) { for (i = 0, k = 0; i < len; i++) { - nZ = (sal_Int32)rB.nNum[i] - (sal_Int32)nNum[i] + k; + nZ = static_cast<sal_Int32>(rB.nNum[i]) - static_cast<sal_Int32>(nNum[i]) + k; if (nZ < 0) k = -1; else k = 0; - rErg.nNum[i] = (sal_uInt16)(nZ & 0xffffL); + rErg.nNum[i] = static_cast<sal_uInt16>(nZ & 0xffffL); } // if a < b, revert sign rErg.bIsNeg = !bIsNeg; @@ -300,12 +300,12 @@ void BigInt::MultLong( const BigInt& rB, BigInt& rErg ) const { for (i = 0, k = 0; i < nLen; i++) { - nZ = (sal_uInt32)nNum[i] * (sal_uInt32)rB.nNum[j] + - (sal_uInt32)rErg.nNum[i + j] + k; - rErg.nNum[i + j] = (sal_uInt16)(nZ & 0xffffU); + nZ = static_cast<sal_uInt32>(nNum[i]) * static_cast<sal_uInt32>(rB.nNum[j]) + + static_cast<sal_uInt32>(rErg.nNum[i + j]) + k; + rErg.nNum[i + j] = static_cast<sal_uInt16>(nZ & 0xffffU); k = nZ >> 16; } - rErg.nNum[i + j] = (sal_uInt16)k; + rErg.nNum[i + j] = static_cast<sal_uInt16>(k); } } @@ -317,7 +317,7 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const sal_uInt16 nLenB1 = rB.nLen - 1; BigInt aTmpA, aTmpB; - nMult = (sal_uInt16)(0x10000L / ((sal_Int32)rB.nNum[nLenB1] + 1)); + nMult = static_cast<sal_uInt16>(0x10000L / (static_cast<sal_Int32>(rB.nNum[nLenB1]) + 1)); aTmpA.Mult( *this, nMult ); if ( aTmpA.nLen == nLen ) @@ -330,26 +330,26 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const for (j = aTmpA.nLen - 1; j >= nLenB; j--) { // guess divisor - sal_uInt32 nTmp = ( (sal_uInt32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1]; + sal_uInt32 nTmp = ( static_cast<sal_uInt32>(aTmpA.nNum[j]) << 16 ) + aTmpA.nNum[j - 1]; if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1]) nQ = 0xFFFF; else - nQ = (sal_uInt16)(nTmp / aTmpB.nNum[nLenB1]); + nQ = static_cast<sal_uInt16>(nTmp / aTmpB.nNum[nLenB1]); - if ( ((sal_uInt32)aTmpB.nNum[nLenB1 - 1] * nQ) > - ((nTmp - (sal_uInt32)aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2]) + if ( (static_cast<sal_uInt32>(aTmpB.nNum[nLenB1 - 1]) * nQ) > + ((nTmp - static_cast<sal_uInt32>(aTmpB.nNum[nLenB1]) * nQ) << 16) + aTmpA.nNum[j - 2]) nQ--; // Start division nK = 0; for (i = 0; i < nLenB; i++) { - nTmp = (sal_uInt32)aTmpA.nNum[j - nLenB + i] - - ((sal_uInt32)aTmpB.nNum[i] * nQ) + nTmp = static_cast<sal_uInt32>(aTmpA.nNum[j - nLenB + i]) + - (static_cast<sal_uInt32>(aTmpB.nNum[i]) * nQ) - nK; - aTmpA.nNum[j - nLenB + i] = (sal_uInt16)nTmp; - nK = (sal_uInt16) (nTmp >> 16); + aTmpA.nNum[j - nLenB + i] = static_cast<sal_uInt16>(nTmp); + nK = static_cast<sal_uInt16>(nTmp >> 16); if ( nK ) - nK = (sal_uInt16)(0x10000U - nK); + nK = static_cast<sal_uInt16>(0x10000U - nK); } sal_uInt16& rNum( aTmpA.nNum[j - nLenB + i] ); rNum -= nK; @@ -362,7 +362,7 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const for (i = 0; i < nLenB; i++) { nTmp = aTmpA.nNum[j - nLenB + i] + aTmpB.nNum[i] + nK; - aTmpA.nNum[j - nLenB + i] = (sal_uInt16)(nTmp & 0xFFFFL); + aTmpA.nNum[j - nLenB + i] = static_cast<sal_uInt16>(nTmp & 0xFFFFL); if (nTmp & 0xFFFF0000L) nK = 1; else @@ -384,7 +384,7 @@ void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const sal_Int16 nLenB1 = rB.nLen - 1; BigInt aTmpA, aTmpB; - nMult = (sal_uInt16)(0x10000L / ((sal_Int32)rB.nNum[nLenB1] + 1)); + nMult = static_cast<sal_uInt16>(0x10000L / (static_cast<sal_Int32>(rB.nNum[nLenB1]) + 1)); aTmpA.Mult( *this, nMult); if ( aTmpA.nLen == nLen ) @@ -397,26 +397,26 @@ void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const for (j = aTmpA.nLen - 1; j >= nLenB; j--) { // Guess divisor - sal_uInt32 nTmp = ( (sal_uInt32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1]; + sal_uInt32 nTmp = ( static_cast<sal_uInt32>(aTmpA.nNum[j]) << 16 ) + aTmpA.nNum[j - 1]; if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1]) nQ = 0xFFFF; else - nQ = (sal_uInt16)(nTmp / aTmpB.nNum[nLenB1]); + nQ = static_cast<sal_uInt16>(nTmp / aTmpB.nNum[nLenB1]); - if ( ((sal_uInt32)aTmpB.nNum[nLenB1 - 1] * nQ) > + if ( (static_cast<sal_uInt32>(aTmpB.nNum[nLenB1 - 1]) * nQ) > ((nTmp - aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2]) nQ--; // Start division nK = 0; for (i = 0; i < nLenB; i++) { - nTmp = (sal_uInt32)aTmpA.nNum[j - nLenB + i] - - ((sal_uInt32)aTmpB.nNum[i] * nQ) + nTmp = static_cast<sal_uInt32>(aTmpA.nNum[j - nLenB + i]) + - (static_cast<sal_uInt32>(aTmpB.nNum[i]) * nQ) - nK; - aTmpA.nNum[j - nLenB + i] = (sal_uInt16)nTmp; - nK = (sal_uInt16) (nTmp >> 16); + aTmpA.nNum[j - nLenB + i] = static_cast<sal_uInt16>(nTmp); + nK = static_cast<sal_uInt16>(nTmp >> 16); if ( nK ) - nK = (sal_uInt16)(0x10000U - nK); + nK = static_cast<sal_uInt16>(0x10000U - nK); } sal_uInt16& rNum( aTmpA.nNum[j - nLenB + i] ); rNum = rNum - nK; @@ -428,7 +428,7 @@ void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const nK = 0; for (i = 0; i < nLenB; i++) { nTmp = aTmpA.nNum[j - nLenB + i] + aTmpB.nNum[i] + nK; - aTmpA.nNum[j - nLenB + i] = (sal_uInt16)(nTmp & 0xFFFFL); + aTmpA.nNum[j - nLenB + i] = static_cast<sal_uInt16>(nTmp & 0xFFFFL); if (nTmp & 0xFFFF0000L) nK = 1; else @@ -541,13 +541,13 @@ BigInt::BigInt( double nValue ) while ( ( nValue > 65536.0 ) && ( i < MAX_DIGITS ) ) { - nNum[i] = (sal_uInt16) fmod( nValue, 65536.0 ); + nNum[i] = static_cast<sal_uInt16>(fmod( nValue, 65536.0 )); nValue -= nNum[i]; nValue /= 65536.0; i++; } if ( i < MAX_DIGITS ) - nNum[i++] = (sal_uInt16) nValue; + nNum[i++] = static_cast<sal_uInt16>(nValue); nLen = i; @@ -564,8 +564,8 @@ BigInt::BigInt( sal_uInt32 nValue ) { bIsBig = true; bIsNeg = false; - nNum[0] = (sal_uInt16)(nValue & 0xffffU); - nNum[1] = (sal_uInt16)(nValue >> 16); + nNum[0] = static_cast<sal_uInt16>(nValue & 0xffffU); + nNum[1] = static_cast<sal_uInt16>(nValue >> 16); nLen = 2; } else @@ -605,17 +605,17 @@ BigInt::BigInt( sal_Int64 nValue ) BigInt::operator double() const { if ( !bIsBig ) - return (double) nVal; + return static_cast<double>(nVal); else { int i = nLen-1; - double nRet = (double) ((sal_uInt32)nNum[i]); + double nRet = static_cast<double>(static_cast<sal_uInt32>(nNum[i])); while ( i ) { nRet *= 65536.0; i--; - nRet += (double) ((sal_uInt32)nNum[i]); + nRet += static_cast<double>(static_cast<sal_uInt32>(nNum[i])); } if ( bIsNeg ) @@ -748,11 +748,11 @@ BigInt& BigInt::operator/=( const BigInt& rVal ) sal_uInt16 nTmp; if ( rVal.nVal < 0 ) { - nTmp = (sal_uInt16) -rVal.nVal; + nTmp = static_cast<sal_uInt16>(-rVal.nVal); bIsNeg = !bIsNeg; } else - nTmp = (sal_uInt16) rVal.nVal; + nTmp = static_cast<sal_uInt16>(rVal.nVal); Div( nTmp, nTmp ); Normalize(); @@ -798,11 +798,11 @@ BigInt& BigInt::operator%=( const BigInt& rVal ) sal_uInt16 nTmp; if ( rVal.nVal < 0 ) { - nTmp = (sal_uInt16) -rVal.nVal; + nTmp = static_cast<sal_uInt16>(-rVal.nVal); bIsNeg = !bIsNeg; } else - nTmp = (sal_uInt16) rVal.nVal; + nTmp = static_cast<sal_uInt16>(rVal.nVal); Div( nTmp, nTmp ); *this = BigInt( nTmp ); diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index 86689502a7c4..f11f6fd564eb 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -30,25 +30,25 @@ sal_uInt8 Color::GetColorError( const Color& rCompareColor ) const { - const long nErrAbs = labs( (long) rCompareColor.GetRed() - GetRed() ) + - labs( (long) rCompareColor.GetGreen() - GetGreen() ) + - labs( (long) rCompareColor.GetBlue() - GetBlue() ); + const long nErrAbs = labs( static_cast<long>(rCompareColor.GetRed()) - GetRed() ) + + labs( static_cast<long>(rCompareColor.GetGreen()) - GetGreen() ) + + labs( static_cast<long>(rCompareColor.GetBlue()) - GetBlue() ); - return (sal_uInt8) FRound( nErrAbs * 0.3333333333 ); + return static_cast<sal_uInt8>(FRound( nErrAbs * 0.3333333333 )); } void Color::IncreaseLuminance( sal_uInt8 cLumInc ) { - SetRed( (sal_uInt8) SAL_BOUND( (long) COLORDATA_RED( mnColor ) + cLumInc, 0L, 255L ) ); - SetGreen( (sal_uInt8) SAL_BOUND( (long) COLORDATA_GREEN( mnColor ) + cLumInc, 0L, 255L ) ); - SetBlue( (sal_uInt8) SAL_BOUND( (long) COLORDATA_BLUE( mnColor ) + cLumInc, 0L, 255L ) ); + SetRed( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_RED( mnColor )) + cLumInc, 0L, 255L )) ); + SetGreen( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_GREEN( mnColor )) + cLumInc, 0L, 255L )) ); + SetBlue( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_BLUE( mnColor )) + cLumInc, 0L, 255L )) ); } void Color::DecreaseLuminance( sal_uInt8 cLumDec ) { - SetRed( (sal_uInt8) SAL_BOUND( (long) COLORDATA_RED( mnColor ) - cLumDec, 0L, 255L ) ); - SetGreen( (sal_uInt8) SAL_BOUND( (long) COLORDATA_GREEN( mnColor ) - cLumDec, 0L, 255L ) ); - SetBlue( (sal_uInt8) SAL_BOUND( (long) COLORDATA_BLUE( mnColor ) - cLumDec, 0L, 255L ) ); + SetRed( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_RED( mnColor )) - cLumDec, 0L, 255L )) ); + SetGreen( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_GREEN( mnColor )) - cLumDec, 0L, 255L )) ); + SetBlue( static_cast<sal_uInt8>(SAL_BOUND( static_cast<long>(COLORDATA_BLUE( mnColor )) - cLumDec, 0L, 255L )) ); } void Color::DecreaseContrast( sal_uInt8 cContDec ) @@ -58,9 +58,9 @@ void Color::DecreaseContrast( sal_uInt8 cContDec ) const double fM = ( 128.0 - 0.4985 * cContDec ) / 128.0; const double fOff = 128.0 - fM * 128.0; - SetRed( (sal_uInt8) SAL_BOUND( FRound( COLORDATA_RED( mnColor ) * fM + fOff ), 0L, 255L ) ); - SetGreen( (sal_uInt8) SAL_BOUND( FRound( COLORDATA_GREEN( mnColor ) * fM + fOff ), 0L, 255L ) ); - SetBlue( (sal_uInt8) SAL_BOUND( FRound( COLORDATA_BLUE( mnColor ) * fM + fOff ), 0L, 255L ) ); + SetRed( static_cast<sal_uInt8>(SAL_BOUND( FRound( COLORDATA_RED( mnColor ) * fM + fOff ), 0L, 255L )) ); + SetGreen( static_cast<sal_uInt8>(SAL_BOUND( FRound( COLORDATA_GREEN( mnColor ) * fM + fOff ), 0L, 255L )) ); + SetBlue( static_cast<sal_uInt8>(SAL_BOUND( FRound( COLORDATA_BLUE( mnColor ) * fM + fOff ), 0L, 255L )) ); } } @@ -123,29 +123,29 @@ void Color::RGBtoHSB( sal_uInt16& nHue, sal_uInt16& nSat, sal_uInt16& nBri ) con if( c[0] == cMax ) { - dHue = (double)( c[1] - c[2] ) / (double)cDelta; + dHue = static_cast<double>( c[1] - c[2] ) / static_cast<double>(cDelta); } else if( c[1] == cMax ) { - dHue = 2.0 + (double)( c[2] - c[0] ) / (double)cDelta; + dHue = 2.0 + static_cast<double>( c[2] - c[0] ) / static_cast<double>(cDelta); } else if ( c[2] == cMax ) { - dHue = 4.0 + (double)( c[0] - c[1] ) / (double)cDelta; + dHue = 4.0 + static_cast<double>( c[0] - c[1] ) / static_cast<double>(cDelta); } dHue *= 60.0; if( dHue < 0.0 ) dHue += 360.0; - nHue = (sal_uInt16) dHue; + nHue = static_cast<sal_uInt16>(dHue); } } ColorData Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri ) { sal_uInt8 cR=0,cG=0,cB=0; - sal_uInt8 nB = (sal_uInt8) ( nBri * 255 / 100 ); + sal_uInt8 nB = static_cast<sal_uInt8>( nBri * 255 / 100 ); if( nSat == 0 ) { @@ -162,12 +162,12 @@ ColorData Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri ) dH = 0.0; dH /= 60.0; - n = (sal_uInt16) dH; + n = static_cast<sal_uInt16>(dH); f = dH - n; - sal_uInt8 a = (sal_uInt8) ( nB * ( 100 - nSat ) / 100 ); - sal_uInt8 b = (sal_uInt8) ( nB * ( 100 - ( (double)nSat * f ) ) / 100 ); - sal_uInt8 c = (sal_uInt8) ( nB * ( 100 - ( (double)nSat * ( 1.0 - f ) ) ) / 100 ); + sal_uInt8 a = static_cast<sal_uInt8>( nB * ( 100 - nSat ) / 100 ); + sal_uInt8 b = static_cast<sal_uInt8>( nB * ( 100 - ( static_cast<double>(nSat) * f ) ) / 100 ); + sal_uInt8 c = static_cast<sal_uInt8>( nB * ( 100 - ( static_cast<double>(nSat) * ( 1.0 - f ) ) ) / 100 ); switch( n ) { @@ -202,7 +202,7 @@ OUString Color::AsRGBHexString() const return OUString::createFromAscii(ss.str().c_str()); } -#define COL_NAME_USER ((sal_uInt16)0x8000) +#define COL_NAME_USER (sal_uInt16(0x8000)) SvStream& ReadColor( SvStream& rIStream, Color& rColor ) { diff --git a/tools/source/generic/point.cxx b/tools/source/generic/point.cxx index 6d4dc2e1e3ec..0b3d06c4753b 100644 --- a/tools/source/generic/point.cxx +++ b/tools/source/generic/point.cxx @@ -71,8 +71,8 @@ void Point::RotateAround( long& rX, long& rY, long nY = rY-nOriginY; // Rotation... - rX = +((long)(nCos*nX + nSin*nY)) + nOriginX; - rY = -((long)(nSin*nX - nCos*nY)) + nOriginY; + rX = + static_cast<long>(nCos*nX + nSin*nY) + nOriginX; + rY = - static_cast<long>(nSin*nX - nCos*nY) + nOriginY; } } diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 36cb5c69e90d..ce1156bac990 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -177,10 +177,10 @@ ImplPolygon::ImplPolygon( const Point& rCenter, long nRadX, long nRadY ) const bool bOverflow = o3tl::checked_multiply(nRadX, nRadY, nRadXY); if (!bOverflow) { - nPoints = (sal_uInt16) MinMax( + nPoints = static_cast<sal_uInt16>(MinMax( ( F_PI * ( 1.5 * ( nRadX + nRadY ) - - sqrt( (double) labs(nRadXY) ) ) ), - 32, 256 ); + sqrt( static_cast<double>(labs(nRadXY)) ) ) ), + 32, 256 )); } else { @@ -240,10 +240,10 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c const bool bOverflow = o3tl::checked_multiply(nRadX, nRadY, nRadXY); if (!bOverflow) { - nPoints = (sal_uInt16) MinMax( + nPoints = static_cast<sal_uInt16>(MinMax( ( F_PI * ( 1.5 * ( nRadX + nRadY ) - - sqrt( (double) labs(nRadXY) ) ) ), - 32, 256 ); + sqrt( static_cast<double>(labs(nRadXY)) ) ) ), + 32, 256 )); } else { @@ -273,7 +273,7 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c fDiff = F_2PI; // Proportionally shrink number of points( fDiff / (2PI) ); - nPoints = std::max( (sal_uInt16) ( ( fDiff * 0.1591549 ) * nPoints ), (sal_uInt16) 16 ); + nPoints = std::max( static_cast<sal_uInt16>( ( fDiff * 0.1591549 ) * nPoints ), sal_uInt16(16) ); fStep = fDiff / ( nPoints - 1 ); if( PolyStyle::Pie == eStyle ) @@ -771,7 +771,7 @@ Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const else ady += mn/2; ady /= mn; - nNewX = (long)ady + lx; + nNewX = static_cast<long>(ady) + lx; } } else @@ -797,7 +797,7 @@ Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const else adx += md/2; adx /= md; - nNewY = (long)adx + ly; + nNewY = static_cast<long>(adx) + ly; } } @@ -1229,7 +1229,7 @@ void Polygon::AdaptiveSubdivide( Polygon& rResult, const double d ) const } // fill result polygon - rResult = tools::Polygon( (sal_uInt16)aPoints.size() ); // ensure sufficient size for copy + rResult = tools::Polygon( static_cast<sal_uInt16>(aPoints.size()) ); // ensure sufficient size for copy ::std::copy(aPoints.begin(), aPoints.end(), rResult.mpImplPolygon->mxPointAry.get()); } } @@ -1333,7 +1333,7 @@ void Polygon::ImplReduceEdges( tools::Polygon& rPoly, const double& rArea, sal_u else if( fRelLen > 1.0 ) fRelLen = 1.0; - if( ( (sal_uInt32) ( ( ( fLenFact - 1.0 ) * 1000000.0 ) + 0.5 ) < fBound ) && + if( ( static_cast<sal_uInt32>( ( ( fLenFact - 1.0 ) * 1000000.0 ) + 0.5 ) < fBound ) && ( fabs( fGradB ) <= ( fRelLen * fBound * 0.01 ) ) ) { bDeletePoint = true; @@ -1388,8 +1388,8 @@ void Polygon::Scale( double fScaleX, double fScaleY ) for ( sal_uInt16 i = 0, nCount = mpImplPolygon->mnPoints; i < nCount; i++ ) { Point& rPnt = mpImplPolygon->mxPointAry[i]; - rPnt.X() = (long) ( fScaleX * rPnt.X() ); - rPnt.Y() = (long) ( fScaleY * rPnt.Y() ); + rPnt.X() = static_cast<long>( fScaleX * rPnt.X() ); + rPnt.Y() = static_cast<long>( fScaleY * rPnt.Y() ); } } diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 82b23232441f..a3c3a88800a7 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -64,7 +64,7 @@ static sal_uInt16 ParseNumber(const OString& rStr, sal_Int32& nIndex) OString aNum(rStr.copy(nIndex, (n - nIndex))); nIndex = n; - return (sal_uInt16)(aNum.toInt32()); + return static_cast<sal_uInt16>(aNum.toInt32()); } static sal_uInt16 ParseMonth(const OString& rStr, sal_Int32& nIndex) diff --git a/tools/source/memtools/mempool.cxx b/tools/source/memtools/mempool.cxx index 7c1c08002b8a..f38ab6925079 100644 --- a/tools/source/memtools/mempool.cxx +++ b/tools/source/memtools/mempool.cxx @@ -27,7 +27,7 @@ FixedMemPool::FixedMemPool(char const * pTypeName, sal_uInt16 nTypeSize) : m_pTypeName (pTypeName) { char name[RTL_CACHE_NAME_LENGTH + 1]; - snprintf (name, sizeof(name), "FixedMemPool_%d", (int)nTypeSize); + snprintf (name, sizeof(name), "FixedMemPool_%d", static_cast<int>(nTypeSize)); m_pImpl = reinterpret_cast<FixedMemPool_Impl*>(rtl_cache_create (name, nTypeSize, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0)); SAL_INFO("tools.memtools","FixedMemPool::ctor(\"" << m_pTypeName << "\"): " << m_pImpl); } diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx index 3d8ea7b155ef..47f1da1577e5 100644 --- a/tools/source/ref/globname.cxx +++ b/tools/source/ref/globname.cxx @@ -84,11 +84,11 @@ SvGlobalName::SvGlobalName( const css::uno::Sequence < sal_Int8 >& aSeq ) memset( &aResult, 0, sizeof( aResult ) ); if ( aSeq.getLength() == 16 ) { - aResult.Data1 = ( ( ( ( ( ( sal_uInt8 )aSeq[0] << 8 ) + ( sal_uInt8 )aSeq[1] ) << 8 ) + ( sal_uInt8 )aSeq[2] ) << 8 ) + ( sal_uInt8 )aSeq[3]; - aResult.Data2 = ( ( sal_uInt8 )aSeq[4] << 8 ) + ( sal_uInt8 )aSeq[5]; - aResult.Data3 = ( ( sal_uInt8 )aSeq[6] << 8 ) + ( sal_uInt8 )aSeq[7]; + aResult.Data1 = ( ( ( ( ( static_cast<sal_uInt8>(aSeq[0]) << 8 ) + static_cast<sal_uInt8>(aSeq[1]) ) << 8 ) + static_cast<sal_uInt8>(aSeq[2]) ) << 8 ) + static_cast<sal_uInt8>(aSeq[3]); + aResult.Data2 = ( static_cast<sal_uInt8>(aSeq[4]) << 8 ) + static_cast<sal_uInt8>(aSeq[5]); + aResult.Data3 = ( static_cast<sal_uInt8>(aSeq[6]) << 8 ) + static_cast<sal_uInt8>(aSeq[7]); for( int nInd = 0; nInd < 8; nInd++ ) - aResult.Data4[nInd] = ( sal_uInt8 )aSeq[nInd+8]; + aResult.Data4[nInd] = static_cast<sal_uInt8>(aSeq[nInd+8]); } pImp = ::o3tl::cow_wrapper< ImpSvGlobalName >(aResult); @@ -186,7 +186,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) if( rtl::isAsciiDigit( *pStr ) ) nSec = nSec * 16 + (*pStr - '0'); else - nSec = nSec * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 ); + nSec = nSec * 16 + static_cast<sal_uInt16>(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 ); else return false; pStr++; @@ -200,7 +200,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) if( rtl::isAsciiDigit( *pStr ) ) nThird = nThird * 16 + (*pStr - '0'); else - nThird = nThird * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 ); + nThird = nThird * 16 + static_cast<sal_uInt16>(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 ); else return false; pStr++; @@ -215,7 +215,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr ) if( rtl::isAsciiDigit( *pStr ) ) szRemain[i/2] = szRemain[i/2] * 16 + (*pStr - '0'); else - szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 ); + szRemain[i/2] = szRemain[i/2] * 16 + static_cast<sal_Int8>(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 ); else return false; pStr++; @@ -266,14 +266,14 @@ css::uno::Sequence < sal_Int8 > SvGlobalName::GetByteSequence() const // maybe transported remotely css::uno::Sequence< sal_Int8 > aResult( 16 ); - aResult[ 0] = (sal_Int8) (pImp->szData.Data1 >> 24); - aResult[ 1] = (sal_Int8) ((pImp->szData.Data1 << 8 ) >> 24); - aResult[ 2] = (sal_Int8) ((pImp->szData.Data1 << 16 ) >> 24); - aResult[ 3] = (sal_Int8) ((pImp->szData.Data1 << 24 ) >> 24); - aResult[ 4] = (sal_Int8) (pImp->szData.Data2 >> 8); - aResult[ 5] = (sal_Int8) ((pImp->szData.Data2 << 8 ) >> 8); - aResult[ 6] = (sal_Int8) (pImp->szData.Data3 >> 8); - aResult[ 7] = (sal_Int8) ((pImp->szData.Data3 << 8 ) >> 8); + aResult[ 0] = static_cast<sal_Int8>(pImp->szData.Data1 >> 24); + aResult[ 1] = static_cast<sal_Int8>((pImp->szData.Data1 << 8 ) >> 24); + aResult[ 2] = static_cast<sal_Int8>((pImp->szData.Data1 << 16 ) >> 24); + aResult[ 3] = static_cast<sal_Int8>((pImp->szData.Data1 << 24 ) >> 24); + aResult[ 4] = static_cast<sal_Int8>(pImp->szData.Data2 >> 8); + aResult[ 5] = static_cast<sal_Int8>((pImp->szData.Data2 << 8 ) >> 8); + aResult[ 6] = static_cast<sal_Int8>(pImp->szData.Data3 >> 8); + aResult[ 7] = static_cast<sal_Int8>((pImp->szData.Data3 << 8 ) >> 8); aResult[ 8] = pImp->szData.Data4[ 0 ]; aResult[ 9] = pImp->szData.Data4[ 1 ]; aResult[10] = pImp->szData.Data4[ 2 ]; diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index c7d1e3f8414a..3a9f767880dd 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1252,10 +1252,10 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount ) { // => yes if (nCount != 0) - memcpy(pData, m_pBufPos, (size_t) nCount); - m_nBufActualPos = m_nBufActualPos + (sal_uInt16)nCount; + memcpy(pData, m_pBufPos, static_cast<size_t>(nCount)); + m_nBufActualPos = m_nBufActualPos + static_cast<sal_uInt16>(nCount); m_pBufPos += nCount; - m_nBufFree = m_nBufFree - (sal_uInt16)nCount; + m_nBufFree = m_nBufFree - static_cast<sal_uInt16>(nCount); } else { @@ -1290,13 +1290,13 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount ) std::size_t nCountTmp = GetData( m_pRWBuf.get(), m_nBufSize ); if (m_nCryptMask) EncryptBuffer(m_pRWBuf.get(), nCountTmp); - m_nBufActualLen = (sal_uInt16)nCountTmp; + m_nBufActualLen = static_cast<sal_uInt16>(nCountTmp); if( nCount > nCountTmp ) { nCount = nCountTmp; // trim count back, EOF see below } - memcpy( pData, m_pRWBuf.get(), (size_t)nCount ); - m_nBufActualPos = (sal_uInt16)nCount; + memcpy( pData, m_pRWBuf.get(), static_cast<size_t>(nCount) ); + m_nBufActualPos = static_cast<sal_uInt16>(nCount); m_pBufPos = m_pRWBuf.get() + nCount; } } @@ -1337,8 +1337,8 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount ) m_isIoWrite = true; if (nCount <= static_cast<std::size_t>(m_nBufSize - m_nBufActualPos)) { - memcpy( m_pBufPos, pData, (size_t)nCount ); - m_nBufActualPos = m_nBufActualPos + (sal_uInt16)nCount; + memcpy( m_pBufPos, pData, static_cast<size_t>(nCount) ); + m_nBufActualPos = m_nBufActualPos + static_cast<sal_uInt16>(nCount); // Update length if buffer was updated if (m_nBufActualPos > m_nBufActualLen) m_nBufActualLen = m_nBufActualPos; @@ -1368,13 +1368,13 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount ) else { // Copy block to buffer - memcpy( m_pRWBuf.get(), pData, (size_t)nCount ); + memcpy( m_pRWBuf.get(), pData, static_cast<size_t>(nCount) ); // Mind the order! m_nBufFilePos += m_nBufActualPos; - m_nBufActualPos = (sal_uInt16)nCount; + m_nBufActualPos = static_cast<sal_uInt16>(nCount); m_pBufPos = m_pRWBuf.get() + nCount; - m_nBufActualLen = (sal_uInt16)nCount; + m_nBufActualLen = static_cast<sal_uInt16>(nCount); m_isDirty = true; } } @@ -1396,7 +1396,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos) // Is seek position within buffer? if (nFilePos >= m_nBufFilePos && nFilePos <= (m_nBufFilePos + m_nBufActualLen)) { - m_nBufActualPos = (sal_uInt16)(nFilePos - m_nBufFilePos); + m_nBufActualPos = static_cast<sal_uInt16>(nFilePos - m_nBufFilePos); m_pBufPos = m_pRWBuf.get() + m_nBufActualPos; // Update m_nBufFree to avoid crash upon PutBack m_nBufFree = m_nBufActualLen - m_nBufActualPos; @@ -1441,11 +1441,11 @@ void SvStream::RefreshBuffer() { FlushBuffer(m_isConsistent); SeekPos(m_nBufFilePos); - m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf.get(), m_nBufSize ); + m_nBufActualLen = static_cast<sal_uInt16>(GetData( m_pRWBuf.get(), m_nBufSize )); if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING) m_nError = ERRCODE_NONE; if (m_nCryptMask) - EncryptBuffer(m_pRWBuf.get(), (std::size_t)m_nBufActualLen); + EncryptBuffer(m_pRWBuf.get(), static_cast<std::size_t>(m_nBufActualLen)); m_isConsistent = true; m_isIoRead = m_isIoWrite = false; } @@ -1483,7 +1483,7 @@ std::size_t SvStream::CryptAndWriteBuffer( const void* pStart, std::size_t nLen) else nBufCount = nLen; nLen -= nBufCount; - memcpy( pTemp, pDataPtr, (sal_uInt16)nBufCount ); + memcpy( pTemp, pDataPtr, static_cast<sal_uInt16>(nBufCount) ); // ******** Encrypt ******** for (unsigned char & rn : pTemp) { @@ -1700,7 +1700,7 @@ std::size_t SvMemoryStream::GetData( void* pData, std::size_t nCount ) nCount = nMaxCount; if (nCount != 0) { - memcpy( pData, pBuf+nPos, (size_t)nCount ); + memcpy( pData, pBuf+nPos, static_cast<size_t>(nCount) ); } nPos += nCount; return nCount; @@ -1753,7 +1753,7 @@ std::size_t SvMemoryStream::PutData( const void* pData, std::size_t nCount ) } } assert(pBuf && "Possibly Reallocate failed"); - memcpy( pBuf+nPos, pData, (size_t)nCount); + memcpy( pBuf+nPos, pData, static_cast<size_t>(nCount)); nPos += nCount; if( nPos > nEndOfData ) @@ -1778,8 +1778,8 @@ sal_uInt64 SvMemoryStream::SeekPos(sal_uInt64 const nNewPos) { if( nResize ) // Is extension possible? { - long nDiff = (long)(nNewPos - nSize + 1); - nDiff += (long)nResize; + long nDiff = static_cast<long>(nNewPos - nSize + 1); + nDiff += static_cast<long>(nResize); ReAllocateMemory( nDiff ); nPos = nNewPos; nEndOfData = nNewPos; @@ -1821,9 +1821,9 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff ) return false; bool bRetVal = false; - long nTemp = (long)nSize; + long nTemp = static_cast<long>(nSize); nTemp += nDiff; - std::size_t nNewSize = (std::size_t)nTemp; + std::size_t nNewSize = static_cast<std::size_t>(nTemp); if( nNewSize ) { @@ -1832,7 +1832,7 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff ) bRetVal = true; // Success! if( nNewSize < nSize ) // Are we shrinking? { - memcpy( pNewBuf, pBuf, (size_t)nNewSize ); + memcpy( pNewBuf, pBuf, static_cast<size_t>(nNewSize) ); if( nPos > nNewSize ) nPos = 0; if( nEndOfData >= nNewSize ) @@ -1842,7 +1842,7 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff ) { if (nSize != 0) { - memcpy( pNewBuf, pBuf, (size_t)nSize ); + memcpy( pNewBuf, pBuf, static_cast<size_t>(nSize) ); } memset(pNewBuf + nSize, 0x00, nNewSize - nSize); } @@ -1909,7 +1909,7 @@ void SvMemoryStream::SetSize(sal_uInt64 const nNewSize) return; } - long nDiff = (long)nNewSize - (long)nSize; + long nDiff = static_cast<long>(nNewSize) - static_cast<long>(nSize); ReAllocateMemory( nDiff ); } diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index d06544e72031..86a296b1d598 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -211,7 +211,7 @@ static ErrCode GetSvError( int nErrno ) { ETXTBSY, SVSTREAM_ACCESS_DENIED }, { EEXIST, SVSTREAM_CANNOT_MAKE }, { ENOSPC, SVSTREAM_DISK_FULL }, - { (int)0xFFFF, SVSTREAM_GENERALERROR } + { int(0xFFFF), SVSTREAM_GENERALERROR } }; ErrCode nRetVal = SVSTREAM_GENERALERROR; // default error @@ -306,14 +306,14 @@ std::size_t SvFileStream::GetData( void* pData, std::size_t nSize ) sal_uInt64 nRead = 0; if ( IsOpen() ) { - oslFileError rc = osl_readFile(pInstanceData->rHandle,pData,(sal_uInt64)nSize,&nRead); + oslFileError rc = osl_readFile(pInstanceData->rHandle,pData,static_cast<sal_uInt64>(nSize),&nRead); if ( rc != osl_File_E_None ) { SetError( ::GetSvError( rc )); return -1; } } - return (std::size_t)nRead; + return static_cast<std::size_t>(nRead); } std::size_t SvFileStream::PutData( const void* pData, std::size_t nSize ) @@ -323,7 +323,7 @@ std::size_t SvFileStream::PutData( const void* pData, std::size_t nSize ) sal_uInt64 nWrite = 0; if ( IsOpen() ) { - oslFileError rc = osl_writeFile(pInstanceData->rHandle,pData,(sal_uInt64)nSize,&nWrite); + oslFileError rc = osl_writeFile(pInstanceData->rHandle,pData,static_cast<sal_uInt64>(nSize),&nWrite); if ( rc != osl_File_E_None ) { SetError( ::GetSvError( rc ) ); @@ -332,13 +332,13 @@ std::size_t SvFileStream::PutData( const void* pData, std::size_t nSize ) else if( !nWrite ) SetError( SVSTREAM_DISK_FULL ); } - return (std::size_t)nWrite; + return static_cast<std::size_t>(nWrite); } sal_uInt64 SvFileStream::SeekPos(sal_uInt64 const nPos) { // check if a truncated STREAM_SEEK_TO_END was passed - assert(nPos != (sal_uInt64)(sal_uInt32)STREAM_SEEK_TO_END); + assert(nPos != sal_uInt64(sal_uInt32(STREAM_SEEK_TO_END))); if ( IsOpen() ) { oslFileError rc; diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx index 258677952a3d..174753bac248 100644 --- a/tools/source/zcodec/zcodec.cxx +++ b/tools/source/zcodec/zcodec.cxx @@ -166,7 +166,7 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm ) while ( ( err != Z_STREAM_END) && ( PZSTREAM->avail_in || mnInToRead ) ); ImplWriteBack(); - return ( mbStatus ) ? (long)(PZSTREAM->total_out - nOldTotal_Out) : -1; + return ( mbStatus ) ? static_cast<long>(PZSTREAM->total_out - nOldTotal_Out) : -1; } void ZCodec::Write( SvStream& rOStm, const sal_uInt8* pData, sal_uInt32 nSize ) @@ -235,7 +235,7 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) if ( err == Z_STREAM_END ) mbFinish = true; - return (mbStatus ? (long)(nSize - PZSTREAM->avail_out) : -1); + return (mbStatus ? static_cast<long>(nSize - PZSTREAM->avail_out) : -1); } long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) @@ -288,7 +288,7 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize if ( err == Z_STREAM_END ) mbFinish = true; - return (mbStatus ? (long)(nSize - PZSTREAM->avail_out) : -1); + return (mbStatus ? static_cast<long>(nSize - PZSTREAM->avail_out) : -1); } void ZCodec::ImplWriteBack() |