summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-11-28 15:13:42 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-29 07:17:37 +0100
commit21de55596c0fdc2be736c6d0369bd9d3783020be (patch)
tree07d0f0cd54690e54405fe574c572cb2be74a3336 /sc
parentda9fb5d6d9ebf9363981c370ce937d8848989fcb (diff)
remove unnecessary "if (!empty()" checks before loops
found with git grep -n -A4 'if.*!.*empty' | grep -B3 -P '(\bfor)|(\bwhile)|(\bdo)' Change-Id: I582235b7cf977a0f9fb4099eb306fdb4a07b5334 Reviewed-on: https://gerrit.libreoffice.org/64169 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/table5.cxx18
-rw-r--r--sc/source/core/tool/addincol.cxx17
-rw-r--r--sc/source/core/tool/adiasync.cxx25
-rw-r--r--sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx21
-rw-r--r--sc/source/ui/app/inputwin.cxx20
-rw-r--r--sc/source/ui/dbgui/sfiltdlg.cxx19
-rw-r--r--sc/source/ui/docshell/docfunc.cxx11
-rw-r--r--sc/source/ui/navipi/content.cxx20
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx31
-rw-r--r--sc/source/ui/unoobj/listenercalls.cxx33
-rw-r--r--sc/source/ui/view/gridwin2.cxx2
11 files changed, 89 insertions, 128 deletions
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index ab908712f108..907d292b4d37 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1012,19 +1012,13 @@ void ScTable::SyncColRowFlags()
pRowFlags->AndValue(0, MAXROW, nManualBreakComplement);
mpColFlags->AndValue(0, MAXCOL+1, nManualBreakComplement);
- if (!maRowManualBreaks.empty())
- {
- for (set<SCROW>::const_iterator itr = maRowManualBreaks.begin(), itrEnd = maRowManualBreaks.end();
- itr != itrEnd; ++itr)
- pRowFlags->OrValue(*itr, CRFlags::ManualBreak);
- }
+ for (set<SCROW>::const_iterator itr = maRowManualBreaks.begin(), itrEnd = maRowManualBreaks.end();
+ itr != itrEnd; ++itr)
+ pRowFlags->OrValue(*itr, CRFlags::ManualBreak);
- if (!maColManualBreaks.empty())
- {
- for (set<SCCOL>::const_iterator itr = maColManualBreaks.begin(), itrEnd = maColManualBreaks.end();
- itr != itrEnd; ++itr)
- mpColFlags->OrValue(*itr, CRFlags::ManualBreak);
- }
+ for (set<SCCOL>::const_iterator itr = maColManualBreaks.begin(), itrEnd = maColManualBreaks.end();
+ itr != itrEnd; ++itr)
+ mpColFlags->OrValue(*itr, CRFlags::ManualBreak);
// Hidden flags.
lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, mpColFlags.get(), pRowFlags.get(), CRFlags::Hidden);
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 4e77457c9058..2ce4acabac43 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -605,19 +605,16 @@ bool ScUnoAddInCollection::GetCalcName( const OUString& rExcelName, OUString& rR
if ( pFuncData )
{
const ::std::vector<ScUnoAddInFuncData::LocalizedName>& rNames = pFuncData->GetCompNames();
- if ( !rNames.empty() )
+ ::std::vector<ScUnoAddInFuncData::LocalizedName>::const_iterator it( rNames.begin());
+ for ( ; it != rNames.end(); ++it)
{
- ::std::vector<ScUnoAddInFuncData::LocalizedName>::const_iterator it( rNames.begin());
- for ( ; it != rNames.end(); ++it)
+ if ( ScGlobal::pCharClass->uppercase( (*it).maName ) == aUpperCmp )
{
- if ( ScGlobal::pCharClass->uppercase( (*it).maName ) == aUpperCmp )
- {
- //TODO: store upper case for comparing?
+ //TODO: store upper case for comparing?
- // use the first function that has this name for any language
- rRetCalcName = pFuncData->GetOriginalName();
- return true;
- }
+ // use the first function that has this name for any language
+ rRetCalcName = pFuncData->GetOriginalName();
+ return true;
}
}
}
diff --git a/sc/source/core/tool/adiasync.cxx b/sc/source/core/tool/adiasync.cxx
index 9a0770b7addb..05502b552625 100644
--- a/sc/source/core/tool/adiasync.cxx
+++ b/sc/source/core/tool/adiasync.cxx
@@ -121,20 +121,17 @@ void ScAddInAsync::CallBack( sal_uLong nHandleP, void* pData )
void ScAddInAsync::RemoveDocument( ScDocument* pDocumentP )
{
- if ( !theAddInAsyncTbl.empty() )
- {
- for( ScAddInAsyncs::reverse_iterator iter1 = theAddInAsyncTbl.rbegin(); iter1 != theAddInAsyncTbl.rend(); ++iter1 )
- { // backwards because of pointer-movement in array
- ScAddInAsync* pAsync = iter1->get();
- ScAddInDocs* p = pAsync->pDocs.get();
- ScAddInDocs::iterator iter2 = p->find( pDocumentP );
- if( iter2 != p->end() )
- {
- p->erase( iter2 );
- if ( p->empty() )
- { // this AddIn is not used anymore
- theAddInAsyncTbl.erase( --(iter1.base()) );
- }
+ for( ScAddInAsyncs::reverse_iterator iter1 = theAddInAsyncTbl.rbegin(); iter1 != theAddInAsyncTbl.rend(); ++iter1 )
+ { // backwards because of pointer-movement in array
+ ScAddInAsync* pAsync = iter1->get();
+ ScAddInDocs* p = pAsync->pDocs.get();
+ ScAddInDocs::iterator iter2 = p->find( pDocumentP );
+ if( iter2 != p->end() )
+ {
+ p->erase( iter2 );
+ if ( p->empty() )
+ { // this AddIn is not used anymore
+ theAddInAsyncTbl.erase( --(iter1.base()) );
}
}
}
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index 49e7b5850a74..acd43adcea6a 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -484,21 +484,18 @@ std::unique_ptr<ScChangeAction> ScXMLChangeTrackingImportHelper::CreateContentAc
void ScXMLChangeTrackingImportHelper::CreateGeneratedActions(std::deque<ScMyGenerated>& rList)
{
- if (!rList.empty())
+ for (ScMyGenerated & rGenerated : rList)
{
- for (ScMyGenerated & rGenerated : rList)
+ if (rGenerated.nID == 0)
{
- if (rGenerated.nID == 0)
- {
- ScCellValue aCell;
- if (rGenerated.pCellInfo)
- aCell = rGenerated.pCellInfo->CreateCell(pDoc);
+ ScCellValue aCell;
+ if (rGenerated.pCellInfo)
+ aCell = rGenerated.pCellInfo->CreateCell(pDoc);
- if (!aCell.isEmpty())
- {
- rGenerated.nID = pTrack->AddLoadedGenerated(aCell, rGenerated.aBigRange, rGenerated.pCellInfo->sInputString);
- OSL_ENSURE(rGenerated.nID, "could not insert generated action");
- }
+ if (!aCell.isEmpty())
+ {
+ rGenerated.nID = pTrack->AddLoadedGenerated(aCell, rGenerated.aBigRange, rGenerated.pCellInfo->sInputString);
+ OSL_ENSURE(rGenerated.nID, "could not insert generated action");
}
}
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 71abccec99a4..d7f51e0c7b7b 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1882,14 +1882,11 @@ void ScPosWnd::FillRangeNames()
ScRange aDummy;
std::set<OUString> aSet;
ScRangeName* pRangeNames = rDoc.GetRangeName();
- if (!pRangeNames->empty())
+ ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
{
- ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
- for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
- {
- if (itr->second->IsValidReference(aDummy))
- aSet.insert(itr->second->GetName());
- }
+ if (itr->second->IsValidReference(aDummy))
+ aSet.insert(itr->second->GetName());
}
for (SCTAB i = 0; i < rDoc.GetTableCount(); ++i)
{
@@ -1906,13 +1903,10 @@ void ScPosWnd::FillRangeNames()
}
}
- if (!aSet.empty())
+ for (std::set<OUString>::iterator itr = aSet.begin();
+ itr != aSet.end(); ++itr)
{
- for (std::set<OUString>::iterator itr = aSet.begin();
- itr != aSet.end(); ++itr)
- {
- InsertEntry(*itr);
- }
+ InsertEntry(*itr);
}
}
SetText(aPosStr);
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
index 33010a009833..583b5d61517c 100644
--- a/sc/source/ui/dbgui/sfiltdlg.cxx
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -163,19 +163,16 @@ void ScSpecialFilterDlg::Init( const SfxItemSet& rArgSet )
pLbFilterArea->Clear();
pLbFilterArea->InsertEntry( aStrUndefined, 0 );
- if (!pRangeNames->empty())
+ ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ for (; itr != itrEnd; ++itr)
{
- ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
- for (; itr != itrEnd; ++itr)
- {
- if (!itr->second->HasType(ScRangeData::Type::Criteria))
- continue;
+ if (!itr->second->HasType(ScRangeData::Type::Criteria))
+ continue;
- const sal_Int32 nInsert = pLbFilterArea->InsertEntry(itr->second->GetName());
- OUString aSymbol;
- itr->second->GetSymbol(aSymbol);
- pLbFilterArea->SetEntryData(nInsert, new OUString(aSymbol));
- }
+ const sal_Int32 nInsert = pLbFilterArea->InsertEntry(itr->second->GetName());
+ OUString aSymbol;
+ itr->second->GetSymbol(aSymbol);
+ pLbFilterArea->SetEntryData(nInsert, new OUString(aSymbol));
}
// is there a stored source range?
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 2a0f21fa5299..d3622d2c6f1e 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1099,14 +1099,11 @@ void ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
bRet = SetEditCell(rPos, *pNewData, !bApi);
// Set the paragraph attributes back to the EditEngine.
- if (!aRememberItems.empty())
+ ScMyRememberItemVector::iterator aItr = aRememberItems.begin();
+ while (aItr != aRememberItems.end())
{
- ScMyRememberItemVector::iterator aItr = aRememberItems.begin();
- while (aItr != aRememberItems.end())
- {
- rEngine.SetParaAttribs((*aItr)->nIndex, (*aItr)->aItemSet);
- ++aItr;
- }
+ rEngine.SetParaAttribs((*aItr)->nIndex, (*aItr)->aItemSet);
+ ++aItr;
}
// #i61702# if the content isn't accessed, there's no need to set the UpdateMode again
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index cd1f340dea28..cca7461fea0b 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -891,14 +891,11 @@ void ScContentTree::GetAreaNames()
ScRange aDummy;
std::set<OUString> aSet;
ScRangeName* pRangeNames = pDoc->GetRangeName();
- if (!pRangeNames->empty())
+ ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
+ for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
{
- ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
- for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
- {
- if (itr->second->IsValidReference(aDummy))
- aSet.insert(itr->second->GetName());
- }
+ if (itr->second->IsValidReference(aDummy))
+ aSet.insert(itr->second->GetName());
}
for (SCTAB i = 0; i < pDoc->GetTableCount(); ++i)
{
@@ -915,13 +912,10 @@ void ScContentTree::GetAreaNames()
}
}
- if (!aSet.empty())
+ for (std::set<OUString>::iterator itr = aSet.begin();
+ itr != aSet.end(); ++itr)
{
- for (std::set<OUString>::iterator itr = aSet.begin();
- itr != aSet.end(); ++itr)
- {
- InsertContent(ScContentId::RANGENAME, *itr);
- }
+ InsertContent(ScContentId::RANGENAME, *itr);
}
}
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index d9537c86acf7..956b0ee64bc1 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -4438,24 +4438,21 @@ static bool lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
// named entry in this object?
- if ( !rNamedEntries.empty() )
- {
- for (const auto & rNamedEntry : rNamedEntries)
- if ( rNamedEntry.GetName() == rName )
- {
- // test if named entry is contained in rRanges
+ for (const auto & rNamedEntry : rNamedEntries)
+ if ( rNamedEntry.GetName() == rName )
+ {
+ // test if named entry is contained in rRanges
- const ScRange& rComp = rNamedEntry.GetRange();
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList( rRanges, false );
- aMarkData.MarkToMulti(); // needed for IsAllMarked
- if ( aMarkData.IsAllMarked( rComp ) )
- {
- rFound = rComp;
- return true;
- }
+ const ScRange& rComp = rNamedEntry.GetRange();
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( rRanges, false );
+ aMarkData.MarkToMulti(); // needed for IsAllMarked
+ if ( aMarkData.IsAllMarked( rComp ) )
+ {
+ rFound = rComp;
+ return true;
}
- }
+ }
return false; // not found
}
@@ -4483,7 +4480,7 @@ void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
ScRangeList aDiff;
bool bValid = ( aDiff.Parse( aName, &pDocSh->GetDocument() ) & ScRefFlags::VALID )
== ScRefFlags::VALID;
- if (!bValid && !m_pImpl->m_aNamedEntries.empty())
+ if (!bValid)
{
sal_uInt16 nCount = m_pImpl->m_aNamedEntries.size();
for (sal_uInt16 n=0; n<nCount && !bValid; n++)
diff --git a/sc/source/ui/unoobj/listenercalls.cxx b/sc/source/ui/unoobj/listenercalls.cxx
index c7e30f314913..d05938d85101 100644
--- a/sc/source/ui/unoobj/listenercalls.cxx
+++ b/sc/source/ui/unoobj/listenercalls.cxx
@@ -46,28 +46,25 @@ void ScUnoListenerCalls::ExecuteAndClear()
// During each modified() call, Add may be called again.
// These new calls are executed here, too.
- if (!aEntries.empty())
+ std::vector<ScUnoListenerEntry>::iterator aItr(aEntries.begin());
+ while (aItr != aEntries.end())
{
- std::vector<ScUnoListenerEntry>::iterator aItr(aEntries.begin());
- while (aItr != aEntries.end())
+ ScUnoListenerEntry aEntry = *aItr;
+ try
{
- ScUnoListenerEntry aEntry = *aItr;
- try
- {
- aEntry.xListener->modified( aEntry.aEvent );
- }
- catch ( const uno::RuntimeException& )
- {
- // the listener is an external object and may throw a RuntimeException
- // for reasons we don't know
- }
+ aEntry.xListener->modified( aEntry.aEvent );
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ // the listener is an external object and may throw a RuntimeException
+ // for reasons we don't know
+ }
- // New calls that are added during the modified() call are appended to the end
- // of aEntries, so the loop will catch them, too (as long as erase happens
- // after modified).
+ // New calls that are added during the modified() call are appended to the end
+ // of aEntries, so the loop will catch them, too (as long as erase happens
+ // after modified).
- aItr = aEntries.erase(aItr);
- }
+ aItr = aEntries.erase(aItr);
}
}
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 3864714bb752..8f3ae51260de 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -515,7 +515,7 @@ void ScGridWindow::DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScr
ScMenuFloatingWindow* pSubMenu = mpDPFieldPopup->addSubMenuItem(
ScResId(STR_MENU_SORT_CUSTOM), !aUserSortNames.empty());
- if (pSubMenu && !aUserSortNames.empty())
+ if (pSubMenu)
{
size_t n = aUserSortNames.size();
for (size_t i = 0; i < n; ++i)