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/undo | |
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/undo')
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 46 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk2.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 39 | ||||
-rw-r--r-- | sc/source/ui/undo/undorangename.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/undo/undostyl.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/undo/undotab.cxx | 5 |
7 files changed, 66 insertions, 68 deletions
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index a14410e399bb..a6ff4f184a40 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -212,10 +212,9 @@ void ScSimpleUndo::BroadcastChanges( const DataSpansType& rSpans ) ScDocument& rDoc = pDocShell->GetDocument(); SpanBroadcaster aBroadcaster(rDoc); - DataSpansType::const_iterator it = rSpans.begin(), itEnd = rSpans.end(); - for (; it != itEnd; ++it) + for (const auto& rEntry : rSpans) { - const sc::ColumnSpanSet& rSet = *it->second; + const sc::ColumnSpanSet& rSet = *rEntry.second; rSet.executeColumnAction(rDoc, aBroadcaster); } } diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 5d66cc393150..1404d6e66ad3 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -724,22 +724,20 @@ void ScUndoDeleteMulti::Undo() ScDocument& rDoc = pDocShell->GetDocument(); // reverse delete -> forward insert - std::vector<sc::ColRowSpan>::const_iterator it = maSpans.begin(), itEnd = maSpans.end(); - for (; it != itEnd; ++it) + for (const auto& rSpan : maSpans) { - SCCOLROW nStart = it->mnStart; - SCCOLROW nEnd = it->mnEnd; + SCCOLROW nStart = rSpan.mnStart; + SCCOLROW nEnd = rSpan.mnEnd; if (mbRows) rDoc.InsertRow( 0,nTab, MAXCOL,nTab, nStart,static_cast<SCSIZE>(nEnd-nStart+1) ); else rDoc.InsertCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) ); } - it = maSpans.begin(); - for (; it != itEnd; ++it) + for (const auto& rSpan : maSpans) { - SCCOLROW nStart = it->mnStart; - SCCOLROW nEnd = it->mnEnd; + SCCOLROW nStart = rSpan.mnStart; + SCCOLROW nEnd = rSpan.mnEnd; if (mbRows) pRefUndoDoc->CopyToDocument(0, nStart, nTab, MAXCOL, nEnd, nTab, InsertDeleteFlags::ALL, false, rDoc); else @@ -1028,14 +1026,16 @@ void ScUndoPaste::DoChange(bool bUndo) aRange.aStart.SetTab(nFirstSelected); aRange.aEnd.SetTab(nFirstSelected); pRedoDoc->UndoToDocument(aRange, nUndoFlags, false, rDoc); - ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); - for (; itr != itrEnd && *itr < nTabCount; ++itr) + for (const auto& rTab : aMarkData) { - if (*itr == nFirstSelected) + if (rTab >= nTabCount) + break; + + if (rTab == nFirstSelected) continue; - aRange.aStart.SetTab(*itr); - aRange.aEnd.SetTab(*itr); + aRange.aStart.SetTab(rTab); + aRange.aEnd.SetTab(rTab); pRedoDoc->CopyToDocument(aRange, nUndoFlags, false, rDoc); } } @@ -1057,11 +1057,12 @@ void ScUndoPaste::DoChange(bool bUndo) for (size_t i = 0, n = maBlockRanges.size(); i < n; ++i) { ScRange aRange = maBlockRanges[i]; - ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); - for (; itr != itrEnd && *itr < nTabCount; ++itr) + for (const auto& rTab : aMarkData) { - aRange.aStart.SetTab(*itr); - aRange.aEnd.SetTab(*itr); + if (rTab >= nTabCount) + break; + aRange.aStart.SetTab(rTab); + aRange.aEnd.SetTab(rTab); pUndoDoc->UndoToDocument(aRange, nUndoFlags, false, rDoc); } } @@ -2263,21 +2264,20 @@ void ScUndoRemoveMerge::Undo() ScDocument& rDoc = pDocShell->GetDocument(); for (const auto & rOption : maOptions) { - for (set<SCTAB>::const_iterator itr = rOption.maTabs.begin(), itrEnd = rOption.maTabs.end(); - itr != itrEnd; ++itr) + for (const auto& rTab : rOption.maTabs) { OSL_ENSURE(pUndoDoc, "NULL pUndoDoc!"); if (!pUndoDoc) continue; // There is no need to extend merge area because it's already been extended. - ScRange aRange = rOption.getSingleRange(*itr); + ScRange aRange = rOption.getSingleRange(rTab); rDoc.DeleteAreaTab(aRange, InsertDeleteFlags::ATTRIB); pUndoDoc->CopyToDocument(aRange, InsertDeleteFlags::ATTRIB, false, rDoc); bool bDidPaint = false; if ( pViewShell ) { - pViewShell->SetTabNo(*itr); + pViewShell->SetTabNo(rTab); bDidPaint = pViewShell->AdjustRowHeight(rOption.mnStartRow, rOption.mnEndRow); } if (!bDidPaint) @@ -2300,10 +2300,8 @@ void ScUndoRemoveMerge::Redo() for (const auto & rOption : maOptions) { - for (set<SCTAB>::const_iterator itr = rOption.maTabs.begin(), itrEnd = rOption.maTabs.end(); - itr != itrEnd; ++itr) + for (const SCTAB nTab : rOption.maTabs) { - SCTAB nTab = *itr; // There is no need to extend merge area because it's already been extended. ScRange aRange = rOption.getSingleRange(nTab); diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx index 6418e604192b..163429522244 100644 --- a/sc/source/ui/undo/undoblk2.cxx +++ b/sc/source/ui/undo/undoblk2.cxx @@ -99,26 +99,28 @@ void ScUndoWidthOrHeight::Undo() ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); SCTAB nTabCount = rDoc.GetTableCount(); - ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); - for (; itr != itrEnd && *itr < nTabCount; ++itr) + for (const auto& rTab : aMarkData) { + if (rTab >= nTabCount) + break; + if (pViewShell) pViewShell->OnLOKSetWidthOrHeight(nStart, bWidth); if (bWidth) // Width { - pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, *itr, - static_cast<SCCOL>(nEnd), MAXROW, *itr, InsertDeleteFlags::NONE, + pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, rTab, + static_cast<SCCOL>(nEnd), MAXROW, rTab, InsertDeleteFlags::NONE, false, rDoc); - rDoc.UpdatePageBreaks( *itr ); - pDocShell->PostPaint( static_cast<SCCOL>(nPaintStart), 0, *itr, - MAXCOL, MAXROW, *itr, PaintPartFlags::Grid | PaintPartFlags::Top ); + rDoc.UpdatePageBreaks( rTab ); + pDocShell->PostPaint( static_cast<SCCOL>(nPaintStart), 0, rTab, + MAXCOL, MAXROW, rTab, PaintPartFlags::Grid | PaintPartFlags::Top ); } else // Height { - pUndoDoc->CopyToDocument(0, nStart, *itr, MAXCOL, nEnd, *itr, InsertDeleteFlags::NONE, false, rDoc); - rDoc.UpdatePageBreaks( *itr ); - pDocShell->PostPaint( 0, nPaintStart, *itr, MAXCOL, MAXROW, *itr, PaintPartFlags::Grid | PaintPartFlags::Left ); + pUndoDoc->CopyToDocument(0, nStart, rTab, MAXCOL, nEnd, rTab, InsertDeleteFlags::NONE, false, rDoc); + rDoc.UpdatePageBreaks( rTab ); + pDocShell->PostPaint( 0, nPaintStart, rTab, MAXCOL, MAXROW, rTab, PaintPartFlags::Grid | PaintPartFlags::Left ); } } diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index bc7173aa15bb..b83c7f144e35 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -246,13 +246,14 @@ void ScUndoFillTable::SetChangeTrack() ScRange aWorkRange(aRange); nStartChangeAction = 0; sal_uLong nTmpAction; - ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); - for (; itr != itrEnd && *itr < nTabCount; ++itr) + for (const auto& rTab : aMarkData) { - if (*itr != nSrcTab) + if (rTab >= nTabCount) + break; + if (rTab != nSrcTab) { - aWorkRange.aStart.SetTab(*itr); - aWorkRange.aEnd.SetTab(*itr); + aWorkRange.aStart.SetTab(rTab); + aWorkRange.aEnd.SetTab(rTab); pChangeTrack->AppendContentRange( aWorkRange, pUndoDoc.get(), nTmpAction, nEndChangeAction ); if ( !nStartChangeAction ) @@ -274,18 +275,21 @@ void ScUndoFillTable::DoChange( const bool bUndo ) { SCTAB nTabCount = rDoc.GetTableCount(); ScRange aWorkRange(aRange); - ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); - for (; itr != itrEnd && *itr < nTabCount; ++itr) - if (*itr != nSrcTab) + for (const auto& rTab : aMarkData) + { + if (rTab >= nTabCount) + break; + if (rTab != nSrcTab) { - aWorkRange.aStart.SetTab(*itr); - aWorkRange.aEnd.SetTab(*itr); + aWorkRange.aStart.SetTab(rTab); + aWorkRange.aEnd.SetTab(rTab); if (bMulti) - rDoc.DeleteSelectionTab( *itr, InsertDeleteFlags::ALL, aMarkData ); + rDoc.DeleteSelectionTab( rTab, InsertDeleteFlags::ALL, aMarkData ); else rDoc.DeleteAreaTab( aWorkRange, InsertDeleteFlags::ALL ); pUndoDoc->CopyToDocument(aWorkRange, InsertDeleteFlags::ALL, bMulti, rDoc, &aMarkData); } + } ScChangeTrack* pChangeTrack = rDoc.GetChangeTrack(); if ( pChangeTrack ) @@ -527,12 +531,13 @@ void ScUndoAutoFill::Undo() ScDocument& rDoc = pDocShell->GetDocument(); SCTAB nTabCount = rDoc.GetTableCount(); - ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); - for (; itr != itrEnd && *itr < nTabCount; ++itr) + for (const auto& rTab : aMarkData) { + if (rTab >= nTabCount) + break; ScRange aWorkRange = aBlockRange; - aWorkRange.aStart.SetTab(*itr); - aWorkRange.aEnd.SetTab(*itr); + aWorkRange.aStart.SetTab(rTab); + aWorkRange.aEnd.SetTab(rTab); sal_uInt16 nExtFlags = 0; pDocShell->UpdatePaintExt( nExtFlags, aWorkRange ); @@ -669,10 +674,8 @@ void ScUndoMerge::DoChange( bool bUndo ) const ScRange aCurRange = maOption.getSingleRange(ScDocShell::GetCurTab()); ScUndoUtil::MarkSimpleBlock(pDocShell, aCurRange); - for (set<SCTAB>::const_iterator itr = maOption.maTabs.begin(), itrEnd = maOption.maTabs.end(); - itr != itrEnd; ++itr) + for (const SCTAB nTab : maOption.maTabs) { - SCTAB nTab = *itr; ScRange aRange = maOption.getSingleRange(nTab); if (bUndo) diff --git a/sc/source/ui/undo/undorangename.cxx b/sc/source/ui/undo/undorangename.cxx index eb195e466b2e..c139f59f8189 100644 --- a/sc/source/ui/undo/undorangename.cxx +++ b/sc/source/ui/undo/undorangename.cxx @@ -27,10 +27,9 @@ ScUndoAllRangeNames::ScUndoAllRangeNames( const std::map<OUString, std::unique_ptr<ScRangeName>>& rNewNames) : ScSimpleUndo(pDocSh) { - std::map<OUString, ScRangeName*>::const_iterator itr, itrEnd; - for (itr = rOldNames.begin(), itrEnd = rOldNames.end(); itr != itrEnd; ++itr) + for (const auto& [rName, pRangeName] : rOldNames) { - m_OldNames.insert(std::make_pair(itr->first,o3tl::make_unique<ScRangeName>(*itr->second))); + m_OldNames.insert(std::make_pair(rName, o3tl::make_unique<ScRangeName>(*pRangeName))); } for (auto const& it : rNewNames) diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx index 62b19d45c6ce..1a868c330c8b 100644 --- a/sc/source/ui/undo/undostyl.cxx +++ b/sc/source/ui/undo/undostyl.cxx @@ -240,10 +240,10 @@ OUString ScUndoApplyPageStyle::GetComment() const void ScUndoApplyPageStyle::Undo() { BeginUndo(); - for( ApplyStyleVec::const_iterator aIt = maEntries.begin(), aEnd = maEntries.end(); aIt != aEnd; ++aIt ) + for( const auto& rEntry : maEntries ) { - pDocShell->GetDocument().SetPageStyle( aIt->mnTab, aIt->maOldStyle ); - ScPrintFunc( pDocShell, pDocShell->GetPrinter(), aIt->mnTab ).UpdatePages(); + pDocShell->GetDocument().SetPageStyle( rEntry.mnTab, rEntry.maOldStyle ); + ScPrintFunc( pDocShell, pDocShell->GetPrinter(), rEntry.mnTab ).UpdatePages(); } EndUndo(); } @@ -251,10 +251,10 @@ void ScUndoApplyPageStyle::Undo() void ScUndoApplyPageStyle::Redo() { BeginRedo(); - for( ApplyStyleVec::const_iterator aIt = maEntries.begin(), aEnd = maEntries.end(); aIt != aEnd; ++aIt ) + for( const auto& rEntry : maEntries ) { - pDocShell->GetDocument().SetPageStyle( aIt->mnTab, maNewStyle ); - ScPrintFunc( pDocShell, pDocShell->GetPrinter(), aIt->mnTab ).UpdatePages(); + pDocShell->GetDocument().SetPageStyle( rEntry.mnTab, maNewStyle ); + ScPrintFunc( pDocShell, pDocShell->GetPrinter(), rEntry.mnTab ).UpdatePages(); } EndRedo(); } diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx index 24e784feea75..8514920bcaa8 100644 --- a/sc/source/ui/undo/undotab.cxx +++ b/sc/source/ui/undo/undotab.cxx @@ -1098,11 +1098,8 @@ void ScUndoShowHideTab::DoChange( bool bShowP ) const ScDocument& rDoc = pDocShell->GetDocument(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); - SCTAB nTab; - - for(std::vector<SCTAB>::const_iterator itr = undoTabs.begin(), itrEnd = undoTabs.end(); itr != itrEnd; ++itr) + for(const SCTAB& nTab : undoTabs) { - nTab = *itr; rDoc.SetVisible( nTab, bShowP ); if (pViewShell) pViewShell->SetTabNo(nTab,true); |