diff options
Diffstat (limited to 'connectivity')
25 files changed, 237 insertions, 179 deletions
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx index 9a73d10b7a86..6b9ea06247f5 100644 --- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -190,43 +190,43 @@ Reference< css::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getChara sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) { - return bool(getValue(columnIndex)); + return getValue(columnIndex).getBool(); } sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getInt8(); } Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getSequence(); } css::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getDate(); } double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getDouble(); } float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getFloat(); } sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getInt32(); } @@ -238,7 +238,7 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getLong(); } @@ -285,25 +285,25 @@ Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getInt16(); } OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getString(); } css::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getTime(); } css::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getDateTime(); } diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index c4f8f9faeac1..85da5fba30b3 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -945,20 +945,20 @@ OUString ORowSetValue::getString( ) const aRet = m_aValue.m_pString; break; case DataType::FLOAT: - aRet = OUString::number(static_cast<float>(*this)); + aRet = OUString::number(getFloat()); break; case DataType::DOUBLE: case DataType::REAL: - aRet = OUString::number(static_cast<double>(*this)); + aRet = OUString::number(getDouble()); break; case DataType::DATE: - aRet = DBTypeConversion::toDateString(*this); + aRet = DBTypeConversion::toDateString(getDate()); break; case DataType::TIME: - aRet = DBTypeConversion::toTimeString(*this); + aRet = DBTypeConversion::toTimeString(getTime()); break; case DataType::TIMESTAMP: - aRet = DBTypeConversion::toDateTimeString(*this); + aRet = DBTypeConversion::toDateTimeString(getDateTime()); break; case DataType::BINARY: case DataType::VARBINARY: @@ -974,24 +974,24 @@ OUString ORowSetValue::getString( ) const } break; case DataType::BIT: - aRet = OUString::number(int(static_cast<bool>(*this))); + aRet = OUString::number(int(getBool())); break; case DataType::BOOLEAN: - aRet = OUString::boolean(static_cast<bool>(*this)); + aRet = OUString::boolean(getBool()); break; case DataType::TINYINT: case DataType::SMALLINT: case DataType::INTEGER: if ( m_bSigned ) - aRet = OUString::number(static_cast<sal_Int32>(*this)); + aRet = OUString::number(getInt32()); else - aRet = OUString::number(static_cast<sal_uInt32>(*this)); + aRet = OUString::number(getUInt32()); break; case DataType::BIGINT: if ( m_bSigned ) - aRet = OUString::number(static_cast<sal_Int64>(*this)); + aRet = OUString::number(getLong()); else - aRet = OUString::number(static_cast<sal_uInt64>(*this)); + aRet = OUString::number(getULong()); break; case DataType::CLOB: { @@ -1907,7 +1907,7 @@ css::util::Date ORowSetValue::getDate() const case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: - aValue = DBTypeConversion::toDate(static_cast<double>(*this)); + aValue = DBTypeConversion::toDate(getDouble()); break; case DataType::DATE: @@ -1927,7 +1927,7 @@ css::util::Date ORowSetValue::getDate() const case DataType::SMALLINT: case DataType::INTEGER: case DataType::BIGINT: - aValue = DBTypeConversion::toDate( double( sal_Int64( *this ) ) ); + aValue = DBTypeConversion::toDate( double( getLong() ) ); break; case DataType::BLOB: @@ -1962,12 +1962,12 @@ css::util::Time ORowSetValue::getTime() const break; case DataType::DECIMAL: case DataType::NUMERIC: - aValue = DBTypeConversion::toTime(static_cast<double>(*this)); + aValue = DBTypeConversion::toTime(getDouble()); break; case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: - aValue = DBTypeConversion::toTime(static_cast<double>(*this)); + aValue = DBTypeConversion::toTime(getDouble()); break; case DataType::TIMESTAMP: { @@ -2006,12 +2006,12 @@ css::util::DateTime ORowSetValue::getDateTime() const break; case DataType::DECIMAL: case DataType::NUMERIC: - aValue = DBTypeConversion::toDateTime(static_cast<double>(*this)); + aValue = DBTypeConversion::toDateTime(getDouble()); break; case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: - aValue = DBTypeConversion::toDateTime(static_cast<double>(*this)); + aValue = DBTypeConversion::toDateTime(getDouble()); break; case DataType::DATE: { diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 8cb7a292c375..0d4394ca6963 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -1792,7 +1792,7 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - _xParams->setString(parameterIndex,_rValue); + _xParams->setString(parameterIndex,_rValue.getString()); break; case DataType::CLOB: { @@ -1816,26 +1816,26 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, break; case DataType::BIGINT: if ( _rValue.isSigned() ) - _xParams->setLong(parameterIndex,_rValue); + _xParams->setLong(parameterIndex,_rValue.getLong()); else - _xParams->setString(parameterIndex,_rValue); + _xParams->setString(parameterIndex,_rValue.getString()); break; case DataType::FLOAT: - _xParams->setFloat(parameterIndex,_rValue); + _xParams->setFloat(parameterIndex,_rValue.getFloat()); break; case DataType::REAL: case DataType::DOUBLE: - _xParams->setDouble(parameterIndex,_rValue); + _xParams->setDouble(parameterIndex,_rValue.getDouble()); break; case DataType::DATE: - _xParams->setDate(parameterIndex,_rValue); + _xParams->setDate(parameterIndex,_rValue.getDate()); break; case DataType::TIME: - _xParams->setTime(parameterIndex,_rValue); + _xParams->setTime(parameterIndex,_rValue.getTime()); break; case DataType::TIMESTAMP: - _xParams->setTimestamp(parameterIndex,_rValue); + _xParams->setTimestamp(parameterIndex,_rValue.getDateTime()); break; case DataType::BINARY: case DataType::VARBINARY: @@ -1868,25 +1868,25 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, break; case DataType::BIT: case DataType::BOOLEAN: - _xParams->setBoolean(parameterIndex,static_cast<bool>(_rValue)); + _xParams->setBoolean(parameterIndex,_rValue.getBool()); break; case DataType::TINYINT: if ( _rValue.isSigned() ) - _xParams->setByte(parameterIndex,_rValue); + _xParams->setByte(parameterIndex,_rValue.getInt8()); else - _xParams->setShort(parameterIndex,_rValue); + _xParams->setShort(parameterIndex,_rValue.getInt16()); break; case DataType::SMALLINT: if ( _rValue.isSigned() ) - _xParams->setShort(parameterIndex,_rValue); + _xParams->setShort(parameterIndex,_rValue.getInt16()); else - _xParams->setInt(parameterIndex,_rValue); + _xParams->setInt(parameterIndex,_rValue.getInt32()); break; case DataType::INTEGER: if ( _rValue.isSigned() ) - _xParams->setInt(parameterIndex,_rValue); + _xParams->setInt(parameterIndex,_rValue.getULong()); else - _xParams->setLong(parameterIndex,_rValue); + _xParams->setLong(parameterIndex,_rValue.getLong()); break; default: { diff --git a/connectivity/source/drivers/component/CDatabaseMetaData.cxx b/connectivity/source/drivers/component/CDatabaseMetaData.cxx index 781e75d5f0b7..b8bbae3d7499 100644 --- a/connectivity/source/drivers/component/CDatabaseMetaData.cxx +++ b/connectivity/source/drivers/component/CDatabaseMetaData.cxx @@ -176,7 +176,7 @@ Reference< XResultSet > SAL_CALL OComponentDatabaseMetaData::getColumns( aRow[13] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); // aRow[14] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); // aRow[15] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - switch(sal_Int32(aRow[5]->getValue())) + switch(aRow[5]->getValue().getInt32()) { case DataType::CHAR: case DataType::VARCHAR: @@ -189,7 +189,7 @@ Reference< XResultSet > SAL_CALL OComponentDatabaseMetaData::getColumns( aRow[16] = new ORowSetValueDecorator(sal_Int32(0)); } aRow[17] = new ORowSetValueDecorator(i); - switch(sal_Int32(aRow[11]->getValue())) + switch(aRow[11]->getValue().getInt32()) { case ColumnValue::NO_NULLS: aRow[18] = new ORowSetValueDecorator(OUString("NO")); diff --git a/connectivity/source/drivers/component/CResultSet.cxx b/connectivity/source/drivers/component/CResultSet.cxx index 55d19f8b2ed8..acf5d6a74df8 100644 --- a/connectivity/source/drivers/component/CResultSet.cxx +++ b/connectivity/source/drivers/component/CResultSet.cxx @@ -77,7 +77,7 @@ Any SAL_CALL OComponentResultSet::getBookmark( ) checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - return makeAny(static_cast<sal_Int32>((*m_aRow)[0]->getValue())); + return makeAny((*m_aRow)[0]->getValue().getInt32()); } sal_Bool SAL_CALL OComponentResultSet::moveToBookmark( const Any& bookmark ) diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx index 2f0dc0a8e85a..bdff15cafa82 100644 --- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -207,7 +207,7 @@ 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(static_cast<sal_Int32>(aRow[5]->getValue())) + switch(aRow[5]->getValue().getInt32()) { case DataType::CHAR: case DataType::VARCHAR: @@ -220,7 +220,7 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( aRow[16] = new ORowSetValueDecorator(sal_Int32(0)); } aRow[17] = new ORowSetValueDecorator(i); - switch(sal_Int32(aRow[11]->getValue())) + switch(aRow[11]->getValue().getInt32()) { case ColumnValue::NO_NULLS: aRow[18] = new ORowSetValueDecorator(OUString("NO")); diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx index 148dc145ad9e..3533477bb0cf 100644 --- a/connectivity/source/drivers/dbase/DResultSet.cxx +++ b/connectivity/source/drivers/dbase/DResultSet.cxx @@ -81,7 +81,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(static_cast<sal_Int32>((*m_aRow)[0]->getValue())); + return makeAny((*m_aRow)[0]->getValue().getInt32()); } 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 c153ebc909eb..90d0b9f21759 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -1843,7 +1843,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo case DataType::TIMESTAMP: { sal_Int32 nJulianDate = 0, nJulianTime = 0; - lcl_CalcJulDate(nJulianDate,nJulianTime, thisColVal); + lcl_CalcJulDate(nJulianDate,nJulianTime, thisColVal.getDateTime()); // Exactly 8 bytes to copy: memcpy(pData,&nJulianDate,4); memcpy(pData+4,&nJulianTime,4); @@ -1855,7 +1855,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo if(thisColVal.getTypeKind() == DataType::DOUBLE) aDate = ::dbtools::DBTypeConversion::toDate(thisColVal.getDouble()); else - aDate = thisColVal; + aDate = thisColVal.getDate(); char s[sizeof("-327686553565535")]; // reserve enough space for hypothetical max length snprintf(s, @@ -1870,7 +1870,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo } break; case DataType::INTEGER: { - sal_Int32 nValue = thisColVal; + sal_Int32 nValue = thisColVal.getInt32(); if (o3tl::make_unsigned(nLen) > sizeof(nValue)) return false; memcpy(pData,&nValue,nLen); @@ -1878,7 +1878,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo break; case DataType::DOUBLE: { - const double d = thisColVal; + const double d = thisColVal.getDouble(); m_xColumns->getByIndex(i) >>= xCol; if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency is treated separately @@ -1904,7 +1904,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo { memset(pData,' ',nLen); // Clear to NULL - const double n = thisColVal; + const double n = thisColVal.getDouble(); // one, because const_cast GetFormatPrecision on SvNumberFormat is not constant, // even though it really could and should be diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index 69648c480e79..422fef11ce20 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -701,7 +701,7 @@ void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const rStream.WriteBytes(&buf[0], sizeof(double)); } else - rStream.WriteDouble( static_cast<double>(aKey.getValue()) ); + rStream.WriteDouble( aKey.getValue().getDouble() ); } else { @@ -710,7 +710,7 @@ void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const memset(&pBuf[0], 0x20, nLen); if (!aKey.getValue().isNull()) { - OUString sValue = aKey.getValue(); + OUString sValue = aKey.getValue().getString(); OString aText(OUStringToOString(sValue, rIndex.m_pTable->getConnection()->getTextEncoding())); strncpy(reinterpret_cast<char *>(&pBuf[0]), aText.getStr(), std::min<size_t>(nLen, aText.getLength())); @@ -764,8 +764,8 @@ int ONDXKey::Compare(const ONDXKey& rKey) const } else { - double m = getValue(); - double n = rKey.getValue(); + double m = getValue().getDouble(); + double n = rKey.getValue().getDouble(); nRes = (m > n) ? 1 : ( m < n) ? -1 : 0; } diff --git a/connectivity/source/drivers/file/FDateFunctions.cxx b/connectivity/source/drivers/file/FDateFunctions.cxx index d5b7c48c0dcc..1be992d4b672 100644 --- a/connectivity/source/drivers/file/FDateFunctions.cxx +++ b/connectivity/source/drivers/file/FDateFunctions.cxx @@ -32,7 +32,7 @@ ORowSetValue OOp_DayOfWeek::operate(const ORowSetValue& lhs) const return lhs; sal_Int32 nRet = 0; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); Date aDate(aD.Day, aD.Month, aD.Year); DayOfWeek eDayOfWeek = aDate.GetDayOfWeek(); switch (eDayOfWeek) @@ -69,7 +69,7 @@ ORowSetValue OOp_DayOfMonth::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); return static_cast<sal_Int16>(aD.Day); } @@ -78,7 +78,7 @@ ORowSetValue OOp_DayOfYear::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); Date aDate(aD.Day, aD.Month, aD.Year); return static_cast<sal_Int16>(aDate.GetDayOfYear()); } @@ -88,7 +88,7 @@ ORowSetValue OOp_Month::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); return static_cast<sal_Int16>(aD.Month); } @@ -98,7 +98,7 @@ ORowSetValue OOp_DayName::operate(const ORowSetValue& lhs) const return lhs; OUString sRet; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); Date aDate(aD.Day, aD.Month, aD.Year); DayOfWeek eDayOfWeek = aDate.GetDayOfWeek(); switch (eDayOfWeek) @@ -136,7 +136,7 @@ ORowSetValue OOp_MonthName::operate(const ORowSetValue& lhs) const return lhs; OUString sRet; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); switch (aD.Month) { case 1: @@ -185,7 +185,7 @@ ORowSetValue OOp_Quarter::operate(const ORowSetValue& lhs) const return lhs; sal_Int32 nRet = 1; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); if (aD.Month >= 4 && aD.Month < 7) nRet = 2; else if (aD.Month >= 7 && aD.Month < 10) @@ -202,12 +202,12 @@ ORowSetValue OOp_Week::operate(const std::vector<ORowSetValue>& lhs) const size_t nSize = lhs.size(); - css::util::Date aD = lhs[nSize - 1]; + css::util::Date aD = lhs[nSize - 1].getDate(); Date aDate(aD.Day, aD.Month, aD.Year); sal_Int16 nStartDay = SUNDAY; if (nSize == 2 && !lhs[0].isNull()) - nStartDay = lhs[0]; + nStartDay = lhs[0].getInt16(); return static_cast<sal_Int16>(aDate.GetWeekOfYear(static_cast<DayOfWeek>(nStartDay))); } @@ -217,7 +217,7 @@ ORowSetValue OOp_Year::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Date aD = lhs; + css::util::Date aD = lhs.getDate(); return aD.Year; } @@ -226,7 +226,7 @@ ORowSetValue OOp_Hour::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Time aT = lhs; + css::util::Time aT = lhs.getTime(); return static_cast<sal_Int16>(aT.Hours); } @@ -235,7 +235,7 @@ ORowSetValue OOp_Minute::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Time aT = lhs; + css::util::Time aT = lhs.getTime(); return static_cast<sal_Int16>(aT.Minutes); } @@ -244,7 +244,7 @@ ORowSetValue OOp_Second::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - css::util::Time aT = lhs; + css::util::Time aT = lhs.getTime(); return static_cast<sal_Int16>(aT.Seconds); } diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx index 7c26081da12e..920bb38859f1 100644 --- a/connectivity/source/drivers/file/FNoException.cxx +++ b/connectivity/source/drivers/file/FNoException.cxx @@ -85,7 +85,7 @@ void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,std::vector< OS std::unique_ptr<OKeyValue> OResultSet::GetOrderbyKeyValue(OValueRefRow const & _rRow) { - sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((*_rRow)[0]->getValue())); + sal_uInt32 nBookmarkValue = std::abs((*_rRow)[0]->getValue().getInt32()); std::unique_ptr<OKeyValue> pKeyValue = OKeyValue::createKeyValue(nBookmarkValue); diff --git a/connectivity/source/drivers/file/FNumericFunctions.cxx b/connectivity/source/drivers/file/FNumericFunctions.cxx index a6784a55c140..7de058dee06c 100644 --- a/connectivity/source/drivers/file/FNumericFunctions.cxx +++ b/connectivity/source/drivers/file/FNumericFunctions.cxx @@ -32,7 +32,7 @@ ORowSetValue OOp_Abs::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - double nVal(lhs); + double nVal = lhs.getDouble(); if ( nVal < 0 ) nVal *= -1.0; return fabs(nVal); @@ -44,7 +44,7 @@ ORowSetValue OOp_Sign::operate(const ORowSetValue& lhs) const return lhs; sal_Int32 nRet = 0; - double nVal(lhs); + double nVal = lhs.getDouble(); if ( nVal < 0 ) nRet = -1; else if ( nVal > 0 ) @@ -58,7 +58,7 @@ ORowSetValue OOp_Mod::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) c if ( lhs.isNull() || rhs.isNull() ) return ORowSetValue(); - return fmod(static_cast<double>(lhs),static_cast<double>(rhs)); + return fmod(lhs.getDouble(), rhs.getDouble()); } 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(static_cast<double>(lhs)); + return floor(lhs.getDouble()); } ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const @@ -74,7 +74,7 @@ ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - double nVal(lhs); + double nVal = lhs.getDouble(); return ceil(nVal); } @@ -84,11 +84,11 @@ ORowSetValue OOp_Round::operate(const std::vector<ORowSetValue>& lhs) const return ORowSetValue(); size_t nSize = lhs.size(); - double nVal = lhs[nSize-1]; + double nVal = lhs[nSize-1].getDouble(); sal_Int32 nDec = 0; if ( nSize == 2 && !lhs[0].isNull() ) - nDec = lhs[0]; + nDec = lhs[0].getDouble(); return ::rtl::math::round(nVal,nDec); } @@ -97,16 +97,16 @@ ORowSetValue OOp_Exp::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - double nVal(lhs); + double nVal = lhs.getDouble(); return exp(nVal); } ORowSetValue OOp_Ln::operate(const ORowSetValue& lhs) const { - if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 ) + if ( lhs.isNull() || lhs.getDouble() < 0.0 ) return lhs; - double nVal(lhs); + double nVal = lhs.getDouble(); nVal = log(nVal); if ( std::isnan(nVal) ) return ORowSetValue(); @@ -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( static_cast<double>(lhs[nSize-1]) ); + double nVal = log( lhs[nSize-1].getDouble() ); if ( nSize == 2 && !lhs[0].isNull() ) - nVal /= log(static_cast<double>(lhs[0])); + nVal /= log(lhs[0].getDouble()); if ( std::isnan(nVal) ) return ORowSetValue(); @@ -131,10 +131,10 @@ ORowSetValue OOp_Log::operate(const std::vector<ORowSetValue>& lhs) const ORowSetValue OOp_Log10::operate(const ORowSetValue& lhs) const { - if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 ) + if ( lhs.isNull() || lhs.getDouble() < 0.0 ) return lhs; - double nVal = log(static_cast<double>(lhs)); + double nVal = log(lhs.getDouble()); if ( std::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(static_cast<double>(lhs),static_cast<double>(rhs)); + return pow(lhs.getDouble(), rhs.getDouble()); } 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(static_cast<double>(lhs)); + double nVal = sqrt(lhs.getDouble()); if ( std::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(static_cast<double>(lhs)); + return cos(lhs.getDouble()); } 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(static_cast<double>(lhs)); + return sin(lhs.getDouble()); } 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(static_cast<double>(lhs)); + return tan(lhs.getDouble()); } 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(static_cast<double>(lhs)); + return acos(lhs.getDouble()); } 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(static_cast<double>(lhs)); + return asin(lhs.getDouble()); } 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(static_cast<double>(lhs)); + return atan(lhs.getDouble()); } 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(static_cast<double>(lhs),static_cast<double>(rhs)); + return atan2(lhs.getDouble(), rhs.getDouble()); } ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const @@ -226,7 +226,7 @@ ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - double nLhs = lhs; + double nLhs = lhs.getDouble(); return nLhs*180*(1.0/fPi); } @@ -235,7 +235,7 @@ ORowSetValue OOp_Radians::operate(const ORowSetValue& lhs) const if ( lhs.isNull() ) return lhs; - double nLhs = lhs; + double nLhs = lhs.getDouble(); return nLhs*fPi*(1.0/180.0); } diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 930c5c2f7b98..fdf3a4e47d84 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -217,43 +217,43 @@ Reference< css::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_ sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) { - return bool(getValue(columnIndex)); + return getValue(columnIndex).getBool(); } sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getInt8(); } Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getSequence(); } css::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getDate(); } double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getDouble(); } float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getFloat(); } sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getInt32(); } @@ -264,13 +264,13 @@ sal_Int32 SAL_CALL OResultSet::getRow( ) OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row"); - return m_aSkipDeletedSet.getMappedPosition((*m_aRow)[0]->getValue()); + return m_aSkipDeletedSet.getMappedPosition((*m_aRow)[0]->getValue().getInt32()); } sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getLong(); } @@ -316,22 +316,22 @@ Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< css: sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getInt16(); } OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getString(); } css::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getTime(); } css::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) { - return getValue(columnIndex); + return getValue(columnIndex).getDateTime(); } @@ -518,12 +518,12 @@ void SAL_CALL OResultSet::insertRow( ) m_bRowInserted = m_pTable->InsertRow(*m_aInsertRow, m_xColsIdx); if(m_bRowInserted && m_pFileSet.is()) { - sal_Int32 nPos = (*m_aInsertRow)[0]->getValue(); + sal_Int32 nPos = (*m_aInsertRow)[0]->getValue().getInt32(); m_pFileSet->push_back(nPos); *(*m_aInsertRow)[0] = sal_Int32(m_pFileSet->size()); clearInsertRow(); - m_aSkipDeletedSet.insertNewPosition((*m_aRow)[0]->getValue()); + m_aSkipDeletedSet.insertNewPosition((*m_aRow)[0]->getValue().getInt32()); } } @@ -536,7 +536,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)[0] = static_cast<sal_Int32>((*m_aRow)[0]->getValue()); + *(*m_aInsertRow)[0] = (*m_aRow)[0]->getValue().getInt32(); clearInsertRow(); } @@ -553,7 +553,7 @@ void SAL_CALL OResultSet::deleteRow() if(m_aRow->isDeleted()) lcl_throwError(STR_ROW_ALREADY_DELETED,*this); - sal_Int32 nPos = static_cast<sal_Int32>((*m_aRow)[0]->getValue()); + sal_Int32 nPos = (*m_aRow)[0]->getValue().getInt32(); m_bRowDeleted = m_pTable->DeleteRow(*m_xColumns); if(m_bRowDeleted && m_pFileSet.is()) { @@ -837,7 +837,7 @@ again: } else if (m_pFileSet.is()) { - sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((*m_aEvaluateRow)[0]->getValue())); + sal_uInt32 nBookmarkValue = std::abs((*m_aEvaluateRow)[0]->getValue().getInt32()); m_pFileSet->push_back(nBookmarkValue); } } @@ -1143,7 +1143,7 @@ void OResultSet::sortRows() (*m_aSelectRow)[0]->setValue( (*m_aRow)[0]->getValue() ); if ( m_pSQLAnalyzer->hasFunctions() ) m_pSQLAnalyzer->setSelectionEvaluationResult( m_aSelectRow, m_aColMapping ); - const sal_Int32 nBookmark = (*m_aRow->begin())->getValue(); + const sal_Int32 nBookmark = (*m_aRow->begin())->getValue().getInt32(); ExecuteRow( IResultSetHelper::BOOKMARK, nBookmark, true, false ); } @@ -1571,7 +1571,7 @@ bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nO sal_Int32 OResultSet::getDriverPos() const { - return (*m_aRow)[0]->getValue(); + return (*m_aRow)[0]->getValue().getInt32(); } bool OResultSet::isRowDeleted() const diff --git a/connectivity/source/drivers/file/FStringFunctions.cxx b/connectivity/source/drivers/file/FStringFunctions.cxx index 8bac436e07be..619c1a128dbf 100644 --- a/connectivity/source/drivers/file/FStringFunctions.cxx +++ b/connectivity/source/drivers/file/FStringFunctions.cxx @@ -68,7 +68,7 @@ ORowSetValue OOp_Char::operate(const std::vector<ORowSetValue>& lhs) const { if (!aIter->isNull()) { - char c = static_cast<char>(static_cast<sal_Int32>(*aIter)); + char c = static_cast<char>(aIter->getInt32()); sRet.appendAscii(&c, 1); } @@ -90,7 +90,7 @@ ORowSetValue OOp_Concat::operate(const std::vector<ORowSetValue>& lhs) const if (aIter->isNull()) return ORowSetValue(); - sRet.append(aIter->operator OUString()); + sRet.append(aIter->getString()); } return sRet.makeStringAndClear(); @@ -108,7 +108,7 @@ ORowSetValue OOp_Locate::operate(const std::vector<ORowSetValue>& lhs) const else if (lhs.size() != 3) return ORowSetValue(); - return lhs[1].getString().indexOf(lhs[2].getString(), lhs[0]) + 1; + return lhs[1].getString().indexOf(lhs[2].getString(), lhs[0].getInt32()) + 1; } ORowSetValue OOp_SubString::operate(const std::vector<ORowSetValue>& lhs) const @@ -117,13 +117,13 @@ ORowSetValue OOp_SubString::operate(const std::vector<ORowSetValue>& lhs) const [](const ORowSetValue& rValue) { return rValue.isNull(); })) return ORowSetValue(); - if (lhs.size() == 2 && static_cast<sal_Int32>(lhs[0]) >= sal_Int32(0)) - return lhs[1].getString().copy(static_cast<sal_Int32>(lhs[0]) - 1); + if (lhs.size() == 2 && lhs[0].getInt32() >= sal_Int32(0)) + return lhs[1].getString().copy(lhs[0].getInt32() - 1); - else if (lhs.size() != 3 || static_cast<sal_Int32>(lhs[1]) < sal_Int32(0)) + else if (lhs.size() != 3 || lhs[1].getInt32() < sal_Int32(0)) return ORowSetValue(); - return lhs[2].getString().copy(static_cast<sal_Int32>(lhs[1]) - 1, lhs[0]); + return lhs[2].getString().copy(lhs[1].getInt32() - 1, lhs[0].getInt32()); } ORowSetValue OOp_LTrim::operate(const ORowSetValue& lhs) const @@ -131,7 +131,7 @@ ORowSetValue OOp_LTrim::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - OUString sRet = lhs; + OUString sRet = lhs.getString(); OUString sNew = sRet.trim(); return sRet.copy(sRet.indexOf(sNew)); } @@ -141,7 +141,7 @@ ORowSetValue OOp_RTrim::operate(const ORowSetValue& lhs) const if (lhs.isNull()) return lhs; - OUString sRet = lhs; + OUString sRet = lhs.getString(); OUString sNew = sRet.trim(); return sRet.copy(0, sRet.lastIndexOf(sNew[sNew.getLength() - 1]) + 1); } @@ -153,7 +153,7 @@ ORowSetValue OOp_Space::operate(const ORowSetValue& lhs) const const char c = ' '; OUStringBuffer sRet; - sal_Int32 nCount = lhs; + sal_Int32 nCount = lhs.getInt32(); for (sal_Int32 i = 0; i < nCount; ++i) { sRet.appendAscii(&c, 1); @@ -166,9 +166,9 @@ ORowSetValue OOp_Replace::operate(const std::vector<ORowSetValue>& lhs) const if (lhs.size() != 3) return ORowSetValue(); - OUString sStr = lhs[2]; - OUString sFrom = lhs[1]; - OUString sTo = lhs[0]; + OUString sStr = lhs[2].getString(); + OUString sFrom = lhs[1].getString(); + OUString sTo = lhs[0].getString(); sal_Int32 nIndexOf = sStr.indexOf(sFrom); while (nIndexOf != -1) { @@ -185,10 +185,10 @@ ORowSetValue OOp_Repeat::operate(const ORowSetValue& lhs, const ORowSetValue& rh return lhs; OUStringBuffer sRet; - sal_Int32 nCount = rhs; + sal_Int32 nCount = rhs.getInt32(); for (sal_Int32 i = 0; i < nCount; ++i) { - sRet.append(lhs.operator OUString()); + sRet.append(lhs.getString()); } return sRet.makeStringAndClear(); } @@ -198,12 +198,12 @@ ORowSetValue OOp_Insert::operate(const std::vector<ORowSetValue>& lhs) const if (lhs.size() != 4) return ORowSetValue(); - OUString sStr = lhs[3]; + OUString sStr = lhs[3].getString(); - sal_Int32 nStart = static_cast<sal_Int32>(lhs[2]); + sal_Int32 nStart = lhs[2].getInt32(); if (nStart < 1) nStart = 1; - return sStr.replaceAt(nStart - 1, static_cast<sal_Int32>(lhs[1]), lhs[0]); + return sStr.replaceAt(nStart - 1, lhs[1].getInt32(), lhs[0].getString()); } ORowSetValue OOp_Left::operate(const ORowSetValue& lhs, const ORowSetValue& rhs) const @@ -211,8 +211,8 @@ ORowSetValue OOp_Left::operate(const ORowSetValue& lhs, const ORowSetValue& rhs) if (lhs.isNull() || rhs.isNull()) return lhs; - OUString sRet = lhs; - sal_Int32 nCount = rhs; + OUString sRet = lhs.getString(); + sal_Int32 nCount = rhs.getInt32(); if (nCount < 0) return ORowSetValue(); return sRet.copy(0, nCount); @@ -223,8 +223,8 @@ ORowSetValue OOp_Right::operate(const ORowSetValue& lhs, const ORowSetValue& rhs if (lhs.isNull() || rhs.isNull()) return lhs; - sal_Int32 nCount = rhs; - OUString sRet = lhs; + sal_Int32 nCount = rhs.getInt32(); + OUString sRet = lhs.getString(); if (nCount < 0 || nCount >= sRet.getLength()) return ORowSetValue(); diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx index 6e1a0cdf54e5..14fb8f41d6f8 100644 --- a/connectivity/source/drivers/file/fcode.cxx +++ b/connectivity/source/drivers/file/fcode.cxx @@ -231,7 +231,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const case DataType::VARCHAR: case DataType::LONGVARCHAR: { - OUString sLH = aLH, sRH = aRH; + OUString sLH = aLH.getString(), sRH = aRH.getString(); sal_Int32 nRes = sLH.compareToIgnoreAsciiCase(sRH); switch(aPredicateType) { @@ -256,7 +256,7 @@ bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const case DataType::DATE: case DataType::TIME: { - double n = aLH ,m = aRH; + double n = aLH.getDouble(), m = aRH.getDouble(); switch (aPredicateType) { @@ -285,7 +285,7 @@ void ONumOperator::Exec(OCodeStack& rCodeStack) OOperand *pLeft = rCodeStack.top(); rCodeStack.pop(); - rCodeStack.push(new OOperandResultNUM(operate(pLeft->getValue(), pRight->getValue()))); + rCodeStack.push(new OOperandResultNUM(operate(pLeft->getValue().getDouble(), pRight->getValue().getDouble()))); if( typeid(OOperandResult) == typeid(*pLeft)) delete pLeft; if( typeid(OOperandResult) == typeid(*pRight)) diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index be01a70ed360..e725b1870865 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -353,29 +353,29 @@ void OPredicateCompiler::execute_BETWEEN(OSQLParseNode const * pPredicateNode) break; case DataType::DECIMAL: case DataType::NUMERIC: - pOb1->setValue(static_cast<double>(pOb1->getValue())); - pOb2->setValue(static_cast<double>(pOb2->getValue())); + pOb1->setValue(pOb1->getValue().getDouble()); + pOb2->setValue(pOb2->getValue().getDouble()); break; case DataType::FLOAT: - pOb1->setValue(static_cast<float>(pOb1->getValue())); - pOb2->setValue(static_cast<float>(pOb2->getValue())); + pOb1->setValue(pOb1->getValue().getFloat()); + pOb2->setValue(pOb2->getValue().getFloat()); break; case DataType::DOUBLE: case DataType::REAL: - pOb1->setValue(static_cast<double>(pOb1->getValue())); - pOb2->setValue(static_cast<double>(pOb2->getValue())); + pOb1->setValue(pOb1->getValue().getDouble()); + pOb2->setValue(pOb2->getValue().getDouble()); break; case DataType::DATE: - pOb1->setValue(static_cast<util::Date>(pOb1->getValue())); - pOb2->setValue(static_cast<util::Date>(pOb2->getValue())); + pOb1->setValue(pOb1->getValue().getDate()); + pOb2->setValue(pOb2->getValue().getDate()); break; case DataType::TIME: - pOb1->setValue(static_cast<util::Time>(pOb1->getValue())); - pOb2->setValue(static_cast<util::Time>(pOb2->getValue())); + pOb1->setValue(pOb1->getValue().getTime()); + pOb2->setValue(pOb2->getValue().getTime()); break; case DataType::TIMESTAMP: - pOb1->setValue(static_cast<util::DateTime>(pOb1->getValue())); - pOb2->setValue(static_cast<util::DateTime>(pOb2->getValue())); + pOb1->setValue(pOb1->getValue().getDateTime()); + pOb2->setValue(pOb2->getValue().getDateTime()); break; } } diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx index 892e510138a3..aa13dbd0b96c 100644 --- a/connectivity/source/drivers/firebird/ResultSet.cxx +++ b/connectivity/source/drivers/firebird/ResultSet.cxx @@ -430,7 +430,23 @@ T OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT nType) if ((m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1) == nType) return *reinterpret_cast<T*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata); else - return retrieveValue< ORowSetValue >(nColumnIndex, 0); + { + ORowSetValue row = retrieveValue< ORowSetValue >(nColumnIndex, 0); + if constexpr ( std::is_same_v<sal_Int64, T> ) + return row.getLong(); + else if constexpr ( std::is_same_v<sal_Int32, T> ) + return row.getInt32(); + else if constexpr ( std::is_same_v<sal_Int16, T> ) + return row.getInt16(); + else if constexpr ( std::is_same_v<float, T> ) + return row.getFloat(); + else if constexpr ( std::is_same_v<double, T> ) + return row.getDouble(); + else if constexpr ( std::is_same_v<bool, T> ) + return row.getBool(); + else + return row; + } } template <> @@ -511,7 +527,7 @@ Date OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n } else { - return retrieveValue< ORowSetValue >(nColumnIndex, 0); + return retrieveValue< ORowSetValue >(nColumnIndex, 0).getDate(); } } @@ -534,7 +550,7 @@ Time OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n } else { - return retrieveValue< ORowSetValue >(nColumnIndex, 0); + return retrieveValue< ORowSetValue >(nColumnIndex, 0).getTime(); } } @@ -560,7 +576,7 @@ DateTime OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT } else { - return retrieveValue< ORowSetValue >(nColumnIndex, 0); + return retrieveValue< ORowSetValue >(nColumnIndex, 0).getDateTime(); } } @@ -615,7 +631,7 @@ OUString OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT } else { - return retrieveValue< ORowSetValue >(nColumnIndex, 0); + return retrieveValue< ORowSetValue >(nColumnIndex, 0).getString(); } } @@ -663,7 +679,7 @@ sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 nColumnIndex) sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 nColumnIndex) { // Not a native firebird type hence we always have to convert. - return safelyRetrieveValue< ORowSetValue >(nColumnIndex); + return safelyRetrieveValue< ORowSetValue >(nColumnIndex).getInt8(); } Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32 nColumnIndex) diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx index 0580f0381a85..7150973069d9 100644 --- a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx +++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx @@ -198,7 +198,7 @@ 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(static_cast<sal_Int32>(aRow[5]->getValue())) + switch(aRow[5]->getValue().getInt32()) { case DataType::CHAR: case DataType::VARCHAR: @@ -211,7 +211,7 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns( aRow[16] = new ORowSetValueDecorator(sal_Int32(0)); } aRow[17] = new ORowSetValueDecorator(i); - switch(sal_Int32(aRow[11]->getValue())) + switch(aRow[11]->getValue().getInt32()) { case ColumnValue::NO_NULLS: aRow[18] = new ORowSetValueDecorator(OUString("NO")); diff --git a/connectivity/source/drivers/flat/EResultSet.cxx b/connectivity/source/drivers/flat/EResultSet.cxx index baad465e3f2e..2e8c2a391d97 100644 --- a/connectivity/source/drivers/flat/EResultSet.cxx +++ b/connectivity/source/drivers/flat/EResultSet.cxx @@ -96,7 +96,7 @@ Any SAL_CALL OFlatResultSet::getBookmark( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - return makeAny(static_cast<sal_Int32>((*m_aRow)[0]->getValue())); + return makeAny((*m_aRow)[0]->getValue().getInt32()); } sal_Bool SAL_CALL OFlatResultSet::moveToBookmark( const Any& bookmark ) diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index f03056afd121..33aadcbca840 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -354,7 +354,7 @@ void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameter { ORowSetValue aValue; aValue.fill(x); - const OUString sValue = aValue; + const OUString sValue = aValue.getString(); if ( !sValue.isEmpty() ) pBigDecimal.reset(new java_math_BigDecimal(sValue)); else diff --git a/connectivity/source/drivers/macab/MacabPreparedStatement.cxx b/connectivity/source/drivers/macab/MacabPreparedStatement.cxx index 22fd7b499a82..6d72345b6021 100644 --- a/connectivity/source/drivers/macab/MacabPreparedStatement.cxx +++ b/connectivity/source/drivers/macab/MacabPreparedStatement.cxx @@ -78,7 +78,7 @@ void MacabPreparedStatement::getNextParameter(OUString &rParameter) const ::dbtools::throwGenericSQLException(sError,*const_cast<MacabPreparedStatement *>(this)); } - rParameter = (*m_aParameterRow)[m_nParameterIndex]; + rParameter = (*m_aParameterRow)[m_nParameterIndex].getString(); m_nParameterIndex++; } diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index 7c88cd1a347c..8360700434fc 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -248,7 +248,25 @@ template <typename T> T OPreparedResultSet::retrieveValue(sal_Int32 nColumnIndex if (getTypeFromMysqlType(m_aFields[nColumnIndex - 1].type) == std::type_index(typeid(T))) return *static_cast<T*>(m_aData[nColumnIndex - 1].buffer); else - return getRowSetValue(nColumnIndex); + { + auto const& row = getRowSetValue(nColumnIndex); + if constexpr (std::is_same_v<sal_Int64, T>) + return row.getLong(); + else if constexpr (std::is_same_v<sal_Int32, T>) + return row.getInt32(); + else if constexpr (std::is_same_v<sal_Int16, T>) + return row.getInt16(); + else if constexpr (std::is_same_v<sal_Int8, T>) + return row.getInt8(); + else if constexpr (std::is_same_v<double, T>) + return row.getDouble(); + else if constexpr (std::is_same_v<float, T>) + return row.getFloat(); + else if constexpr (std::is_same_v<bool, T>) + return row.getBool(); + else + return row; + } } template <> uno::Sequence<sal_Int8> OPreparedResultSet::retrieveValue(sal_Int32 column) @@ -261,7 +279,7 @@ template <> uno::Sequence<sal_Int8> OPreparedResultSet::retrieveValue(sal_Int32 template <> Date OPreparedResultSet::retrieveValue(sal_Int32 column) { if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(Date))) - return getRowSetValue(column); + return getRowSetValue(column).getDate(); const MYSQL_TIME* pTime = static_cast<MYSQL_TIME*>(m_aData[column - 1].buffer); Date d; @@ -274,7 +292,7 @@ template <> Date OPreparedResultSet::retrieveValue(sal_Int32 column) template <> Time OPreparedResultSet::retrieveValue(sal_Int32 column) { if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(Time))) - return getRowSetValue(column); + return getRowSetValue(column).getTime(); const MYSQL_TIME* pTime = static_cast<MYSQL_TIME*>(m_aData[column - 1].buffer); Time t; @@ -287,7 +305,7 @@ template <> Time OPreparedResultSet::retrieveValue(sal_Int32 column) template <> DateTime OPreparedResultSet::retrieveValue(sal_Int32 column) { if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(DateTime))) - return getRowSetValue(column); + return getRowSetValue(column).getDateTime(); const MYSQL_TIME* pTime = static_cast<MYSQL_TIME*>(m_aData[column - 1].buffer); DateTime t; @@ -306,7 +324,7 @@ template <> OUString OPreparedResultSet::retrieveValue(sal_Int32 column) // BLOB can be simply read out as string if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(OUString)) && m_aFields[column - 1].type != MYSQL_TYPE_BLOB) - return getRowSetValue(column); + return getRowSetValue(column).getString(); const char* sStr = static_cast<const char*>(m_aData[column - 1].buffer); return OUString(sStr, *m_aData[column - 1].length, m_encoding); diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index aa01e2ea936a..507a52d872a2 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -491,7 +491,7 @@ void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x } catch(SQLException&) { - setString(parameterIndex, ORowSetValue(x)); + setString(parameterIndex, ORowSetValue(x).getString()); } } @@ -584,8 +584,7 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c { ORowSetValue aValue; aValue.fill(x); - // TODO: make sure that this calls the string overload - setParameter(parameterIndex, sqlType, scale, aValue); + setParameter(parameterIndex, sqlType, scale, aValue.getString()); } else setNull(parameterIndex,sqlType); diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 9e6bb3d91887..b38d81b3a4eb 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -443,8 +443,33 @@ template < typename T > T OResultSet::getValue( sal_Int32 columnIndex ) checkDisposed(OResultSet_BASE::rBHelper.bDisposed); fillColumn(columnIndex); m_bWasNull = m_aRow[columnIndex].isNull(); - return m_aRow[columnIndex]; + auto const & row = m_aRow[columnIndex]; + if constexpr ( std::is_same_v<css::util::Time, T> ) + return row.getTime(); + else if constexpr ( std::is_same_v<css::util::DateTime, T> ) + return row.getDateTime(); + else if constexpr ( std::is_same_v<css::util::Date, T> ) + return row.getDate(); + else if constexpr ( std::is_same_v<OUString, T> ) + return row.getString(); + else if constexpr ( std::is_same_v<sal_Int64, T> ) + return row.getLong(); + else if constexpr ( std::is_same_v<sal_Int32, T> ) + return row.getInt32(); + else if constexpr ( std::is_same_v<sal_Int16, T> ) + return row.getInt16(); + else if constexpr ( std::is_same_v<sal_Int8, T> ) + return row.getInt8(); + else if constexpr ( std::is_same_v<float, T> ) + return row.getFloat(); + else if constexpr ( std::is_same_v<double, T> ) + return row.getDouble(); + else if constexpr ( std::is_same_v<bool, T> ) + return row.getBool(); + else + return row; } + sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) { return getValue<bool>( columnIndex ); @@ -469,7 +494,7 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: - nRet = m_aRow[columnIndex]; + nRet = m_aRow[columnIndex].getSequence(); break; default: { @@ -1764,7 +1789,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: - aSeq = m_aRow[nColumnIndex]; + aSeq = m_aRow[nColumnIndex].getSequence(); N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength()); break; case SQL_WLONGVARCHAR: diff --git a/connectivity/source/inc/TKeyValue.hxx b/connectivity/source/inc/TKeyValue.hxx index baed7f75c23b..49d41e0144f2 100644 --- a/connectivity/source/inc/TKeyValue.hxx +++ b/connectivity/source/inc/TKeyValue.hxx @@ -44,12 +44,12 @@ namespace connectivity OUString getKeyString(std::vector<ORowSetValueDecoratorRef>::size_type i) const { OSL_ENSURE(m_aKeys.size() > i,"Wrong index for KEyValue"); - return m_aKeys[i]->getValue(); + return m_aKeys[i]->getValue().getString(); } double getKeyDouble(std::vector<ORowSetValueDecoratorRef>::size_type i) const { OSL_ENSURE(m_aKeys.size() > i,"Wrong index for KEyValue"); - return m_aKeys[i]->getValue(); + return m_aKeys[i]->getValue().getDouble(); } sal_Int32 getValue() const { return m_nValue; } |