summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/file/FResultSet.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/file/FResultSet.cxx')
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx86
1 files changed, 34 insertions, 52 deletions
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index d7f3d6bd2090..60fd9b6d4df2 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -29,6 +29,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <connectivity/dbtools.hxx>
#include <cppuhelper/propshlp.hxx>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <iterator>
#include <com/sun/star/sdbc/ResultSetType.hpp>
@@ -41,6 +42,7 @@
#include <comphelper/types.hxx>
#include <resource/sharedresources.hxx>
#include <strings.hrc>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::comphelper;
using namespace connectivity;
@@ -56,7 +58,7 @@ using namespace com::sun::star::container;
namespace
{
- void lcl_throwError(const char* pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext)
+ void lcl_throwError(TranslateId pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext)
{
::connectivity::SharedResources aResources;
const OUString sMessage = aResources.getResourceString(pErrorId);
@@ -64,7 +66,7 @@ namespace
}
}
-IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet");
+IMPLEMENT_SERVICE_INFO(OResultSet,u"com.sun.star.sdbcx.drivers.file.ResultSet"_ustr,u"com.sun.star.sdbc.ResultSet"_ustr);
OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex)
,::comphelper::OPropertyContainer(OResultSet_BASE::rBHelper)
@@ -132,9 +134,8 @@ void OResultSet::disposing()
m_xColumns = nullptr;
m_xColsIdx.clear();
- Reference<XComponent> xComp = m_pTable.get();
- if ( xComp.is() )
- xComp->removeEventListener(this);
+ if ( m_pTable.is() )
+ m_pTable->removeEventListener(this);
m_pTable.clear();
m_pFileSet = nullptr;
@@ -181,8 +182,6 @@ sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName )
}
::dbtools::throwInvalidColumnException( columnName, *this );
- assert(false);
- return 0; // Never reached
}
const ORowSetValue& OResultSet::getValue(sal_Int32 columnIndex)
@@ -217,43 +216,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 +263,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 +315,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 +517,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 +535,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 +552,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())
{
@@ -652,7 +651,7 @@ void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x )
void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ )
{
- ::dbtools::throwFeatureNotImplementedSQLException( "XRowUpdate::updateLong", *this );
+ ::dbtools::throwFeatureNotImplementedSQLException( u"XRowUpdate::updateLong"_ustr, *this );
}
void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x )
@@ -837,7 +836,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);
}
}
@@ -921,7 +920,7 @@ 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 >= static_cast<sal_Int32>(m_pFileSet->size()) )) // && m_pFileSet->IsFrozen()
+ if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && o3tl::make_unsigned(m_nRowPos) >= m_pFileSet->size() )) // && m_pFileSet->IsFrozen()
{
goto Error;
}
@@ -1136,14 +1135,14 @@ void OResultSet::sortRows()
++i;
}
- m_pSortIndex.reset(new OSortIndex(eKeyType,m_aOrderbyAscending));
+ m_pSortIndex.reset(new OSortIndex(std::move(eKeyType), std::vector(m_aOrderbyAscending)));
while ( ExecuteRow( IResultSetHelper::NEXT, 1, false ) )
{
(*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 );
}
@@ -1380,22 +1379,6 @@ void OResultSet::OpenImpl()
m_nFilePos = 0;
}
-Sequence< sal_Int8 > OResultSet::getUnoTunnelId()
-{
- static ::cppu::OImplementationId implId;
-
- return implId.getImplementationId();
-}
-
-// css::lang::XUnoTunnel
-
-sal_Int64 OResultSet::getSomething( const Sequence< sal_Int8 > & rId )
-{
- return isUnoTunnelId<OResultSet>(rId)
- ? reinterpret_cast< sal_Int64 >( this )
- : 0;
-}
-
void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
const OValueRefRow& _rSelectRow,
const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
@@ -1468,7 +1451,7 @@ void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
}
catch (Exception&)
{
- SAL_WARN( "connectivity.drivers","OResultSet::setBoundedColumns: caught an Exception!");
+ TOOLS_WARN_EXCEPTION( "connectivity.drivers","");
}
}
// in this case we got more select columns as columns exist in the table
@@ -1513,12 +1496,12 @@ void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
}
}
-void SAL_CALL OResultSet::acquire() throw()
+void SAL_CALL OResultSet::acquire() noexcept
{
OResultSet_BASE::acquire();
}
-void SAL_CALL OResultSet::release() throw()
+void SAL_CALL OResultSet::release() noexcept
{
OResultSet_BASE::release();
}
@@ -1530,8 +1513,7 @@ Reference< css::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInf
void OResultSet::doTableSpecials(const OSQLTable& _xTable)
{
- Reference<css::lang::XUnoTunnel> xTunnel(_xTable, UNO_QUERY_THROW);
- m_pTable = reinterpret_cast< OFileTable* >(xTunnel->getSomething(OFileTable::getUnoTunnelId()));
+ m_pTable = dynamic_cast<OFileTable*>(_xTable.get());
assert(m_pTable.is());
}
@@ -1574,7 +1556,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
@@ -1584,7 +1566,7 @@ bool OResultSet::isRowDeleted() const
void SAL_CALL OResultSet::disposing( const EventObject& Source )
{
- Reference<XPropertySet> xProp = m_pTable.get();
+ Reference<XPropertySet> xProp = m_pTable;
if(m_pTable.is() && Source.Source == xProp)
{
m_pTable.clear();