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

Julien Nabet serval2412 at yahoo.fr
Sat Mar 10 15:53:16 UTC 2018


 dbaccess/source/ui/misc/UITools.cxx                        |   24 --
 dbaccess/source/ui/misc/WCPage.cxx                         |   15 -
 dbaccess/source/ui/misc/WColumnSelect.cxx                  |   20 -
 dbaccess/source/ui/misc/WCopyTable.cxx                     |   63 ++---
 dbaccess/source/ui/misc/WNameMatch.cxx                     |   46 ++-
 dbaccess/source/ui/misc/WTypeSelect.cxx                    |   20 -
 dbaccess/source/ui/misc/indexcollection.cxx                |   11 
 dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx    |   17 +
 dbaccess/source/ui/querydesign/JoinController.cxx          |   31 +-
 dbaccess/source/ui/querydesign/JoinExchange.cxx            |    8 
 dbaccess/source/ui/querydesign/JoinTableView.cxx           |   92 ++-----
 dbaccess/source/ui/querydesign/QueryDesignView.cxx         |   15 -
 dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx      |    8 
 dbaccess/source/ui/querydesign/QueryTableView.cxx          |   43 +--
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx      |  153 +++++--------
 dbaccess/source/ui/querydesign/TableConnection.cxx         |   22 -
 dbaccess/source/ui/querydesign/TableConnectionData.cxx     |   27 --
 dbaccess/source/ui/querydesign/TableFieldDescription.cxx   |    8 
 dbaccess/source/ui/querydesign/TableWindowAccess.cxx       |   19 +
 dbaccess/source/ui/querydesign/querycontroller.cxx         |   13 -
 dbaccess/source/ui/relationdesign/RTableConnectionData.cxx |   12 -
 dbaccess/source/ui/tabledesign/TableController.cxx         |   14 -
 22 files changed, 301 insertions(+), 380 deletions(-)

New commits:
commit ba98f6e3e4dbfc23474e13d59bb08c618ee8c4e5
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Mar 10 14:49:40 2018 +0100

    Modernize a bit more dbaccess (part2)
    
    mainly by using for-range loops but also by simplifying some simple algo
    
    Change-Id: If5ce6d901761db2b872a99e6de0eb6d2f098df99
    Reviewed-on: https://gerrit.libreoffice.org/51044
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index fccb5260b191..9f5c205b338b 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -407,13 +407,11 @@ TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
     {
         ::comphelper::UStringMixEqual aCase(false);
         // search for typeinfo where the typename is equal _sTypeName
-        OTypeInfoMap::const_iterator typeInfoLoop = _rTypeInfo.begin();
-        OTypeInfoMap::const_iterator typeInfoEnd  = _rTypeInfo.end();
-        for (; typeInfoLoop != typeInfoEnd; ++typeInfoLoop)
+        for (auto const& elem : _rTypeInfo)
         {
-            if ( aCase( typeInfoLoop->second->getDBName() , _sTypeName ) )
+            if ( aCase( elem.second->getDBName() , _sTypeName ) )
             {
-                pTypeInfo = typeInfoLoop->second;
+                pTypeInfo = elem.second;
                 break;
             }
         }
@@ -1104,24 +1102,22 @@ TOTypeInfoSP queryPrimaryKeyType(const OTypeInfoMap& _rTypeInfo)
 {
     TOTypeInfoSP pTypeInfo;
     // first we search for a type which supports autoIncrement
-    OTypeInfoMap::const_iterator aIter = _rTypeInfo.begin();
-    OTypeInfoMap::const_iterator aEnd  = _rTypeInfo.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& elem : _rTypeInfo)
     {
         // OJ: we don't want to set an autoincrement column to be key
         // because we don't have the possibility to know how to create
         // such auto increment column later on
         // so until we know how to do it, we create a column without autoincrement
         // therefore we have searched
-        if ( aIter->second->nType == DataType::INTEGER )
+        if ( elem.second->nType == DataType::INTEGER )
         {
-            pTypeInfo = aIter->second; // alternative
+            pTypeInfo = elem.second; // alternative
             break;
         }
-        else if ( !pTypeInfo.get() && aIter->second->nType == DataType::DOUBLE )
-            pTypeInfo = aIter->second; // alternative
-        else if ( !pTypeInfo.get() && aIter->second->nType == DataType::REAL )
-            pTypeInfo = aIter->second; // alternative
+        else if ( !pTypeInfo.get() && elem.second->nType == DataType::DOUBLE )
+            pTypeInfo = elem.second; // alternative
+        else if ( !pTypeInfo.get() && elem.second->nType == DataType::REAL )
+            pTypeInfo = elem.second; // alternative
     }
     if ( !pTypeInfo.get() ) // just a fallback
         pTypeInfo = queryTypeInfoByType(DataType::VARCHAR,_rTypeInfo);
diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx
index db79ea254e0f..0d1a62abbab3 100644
--- a/dbaccess/source/ui/misc/WCPage.cxx
+++ b/dbaccess/source/ui/misc/WCPage.cxx
@@ -274,18 +274,18 @@ bool OCopyTable::checkAppendData()
         ObjectCopySource aTableCopySource( m_pParent->m_xDestConnection, xTable );
         m_pParent->loadData( aTableCopySource, m_pParent->m_vDestColumns, m_pParent->m_aDestVec );
         const ODatabaseExport::TColumnVector& rDestColumns          = m_pParent->getDestVector();
-        ODatabaseExport::TColumnVector::const_iterator aDestIter    = rDestColumns.begin();
-        ODatabaseExport::TColumnVector::const_iterator aDestEnd     = rDestColumns.end();
-        const sal_uInt32 nDestSize = rDestColumns.size();
+        const sal_uInt32 nMinSrcDestSize = std::min<sal_uInt32>(nSrcSize, rDestColumns.size());
         sal_uInt32 i = 0;
-        for(sal_Int32 nPos = 1;aDestIter != aDestEnd && i < nDestSize && i < nSrcSize;++aDestIter,++nPos,++i)
+        for (auto const& column : rDestColumns)
         {
+            if (i >= nMinSrcDestSize)
+                break;
             bool bNotConvert = true;
-            m_pParent->m_vColumnPositions[i] = ODatabaseExport::TPositions::value_type(nPos,nPos);
-            TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert);
+            m_pParent->m_vColumnPositions[i] = ODatabaseExport::TPositions::value_type(i+1,i+1);
+            TOTypeInfoSP pTypeInfo = m_pParent->convertType(column->second->getSpecialTypeInfo(),bNotConvert);
             if ( !bNotConvert )
             {
-                m_pParent->showColumnTypeNotSupported((*aDestIter)->first);
+                m_pParent->showColumnTypeNotSupported(column->first);
                 return false;
             }
 
@@ -293,6 +293,7 @@ bool OCopyTable::checkAppendData()
                 m_pParent->m_vColumnTypes[i] = pTypeInfo->nType;
             else
                 m_pParent->m_vColumnTypes[i] = DataType::VARCHAR;
+            ++i;
         }
 
     }
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
index 032737555f47..b790b651bbcc 100644
--- a/dbaccess/source/ui/misc/WColumnSelect.cxx
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -123,13 +123,11 @@ void OWizColumnSelect::Reset()
 
     // insert the source columns in the left listbox
     const ODatabaseExport::TColumnVector& rSrcColumns = m_pParent->getSrcVector();
-    ODatabaseExport::TColumnVector::const_iterator aIter = rSrcColumns.begin();
-    ODatabaseExport::TColumnVector::const_iterator aEnd = rSrcColumns.end();
 
-    for(;aIter != aEnd;++aIter)
+    for (auto const& column : rSrcColumns)
     {
-        const sal_Int32 nPos = m_pOrgColumnNames->InsertEntry((*aIter)->first);
-        m_pOrgColumnNames->SetEntryData(nPos,(*aIter)->second);
+        const sal_Int32 nPos = m_pOrgColumnNames->InsertEntry(column->first);
+        m_pOrgColumnNames->SetEntryData(nPos,column->second);
     }
 
     if(m_pOrgColumnNames->GetEntryCount())
@@ -155,15 +153,13 @@ void OWizColumnSelect::ActivatePage( )
     // we want to avoid to list the new column generated in the next page
     const ODatabaseExport::TColumns& rSrcColumns = m_pParent->getSourceColumns();
 
