diff options
Diffstat (limited to 'dbaccess/source/core/api/RowSet.cxx')
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 90 |
1 files changed, 32 insertions, 58 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index d22717c263b0..d9904071d64b 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -70,9 +70,8 @@ #include <i18nlangtag/languagetag.hxx> #include <o3tl/safeint.hxx> #include <unotools/syslocale.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> -using namespace utl; using namespace dbaccess; using namespace connectivity; using namespace comphelper; @@ -419,18 +418,6 @@ void SAL_CALL ORowSet::release() noexcept ORowSet_BASE1::release(); } -// css::XUnoTunnel -sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - -Sequence< sal_Int8 > ORowSet::getUnoTunnelId() -{ - static const comphelper::UnoIdInit s_Id; - return s_Id.getSeq(); -} - // css::XAggregation Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) { @@ -618,7 +605,7 @@ void SAL_CALL ORowSet::close( ) MutexGuard aGuard( m_aMutex ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); } - // additionals things to set + // additional things to set freeResources( true ); } @@ -974,7 +961,7 @@ void SAL_CALL ORowSet::deleteRow( ) // this call position the cache indirect Any aBookmarkToDelete( m_aBookmark ); - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); sal_Int32 nDeletePosition = m_pCache->getRow(); notifyRowSetAndClonesRowDelete( aBookmarkToDelete ); @@ -1021,7 +1008,7 @@ void ORowSet::implCancelRowUpdates( bool _bNotifyModified ) if ( m_bNew || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) throwFunctionSequenceException(*this); - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); ORowSetRow aOldValues; if ( !m_bModified && _bNotifyModified && !m_aCurrentRow.isNull() ) @@ -1171,12 +1158,12 @@ void SAL_CALL ORowSet::moveToInsertRow( ) ORowSetRow aOldValues; if ( rowDeleted() ) { - positionCache( MOVE_FORWARD ); + positionCache( CursorMoveDirection::Forward ); m_pCache->next(); setCurrentRow( true, false, aOldValues, aGuard); } else - positionCache( MOVE_NONE ); + positionCache( CursorMoveDirection::Current ); // check before because the resultset could be empty if ( !m_bBeforeFirst @@ -1226,18 +1213,18 @@ void ORowSet::impl_setDataColumnsWriteable_throw() dataColumn->getPropertyValue(PROPERTY_ISREADONLY) >>= bReadOnly; *aReadIter = bReadOnly; - dataColumn->setPropertyValue(PROPERTY_ISREADONLY,makeAny(false)); + dataColumn->setPropertyValue(PROPERTY_ISREADONLY,Any(false)); ++aReadIter; } } void ORowSet::impl_restoreDataColumnsWriteable_throw() { - assert(m_aDataColumns.size() == m_aReadOnlyDataColumns.size() || m_aReadOnlyDataColumns.size() == 0 ); + assert(m_aDataColumns.size() == m_aReadOnlyDataColumns.size() || m_aReadOnlyDataColumns.empty()); TDataColumns::const_iterator aIter = m_aDataColumns.begin(); for (bool readOnlyDataColumn : m_aReadOnlyDataColumns) { - (*aIter)->setPropertyValue(PROPERTY_ISREADONLY, makeAny(readOnlyDataColumn) ); + (*aIter)->setPropertyValue(PROPERTY_ISREADONLY, Any(readOnlyDataColumn) ); ++aIter; } m_aReadOnlyDataColumns.clear(); @@ -1265,7 +1252,7 @@ void SAL_CALL ORowSet::moveToCurrentRow( ) if ( !notifyAllListenersCursorBeforeMove( aGuard ) ) return; - positionCache( MOVE_NONE_REFRESH ); + positionCache( CursorMoveDirection::CurrentRefresh ); ORowSetNotifier aNotifier( this ); @@ -1616,8 +1603,8 @@ void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxSta } } - _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, makeAny( nResultSetType ) ); - _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, makeAny( nResultSetConcurrency ) ); + _rxStatement->setPropertyValue( PROPERTY_RESULTSETTYPE, Any( nResultSetType ) ); + _rxStatement->setPropertyValue( PROPERTY_RESULTSETCONCURRENCY, Any( nResultSetConcurrency ) ); } void ORowSet::impl_ensureStatement_throw() @@ -1644,8 +1631,8 @@ void ORowSet::impl_ensureStatement_throw() // set the result set type and concurrency try { - xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, makeAny( true ) ); - xStatementProps->setPropertyValue( PROPERTY_MAXROWS, makeAny( m_nMaxRows ) ); + xStatementProps->setPropertyValue( PROPERTY_USEBOOKMARKS, Any( true ) ); + xStatementProps->setPropertyValue( PROPERTY_MAXROWS, Any( m_nMaxRows ) ); setStatementResultSetType( xStatementProps, m_nResultSetType, m_nResultSetConcurrency ); } @@ -1662,8 +1649,7 @@ void ORowSet::impl_ensureStatement_throw() // append information about what we were actually going to execute OUString sInfo(m_sErrorString.replaceFirst("$command$", sCommandToExecute)); - css::uno::Any aAppend = SQLExceptionInfo::createException(SQLExceptionInfo::TYPE::SQLContext, sInfo, OUString(), 0); - pLastExceptionInChain->NextException = aAppend; + pLastExceptionInChain->NextException = SQLExceptionInfo::createException(SQLExceptionInfo::TYPE::SQLContext, sInfo, OUString(), 0); // propagate throw; @@ -1720,8 +1706,8 @@ void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertyS // a number of properties is plain copied const OUString aPropertyNames[] = { - OUString(PROPERTY_ALIGN), OUString(PROPERTY_RELATIVEPOSITION), OUString(PROPERTY_WIDTH), OUString(PROPERTY_HIDDEN), OUString(PROPERTY_CONTROLMODEL), - OUString(PROPERTY_HELPTEXT), OUString(PROPERTY_CONTROLDEFAULT) + PROPERTY_ALIGN, PROPERTY_RELATIVEPOSITION, PROPERTY_WIDTH, PROPERTY_HIDDEN, PROPERTY_CONTROLMODEL, + PROPERTY_HELPTEXT, PROPERTY_CONTROLDEFAULT }; for (const auto & aPropertyName : aPropertyNames) { @@ -1741,7 +1727,7 @@ void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertyS } if ( !nFormatKey && m_xNumberFormatTypes.is() ) nFormatKey = ::dbtools::getDefaultNumberFormat( _rxTemplateColumn, m_xNumberFormatTypes, SvtSysLocale().GetLanguageTag().getLocale() ); - _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, makeAny( nFormatKey ) ); + _rxRowSetColumn->setPropertyValue( PROPERTY_NUMBERFORMAT, Any( nFormatKey ) ); } catch(Exception&) { @@ -1873,7 +1859,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi aNames.push_back(sName); m_aDataColumns.push_back(pColumn.get()); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i+1) != rKeyColumns.end())); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,Any(rKeyColumns.find(i+1) != rKeyColumns.end())); try { @@ -1882,10 +1868,10 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi nFormatKey = ::dbtools::getDefaultNumberFormat(pColumn,m_xNumberFormatTypes,aLocale); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,makeAny(sal_Int32(i+1))); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,makeAny(sal_Int32(227))); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,makeAny(sal_Int32(0))); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,Any(nFormatKey)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,Any(sal_Int32(i+1))); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,Any(sal_Int32(227))); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,Any(sal_Int32(0))); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN, css::uno::Any(false)); } catch(Exception&) @@ -1973,7 +1959,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi }); aColumns->emplace_back(pColumn); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,makeAny(rKeyColumns.find(i) != rKeyColumns.end())); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ISREADONLY,Any(rKeyColumns.find(i) != rKeyColumns.end())); if(sColumnLabel.isEmpty()) { @@ -2071,7 +2057,7 @@ Reference< XResultSet > SAL_CALL ORowSet::createResultSet( ) if(m_xStatement.is()) { rtl::Reference<ORowSetClone> pClone = new ORowSetClone( m_aContext, *this, m_pMutex ); - m_aClones.emplace_back(static_cast<cppu::OWeakObject*>(pClone.get())); + m_aClones.emplace_back(css::uno::Reference< css::uno::XWeak >(pClone)); return pClone; } return Reference< XResultSet >(); @@ -2145,7 +2131,7 @@ void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark ) // notify the clones for (auto const& elem : m_aClones) { - auto pClone = comphelper::getFromUnoTunnel<ORowSetClone>(elem.get()); + rtl::Reference<ORowSetClone> pClone = dynamic_cast<ORowSetClone*>(elem.get().get()); if(pClone) pClone->onDeleteRow( _rBookmark ); } @@ -2158,7 +2144,7 @@ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 // notify the clones for (auto const& clone : m_aClones) { - auto pClone = comphelper::getFromUnoTunnel<ORowSetClone>(clone.get()); + rtl::Reference<ORowSetClone> pClone = dynamic_cast<ORowSetClone*>(clone.get().get()); if(pClone) pClone->onDeletedRow( _rBookmark, _nPos ); } @@ -2701,7 +2687,7 @@ void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) if ( m_aCurrentRow.isNull() ) ::dbtools::throwSQLException( DBA_RES( RID_STR_INVALID_CURSOR_STATE ), StandardSQLState::INVALID_CURSOR_STATE, *this ); - if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->size()) <= columnIndex ) + if ( columnIndex <= 0 || (*m_aCurrentRow)->size() <= o3tl::make_unsigned(columnIndex) ) ::dbtools::throwSQLException( DBA_RES( RID_STR_INVALID_INDEX ), StandardSQLState::INVALID_DESCRIPTOR_INDEX, *this ); } @@ -2737,7 +2723,7 @@ void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard) ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex ) :OSubComponent(m_aMutex, rParent) - ,ORowSetBase( _rContext, OComponentHelper::rBHelper, _pMutex ) + ,ORowSetBase( _rContext, WeakComponentImplHelper::rBHelper, _pMutex ) ,m_pParent(&rParent) ,m_nFetchDirection(rParent.m_nFetchDirection) ,m_nFetchSize(rParent.m_nFetchSize) @@ -2797,7 +2783,7 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT) >>= nFormatKey; if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is()) nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,Any(nFormatKey)); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION)); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH)); pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN)); @@ -2883,8 +2869,8 @@ void ORowSetClone::close() { { MutexGuard aGuard( m_aMutex ); - if (OComponentHelper::rBHelper.bDisposed) - throw DisposedException(); + if (WeakComponentImplHelper::rBHelper.bDisposed) + return; } dispose(); } @@ -2903,18 +2889,6 @@ void ORowSetClone::close() return *::comphelper::OPropertyArrayUsageHelper<ORowSetClone>::getArrayHelper(); } -Sequence< sal_Int8 > ORowSetClone::getUnoTunnelId() -{ - static const comphelper::UnoIdInit implId; - return implId.getSeq(); -} - -// css::XUnoTunnel -sal_Int64 SAL_CALL ORowSetClone::getSomething( const Sequence< sal_Int8 >& rId ) -{ - return comphelper::getSomethingImpl(rId, this); -} - void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) { if ( nHandle == PROPERTY_ID_FETCHSIZE ) |