use more concrete UNO in connectivity

Change-Id: I3842706a0b28c3bf78c8f359ca2d2226ed5f1b07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182769
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2025-03-11 13:15:41 +02:00
parent 0ce35e70da
commit 02a5df653f
16 changed files with 246 additions and 257 deletions

View File

@ -65,9 +65,10 @@ css::uno::Reference< css::beans::XPropertySet > OIndexColumns::createObject(cons
xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(
Catalog, aSchema, aTable, _rName);
css::uno::Reference< css::beans::XPropertySet > xRet;
if ( xResult.is() )
{
if ( !xResult.is() )
return nullptr;
rtl::Reference< OIndexColumn > xRet;
Reference< XRow > xRow(xResult,UNO_QUERY);
while( xResult->next() )
{
@ -93,7 +94,6 @@ css::uno::Reference< css::beans::XPropertySet > OIndexColumns::createObject(cons
break;
}
}
}
return xRet;
}

View File

@ -56,7 +56,7 @@ css::uno::Reference< css::beans::XPropertySet > OIndexesHelper::createObject(con
if ( !xConnection.is() )
return nullptr;
css::uno::Reference< css::beans::XPropertySet > xRet;
rtl::Reference< OIndexHelper > xRet;
OUString aName,aQualifier;
sal_Int32 nLen = _rName.indexOf('.');
if ( nLen != -1 )

View File

@ -70,18 +70,19 @@ css::uno::Reference< css::beans::XPropertySet > OKeyColumnsHelper::createObject(
}
}
css::uno::Reference< css::beans::XPropertySet > xRet;
// now describe the column _rName and set his related column
xResult = m_pKey->getTable()->getMetaData()->getColumns(Catalog, aSchema, aTable, _rName);
if ( xResult.is() )
{
if ( !xResult.is() )
return nullptr;
Reference< XRow > xRow(xResult,UNO_QUERY);
if ( xResult->next() )
{
if ( xRow->getString(4) == _rName )
{
if ( !xResult->next() )
return nullptr;
if ( xRow->getString(4) != _rName )
return nullptr;
sal_Int32 nDataType = xRow->getInt(5);
OUString aTypeName(xRow->getString(6));
sal_Int32 nSize = xRow->getInt(7);
@ -97,7 +98,7 @@ css::uno::Reference< css::beans::XPropertySet > OKeyColumnsHelper::createObject(
// sometimes we get an error when asking for this param
}
xRet = new OKeyColumn(aRefColumnName,
rtl::Reference<OKeyColumn> xRet = new OKeyColumn(aRefColumnName,
_rName,
aTypeName,
sColumnDef,
@ -109,9 +110,6 @@ css::uno::Reference< css::beans::XPropertySet > OKeyColumnsHelper::createObject(
aCatalog,
aSchema,
aTable);
}
}
}
return xRet;
}

View File

@ -52,7 +52,7 @@ OKeysHelper::OKeysHelper( OTableHelper* _pTable,
css::uno::Reference< css::beans::XPropertySet > OKeysHelper::createObject(const OUString& _rName)
{
css::uno::Reference< css::beans::XPropertySet > xRet;
rtl::Reference< OTableKeyHelper > xRet;
if(!_rName.isEmpty())
{

View File

@ -408,14 +408,15 @@ namespace
bool _bIsCurrency,
sal_Int32 _nDataType)
{
Reference<XPropertySet> xProp;
Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
Reference< XResultSet > xResult = xMetaData->getColumns(_aCatalog, _aSchema, _aTable, _rQueryName);
OUString sCatalog;
_aCatalog >>= sCatalog;
if ( xResult.is() )
{
if ( !xResult.is() )
return nullptr;
rtl::Reference<connectivity::sdbcx::OColumn> xProp;
UStringMixEqual aMixCompare(_bCase);
Reference< XRow > xRow(xResult,UNO_QUERY);
while( xResult->next() )
@ -503,7 +504,6 @@ namespace
break;
}
}
}
return xProp;
}

View File

@ -45,10 +45,16 @@ css::uno::Reference< css::beans::XPropertySet > ODbaseIndexes::createObject(cons
::dbtools::throwGenericSQLException( sError, *m_pTable );
}
css::uno::Reference< css::beans::XPropertySet > xRet;
std::unique_ptr<SvStream> pFileStream = ::connectivity::file::OFileTable::createStream_simpleError(sFile, StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYWRITE);
if(pFileStream)
if(!pFileStream)
{
const OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
STR_COULD_NOT_LOAD_FILE,
"$filename$", sFile
) );
::dbtools::throwGenericSQLException( sError, *m_pTable );
}
pFileStream->SetEndian(SvStreamEndian::LITTLE);
pFileStream->SetBufferSize(DINDEX_PAGE_SIZE);
ODbaseIndex::NDXHeader aHeader;
@ -58,18 +64,8 @@ css::uno::Reference< css::beans::XPropertySet > ODbaseIndexes::createObject(cons
pFileStream.reset();
rtl::Reference<ODbaseIndex> pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
xRet = pIndex;
pIndex->openIndexFile();
}
else
{
const OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
STR_COULD_NOT_LOAD_FILE,
"$filename$", sFile
) );
::dbtools::throwGenericSQLException( sError, *m_pTable );
}
return xRet;
return pIndex;
}
void ODbaseIndexes::impl_refresh( )