-    ODatabaseExport::TColumnVector::const_iterator aIter = rDestColumns.begin();
-    ODatabaseExport::TColumnVector::const_iterator aEnd = rDestColumns.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& column : rDestColumns)
     {
-        if (rSrcColumns.find((*aIter)->first) != rSrcColumns.end())
+        if (rSrcColumns.find(column->first) != rSrcColumns.end())
         {
-            const sal_Int32 nPos = m_pNewColumnNames->InsertEntry((*aIter)->first);
-            m_pNewColumnNames->SetEntryData(nPos,new OFieldDescription(*((*aIter)->second)));
-            m_pOrgColumnNames->RemoveEntry((*aIter)->first);
+            const sal_Int32 nPos = m_pNewColumnNames->InsertEntry(column->first);
+            m_pNewColumnNames->SetEntryData(nPos,new OFieldDescription(*(column->second)));
+            m_pOrgColumnNames->RemoveEntry(column->first);
         }
     }
     m_pParent->GetOKButton().Enable(m_pNewColumnNames->GetEntryCount() != 0);
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index f6f21d745dbd..2d3bc6bf45a5 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -83,11 +83,8 @@ namespace
 {
     void clearColumns(ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColumnsVec)
     {
-        ODatabaseExport::TColumns::const_iterator aIter = _rColumns.begin();
-        ODatabaseExport::TColumns::const_iterator aEnd  = _rColumns.end();
-
-        for(;aIter != aEnd;++aIter)
-            delete aIter->second;
+        for (auto const& column : _rColumns)
+            delete column.second;
 
         _rColumnsVec.clear();
         _rColumns.clear();
@@ -341,11 +338,9 @@ void NamedTableCopySource::impl_ensureColumnInfo_throw()
 Sequence< OUString > NamedTableCopySource::getColumnNames() const
 {
     Sequence< OUString > aNames( m_aColumnInfo.size() );
-    for (   std::vector< OFieldDescription >::const_iterator col = m_aColumnInfo.begin();
-            col != m_aColumnInfo.end();
-            ++col
-        )
-        aNames[ col - m_aColumnInfo.begin() ] = col->GetName();
+    size_t nPos = 0;
+    for (auto const& elem : m_aColumnInfo)
+        aNames[ nPos++ ] = elem.GetName();
 
     return aNames;
 }
@@ -375,12 +370,9 @@ Sequence< OUString > NamedTableCopySource::getPrimaryKeyColumnNames() const
 
 OFieldDescription* NamedTableCopySource::createFieldDescription( const OUString& _rColumnName ) const
 {
-    for (   std::vector< OFieldDescription >::const_iterator col = m_aColumnInfo.begin();
-            col != m_aColumnInfo.end();
-            ++col
-        )
-        if ( col->GetName() == _rColumnName )
-            return new OFieldDescription( *col );
+    for (auto const& elem : m_aColumnInfo)
+        if ( elem.GetName() == _rColumnName )
+            return new OFieldDescription(elem);
 
     return nullptr;
 }
@@ -612,11 +604,9 @@ OCopyTableWizard::OCopyTableWizard( vcl::Window* pParent, const OUString& _rDefa
     ,m_bCreatePrimaryKeyColumn(false)
 {
     construct();
-    ODatabaseExport::TColumnVector::const_iterator aIter = _rSourceColVec.begin();
-    ODatabaseExport::TColumnVector::const_iterator aEnd = _rSourceColVec.end();
-    for (; aIter != aEnd ; ++aIter)
+    for (auto const& sourceCol : _rSourceColVec)
     {
-        m_vSourceVec.emplace_back(m_vSourceColumns.find((*aIter)->first));
+        m_vSourceVec.emplace_back(m_vSourceColumns.find(sourceCol->first));
     }
 
     ::dbaui::fillTypeInfo( _xConnection, m_sTypeNames, m_aTypeInfo, m_aTypeInfoIndex );
@@ -792,11 +782,9 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos)
 
         if ( bContainsColumns )
         {   // we have dest columns so look for the matching column
-            ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin();
-            ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end();
-            for(;aSrcIter != aSrcEnd;++aSrcIter)
+            for (auto const& elemSource : m_vSourceVec)
             {
-                ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(m_mNameMapping[(*aSrcIter)->first]);
+                ODatabaseExport::TColumns::const_iterator aDestIter = m_vDestColumns.find(m_mNameMapping[elemSource->first]);
 
                 if ( aDestIter != m_vDestColumns.end() )
                 {
@@ -818,13 +806,12 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos)
             OUString sExtraChars = xMetaData->getExtraNameCharacters();
             sal_Int32 nMaxNameLen       = getMaxColumnNameLength();
 
-            ODatabaseExport::TColumnVector::const_iterator aSrcIter = m_vSourceVec.begin();
-            ODatabaseExport::TColumnVector::const_iterator aSrcEnd = m_vSourceVec.end();
-            for(_rnBreakPos=0;aSrcIter != aSrcEnd && bRet ;++aSrcIter,++_rnBreakPos)
+            _rnBreakPos=0;
+            for (auto const& elemSource : m_vSourceVec)
             {
-                OFieldDescription* pField = new OFieldDescription(*(*aSrcIter)->second);
-                pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),(*aSrcIter)->first,sExtraChars,nMaxNameLen));
-                TOTypeInfoSP pType = convertType((*aSrcIter)->second->getSpecialTypeInfo(),bRet);
+                OFieldDescription* pField = new OFieldDescription(*elemSource->second);
+                pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),elemSource->first,sExtraChars,nMaxNameLen));
+                TOTypeInfoSP pType = convertType(elemSource->second->getSpecialTypeInfo(),bRet);
                 pField->SetType(pType);
                 if ( !bPKeyAllowed )
                     pField->SetPrimaryKey(false);
@@ -832,7 +819,10 @@ bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos)
                 // now create a column
                 insertColumn(m_vDestColumns.size(),pField);
                 m_vColumnPositions.emplace_back(m_vDestColumns.size(),m_vDestColumns.size());
-                m_vColumnTypes.push_back((*aSrcIter)->second->GetType());
+                m_vColumnTypes.push_back(elemSource->second->GetType());
+                ++_rnBreakPos;
+                if (!bRet)
+                    break;
             }
         }
     }
@@ -1031,9 +1021,8 @@ void OCopyTableWizard::replaceColumn(sal_Int32 _nPos,OFieldDescription* _pField,
 
 void OCopyTableWizard::loadData(  const ICopyTableSourceObject& _rSourceObject, ODatabaseExport::TColumns& _rColumns, ODatabaseExport::TColumnVector& _rColVector )
 {
-    ODatabaseExport::TColumns::const_iterator colEnd = _rColumns.end();
-    for ( ODatabaseExport::TColumns::const_iterator col = _rColumns.begin(); col != colEnd; ++col )
-        delete col->second;
+    for (auto const& column : _rColumns)
+        delete column.second;
 
     _rColVector.clear();
     _rColumns.clear();
@@ -1108,11 +1097,9 @@ void OCopyTableWizard::appendColumns( Reference<XColumnsSupplier> const & _rxCol
     Reference<XAppend> xAppend(xColumns,UNO_QUERY);
     OSL_ENSURE(xAppend.is(),"No XAppend Interface!");
 
-    ODatabaseExport::TColumnVector::const_iterator aIter = _pVec->begin();
-    ODatabaseExport::TColumnVector::const_iterator aEnd = _pVec->end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& elem : *_pVec)
     {
-        OFieldDescription* pField = (*aIter)->second;
+        OFieldDescription* pField = elem->second;
         if(!pField)
             continue;
 
diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx
index e2d565852220..fa1a3b83370e 100644
--- a/dbaccess/source/ui/misc/WNameMatch.cxx
+++ b/dbaccess/source/ui/misc/WNameMatch.cxx
@@ -153,34 +153,44 @@ bool OWizNameMatching::LeavePage()
         OFieldDescription* pSrcField = static_cast<OFieldDescription*>(pLeftEntry->GetUserData());
         OSL_ENSURE(pSrcField,"OWizNameMatching: OColumn can not be null!");
 
-        ODatabaseExport::TColumnVector::const_iterator aSrcIter = rSrcColumns.begin();
-        ODatabaseExport::TColumnVector::const_iterator aSrcEnd  = rSrcColumns.end();
-        for(;aSrcIter != aSrcEnd && (*aSrcIter)->second != pSrcField;++aSrcIter)
-            ;
-        const sal_Int32 nPos = std::distance(rSrcColumns.begin(),aSrcIter);
+        sal_Int32 nPos = 0;
+        for (auto const& column : rSrcColumns)
+        {
+            if (column->second == pSrcField)
+                break;
+            ++nPos;
+        }
 
         if(m_pCTRL_LEFT->GetCheckButtonState(pLeftEntry) == SvButtonState::Checked)
         {
             OFieldDescription* pDestField = static_cast<OFieldDescription*>(pRightEntry->GetUserData());
             OSL_ENSURE(pDestField,"OWizNameMatching: OColumn can not be null!");
             const ODatabaseExport::TColumnVector& rDestColumns          = m_pParent->getDestVector();
-            ODatabaseExport::TColumnVector::const_iterator aDestIter    = rDestColumns.begin();
-            ODatabaseExport::TColumnVector::const_iterator aDestEnd = rDestColumns.end();
-
-            for(;aDestIter != aDestEnd && (*aDestIter)->second != pDestField;++aDestIter)
-                ;
+            sal_Int32 nPosDest = 1;
+            bool bDestColumnFound = false;
+            TOTypeInfoSP typeInfoSPFound;
+            for (auto const& column : rDestColumns)
+            {
+                if (column->second == pDestField)
+                {
+                    bDestColumnFound = true;
+                    typeInfoSPFound = column->second->getSpecialTypeInfo();
+                    break;
+                }
+                ++nPosDest;
+            }
 
             OSL_ENSURE((nPos) < static_cast<sal_Int32>(m_pParent->m_vColumnPositions.size()),"m_pParent->m_vColumnPositions: Illegal index for vector");
             m_pParent->m_vColumnPositions[nPos].first = ++nParamPos;
-            m_pParent->m_vColumnPositions[nPos].second = std::distance(rDestColumns.begin(),aDestIter) + 1;
+            m_pParent->m_vColumnPositions[nPos].second = nPosDest;
 
             TOTypeInfoSP pTypeInfo;
 
-            assert(aDestIter != aDestEnd);
-            if (aDestIter != aDestEnd)
+            assert(bDestColumnFound);
+            if (bDestColumnFound)
             {
                 bool bNotConvert = true;
-                pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(), bNotConvert);
+                pTypeInfo = m_pParent->convertType(typeInfoSPFound, bNotConvert);
             }
 
             sal_Int32 nType = css::sdbc::DataType::VARCHAR;
@@ -391,12 +401,10 @@ bool OColumnTreeBox::Select( SvTreeListEntry* pEntry, bool bSelect )
 void OColumnTreeBox::FillListBox( const ODatabaseExport::TColumnVector& _rList)
 {
     Clear();
-    ODatabaseExport::TColumnVector::const_iterator aIter = _rList.begin();
-    ODatabaseExport::TColumnVector::const_iterator aEnd = _rList.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& elem : _rList)
     {
-        SvTreeListEntry* pEntry = InsertEntry((*aIter)->first, nullptr, false, TREELIST_APPEND, (*aIter)->second);
-        SvButtonState eState = !(m_bReadOnly && (*aIter)->second->IsAutoIncrement()) ? SvButtonState::Checked : SvButtonState::Unchecked;
+        SvTreeListEntry* pEntry = InsertEntry(elem->first, nullptr, false, TREELIST_APPEND, elem->second);
+        SvButtonState eState = !(m_bReadOnly && elem->second->IsAutoIncrement()) ? SvButtonState::Checked : SvButtonState::Unchecked;
         SetCheckButtonState( pEntry, eState );
     }
 }
diff --git a/dbaccess/source/ui/misc/WTypeSelect.cxx b/dbaccess/source/ui/misc/WTypeSelect.cxx
index ac8dc40612a1..4507c4f7c8c2 100644
--- a/dbaccess/source/ui/misc/WTypeSelect.cxx
+++ b/dbaccess/source/ui/misc/WTypeSelect.cxx
@@ -152,15 +152,13 @@ void OWizTypeSelectControl::CellModified(long nRow, sal_uInt16 nColId )
                 static_cast<OWizTypeSelect*>(m_pParentTabPage.get())->setDuplicateName(false);
 
                 // now we change the name
-                OCopyTableWizard::TNameMapping::iterator aIter = pWiz->m_mNameMapping.begin();
-                OCopyTableWizard::TNameMapping::const_iterator aEnd  = pWiz->m_mNameMapping.end();
 
                 ::comphelper::UStringMixEqual aCase(bCase);
-                for(;aIter != aEnd;++aIter)
+                for (auto & elem : pWiz->m_mNameMapping)
                 {
-                    if ( aCase(aIter->second,sName) )
+                    if ( aCase(elem.second,sName) )
                     {
-                        aIter->second = sNewName;
+                        elem.second = sNewName;
                         break;
                     }
                 }
@@ -299,14 +297,12 @@ void OWizTypeSelect::Reset()
     m_pParent->CheckColumns(nBreakPos);
 
     const ODatabaseExport::TColumnVector& rDestColumns = m_pParent->getDestVector();
-    ODatabaseExport::TColumnVector::const_iterator aIter = rDestColumns.begin();
-    ODatabaseExport::TColumnVector::const_iterator aEnd = rDestColumns.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& column : rDestColumns)
     {
-        const sal_Int32 nPos = (*aIter)->second->IsPrimaryKey()
-            ? m_pColumnNames->InsertEntry((*aIter)->first, m_imgPKey )
-            : m_pColumnNames->InsertEntry((*aIter)->first);
-        m_pColumnNames->SetEntryData(nPos,(*aIter)->second);
+        const sal_Int32 nPos = column->second->IsPrimaryKey()
+            ? m_pColumnNames->InsertEntry(column->first, m_imgPKey )
+            : m_pColumnNames->InsertEntry(column->first);
+        m_pColumnNames->SetEntryData(nPos,column->second);
     }
     m_bFirstTime = false;
 }
diff --git a/dbaccess/source/ui/misc/indexcollection.cxx b/dbaccess/source/ui/misc/indexcollection.cxx
index c68a96716dfa..76e6176f0866 100644
--- a/dbaccess/source/ui/misc/indexcollection.cxx
+++ b/dbaccess/source/ui/misc/indexcollection.cxx
@@ -148,19 +148,16 @@ namespace dbaui
             xIndexDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(_rPos->sName));
 
             // the fields
-            for (   IndexFields::const_iterator aFieldLoop = _rPos->aFields.begin();
-                    aFieldLoop != _rPos->aFields.end();
-                    ++aFieldLoop
-                )
+            for (auto const& field : _rPos->aFields)
             {
-                OSL_ENSURE(!xCols->hasByName(aFieldLoop->sFieldName), "OIndexCollection::commitNewIndex: double column name (need to prevent this outside)!");
+                OSL_ENSURE(!xCols->hasByName(field.sFieldName), "OIndexCollection::commitNewIndex: double column name (need to prevent this outside)!");
 
                 Reference< XPropertySet > xColDescriptor = xColumnFactory->createDataDescriptor();
                 OSL_ENSURE(xColDescriptor.is(), "OIndexCollection::commitNewIndex: invalid column descriptor!");
                 if (xColDescriptor.is())
                 {
-                    xColDescriptor->setPropertyValue("IsAscending", css::uno::makeAny(aFieldLoop->bSortAscending));
-                    xColDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(aFieldLoop->sFieldName));
+                    xColDescriptor->setPropertyValue("IsAscending", css::uno::makeAny(field.bSortAscending));
+                    xColDescriptor->setPropertyValue(s_sNamePropertyName, makeAny(field.sFieldName));
                     xAppendCols->appendByDescriptor(xColDescriptor);
                 }
             }
diff --git a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
index 366c827a9744..ddebfc064ddd 100644
--- a/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
+++ b/dbaccess/source/ui/querydesign/ConnectionLineAccess.cxx
@@ -77,13 +77,20 @@ namespace dbaui
         if( m_pLine )
         {
             // search the position of our table window in the table window map
+            // TODO JNA Shouldn't nIndex begin at 0?
             nIndex = m_pLine->GetParent()->GetTabWinMap().size();
             const auto& rVec = m_pLine->GetParent()->getTableConnections();
-            auto aIter = rVec.begin();
-            auto aEnd = rVec.end();
-            for (; aIter != aEnd && (*aIter).get() != m_pLine; ++nIndex,++aIter)
-                ;
-            nIndex = ( aIter != aEnd ) ? nIndex : -1;
+            bool bFound = false;
+            for (auto const& elem : rVec)
+            {
+                if (elem.get() == m_pLine)
+                {
+                    bFound = true;
+                    break;
+                }
+                ++nIndex;
+            }
+            nIndex = bFound ? nIndex : -1;
         }
         return nIndex;
     }
diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx
index 06eace51be38..9575155533c1 100644
--- a/dbaccess/source/ui/querydesign/JoinController.cxx
+++ b/dbaccess/source/ui/querydesign/JoinController.cxx
@@ -292,10 +292,8 @@ void OJoinController::SaveTabWinsPosSize( OJoinTableView::OTableWindowMap* pTabW
     OSL_ENSURE(m_vTableData.size() == pTabWinList->size(),
         "OJoinController::SaveTabWinsPosSize : inconsistent state : should have as many TabWinDatas as TabWins !");
 
-    OJoinTableView::OTableWindowMap::const_iterator aIter = pTabWinList->begin();
-    OJoinTableView::OTableWindowMap::const_iterator aEnd = pTabWinList->end();
-    for(;aIter != aEnd;++aIter)
-        SaveTabWinPosSize(aIter->second, nOffsetX, nOffsetY);
+    for (auto const& tabWin : *pTabWinList)
+        SaveTabWinPosSize(tabWin.second, nOffsetX, nOffsetY);
 }
 
 void OJoinController::removeConnectionData(const TTableConnectionData::value_type& _pData)
@@ -390,21 +388,20 @@ void OJoinController::saveTableWindows( ::comphelper::NamedValueCollection& o_rV
     {
         ::comphelper::NamedValueCollection aAllTablesData;
 
-        TTableWindowData::const_iterator aIter = m_vTableData.begin();
-        TTableWindowData::const_iterator aEnd = m_vTableData.end();
-        for ( sal_Int32 i = 1; aIter != aEnd; ++aIter, ++i )
+        sal_Int32 i = 1;
+        for (auto const& elem : m_vTableData)
         {
             ::comphelper::NamedValueCollection aWindowData;
-            aWindowData.put( "ComposedName", (*aIter)->GetComposedName() );
-            aWindowData.put( "TableName", (*aIter)->GetTableName() );
-            aWindowData.put( "WindowName", (*aIter)->GetWinName() );
-            aWindowData.put( "WindowTop", static_cast<sal_Int32>((*aIter)->GetPosition().Y()) );
-            aWindowData.put( "WindowLeft", static_cast<sal_Int32>((*aIter)->GetPosition().X()) );
-            aWindowData.put( "WindowWidth", static_cast<sal_Int32>((*aIter)->GetSize().Width()) );
-            aWindowData.put( "WindowHeight", static_cast<sal_Int32>((*aIter)->GetSize().Height()) );
-            aWindowData.put( "ShowAll", (*aIter)->IsShowAll() );
-
-            const OUString sTableName( "Table" + OUString::number( i ) );
+            aWindowData.put( "ComposedName", elem->GetComposedName() );
+            aWindowData.put( "TableName", elem->GetTableName() );
+            aWindowData.put( "WindowName", elem->GetWinName() );
+            aWindowData.put( "WindowTop", static_cast<sal_Int32>(elem->GetPosition().Y()) );
+            aWindowData.put( "WindowLeft", static_cast<sal_Int32>(elem->GetPosition().X()) );
+            aWindowData.put( "WindowWidth", static_cast<sal_Int32>(elem->GetSize().Width()) );
+            aWindowData.put( "WindowHeight", static_cast<sal_Int32>(elem->GetSize().Height()) );
+            aWindowData.put( "ShowAll", elem->IsShowAll() );
+
+            const OUString sTableName( "Table" + OUString::number( i++ ) );
             aAllTablesData.put( sTableName, aWindowData.getPropertyValues() );
         }
 
diff --git a/dbaccess/source/ui/querydesign/JoinExchange.cxx b/dbaccess/source/ui/querydesign/JoinExchange.cxx
index 63762020aefb..036943fac4df 100644
--- a/dbaccess/source/ui/querydesign/JoinExchange.cxx
+++ b/dbaccess/source/ui/querydesign/JoinExchange.cxx
@@ -56,13 +56,9 @@ namespace dbaui
 
     bool OJoinExchObj::isFormatAvailable( const DataFlavorExVector& _rFormats ,SotClipboardFormatId _nSlotID)
     {
-        DataFlavorExVector::const_iterator aCheckEnd = _rFormats.end();
-        for (   DataFlavorExVector::const_iterator aCheck = _rFormats.begin();
-                aCheck != aCheckEnd;
-                ++aCheck
-            )
+        for (auto const& format : _rFormats)
         {
-            if ( _nSlotID == aCheck->mnSotId )
+            if ( _nSlotID == format.mnSotId )
                 return true;
         }
         return false;
diff --git a/dbaccess/source/ui/querydesign/JoinTableView.cxx b/dbaccess/source/ui/querydesign/JoinTableView.cxx
index 8de5711da57f..b43fe25ba44d 100644
--- a/dbaccess/source/ui/querydesign/JoinTableView.cxx
+++ b/dbaccess/source/ui/querydesign/JoinTableView.cxx
@@ -228,11 +228,9 @@ void OJoinTableView::Resize()
         // all ok
         return;
 
-    OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
-    OTableWindowMap::const_iterator aEnd = m_aTableMap.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& elem : m_aTableMap)
     {
-        OTableWindow* pCurrent = aIter->second;
+        OTableWindow* pCurrent = elem.second;
         Point aPos(pCurrent->GetData()->GetPosition() - GetScrollOffset());
         pCurrent->SetPosPixel(aPos);
     }
@@ -536,11 +534,9 @@ void OJoinTableView::SetDefaultTabWinPosSize( OTableWindow* pTabWin )
         aRowRect.SetBottom( (nRow+1) * ( TABWIN_SPACING_Y + TABWIN_HEIGHT_STD ) );
 
         // check occupied areas of this line
-        OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
-        OTableWindowMap::const_iterator aEnd = m_aTableMap.end();
-        for(;aIter != aEnd;++aIter)
+        for (auto const& elem : m_aTableMap)
         {
-            OTableWindow* pOtherTabWin = aIter->second;
+            OTableWindow* pOtherTabWin = elem.second;
             tools::Rectangle aOtherTabWinRect( pOtherTabWin->GetPosPixel(), pOtherTabWin->GetSizePixel() );
 
             if(
@@ -700,11 +696,9 @@ bool OJoinTableView::ScrollPane( long nDelta, bool bHoriz, bool bPaintScrollBars
     OTableWindow* pTabWin;
     Point aPos;
 
-    OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
-    OTableWindowMap::const_iterator aEnd = m_aTableMap.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& elem : m_aTableMap)
     {
-        pTabWin = aIter->second;
+        pTabWin = elem.second;
         aPos = pTabWin->GetPosPixel();
 
         if( bHoriz )
@@ -828,17 +822,15 @@ void OJoinTableView::MouseButtonUp( const MouseEvent& rEvt )
     {
         DeselectConn(GetSelectedConn());
 
-        auto aIter = m_vTableConnection.begin();
-        auto aEnd = m_vTableConnection.end();
-        for(;aIter != aEnd;++aIter)
+        for (auto & elem : m_vTableConnection)
         {
-            if( (*aIter)->CheckHit(rEvt.GetPosPixel()) )
+            if( elem->CheckHit(rEvt.GetPosPixel()) )
             {
-                SelectConn(*aIter);
+                SelectConn(elem);
 
                 // Double-click
                 if( rEvt.GetClicks() == 2 )
-                    ConnDoubleClicked( *aIter );
+                    ConnDoubleClicked(elem);
 
                 break;
             }
@@ -981,12 +973,9 @@ void OJoinTableView::ClearAll()
     HideTabWins();
 
     // and the same with the Connections
-    while(true)
+    for (auto & elem : m_vTableConnection)
     {
-        auto aIter = m_vTableConnection.begin();
-        if (aIter == m_vTableConnection.end())
-            break;
-        RemoveConnection(*aIter, true);
+        RemoveConnection(elem, true);
     }
     m_vTableConnection.clear();
 
@@ -1168,15 +1157,13 @@ void OJoinTableView::Command(const CommandEvent& rEvt)
                 DeselectConn(rSelConnection);
 
                 const Point& aMousePos = rEvt.GetMousePosPixel();
-                auto aIter = m_vTableConnection.begin();
-                auto aEnd = m_vTableConnection.end();
-                for(;aIter != aEnd;++aIter)
+                for (auto & elem : m_vTableConnection)
                 {
-                    if( (*aIter)->CheckHit(aMousePos) )
+                    if( elem->CheckHit(aMousePos) )
                     {
-                        SelectConn(*aIter);
+                        SelectConn(elem);
                         if(!getDesignView()->getController().isReadOnly() && getDesignView()->getController().isConnected())
-                            executePopup(rEvt.GetMousePosPixel(),*aIter);
+                            executePopup(rEvt.GetMousePosPixel(),elem);
                         break;
                     }
                 }
@@ -1316,13 +1303,11 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt)
                         {   // no active tab win -> travel the connections
                             // find the currently selected conn within the conn list
                             sal_Int32 i(0);
-                            for (   auto connectionIter = m_vTableConnection.begin();
-                                    connectionIter != m_vTableConnection.end();
-                                    ++connectionIter, ++i
-                                )
+                            for (auto const& elem : m_vTableConnection)
                             {
-                                if ( (*connectionIter).get() == GetSelectedConn() )
+                                if ( elem.get() == GetSelectedConn() )
                                     break;
+                                ++i;
                             }
                             if (i == sal_Int32(m_vTableConnection.size() - 1) && bForward)
                                 // the last conn is active and we're travelling forward -> select the first win
@@ -1398,13 +1383,11 @@ bool OJoinTableView::PreNotify(NotifyEvent& rNEvt)
 
                 if (pSearchFor)
                 {
-                    OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
-                    OTableWindowMap::const_iterator aEnd = m_aTableMap.end();
-                    for(;aIter != aEnd;++aIter)
+                    for (auto const& elem : m_aTableMap)
                     {
-                        if (aIter->second == pSearchFor)
+                        if (elem.second == pSearchFor)
                         {
-                            m_pLastFocusTabWin = aIter->second;
+                            m_pLastFocusTabWin = elem.second;
                             break;
                         }
                     }
@@ -1454,13 +1437,11 @@ void OJoinTableView::StateChanged( StateChangedType nType )
             aFont.Merge( GetControlFont() );
         SetZoomedPointFont(*this, aFont);
 
-        OTableWindowMap::const_iterator aIter = m_aTableMap.begin();
-        OTableWindowMap::const_iterator aEnd = m_aTableMap.end();
-        for(;aIter != aEnd;++aIter)
+        for (auto const& elem : m_aTableMap)
         {
-            aIter->second->SetZoom(GetZoom());
-            Size aSize(CalcZoom(aIter->second->GetSizePixel().Width()),CalcZoom(aIter->second->GetSizePixel().Height()));
-            aIter->second->SetSizePixel(aSize);
+            elem.second->SetZoom(GetZoom());
+            Size aSize(CalcZoom(elem.second->GetSizePixel().Width()),CalcZoom(elem.second->GetSizePixel().Height()));
+            elem.second->SetSizePixel(aSize);
         }
         Resize();
     }
@@ -1474,10 +1455,8 @@ void OJoinTableView::HideTabWins()
 
     // working on a copy because the real list will be cleared in inner calls
     OTableWindowMap aCopy(rTabWins);
-    OTableWindowMap::const_iterator aIter = aCopy.begin();
-    OTableWindowMap::const_iterator aEnd = aCopy.end();
-    for(;aIter != aEnd;++aIter)
-        RemoveTabWin(aIter->second);
+    for (auto const& elem : aCopy)
+        RemoveTabWin(elem.second);
 
     m_pView->getController().setModified(true);
 
@@ -1504,20 +1483,17 @@ void OJoinTableView::clearLayoutInformation()
     m_pLastFocusTabWin  = nullptr;
     m_pSelectedConn     = nullptr;
     // delete lists
-    OTableWindowMap::iterator aIter = m_aTableMap.begin();
-    OTableWindowMap::const_iterator aEnd  = m_aTableMap.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto & elem : m_aTableMap)
     {
-        if ( aIter->second )
-            aIter->second->clearListBox();
-        aIter->second.disposeAndClear();
+        if ( elem.second )
+            elem.second->clearListBox();
+        elem.second.disposeAndClear();
     }
 
     m_aTableMap.clear();
 
-    for(auto i = m_vTableConnection.begin();
-             i != m_vTableConnection.end(); ++i)
-        i->disposeAndClear();
+    for (auto & elem : m_vTableConnection)
+        elem.disposeAndClear();
 
     m_vTableConnection.clear();
 }
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index e26af4db59ae..7a5948c955f6 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -500,11 +500,10 @@ namespace
 
         // first search for the "to" window
         const auto& rConnections = pEntryConn->GetParent()->getTableConnections();
-        auto aIter = rConnections.begin();
-        auto aEnd = rConnections.end();
-        for(;aIter != aEnd;++aIter)
+        bool bFound = false;
+        for (auto const& connection : rConnections)
         {
-            OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>((*aIter).get());
+            OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(connection.get());
             if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabTo || pNext->GetDestWin() == pEntryTabTo))
             {
                 OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabTo ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin());
@@ -512,17 +511,17 @@ namespace
                 JoinCycle(_xConnection,pNext,pEntryTab,aJoin);
                 if(!pNext->IsVisited())
                     GetNextJoin(_xConnection, pNext, pEntryTab, aJoin, _rTableNames);
+                bFound = true;
             }
         }
 
         // when nothing found look for the "from" window
-        if(aIter == aEnd)
+        if(!bFound)
         {
             OQueryTableWindow* pEntryTabFrom = static_cast<OQueryTableWindow*>(pEntryConn->GetSourceWin());
-            aIter = rConnections.begin();
-            for(;aIter != aEnd;++aIter)
+            for (auto const& connection : rConnections)
             {
-                OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>((*aIter).get());
+                OQueryTableConnection* pNext = static_cast<OQueryTableConnection*>(connection.get());
                 if(!pNext->IsVisited() && (pNext->GetSourceWin() == pEntryTabFrom || pNext->GetDestWin() == pEntryTabFrom))
                 {
                     OQueryTableWindow* pEntryTab = pNext->GetSourceWin() == pEntryTabFrom ? static_cast<OQueryTableWindow*>(pNext->GetDestWin()) : static_cast<OQueryTableWindow*>(pNext->GetSourceWin());
diff --git a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
index 0c1303e3b4ce..329b0cfff4ab 100644
--- a/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTabWinUndoAct.cxx
@@ -59,12 +59,10 @@ OQueryTabWinUndoAct::~OQueryTabWinUndoAct()
         m_pTabWin.disposeAndClear();
 
         // and of course the corresponding connections
-        auto aIter = m_vTableConnection.begin();
-        auto aEnd = m_vTableConnection.end();
-        for(;aIter != aEnd;++aIter)
+        for (auto & connection : m_vTableConnection)
         {
-            m_pOwner->DeselectConn(*aIter);
-            aIter->disposeAndClear();
+            m_pOwner->DeselectConn(connection);
+            connection.disposeAndClear();
         }
         m_vTableConnection.clear();
     }
diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx
index 7ac7aff0fb89..5f7beeb47284 100644
--- a/dbaccess/source/ui/querydesign/QueryTableView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx
@@ -295,14 +295,13 @@ void OQueryTableView::NotifyTabConnection(const OQueryTableConnection& rNewConn,
                                 aEnd,
                                 VclPtr<OTableConnection>(const_cast<OTableConnection*>(static_cast<const OTableConnection*>(&rNewConn)))
                             );
-    if(aIter == aEnd )
+    if(aIter == aEnd)
     {
-        aIter = rConnections.begin();
-        for(;aIter != aEnd;++aIter)
+        for (auto const& connection : rConnections)
         {
-            if(*static_cast<OQueryTableConnection*>((*aIter).get()) == rNewConn)
+            if(*static_cast<OQueryTableConnection*>(connection.get()) == rNewConn)
             {
-                pTabConn = static_cast<OQueryTableConnection*>((*aIter).get());
+                pTabConn = static_cast<OQueryTableConnection*>(connection.get());
                 break;
             }
         }
@@ -402,16 +401,17 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString&
     bool bAppend = bNewTable;
     TTableWindowData::value_type pNewTabWinData;
     TTableWindowData& rWindowData = getDesignView()->getController().getTableWindowData();
-    TTableWindowData::const_iterator aWinIter = rWindowData.begin();
-    TTableWindowData::const_iterator aWinEnd = rWindowData.end();
-    for(;aWinIter != aWinEnd;++aWinIter)
+    bool bFoundElem = false;
+    for (auto const& elem : rWindowData)
     {
-        pNewTabWinData = *aWinIter;
-        if (pNewTabWinData && pNewTabWinData->GetWinName() == strAlias && pNewTabWinData->GetComposedName() == _rComposedName && pNewTabWinData->GetTableName() == _rTableName)
+        if (elem && elem->GetWinName() == strAlias && elem->GetComposedName() == _rComposedName && elem->GetTableName() == _rTableName)
+        {
+            bFoundElem = true;
             break;
+        }
     }
     if ( !bAppend )
-        bAppend = ( aWinIter == aWinEnd );
+        bAppend = !bFoundElem;
     if ( bAppend )
         pNewTabWinData = createTableWindowData(_rComposedName, _rTableName, strAlias);
         // I do not need to add TabWinData to the DocShell list, ShowTabWin does that.
@@ -499,11 +499,9 @@ void OQueryTableView::AddTabWin(const OUString& _rComposedName, const OUString&
                 case KeyType::PRIMARY:
                 {
                     // we have a primary key so look in our list if there exists a key which this is referred to
-                    OTableWindowMap::const_iterator aIter = rTabWins.begin();
-                    OTableWindowMap::const_iterator aEnd  = rTabWins.end();
-                    for(;aIter != aEnd;++aIter)
+                    for (auto const& tabWin : rTabWins)
                     {
-                        OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(aIter->second.get());
+                        OQueryTableWindow* pTabWinTmp = static_cast<OQueryTableWindow*>(tabWin.second.get());
                         if ( pTabWinTmp == pNewTabWin )
                             continue;
 
@@ -653,27 +651,22 @@ OQueryTableWindow* OQueryTableView::FindTable(const OUString& rAliasName)
 bool OQueryTableView::FindTableFromField(const OUString& rFieldName, OTableFieldDescRef const & rInfo, sal_uInt16& rCnt)
 {
     rCnt = 0;
-    OTableWindowMap::const_iterator aIter = GetTabWinMap().begin();
-    OTableWindowMap::const_iterator aEnd  = GetTabWinMap().end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& tabWin : GetTabWinMap())
     {
-        if(static_cast<OQueryTableWindow*>(aIter->second.get())->ExistsField(rFieldName, rInfo))
+        if(static_cast<OQueryTableWindow*>(tabWin.second.get())->ExistsField(rFieldName, rInfo))
             ++rCnt;
     }
+    // TODO JNA : what should we rCnt > 1?
 
     return rCnt == 1;
 }
 
 bool OQueryTableView::ContainsTabWin(const OTableWindow& rTabWin)
 {
-    OTableWindowMap& rTabWins = GetTabWinMap();
 
-    OTableWindowMap::const_iterator aIter = rTabWins.begin();
-    OTableWindowMap::const_iterator aEnd  = rTabWins.end();
-
-    for ( ;aIter != aEnd ; ++aIter )
+    for (auto const& tabWin : GetTabWinMap())
     {
-        if ( aIter->second == &rTabWin )
+        if ( tabWin.second == &rTabWin )
         {
             return true;
         }
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 8937943db748..faa0274117b1 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -295,13 +295,19 @@ void OSelectionBrowseBox::ColumnMoved( sal_uInt16 nColId, bool _bCreateUndo )
     if ( rFields.size() > sal_uInt16(nNewPos-1) )
     {
         sal_uInt16 nOldPos = 0;
-        OTableFields::const_iterator aEnd = rFields.end();
-        OTableFields::const_iterator aIter = rFields.begin();
-        for (; aIter != aEnd && ( (*aIter)->GetColumnId() != nColId ); ++aIter,++nOldPos)
-            ;
+        bool bFoundElem = false;
+        for (auto const& field : rFields)
+        {
+            if (field->GetColumnId() == nColId)
+            {
+                bFoundElem = true;
+                break;
+            }
+            ++nOldPos;
+        }
 
         OSL_ENSURE( (nNewPos-1) != nOldPos && nOldPos < rFields.size(),"Old and new position are equal!");
-        if ( aIter != aEnd )
+        if (bFoundElem)
         {
             OTableFieldDescRef pOldEntry = rFields[nOldPos];
             rFields.erase(rFields.begin() + nOldPos);
@@ -492,12 +498,8 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon
             enableControl(pEntry,m_pTableCell);
             if ( !pEntry->isCondition() )
             {
-                OJoinTableView::OTableWindowMap& rTabWinList = getDesignView()->getTableView()->GetTabWinMap();
-                OJoinTableView::OTableWindowMap::const_iterator aIter = rTabWinList.begin();
-                OJoinTableView::OTableWindowMap::const_iterator aEnd = rTabWinList.end();
-
-                for(;aIter != aEnd;++aIter)
-                    m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(aIter->second.get())->GetAliasName());
+                for (auto const& tabWin : getDesignView()->getTableView()->GetTabWinMap())
+                    m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(tabWin.second.get())->GetAliasName());
 
                 m_pTableCell->InsertEntry(DBA_RES(STR_QUERY_NOTABLE), 0);
                 if (!pEntry->GetAlias().isEmpty())
@@ -1589,15 +1591,11 @@ OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _r
 
 sal_uInt16 OSelectionBrowseBox::FieldsCount()
 {
-    OTableFields::const_iterator aIter = getFields().begin();
-    OTableFields::const_iterator aEnd = getFields().end();
     sal_uInt16 nCount = 0;
-
-    while (aIter != aEnd)
+    for (auto const& field : getFields())
     {
-        if ((*aIter).is() && !(*aIter)->IsEmpty())
+        if (field.is() && !field->IsEmpty())
             ++nCount;
-        ++aIter;
     }
 
     return nCount;
@@ -1605,18 +1603,14 @@ sal_uInt16 OSelectionBrowseBox::FieldsCount()
 
 OTableFieldDescRef OSelectionBrowseBox::FindFirstFreeCol(sal_uInt16& _rColumnPosition )
 {
-    OTableFields::const_iterator aIter = getFields().begin();
-    OTableFields::const_iterator aEnd  = getFields().end();
 
     _rColumnPosition = BROWSER_INVALIDID;
 
-    while ( aIter != aEnd )
+    for (auto const& field : getFields())
     {
         ++_rColumnPosition;
-        OTableFieldDescRef pEntry = (*aIter);
-        if ( pEntry.is() && pEntry->IsEmpty() )
-            return pEntry;
-        ++aIter;
+        if ( field.is() && field->IsEmpty() )
+            return field;
     }
 
     return nullptr;
@@ -1643,26 +1637,24 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo )
     const ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
     //sal_Bool bAppend = sal_False;
 
-    OTableFields& rFields = getFields();
-    OTableFields::const_iterator aIter = rFields.begin();
-    OTableFields::const_iterator aEnd = rFields.end();
-    for(;aIter != aEnd;++aIter)
+    bool bAllFieldsSearched = true;
+    for (auto const& field : getFields())
     {
-        pEntry = *aIter;
         OSL_ENSURE(pEntry.is(),"OTableFieldDescRef was null!");
 
-        const OUString   aField = pEntry->GetField();
-        const OUString   aAlias = pEntry->GetAlias();
+        const OUString   aField = field->GetField();
+        const OUString   aAlias = field->GetAlias();
 
         if (bCase(aField,rInfo->GetField()) &&
             bCase(aAlias,rInfo->GetAlias()) &&
-            pEntry->GetFunctionType() == rInfo->GetFunctionType() &&
-            pEntry->GetFunction() == rInfo->GetFunction())
+            field->GetFunctionType() == rInfo->GetFunctionType() &&
+            field->GetFunction() == rInfo->GetFunction())
         {
-            if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
+            if ( field->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
             {
-                pEntry->SetGroupBy(false);
-                aIter = rFields.end();
+                field->SetGroupBy(false);
+                // we do want to consider that bAllFieldsSearched still true here
+                // bAllFieldsSearched = false;
                 break;
             }
             else
@@ -1672,6 +1664,7 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo )
                     pEntry->SetGroupBy(rInfo->IsGroupBy());
                     if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
                         pEntry->SetVisible();
+                    bAllFieldsSearched = false;
                     break;
                 }
             }
@@ -1679,7 +1672,7 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo )
         }
     }
 
-    if (aIter == rFields.end())
+    if (bAllFieldsSearched)
     {
         OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, false, false );
         if ( pTmp->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) // the GroupBy is inherited from rInfo
@@ -1690,17 +1683,12 @@ void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo )
 void OSelectionBrowseBox::DuplicateConditionLevel( const sal_uInt16 nLevel)
 {
     const sal_uInt16 nNewLevel = nLevel +1;
-    OTableFields& rFields = getFields();
-    OTableFields::const_iterator aIter = rFields.begin();
-    OTableFields::const_iterator aEnd = rFields.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& field : getFields())
     {
-        OTableFieldDescRef pEntry = *aIter;
-
-        OUString sValue = pEntry->GetCriteria(nLevel);
+        OUString sValue = field->GetCriteria(nLevel);
         if ( !sValue.isEmpty() )
         {
-            pEntry->SetCriteria( nNewLevel, sValue);
+            field->SetCriteria( nNewLevel, sValue);
             if ( nNewLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1) )
             {
                 RowInserted( GetRowCount()-1 );
@@ -1723,31 +1711,28 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const O
     Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
     ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
 
-    OTableFields& rFields = getFields();
-    OTableFields::const_iterator aIter = rFields.begin();
-    OTableFields::const_iterator aEnd = rFields.end();
-    for(;aIter != aEnd;++aIter)
+    bool bAllFieldsSearched = true;
+    for (auto const& field : getFields())
     {
-        OTableFieldDescRef pEntry = *aIter;
-        const OUString   aField = pEntry->GetField();
-        const OUString   aAlias = pEntry->GetAlias();
+        const OUString   aField = field->GetField();
+        const OUString   aAlias = field->GetAlias();
 
         if (bCase(aField,rInfo->GetField()) &&
             bCase(aAlias,rInfo->GetAlias()) &&
-            pEntry->GetFunctionType() == rInfo->GetFunctionType() &&
-            pEntry->GetFunction() == rInfo->GetFunction() &&
-            pEntry->IsGroupBy() == rInfo->IsGroupBy() )
+            field->GetFunctionType() == rInfo->GetFunctionType() &&
+            field->GetFunction() == rInfo->GetFunction() &&
+            field->IsGroupBy() == rInfo->IsGroupBy() )
         {
-            if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
-                pEntry->SetGroupBy(false);
+            if ( field->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
+                field->SetGroupBy(false);
             else
             {
-                if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
-                    pEntry->SetVisible();
+                if(!m_bGroupByUnRelated && field->IsGroupBy())
+                    field->SetVisible();
             }
-            if (pEntry->GetCriteria(nLevel).isEmpty() )
+            if (field->GetCriteria(nLevel).isEmpty() )
             {
-                pEntry->SetCriteria( nLevel, rValue);
+                field->SetCriteria( nLevel, rValue);
                 if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
                 {
                     RowInserted( GetRowCount()-1 );
@@ -1755,11 +1740,12 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const O
                     ++m_nVisibleCount;
                 }
                 m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = true;
+                bAllFieldsSearched = false;
                 break;
             }
             if ( _bAddOrOnOneLine )
             {
-                pLastEntry = pEntry;
+                pLastEntry = field;
             }
         }
     }
@@ -1780,7 +1766,7 @@ void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const O
         }
         m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = true;
     }
-    else if (aIter == rFields.end())
+    else if (bAllFieldsSearched)
     {
         OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, false, false );
         if ( pTmp->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) // the GroupBy was inherited from rInfo
@@ -1812,34 +1798,37 @@ void OSelectionBrowseBox::AddOrder( const OTableFieldDescRef& rInfo, const EOrde
     ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
 
     bool bAppend = false;
-    OTableFields& rFields = getFields();
-    OTableFields::const_iterator aIter = rFields.begin();
-    OTableFields::const_iterator aEnd = rFields.end();
-    for(;aIter != aEnd;++aIter)
+    sal_uInt32 nPos = 0;
+    bool bAllFieldsSearched = true;
+    for (auto const& field : getFields())
     {
-        pEntry = *aIter;
-        OUString aField = pEntry->GetField();
-        OUString aAlias = pEntry->GetAlias();
+        OUString aField = field->GetField();
+        OUString aAlias = field->GetAlias();
 
         if (bCase(aField,rInfo->GetField()) &&
             bCase(aAlias,rInfo->GetAlias()))
         {
-            sal_uInt32 nPos = aIter - rFields.begin();
             bAppend = (m_nLastSortColumn != SORT_COLUMN_NONE) && (nPos <= m_nLastSortColumn);
             if ( bAppend )
-                aIter = rFields.end();
+            {
+                // we do want to consider that bAllFieldsSearched still true here
+                // bAllFieldsSearched = false;
+                break;
+            }
             else
             {
                 if ( !m_bOrderByUnRelated )
-                    pEntry->SetVisible();
-                pEntry->SetOrderDir( eDir );
+                    field->SetVisible();
+                field->SetOrderDir( eDir );
                 m_nLastSortColumn = nPos;
             }
+            bAllFieldsSearched = false;
             break;
         }
+        ++nPos;
     }
 
-    if (aIter == rFields.end())
+    if (bAllFieldsSearched)
     {
         OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, false, false );
         if(pTmp.is())
@@ -2670,19 +2659,15 @@ Reference< XAccessible > OSelectionBrowseBox::CreateAccessibleCell( sal_Int32 _n
 
 bool OSelectionBrowseBox::HasFieldByAliasName(const OUString& rFieldName, OTableFieldDescRef const & rInfo) const
 {
-    OTableFields& aFields = getFields();
-    OTableFields::const_iterator aIter = aFields.begin();
-    OTableFields::const_iterator aEnd  = aFields.end();
-
-    for(;aIter != aEnd;++aIter)
+    for (auto const& field : getFields())
     {
-        if ( (*aIter)->GetFieldAlias() == rFieldName )
+        if ( field->GetFieldAlias() == rFieldName )
         {
-            *rInfo = *(*aIter);
-            break;
+            *rInfo = *field;
+            return true;
         }
     }
-    return aIter != aEnd;
+    return false;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/TableConnection.cxx b/dbaccess/source/ui/querydesign/TableConnection.cxx
index c7fe03a81d09..21f82f792feb 100644
--- a/dbaccess/source/ui/querydesign/TableConnection.cxx
+++ b/dbaccess/source/ui/querydesign/TableConnection.cxx
@@ -55,18 +55,15 @@ namespace dbaui
     {
         // initialise linelist with defaults
         OConnectionLineDataVec& rLineData = GetData()->GetConnLineDataList();
-        OConnectionLineDataVec::const_iterator aIter = rLineData.begin();
-        OConnectionLineDataVec::const_iterator aEnd = rLineData.end();
         m_vConnLine.reserve(rLineData.size());
-        for(;aIter != aEnd;++aIter)
-            m_vConnLine.push_back( new OConnectionLine(this, *aIter) );
+        for (auto const& elem : rLineData)
+            m_vConnLine.push_back( new OConnectionLine(this, elem) );
     }
 
     void OTableConnection::clearLineData()
     {
-        std::vector<OConnectionLine*>::const_iterator aLineEnd = m_vConnLine.end();
-        for(std::vector<OConnectionLine*>::const_iterator aLineIter = m_vConnLine.begin();aLineIter != aLineEnd;++aLineIter)
-            delete *aLineIter;
+        for (auto const& elem : m_vConnLine)
+            delete elem;
         m_vConnLine.clear();
     }
     void OTableConnection::UpdateLineList()
@@ -89,11 +86,9 @@ namespace dbaui
         if(! rConn.GetConnLineList().empty() )
         {
             const std::vector<OConnectionLine*>& rLine = rConn.GetConnLineList();
-            std::vector<OConnectionLine*>::const_iterator aIter = rLine.begin();
-            std::vector<OConnectionLine*>::const_iterator aEnd = rLine.end();
             m_vConnLine.reserve(rLine.size());
-            for(;aIter != aEnd;++aIter)
-                m_vConnLine.push_back( new OConnectionLine( **aIter ));
+            for (auto const& elem : rLine)
+                m_vConnLine.push_back( new OConnectionLine(*elem));
         }
 
         // as the data are not mine, I also do not delete the old
@@ -172,10 +167,9 @@ namespace dbaui
         // determine all lines of the surrounding rectangle
         tools::Rectangle aBoundingRect( Point(0,0), Point(0,0) );
         tools::Rectangle aTempRect;
-        std::vector<OConnectionLine*>::const_iterator aEnd = m_vConnLine.end();
-        for(std::vector<OConnectionLine*>::const_iterator aIter = m_vConnLine.begin();aIter != aEnd;++aIter)
+        for (auto const& elem : m_vConnLine)
         {
-            aTempRect = (*aIter)->GetBoundingRect();
+            aTempRect = elem->GetBoundingRect();
 
             // is the BoundingRect of this line valid?
             if( (aTempRect.GetWidth()!=1) && (aTempRect.GetHeight()!=1) )
diff --git a/dbaccess/source/ui/querydesign/TableConnectionData.cxx b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
index 812948d9efc8..93bf1b5506b8 100644
--- a/dbaccess/source/ui/querydesign/TableConnectionData.cxx
+++ b/dbaccess/source/ui/querydesign/TableConnectionData.cxx
@@ -74,12 +74,8 @@ OTableConnectionData& OTableConnectionData::operator=( const OTableConnectionDat
     ResetConnLines();
 
     // and copy
-    const OConnectionLineDataVec& rLineData = rConnData.GetConnLineDataList();
-
-    OConnectionLineDataVec::const_iterator aIter = rLineData.begin();
-    OConnectionLineDataVec::const_iterator aEnd = rLineData.end();
-    for(;aIter != aEnd;++aIter)
-        m_vConnLineData.push_back(new OConnectionLineData(**aIter));
+    for (auto const& elem : rConnData.GetConnLineDataList())
+        m_vConnLineData.push_back(new OConnectionLineData(*elem));
 
     return *this;
 }
@@ -106,21 +102,16 @@ void OTableConnectionData::SetConnLine( sal_uInt16 nIndex, const OUString& rSour
 
 bool OTableConnectionData::AppendConnLine( const OUString& rSourceFieldName, const OUString& rDestFieldName )
 {
-    OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin();
-    OConnectionLineDataVec::const_iterator aEnd = m_vConnLineData.end();
-    for(;aIter != aEnd;++aIter)
+    for (auto const& elem : m_vConnLineData)
     {
-        if((*aIter)->GetDestFieldName() == rDestFieldName && (*aIter)->GetSourceFieldName() == rSourceFieldName)
-            break;
+        if(elem->GetDestFieldName() == rDestFieldName && elem->GetSourceFieldName() == rSourceFieldName)
+            return true;
     }
-    if(aIter == aEnd)
-    {
-        OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName);
-        if (!pNew.is())
-            return false;
+    OConnectionLineDataRef pNew = new OConnectionLineData(rSourceFieldName, rDestFieldName);
+    if (!pNew.is())
+        return false;
 
-        m_vConnLineData.push_back(pNew);
-    }
+    m_vConnLineData.push_back(pNew);
     return true;
 }
 
diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
index 9c09c4b7e076..ca4c89ac81df 100644
--- a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
+++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
@@ -181,13 +181,11 @@ void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings, con
         {
             sal_Int32 c = 0;
             Sequence< PropertyValue > aCriteria( m_aCriteria.size() );
-            for (   std::vector< OUString >::const_iterator crit = m_aCriteria.begin();
-                    crit != m_aCriteria.end();
-                    ++crit, ++c
-                )
+            for (auto const& criteria : m_aCriteria)
             {
                 aCriteria[c].Name = "Criterion_" + OUString::number( c );
-                aCriteria[c].Value <<= *crit;
+                aCriteria[c].Value <<= criteria;
+                ++c;
             }
 
             o_rSettings.put( "Criteria", aCriteria );
diff --git a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
index 8c227da3957c..42c68d06d13b 100644
--- a/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
+++ b/dbaccess/source/ui/querydesign/TableWindowAccess.cxx
@@ -126,12 +126,17 @@ namespace dbaui
         if( m_pTable )
         {
             // search the position of our table window in the table window map
-            OJoinTableView::OTableWindowMap& rMap = m_pTable->getTableView()->GetTabWinMap();
-            OJoinTableView::OTableWindowMap::const_iterator aIter = rMap.begin();
-            OJoinTableView::OTableWindowMap::const_iterator aEnd = rMap.end();
-            for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter)
-                ;
-            nIndex = aIter != aEnd ? nIndex : -1;
+            bool bFoundElem = false;
+            for (auto const& tabWin : m_pTable->getTableView()->GetTabWinMap())
+            {
+                if (tabWin.second == m_pTable)
+                {
+                    bFoundElem = true;
+                    break;
+                }
+                ++nIndex;
+            }
+            nIndex = bFoundElem? nIndex : -1;
         }
         return nIndex;
     }
@@ -215,6 +220,8 @@ namespace dbaui
             auto aEnd = rConnectionList.end();
             std::vector< Reference<XInterface> > aRelations;
             aRelations.reserve(5); // just guessing
+            // TODO JNA aIter comes from pView->getTableConnections(m_pTable)
+            // and aEnd comes from pView->getTableConnections().end()
             for (; aIter != aEnd ; ++aIter )
             {
                 uno::Reference<uno::XInterface> xInterface(
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index 0102620d8f11..7f96f3f481b6 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -599,7 +599,7 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >&
                         else
                         {
                             const OSQLTables& rTabs = m_pSqlIterator->getTables();
-                            if ( m_pSqlIterator->getStatementType() != OSQLStatementType::Select || rTabs.begin() == rTabs.end() )
+                            if ( m_pSqlIterator->getStatementType() != OSQLStatementType::Select || rTabs.empty() )
                             {
                                 aError = SQLException(
                                     DBA_RES(STR_QRY_NOSELECT),
@@ -1160,21 +1160,20 @@ void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_r
 {
     saveTableWindows( o_rViewSettings );
 
-    OTableFields::const_iterator field = m_vTableFieldDesc.begin();
-    OTableFields::const_iterator fieldEnd = m_vTableFieldDesc.end();
-
     ::comphelper::NamedValueCollection aAllFieldsData;
     ::comphelper::NamedValueCollection aFieldData;
-    for ( sal_Int32 i = 1; field != fieldEnd; ++field, ++i )
+    sal_Int32 i = 1;
+    for (auto const& fieldDesc : m_vTableFieldDesc)
     {
-        if ( !(*field)->IsEmpty() )
+        if ( !fieldDesc->IsEmpty() )
         {
             aFieldData.clear();
-            (*field)->Save( aFieldData, i_includingCriteria );
+            fieldDesc->Save( aFieldData, i_includingCriteria );
 
             const OUString sFieldSettingName = "Field" + OUString::number( i );
             aAllFieldsData.put( sFieldSettingName, aFieldData.getPropertyValues() );
         }
+        ++i;
     }
 
     o_rViewSettings.put( "Fields", aAllFieldsData.getPropertyValues() );
diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
index e7a590c85866..8c4a56d41348 100644
--- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
+++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
@@ -337,17 +337,17 @@ xKey.clear();
                         xColumn->getPropertyValue(PROPERTY_NAME)            >>= sName;
                         xColumn->getPropertyValue(PROPERTY_RELATEDCOLUMN)   >>= sRelatedColumn;
 
-                        OConnectionLineDataVec::const_iterator aIter = m_vConnLineData.begin();
-                        OConnectionLineDataVec::const_iterator aEnd = m_vConnLineData.end();
-                        for(;aIter != aEnd;++aIter)
+                        bool bFoundElem = false;
+                        for (auto const& elem : m_vConnLineData)
                         {
-                            if(    (*aIter)->GetSourceFieldName() == sName
-                                && (*aIter)->GetDestFieldName() == sRelatedColumn )
+                            if(    elem->GetSourceFieldName() == sName
+                                && elem->GetDestFieldName() == sRelatedColumn )
                             {
+                                bFoundElem = true;
                                 break;
                             }
                         }
-                        if ( aIter == m_vConnLineData.end() )
+                        if (!bFoundElem)
                             break;
                     }
                     if ( pIter == pEnd )
diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx
index 0de9fce3f866..56509b1a843a 100644
--- a/dbaccess/source/ui/tabledesign/TableController.cxx
+++ b/dbaccess/source/ui/tabledesign/TableController.cxx
@@ -1496,18 +1496,18 @@ void OTableController::reload()
 
 sal_Int32 OTableController::getFirstEmptyRowPosition()
 {
-    sal_Int32 nRet = -1;
-    std::vector< std::shared_ptr<OTableRow> >::const_iterator aIter = m_vRowList.begin();
-    std::vector< std::shared_ptr<OTableRow> >::const_iterator aEnd = m_vRowList.end();
-    for(;aIter != aEnd;++aIter)
+    sal_Int32 nRet = 0;
+    bool bFoundElem = false;
+    for (auto const& row : m_vRowList)
     {
-        if ( !*aIter || !(*aIter)->GetActFieldDescr() || (*aIter)->GetActFieldDescr()->GetName().isEmpty() )
+        if ( !row || !row->GetActFieldDescr() || row->GetActFieldDescr()->GetName().isEmpty() )
         {
-            nRet = aIter - m_vRowList.begin();
+            bFoundElem = true;
             break;
         }
+        ++nRet;
     }
-    if ( nRet == -1 )
+    if (!bFoundElem)
     {
         bool bReadRow = !isAddAllowed();
         std::shared_ptr<OTableRow> pTabEdRow(new OTableRow());


More information about the Libreoffice-commits mailing list