summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-09-22 18:20:39 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-09-23 15:47:12 +0200
commit1d398fb983d8f8b53a78e7c47b588fc1f1e7f748 (patch)
tree89e11384ea13d73b3c1dc198c5fee8675036abbe /connectivity
parentcd6780aae1392d4c1af0b15b311a4966834a9602 (diff)
tdf#39593 use getUnoTunnelImplementation
Change-Id: I78eb67913a568c610e38e5002f914773c4906dfd Reviewed-on: https://gerrit.libreoffice.org/79350 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/dbase/DDatabaseMetaData.cxx13
-rw-r--r--connectivity/source/drivers/dbase/DIndexes.cxx12
-rw-r--r--connectivity/source/drivers/dbase/DResultSet.cxx27
-rw-r--r--connectivity/source/drivers/dbase/DTables.cxx35
-rw-r--r--connectivity/source/drivers/file/FDatabaseMetaData.cxx37
-rw-r--r--connectivity/source/drivers/hsqldb/HDriver.cxx11
-rw-r--r--connectivity/source/drivers/mysql_jdbc/YDriver.cxx45
7 files changed, 76 insertions, 104 deletions
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 <dbase/DIndex.hxx>
#include <connectivity/FValue.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <ucbhelper/content.hxx>
@@ -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<ODbaseIndex>(xIndex);
+ if(pIndex)
{
- ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelId()) );
- if(pIndex)
- {
- aRow[11] = new ORowSetValueDecorator(static_cast<sal_Int32>(pIndex->getHeader().db_maxkeys));
- aRow[12] = new ORowSetValueDecorator(static_cast<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));
}
Reference<XColumnsSupplier> 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 <dbase/DIndexes.hxx>
#include <dbase/DIndex.hxx>
+#include <comphelper/servicehelper.hxx>
#include <connectivity/dbexception.hxx>
#include <unotools/ucbhelper.hxx>
#include <strings.hrc>
@@ -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<ODbaseIndex>(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 <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <comphelper/sequence.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <dbase/DIndex.hxx>
#include <dbase/DIndexIter.hxx>
@@ -155,25 +156,21 @@ Sequence< sal_Int32 > SAL_CALL ODbaseResultSet::deleteRows( const Sequence< An
bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex)
{
- Reference<XUnoTunnel> xTunnel(_xIndex,UNO_QUERY);
- if(xTunnel.is())
+ auto pIndex = comphelper::getUnoTunnelImplementation<dbase::ODbaseIndex>(_xIndex);
+ if(pIndex)
{
- dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelId()) );
- if(pIndex)
- {
- std::unique_ptr<dbase::OIndexIterator> pIter = pIndex->createIterator();
+ std::unique_ptr<dbase::OIndexIterator> 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 <file/FConnection.hxx>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <dbase/DCatalog.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <strings.hrc>
#include <connectivity/dbexception.hxx>
@@ -69,27 +70,23 @@ Reference< XPropertySet > ODbaseTables::createDescriptor()
// XAppend
sdbcx::ObjectType ODbaseTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
{
- Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
- if(xTunnel.is())
+ auto pTable = comphelper::getUnoTunnelImplementation<ODbaseTable>(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 <file/FDriver.hxx>
#include <file/FTable.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
#include <tools/diagnose_ex.h>
#include <ucbhelper/content.hxx>
@@ -401,30 +402,26 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
xNames->getByName(*pBegin), css::uno::UNO_QUERY);
if(xTable.is())
{
- Reference<XUnoTunnel> xTunnel(xTable,UNO_QUERY);
- if(xTunnel.is())
+ auto pTable = comphelper::getUnoTunnelImplementation<OFileTable>(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 <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/types.hxx>
#include <unotools/confignode.hxx>
@@ -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<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelId() ));
- if ( pMetaConnection )
- pMetaConnection->setURL(url);
- }
+ auto pMetaConnection = comphelper::getUnoTunnelImplementation<OMetaConnection>(xOrig);
+ if ( pMetaConnection )
+ pMetaConnection->setURL(url);
Reference<XComponent> 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 <mysql/YCatalog.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <connectivity/dbexception.hxx>
@@ -265,16 +266,11 @@ Reference<XConnection> 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<XUnoTunnel> xTunnel(xConnection, UNO_QUERY);
- if (xTunnel.is())
- {
- pMetaConnection = reinterpret_cast<OMetaConnection*>(
- xTunnel->getSomething(OMetaConnection::getUnoTunnelId()));
- if (pMetaConnection)
- pMetaConnection->setURL(url);
- }
+ auto pMetaConnection
+ = comphelper::getUnoTunnelImplementation<OMetaConnection>(xConnection);
+ if (pMetaConnection)
+ pMetaConnection->setURL(url);
m_aConnections.push_back(
TWeakPair(WeakReferenceHelper(xConnection),
TWeakConnectionPair(WeakReferenceHelper(), pMetaConnection)));
@@ -340,29 +336,24 @@ ODriverDelegator::getDataDefinitionByConnection(const Reference<XConnection>& co
checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed);
Reference<XTablesSupplier> xTab;
- Reference<XUnoTunnel> xTunnel(connection, UNO_QUERY);
- if (xTunnel.is())
+ auto pConnection = comphelper::getUnoTunnelImplementation<OMetaConnection>(connection);
+ if (pConnection)
{
- OMetaConnection* pConnection = reinterpret_cast<OMetaConnection*>(
- 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