View File

@ -42,11 +42,11 @@ css::uno::Reference< css::beans::XPropertySet > OEvoabColumns::createObject(cons
sTableName,
_rName);
css::uno::Reference< css::beans::XPropertySet > xRet;
if (xResult.is())
{
Reference< XRow > xRow(xResult,UNO_QUERY);
if (!xResult.is())
return nullptr;
rtl::Reference< OColumn > xRet;
Reference< XRow > xRow(xResult,UNO_QUERY);
while (xResult->next())
{
if (xRow->getString(4) == _rName)
@ -70,7 +70,6 @@ css::uno::Reference< css::beans::XPropertySet > OEvoabColumns::createObject(cons
break;
}
}
}
return xRet;
}

View File

@ -37,9 +37,10 @@ css::uno::Reference< css::beans::XPropertySet > OEvoabTables::createObject(const
Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),u"%"_ustr,aName,aTypes);
css::uno::Reference< css::beans::XPropertySet > xRet;
if(xResult.is())
{
rtl::Reference< OEvoabTable > xRet;
if(!xResult.is())
return nullptr;
Reference< XRow > xRow(xResult,UNO_QUERY);
if(xResult->next()) // there can be only one table with this name
{
@ -52,7 +53,6 @@ css::uno::Reference< css::beans::XPropertySet > OEvoabTables::createObject(const
u""_ustr,
u""_ustr);
}
}
::comphelper::disposeComponent(xResult);

View File

@ -36,9 +36,10 @@ css::uno::Reference< css::beans::XPropertySet > OColumns::createObject(const OUS
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
sSchemaName, sTableName, _rName);
css::uno::Reference< css::beans::XPropertySet > xRet;
if(xResult.is())
{
if(!xResult.is())
return nullptr;
rtl::Reference< sdbcx::OColumn > xRet;
Reference< XRow > xRow(xResult,UNO_QUERY);
while(xResult->next())
{
@ -62,7 +63,6 @@ css::uno::Reference< css::beans::XPropertySet > OColumns::createObject(const OUS
break;
}
}
}
return xRet;
}

View File

