[Libreoffice-commits] core.git: connectivity/source dbaccess/source include/connectivity

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 5 11:04:58 UTC 2018


 connectivity/source/commontools/TTableHelper.cxx |   20 ++--
 connectivity/source/drivers/ado/ATable.cxx       |   22 ++---
 connectivity/source/drivers/component/CTable.cxx |    6 -
 connectivity/source/drivers/dbase/DTable.cxx     |  100 +++++++++++------------
 connectivity/source/drivers/evoab2/NTable.cxx    |    6 -
 connectivity/source/drivers/file/FTable.cxx      |    6 -
 connectivity/source/drivers/firebird/Table.cxx   |    4 
 connectivity/source/drivers/flat/ETable.cxx      |    6 -
 connectivity/source/drivers/hsqldb/HTable.cxx    |   12 +-
 connectivity/source/drivers/macab/MacabTable.cxx |    6 -
 connectivity/source/drivers/mysql/YTable.cxx     |   12 +-
 connectivity/source/sdbcx/VTable.cxx             |   33 ++-----
 dbaccess/source/core/api/table.cxx               |    6 -
 include/connectivity/sdbcx/VTable.hxx            |    7 -
 14 files changed, 119 insertions(+), 127 deletions(-)

New commits:
commit 5c7b954935369cbbd22a6f43be63ac7c0ddbbfdc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 29 13:28:44 2018 +0200

    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/49180
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx
index b94ab42d4617..7bb03a90da3c 100644
--- a/connectivity/source/commontools/TTableHelper.cxx
+++ b/connectivity/source/commontools/TTableHelper.cxx
@@ -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);
 }
diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx
index c1688a152cc4..0c028794a6c3 100644
--- a/connectivity/source/drivers/ado/ATable.cxx
+++ b/connectivity/source/drivers/ado/ATable.cxx
@@ -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);
 }
diff --git a/connectivity/source/drivers/component/CTable.cxx b/connectivity/source/drivers/component/CTable.cxx
index 04237c7cfb48..3abfc2224923 100644
--- a/connectivity/source/drivers/component/CTable.cxx
+++ b/connectivity/source/drivers/component/CTable.cxx
@@ -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()
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 75c79b6c4bfd..30f35f74c512 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -645,16 +645,16 @@ void ODbaseTable::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 ODbaseColumns(this,m_aMutex,aVector);
+        m_xColumns = new ODbaseColumns(this,m_aMutex,aVector);
 }
 
 void ODbaseTable::refreshIndexes()
 {
     ::std::vector< OUString> aVector;
-    if(m_pFileStream && (!m_pIndexes || m_pIndexes->getCount() == 0))
+    if(m_pFileStream && (!m_xIndexes || m_xIndexes->getCount() == 0))
     {
         INetURLObject aURL;
         aURL.SetURL(getEntry(m_pConnection,m_Name));
@@ -688,10 +688,10 @@ void ODbaseTable::refreshIndexes()
             }
         }
     }
-    if(m_pIndexes)
-        m_pIndexes->reFill(aVector);
+    if(m_xIndexes)
+        m_xIndexes->reFill(aVector);
     else
-        m_pIndexes  = new ODbaseIndexes(this,m_aMutex,aVector);
+        m_xIndexes = new ODbaseIndexes(this,m_aMutex,aVector);
 }
 
 
@@ -1182,7 +1182,7 @@ bool ODbaseTable::CreateFile(const INetURLObject& aFile, bool& bCreateMemo)
     (*m_pFileStream).WriteUChar( aDate.GetMonth() );
     (*m_pFileStream).WriteUChar( aDate.GetDay() );
     (*m_pFileStream).WriteUInt32( 0 );                                    // number of data records
-    (*m_pFileStream).WriteUInt16( (m_pColumns->getCount()+1) * 32 + 1 );  // header information,
+    (*m_pFileStream).WriteUInt16( (m_xColumns->getCount()+1) * 32 + 1 );  // header information,
                                                                           // pColumns contains always an additional column
     (*m_pFileStream).WriteUInt16( 0 );                                     // record length will be determined later
     m_pFileStream->WriteBytes(aBuffer, 20);
@@ -1440,15 +1440,15 @@ bool ODbaseTable::DropImpl()
 {
     FileClose();
 
-    if(!m_pIndexes)
+    if(!m_xIndexes)
         refreshIndexes(); // look for indexes which must be deleted as well
 
-    bool bDropped = Drop_Static(getEntry(m_pConnection,m_Name),HasMemoFields(),m_pIndexes);
+    bool bDropped = Drop_Static(getEntry(m_pConnection,m_Name),HasMemoFields(),m_xIndexes.get());
     if(!bDropped)
     {// we couldn't drop the table so we have to reopen it
         construct();
-        if(m_pColumns)
-            m_pColumns->refresh();
+        if(m_xColumns)
+            m_xColumns->refresh();
     }
     return bDropped;
 }
