Kaydet (Commit) 319b187e authored tarafından Caolán McNamara's avatar Caolán McNamara

Use for-range loops

Change-Id: I7bf26258b8330a5f81657a3684c81ce429b37090
Reviewed-on: https://gerrit.libreoffice.org/59262
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst a2adca5f
...@@ -288,15 +288,14 @@ std::vector<OUString> ScDocument::GetAllTableNames() const ...@@ -288,15 +288,14 @@ std::vector<OUString> ScDocument::GetAllTableNames() const
{ {
std::vector<OUString> aNames; std::vector<OUString> aNames;
aNames.reserve(maTabs.size()); aNames.reserve(maTabs.size());
TableContainer::const_iterator it = maTabs.begin(), itEnd = maTabs.end(); for (const auto& a : maTabs)
for (; it != itEnd; ++it)
{ {
// Positions need to be preserved for ScCompiler and address convention // Positions need to be preserved for ScCompiler and address convention
// context, so still push an empty string for NULL tabs. // context, so still push an empty string for NULL tabs.
OUString aName; OUString aName;
if (*it) if (a)
{ {
const ScTable& rTab = **it; const ScTable& rTab = *a;
aName = rTab.GetName(); aName = rTab.GetName();
} }
aNames.push_back(aName); aNames.push_back(aName);
...@@ -498,12 +497,10 @@ void ScDocument::SetTabNameOnLoad(SCTAB nTab, const OUString& rName) ...@@ -498,12 +497,10 @@ void ScDocument::SetTabNameOnLoad(SCTAB nTab, const OUString& rName)
void ScDocument::InvalidateStreamOnSave() void ScDocument::InvalidateStreamOnSave()
{ {
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); for (const auto& a : maTabs)
for (; it != itEnd; ++it)
{ {
ScTable* pTab = it->get(); if (a)
if (pTab) a->SetStreamValid(false);
pTab->SetStreamValid(false);
} }
} }
...@@ -545,20 +542,22 @@ bool ScDocument::InsertTab( ...@@ -545,20 +542,22 @@ bool ScDocument::InsertTab(
if ( pUnoBroadcaster ) if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) ); pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,1 ) );
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
(*it)->UpdateInsertTab(aCxt); a->UpdateInsertTab(aCxt);
}
maTabs.emplace(maTabs.begin() + nPos, new ScTable(this, nPos, rName)); maTabs.emplace(maTabs.begin() + nPos, new ScTable(this, nPos, rName));
// UpdateBroadcastAreas must be called between UpdateInsertTab, // UpdateBroadcastAreas must be called between UpdateInsertTab,
// which ends listening, and StartAllListeners, to not modify // which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners. // areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,1); UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,1);
it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
(*it)->UpdateCompile(); a->UpdateCompile();
}
StartAllListeners(); StartAllListeners();
...@@ -634,10 +633,11 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames, ...@@ -634,10 +633,11 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
if ( pUnoBroadcaster ) if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,nNewSheets ) ); pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,nNewSheets ) );
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
(*it)->UpdateInsertTab(aCxt); a->UpdateInsertTab(aCxt);
}
for (SCTAB i = 0; i < nNewSheets; ++i) for (SCTAB i = 0; i < nNewSheets; ++i)
{ {
maTabs.emplace(maTabs.begin() + nPos + i, new ScTable(this, nPos + i, rNames.at(i)) ); maTabs.emplace(maTabs.begin() + nPos + i, new ScTable(this, nPos + i, rNames.at(i)) );
...@@ -647,11 +647,10 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames, ...@@ -647,11 +647,10 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
// which ends listening, and StartAllListeners, to not modify // which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners. // areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,nNewSheets); UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,nNewSheets);
it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it)
{ {
if ( *it ) if (a)
(*it)->UpdateCompile(); a->UpdateCompile();
} }
StartAllListeners(); StartAllListeners();
...@@ -738,10 +737,11 @@ bool ScDocument::DeleteTab( SCTAB nTab ) ...@@ -738,10 +737,11 @@ bool ScDocument::DeleteTab( SCTAB nTab )
// which ends listening, and StartAllListeners, to not modify // which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners. // areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1); UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1);
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
(*it)->UpdateCompile(); a->UpdateCompile();
}
// Excel-Filter deletes some Tables while loading, Listeners will // Excel-Filter deletes some Tables while loading, Listeners will
// only be triggered after the loading is done. // only be triggered after the loading is done.
if ( !bInsertingFromOtherDoc ) if ( !bInsertingFromOtherDoc )
...@@ -833,10 +833,11 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets ) ...@@ -833,10 +833,11 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
// which ends listening, and StartAllListeners, to not modify // which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners. // areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets); UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets);
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
(*it)->UpdateCompile(); a->UpdateCompile();
}
// Excel-Filter deletes some Tables while loading, Listeners will // Excel-Filter deletes some Tables while loading, Listeners will
// only be triggered after the loading is done. // only be triggered after the loading is done.
if ( !bInsertingFromOtherDoc ) if ( !bInsertingFromOtherDoc )
...@@ -892,10 +893,11 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc ...@@ -892,10 +893,11 @@ bool ScDocument::RenameTab( SCTAB nTab, const OUString& rName, bool bExternalDoc
// If formulas refer to the renamed sheet, the TokenArray remains valid, // If formulas refer to the renamed sheet, the TokenArray remains valid,
// but the XML stream must be re-generated. // but the XML stream must be re-generated.
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
(*it)->SetStreamValid( false ); a->SetStreamValid( false );
}
if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer()) if (comphelper::LibreOfficeKit::isActive() && GetDrawLayer())
{ {
...@@ -1337,10 +1339,11 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab, ...@@ -1337,10 +1339,11 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab,
// At least all cells using range names pointing relative to the // At least all cells using range names pointing relative to the
// moved range must be recalculated, and all cells marked postponed // moved range must be recalculated, and all cells marked postponed
// dirty. // dirty.
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->SetDirtyIfPostponed(); a->SetDirtyIfPostponed();
}
std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this)); std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
} }
...@@ -1447,10 +1450,11 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab, ...@@ -1447,10 +1450,11 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
// At least all cells using range names pointing relative to the moved // At least all cells using range names pointing relative to the moved
// range must be recalculated, and all cells marked postponed dirty. // range must be recalculated, and all cells marked postponed dirty.
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->SetDirtyIfPostponed(); a->SetDirtyIfPostponed();
}
std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this)); std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
} }
...@@ -1649,10 +1653,11 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA ...@@ -1649,10 +1653,11 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA
// At least all cells using range names pointing relative to the moved // At least all cells using range names pointing relative to the moved
// range must be recalculated, and all cells marked postponed dirty. // range must be recalculated, and all cells marked postponed dirty.
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->SetDirtyIfPostponed(); a->SetDirtyIfPostponed();
}
std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this)); std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler( this));
} }
...@@ -3823,10 +3828,11 @@ void ScDocument::CheckVectorizationState() ...@@ -3823,10 +3828,11 @@ void ScDocument::CheckVectorizationState()
bool bOldAutoCalc = GetAutoCalc(); bool bOldAutoCalc = GetAutoCalc();
bAutoCalc = false; // no multiple calculations bAutoCalc = false; // no multiple calculations
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->CheckVectorizationState(); a->CheckVectorizationState();
}
SetAutoCalc(bOldAutoCalc); SetAutoCalc(bOldAutoCalc);
} }
...@@ -3837,10 +3843,11 @@ void ScDocument::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt ) ...@@ -3837,10 +3843,11 @@ void ScDocument::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
bAutoCalc = false; // no multiple calculations bAutoCalc = false; // no multiple calculations
{ // scope for bulk broadcast { // scope for bulk broadcast
ScBulkBroadcast aBulkBroadcast( GetBASM(), SfxHintId::ScDataChanged); ScBulkBroadcast aBulkBroadcast( GetBASM(), SfxHintId::ScDataChanged);
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (;it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->SetAllFormulasDirty(rCxt); a->SetAllFormulasDirty(rCxt);
}
} }
// Although Charts are also set to dirty in Tracking without AutoCalc // Although Charts are also set to dirty in Tracking without AutoCalc
...@@ -3933,13 +3940,16 @@ void ScDocument::CalcAll() ...@@ -3933,13 +3940,16 @@ void ScDocument::CalcAll()
PrepareFormulaCalc(); PrepareFormulaCalc();
ClearLookupCaches(); // Ensure we don't deliver zombie data. ClearLookupCaches(); // Ensure we don't deliver zombie data.
sc::AutoCalcSwitch aSwitch(*this, true); sc::AutoCalcSwitch aSwitch(*this, true);
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->SetDirtyVar(); a->SetDirtyVar();
for (it = maTabs.begin(); it != maTabs.end(); ++it) }
if (*it) for (const auto& a : maTabs)
(*it)->CalcAll(); {
if (a)
a->CalcAll();
}
ClearFormulaTree(); ClearFormulaTree();
// In eternal hard recalc state caches were not added as listeners, // In eternal hard recalc state caches were not added as listeners,
...@@ -3952,10 +3962,11 @@ void ScDocument::CalcAll() ...@@ -3952,10 +3962,11 @@ void ScDocument::CalcAll()
void ScDocument::CompileAll() void ScDocument::CompileAll()
{ {
sc::CompileFormulaContext aCxt(this); sc::CompileFormulaContext aCxt(this);
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->CompileAll(aCxt); a->CompileAll(aCxt);
}
sc::SetFormulaDirtyContext aFormulaDirtyCxt; sc::SetFormulaDirtyContext aFormulaDirtyCxt;
SetAllFormulasDirty(aFormulaDirtyCxt); SetAllFormulasDirty(aFormulaDirtyCxt);
...@@ -4005,14 +4016,12 @@ bool ScDocument::CompileErrorCells(FormulaError nErrCode) ...@@ -4005,14 +4016,12 @@ bool ScDocument::CompileErrorCells(FormulaError nErrCode)
{ {
bool bCompiled = false; bool bCompiled = false;
sc::CompileFormulaContext aCxt(this); sc::CompileFormulaContext aCxt(this);
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); for (const auto& a : maTabs)
for (; it != itEnd; ++it)
{ {
ScTable* pTab = it->get(); if (!a)
if (!pTab)
continue; continue;
if (pTab->CompileErrorCells(aCxt, nErrCode)) if (a->CompileErrorCells(aCxt, nErrCode))
bCompiled = true; bCompiled = true;
} }
...@@ -4027,13 +4036,16 @@ void ScDocument::CalcAfterLoad( bool bStartListening ) ...@@ -4027,13 +4036,16 @@ void ScDocument::CalcAfterLoad( bool bStartListening )
bCalcingAfterLoad = true; bCalcingAfterLoad = true;
sc::CompileFormulaContext aCxt(this); sc::CompileFormulaContext aCxt(this);
{ {
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->CalcAfterLoad(aCxt, bStartListening); a->CalcAfterLoad(aCxt, bStartListening);
for (it = maTabs.begin(); it != maTabs.end(); ++it) }
if (*it) for (const auto& a : maTabs)
(*it)->SetDirtyAfterLoad(); {
if (a)
a->SetDirtyAfterLoad();
}
} }
bCalcingAfterLoad = false; bCalcingAfterLoad = false;
...@@ -4555,11 +4567,10 @@ bool ScDocument::IsManualRowHeight(SCROW nRow, SCTAB nTab) const ...@@ -4555,11 +4567,10 @@ bool ScDocument::IsManualRowHeight(SCROW nRow, SCTAB nTab) const
void ScDocument::SyncColRowFlags() void ScDocument::SyncColRowFlags()
{ {
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it)
{ {
if (*it) if (a)
(*it)->SyncColRowFlags(); a->SyncColRowFlags();
} }
} }
...@@ -4932,11 +4943,12 @@ void ScDocument::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool b ...@@ -4932,11 +4943,12 @@ void ScDocument::StyleSheetChanged( const SfxStyleSheetBase* pStyleSheet, bool b
double nPPTX, double nPPTY, double nPPTX, double nPPTY,
const Fraction& rZoomX, const Fraction& rZoomY ) const Fraction& rZoomX, const Fraction& rZoomY )
{ {
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if (*it) if (a)
(*it)->StyleSheetChanged a->StyleSheetChanged
( pStyleSheet, bRemoved, pDev, nPPTX, nPPTY, rZoomX, rZoomY ); ( pStyleSheet, bRemoved, pDev, nPPTX, nPPTY, rZoomX, rZoomY );
}
if ( pStyleSheet && pStyleSheet->GetName() == ScResId(STR_STYLENAME_STANDARD) ) if ( pStyleSheet && pStyleSheet->GetName() == ScResId(STR_STYLENAME_STANDARD) )
{ {
...@@ -4963,15 +4975,16 @@ bool ScDocument::IsStyleSheetUsed( const ScStyleSheet& rStyle ) const ...@@ -4963,15 +4975,16 @@ bool ScDocument::IsStyleSheetUsed( const ScStyleSheet& rStyle ) const
bool bIsUsed = false; bool bIsUsed = false;
TableContainer::const_iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it)
if (*it)
{ {
if ( (*it)->IsStyleSheetUsed( rStyle ) ) if (a)
{
if ( a->IsStyleSheetUsed( rStyle ) )
{ {
bIsUsed = true; bIsUsed = true;
} }
} }
}
bStyleSheetUsageInvalid = false; bStyleSheetUsageInvalid = false;
...@@ -6065,10 +6078,11 @@ sal_uLong ScDocument::GetCellCount() const ...@@ -6065,10 +6078,11 @@ sal_uLong ScDocument::GetCellCount() const
{ {
sal_uLong nCellCount = 0; sal_uLong nCellCount = 0;
TableContainer::const_iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
nCellCount += (*it)->GetCellCount(); nCellCount += a->GetCellCount();
}
return nCellCount; return nCellCount;
} }
...@@ -6090,10 +6104,11 @@ sal_uLong ScDocument::GetCodeCount() const ...@@ -6090,10 +6104,11 @@ sal_uLong ScDocument::GetCodeCount() const
{ {
sal_uLong nCodeCount = 0; sal_uLong nCodeCount = 0;
TableContainer::const_iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end(); ++it) {
if ( *it ) if (a)
nCodeCount += (*it)->GetCodeCount(); nCodeCount += a->GetCodeCount();
}
return nCodeCount; return nCodeCount;
} }
...@@ -6178,10 +6193,14 @@ bool ScDocument::HasPrintRange() ...@@ -6178,10 +6193,14 @@ bool ScDocument::HasPrintRange()
{ {
bool bResult = false; bool bResult = false;
TableContainer::iterator it = maTabs.begin(); for (const auto& a : maTabs)
for (; it != maTabs.end() && !bResult; ++it) {
if ( *it ) if (!a)
bResult = (*it)->IsPrintEntireSheet() || ((*it)->GetPrintRangeCount() > 0); continue;
bResult = a->IsPrintEntireSheet() || (a->GetPrintRangeCount() > 0);
if (bResult)
break;
}
return bResult; return bResult;
} }
...@@ -6542,12 +6561,10 @@ size_t ScDocument::GetNoteCount( SCTAB nTab, SCCOL nCol ) const ...@@ -6542,12 +6561,10 @@ size_t ScDocument::GetNoteCount( SCTAB nTab, SCCOL nCol ) const
void ScDocument::CreateAllNoteCaptions() void ScDocument::CreateAllNoteCaptions()
{ {
TableContainer::iterator it = maTabs.begin(), itEnd = maTabs.end(); for (const auto& a : maTabs)
for (; it != itEnd; ++it)
{ {
ScTable* p = it->get(); if (a)
if (p) a->CreateAllNoteCaptions();
p->CreateAllNoteCaptions();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment