Kaydet (Commit) 5c7b9549 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in OTable

use rtl::Reference here since these are reference counted data
structures, and we hand out references to me via our API

Change-Id: I8f69dde2db08519cb3d9de20b4ad54462e3ecc98
Reviewed-on: https://gerrit.libreoffice.org/49180Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 68d9583d
......@@ -299,10 +299,10 @@ void OTableHelper::refreshColumns()
);
}
if(m_pColumns)
m_pColumns->reFill(aVector);
if(m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = createColumns(aVector);
m_xColumns = createColumns(aVector);
}
const ColumnDesc* OTableHelper::getColumnDescription(const OUString& _sName) const
......@@ -424,10 +424,10 @@ void OTableHelper::refreshKeys()
{
refreshPrimaryKeys(aNames);
refreshForeignKeys(aNames);
m_pKeys = createKeys(aNames);
m_xKeys = createKeys(aNames);
} // if(!isNew())
else if (!m_pKeys )
m_pKeys = createKeys(aNames);
else if (!m_xKeys )
m_xKeys = createKeys(aNames);
/*if(m_pKeys)
m_pKeys->reFill(aVector);
else*/
......@@ -469,10 +469,10 @@ void OTableHelper::refreshIndexes()
}
}
if(m_pIndexes)
m_pIndexes->reFill(aVector);
if(m_xIndexes)
m_xIndexes->reFill(aVector);
else
m_pIndexes = createIndexes(aVector);
m_xIndexes = createIndexes(aVector);
}
OUString OTableHelper::getRenameStart() const
......@@ -549,7 +549,7 @@ void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference
);
Reference< XPropertySet > xOld(
m_pColumns->getByIndex(index), css::uno::UNO_QUERY);
m_xColumns->getByIndex(index), css::uno::UNO_QUERY);
if(xOld.is())
alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor);
}
......
......@@ -84,10 +84,10 @@ void OAdoTable::refreshColumns()
aColumns.fillElementNames(aVector);
}
if(m_pColumns)
m_pColumns->reFill(aVector);
if(m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pCatalog->getConnection());
m_xColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pCatalog->getConnection());
}
void OAdoTable::refreshKeys()
......@@ -101,10 +101,10 @@ void OAdoTable::refreshKeys()
aKeys.fillElementNames(aVector);
}
if(m_pKeys)
m_pKeys->reFill(aVector);
if(m_xKeys)
m_xKeys->reFill(aVector);
else
m_pKeys = new OKeys(*this,m_aMutex,aVector,aKeys,isCaseSensitive(),m_pCatalog->getConnection());
m_xKeys = new OKeys(*this,m_aMutex,aVector,aKeys,isCaseSensitive(),m_pCatalog->getConnection());
}
void OAdoTable::refreshIndexes()
......@@ -118,10 +118,10 @@ void OAdoTable::refreshIndexes()
aIndexes.fillElementNames(aVector);
}
if(m_pIndexes)
m_pIndexes->reFill(aVector);
if(m_xIndexes)
m_xIndexes->reFill(aVector);
else
m_pIndexes = new OIndexes(*this,m_aMutex,aVector,aIndexes,isCaseSensitive(),m_pCatalog->getConnection());
m_xIndexes = new OIndexes(*this,m_aMutex,aVector,aIndexes,isCaseSensitive(),m_pCatalog->getConnection());
}
Sequence< sal_Int8 > OAdoTable::getUnoTunnelImplementationId()
......@@ -174,7 +174,7 @@ void SAL_CALL OAdoTable::alterColumnByName( const OUString& colName, const Refer
if(bError)
ADOS::ThrowException(*(m_pCatalog->getConnection()->getConnection()),*this);
m_pColumns->refresh();
m_xColumns->refresh();
refreshColumns();
}
......@@ -184,7 +184,7 @@ void SAL_CALL OAdoTable::alterColumnByIndex( sal_Int32 index, const Reference< X
checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed);
Reference< XPropertySet > xOld;
m_pColumns->getByIndex(index) >>= xOld;
m_xColumns->getByIndex(index) >>= xOld;
if(xOld.is())
alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor);
}
......
......@@ -90,10 +90,10 @@ void OComponentTable::refreshColumns()
for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != aEnd;++aIter)
aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
if(m_pColumns)
m_pColumns->reFill(aVector);
if(m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = new component::OComponentColumns(this,m_aMutex,aVector);
m_xColumns = new component::OComponentColumns(this,m_aMutex,aVector);
}
void OComponentTable::refreshIndexes()
......
......@@ -67,10 +67,10 @@ void OEvoabTable::refreshColumns()
aVector.push_back(xRow->getString(4));
}
}
if (m_pColumns)
m_pColumns->reFill(aVector);
if (m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = new OEvoabColumns(this,m_aMutex,aVector);
m_xColumns = new OEvoabColumns(this,m_aMutex,aVector);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -89,10 +89,10 @@ void OFileTable::refreshColumns()
aVector.push_back(xRow->getString(4));
}
if(m_pColumns)
m_pColumns->reFill(aVector);
if(m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = new OColumns(this,m_aMutex,aVector);
m_xColumns = new OColumns(this,m_aMutex,aVector);
}
void OFileTable::refreshKeys()
......
......@@ -116,7 +116,7 @@ void SAL_CALL Table::alterColumnByName(const OUString& rColName,
MutexGuard aGuard(m_rMutex);
checkDisposed(WeakComponentImplHelperBase::rBHelper.bDisposed);
uno::Reference< XPropertySet > xColumn(m_pColumns->getByName(rColName), UNO_QUERY);
uno::Reference< XPropertySet > xColumn(m_xColumns->getByName(rColName), UNO_QUERY);
// sdbcx::Descriptor
const bool bNameChanged = xColumn->getPropertyValue("Name") != rDescriptor->getPropertyValue("Name");
......@@ -218,7 +218,7 @@ void SAL_CALL Table::alterColumnByName(const OUString& rColName,
}
m_pColumns->refresh();
m_xColumns->refresh();
}
// ----- XRename --------------------------------------------------------------
......
......@@ -501,10 +501,10 @@ void OFlatTable::refreshColumns()
for (auto const& column : m_aColumns->get())
aVector.push_back(Reference< XNamed>(column,UNO_QUERY)->getName());
if(m_pColumns)
m_pColumns->reFill(aVector);
if(m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = new OFlatColumns(this,m_aMutex,aVector);
m_xColumns = new OFlatColumns(this,m_aMutex,aVector);
}
......
......@@ -154,7 +154,7 @@ void SAL_CALL OHSQLTable::alterColumnByName( const OUString& colName, const Refe
#endif
);
if ( !m_pColumns || !m_pColumns->hasByName(colName) )
if ( !m_xColumns || !m_xColumns->hasByName(colName) )
throw NoSuchElementException(colName,*this);
......@@ -162,7 +162,7 @@ void SAL_CALL OHSQLTable::alterColumnByName( const OUString& colName, const Refe
{
// first we have to check what should be altered
Reference<XPropertySet> xProp;
m_pColumns->getByName(colName) >>= xProp;
m_xColumns->getByName(colName) >>= xProp;
// first check the types
sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
OUString sOldTypeName, sNewTypeName;
......@@ -237,14 +237,14 @@ void SAL_CALL OHSQLTable::alterColumnByName( const OUString& colName, const Refe
else if(sOldDefault.isEmpty() && !sNewDefault.isEmpty())
alterDefaultValue(sNewDefault,sNewColumnName);
m_pColumns->refresh();
m_xColumns->refresh();
}
else
{
if(m_pColumns)
if(m_xColumns)
{
m_pColumns->dropByName(colName);
m_pColumns->appendByDescriptor(descriptor);
m_xColumns->dropByName(colName);
m_xColumns->appendByDescriptor(descriptor);
}
}
......
......@@ -76,10 +76,10 @@ void MacabTable::refreshColumns()
}
}
if (m_pColumns)
m_pColumns->reFill(aVector);
if (m_xColumns)
m_xColumns->reFill(aVector);
else
m_pColumns = new MacabColumns(this,m_aMutex,aVector);
m_xColumns = new MacabColumns(this,m_aMutex,aVector);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -173,7 +173,7 @@ void SAL_CALL OMySQLTable::alterColumnByName( const OUString& colName, const Ref
#endif
);
if ( !m_pColumns || !m_pColumns->hasByName(colName) )
if ( !m_xColumns || !m_xColumns->hasByName(colName) )
throw NoSuchElementException(colName,*this);
......@@ -181,7 +181,7 @@ void SAL_CALL OMySQLTable::alterColumnByName( const OUString& colName, const Ref
{
// first we have to check what should be altered
Reference<XPropertySet> xProp;
m_pColumns->getByName(colName) >>= xProp;
m_xColumns->getByName(colName) >>= xProp;
// first check the types
sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
......@@ -269,14 +269,14 @@ void SAL_CALL OMySQLTable::alterColumnByName( const OUString& colName, const Ref
" " + OTables::adjustSQL(::dbtools::createStandardColumnPart(descriptor,getConnection(),static_cast<OTables*>(m_pTables),getTypeCreatePattern()));
executeStatement(sSql);
}
m_pColumns->refresh();
m_xColumns->refresh();
}
else
{
if(m_pColumns)
if(m_xColumns)
{
m_pColumns->dropByName(colName);
m_pColumns->appendByDescriptor(descriptor);
m_xColumns->dropByName(colName);
m_xColumns->appendByDescriptor(descriptor);
}
}
......
......@@ -68,9 +68,6 @@ OTable::OTable(OCollection* _pTables,
bool _bCase)
: OTableDescriptor_BASE(m_aMutex)
,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase,true)
,m_pKeys(nullptr)
,m_pColumns(nullptr)
,m_pIndexes(nullptr)
,m_pTables(_pTables)
{
}
......@@ -85,9 +82,6 @@ OTable::OTable( OCollection* _pTables,
,m_SchemaName(SchemaName)
,m_Description(Description)
,m_Type(Type)
,m_pKeys(nullptr)
,m_pColumns(nullptr)
,m_pIndexes(nullptr)
,m_pTables(_pTables)
{
m_Name = Name;
......@@ -95,9 +89,6 @@ OTable::OTable( OCollection* _pTables,
OTable::~OTable()
{
delete m_pKeys;
delete m_pColumns;
delete m_pIndexes;
}
void OTable::construct()
......@@ -151,12 +142,12 @@ void SAL_CALL OTable::disposing()
::osl::MutexGuard aGuard(m_aMutex);
if(m_pKeys)
m_pKeys->disposing();
if(m_pColumns)
m_pColumns->disposing();
if(m_pIndexes)
m_pIndexes->disposing();
if(m_xKeys)
m_xKeys->disposing();
if(m_xColumns)
m_xColumns->disposing();
if(m_xIndexes)
m_xIndexes->disposing();
m_pTables = nullptr;
}
......@@ -169,7 +160,7 @@ Reference< XNameAccess > SAL_CALL OTable::getColumns( )
try
{
if ( !m_pColumns )
if ( !m_xColumns )
refreshColumns();
}
catch( const RuntimeException& )
......@@ -182,7 +173,7 @@ Reference< XNameAccess > SAL_CALL OTable::getColumns( )
// allowed
}
return m_pColumns;
return m_xColumns.get();
}
......@@ -196,9 +187,9 @@ Reference< XIndexAccess > SAL_CALL OTable::getKeys( )
try
{
if ( !m_pKeys )
if ( !m_xKeys )
refreshKeys();
xKeys = m_pKeys;
xKeys = m_xKeys.get();
}
catch( const RuntimeException& )
{
......@@ -241,7 +232,7 @@ Reference< XNameAccess > SAL_CALL OTable::getIndexes( )
try
{
if ( !m_pIndexes )
if ( !m_xIndexes )
refreshIndexes();
}
catch( const RuntimeException& )
......@@ -254,7 +245,7 @@ Reference< XNameAccess > SAL_CALL OTable::getIndexes( )
// allowed
}
return m_pIndexes;
return m_xIndexes.get();
}
// XRename
......
......@@ -103,7 +103,7 @@ OColumn* ODBTable::createColumn(const OUString& _rName) const
}
else
{
OColumns* pColumns = static_cast<OColumns*>(m_pColumns);
OColumns* pColumns = static_cast<OColumns*>(m_xColumns.get());
xProp.set(pColumns->createBaseObject(_rName),UNO_QUERY);
}
......@@ -294,12 +294,12 @@ void SAL_CALL ODBTable::alterColumnByName( const OUString& _rName, const Referen
if ( !getAlterService().is() )
throw SQLException(DBA_RES(RID_STR_NO_TABLE_RENAME),*this,SQLSTATE_GENERAL,1000,Any() );
if ( !m_pColumns->hasByName(_rName) )
if ( !m_xColumns->hasByName(_rName) )
throw SQLException(DBA_RES(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,Any() );
Reference<XPropertySet> xTable(this);
getAlterService()->alterColumnByName(xTable,_rName,_rxDescriptor);
m_pColumns->refresh();
m_xColumns->refresh();
}
sal_Int64 SAL_CALL ODBTable::getSomething( const Sequence< sal_Int8 >& rId )
......
......@@ -36,6 +36,7 @@
#include <connectivity/CommonTools.hxx>
#include <connectivity/dbtoolsdllapi.hxx>
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include <memory>
namespace connectivity
{
......@@ -72,9 +73,9 @@ namespace connectivity
OUString m_Description;
OUString m_Type;
OCollection* m_pKeys;
OCollection* m_pColumns;
OCollection* m_pIndexes;
rtl::Reference<OCollection> m_xKeys;
rtl::Reference<OCollection> m_xColumns;
rtl::Reference<OCollection> m_xIndexes;
OCollection* m_pTables; // must hold his own container to notify him when renaming
using OTableDescriptor_BASE::rBHelper;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment