diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:27:27 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-01-12 20:27:27 +0100 |
commit | f8558f844674c7ba541699708e95f509026c9407 (patch) | |
tree | b402baade1bf3b1bfe1cf89b3cacb275c020e44b /connectivity | |
parent | 4a7fb6abcd8999d64acefb598dfe85fff042d533 (diff) |
More loplugin:cstylecast: connectivity
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: Idbefb16acae20ab137497e78c9bc5dc5634c07fe
Diffstat (limited to 'connectivity')
72 files changed, 364 insertions, 365 deletions
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index 39acab5c1092..3ba09ee62430 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -80,7 +80,7 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, { OUString aTemp; _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp; - sal_Int32 nIndex = (sal_Int32)-1; + sal_Int32 nIndex = sal_Int32(-1); const OUString sQuot("\'"); do { diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx index 4e6ae28ac7de..ec53891aae38 100644 --- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -189,7 +189,7 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& colum void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) { - if(columnIndex >= (sal_Int32)(*m_aRowsIter).size() || columnIndex < 1) + if(columnIndex >= static_cast<sal_Int32>((*m_aRowsIter).size()) || columnIndex < 1) ::dbtools::throwInvalidIndexException(*this); } @@ -675,14 +675,14 @@ ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::getEmptyValue() /// return an ORowSetValueDecorator with 0 as value ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get0Value() { - static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0); + static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator(sal_Int32(0)); return a0ValueRef; } /// return an ORowSetValueDecorator with 1 as value ORowSetValueDecoratorRef const & ODatabaseMetaDataResultSet::get1Value() { - static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator((sal_Int32)1); + static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator(sal_Int32(1)); return a1ValueRef; } diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 9bd18eef6df6..625ac761fc09 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -964,7 +964,7 @@ OUString ORowSetValue::getString( ) const const sal_Int8* pBegin = aSeq.getConstArray(); const sal_Int8* pEnd = pBegin + aSeq.getLength(); for(;pBegin != pEnd;++pBegin) - sVal.append((sal_Int32)*pBegin,16); + sVal.append(static_cast<sal_Int32>(*pBegin),16); aRet = sVal.makeStringAndClear(); } break; @@ -996,7 +996,7 @@ OUString ORowSetValue::getString( ) const { if ( xClob.is() ) { - aRet = xClob->getSubString(1,(sal_Int32)xClob->length() ); + aRet = xClob->getSubString(1,static_cast<sal_Int32>(xClob->length()) ); } } } @@ -1683,16 +1683,16 @@ float ORowSetValue::getFloat() const break; case DataType::DOUBLE: case DataType::REAL: - nRet = (float)m_aValue.m_nDouble; + nRet = static_cast<float>(m_aValue.m_nDouble); break; case DataType::DATE: - nRet = (float)dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Date*>(m_aValue.m_pValue)); + nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Date*>(m_aValue.m_pValue))); break; case DataType::TIME: - nRet = (float)dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Time*>(m_aValue.m_pValue)); + nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Time*>(m_aValue.m_pValue))); break; case DataType::TIMESTAMP: - nRet = (float)dbtools::DBTypeConversion::toDouble(*static_cast<css::util::DateTime*>(m_aValue.m_pValue)); + nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::DateTime*>(m_aValue.m_pValue))); break; case DataType::BINARY: case DataType::VARBINARY: @@ -1715,19 +1715,19 @@ float ORowSetValue::getFloat() const if ( m_bSigned ) nRet = m_aValue.m_nInt16; else - nRet = (float)m_aValue.m_uInt16; + nRet = static_cast<float>(m_aValue.m_uInt16); break; case DataType::INTEGER: if ( m_bSigned ) - nRet = (float)m_aValue.m_nInt32; + nRet = static_cast<float>(m_aValue.m_nInt32); else - nRet = (float)m_aValue.m_uInt32; + nRet = static_cast<float>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned ) - nRet = (float)m_aValue.m_nInt64; + nRet = static_cast<float>(m_aValue.m_nInt64); else - nRet = (float)m_aValue.m_uInt64; + nRet = static_cast<float>(m_aValue.m_uInt64); break; default: { @@ -1905,7 +1905,7 @@ css::util::Date ORowSetValue::getDate() const case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: - aValue = DBTypeConversion::toDate((double)*this); + aValue = DBTypeConversion::toDate(static_cast<double>(*this)); break; case DataType::DATE: @@ -1939,7 +1939,7 @@ css::util::Date ORowSetValue::getDate() const case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::TIME: - aValue = DBTypeConversion::toDate( (double)0 ); + aValue = DBTypeConversion::toDate( double(0) ); break; } } @@ -1960,12 +1960,12 @@ css::util::Time ORowSetValue::getTime() const break; case DataType::DECIMAL: case DataType::NUMERIC: - aValue = DBTypeConversion::toTime((double)*this); + aValue = DBTypeConversion::toTime(static_cast<double>(*this)); break; case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: - aValue = DBTypeConversion::toTime((double)*this); + aValue = DBTypeConversion::toTime(static_cast<double>(*this)); break; case DataType::TIMESTAMP: { @@ -2004,12 +2004,12 @@ css::util::DateTime ORowSetValue::getDateTime() const break; case DataType::DECIMAL: case DataType::NUMERIC: - aValue = DBTypeConversion::toDateTime((double)*this); + aValue = DBTypeConversion::toDateTime(static_cast<double>(*this)); break; case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: - aValue = DBTypeConversion::toDateTime((double)*this); + aValue = DBTypeConversion::toDateTime(static_cast<double>(*this)); break; case DataType::DATE: { diff --git a/connectivity/source/commontools/TConnection.cxx b/connectivity/source/commontools/TConnection.cxx index 62b14f11f6a0..3a7705bd75fb 100644 --- a/connectivity/source/commontools/TConnection.cxx +++ b/connectivity/source/commontools/TConnection.cxx @@ -59,7 +59,7 @@ sal_Int64 SAL_CALL OMetaConnection::getSomething( const css::uno::Sequence< sal_ { return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) ? reinterpret_cast< sal_Int64 >( this ) - : (sal_Int64)0; + : sal_Int64(0); } Sequence< sal_Int8 > OMetaConnection::getUnoTunnelImplementationId() diff --git a/connectivity/source/commontools/TSkipDeletedSet.cxx b/connectivity/source/commontools/TSkipDeletedSet.cxx index d63bc5e23275..d3ae392f7a09 100644 --- a/connectivity/source/commontools/TSkipDeletedSet.cxx +++ b/connectivity/source/commontools/TSkipDeletedSet.cxx @@ -148,7 +148,7 @@ bool OSkipDeletedSet::skipDeleted(IResultSetHelper::Movement _eCursorPosition, s const sal_Int32 nDriverPos = m_pHelper->getDriverPos(); if ( m_bDeletedVisible ) { - if ( nDriverPos > (sal_Int32)m_aBookmarksPositions.size() ) + if ( nDriverPos > static_cast<sal_Int32>(m_aBookmarksPositions.size()) ) m_aBookmarksPositions.push_back(nDriverPos); } else if ( std::find(m_aBookmarksPositions.begin(),m_aBookmarksPositions.end(),nDriverPos) == m_aBookmarksPositions.end() ) @@ -167,7 +167,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData) sal_Int32 nNewPos = _nPos; if(nNewPos > 0) { - if((sal_Int32)m_aBookmarksPositions.size() < nNewPos) + if(static_cast<sal_Int32>(m_aBookmarksPositions.size()) < nNewPos) { // bookmark isn't known yet // start at the last known position diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx index 4d24bc3a7829..fe600a7b8063 100644 --- a/connectivity/source/commontools/dbconversion.cxx +++ b/connectivity/source/commontools/dbconversion.cxx @@ -121,9 +121,9 @@ namespace dbtools css::util::Date DBTypeConversion::toDate(const sal_Int32 _nVal) { css::util::Date aReturn; - aReturn.Day = (sal_uInt16)(_nVal % 100); - aReturn.Month = (sal_uInt16)((_nVal / 100) % 100); - aReturn.Year = (sal_uInt16)(_nVal / 10000); + aReturn.Day = static_cast<sal_uInt16>(_nVal % 100); + aReturn.Month = static_cast<sal_uInt16>((_nVal / 100) % 100); + aReturn.Year = static_cast<sal_uInt16>(_nVal / 10000); return aReturn; } @@ -209,7 +209,7 @@ namespace dbtools do { nTempDays = nDays; - rYear = (sal_uInt16)((nTempDays / 365) - i); + rYear = static_cast<sal_uInt16>((nTempDays / 365) - i); nTempDays -= (rYear-1) * 365; nTempDays -= ((rYear-1) / 4) - ((rYear-1) / 100) + ((rYear-1) / 400); bCalc = false; @@ -238,7 +238,7 @@ namespace dbtools nTempDays -= implDaysInMonth( rMonth, rYear ); rMonth++; } - rDay = (sal_uInt16)nTempDays; + rDay = static_cast<sal_uInt16>(nTempDays); } sal_Int32 DBTypeConversion::toDays(const css::util::Date& _rVal, const css::util::Date& _rNullDate) @@ -249,13 +249,13 @@ namespace dbtools double DBTypeConversion::toDouble(const css::util::Date& rVal, const css::util::Date& _rNullDate) { - return (double)toDays(rVal, _rNullDate); + return static_cast<double>(toDays(rVal, _rNullDate)); } double DBTypeConversion::toDouble(const css::util::Time& rVal) { - return (double)getNsFromTime(rVal) / fNanoSecondsPerDay; + return static_cast<double>(getNsFromTime(rVal)) / fNanoSecondsPerDay; } @@ -269,7 +269,7 @@ namespace dbtools aTimePart.Seconds = _rVal.Seconds; aTimePart.NanoSeconds = _rVal.NanoSeconds; - return ((double)nTime) + toDouble(aTimePart); + return static_cast<double>(nTime) + toDouble(aTimePart); } static void addDays(const sal_Int32 nDays, css::util::Date& _rDate) @@ -323,9 +323,9 @@ namespace dbtools css::util::Date aRet = _rNullDate; if (dVal >= 0) - addDays((sal_Int32)dVal,aRet); + addDays(static_cast<sal_Int32>(dVal),aRet); else - subDays((sal_uInt32)(-dVal),aRet); + subDays(static_cast<sal_uInt32>(-dVal),aRet); // x -= (sal_uInt32)(-nDays); return aRet; @@ -333,10 +333,10 @@ namespace dbtools css::util::Time DBTypeConversion::toTime(const double dVal, short nDigits) { - const sal_Int32 nDays = (sal_Int32)dVal; + const sal_Int32 nDays = static_cast<sal_Int32>(dVal); sal_Int64 nNS; { - double fSeconds((dVal - (double)nDays) * (fNanoSecondsPerDay / nanoSecInSec)); + double fSeconds((dVal - static_cast<double>(nDays)) * (fNanoSecondsPerDay / nanoSecInSec)); fSeconds = ::rtl::math::round( fSeconds, nDigits ); nNS = fSeconds * nanoSecInSec; } @@ -412,12 +412,12 @@ namespace dbtools sal_uInt16 nYear = 0, nMonth = 0, nDay = 0; - nYear = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32(); + nYear = static_cast<sal_uInt16>(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); if(nIndex != -1) { - nMonth = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32(); + nMonth = static_cast<sal_uInt16>(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); if(nIndex != -1) - nDay = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32(); + nDay = static_cast<sal_uInt16>(_sSQLString.getToken(0,sDateSep,nIndex).toInt32()); } return css::util::Date(nDay,nMonth,nYear); diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 653c8dcc7717..daca0a341c63 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -170,22 +170,22 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, { try { - nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale); + nFormat = _xTypes->getStandardFormat(static_cast<sal_Int16>(nNumberType), _rLocale); if(_nScale > 0) { // generate a new format if necessary Reference< XNumberFormats > xFormats(_xTypes, UNO_QUERY); - OUString sNewFormat = xFormats->generateFormat( 0, _rLocale, false, false, (sal_Int16)_nScale, 1); + OUString sNewFormat = xFormats->generateFormat( 0, _rLocale, false, false, static_cast<sal_Int16>(_nScale), 1); // and add it to the formatter if necessary nFormat = xFormats->queryKey(sNewFormat, _rLocale, false); - if (nFormat == (sal_Int32)-1) + if (nFormat == sal_Int32(-1)) nFormat = xFormats->addNew(sNewFormat, _rLocale); } } catch (Exception&) { - nFormat = _xTypes->getStandardFormat((sal_Int16)nNumberType, _rLocale); + nFormat = _xTypes->getStandardFormat(static_cast<sal_Int16>(nNumberType), _rLocale); } } break; case DataType::CHAR: @@ -1122,7 +1122,7 @@ try // ... and add at FormatsSupplier (if needed) sal_Int32 nKey = xFormats->queryKey(sNewFormat, _rLocale, false); - if (nKey == (sal_Int32)-1) + if (nKey == sal_Int32(-1)) { // not added yet in my formatter ... nKey = xFormats->addNew(sNewFormat, _rLocale); } @@ -1643,7 +1643,7 @@ namespace { if ( m_aSet.empty() ) return m_xSource->getByIndex(Index); - if ( m_aSet.size() < (size_t)Index ) + if ( m_aSet.size() < static_cast<size_t>(Index) ) throw IndexOutOfBoundsException(); std::vector<bool, std::allocator<bool> >::const_iterator aIter = m_aSet.begin(); diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx index 9934bdb39aad..cd77c028157e 100644 --- a/connectivity/source/commontools/parameters.cxx +++ b/connectivity/source/commontools/parameters.cxx @@ -485,7 +485,7 @@ namespace dbtools ++aIndex ) { - if ( ( m_aParametersVisited.size() > (size_t)*aIndex ) && m_aParametersVisited[ *aIndex ] ) + if ( ( m_aParametersVisited.size() > static_cast<size_t>(*aIndex) ) && m_aParametersVisited[ *aIndex ] ) { // exclude this index *aIndex = -1; ++nAlreadyVisited; @@ -973,7 +973,7 @@ namespace dbtools void ParameterManager::externalParameterVisited( sal_Int32 _nIndex ) { - if ( m_aParametersVisited.size() < (size_t)_nIndex ) + if ( m_aParametersVisited.size() < static_cast<size_t>(_nIndex) ) { m_aParametersVisited.reserve( _nIndex ); for ( sal_Int32 i = m_aParametersVisited.size(); i < _nIndex; ++i ) diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx index b204e8d4727e..d644eb661e5a 100644 --- a/connectivity/source/commontools/paramwrapper.cxx +++ b/connectivity/source/commontools/paramwrapper.cxx @@ -310,7 +310,7 @@ namespace param ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); - if ( ( _nIndex < 0 ) || ( _nIndex >= (sal_Int32)m_aParameters.size() ) ) + if ( ( _nIndex < 0 ) || ( _nIndex >= static_cast<sal_Int32>(m_aParameters.size()) ) ) throw IndexOutOfBoundsException(); return makeAny( Reference< XPropertySet >( m_aParameters[ _nIndex ].get() ) ); diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 06764a4f34ea..ac64032aaa7b 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -256,7 +256,7 @@ namespace dbtools sTransformedText.clear(); pParseNode->parseNodeToPredicateStr( sTransformedText, m_xConnection, m_xFormatter, _rxField, OUString(), - rParseContext.getPreferredLocale(), (sal_Char)nDecSeparator, &rParseContext + rParseContext.getPreferredLocale(), static_cast<sal_Char>(nDecSeparator), &rParseContext ); _rPredicateValue = sTransformedText; delete pParseNode; diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index 16304fa224b2..142e8a2bf6a6 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -363,14 +363,14 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x if ( nIntTime == ::tools::Time::nanoSecPerDay) nIntTime = 0; // 23:59:59.9999999995 and above is 00:00:00.00 css::util::Time aTime; - aTime.NanoSeconds = (sal_uInt32)( nIntTime % ::tools::Time::nanoSecPerSec ); + aTime.NanoSeconds = static_cast<sal_uInt32>( nIntTime % ::tools::Time::nanoSecPerSec ); nIntTime /= ::tools::Time::nanoSecPerSec; - aTime.Seconds = (sal_uInt16)( nIntTime % 60 ); + aTime.Seconds = static_cast<sal_uInt16>( nIntTime % 60 ); nIntTime /= 60; - aTime.Minutes = (sal_uInt16)( nIntTime % 60 ); + aTime.Minutes = static_cast<sal_uInt16>( nIntTime % 60 ); nIntTime /= 60; OSL_ENSURE( nIntTime < 24, "error in time calculation" ); - aTime.Hours = (sal_uInt16) nIntTime; + aTime.Hours = static_cast<sal_uInt16>(nIntTime); rValue = aTime; } else @@ -382,7 +382,7 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x double fCellVal = xCell->getValue(); double fDays = ::rtl::math::approxFloor( fCellVal ); double fTime = fCellVal - fDays; - long nIntDays = (long)fDays; + long nIntDays = static_cast<long>(fDays); sal_Int64 nIntTime = ::rtl::math::round( fTime * static_cast<double>(::tools::Time::nanoSecPerDay) ); if ( nIntTime == ::tools::Time::nanoSecPerDay ) { @@ -392,14 +392,14 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x css::util::DateTime aDateTime; - aDateTime.NanoSeconds = (sal_uInt16)( nIntTime % ::tools::Time::nanoSecPerSec ); + aDateTime.NanoSeconds = static_cast<sal_uInt16>( nIntTime % ::tools::Time::nanoSecPerSec ); nIntTime /= ::tools::Time::nanoSecPerSec; - aDateTime.Seconds = (sal_uInt16)( nIntTime % 60 ); + aDateTime.Seconds = static_cast<sal_uInt16>( nIntTime % 60 ); nIntTime /= 60; - aDateTime.Minutes = (sal_uInt16)( nIntTime % 60 ); + aDateTime.Minutes = static_cast<sal_uInt16>( nIntTime % 60 ); nIntTime /= 60; OSL_ENSURE( nIntTime < 24, "error in time calculation" ); - aDateTime.Hours = (sal_uInt16) nIntTime; + aDateTime.Hours = static_cast<sal_uInt16>(nIntTime); ::Date aDate( rNullDate ); aDate.AddDays( nIntDays ); @@ -422,13 +422,13 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x static OUString lcl_GetColumnStr( sal_Int32 nColumn ) { if ( nColumn < 26 ) - return OUString( (sal_Unicode) ( 'A' + nColumn ) ); + return OUString( static_cast<sal_Unicode>( 'A' + nColumn ) ); else { OUStringBuffer aBuffer(2); aBuffer.setLength( 2 ); - aBuffer[0] = (sal_Unicode) ( 'A' + ( nColumn / 26 ) - 1 ); - aBuffer[1] = (sal_Unicode) ( 'A' + ( nColumn % 26 ) ); + aBuffer[0] = static_cast<sal_Unicode>( 'A' + ( nColumn / 26 ) - 1 ); + aBuffer[1] = static_cast<sal_Unicode>( 'A' + ( nColumn % 26 ) ); return aBuffer.makeStringAndClear(); } } diff --git a/connectivity/source/drivers/component/CDatabaseMetaData.cxx b/connectivity/source/drivers/component/CDatabaseMetaData.cxx index dca201015cb0..7834e53c18b7 100644 --- a/connectivity/source/drivers/component/CDatabaseMetaData.cxx +++ b/connectivity/source/drivers/component/CDatabaseMetaData.cxx @@ -64,13 +64,13 @@ Reference< XResultSet > OComponentDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)65535)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(65535))); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); // ORowSetValue((sal_Int32)ColumnValue::NULLABLE) aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnSearch::CHAR))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -79,7 +79,7 @@ Reference< XResultSet > OComponentDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(10))); aRows.push_back(aRow); @@ -93,9 +93,9 @@ Reference< XResultSet > OComponentDatabaseMetaData::impl_getTypeInfo_throw( ) aRow[1] = new ORowSetValueDecorator(OUString("BOOL")); aRow[2] = new ORowSetValueDecorator(DataType::BIT); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[3] = new ORowSetValueDecorator(sal_Int32(20)); aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); - aRow[15] = new ORowSetValueDecorator((sal_Int32)15); + aRow[15] = new ORowSetValueDecorator(sal_Int32(15)); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("DATE")); @@ -142,7 +142,7 @@ Reference< XResultSet > SAL_CALL OComponentDatabaseMetaData::getColumns( ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORow aRow(19); - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + aRow[10] = new ORowSetValueDecorator(sal_Int32(10)); Sequence< OUString> aTabNames(xNames->getElementNames()); const OUString* pTabIter = aTabNames.getConstArray(); @@ -186,13 +186,13 @@ Reference< XResultSet > SAL_CALL OComponentDatabaseMetaData::getColumns( { case DataType::CHAR: case DataType::VARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)254); + aRow[16] = new ORowSetValueDecorator(sal_Int32(254)); break; case DataType::LONGVARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[16] = new ORowSetValueDecorator(sal_Int32(65535)); break; default: - aRow[16] = new ORowSetValueDecorator((sal_Int32)0); + aRow[16] = new ORowSetValueDecorator(sal_Int32(0)); } aRow[17] = new ORowSetValueDecorator(i); switch(sal_Int32(aRow[11]->getValue())) diff --git a/connectivity/source/drivers/component/CResultSet.cxx b/connectivity/source/drivers/component/CResultSet.cxx index d760285810d3..faa80e00a116 100644 --- a/connectivity/source/drivers/component/CResultSet.cxx +++ b/connectivity/source/drivers/component/CResultSet.cxx @@ -80,7 +80,7 @@ Any SAL_CALL OComponentResultSet::getBookmark( ) checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); + return makeAny(static_cast<sal_Int32>((m_aRow->get())[0]->getValue())); } sal_Bool SAL_CALL OComponentResultSet::moveToBookmark( const Any& bookmark ) diff --git a/connectivity/source/drivers/component/CTable.cxx b/connectivity/source/drivers/component/CTable.cxx index a6c0e68248d4..04237c7cfb48 100644 --- a/connectivity/source/drivers/component/CTable.cxx +++ b/connectivity/source/drivers/component/CTable.cxx @@ -169,18 +169,18 @@ bool OComponentTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_In break; case IResultSetHelper::RELATIVE1: m_nFilePos = (m_nFilePos + nOffset < 0) ? 0 - : (sal_uInt32)(m_nFilePos + nOffset); + : static_cast<sal_uInt32>(m_nFilePos + nOffset); break; case IResultSetHelper::ABSOLUTE1: case IResultSetHelper::BOOKMARK: - m_nFilePos = (sal_uInt32)nOffset; + m_nFilePos = static_cast<sal_uInt32>(nOffset); break; } - if (m_nFilePos > (sal_Int32)nNumberOfRecords) - m_nFilePos = (sal_Int32)nNumberOfRecords + 1; + if (m_nFilePos > static_cast<sal_Int32>(nNumberOfRecords)) + m_nFilePos = static_cast<sal_Int32>(nNumberOfRecords) + 1; - if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1) + if (m_nFilePos == 0 || m_nFilePos == static_cast<sal_Int32>(nNumberOfRecords) + 1) { switch(eCursorPosition) { diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx index 7e6f71c9a860..6bfae6027588 100644 --- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -69,13 +69,13 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)254)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(254))); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(new ORowSetValueDecorator(OUString("length"))); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnValue::NULLABLE))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnSearch::FULL))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -84,20 +84,20 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(10))); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("LONGVARCHAR")); aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR); - aRow[3] = new ORowSetValueDecorator((sal_Int32)2147483647); + aRow[3] = new ORowSetValueDecorator(sal_Int32(2147483647)); aRow[6] = new ORowSetValueDecorator(); aRow[13] = new ORowSetValueDecorator(OUString("M")); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("DATE")); aRow[2] = new ORowSetValueDecorator(DataType::DATE); - aRow[3] = new ORowSetValueDecorator((sal_Int32)10); + aRow[3] = new ORowSetValueDecorator(sal_Int32(10)); aRow[13] = new ORowSetValueDecorator(OUString("D")); aRows.push_back(aRow); @@ -113,7 +113,7 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow[1] = new ORowSetValueDecorator(OUString("DOUBLE")); aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE); - aRow[3] = new ORowSetValueDecorator((sal_Int32)8); + aRow[3] = new ORowSetValueDecorator(sal_Int32(8)); aRow[13] = new ORowSetValueDecorator(OUString("B")); aRows.push_back(aRow); @@ -129,22 +129,22 @@ Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( ) aRow[1] = new ORowSetValueDecorator(OUString("INTEGER")); aRow[2] = new ORowSetValueDecorator(DataType::INTEGER); - aRow[3] = new ORowSetValueDecorator((sal_Int32)10); + aRow[3] = new ORowSetValueDecorator(sal_Int32(10)); aRow[13] = new ORowSetValueDecorator(OUString("I")); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("DECIMAL")); aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[3] = new ORowSetValueDecorator(sal_Int32(20)); aRow[6] = new ORowSetValueDecorator(OUString("length,scale")); aRow[13] = new ORowSetValueDecorator(OUString("F")); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("NUMERIC")); aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); - aRow[3] = new ORowSetValueDecorator((sal_Int32)16); + aRow[3] = new ORowSetValueDecorator(sal_Int32(16)); aRow[13] = new ORowSetValueDecorator(OUString("N")); - aRow[15] = new ORowSetValueDecorator((sal_Int32)16); + aRow[15] = new ORowSetValueDecorator(sal_Int32(16)); aRows.push_back(aRow); } @@ -171,7 +171,7 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( try { - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + aRow[10] = new ORowSetValueDecorator(sal_Int32(10)); Sequence< OUString> aTabNames(xNames->getElementNames()); const OUString* pTabBegin = aTabNames.getConstArray(); const OUString* pTabEnd = pTabBegin + aTabNames.getLength(); @@ -208,17 +208,17 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); - switch((sal_Int32)aRow[5]->getValue()) + switch(static_cast<sal_Int32>(aRow[5]->getValue())) { case DataType::CHAR: case DataType::VARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)254); + aRow[16] = new ORowSetValueDecorator(sal_Int32(254)); break; case DataType::LONGVARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[16] = new ORowSetValueDecorator(sal_Int32(65535)); break; default: - aRow[16] = new ORowSetValueDecorator((sal_Int32)0); + aRow[16] = new ORowSetValueDecorator(sal_Int32(0)); } aRow[17] = new ORowSetValueDecorator(i); switch(sal_Int32(aRow[11]->getValue())) @@ -275,7 +275,7 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( Reference< XIndexesSupplier> xTable( xNames->getByName(table), css::uno::UNO_QUERY); aRow[3] = new ORowSetValueDecorator(table); - aRow[7] = new ORowSetValueDecorator((sal_Int32)3); + aRow[7] = new ORowSetValueDecorator(sal_Int32(3)); Reference< XNameAccess> xIndexes = xTable->getIndexes(); if(!xIndexes.is()) @@ -302,8 +302,8 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) ); if(pIndex) { - aRow[11] = new ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_maxkeys); - aRow[12] = new ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_pagecount); + aRow[11] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_maxkeys)); + aRow[12] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_pagecount)); } } diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx index 92d1d764e01c..4d333438538e 100644 --- a/connectivity/source/drivers/dbase/DIndex.cxx +++ b/connectivity/source/drivers/dbase/DIndex.cxx @@ -552,7 +552,7 @@ bool ODbaseIndex::CreateImpl() xTableCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType; m_aHeader.db_keytype = (nType == DataType::VARCHAR || nType == DataType::CHAR) ? 0 : 1; - m_aHeader.db_keylen = (m_aHeader.db_keytype) ? 8 : (sal_uInt16)getINT32(xTableCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); + m_aHeader.db_keylen = (m_aHeader.db_keytype) ? 8 : static_cast<sal_uInt16>(getINT32(xTableCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); m_aHeader.db_keylen = (( m_aHeader.db_keylen - 1) / 4 + 1) * 4; m_aHeader.db_maxkeys = (DINDEX_PAGE_SIZE - 4) / (8 + m_aHeader.db_keylen); if ( m_aHeader.db_maxkeys < 3 ) diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx index 40e38e5d2973..7e41b2402af5 100644 --- a/connectivity/source/drivers/dbase/DResultSet.cxx +++ b/connectivity/source/drivers/dbase/DResultSet.cxx @@ -83,7 +83,7 @@ Any SAL_CALL ODbaseResultSet::getBookmark( ) checkDisposed(OResultSet_BASE::rBHelper.bDisposed); OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getBookmark called for deleted row"); - return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); + return makeAny(static_cast<sal_Int32>((m_aRow->get())[0]->getValue())); } sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const Any& bookmark ) diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index c163b3bf4133..d1b751dc7e9e 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -128,18 +128,18 @@ void lcl_CalcJulDate(sal_Int32& _nJulianDate,sal_Int32& _nJulianTime, const css: /* calculate julian date */ if ( aDateTime.Year <= 0 ) { - _nJulianDate = (sal_Int32) ((365.25 * iy0) - 0.75) - + (sal_Int32) (30.6001 * (im0 + 1) ) + _nJulianDate = static_cast<sal_Int32>((365.25 * iy0) - 0.75) + + static_cast<sal_Int32>(30.6001 * (im0 + 1) ) + aDateTime.Day + 1720994; } // if ( rDateTime.Year <= 0 ) else { _nJulianDate = static_cast<sal_Int32>( ((365.25 * iy0) - + (sal_Int32) (30.6001 * (im0 + 1)) + + static_cast<sal_Int32>(30.6001 * (im0 + 1)) + aDateTime.Day + 1720994)); } double JD = _nJulianDate + 0.5; - _nJulianDate = (sal_Int32)( JD + 0.5); + _nJulianDate = static_cast<sal_Int32>( JD + 0.5); const double gyr = aDateTime.Year + (0.01 * aDateTime.Month) + (0.0001 * aDateTime.Day); if ( gyr >= 1582.1015 ) /* on or after 15 October 1582 */ _nJulianDate += ib; @@ -156,14 +156,14 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,css::util::DateTi sal_Int32 ka = _nJulianDate; if ( _nJulianDate >= 2299161 ) { - ialp = (sal_Int32)( ((double) _nJulianDate - 1867216.25 ) / 36524.25 ); + ialp = static_cast<sal_Int32>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 ); ka = _nJulianDate + 1 + ialp - ( ialp >> 2 ); } sal_Int32 kb = ka + 1524; - sal_Int32 kc = (sal_Int32) ( ((double) kb - 122.1 ) / 365.25 ); - sal_Int32 kd = (sal_Int32) ((double) kc * 365.25); - sal_Int32 ke = (sal_Int32) ((double) ( kb - kd ) / 30.6001 ); - _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - ((sal_Int32) ( (double) ke * 30.6001 ))); + sal_Int32 kc = static_cast<sal_Int32>( (static_cast<double>(kb) - 122.1 ) / 365.25 ); + sal_Int32 kd = static_cast<sal_Int32>(static_cast<double>(kc) * 365.25); + sal_Int32 ke = static_cast<sal_Int32>(static_cast<double>( kb - kd ) / 30.6001 ); + _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - static_cast<sal_Int32>( static_cast<double>(ke) * 30.6001 )); if ( ke > 13 ) _rDateTime.Month = static_cast<sal_uInt16>(ke - 13); else @@ -183,9 +183,9 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,css::util::DateTi double d_s = _nJulianTime / 1000.0; double d_m = d_s / 60.0; double d_h = d_m / 60.0; - _rDateTime.Hours = (sal_uInt16) d_h; - _rDateTime.Minutes = (sal_uInt16) d_m; - _rDateTime.Seconds = static_cast<sal_uInt16>(( d_m - (double) _rDateTime.Minutes ) * 60.0); + _rDateTime.Hours = static_cast<sal_uInt16>(d_h); + _rDateTime.Minutes = static_cast<sal_uInt16>(d_m); + _rDateTime.Seconds = static_cast<sal_uInt16>(( d_m - static_cast<double>(_rDateTime.Minutes) ) * 60.0); } } @@ -567,7 +567,7 @@ bool ODbaseTable::ReadMemoHeader() m_pMemoStream->Seek(m_aMemoHeader.db_size); m_pMemoStream->ReadBytes(sHeader, 4); - if ((m_pMemoStream->GetErrorCode() != ERRCODE_NONE) || ((sal_uInt8)sHeader[0]) != 0xFF || ((sal_uInt8)sHeader[1]) != 0xFF || ((sal_uInt8)sHeader[2]) != 0x08) + if ((m_pMemoStream->GetErrorCode() != ERRCODE_NONE) || static_cast<sal_uInt8>(sHeader[0]) != 0xFF || static_cast<sal_uInt8>(sHeader[1]) != 0xFF || static_cast<sal_uInt8>(sHeader[2]) != 0x08) m_aMemoHeader.db_typ = MemodBaseIII; else m_aMemoHeader.db_typ = MemodBaseIV; @@ -756,7 +756,7 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool return false; // Read the data - bool bIsCurRecordDeleted = (char)m_pBuffer[0] == '*'; + bool bIsCurRecordDeleted = static_cast<char>(m_pBuffer[0]) == '*'; // only read the bookmark @@ -869,9 +869,9 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool memcpy(&nValue, pData, nLen); if ( m_aScales[i-1] ) - d = (nValue / pow(10.0,(int)m_aScales[i-1])); + d = (nValue / pow(10.0,static_cast<int>(m_aScales[i-1]))); else - d = (double)nValue; + d = static_cast<double>(nValue); } else { @@ -921,9 +921,9 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const OSQLColumns & _rCols, bool (_rRow->get())[i]->setNull(); break; } - const sal_uInt16 nYear = (sal_uInt16)aStr.copy( 0, 4 ).toInt32(); - const sal_uInt16 nMonth = (sal_uInt16)aStr.copy( 4, 2 ).toInt32(); - const sal_uInt16 nDay = (sal_uInt16)aStr.copy( 6, 2 ).toInt32(); + const sal_uInt16 nYear = static_cast<sal_uInt16>(aStr.copy( 0, 4 ).toInt32()); + const sal_uInt16 nMonth = static_cast<sal_uInt16>(aStr.copy( 4, 2 ).toInt32()); + const sal_uInt16 nDay = static_cast<sal_uInt16>(aStr.copy( 6, 2 ).toInt32()); const css::util::Date aDate(nDay,nMonth,nYear); *(_rRow->get())[i] = aDate; @@ -1280,8 +1280,8 @@ bool ODbaseTable::CreateFile(const INetURLObject& aFile, bool& bCreateMemo) { throwInvalidColumnType(STR_INVALID_COLUMN_PRECISION, aName); } - (*m_pFileStream).WriteUChar( std::min((unsigned)nPrecision, 255U) ); // field length - nRecLength = nRecLength + (sal_uInt16)std::min((sal_uInt16)nPrecision, (sal_uInt16)255UL); + (*m_pFileStream).WriteUChar( std::min(static_cast<unsigned>(nPrecision), 255U) ); // field length + nRecLength = nRecLength + static_cast<sal_uInt16>(std::min(static_cast<sal_uInt16>(nPrecision), sal_uInt16(255UL))); (*m_pFileStream).WriteUChar( 0 ); // decimals break; case 'F': @@ -1304,7 +1304,7 @@ bool ODbaseTable::CreateFile(const INetURLObject& aFile, bool& bCreateMemo) (*m_pFileStream).WriteUChar( nPrec ); (*m_pFileStream).WriteUChar( nScale ); - nRecLength += (sal_uInt16)nPrec; + nRecLength += static_cast<sal_uInt16>(nPrec); } break; case 'L': @@ -1341,7 +1341,7 @@ bool ODbaseTable::CreateFile(const INetURLObject& aFile, bool& bCreateMemo) } (*m_pFileStream).WriteUChar( FIELD_DESCRIPTOR_TERMINATOR ); // end of header - (*m_pFileStream).WriteChar( (char)DBF_EOL ); + (*m_pFileStream).WriteChar( char(DBF_EOL) ); m_pFileStream->Seek(10); (*m_pFileStream).WriteUInt16( nRecLength ); // set record length afterwards @@ -1467,7 +1467,7 @@ bool ODbaseTable::InsertRow(OValueRefVector& rRow, const Reference<XIndexAccess> // ... and add at the end as new Record: std::size_t nTempPos = m_nFilePos; - m_nFilePos = (std::size_t)m_aHeader.nbRecords + 1; + m_nFilePos = static_cast<std::size_t>(m_aHeader.nbRecords) + 1; bool bInsertRow = UpdateBuffer( rRow, nullptr, _xCols, true ); if ( bInsertRow ) { @@ -1491,7 +1491,7 @@ bool ODbaseTable::InsertRow(OValueRefVector& rRow, const Reference<XIndexAccess> } else { - (*m_pFileStream).WriteChar( (char)DBF_EOL ); // write EOL + (*m_pFileStream).WriteChar( char(DBF_EOL) ); // write EOL // raise number of datasets in the header: m_pFileStream->Seek( 4 ); (*m_pFileStream).WriteUInt32( m_aHeader.nbRecords + 1 ); @@ -1518,7 +1518,7 @@ bool ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow, const return false; // position on desired record: - std::size_t nPos = m_aHeader.headerLength + (long)(m_nFilePos-1) * m_aHeader.recordLength; + std::size_t nPos = m_aHeader.headerLength + static_cast<long>(m_nFilePos-1) * m_aHeader.recordLength; m_pFileStream->Seek(nPos); m_pFileStream->ReadBytes(m_pBuffer, m_aHeader.recordLength); @@ -1545,7 +1545,7 @@ bool ODbaseTable::DeleteRow(const OSQLColumns& _rCols) { // Set the Delete-Flag (be it set or not): // Position on desired record: - std::size_t nFilePos = m_aHeader.headerLength + (long)(m_nFilePos-1) * m_aHeader.recordLength; + std::size_t nFilePos = m_aHeader.headerLength + static_cast<long>(m_nFilePos-1) * m_aHeader.recordLength; m_pFileStream->Seek(nFilePos); OValueRefRow aRow = new OValueRefVector(_rCols.get().size()); @@ -1831,9 +1831,9 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo snprintf(s, sizeof(s), "%04d%02d%02d", - (int)aDate.Year, - (int)aDate.Month, - (int)aDate.Day); + static_cast<int>(aDate.Year), + static_cast<int>(aDate.Month), + static_cast<int>(aDate.Day)); // Exactly 8 bytes to copy: strncpy(pData,s,sizeof s - 1); @@ -1855,9 +1855,9 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo { sal_Int64 nValue = 0; if ( m_aScales[i] ) - nValue = (sal_Int64)(d * pow(10.0,(int)m_aScales[i])); + nValue = static_cast<sal_Int64>(d * pow(10.0,static_cast<int>(m_aScales[i]))); else - nValue = (sal_Int64)d; + nValue = static_cast<sal_Int64>(d); if (static_cast<size_t>(nLen) > sizeof(nValue)) return false; memcpy(pData,&nValue,nLen); @@ -2009,15 +2009,15 @@ bool ODbaseTable::WriteMemo(const ORowSetValue& aVariable, std::size_t& rBlockNr std::size_t nOldSize; if (m_aMemoHeader.db_typ == MemoFoxPro) - nOldSize = ((((unsigned char)sHeader[0]) * 256 + - (unsigned char)sHeader[1]) * 256 + - (unsigned char)sHeader[2]) * 256 + - (unsigned char)sHeader[3]; + nOldSize = ((static_cast<unsigned char>(sHeader[0]) * 256 + + static_cast<unsigned char>(sHeader[1])) * 256 + + static_cast<unsigned char>(sHeader[2])) * 256 + + static_cast<unsigned char>(sHeader[3]); else - nOldSize = ((((unsigned char)sHeader[3]) * 256 + - (unsigned char)sHeader[2]) * 256 + - (unsigned char)sHeader[1]) * 256 + - (unsigned char)sHeader[0] - 8; + nOldSize = ((static_cast<unsigned char>(sHeader[3]) * 256 + + static_cast<unsigned char>(sHeader[2])) * 256 + + static_cast<unsigned char>(sHeader[1])) * 256 + + static_cast<unsigned char>(sHeader[0]) - 8; // fits the new length in the used blocks std::size_t nUsedBlocks = ((nSize + 8) / m_aMemoHeader.db_size) + (((nSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0), @@ -2045,7 +2045,7 @@ bool ODbaseTable::WriteMemo(const ORowSetValue& aVariable, std::size_t& rBlockNr { case MemodBaseIII: // dBase III-Memofield, ends with Ctrl-Z { - const char cEOF = (char) DBF_EOL; + const char cEOF = char(DBF_EOL); nSize++; m_pMemoStream->WriteBytes(aStr.getStr(), aStr.getLength()); m_pMemoStream->WriteChar( cEOF ).WriteChar( cEOF ); @@ -2070,14 +2070,14 @@ bool ODbaseTable::WriteMemo(const ORowSetValue& aVariable, std::size_t& rBlockNr else (*m_pMemoStream).WriteUChar( 0x01 ); // Memo for (int i = 4; i > 0; nWriteSize >>= 8) - nHeader[--i] = (sal_uInt8) (nWriteSize % 256); + nHeader[--i] = static_cast<sal_uInt8>(nWriteSize % 256); } else { (*m_pMemoStream).WriteUChar( 0x00 ); nWriteSize += 8; for (int i = 0; i < 4; nWriteSize >>= 8) - nHeader[i++] = (sal_uInt8) (nWriteSize % 256); + nHeader[i++] = static_cast<sal_uInt8>(nWriteSize % 256); } m_pMemoStream->WriteBytes(nHeader, 4); @@ -2482,7 +2482,7 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos) // we only have to bind the values which we need to copy into the new table std::for_each(aRow->get().begin(),aRow->get().end(),TSetRefBound(true)); - if(_nPos && (_nPos < (sal_Int32)aRow->get().size())) + if(_nPos && (_nPos < static_cast<sal_Int32>(aRow->get().size()))) (aRow->get())[nPos]->setBound(false); @@ -2569,25 +2569,25 @@ bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 break; case IResultSetHelper::RELATIVE1: m_nFilePos = (m_nFilePos + nOffset < 0) ? 0 - : (sal_uInt32)(m_nFilePos + nOffset); + : static_cast<sal_uInt32>(m_nFilePos + nOffset); break; case IResultSetHelper::ABSOLUTE1: case IResultSetHelper::BOOKMARK: - m_nFilePos = (sal_uInt32)nOffset; + m_nFilePos = static_cast<sal_uInt32>(nOffset); break; } - if (m_nFilePos > (sal_Int32)nNumberOfRecords) - m_nFilePos = (sal_Int32)nNumberOfRecords + 1; + if (m_nFilePos > static_cast<sal_Int32>(nNumberOfRecords)) + m_nFilePos = static_cast<sal_Int32>(nNumberOfRecords) + 1; - if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1) + if (m_nFilePos == 0 || m_nFilePos == static_cast<sal_Int32>(nNumberOfRecords) + 1) goto Error; else { std::size_t nEntryLen = m_aHeader.recordLength; OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: invalid record position"); - std::size_t nPos = m_aHeader.headerLength + (std::size_t)(m_nFilePos-1) * nEntryLen; + std::size_t nPos = m_aHeader.headerLength + static_cast<std::size_t>(m_nFilePos-1) * nEntryLen; m_pFileStream->Seek(nPos); if (m_pFileStream->GetError() != ERRCODE_NONE) @@ -2637,7 +2637,7 @@ bool ODbaseTable::ReadMemo(std::size_t nBlockNo, ORowSetValue& aVariable) { case MemodBaseIII: // dBase III-Memofield, ends with Ctrl-Z { - const char cEOF = (char) DBF_EOL; + const char cEOF = char(DBF_EOL); OStringBuffer aBStr; static char aBuf[514]; aBuf[512] = 0; // avoid random value @@ -2672,7 +2672,7 @@ bool ODbaseTable::ReadMemo(std::size_t nBlockNo, ORowSetValue& aVariable) { bIsText = sHeader[3] != 0; } - else if (((sal_uInt8)sHeader[0]) != 0xFF || ((sal_uInt8)sHeader[1]) != 0xFF || ((sal_uInt8)sHeader[2]) != 0x08) + else if (static_cast<sal_uInt8>(sHeader[0]) != 0xFF || static_cast<sal_uInt8>(sHeader[1]) != 0xFF || static_cast<sal_uInt8>(sHeader[2]) != 0x08) { return false; } @@ -2731,7 +2731,7 @@ bool ODbaseTable::WriteBuffer() OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: invalid record position"); // position on desired record: - std::size_t nPos = m_aHeader.headerLength + (long)(m_nFilePos-1) * m_aHeader.recordLength; + std::size_t nPos = m_aHeader.headerLength + static_cast<long>(m_nFilePos-1) * m_aHeader.recordLength; m_pFileStream->Seek(nPos); return m_pFileStream->WriteBytes(m_pBuffer, m_aHeader.recordLength) > 0; } diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index 5f4e192ab83b..1bc8b37a2b4b 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -247,7 +247,7 @@ bool ONDXPage::Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft) // How many nodes are being inserted? // Enough, then we can fill the page to the brim ONDXNode aInnerNode; - if (!IsLeaf() || nRowsLeft < (sal_uInt32)(rIndex.GetMaxNodes() / 2)) + if (!IsLeaf() || nRowsLeft < static_cast<sal_uInt32>(rIndex.GetMaxNodes() / 2)) aInnerNode = Split(*aNewPage); else { @@ -310,7 +310,7 @@ bool ONDXPage::Insert(sal_uInt16 nPos, ONDXNode& rNode) { ++nCount; // shift right - for (sal_uInt16 i = std::min((sal_uInt16)(nMaxCount-1), (sal_uInt16)(nCount-1)); nPos < i; --i) + for (sal_uInt16 i = std::min(static_cast<sal_uInt16>(nMaxCount-1), static_cast<sal_uInt16>(nCount-1)); nPos < i; --i) (*this)[i] = (*this)[i-1]; } else @@ -705,7 +705,7 @@ void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const rStream.WriteBytes(&buf[0], sizeof(double)); } else - rStream.WriteDouble( (double) aKey.getValue() ); + rStream.WriteDouble( static_cast<double>(aKey.getValue()) ); } else { diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx index 9e04619c923a..671bb230b60c 100644 --- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx @@ -175,7 +175,7 @@ namespace connectivity guint findEvoabField(const OUString& aColName) { - guint nRet = (guint)-1; + guint nRet = guint(-1); bool bFound = false; initFields(); for (guint i=0;(i < nFields) && !bFound;i++) @@ -278,7 +278,7 @@ ODatabaseMetaDataResultSet::ORows& OEvoabDatabaseMetaData::getColumnRows( const // DECIMAL_DIGITS. aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS); // NUM_PREC_RADIX - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + aRow[10] = new ORowSetValueDecorator(sal_Int32(10)); // NULLABLE aRow[11] = new ORowSetValueDecorator(s_nNULLABLE); // REMARKS @@ -299,7 +299,7 @@ ODatabaseMetaDataResultSet::ORows& OEvoabDatabaseMetaData::getColumnRows( const ::osl::MutexGuard aGuard( m_aMutex ); initFields(); - for (sal_Int32 i = 0; i < (sal_Int32) nFields; i++) + for (sal_Int32 i = 0; i < static_cast<sal_Int32>(nFields); i++) { if( match( columnNamePattern, getFieldName( i ), '\0' ) ) { @@ -1027,14 +1027,14 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(s_nCHAR_OCTET_LENGTH))); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnSearch::FULL))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -1043,13 +1043,13 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(10))); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("VARCHAR")); aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR); - aRow[3] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[3] = new ORowSetValueDecorator(sal_Int32(65535)); aRows.push_back(aRow); } pResultSet->setRows(aRows); diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx index e4e9dd37e9f4..517e7b1a7f8e 100644 --- a/connectivity/source/drivers/evoab2/NResultSet.cxx +++ b/connectivity/source/drivers/evoab2/NResultSet.cxx @@ -264,8 +264,8 @@ getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackV if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType ) { - SAL_WARN("connectivity.evoab2", "Wrong type (0x" << std::hex << (int)G_PARAM_SPEC_VALUE_TYPE(pSpec) << ") (0x" - << std::hex << (int) nType << ") " << (pSpec->name ? pSpec->name : "<noname>")); + SAL_WARN("connectivity.evoab2", "Wrong type (0x" << std::hex << static_cast<int>(G_PARAM_SPEC_VALUE_TYPE(pSpec)) << ") (0x" + << std::hex << static_cast<int>(nType) << ") " << (pSpec->name ? pSpec->name : "<noname>")); return false; } diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx index 7dcf3146055b..7af9ebb81543 100644 --- a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx +++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx @@ -50,7 +50,7 @@ void OEvoabResultSetMetaData::setEvoabFields(const ::rtl::Reference<connectivity (*aIter)->getPropertyValue(aName) >>= aFieldName; guint nFieldNumber = findEvoabField(aFieldName); - if (nFieldNumber == (guint)-1) + if (nFieldNumber == guint(-1)) { connectivity::SharedResources aResource; const OUString sError( aResource.getResourceStringWithSubstitution( diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx index 378bd2d9cd0a..ba5822a9696c 100644 --- a/connectivity/source/drivers/file/FConnection.cxx +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -407,7 +407,7 @@ sal_Int64 SAL_CALL OConnection::getSomething( const Sequence< sal_Int8 >& rId ) { return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) ? reinterpret_cast< sal_Int64 >( this ) - : (sal_Int64)0; + : sal_Int64(0); } Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId() diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx index c165874c6417..fbf639d47aa2 100644 --- a/connectivity/source/drivers/file/FNoException.cxx +++ b/connectivity/source/drivers/file/FNoException.cxx @@ -89,7 +89,7 @@ void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,std::vector< OS OKeyValue* OResultSet::GetOrderbyKeyValue(OValueRefRow const & _rRow) { - sal_uInt32 nBookmarkValue = std::abs((sal_Int32)(_rRow->get())[0]->getValue()); + sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((_rRow->get())[0]->getValue())); OKeyValue* pKeyValue = OKeyValue::createKeyValue(nBookmarkValue); diff --git a/connectivity/source/drivers/file/FNumericFunctions.cxx b/connectivity/source/drivers/file/FNumericFunctions.cxx index 059a6e374cda..a71abc31f1a8 100644 --- a/connectivity/source/drivers/file/FNumericFunctions.cxx +++ b/connectivity/source/drivers/file/FNumericFunctions.cxx @@ -58,7 +58,7 @@ ORowSetValue OOp_Mod::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) c if ( lhs.isNull() || rhs.isNull() ) return ORowSetValue(); - return fmod((double)lhs,(double)rhs); + return fmod(static_cast<double>(lhs),static_cast<double>(rhs)); } ORowSetValue OOp_Floor::operate(const ORowSetValue& lhs) const @@ -66,7 +66,7 @@ ORowSetValue OOp_Floor::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return floor((double)lhs); + return floor(static_cast<double>(lhs)); } ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const @@ -118,11 +118,11 @@ ORowSetValue OOp_Log::operate(const std::vector<ORowSetValue>& lhs) const if ( lhs.empty() || lhs.size() > 2 ) return ORowSetValue(); size_t nSize = lhs.size(); - double nVal = log( (double)lhs[nSize-1] ); + double nVal = log( static_cast<double>(lhs[nSize-1]) ); if ( nSize == 2 && !lhs[0].isNull() ) - nVal /= log((double)lhs[0]); + nVal /= log(static_cast<double>(lhs[0])); if ( rtl::math::isNan(nVal) ) return ORowSetValue(); @@ -134,7 +134,7 @@ ORowSetValue OOp_Log10::operate(const ORowSetValue& lhs) const if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 ) return lhs; - double nVal = log((double)lhs); + double nVal = log(static_cast<double>(lhs)); if ( rtl::math::isNan(nVal) ) return ORowSetValue(); nVal /= log(10.0); @@ -146,7 +146,7 @@ ORowSetValue OOp_Pow::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) c if ( lhs.isNull() || rhs.isNull() ) return lhs; - return pow((double)lhs,(double)rhs); + return pow(static_cast<double>(lhs),static_cast<double>(rhs)); } ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const @@ -154,7 +154,7 @@ ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - double nVal = sqrt((double)lhs); + double nVal = sqrt(static_cast<double>(lhs)); if ( rtl::math::isNan(nVal) ) return ORowSetValue(); return nVal; @@ -170,7 +170,7 @@ ORowSetValue OOp_Cos::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return cos((double)lhs); + return cos(static_cast<double>(lhs)); } ORowSetValue OOp_Sin::operate(const ORowSetValue& lhs) const @@ -178,7 +178,7 @@ ORowSetValue OOp_Sin::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return sin((double)lhs); + return sin(static_cast<double>(lhs)); } ORowSetValue OOp_Tan::operate(const ORowSetValue& lhs) const @@ -186,7 +186,7 @@ ORowSetValue OOp_Tan::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return tan((double)lhs); + return tan(static_cast<double>(lhs)); } ORowSetValue OOp_ACos::operate(const ORowSetValue& lhs) const @@ -194,7 +194,7 @@ ORowSetValue OOp_ACos::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return acos((double)lhs); + return acos(static_cast<double>(lhs)); } ORowSetValue OOp_ASin::operate(const ORowSetValue& lhs) const @@ -202,7 +202,7 @@ ORowSetValue OOp_ASin::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return asin((double)lhs); + return asin(static_cast<double>(lhs)); } ORowSetValue OOp_ATan::operate(const ORowSetValue& lhs) const @@ -210,7 +210,7 @@ ORowSetValue OOp_ATan::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - return atan((double)lhs); + return atan(static_cast<double>(lhs)); } ORowSetValue OOp_ATan2::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const @@ -218,7 +218,7 @@ ORowSetValue OOp_ATan2::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) if ( lhs.isNull() || rhs.isNull() ) return lhs; - return atan2((double)lhs,(double)rhs); + return atan2(static_cast<double>(lhs),static_cast<double>(rhs)); } ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 76f30d4045c8..dc6bb60a07da 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -548,7 +548,7 @@ void SAL_CALL OResultSet::updateRow( ) lcl_throwError(STR_TABLE_READONLY,*this); m_bRowUpdated = m_pTable->UpdateRow(*m_aInsertRow, m_aRow,m_xColsIdx); - *(m_aInsertRow->get())[0] = (sal_Int32)(m_aRow->get())[0]->getValue(); + *(m_aInsertRow->get())[0] = static_cast<sal_Int32>((m_aRow->get())[0]->getValue()); clearInsertRow(); } @@ -565,7 +565,7 @@ void SAL_CALL OResultSet::deleteRow() if(m_aRow->isDeleted()) lcl_throwError(STR_ROW_ALREADY_DELETED,*this); - sal_Int32 nPos = (sal_Int32)(m_aRow->get())[0]->getValue(); + sal_Int32 nPos = static_cast<sal_Int32>((m_aRow->get())[0]->getValue()); m_bRowDeleted = m_pTable->DeleteRow(*m_xColumns); if(m_bRowDeleted && m_pFileSet.is()) { @@ -849,7 +849,7 @@ again: } else if (m_pFileSet.is()) { - sal_uInt32 nBookmarkValue = std::abs((sal_Int32)(m_aEvaluateRow->get())[0]->getValue()); + sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((m_aEvaluateRow->get())[0]->getValue())); m_pFileSet->get().push_back(nBookmarkValue); } } @@ -933,13 +933,13 @@ bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOff // The FileCursor is outside of the valid range, if: // a.) m_nRowPos < 1 // b.) a KeySet exists and m_nRowPos > m_pFileSet->size() - if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= (sal_Int32)m_pFileSet->get().size() )) // && m_pFileSet->IsFrozen() + if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->get().size()) )) // && m_pFileSet->IsFrozen() { goto Error; } else { - if (m_nRowPos < (sal_Int32)m_pFileSet->get().size()) + if (m_nRowPos < static_cast<sal_Int32>(m_pFileSet->get().size())) { // Fetch via Index bool bOK = ExecuteRow(IResultSetHelper::BOOKMARK,(m_pFileSet->get())[m_nRowPos],false,bRetrieveData); @@ -967,7 +967,7 @@ bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOff } bool bOK = true; // Determine the number of further Fetches - while (bOK && m_nRowPos >= (sal_Int32)m_pFileSet->get().size()) + while (bOK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->get().size())) { bOK = ExecuteRow(IResultSetHelper::NEXT,1,true, false);//bRetrieveData); } @@ -1064,7 +1064,7 @@ Error: case IResultSetHelper::ABSOLUTE1: case IResultSetHelper::RELATIVE1: if (nOffset > 0) - m_nRowPos = m_pFileSet.is() ? (sal_Int32)m_pFileSet->get().size() : -1; + m_nRowPos = m_pFileSet.is() ? static_cast<sal_Int32>(m_pFileSet->get().size()) : -1; else if (nOffset < 0) m_nRowPos = -1; break; @@ -1114,7 +1114,7 @@ void OResultSet::sortRows() std::vector<sal_Int32>::const_iterator aOrderByIter = m_aOrderbyColumnNumber.begin(); for (std::vector<sal_Int16>::size_type i=0;aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i) { - OSL_ENSURE((sal_Int32)m_aSelectRow->get().size() > *aOrderByIter,"Invalid Index"); + OSL_ENSURE(static_cast<sal_Int32>(m_aSelectRow->get().size()) > *aOrderByIter,"Invalid Index"); switch ((*(m_aSelectRow->get().begin()+*aOrderByIter))->getValue().getTypeKind()) { case DataType::CHAR: diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx index 503f76a84e9d..e9adbc0930ec 100644 --- a/connectivity/source/drivers/file/FResultSetMetaData.cxx +++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx @@ -51,7 +51,7 @@ OResultSetMetaData::~OResultSetMetaData() void OResultSetMetaData::checkColumnIndex(sal_Int32 column) { - if(column <= 0 || column > (sal_Int32)m_xColumns->get().size()) + if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->get().size())) throwInvalidIndexException(*this); } diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index 93772f5e979a..e0ed9a16c35e 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -445,7 +445,7 @@ void OStatement_Base::createColumnMapping() // initialize the column index map (mapping select columns to table columns) ::rtl::Reference<connectivity::OSQLColumns> xColumns = m_aSQLIterator.getSelectColumns(); m_aColMapping.resize(xColumns->get().size() + 1); - for (sal_Int32 i=0; i<(sal_Int32)m_aColMapping.size(); ++i) + for (sal_Int32 i=0; i<static_cast<sal_Int32>(m_aColMapping.size()); ++i) m_aColMapping[i] = i; Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index 3d7695caad29..d04e3f1e1c63 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -354,17 +354,17 @@ void OPredicateCompiler::execute_BETWEEN(OSQLParseNode const * pPredicateNode) break; case DataType::DECIMAL: case DataType::NUMERIC: - pOb1->setValue((double)pOb1->getValue()); - pOb2->setValue((double)pOb2->getValue()); + pOb1->setValue(static_cast<double>(pOb1->getValue())); + pOb2->setValue(static_cast<double>(pOb2->getValue())); break; case DataType::FLOAT: - pOb1->setValue((float)pOb1->getValue()); - pOb2->setValue((float)pOb2->getValue()); + pOb1->setValue(static_cast<float>(pOb1->getValue())); + pOb2->setValue(static_cast<float>(pOb2->getValue())); break; case DataType::DOUBLE: case DataType::REAL: - pOb1->setValue((double)pOb1->getValue()); - pOb2->setValue((double)pOb2->getValue()); + pOb1->setValue(static_cast<double>(pOb1->getValue())); + pOb2->setValue(static_cast<double>(pOb2->getValue())); break; case DataType::DATE: pOb1->setValue(static_cast<util::Date>(pOb1->getValue())); diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx index d8d26c1042c1..3bf9252c7fdb 100644 --- a/connectivity/source/drivers/firebird/Blob.cxx +++ b/connectivity/source/drivers/firebird/Blob.cxx @@ -94,7 +94,7 @@ void Blob::ensureBlobIsOpened() while( *pIt != isc_info_end ) // info is in clusters { char item = *pIt++; - short aResultLength = (short) isc_vax_integer(pIt, 2); + short aResultLength = static_cast<short>(isc_vax_integer(pIt, 2)); pIt += 2; switch(item) diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 7d0937e3ae99..4ae13ad6beae 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -570,7 +570,7 @@ isc_svc_handle Connection::attachServiceManager() *pSPB++ = isc_spb_current_version; *pSPB++ = isc_spb_user_name; OUString sUserName("SYSDBA"); - char aLength = (char) sUserName.getLength(); + char aLength = static_cast<char>(sUserName.getLength()); *pSPB++ = aLength; strncpy(pSPB, OUStringToOString(sUserName, @@ -620,23 +620,23 @@ void Connection::runBackupService(const short nAction) OStringBuffer aRequest; // byte array - aRequest.append((char) nAction); + aRequest.append(static_cast<char>(nAction)); - aRequest.append((char) isc_spb_dbname); // .fdb + aRequest.append(char(isc_spb_dbname)); // .fdb sal_uInt16 nFDBLength = sFDBPath.getLength(); - aRequest.append((char) (nFDBLength & 0xFF)); // least significant byte first - aRequest.append((char) ((nFDBLength >> 8) & 0xFF)); + aRequest.append(static_cast<char>(nFDBLength & 0xFF)); // least significant byte first + aRequest.append(static_cast<char>((nFDBLength >> 8) & 0xFF)); aRequest.append(sFDBPath); - aRequest.append((char) isc_spb_bkp_file); // .fbk + aRequest.append(char(isc_spb_bkp_file)); // .fbk sal_uInt16 nFBKLength = sFBKPath.getLength(); - aRequest.append((char) (nFBKLength & 0xFF)); - aRequest.append((char) ((nFBKLength >> 8) & 0xFF)); + aRequest.append(static_cast<char>(nFBKLength & 0xFF)); + aRequest.append(static_cast<char>((nFBKLength >> 8) & 0xFF)); aRequest.append(sFBKPath); if (nAction == isc_action_svc_restore) { - aRequest.append((char) isc_spb_options); // 4-Byte bitmask + aRequest.append(char(isc_spb_options)); // 4-Byte bitmask char sOptions[4]; char * pOptions = sOptions; ADD_SPB_NUMERIC(pOptions, isc_spb_res_create); diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx index 0015219d53eb..1d3f46d9b071 100644 --- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx @@ -1219,7 +1219,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( // 9. Decimal digits (scale) // fb stores a negative number - aCurrentRow[9] = new ORowSetValueDecorator( (sal_Int16) -aScale ); + aCurrentRow[9] = new ORowSetValueDecorator( static_cast<sal_Int16>(-aScale) ); // 11. Nullable if (xRow->getShort(11)) @@ -1236,7 +1236,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( uno::Reference< XBlob > xDescriptionBlob = xRow->getBlob(3); if (xDescriptionBlob.is()) { - sal_Int32 aBlobLength = (sal_Int32) xDescriptionBlob->length(); + sal_Int32 aBlobLength = static_cast<sal_Int32>(xDescriptionBlob->length()); aDescription = OUString(reinterpret_cast<char*>(xDescriptionBlob->getBytes(0, aBlobLength).getArray()), aBlobLength, RTL_TEXTENCODING_UTF8); @@ -1403,7 +1403,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( { // TODO: we should actually be using CLOB here instead. // However we haven't implemented CLOB yet, so use BLOB. - sal_Int32 aBlobLength = (sal_Int32) xBlob->length(); + sal_Int32 aBlobLength = static_cast<sal_Int32>(xBlob->length()); sDescription = OUString(reinterpret_cast<char*>(xBlob->getBytes(0, aBlobLength).getArray()), aBlobLength, RTL_TEXTENCODING_UTF8); @@ -1684,9 +1684,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo( aCurrentRow[10] = new ORowSetValueDecorator(OUString("A")); // TODO: double check this^^^, doesn't seem to be officially documented anywhere. // 11. CARDINALITY - aCurrentRow[11] = new ORowSetValueDecorator((sal_Int32)0); // TODO: determine how to do this + aCurrentRow[11] = new ORowSetValueDecorator(sal_Int32(0)); // TODO: determine how to do this // 12. PAGES - aCurrentRow[12] = new ORowSetValueDecorator((sal_Int32)0); // TODO: determine how to do this + aCurrentRow[12] = new ORowSetValueDecorator(sal_Int32(0)); // TODO: determine how to do this aResults.push_back(aCurrentRow); } diff --git a/connectivity/source/drivers/firebird/ResultSetMetaData.cxx b/connectivity/source/drivers/firebird/ResultSetMetaData.cxx index b598846545de..877964630c4f 100644 --- a/connectivity/source/drivers/firebird/ResultSetMetaData.cxx +++ b/connectivity/source/drivers/firebird/ResultSetMetaData.cxx @@ -245,7 +245,7 @@ sal_Int32 SAL_CALL OResultSetMetaData::getPrecision(sal_Int32 column) Reference<XRow> xRow ( xRes, UNO_QUERY); if(xRes->next()) { - return (sal_Int32) xRow->getShort(1); + return static_cast<sal_Int32>(xRow->getShort(1)); } else { diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx index 2dab23cdd34d..3b6c0040e67b 100644 --- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx +++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx @@ -373,8 +373,8 @@ short OStatementCommonBase::getSqlInfoItem(char aInfoItem) if (!aErr && aResultsBuffer[0] == aInfoItem) { - const short aBytes = (short) isc_vax_integer(aResultsBuffer+1, 2); - return (short) isc_vax_integer(aResultsBuffer+3, aBytes); + const short aBytes = static_cast<short>(isc_vax_integer(aResultsBuffer+1, 2)); + return static_cast<short>(isc_vax_integer(aResultsBuffer+3, aBytes)); } evaluateStatusVector(aStatusVector, @@ -438,7 +438,7 @@ sal_Int32 OStatementCommonBase::getStatementChangeCount() } char* pResults = aResultsBuffer; - if (((short) *pResults++) == isc_info_sql_records) + if (static_cast<short>(*pResults++) == isc_info_sql_records) { // const short aTotalLength = (short) isc_vax_integer(pResults, 2); pResults += 2; @@ -447,7 +447,7 @@ sal_Int32 OStatementCommonBase::getStatementChangeCount() while (*pResults != isc_info_rsb_end) { const char aToken = *pResults; - const short aLength = (short) isc_vax_integer(pResults+1, 2); + const short aLength = static_cast<short>(isc_vax_integer(pResults+1, 2)); if (aToken == aDesiredInfoType) { diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx index b9c65817fd04..a78b7c91575d 100644 --- a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx +++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx @@ -63,13 +63,13 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(new ORowSetValueDecorator(OUString("CHAR"))); aRow.push_back(new ORowSetValueDecorator(DataType::CHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)254)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(254))); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnValue::NULLABLE))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnSearch::CHAR))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -78,7 +78,7 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(10))); aRows.push_back(aRow); @@ -91,28 +91,28 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( ) aRow[1] = new ORowSetValueDecorator(OUString("LONGVARCHAR")); aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR); - aRow[3] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[3] = new ORowSetValueDecorator(sal_Int32(65535)); aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("DATE")); aRow[2] = new ORowSetValueDecorator(DataType::DATE); - aRow[3] = new ORowSetValueDecorator((sal_Int32)10); + aRow[3] = new ORowSetValueDecorator(sal_Int32(10)); aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("TIME")); aRow[2] = new ORowSetValueDecorator(DataType::TIME); - aRow[3] = new ORowSetValueDecorator((sal_Int32)8); + aRow[3] = new ORowSetValueDecorator(sal_Int32(8)); aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("TIMESTAMP")); aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP); - aRow[3] = new ORowSetValueDecorator((sal_Int32)19); + aRow[3] = new ORowSetValueDecorator(sal_Int32(19)); aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); aRows.push_back(aRow); @@ -125,20 +125,20 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( ) aRow[1] = new ORowSetValueDecorator(OUString("DECIMAL")); aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); - aRow[15] = new ORowSetValueDecorator((sal_Int32)15); + aRow[3] = new ORowSetValueDecorator(sal_Int32(20)); + aRow[15] = new ORowSetValueDecorator(sal_Int32(15)); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("DOUBLE")); aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); + aRow[3] = new ORowSetValueDecorator(sal_Int32(20)); aRow[15] = ODatabaseMetaDataResultSet::get0Value(); aRows.push_back(aRow); aRow[1] = new ORowSetValueDecorator(OUString("NUMERIC")); aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC); - aRow[3] = new ORowSetValueDecorator((sal_Int32)20); - aRow[15] = new ORowSetValueDecorator((sal_Int32)20); + aRow[3] = new ORowSetValueDecorator(sal_Int32(20)); + aRow[15] = new ORowSetValueDecorator(sal_Int32(20)); aRows.push_back(aRow); } @@ -162,7 +162,7 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns( ODatabaseMetaDataResultSet::ORows aRows; ODatabaseMetaDataResultSet::ORow aRow(19); - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + aRow[10] = new ORowSetValueDecorator(sal_Int32(10)); Sequence< OUString> aTabNames(xNames->getElementNames()); const OUString* pTabBegin = aTabNames.getConstArray(); const OUString* pTabEnd = pTabBegin + aTabNames.getLength(); @@ -199,17 +199,17 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns( aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); - switch((sal_Int32)aRow[5]->getValue()) + switch(static_cast<sal_Int32>(aRow[5]->getValue())) { case DataType::CHAR: case DataType::VARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)254); + aRow[16] = new ORowSetValueDecorator(sal_Int32(254)); break; case DataType::LONGVARCHAR: - aRow[16] = new ORowSetValueDecorator((sal_Int32)65535); + aRow[16] = new ORowSetValueDecorator(sal_Int32(65535)); break; default: - aRow[16] = new ORowSetValueDecorator((sal_Int32)0); + aRow[16] = new ORowSetValueDecorator(sal_Int32(0)); } aRow[17] = new ORowSetValueDecorator(i); switch(sal_Int32(aRow[11]->getValue())) diff --git a/connectivity/source/drivers/flat/EResultSet.cxx b/connectivity/source/drivers/flat/EResultSet.cxx index 8c1e155641ba..4fb5214d6301 100644 --- a/connectivity/source/drivers/flat/EResultSet.cxx +++ b/connectivity/source/drivers/flat/EResultSet.cxx @@ -99,7 +99,7 @@ Any SAL_CALL OFlatResultSet::getBookmark( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - return makeAny((sal_Int32)(m_aRow->get())[0]->getValue()); + return makeAny(static_cast<sal_Int32>((m_aRow->get())[0]->getValue())); } sal_Bool SAL_CALL OFlatResultSet::moveToBookmark( const Any& bookmark ) diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index 435faf76553c..829f1e43854f 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -874,7 +874,7 @@ bool OFlatTable::readLine(sal_Int32 * const pEndPos, sal_Int32 * const pStartPos do { if (pStartPos) - *pStartPos = (sal_Int32)m_pFileStream->Tell(); + *pStartPos = static_cast<sal_Int32>(m_pFileStream->Tell()); m_pFileStream->ReadByteStringLine(m_aCurrentLine, nEncoding); if (m_pFileStream->eof()) return false; @@ -943,7 +943,7 @@ bool OFlatTable::readLine(sal_Int32 * const pEndPos, sal_Int32 * const pStartPos while(nonEmpty && m_aCurrentLine.Len() == 0); if(pEndPos) - *pEndPos = (sal_Int32)m_pFileStream->Tell(); + *pEndPos = static_cast<sal_Int32>(m_pFileStream->Tell()); return true; } diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 5b3c9f208214..69261b2dd53f 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -828,7 +828,7 @@ namespace connectivity Sequence<Any> aArguments(comphelper::InitAnyPropertySequence( { {"nodepath", Any(OUString("/org.openoffice.Setup/L10N" ))}, // the path to the node to open - {"depth", Any((sal_Int32)-1)}, // the depth: -1 means unlimited + {"depth", Any(sal_Int32(-1))}, // the depth: -1 means unlimited })); // create the access Reference< XPropertySet > xNode( diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx index 845da8abb825..7702ea574342 100644 --- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx @@ -472,10 +472,10 @@ void write_to_storage_stream( JNIEnv* env, jstring name, jstring key, jint v ) if ( xOut.is() ) { Sequence< ::sal_Int8 > oneByte(4); - oneByte[0] = (sal_Int8) ((v >> 24) & 0xFF); - oneByte[1] = (sal_Int8) ((v >> 16) & 0xFF); - oneByte[2] = (sal_Int8) ((v >> 8) & 0xFF); - oneByte[3] = (sal_Int8) ((v >> 0) & 0xFF); + oneByte[0] = static_cast<sal_Int8>((v >> 24) & 0xFF); + oneByte[1] = static_cast<sal_Int8>((v >> 16) & 0xFF); + oneByte[2] = static_cast<sal_Int8>((v >> 8) & 0xFF); + oneByte[3] = static_cast<sal_Int8>((v >> 0) & 0xFF); xOut->writeBytes(oneByte); } diff --git a/connectivity/source/drivers/jdbc/Blob.cxx b/connectivity/source/drivers/jdbc/Blob.cxx index 5d9b6b9c9b84..9211641526f8 100644 --- a/connectivity/source/drivers/jdbc/Blob.cxx +++ b/connectivity/source/drivers/jdbc/Blob.cxx @@ -63,7 +63,7 @@ sal_Int64 SAL_CALL java_sql_Blob::length( ) out = t.pEnv->CallLongMethod( object, mID ); ThrowSQLException(t.pEnv,*this); } //t.pEnv - return (sal_Int64)out; + return static_cast<sal_Int64>(out); } css::uno::Sequence< sal_Int8 > SAL_CALL java_sql_Blob::getBytes( sal_Int64 pos, sal_Int32 count ) { @@ -127,7 +127,7 @@ sal_Int64 SAL_CALL java_sql_Blob::position( const css::uno::Sequence< sal_Int8 > t.pEnv->DeleteLocalRef(pByteArray); ThrowSQLException(t.pEnv,*this); } //t.pEnv - return (sal_Int64)out; + return static_cast<sal_Int64>(out); } sal_Int64 SAL_CALL java_sql_Blob::positionOfBlob( const css::uno::Reference< css::sdbc::XBlob >& /*pattern*/, sal_Int64 /*start*/ ) diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx index 7e6f77de410d..ee02595f3666 100644 --- a/connectivity/source/drivers/jdbc/Clob.cxx +++ b/connectivity/source/drivers/jdbc/Clob.cxx @@ -62,7 +62,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) out = t.pEnv->CallLongMethod( object, mID ); ThrowSQLException(t.pEnv,*this); } //t.pEnv - return (sal_Int64)out; + return static_cast<sal_Int64>(out); } OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 subStringLength ) @@ -113,7 +113,7 @@ sal_Int64 SAL_CALL java_sql_Clob::position( const OUString& searchstr, sal_Int32 ThrowSQLException(t.pEnv,*this); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l)); } //t.pEnv - return (sal_Int64)out; + return static_cast<sal_Int64>(out); } sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const css::uno::Reference< css::sdbc::XClob >& /*pattern*/, sal_Int64 /*start*/ ) diff --git a/connectivity/source/drivers/jdbc/ConnectionLog.cxx b/connectivity/source/drivers/jdbc/ConnectionLog.cxx index 3218c0dc2bdc..329a0c185970 100644 --- a/connectivity/source/drivers/jdbc/ConnectionLog.cxx +++ b/connectivity/source/drivers/jdbc/ConnectionLog.cxx @@ -81,7 +81,7 @@ namespace comphelper { namespace log { namespace convert char buffer[ 30 ]; const size_t buffer_size = sizeof( buffer ); snprintf( buffer, buffer_size, "%04i-%02i-%02i", - (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day ); + static_cast<int>(_rDate.Year), static_cast<int>(_rDate.Month), static_cast<int>(_rDate.Day) ); return OUString::createFromAscii( buffer ); } @@ -91,7 +91,7 @@ namespace comphelper { namespace log { namespace convert char buffer[ 30 ]; const size_t buffer_size = sizeof( buffer ); snprintf( buffer, buffer_size, "%02i:%02i:%02i.%09i", - (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.NanoSeconds ); + static_cast<int>(_rTime.Hours), static_cast<int>(_rTime.Minutes), static_cast<int>(_rTime.Seconds), static_cast<int>(_rTime.NanoSeconds) ); return OUString::createFromAscii( buffer ); } @@ -101,8 +101,8 @@ namespace comphelper { namespace log { namespace convert char buffer[ 30 ]; const size_t buffer_size = sizeof( buffer ); snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%09i", - (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day, - (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.NanoSeconds ); + static_cast<int>(_rDateTime.Year), static_cast<int>(_rDateTime.Month), static_cast<int>(_rDateTime.Day), + static_cast<int>(_rDateTime.Hours), static_cast<int>(_rDateTime.Minutes), static_cast<int>(_rDateTime.Seconds), static_cast<int>(_rDateTime.NanoSeconds) ); return OUString::createFromAscii( buffer ); } diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx index ccef2260e8b0..7cd26be1daba 100644 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx @@ -124,7 +124,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( sal_Int32 typeFilterCount = _types.getLength(); if ( typeFilterCount ) { - jobjectArray pObjArray = t.pEnv->NewObjectArray( (jsize)typeFilterCount, java_lang_String::st_getMyClass(), nullptr ); + jobjectArray pObjArray = t.pEnv->NewObjectArray( static_cast<jsize>(typeFilterCount), java_lang_String::st_getMyClass(), nullptr ); OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); const OUString* typeFilter = _types.getConstArray(); bool bIncludeAllTypes = false; @@ -136,7 +136,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( break; } jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter ); - t.pEnv->SetObjectArrayElement( pObjArray, (jsize)i, aT ); + t.pEnv->SetObjectArrayElement( pObjArray, static_cast<jsize>(i), aT ); OSL_VERIFY( !isExceptionOccurred( t.pEnv ) ); } diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 06ee354903c9..20edd90d6192 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -291,7 +291,7 @@ sal_Int32 java_lang_Object::callIntMethod_ThrowSQL(const char* _pMethodName, jme // call method jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) ); ThrowSQLException( t.pEnv, nullptr ); - return (sal_Int32)out; + return static_cast<sal_Int32>(out); } sal_Int32 java_lang_Object::callIntMethod_ThrowRuntime(const char* _pMethodName, jmethodID& _inout_MethodID) const @@ -302,7 +302,7 @@ sal_Int32 java_lang_Object::callIntMethod_ThrowRuntime(const char* _pMethodName, // call method jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) ); ThrowRuntimeException(t.pEnv, nullptr); - return (sal_Int32)out; + return static_cast<sal_Int32>(out); } sal_Int32 java_lang_Object::callIntMethodWithIntArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const @@ -313,7 +313,7 @@ sal_Int32 java_lang_Object::callIntMethodWithIntArg_ThrowSQL( const char* _pMeth // call method jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) ); ThrowSQLException( t.pEnv, nullptr ); - return (sal_Int32)out; + return static_cast<sal_Int32>(out); } sal_Int32 java_lang_Object::callIntMethodWithIntArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const @@ -324,7 +324,7 @@ sal_Int32 java_lang_Object::callIntMethodWithIntArg_ThrowRuntime( const char* _p // call method jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) ); ThrowRuntimeException(t.pEnv, nullptr); - return (sal_Int32)out; + return static_cast<sal_Int32>(out); } void java_lang_Object::callVoidMethod_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID) const @@ -460,7 +460,7 @@ sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName // call method jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get()); ThrowSQLException( t.pEnv, nullptr ); - return (sal_Int32)out; + return static_cast<sal_Int32>(out); } jclass java_lang_Object::findMyClass(const char* _pClassName) diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index 3b726fe197b2..85ef0adb621d 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -176,7 +176,7 @@ void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex, void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) { - m_aLogger.log( LogLevel::FINER, STR_LOG_BYTE_PARAMETER, parameterIndex, (sal_Int32)x ); + m_aLogger.log( LogLevel::FINER, STR_LOG_BYTE_PARAMETER, parameterIndex, static_cast<sal_Int32>(x) ); ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); diff --git a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx index 09d3c0d229c4..cbf86ec30609 100644 --- a/connectivity/source/drivers/mork/MDatabaseMetaData.cxx +++ b/connectivity/source/drivers/mork/MDatabaseMetaData.cxx @@ -91,7 +91,7 @@ ODatabaseMetaDataResultSet::ORows& ODatabaseMetaData::getColumnRows( // DECIMAL_DIGITS. aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS); // NUM_PREC_RADIX - aRow[10] = new ORowSetValueDecorator((sal_Int32)10); + aRow[10] = new ORowSetValueDecorator(sal_Int32(10)); // NULLABLE aRow[11] = new ORowSetValueDecorator(s_nNULLABLE); // REMARKS @@ -855,14 +855,14 @@ Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR"))); aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR)); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(s_nCHAR_OCTET_LENGTH))); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(ColumnSearch::CHAR))); aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); @@ -871,7 +871,7 @@ Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( ) aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ORowSetValueDecorator((sal_Int32)10)); + aRow.push_back(new ORowSetValueDecorator(sal_Int32(10))); aRows.push_back(aRow); diff --git a/connectivity/source/drivers/mork/MPreparedStatement.cxx b/connectivity/source/drivers/mork/MPreparedStatement.cxx index fdd374c63ff2..716a87ca9c9e 100644 --- a/connectivity/source/drivers/mork/MPreparedStatement.cxx +++ b/connectivity/source/drivers/mork/MPreparedStatement.cxx @@ -345,7 +345,7 @@ void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex) m_aParameterRow->get().push_back(sal_Int32(0)); } - if ((sal_Int32)m_aParameterRow->get().size() <= parameterIndex) + if (static_cast<sal_Int32>(m_aParameterRow->get().size()) <= parameterIndex) m_aParameterRow->get().resize(parameterIndex+1); } diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx index 49905f3e8f39..e69022912e04 100644 --- a/connectivity/source/drivers/mork/MResultSet.cxx +++ b/connectivity/source/drivers/mork/MResultSet.cxx @@ -270,7 +270,7 @@ sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 /*columnIndex*/ ) void OResultSet::checkIndex(sal_Int32 columnIndex ) { - if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->get().size()) + if(columnIndex <= 0 || columnIndex > static_cast<sal_Int32>(m_xColumns->get().size())) ::dbtools::throwInvalidIndexException(*this); } @@ -297,7 +297,7 @@ bool OResultSet::fetchRow(sal_Int32 cardNumber,bool bForceReload) if (!bForceReload) { // Check whether we've already fetched the row... - if ( !(m_aRow->get())[0].isNull() && (sal_Int32)(m_aRow->get())[0] == cardNumber ) + if ( !(m_aRow->get())[0].isNull() && static_cast<sal_Int32>((m_aRow->get())[0]) == cardNumber ) return true; } // else @@ -347,7 +347,7 @@ OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) ResultSetEntryGuard aGuard( *this ); OSL_ENSURE(m_xColumns.is(), "Need the Columns!!"); - OSL_ENSURE(columnIndex <= (sal_Int32)m_xColumns->get().size(), "Trying to access invalid columns number"); + OSL_ENSURE(columnIndex <= static_cast<sal_Int32>(m_xColumns->get().size()), "Trying to access invalid columns number"); checkIndex( columnIndex ); // If this query was sorted then we should have a valid KeySet, so use it @@ -597,7 +597,7 @@ void OResultSet::getFastPropertyValue( switch(nHandle) { case PROPERTY_ID_RESULTSETCONCURRENCY: - rValue <<= (sal_Int32)ResultSetConcurrency::UPDATABLE; + rValue <<= sal_Int32(ResultSetConcurrency::UPDATABLE); break; case PROPERTY_ID_RESULTSETTYPE: rValue <<= m_nResultSetType; @@ -606,7 +606,7 @@ void OResultSet::getFastPropertyValue( rValue <<= m_nFetchDirection; break; case PROPERTY_ID_FETCHSIZE: - rValue <<= (sal_Int32)0; + rValue <<= sal_Int32(0); break; case PROPERTY_ID_ISBOOKMARKABLE: const_cast< OResultSet* >( this )->determineReadOnly(); @@ -653,8 +653,8 @@ void OResultSet::parseParameter( const OSQLParseNode* pNode, OUString& rMatchStr "Parameter name [" << m_nParamIndex << "]: " << aParameterName); if ( m_aParameterRow.is() ) { - OSL_ENSURE( m_nParamIndex < (sal_Int32)m_aParameterRow->get().size() + 1, "More parameters than values found" ); - rMatchString = (m_aParameterRow->get())[(sal_uInt16)m_nParamIndex]; + OSL_ENSURE( m_nParamIndex < static_cast<sal_Int32>(m_aParameterRow->get().size()) + 1, "More parameters than values found" ); + rMatchString = (m_aParameterRow->get())[static_cast<sal_uInt16>(m_nParamIndex)]; SAL_INFO("connectivity.mork", "Prop Value: " << rMatchString); } else { @@ -688,7 +688,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; SAL_INFO("connectivity.mork", "Prop Column Name: " << aColName); if ( m_aParameterRow.is() ) { - aParameterValue = (m_aParameterRow->get())[(sal_uInt16)i]; + aParameterValue = (m_aParameterRow->get())[static_cast<sal_uInt16>(i)]; SAL_INFO("connectivity.mork", "Prop Value: " << aParameterValue); } else { @@ -1022,7 +1022,7 @@ sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum) if ( m_pKeySet.is() ) { sal_Int32 nPos; - for(nPos=0;nPos < (sal_Int32)m_pKeySet->get().size();nPos++) + for(nPos=0;nPos < static_cast<sal_Int32>(m_pKeySet->get().size());nPos++) { if (nCardNum == (m_pKeySet->get())[nPos]) { @@ -1086,7 +1086,7 @@ void OResultSet::executeQuery() std::vector<sal_Int32>::const_iterator aOrderByIter = m_aOrderbyColumnNumber.begin(); for ( std::vector<sal_Int16>::size_type i = 0; aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i) { - OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index"); + OSL_ENSURE(static_cast<sal_Int32>(m_aRow->get().size()) > *aOrderByIter,"Invalid Index"); switch ((m_aRow->get().begin()+*aOrderByIter)->getTypeKind()) { case DataType::CHAR: @@ -1248,7 +1248,7 @@ void OResultSet::setBoundedColumns(const OValueRow& _rRow, ++aIter,++nColumnPos ) { - if ( nColumnPos < (sal_Int32)aColumnNames.size() ) + if ( nColumnPos < static_cast<sal_Int32>(aColumnNames.size()) ) sSelectColumnRealName = aColumnNames[nColumnPos]; else { @@ -1306,7 +1306,7 @@ bool OResultSet::validRow( sal_uInt32 nRow) { sal_Int32 nNumberOfRecords = m_aQueryHelper.getResultCount(); - while ( nRow > (sal_uInt32)nNumberOfRecords && !MQueryHelper::queryComplete() ) { + while ( nRow > static_cast<sal_uInt32>(nNumberOfRecords) && !MQueryHelper::queryComplete() ) { if (!m_aQueryHelper.checkRowAvailable( nRow )) { SAL_INFO( @@ -1324,7 +1324,7 @@ bool OResultSet::validRow( sal_uInt32 nRow) } if (( nRow == 0 ) || - ( nRow > (sal_uInt32)nNumberOfRecords && MQueryHelper::queryComplete()) ){ + ( nRow > static_cast<sal_uInt32>(nNumberOfRecords) && MQueryHelper::queryComplete()) ){ SAL_INFO("connectivity.mork", "validRow(" << nRow << "): return False"); return false; } @@ -1338,7 +1338,7 @@ bool OResultSet::fillKeySet(sal_Int32 nMaxCardNumber) if (m_CurrentRowCount < nMaxCardNumber) { sal_Int32 nKeyValue; - if ( (sal_Int32)m_pKeySet->get().capacity() < nMaxCardNumber ) + if ( static_cast<sal_Int32>(m_pKeySet->get().capacity()) < nMaxCardNumber ) m_pKeySet->get().reserve(nMaxCardNumber + 20 ); for (nKeyValue = m_CurrentRowCount+1; nKeyValue <= nMaxCardNumber; nKeyValue ++) @@ -1395,7 +1395,7 @@ bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) return false; } sal_Int32 nCurCard; - if ( nCurPos < (sal_Int32)m_pKeySet->get().size() ) //The requested row is exist in m_pKeySet, so we just use it + if ( nCurPos < static_cast<sal_Int32>(m_pKeySet->get().size()) ) //The requested row is exist in m_pKeySet, so we just use it { nCurCard = (m_pKeySet->get())[nCurPos-1]; } @@ -1411,7 +1411,7 @@ bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset ) } //Insert new retrieved items for later use fillKeySet(nNumberOfRecords); - m_nRowPos = (sal_uInt32)nCurPos; + m_nRowPos = static_cast<sal_uInt32>(nCurPos); SAL_INFO("connectivity.mork", "return True, m_nRowPos = " << m_nRowPos); fetchCurrentRow(); return true; @@ -1438,7 +1438,7 @@ css::uno::Any OResultSet::getBookmark( ) } OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row"); - return makeAny((sal_Int32)(m_aRow->get())[0]); + return makeAny(static_cast<sal_Int32>((m_aRow->get())[0])); } sal_Bool OResultSet::moveToBookmark( const css::uno::Any& bookmark ) { diff --git a/connectivity/source/drivers/mork/MResultSet.hxx b/connectivity/source/drivers/mork/MResultSet.hxx index da287247c653..88f93354de5a 100644 --- a/connectivity/source/drivers/mork/MResultSet.hxx +++ b/connectivity/source/drivers/mork/MResultSet.hxx @@ -332,7 +332,7 @@ public: OSL_ENSURE(column > 0, "OResultSet::mapColumn: invalid column index!"); // the first column (index 0) is for convenience only. The // first real select column is no 1. - if ((column > 0) && (column < (sal_Int32)m_aColMapping.size())) + if ((column > 0) && (column < static_cast<sal_Int32>(m_aColMapping.size()))) map = m_aColMapping[column]; return map; diff --git a/connectivity/source/drivers/mork/MResultSetMetaData.cxx b/connectivity/source/drivers/mork/MResultSetMetaData.cxx index 2d362eefc291..80b53817d1af 100644 --- a/connectivity/source/drivers/mork/MResultSetMetaData.cxx +++ b/connectivity/source/drivers/mork/MResultSetMetaData.cxx @@ -43,7 +43,7 @@ OResultSetMetaData::~OResultSetMetaData() void OResultSetMetaData::checkColumnIndex(sal_Int32 column) { - if(column <= 0 || column > (sal_Int32)m_xColumns->get().size()) + if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->get().size())) throwInvalidIndexException(*this); } diff --git a/connectivity/source/drivers/mork/MorkParser.cxx b/connectivity/source/drivers/mork/MorkParser.cxx index 62167e1614a2..143e3d6ca3e2 100644 --- a/connectivity/source/drivers/mork/MorkParser.cxx +++ b/connectivity/source/drivers/mork/MorkParser.cxx @@ -299,7 +299,7 @@ bool MorkParser::parseCell() std::string HexChar; HexChar += nextChar(); HexChar += nextChar(); - Text += (char)strtoul(HexChar.c_str(), nullptr, 16); + Text += static_cast<char>(strtoul(HexChar.c_str(), nullptr, 16)); } break; default: diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx index 3a3a8ce58b0c..5cd342b93e30 100644 --- a/connectivity/source/drivers/odbc/OConnection.cxx +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -103,7 +103,7 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi memset(szConnStrOut,'\0',4096); memset(szConnStrIn,'\0',2048); OString aConStr(OUStringToOString(aConnectStr,getTextEncoding())); - memcpy(szConnStrIn, aConStr.getStr(), std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength())); + memcpy(szConnStrIn, aConStr.getStr(), std::min<sal_Int32>(sal_Int32(2048),aConStr.getLength())); #ifndef MACOSX N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,reinterpret_cast<SQLPOINTER>(nTimeOut),SQL_IS_UINTEGER); @@ -116,9 +116,9 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle, nullptr, szConnStrIn, - (SQLSMALLINT) std::min((sal_Int32)2048,aConStr.getLength()), + static_cast<SQLSMALLINT>(std::min(sal_Int32(2048),aConStr.getLength())), szConnStrOut, - (SQLSMALLINT) (sizeof(szConnStrOut)/sizeof(SDB_ODBC_CHAR)) -1, + SQLSMALLINT(sizeof(szConnStrOut)/sizeof(SDB_ODBC_CHAR)) -1, &cbConnStrOut, SQL_DRIVER_NOPROMPT); if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA || SQL_SUCCESS_WITH_INFO == nSQLRETURN) diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index a5371ac254b6..ef6fb720402d 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -1124,7 +1124,7 @@ void ODatabaseMetaDataResultSet::openSpecialColumns(bool _bRowVer,const Any& cat reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKQ)), (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0, reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKO)), pPKO ? SQL_NTS : 0 , reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(pPKN)), SQL_NTS, - (SQLSMALLINT)scope, + static_cast<SQLSMALLINT>(scope), nullable ? SQL_NULLABLE : SQL_NO_NULLS); OTools::ThrowException(m_pConnection.get(),nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this); checkColumnCount(); diff --git a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx index 59e3fea862b2..fcf4ce65374d 100644 --- a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx +++ b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx @@ -33,15 +33,15 @@ OResultSetMetaData::~OResultSetMetaData() OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) { sal_Int32 column = _column; - if(_column <(sal_Int32) m_vMapping.size()) // use mapping + if(_column <static_cast<sal_Int32>(m_vMapping.size())) // use mapping column = m_vMapping[_column]; SQLSMALLINT BUFFER_LEN = 128; char *pName = new char[BUFFER_LEN+1]; SQLSMALLINT nRealLen=0; SQLRETURN nRet = N3SQLColAttribute(m_aStatementHandle, - (SQLUSMALLINT)column, - (SQLUSMALLINT)ident, + static_cast<SQLUSMALLINT>(column), + static_cast<SQLUSMALLINT>(ident), static_cast<SQLPOINTER>(pName), BUFFER_LEN, &nRealLen, @@ -60,8 +60,8 @@ OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) { pName = new char[nRealLen+1]; nRet = N3SQLColAttribute(m_aStatementHandle, - (SQLUSMALLINT)column, - (SQLUSMALLINT)ident, + static_cast<SQLUSMALLINT>(column), + static_cast<SQLUSMALLINT>(ident), static_cast<SQLPOINTER>(pName), nRealLen, &nRealLen, @@ -84,8 +84,8 @@ SQLLEN OResultSetMetaData::getNumColAttrib(OConnection const * _pConnection { SQLLEN nValue=0; OTools::ThrowException(_pConnection,(*reinterpret_cast<T3SQLColAttribute>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::ColAttribute)))(_aStatementHandle, - (SQLUSMALLINT)_column, - (SQLUSMALLINT)_ident, + static_cast<SQLUSMALLINT>(_column), + static_cast<SQLUSMALLINT>(_ident), nullptr, 0, nullptr, @@ -96,7 +96,7 @@ SQLLEN OResultSetMetaData::getNumColAttrib(OConnection const * _pConnection sal_Int32 OResultSetMetaData::getNumColAttrib(sal_Int32 _column,sal_Int32 ident) { sal_Int32 column = _column; - if(_column < (sal_Int32)m_vMapping.size()) // use mapping + if(_column < static_cast<sal_Int32>(m_vMapping.size())) // use mapping column = m_vMapping[_column]; return getNumColAttrib(m_pConnection,m_aStatementHandle,*this,column,ident); @@ -115,13 +115,13 @@ SQLSMALLINT OResultSetMetaData::getColumnODBCType(OConnection const * _pConnecti SQLSMALLINT nType = 0; try { - nType = (SQLSMALLINT)getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE); + nType = static_cast<SQLSMALLINT>(getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE)); if(nType == SQL_UNKNOWN_TYPE) - nType = (SQLSMALLINT)getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column, SQL_DESC_TYPE); + nType = static_cast<SQLSMALLINT>(getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column, SQL_DESC_TYPE)); } catch(SQLException& ) // in this case we have an odbc 2.0 driver { - nType = (SQLSMALLINT)getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE ); + nType = static_cast<SQLSMALLINT>(getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE )); } return nType; diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index 3137eb656bb6..8f45adf8166a 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -845,7 +845,7 @@ void OStatement_Base::setCursorName(const OUString &_par0) { OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); OString aName(OUStringToOString(_par0,getOwnConnection()->getTextEncoding())); - N3SQLSetCursorName(m_aStatementHandle, reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(aName.getStr())), (SQLSMALLINT)aName.getLength()); + N3SQLSetCursorName(m_aStatementHandle, reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(aName.getStr())), static_cast<SQLSMALLINT>(aName.getLength())); } bool OStatement_Base::isUsingBookmarks() const diff --git a/connectivity/source/drivers/odbc/OTools.cxx b/connectivity/source/drivers/odbc/OTools.cxx index f7a222e12860..aa29a9ebb94d 100644 --- a/connectivity/source/drivers/odbc/OTools.cxx +++ b/connectivity/source/drivers/odbc/OTools.cxx @@ -152,7 +152,7 @@ void OTools::getValue( OConnection const * _pConnection, SQLLEN pcbValue = SQL_NULL_DATA; OTools::ThrowException(_pConnection, (*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))(_aStatementHandle, - (SQLUSMALLINT)columnIndex, + static_cast<SQLUSMALLINT>(columnIndex), _nType, _pValue, _nSize, @@ -187,7 +187,7 @@ void OTools::bindValue( OConnection const * _pConnection, { *pLen = SQL_NULL_DATA; nRetcode = (*reinterpret_cast<T3SQLBindCol>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(_aStatementHandle, - (SQLUSMALLINT)columnIndex, + static_cast<SQLUSMALLINT>(columnIndex), fCType, _pData, _nMaxLen, @@ -218,7 +218,7 @@ void OTools::bindValue( OConnection const * _pConnection, case SQL_NUMERIC: { OString aString = OString::number(*static_cast<double const *>(_pValue)); - *pLen = (SQLSMALLINT)aString.getLength(); + *pLen = static_cast<SQLSMALLINT>(aString.getLength()); *static_cast<OString*>(_pData) = aString; // Pointer on Char* _pData = const_cast<char *>(static_cast<OString*>(_pData)->getStr()); @@ -256,20 +256,20 @@ void OTools::bindValue( OConnection const * _pConnection, { /* see https://msdn.microsoft.com/en-us/library/ms716238%28v=vs.85%29.aspx * for an explanation of that apparently weird cast */ - _pData = reinterpret_cast<void*>((uintptr_t)columnIndex); + _pData = reinterpret_cast<void*>(static_cast<uintptr_t>(columnIndex)); sal_Int32 nLen = 0; nLen = static_cast<const css::uno::Sequence< sal_Int8 > *>(_pValue)->getLength(); - *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen); + *pLen = static_cast<SQLLEN>(SQL_LEN_DATA_AT_EXEC(nLen)); } break; case SQL_LONGVARCHAR: { /* see https://msdn.microsoft.com/en-us/library/ms716238%28v=vs.85%29.aspx * for an explanation of that apparently weird cast */ - _pData = reinterpret_cast<void*>((uintptr_t)columnIndex); + _pData = reinterpret_cast<void*>(static_cast<uintptr_t>(columnIndex)); sal_Int32 nLen = 0; nLen = static_cast<OUString const *>(_pValue)->getLength(); - *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen); + *pLen = static_cast<SQLLEN>(SQL_LEN_DATA_AT_EXEC(nLen)); } break; case SQL_DATE: *pLen = sizeof(DATE_STRUCT); @@ -290,7 +290,7 @@ void OTools::bindValue( OConnection const * _pConnection, } nRetcode = (*reinterpret_cast<T3SQLBindCol>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(_aStatementHandle, - (SQLUSMALLINT)columnIndex, + static_cast<SQLUSMALLINT>(columnIndex), fCType, _pData, _nMaxLen, @@ -382,7 +382,7 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection, OTools::ThrowException(_pConnection, (*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))( _aStatementHandle, - (SQLUSMALLINT)columnIndex, + static_cast<SQLUSMALLINT>(columnIndex), _fSqlType, static_cast<SQLPOINTER>(aCharArray), nMaxLen, @@ -442,10 +442,10 @@ OUString OTools::getStringValue(OConnection const * _pConnection, OTools::ThrowException(_pConnection, (*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))( _aStatementHandle, - (SQLUSMALLINT)columnIndex, + static_cast<SQLUSMALLINT>(columnIndex), SQL_C_WCHAR, &waCharArray, - (SQLLEN)nMaxLen*sizeof(sal_Unicode), + SQLLEN(nMaxLen)*sizeof(sal_Unicode), &pcbValue), _aStatementHandle,SQL_HANDLE_STMT,_xInterface); _bWasNull = pcbValue == SQL_NULL_DATA; @@ -486,7 +486,7 @@ OUString OTools::getStringValue(OConnection const * _pConnection, OTools::ThrowException(_pConnection, (*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))( _aStatementHandle, - (SQLUSMALLINT)columnIndex, + static_cast<SQLUSMALLINT>(columnIndex), SQL_C_CHAR, &aCharArray, nMaxLen, diff --git a/connectivity/source/drivers/postgresql/pq_array.cxx b/connectivity/source/drivers/postgresql/pq_array.cxx index d89fe00f4ca6..1f0ccfd1b6e8 100644 --- a/connectivity/source/drivers/postgresql/pq_array.cxx +++ b/connectivity/source/drivers/postgresql/pq_array.cxx @@ -96,7 +96,7 @@ css::uno::Reference< css::sdbc::XResultSet > Array::getResultSetAtIndex( for( int i = 0 ; i < count ; i ++ ) { std::vector< Any > row( 2 ); - row[0] <<= (sal_Int32) ( i + index ); + row[0] <<= static_cast<sal_Int32>( i + index ); row[1] = m_data[i+index-1]; ret[i] = row; } @@ -108,7 +108,7 @@ css::uno::Reference< css::sdbc::XResultSet > Array::getResultSetAtIndex( void Array::checkRange( sal_Int32 index, sal_Int32 count ) { - if( index >= 1 && index -1 + count <= (sal_Int32)m_data.size() ) + if( index >= 1 && index -1 + count <= static_cast<sal_Int32>(m_data.size()) ) return; throw SQLException( "Array::getArrayAtIndex(): allowed range for index + count " diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index 906ce288c1bb..32ed73fbe219 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -2467,7 +2467,7 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getIndexInfo( result[R_NON_UNIQUE] <<= isNonUnique; result[R_TYPE] <<= indexType; result[R_COLUMN_NAME] <<= rowColumn->getString(2); - sal_Int32 nPos = (sal_Int32)(findIt - columns.begin() +1); // MSVC++ nonsense + sal_Int32 nPos = static_cast<sal_Int32>(findIt - columns.begin() +1); // MSVC++ nonsense result[R_ORDINAL_POSITION] <<= nPos; vec.push_back( result ); } diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx index d06fa9bcf507..7e84c5fe1612 100644 --- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx +++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx @@ -172,8 +172,8 @@ PreparedStatement::PreparedStatement( , m_multipleResultUpdateCount(0) , m_lastOidInserted( InvalidOid ) { - m_props[PREPARED_STATEMENT_QUERY_TIME_OUT] <<= (sal_Int32)0; - m_props[PREPARED_STATEMENT_MAX_ROWS] <<= (sal_Int32)0; + m_props[PREPARED_STATEMENT_QUERY_TIME_OUT] <<= sal_Int32(0); + m_props[PREPARED_STATEMENT_MAX_ROWS] <<= sal_Int32(0); m_props[PREPARED_STATEMENT_RESULT_SET_CONCURRENCY] <<= css::sdbc::ResultSetConcurrency::READ_ONLY; m_props[PREPARED_STATEMENT_RESULT_SET_TYPE] <<= @@ -211,7 +211,7 @@ PreparedStatement::~PreparedStatement() void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex ) { - if( parameterIndex < 1 || parameterIndex > (sal_Int32) m_vars.size() ) + if( parameterIndex < 1 || parameterIndex > static_cast<sal_Int32>(m_vars.size()) ) { throw SQLException( "pq_preparedstatement: parameter index out of range (expected 1 to " diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx index 06341803ba2b..5e1137477dbb 100644 --- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx @@ -166,7 +166,7 @@ void ResultSetMetaData::checkForTypes() buf.append( " OR " ); int oid = m_colDesc[i].typeOid; buf.append( "oid=" ); - buf.append( (sal_Int32) oid ); + buf.append( static_cast<sal_Int32>(oid) ); } Reference< XResultSet > rs = stmt->executeQuery( buf.makeStringAndClear() ); Reference< XRow > xRow( rs, UNO_QUERY ); diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx index d589da130b6a..018bff0aab72 100644 --- a/connectivity/source/drivers/postgresql/pq_statement.cxx +++ b/connectivity/source/drivers/postgresql/pq_statement.cxx @@ -164,8 +164,8 @@ Statement::Statement( const ::rtl::Reference< comphelper::RefCountedMutex > & re , m_multipleResultUpdateCount(0) , m_lastOidInserted(InvalidOid) { - m_props[STATEMENT_QUERY_TIME_OUT] <<= (sal_Int32)0; - m_props[STATEMENT_MAX_ROWS] <<= (sal_Int32)0; + m_props[STATEMENT_QUERY_TIME_OUT] <<= sal_Int32(0); + m_props[STATEMENT_MAX_ROWS] <<= sal_Int32(0); m_props[STATEMENT_RESULT_SET_CONCURRENCY] <<= css::sdbc::ResultSetConcurrency::READ_ONLY; m_props[STATEMENT_RESULT_SET_TYPE] <<= @@ -505,7 +505,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) // check, whether the columns are in the result set (required !) int i; - for( i = 0 ; i < (int)sourceTableKeys.size() ; i ++ ) + for( i = 0 ; i < static_cast<int>(sourceTableKeys.size()) ; i ++ ) { if( -1 == PQfnumber( result, @@ -516,7 +516,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) } } - if( sourceTableKeys.size() && i == (int)sourceTableKeys.size() ) + if( sourceTableKeys.size() && i == static_cast<int>(sourceTableKeys.size()) ) { *(data->pLastResultset) = UpdateableResultSet::createFromPGResultSet( diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index e8e16991c910..707d634044ce 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -497,7 +497,7 @@ void Columns::appendByDescriptor( void Columns::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= (sal_Int32)m_values.size() ) + if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "COLUMNS: Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx index 0ac0f7f39d51..f38ab65e112b 100644 --- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx @@ -155,7 +155,7 @@ Any Container::getByName( const OUString& aName ) "Element " + aName + " unknown in " + m_type + "-Container", *this ); } - OSL_ASSERT( ii->second >= 0 && ii->second < (int)m_values.size() ); + OSL_ASSERT( ii->second >= 0 && ii->second < static_cast<int>(m_values.size()) ); return m_values[ ii->second ]; } @@ -190,7 +190,7 @@ sal_Bool Container::hasElements( ) Any Container::getByIndex( sal_Int32 Index ) { - if( Index < 0 || Index >= (sal_Int32)m_values.size() ) + if( Index < 0 || Index >= static_cast<sal_Int32>(m_values.size()) ) { throw IndexOutOfBoundsException( "Index " + OUString::number( Index ) @@ -226,7 +226,7 @@ public: sal_Bool ContainerEnumeration::hasMoreElements() { - return (int)m_vec.size() > m_index +1; + return static_cast<int>(m_vec.size()) > m_index +1; } css::uno::Any ContainerEnumeration::nextElement() @@ -297,7 +297,7 @@ void Container::dropByName( const OUString& elementName ) void Container::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >=(sal_Int32)m_values.size() ) + if( index < 0 || index >=static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "Index out of range (allowed 0 to " @@ -320,7 +320,7 @@ void Container::dropByIndex( sal_Int32 index ) } } - for( int i = index +1 ; i < (int)m_values.size() ; i ++ ) + for( int i = index +1 ; i < static_cast<int>(m_values.size()) ; i ++ ) { m_values[i-1] = m_values[i]; diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx index ac44329f5676..22b8acf7102c 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx @@ -241,7 +241,7 @@ void Indexes::dropByIndex( sal_Int32 index ) osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= (sal_Int32)m_values.size() ) + if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "Indexes: Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx index dadf75079c3d..07ee93726a4d 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx @@ -225,7 +225,7 @@ void Keys::appendByDescriptor( void Keys::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= (sal_Int32)m_values.size() ) + if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx index 52a418da6a9c..0eb86f12942c 100644 --- a/connectivity/source/drivers/postgresql/pq_xtables.cxx +++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx @@ -120,8 +120,7 @@ void Tables::refresh() st.DESCRIPTION , makeAny( xRow->getString( TABLE_INDEX_REMARKS+1) ) ); pTable->setPropertyValue_NoBroadcast_public( st.PRIVILEGES , - makeAny( (sal_Int32) - ( css::sdbcx::Privilege::SELECT | + makeAny( sal_Int32( css::sdbcx::Privilege::SELECT | css::sdbcx::Privilege::INSERT | css::sdbcx::Privilege::UPDATE | css::sdbcx::Privilege::DELETE | @@ -312,7 +311,7 @@ void Tables::appendByDescriptor( void Tables::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= (sal_Int32)m_values.size() ) + if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx index d34fca1505d6..e7d6b6112b5a 100644 --- a/connectivity/source/drivers/postgresql/pq_xusers.cxx +++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx @@ -148,7 +148,7 @@ void Users::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= (sal_Int32)m_values.size() ) + if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "USERS: Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx index 1dad00db42ba..7b1abf581468 100644 --- a/connectivity/source/drivers/postgresql/pq_xviews.cxx +++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx @@ -173,7 +173,7 @@ void Views::dropByName( const OUString& elementName ) void Views::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= (sal_Int32)m_values.size() ) + if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) { throw css::lang::IndexOutOfBoundsException( "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx index 13369fceddf5..6c0d06fe8af4 100644 --- a/connectivity/source/inc/file/FResultSet.hxx +++ b/connectivity/source/inc/file/FResultSet.hxx @@ -299,7 +299,7 @@ namespace connectivity OSL_ENSURE(column > 0, "file::OResultSet::mapColumn: invalid column index!"); // the first column (index 0) is for convenience only. The first real select column is number 1. - if ((column > 0) && (column < (sal_Int32)m_aColMapping.size())) + if ((column > 0) && (column < static_cast<sal_Int32>(m_aColMapping.size()))) map = m_aColMapping[column]; return map; diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index 696bf3bcf911..ca3a8ffd9759 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -345,7 +345,7 @@ void OSDBCDriverManager::initializeDriverPrecedence() for ( sal_Int32 i=0; i<nOrderedCount; ++i ) m_aEventLogger.log( LogLevel::CONFIG, "configuration's driver order: driver $1$ of $2$: $3$", - (sal_Int32)(i + 1), nOrderedCount, aDriverOrder[i] + static_cast<sal_Int32>(i + 1), nOrderedCount, aDriverOrder[i] ); } diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 86608cbcded9..066ee2eba162 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -712,7 +712,7 @@ namespace { if( _pColumnRef->count() > 1 ) { - for ( sal_Int32 i=0; i<((sal_Int32)_pColumnRef->count())-2; ++i ) + for ( sal_Int32 i=0; i<static_cast<sal_Int32>(_pColumnRef->count())-2; ++i ) _pColumnRef->getChild(i)->parseNodeToStr( _out_rTableRange, _rxConnection, nullptr, false, false ); _out_rColumnName = _pColumnRef->getChild( _pColumnRef->count()-1 )->getChild(0)->getTokenValue(); } @@ -1106,7 +1106,7 @@ namespace OUString lcl_generateParameterName( const OSQLParseNode& _rParentNode, const OSQLParseNode& _rParamNode ) { OUString sColumnName( "param" ); - const sal_Int32 nCount = (sal_Int32)_rParentNode.count(); + const sal_Int32 nCount = static_cast<sal_Int32>(_rParentNode.count()); for ( sal_Int32 i = 0; i < nCount; ++i ) { if ( _rParentNode.getChild(i) == &_rParamNode ) diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 3c28d1ecaa1c..5eb1d44eca30 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -108,7 +108,7 @@ namespace { OUString rNewValue = rQuot; rNewValue += rValue; - sal_Int32 nIndex = (sal_Int32)-1; // Replace quotes with double quotes or the parser gets into problems + sal_Int32 nIndex = sal_Int32(-1); // Replace quotes with double quotes or the parser gets into problems if (!rQuot.isEmpty()) { @@ -1754,7 +1754,7 @@ void OSQLParseNode::replaceNodeValue(const OUString& rTableAlias, const OUString { if (SQL_ISRULE(this,column_ref) && count() == 1 && getChild(0)->getTokenValue() == rColumnName) { - OSQLParseNode * pCol = removeAt((sal_uInt32)0); + OSQLParseNode * pCol = removeAt(sal_uInt32(0)); append(new OSQLParseNode(rTableAlias,SQLNodeType::Name)); append(new OSQLParseNode(".",SQLNodeType::Punctuation)); append(pCol); @@ -1839,7 +1839,7 @@ void OSQLParseNode::disjunctiveNormalForm(OSQLParseNode*& pSearchCondition) pSearchCondition->removeAt(2); pNewRight = MakeANDNode(pOr->removeAt(2) ,pRight); - pNewLeft = MakeANDNode(pOr->removeAt((sal_uInt32)0) ,new OSQLParseNode(*pRight)); + pNewLeft = MakeANDNode(pOr->removeAt(sal_uInt32(0)) ,new OSQLParseNode(*pRight)); pNewNode = MakeORNode(pNewLeft,pNewRight); // and append new Node replaceAndReset(pSearchCondition,pNewNode); @@ -1855,10 +1855,10 @@ void OSQLParseNode::disjunctiveNormalForm(OSQLParseNode*& pSearchCondition) OSQLParseNode* pNewRight = nullptr; // cut left from parent - pSearchCondition->removeAt((sal_uInt32)0); + pSearchCondition->removeAt(sal_uInt32(0)); pNewRight = MakeANDNode(pLeft,pOr->removeAt(2)); - pNewLeft = MakeANDNode(new OSQLParseNode(*pLeft),pOr->removeAt((sal_uInt32)0)); + pNewLeft = MakeANDNode(new OSQLParseNode(*pLeft),pOr->removeAt(sal_uInt32(0))); pNewNode = MakeORNode(pNewLeft,pNewRight); // and append new Node @@ -1890,9 +1890,9 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, bool if(bNegate) { OSQLParseNode* pNewNode = new OSQLParseNode(OUString(),SQLNodeType::Rule,OSQLParser::RuleID(OSQLParseNode::boolean_term)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0)); + pNewNode->append(pSearchCondition->removeAt(sal_uInt32(0))); pNewNode->append(new OSQLParseNode("AND",SQLNodeType::Keyword,SQL_TOKEN_AND)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)1)); + pNewNode->append(pSearchCondition->removeAt(sal_uInt32(1))); replaceAndReset(pSearchCondition,pNewNode); pLeft = pNewNode->getChild(0); @@ -1910,9 +1910,9 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, bool if(bNegate) { OSQLParseNode* pNewNode = new OSQLParseNode(OUString(),SQLNodeType::Rule,OSQLParser::RuleID(OSQLParseNode::search_condition)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)0)); + pNewNode->append(pSearchCondition->removeAt(sal_uInt32(0))); pNewNode->append(new OSQLParseNode("OR",SQLNodeType::Keyword,SQL_TOKEN_OR)); - pNewNode->append(pSearchCondition->removeAt((sal_uInt32)1)); + pNewNode->append(pSearchCondition->removeAt(sal_uInt32(1))); replaceAndReset(pSearchCondition,pNewNode); pLeft = pNewNode->getChild(0); @@ -1925,9 +1925,9 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, bool // SQL_TOKEN_NOT ( boolean_primary ) else if (SQL_ISRULE(pSearchCondition,boolean_factor)) { - OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0); + OSQLParseNode *pNot = pSearchCondition->removeAt(sal_uInt32(0)); delete pNot; - OSQLParseNode *pBooleanTest = pSearchCondition->removeAt((sal_uInt32)0); + OSQLParseNode *pBooleanTest = pSearchCondition->removeAt(sal_uInt32(0)); // TODO is this needed // pBooleanTest->setParent(NULL); replaceAndReset(pSearchCondition,pBooleanTest); @@ -2063,7 +2063,7 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) if(( SQL_ISRULE(pSearchCondition,boolean_term) || SQL_ISRULE(pSearchCondition,search_condition)) && *pSearchCondition->getChild(0) == *pSearchCondition->getChild(2)) { - pNewNode = pSearchCondition->removeAt((sal_uInt32)0); + pNewNode = pSearchCondition->removeAt(sal_uInt32(0)); replaceAndReset(pSearchCondition,pNewNode); } // (a or b) and a || ( b or c ) and a @@ -2085,22 +2085,22 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) // a and ( a or b) -> a or b { - pNewNode = pSearchCondition->removeAt((sal_uInt32)0); + pNewNode = pSearchCondition->removeAt(sal_uInt32(0)); replaceAndReset(pSearchCondition,pNewNode); } else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) // a and ( b or a) -> a or b { - pNewNode = pSearchCondition->removeAt((sal_uInt32)2); + pNewNode = pSearchCondition->removeAt(sal_uInt32(2)); replaceAndReset(pSearchCondition,pNewNode); } else if ( p2ndSearch->getByRule(OSQLParseNode::search_condition) ) { // a and ( b or c ) -> ( a and b ) or ( a and c ) // ( b or c ) and a -> ( a and b ) or ( a and c ) - OSQLParseNode* pC = p2ndSearch->removeAt((sal_uInt32)2); - OSQLParseNode* pB = p2ndSearch->removeAt((sal_uInt32)0); - OSQLParseNode* pA = pSearchCondition->removeAt((sal_uInt32)2-nPos); + OSQLParseNode* pC = p2ndSearch->removeAt(sal_uInt32(2)); + OSQLParseNode* pB = p2ndSearch->removeAt(sal_uInt32(0)); + OSQLParseNode* pA = pSearchCondition->removeAt(sal_uInt32(2)-nPos); OSQLParseNode* p1stAnd = MakeANDNode(pA,pB); OSQLParseNode* p2ndAnd = MakeANDNode(new OSQLParseNode(*pA),pC); @@ -2119,12 +2119,12 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) { if(*pSearchCondition->getChild(2)->getChild(0) == *pSearchCondition->getChild(0)) { - pNewNode = pSearchCondition->removeAt((sal_uInt32)0); + pNewNode = pSearchCondition->removeAt(sal_uInt32(0)); replaceAndReset(pSearchCondition,pNewNode); } else if(*pSearchCondition->getChild(2)->getChild(2) == *pSearchCondition->getChild(0)) { - pNewNode = pSearchCondition->removeAt((sal_uInt32)0); + pNewNode = pSearchCondition->removeAt(sal_uInt32(0)); replaceAndReset(pSearchCondition,pNewNode); } } @@ -2133,12 +2133,12 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition) { if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)) { - pNewNode = pSearchCondition->removeAt((sal_uInt32)2); + pNewNode = pSearchCondition->removeAt(sal_uInt32(2)); replaceAndReset(pSearchCondition,pNewNode); } else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)) { - pNewNode = pSearchCondition->removeAt((sal_uInt32)2); + pNewNode = pSearchCondition->removeAt(sal_uInt32(2)); replaceAndReset(pSearchCondition,pNewNode); } } @@ -2192,12 +2192,12 @@ void OSQLParseNode::compress(OSQLParseNode *&pSearchCondition) OSQLParseNode::eraseBraces(pLeft); OSQLParseNode::eraseBraces(pRight); - pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt((sal_uInt32)0),pNewRule); + pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt(sal_uInt32(0)),pNewRule); replaceAndReset(pSearchCondition,pNode); } else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)->getChild(0)) { - OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt((sal_uInt32)0); + OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(sal_uInt32(0)); OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(2); OSQLParseNode* pNode = MakeORNode(pLeft,pRight); @@ -2215,7 +2215,7 @@ void OSQLParseNode::compress(OSQLParseNode *&pSearchCondition) else if(*pSearchCondition->getChild(0)->getChild(0) == *pSearchCondition->getChild(2)->getChild(2)) { OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(2); - OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt((sal_uInt32)0); + OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(sal_uInt32(0)); OSQLParseNode* pNode = MakeORNode(pLeft,pRight); OSQLParseNode* pNewRule = new OSQLParseNode(OUString(),SQLNodeType::Rule,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); @@ -2226,13 +2226,13 @@ void OSQLParseNode::compress(OSQLParseNode *&pSearchCondition) OSQLParseNode::eraseBraces(pLeft); OSQLParseNode::eraseBraces(pRight); - pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt((sal_uInt32)0),pNewRule); + pNode = MakeANDNode(pSearchCondition->getChild(0)->removeAt(sal_uInt32(0)),pNewRule); replaceAndReset(pSearchCondition,pNode); } else if(*pSearchCondition->getChild(0)->getChild(2) == *pSearchCondition->getChild(2)->getChild(2)) { - OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt((sal_uInt32)0); - OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt((sal_uInt32)0); + OSQLParseNode* pLeft = pSearchCondition->getChild(0)->removeAt(sal_uInt32(0)); + OSQLParseNode* pRight = pSearchCondition->getChild(2)->removeAt(sal_uInt32(0)); OSQLParseNode* pNode = MakeORNode(pLeft,pRight); OSQLParseNode* pNewRule = new OSQLParseNode(OUString(),SQLNodeType::Rule,OSQLParser::RuleID(OSQLParseNode::boolean_primary)); |