From 1d398fb983d8f8b53a78e7c47b588fc1f1e7f748 Mon Sep 17 00:00:00 2001 From: Arkadiy Illarionov Date: Sun, 22 Sep 2019 18:20:39 +0300 Subject: tdf#39593 use getUnoTunnelImplementation Change-Id: I78eb67913a568c610e38e5002f914773c4906dfd Reviewed-on: https://gerrit.libreoffice.org/79350 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov --- .../source/drivers/dbase/DDatabaseMetaData.cxx | 13 +++---- connectivity/source/drivers/dbase/DIndexes.cxx | 12 ++---- connectivity/source/drivers/dbase/DResultSet.cxx | 27 ++++++------- connectivity/source/drivers/dbase/DTables.cxx | 35 ++++++++--------- .../source/drivers/file/FDatabaseMetaData.cxx | 37 ++++++++---------- connectivity/source/drivers/hsqldb/HDriver.cxx | 11 ++---- connectivity/source/drivers/mysql_jdbc/YDriver.cxx | 45 +++++++++------------- 7 files changed, 76 insertions(+), 104 deletions(-) (limited to 'connectivity/source') diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx index 1db65083b06a..cc5f12b6e7ac 100644 --- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -296,15 +297,11 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( aRow[4] = new ORowSetValueDecorator(getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))); aRow[6] = new ORowSetValueDecorator(*pBegin); - Reference< XUnoTunnel> xTunnel(xIndex,UNO_QUERY); - if(xTunnel.is()) + auto pIndex = comphelper::getUnoTunnelImplementation(xIndex); + if(pIndex) { - ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelId()) ); - if(pIndex) - { - aRow[11] = new ORowSetValueDecorator(static_cast(pIndex->getHeader().db_maxkeys)); - aRow[12] = new ORowSetValueDecorator(static_cast(pIndex->getHeader().db_pagecount)); - } + aRow[11] = new ORowSetValueDecorator(static_cast(pIndex->getHeader().db_maxkeys)); + aRow[12] = new ORowSetValueDecorator(static_cast(pIndex->getHeader().db_pagecount)); } Reference xColumnsSup(xIndex,UNO_QUERY); diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx index 3758330b9f3c..1ebce2612098 100644 --- a/connectivity/source/drivers/dbase/DIndexes.cxx +++ b/connectivity/source/drivers/dbase/DIndexes.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -106,14 +107,9 @@ sdbcx::ObjectType ODbaseIndexes::appendObject( const OUString& _rForName, const // XDrop void ODbaseIndexes::dropObject(sal_Int32 _nPos, const OUString& /*_sElementName*/) { - Reference< XUnoTunnel> xTunnel(getObject(_nPos),UNO_QUERY); - if ( xTunnel.is() ) - { - ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelId()) ); - if ( pIndex ) - pIndex->DropImpl(); - } - + auto pIndex = comphelper::getUnoTunnelImplementation(getObject(_nPos)); + if ( pIndex ) + pIndex->DropImpl(); } diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx index 260e009611fc..22826ec2fd0f 100644 --- a/connectivity/source/drivers/dbase/DResultSet.cxx +++ b/connectivity/source/drivers/dbase/DResultSet.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -155,25 +156,21 @@ Sequence< sal_Int32 > SAL_CALL ODbaseResultSet::deleteRows( const Sequence< An bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex) { - Reference xTunnel(_xIndex,UNO_QUERY); - if(xTunnel.is()) + auto pIndex = comphelper::getUnoTunnelImplementation(_xIndex); + if(pIndex) { - dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelId()) ); - if(pIndex) - { - std::unique_ptr pIter = pIndex->createIterator(); + std::unique_ptr pIter = pIndex->createIterator(); - if (pIter) + if (pIter) + { + sal_uInt32 nRec = pIter->First(); + while (nRec != NODE_NOTFOUND) { - sal_uInt32 nRec = pIter->First(); - while (nRec != NODE_NOTFOUND) - { - m_pFileSet->get().push_back(nRec); - nRec = pIter->Next(); - } - m_pFileSet->setFrozen(); - return true; + m_pFileSet->get().push_back(nRec); + nRec = pIter->Next(); } + m_pFileSet->setFrozen(); + return true; } } return false; diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx index d72061b4538f..0054f3fcecc1 100644 --- a/connectivity/source/drivers/dbase/DTables.cxx +++ b/connectivity/source/drivers/dbase/DTables.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -69,27 +70,23 @@ Reference< XPropertySet > ODbaseTables::createDescriptor() // XAppend sdbcx::ObjectType ODbaseTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor ) { - Reference xTunnel(descriptor,UNO_QUERY); - if(xTunnel.is()) + auto pTable = comphelper::getUnoTunnelImplementation(descriptor); + if(pTable) { - ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelId()) ); - if(pTable) + pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName)); + try + { + if(!pTable->CreateImpl()) + throw SQLException(); + } + catch(SQLException&) + { + throw; + } + catch(Exception& ex) { - pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName)); - try - { - if(!pTable->CreateImpl()) - throw SQLException(); - } - catch(SQLException&) - { - throw; - } - catch(Exception& ex) - { - css::uno::Any anyEx = cppu::getCaughtException(); - throw SQLException( ex.Message, nullptr, "", 0, anyEx ); - } + css::uno::Any anyEx = cppu::getCaughtException(); + throw SQLException( ex.Message, nullptr, "", 0, anyEx ); } } return createObject( _rForName ); diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx index c5fdadbbf5d0..44404f98267a 100644 --- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx +++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -401,30 +402,26 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( xNames->getByName(*pBegin), css::uno::UNO_QUERY); if(xTable.is()) { - Reference xTunnel(xTable,UNO_QUERY); - if(xTunnel.is()) + auto pTable = comphelper::getUnoTunnelImplementation(xTable); + if(pTable && !pTable->isReadOnly()) { - OFileTable* pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelId()) ); - if(pTable && !pTable->isReadOnly()) + aRow[6] = ODatabaseMetaDataResultSet::getInsertValue(); + aRows.push_back(aRow); + if(!m_pConnection->showDeleted()) { - aRow[6] = ODatabaseMetaDataResultSet::getInsertValue(); - aRows.push_back(aRow); - if(!m_pConnection->showDeleted()) - { - aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue(); - aRows.push_back(aRow); - } - aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue(); - aRows.push_back(aRow); - aRow[6] = ODatabaseMetaDataResultSet::getCreateValue(); - aRows.push_back(aRow); - aRow[6] = ODatabaseMetaDataResultSet::getReadValue(); - aRows.push_back(aRow); - aRow[6] = ODatabaseMetaDataResultSet::getAlterValue(); - aRows.push_back(aRow); - aRow[6] = ODatabaseMetaDataResultSet::getDropValue(); + aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue(); aRows.push_back(aRow); } + aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue(); + aRows.push_back(aRow); + aRow[6] = ODatabaseMetaDataResultSet::getCreateValue(); + aRows.push_back(aRow); + aRow[6] = ODatabaseMetaDataResultSet::getReadValue(); + aRows.push_back(aRow); + aRow[6] = ODatabaseMetaDataResultSet::getAlterValue(); + aRows.push_back(aRow); + aRow[6] = ODatabaseMetaDataResultSet::getDropValue(); + aRows.push_back(aRow); } } } diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 5ab48b138a1e..1a03f16707d3 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -342,13 +343,9 @@ namespace connectivity if ( xOrig.is() ) { // now we have to set the URL to get the correct answer for metadata()->getURL() - Reference< XUnoTunnel> xTunnel(xOrig,UNO_QUERY); - if ( xTunnel.is() ) - { - OMetaConnection* pMetaConnection = reinterpret_cast(xTunnel->getSomething( OMetaConnection::getUnoTunnelId() )); - if ( pMetaConnection ) - pMetaConnection->setURL(url); - } + auto pMetaConnection = comphelper::getUnoTunnelImplementation(xOrig); + if ( pMetaConnection ) + pMetaConnection->setURL(url); Reference xComp(xOrig,UNO_QUERY); if ( xComp.is() ) diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx index 06631edda7f1..727a8f2b350b 100644 --- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx +++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -265,16 +266,11 @@ Reference SAL_CALL ODriverDelegator::connect(const OUString& url, xConnection = xDriver->connect(sCuttedUrl, aConvertedProperties); if (xConnection.is()) { - OMetaConnection* pMetaConnection = nullptr; // now we have to set the URL to get the correct answer for metadata()->getURL() - Reference xTunnel(xConnection, UNO_QUERY); - if (xTunnel.is()) - { - pMetaConnection = reinterpret_cast( - xTunnel->getSomething(OMetaConnection::getUnoTunnelId())); - if (pMetaConnection) - pMetaConnection->setURL(url); - } + auto pMetaConnection + = comphelper::getUnoTunnelImplementation(xConnection); + if (pMetaConnection) + pMetaConnection->setURL(url); m_aConnections.push_back( TWeakPair(WeakReferenceHelper(xConnection), TWeakConnectionPair(WeakReferenceHelper(), pMetaConnection))); @@ -340,29 +336,24 @@ ODriverDelegator::getDataDefinitionByConnection(const Reference& co checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed); Reference xTab; - Reference xTunnel(connection, UNO_QUERY); - if (xTunnel.is()) + auto pConnection = comphelper::getUnoTunnelImplementation(connection); + if (pConnection) { - OMetaConnection* pConnection = reinterpret_cast( - xTunnel->getSomething(OMetaConnection::getUnoTunnelId())); - if (pConnection) + TWeakPairVector::iterator i + = std::find_if(m_aConnections.begin(), m_aConnections.end(), + [&pConnection](const TWeakPairVector::value_type& rConnection) { + return rConnection.second.second == pConnection; + }); + if (i != m_aConnections.end()) { - TWeakPairVector::iterator i - = std::find_if(m_aConnections.begin(), m_aConnections.end(), - [&pConnection](const TWeakPairVector::value_type& rConnection) { - return rConnection.second.second == pConnection; - }); - if (i != m_aConnections.end()) + xTab.set(i->second.first.get(), UNO_QUERY); + if (!xTab.is()) { - xTab.set(i->second.first.get(), UNO_QUERY); - if (!xTab.is()) - { - xTab = new OMySQLCatalog(connection); - i->second.first = WeakReferenceHelper(xTab); - } + xTab = new OMySQLCatalog(connection); + i->second.first = WeakReferenceHelper(xTab); } } - } // if ( xTunnel.is() ) + } // if (pConnection) if (!xTab.is()) { TWeakPairVector::iterator i -- cgit