diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-01-08 14:14:32 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-01-08 14:16:45 +0100 |
commit | 5072e17ec99da280e70413fa2ec571aa928c4503 (patch) | |
tree | 9dc7b20258b0d3d5448240f065745212e975469a /sc/source/ui/miscdlgs | |
parent | 4d9ed6769f4333331f18d6cad3fc209afa3f0c62 (diff) |
Simplify containers iterations in sc/source/ui/[f-u]*
Use range-based loop or replace with STL functions
Change-Id: Ia117ee3bea76c1cee84c0d2bb43195c59764fe93
Reviewed-on: https://gerrit.libreoffice.org/65961
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/miscdlgs')
-rw-r--r-- | sc/source/ui/miscdlgs/acredlin.cxx | 47 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/conflictsdlg.cxx | 21 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/datafdlg.cxx | 19 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/highred.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/lbseldlg.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/optsolver.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/retypepassdlg.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/scuiautofmt.cxx | 5 |
8 files changed, 48 insertions, 71 deletions
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index b1294a0ddff6..05d1ab0b22d3 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -202,9 +202,8 @@ void ScAcceptChgDlg::Init() aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser()); pTPFilter->ClearAuthors(); const std::set<OUString>& rUserColl = pChanges->GetUserCollection(); - std::set<OUString>::const_iterator it = rUserColl.begin(), itEnd = rUserColl.end(); - for (; it != itEnd; ++it) - pTPFilter->InsertAuthor(*it); + for (const auto& rItem : rUserColl) + pTPFilter->InsertAuthor(rItem); } ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings(); @@ -1124,13 +1123,8 @@ bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap* pActionMap,SvTreeL } SvTreeListEntry* pEntry=nullptr; - ScChangeActionMap::iterator itChangeAction = pActionMap->begin(); - while( itChangeAction != pActionMap->end() ) - { - if( itChangeAction->second->GetState()==SC_CAS_VIRGIN ) - break; - ++itChangeAction; - } + ScChangeActionMap::iterator itChangeAction = std::find_if(pActionMap->begin(), pActionMap->end(), + [](const std::pair<sal_uLong, ScChangeAction*>& rEntry) { return rEntry.second->GetState() == SC_CAS_VIRGIN; }); if( itChangeAction == pActionMap->end() ) return true; @@ -1215,11 +1209,10 @@ bool ScAcceptChgDlg::InsertChildren(ScChangeActionMap* pActionMap,SvTreeListEntr { ScChangeTrack* pChanges=pDoc->GetChangeTrack(); bool bTheTestFlag = true; - ScChangeActionMap::iterator itChangeAction; - for( itChangeAction = pActionMap->begin(); itChangeAction != pActionMap->end(); ++itChangeAction ) + for( const auto& rChangeAction : *pActionMap ) { - SvTreeListEntry* pEntry=AppendChangeAction( itChangeAction->second, pParent, false, true ); + SvTreeListEntry* pEntry=AppendChangeAction( rChangeAction.second, pParent, false, true ); if(pEntry!=nullptr) { @@ -1230,8 +1223,8 @@ bool ScAcceptChgDlg::InsertChildren(ScChangeActionMap* pActionMap,SvTreeListEntr pEntryData->bIsAcceptable=false; pEntryData->bDisabled=true; - if( itChangeAction->second->IsDialogParent() ) - Expand( pChanges, itChangeAction->second, pEntry ); + if( rChangeAction.second->IsDialogParent() ) + Expand( pChanges, rChangeAction.second, pEntry ); } } return bTheTestFlag; @@ -1243,15 +1236,14 @@ bool ScAcceptChgDlg::InsertDeletedChildren(const ScChangeAction* pScChangeAction ScChangeTrack* pChanges=pDoc->GetChangeTrack(); bool bTheTestFlag = true; SvTreeListEntry* pEntry=nullptr; - ScChangeActionMap::iterator itChangeAction; - for( itChangeAction = pActionMap->begin(); itChangeAction != pActionMap->end(); ++itChangeAction ) + for( const auto& rChangeAction : *pActionMap ) { - if( pScChangeAction != itChangeAction->second ) - pEntry = AppendChangeAction( itChangeAction->second, pParent, false, true ); + if( pScChangeAction != rChangeAction.second ) + pEntry = AppendChangeAction( rChangeAction.second, pParent, false, true ); else - pEntry = AppendChangeAction( itChangeAction->second, pParent, true, true ); + pEntry = AppendChangeAction( rChangeAction.second, pParent, true, true ); if(pEntry!=nullptr) { @@ -1262,8 +1254,8 @@ bool ScAcceptChgDlg::InsertDeletedChildren(const ScChangeAction* pScChangeAction bTheTestFlag=false; - if( itChangeAction->second->IsDialogParent() ) - Expand( pChanges, itChangeAction->second, pEntry ); + if( rChangeAction.second->IsDialogParent() ) + Expand( pChanges, rChangeAction.second, pEntry ); } } return bTheTestFlag; @@ -1546,22 +1538,21 @@ void ScAcceptChgDlg::UpdateEntrys(const ScChangeTrack* pChgTrack, sal_uLong nSta IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void) { - ScChangeTrackMsgQueue::iterator iter; ScChangeTrackMsgQueue& aMsgQueue= rChgTrack.GetMsgQueue(); sal_uLong nStartAction; sal_uLong nEndAction; - for (iter = aMsgQueue.begin(); iter != aMsgQueue.end(); ++iter) + for (const auto& pMsg : aMsgQueue) { - nStartAction=(*iter)->nStartAction; - nEndAction=(*iter)->nEndAction; + nStartAction = pMsg->nStartAction; + nEndAction = pMsg->nEndAction; if(!bIgnoreMsg) { bNoSelection=true; - switch((*iter)->eMsgType) + switch(pMsg->eMsgType) { case SC_CTM_APPEND: AppendChanges(&rChgTrack,nStartAction,nEndAction); break; @@ -1577,7 +1568,7 @@ IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack&, rChgTrack, void) } } } - delete *iter; + delete pMsg; } aMsgQueue.clear(); diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx index 95c1649ded09..759f711a399a 100644 --- a/sc/source/ui/miscdlgs/conflictsdlg.cxx +++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx @@ -102,17 +102,16 @@ void ScConflictsListHelper::Transform_Impl( std::vector<sal_uLong>& rActionList, void ScConflictsListHelper::TransformConflictsList( ScConflictsList& rConflictsList, ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap ) { - ScConflictsList::iterator aEnd = rConflictsList.end(); - for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr ) + for ( auto& rConflictEntry : rConflictsList ) { if ( pSharedMap ) { - ScConflictsListHelper::Transform_Impl( aItr->maSharedActions, pSharedMap ); + ScConflictsListHelper::Transform_Impl( rConflictEntry.maSharedActions, pSharedMap ); } if ( pOwnMap ) { - ScConflictsListHelper::Transform_Impl( aItr->maOwnActions, pOwnMap ); + ScConflictsListHelper::Transform_Impl( rConflictEntry.maOwnActions, pOwnMap ); } } } @@ -628,17 +627,15 @@ IMPL_LINK_NOARG(ScConflictsDlg, KeepAllOthersHandle, Button*, void) void ScConflictsDlg::UpdateView() { - ScConflictsList::iterator aEndItr = mrConflictsList.end(); - for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEndItr; ++aItr ) + for ( ScConflictsListEntry& rConflictEntry : mrConflictsList ) { - ScConflictsListEntry& rConflictEntry = *aItr; if (rConflictEntry.meConflictAction == SC_CONFLICT_ACTION_NONE) { RedlinData* pRootUserData = new RedlinData(); pRootUserData->pData = static_cast<void*>(&rConflictEntry); - SvTreeListEntry* pRootEntry = m_pLbConflicts->InsertEntry( GetConflictString( *aItr ), pRootUserData ); + SvTreeListEntry* pRootEntry = m_pLbConflicts->InsertEntry( GetConflictString( rConflictEntry ), pRootUserData ); - for ( auto& aSharedAction : aItr->maSharedActions ) + for ( auto& aSharedAction : rConflictEntry.maSharedActions ) { ScChangeAction* pAction = mpSharedTrack ? mpSharedTrack->GetAction(aSharedAction) : nullptr; if ( pAction ) @@ -647,7 +644,7 @@ void ScConflictsDlg::UpdateView() if ( pAction->GetType() == SC_CAT_CONTENT ) { ScChangeActionContent* pNextContent = dynamic_cast<ScChangeActionContent&>(*pAction).GetNextContent(); - if ( pNextContent && aItr->HasSharedAction( pNextContent->GetActionNumber() ) ) + if ( pNextContent && rConflictEntry.HasSharedAction( pNextContent->GetActionNumber() ) ) { continue; } @@ -658,7 +655,7 @@ void ScConflictsDlg::UpdateView() } } - for ( auto& aOwnAction : aItr->maOwnActions ) + for ( auto& aOwnAction : rConflictEntry.maOwnActions ) { ScChangeAction* pAction = mpOwnTrack ? mpOwnTrack->GetAction(aOwnAction) : nullptr; if ( pAction ) @@ -667,7 +664,7 @@ void ScConflictsDlg::UpdateView() if ( pAction->GetType() == SC_CAT_CONTENT ) { ScChangeActionContent* pNextContent = dynamic_cast<ScChangeActionContent&>(*pAction).GetNextContent(); - if ( pNextContent && aItr->HasOwnAction( pNextContent->GetActionNumber() ) ) + if ( pNextContent && rConflictEntry.HasOwnAction( pNextContent->GetActionNumber() ) ) { continue; } diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx index 6bfd7c78ed41..efd37d8acd4e 100644 --- a/sc/source/ui/miscdlgs/datafdlg.cxx +++ b/sc/source/ui/miscdlgs/datafdlg.cxx @@ -217,10 +217,10 @@ void ScDataFormDlg::dispose() m_pBtnClose.clear(); m_pSlider.clear(); m_pFixedText.clear(); - for ( auto aFTIter = maFixedTexts.begin(); aFTIter != maFixedTexts.end(); ++aFTIter ) - aFTIter->disposeAndClear(); - for ( auto aEditIter = maEdits.begin(); aEditIter != maEdits.end(); ++aEditIter ) - aEditIter->disposeAndClear(); + for ( auto& rxFTIter : maFixedTexts ) + rxFTIter.disposeAndClear(); + for ( auto& rxEdit : maEdits ) + rxEdit.disposeAndClear(); maFixedTexts.clear(); maEdits.clear(); m_pGrid.clear(); @@ -269,15 +269,8 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_NewHdl, Button*, void) ScDocShell* pDocSh = rViewData.GetDocShell(); if ( pDoc ) { - bool bHasData = false; - auto itr = maEdits.begin(), itrEnd = maEdits.end(); - for(; itr != itrEnd; ++itr) - if ((*itr) != nullptr) - if ( !(*itr)->GetText().isEmpty() ) - { - bHasData = true; - break; - } + bool bHasData = std::any_of(maEdits.begin(), maEdits.end(), + [](const VclPtr<Edit>& rxEdit) { return (rxEdit != nullptr) && (!rxEdit->GetText().isEmpty()); }); if ( bHasData ) { diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx index 17d3f752dbad..9030ee1f2b66 100644 --- a/sc/source/ui/miscdlgs/highred.cxx +++ b/sc/source/ui/miscdlgs/highred.cxx @@ -84,9 +84,8 @@ void ScHighlightChgDlg::Init() aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser()); m_pFilterCtr->ClearAuthors(); const std::set<OUString>& rUserColl = pChanges->GetUserCollection(); - std::set<OUString>::const_iterator it = rUserColl.begin(), itEnd = rUserColl.end(); - for (; it != itEnd; ++it) - m_pFilterCtr->InsertAuthor(*it); + for (const auto& rItem : rUserColl) + m_pFilterCtr->InsertAuthor(rItem); } ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings(); diff --git a/sc/source/ui/miscdlgs/lbseldlg.cxx b/sc/source/ui/miscdlgs/lbseldlg.cxx index d01864afd8e2..67adcb1dbe9a 100644 --- a/sc/source/ui/miscdlgs/lbseldlg.cxx +++ b/sc/source/ui/miscdlgs/lbseldlg.cxx @@ -29,9 +29,8 @@ ScSelEntryDlg::ScSelEntryDlg(weld::Window* pParent, const std::vector<OUString> m_xLb->get_height_rows(8)); m_xLb->connect_row_activated(LINK(this, ScSelEntryDlg, DblClkHdl)); - std::vector<OUString>::const_iterator pIter; - for (pIter = rEntryList.begin(); pIter != rEntryList.end(); ++pIter) - m_xLb->append_text(*pIter); + for (const auto& rEntry : rEntryList) + m_xLb->append_text(rEntry); if (m_xLb->n_children() > 0) m_xLb->select(0); diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx index 66ecf951665e..8d26590cfb79 100644 --- a/sc/source/ui/miscdlgs/optsolver.cxx +++ b/sc/source/ui/miscdlgs/optsolver.cxx @@ -868,17 +868,16 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal uno::Sequence<sheet::SolverConstraint> aConstraints; sal_Int32 nConstrPos = 0; - for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin(); - aConstrIter != maConditions.end(); ++aConstrIter ) + for ( const auto& rConstr : maConditions ) { - if ( !aConstrIter->aLeftStr.isEmpty() ) + if ( !rConstr.aLeftStr.isEmpty() ) { sheet::SolverConstraint aConstraint; // order of list box entries must match enum values - aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator); + aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(rConstr.nOperator); ScRange aLeftRange; - if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) ) + if ( !ParseRef( aLeftRange, rConstr.aLeftStr, true ) ) { ShowError( true, nullptr ); return false; @@ -886,7 +885,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal bool bIsRange = false; ScRange aRightRange; - if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) ) + if ( ParseRef( aRightRange, rConstr.aRightStr, true ) ) { if ( aRightRange.aStart == aRightRange.aEnd ) aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(), @@ -904,7 +903,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal { sal_uInt32 nFormat = 0; //! explicit language? double fValue = 0.0; - if ( mrDoc.GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) ) + if ( mrDoc.GetFormatTable()->IsNumberFormat( rConstr.aRightStr, nFormat, fValue ) ) aConstraint.Right <<= fValue; else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER && aConstraint.Operator != sheet::SolverConstraintOperator_BINARY ) diff --git a/sc/source/ui/miscdlgs/retypepassdlg.cxx b/sc/source/ui/miscdlgs/retypepassdlg.cxx index 14b51656b01b..2af3344b94dd 100644 --- a/sc/source/ui/miscdlgs/retypepassdlg.cxx +++ b/sc/source/ui/miscdlgs/retypepassdlg.cxx @@ -64,9 +64,9 @@ void ScRetypePassDlg::dispose() void ScRetypePassDlg::DeleteSheets() { - for(auto it = maSheets.begin(); it != maSheets.end(); ++it) + for(auto& rxSheet : maSheets) { - VclPtr<vcl::Window> pWindow = (*it); + VclPtr<vcl::Window> pWindow = rxSheet; vcl::Window *pChild = pWindow->GetWindow(GetWindowType::FirstChild); while (pChild) { diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index c5ada4123716..2b08756b4d87 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -128,9 +128,8 @@ void ScAutoFormatDlg::Init() m_pBtnRename->SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) ); m_pLbFormat->SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) ); - ScAutoFormat::const_iterator it = pFormat->begin(), itEnd = pFormat->end(); - for (; it != itEnd; ++it) - m_pLbFormat->InsertEntry(it->second->GetName()); + for (const auto& rEntry : *pFormat) + m_pLbFormat->InsertEntry(rEntry.second->GetName()); if (pFormat->size() == 1) m_pBtnRemove->Disable(); |