@ -709,11 +709,11 @@ Reference< XDatabaseMetaData > SAL_CALL Connection::getMetaData( )
// here we have to create the class with biggest interface
// The answer is 42 :-)
Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
rtl::Reference< ODatabaseMetaData > xMetaData = m_xMetaData.get();
if(!xMetaData.is())
{
xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it
m_xMetaData = xMetaData;
m_xMetaData = xMetaData.get();
}
return xMetaData;
@ -879,7 +879,7 @@ void Connection::disposing()
disposeStatements();
m_xMetaData = css::uno::WeakReference< css::sdbc::XDatabaseMetaData>();
m_xMetaData.clear();
ISC_STATUS_ARRAY status; /* status vector */
if (m_aTransactionHandle)
@ -949,18 +949,13 @@ uno::Reference< XTablesSupplier > Connection::createCatalog()
MutexGuard aGuard(m_aMutex);
// m_xCatalog is a weak reference. Reuse it if it still exists.
Reference< XTablesSupplier > xCatalog = m_xCatalog;
if (xCatalog.is())
{
return xCatalog;
}
else
rtl::Reference< Catalog > xCatalog = m_xCatalog.get();
if (!xCatalog.is())
{
xCatalog = new Catalog(this);
m_xCatalog = xCatalog;
return m_xCatalog;
m_xCatalog = xCatalog.get();
}
return xCatalog;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@ -27,6 +27,7 @@
#include <memory>
#include <OTypeInfo.hxx>
#include <unotools/tempfile.hxx>
#include <unotools/weakref.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/document/DocumentEvent.hpp>
@ -54,6 +55,7 @@ namespace connectivity::firebird
class OStatementCommonBase;
class FirebirdDriver;
class ODatabaseMetaData;
class Catalog;
typedef std::vector< ::connectivity::OTypeInfo> TTypeInfoVector;
@ -136,9 +138,9 @@ namespace connectivity::firebird
isc_db_handle m_aDBHandle;
isc_tr_handle m_aTransactionHandle;
css::uno::WeakReference< css::sdbcx::XTablesSupplier>
unotools::WeakReference< Catalog >
m_xCatalog;
css::uno::WeakReference< css::sdbc::XDatabaseMetaData >
unotools::WeakReference< ODatabaseMetaData >
m_xMetaData;
/** Statements owned by this connection. */
OWeakRefArray m_aStatements;

View File

@ -51,9 +51,10 @@ css::uno::Reference< css::beans::XPropertySet > OTables::createObject(const OUSt
aCatalog <<= sCatalog;
Reference< XResultSet > xResult = m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes);
css::uno::Reference< css::beans::XPropertySet > xRet;
if ( xResult.is() )
{
if ( !xResult.is() )
return nullptr;
rtl::Reference< OHSQLTable > xRet;
Reference< XRow > xRow(xResult,UNO_QUERY);
if ( xResult->next() ) // there can be only one table with this name
{
@ -72,7 +73,6 @@ css::uno::Reference< css::beans::XPropertySet > OTables::createObject(const OUSt
,nPrivileges);
}
::comphelper::disposeComponent(xResult);
}
return xRet;
}

View File

@ -68,12 +68,11 @@ Reference< XConnection > SAL_CALL java_sql_Driver::connect( const OUString& url,
{
m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_CONNECTING_URL, url );
Reference< XConnection > xOut;
rtl::Reference< java_sql_Connection > xOut;
if ( acceptsURL(url ) )
{
rtl::Reference<java_sql_Connection> pConnection = new java_sql_Connection( *this );
xOut = pConnection;
if ( !pConnection->construct(url,info) )
xOut = new java_sql_Connection( *this );
if ( !xOut->construct(url,info) )
xOut.clear(); // an error occurred and the java driver didn't throw an exception
else
m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS );

View File

@ -54,7 +54,7 @@ css::uno::Reference<css::beans::XPropertySet> OTables::createObject(const OUStri
aCatalog <<= sCatalog;
Reference<XResultSet> xResult = m_xMetaData->getTables(aCatalog, sSchema, sTable, sTableTypes);
css::uno::Reference<css::beans::XPropertySet> xRet;
rtl::Reference<OMySQLTable> xRet;
if (xResult.is())
{
Reference<XRow> xRow(xResult, UNO_QUERY);

View File

@ -231,7 +231,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( )
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
Reference< XResultSet > rs;
rtl::Reference< OResultSet > rs;
prepareStatement();

View File

@ -1587,7 +1587,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const OUString & rColumnName,con
// without table specified
if ( !bFkt )
{
Reference< XPropertySet> xNewColumn;
rtl::Reference< OParseColumn> xNewColumn;
for (auto const& table : *m_pImpl->m_pTables)
{