@@ -1556,12 +1556,12 @@ bool ODbaseTable::DeleteRow(const OSQLColumns& _rCols)
     Reference<XPropertySet> xCol;
     OUString aColName;
     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
-    for (sal_Int32 i = 0; i < m_pColumns->getCount(); i++)
+    for (sal_Int32 i = 0; i < m_xColumns->getCount(); i++)
     {
         Reference<XPropertySet> xIndex = isUniqueByColumnName(i);
         if (xIndex.is())
         {
-            xCol.set(m_pColumns->getByIndex(i), css::uno::UNO_QUERY);
+            xCol.set(m_xColumns->getByIndex(i), css::uno::UNO_QUERY);
             OSL_ENSURE(xCol.is(),"ODbaseTable::DeleteRow column is null!");
             if(xCol.is())
             {
@@ -1595,20 +1595,20 @@ bool ODbaseTable::DeleteRow(const OSQLColumns& _rCols)
 
 Reference<XPropertySet> ODbaseTable::isUniqueByColumnName(sal_Int32 _nColumnPos)
 {
-    if(!m_pIndexes)
+    if(!m_xIndexes)
         refreshIndexes();
-    if(m_pIndexes->hasElements())
+    if(m_xIndexes->hasElements())
     {
         Reference<XPropertySet> xCol;
-        m_pColumns->getByIndex(_nColumnPos) >>= xCol;
+        m_xColumns->getByIndex(_nColumnPos) >>= xCol;
         OSL_ENSURE(xCol.is(),"ODbaseTable::isUniqueByColumnName column is null!");
         OUString sColName;
         xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sColName;
 
         Reference<XPropertySet> xIndex;
-        for(sal_Int32 i=0;i<m_pIndexes->getCount();++i)
+        for(sal_Int32 i=0;i<m_xIndexes->getCount();++i)
         {
-            xIndex.set(m_pIndexes->getByIndex(i), css::uno::UNO_QUERY);
+            xIndex.set(m_xIndexes->getByIndex(i), css::uno::UNO_QUERY);
             if(xIndex.is() && getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))))
             {
                 Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY)->getColumns());
@@ -1638,19 +1638,19 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
     Reference<XPropertySet> xCol;
     Reference<XPropertySet> xIndex;
     OUString aColName;
-    const sal_Int32 nColumnCount = m_pColumns->getCount();
+    const sal_Int32 nColumnCount = m_xColumns->getCount();
     std::vector< Reference<XPropertySet> > aIndexedCols(nColumnCount);
 
     ::comphelper::UStringMixEqual aCase(isCaseSensitive());
 
-    Reference<XIndexAccess> xColumns = m_pColumns;
+    Reference<XIndexAccess> xColumns = m_xColumns.get();
     // first search a key that exist already in the table
     for (sal_Int32 i = 0; i < nColumnCount; ++i)
     {
         sal_Int32 nPos = i;
         if(_xCols != xColumns)
         {
-            m_pColumns->getByIndex(i) >>= xCol;
+            m_xColumns->getByIndex(i) >>= xCol;
             OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
             xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
 
@@ -1686,7 +1686,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
                     // There is no unique value
                     if ( aColName.isEmpty() )
                     {
-                        m_pColumns->getByIndex(i) >>= xCol;
+                        m_xColumns->getByIndex(i) >>= xCol;
                         OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
                         xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
                         xCol.clear();
@@ -1719,7 +1719,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
         }
         else
         {
-            m_pColumns->getByIndex(i) >>= xCol;
+            m_xColumns->getByIndex(i) >>= xCol;
             if ( xCol.is() )
             {
                 xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
@@ -1753,7 +1753,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
         sal_Int32 nPos = i;
         if(_xCols != xColumns)
         {
-            m_pColumns->getByIndex(i) >>= xCol;
+            m_xColumns->getByIndex(i) >>= xCol;
             OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
             xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
             for(nPos = 0;nPos<_xCols->getCount();++nPos)
@@ -1849,7 +1849,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
                 case DataType::DOUBLE:
                     {
                         const double d = thisColVal;
-                        m_pColumns->getByIndex(i) >>= xCol;
+                        m_xColumns->getByIndex(i) >>= xCol;
 
                         if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency is treated separately
                         {
@@ -1889,7 +1889,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
                     }
                     else
                     {
-                        m_pColumns->getByIndex(i) >>= xCol;
+                        m_xColumns->getByIndex(i) >>= xCol;
                         OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
                         xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
                         std::vector< std::pair<const sal_Char* , OUString > > aStringToSubstitutes;
@@ -1952,7 +1952,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
         }
         catch ( const Exception& )
         {
-            m_pColumns->getByIndex(i) >>= xCol;
+            m_xColumns->getByIndex(i) >>= xCol;
             OSL_ENSURE( xCol.is(), "ODbaseTable::UpdateBuffer column is null!" );
             if ( xCol.is() )
                 xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
@@ -2113,11 +2113,11 @@ void SAL_CALL ODbaseTable::alterColumnByName( const OUString& colName, const Ref
 
 
     Reference<XDataDescriptorFactory> xOldColumn;
-    m_pColumns->getByName(colName) >>= xOldColumn;
+    m_xColumns->getByName(colName) >>= xOldColumn;
 
     try
     {
-        alterColumn(m_pColumns->findColumn(colName)-1,descriptor,xOldColumn);
+        alterColumn(m_xColumns->findColumn(colName)-1,descriptor,xOldColumn);
     }
     catch (const css::lang::IndexOutOfBoundsException&)
     {
@@ -2130,11 +2130,11 @@ void SAL_CALL ODbaseTable::alterColumnByIndex( sal_Int32 index, const Reference<
     ::osl::MutexGuard aGuard(m_aMutex);
     checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
 
-    if(index < 0 || index >= m_pColumns->getCount())
+    if(index < 0 || index >= m_xColumns->getCount())
         throw IndexOutOfBoundsException(OUString::number(index),*this);
 
     Reference<XDataDescriptorFactory> xOldColumn;
-    m_pColumns->getByIndex(index) >>= xOldColumn;
+    m_xColumns->getByIndex(index) >>= xOldColumn;
     alterColumn(index,descriptor,xOldColumn);
 }
 
@@ -2142,7 +2142,7 @@ void ODbaseTable::alterColumn(sal_Int32 index,
                               const Reference< XPropertySet >& descriptor ,
                               const Reference< XDataDescriptorFactory >& xOldColumn )
 {
-    if(index < 0 || index >= m_pColumns->getCount())
+    if(index < 0 || index >= m_xColumns->getCount())
         throw IndexOutOfBoundsException(OUString::number(index),*this);
 
     ODbaseTable* pNewTable = nullptr;
@@ -2173,7 +2173,7 @@ void ODbaseTable::alterColumn(sal_Int32 index,
         for(;i < index;++i)
         {
             Reference<XPropertySet> xProp;
-            m_pColumns->getByIndex(i) >>= xProp;
+            m_xColumns->getByIndex(i) >>= xProp;
             Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
             Reference<XPropertySet> xCpy;
             if(xColumn.is())
@@ -2186,10 +2186,10 @@ void ODbaseTable::alterColumn(sal_Int32 index,
         ++i; // now insert our new column
         xAppend->appendByDescriptor(xCopyColumn);
 
-        for(;i < m_pColumns->getCount();++i)
+        for(;i < m_xColumns->getCount();++i)
         {
             Reference<XPropertySet> xProp;
-            m_pColumns->getByIndex(i) >>= xProp;
+            m_xColumns->getByIndex(i) >>= xProp;
             Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
             Reference<XPropertySet> xCpy;
             if(xColumn.is())
@@ -2241,8 +2241,8 @@ void ODbaseTable::alterColumn(sal_Int32 index,
         }
         FileClose();
         construct();
-        if(m_pColumns)
-            m_pColumns->refresh();
+        if(m_xColumns)
+            m_xColumns->refresh();
 
     }
     catch(const SQLException&)
@@ -2274,8 +2274,8 @@ void SAL_CALL ODbaseTable::rename( const OUString& newName )
     ODbaseTable_BASE::rename(newName);
 
     construct();
-    if(m_pColumns)
-        m_pColumns->refresh();
+    if(m_xColumns)
+        m_xColumns->refresh();
 }
 namespace
 {
@@ -2342,10 +2342,10 @@ void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn)
         Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);
         bool bCase = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers();
         // copy the structure
-        for(sal_Int32 i=0;i < m_pColumns->getCount();++i)
+        for(sal_Int32 i=0;i < m_xColumns->getCount();++i)
         {
             Reference<XPropertySet> xProp;
-            m_pColumns->getByIndex(i) >>= xProp;
+            m_xColumns->getByIndex(i) >>= xProp;
             Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
             Reference<XPropertySet> xCpy;
             if(xColumn.is())
@@ -2375,7 +2375,7 @@ void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn)
 
     pNewTable->construct();
     // copy the data
-    copyData(pNewTable,pNewTable->m_pColumns->getCount());
+    copyData(pNewTable,pNewTable->m_xColumns->getCount());
     // drop the old table
     if(DropImpl())
     {
@@ -2386,8 +2386,8 @@ void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn)
 
     FileClose();
     construct();
-    if(m_pColumns)
-        m_pColumns->refresh();
+    if(m_xColumns)
+        m_xColumns->refresh();
 }
 
 void ODbaseTable::dropColumn(sal_Int32 _nPos)
@@ -2401,12 +2401,12 @@ void ODbaseTable::dropColumn(sal_Int32 _nPos)
         Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);
         bool bCase = getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers();
         // copy the structure
-        for(sal_Int32 i=0;i < m_pColumns->getCount();++i)
+        for(sal_Int32 i=0;i < m_xColumns->getCount();++i)
         {
             if(_nPos != i)
             {
                 Reference<XPropertySet> xProp;
-                m_pColumns->getByIndex(i) >>= xProp;
+                m_xColumns->getByIndex(i) >>= xProp;
                 Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
                 Reference<XPropertySet> xCpy;
                 if(xColumn.is())
@@ -2470,11 +2470,11 @@ OUString ODbaseTable::createTempFile()
 void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos)
 {
     sal_Int32 nPos = _nPos + 1; // +1 because we always have the bookmark column as well
-    OValueRefRow aRow = new OValueRefVector(m_pColumns->getCount());
+    OValueRefRow aRow = new OValueRefVector(m_xColumns->getCount());
     OValueRefRow aInsertRow;
     if(_nPos)
     {
-        aInsertRow = new OValueRefVector(_pNewTable->m_pColumns->getCount());
+        aInsertRow = new OValueRefVector(_pNewTable->m_xColumns->getCount());
         std::for_each(aInsertRow->get().begin(),aInsertRow->get().end(),TSetRefBound(true));
     }
     else
@@ -2510,7 +2510,7 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos)
                         }
                     }
                 }
-                bOk = _pNewTable->InsertRow(*aInsertRow,_pNewTable->m_pColumns);
+                bOk = _pNewTable->InsertRow(*aInsertRow,_pNewTable->m_xColumns.get());
                 SAL_WARN_IF(!bOk, "connectivity.drivers", "Row could not be inserted!");
             }
             else
diff --git a/connectivity/source/drivers/evoab2/NTable.cxx b/connectivity/source/drivers/evoab2/NTable.cxx
index f6394a972d32..f46189857231 100644
--- a/connectivity/source/drivers/evoab2/NTable.cxx
+++ b/connectivity/source/drivers/evoab2/NTable.cxx
@@ -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: */
diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx
index 8d4bded8b121..9ddadb19b86e 100644
--- a/connectivity/source/drivers/file/FTable.cxx
+++ b/connectivity/source/drivers/file/FTable.cxx
@@ -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()
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index 76aebaa2b7ef..7726759e1cf6 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -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 --------------------------------------------------------------
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
index 9801a37e4516..d4be4dcb62f2 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -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);
 }
 
 
diff --git a/connectivity/source/drivers/hsqldb/HTable.cxx b/connectivity/source/drivers/hsqldb/HTable.cxx
index ce9dd4187670..561d15893832 100644
--- a/connectivity/source/drivers/hsqldb/HTable.cxx
+++ b/connectivity/source/drivers/hsqldb/HTable.cxx
@@ -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);
         }
     }
 
diff --git a/connectivity/source/drivers/macab/MacabTable.cxx b/connectivity/source/drivers/macab/MacabTable.cxx
index 7b52de538264..c3bf64203d38 100644
--- a/connectivity/source/drivers/macab/MacabTable.cxx
+++ b/connectivity/source/drivers/macab/MacabTable.cxx
@@ -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: */
diff --git a/connectivity/source/drivers/mysql/YTable.cxx b/connectivity/source/drivers/mysql/YTable.cxx
index 9387e3e52cbb..a6db7380e2fe 100644
--- a/connectivity/source/drivers/mysql/YTable.cxx
+++ b/connectivity/source/drivers/mysql/YTable.cxx
@@ -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);
         }
     }
 
diff --git a/connectivity/source/sdbcx/VTable.cxx b/connectivity/source/sdbcx/VTable.cxx
index 26e2db8b507f..371a28ecf54e 100644
--- a/connectivity/source/sdbcx/VTable.cxx
+++ b/connectivity/source/sdbcx/VTable.cxx
@@ -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
diff --git a/dbaccess/source/core/api/table.cxx b/dbaccess/source/core/api/table.cxx
index 5ea0353b7e06..c2f13dcf9bdc 100644
--- a/dbaccess/source/core/api/table.cxx
+++ b/dbaccess/source/core/api/table.cxx
@@ -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 )
diff --git a/include/connectivity/sdbcx/VTable.hxx b/include/connectivity/sdbcx/VTable.hxx
index ef6ed925cd67..0fe70a36e86a 100644
--- a/include/connectivity/sdbcx/VTable.hxx
+++ b/include/connectivity/sdbcx/VTable.hxx
@@ -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;


More information about the Libreoffice-commits mailing list