diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-12-01 15:19:04 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-01 18:26:01 +0100 |
commit | 56d97cdd0af15c90c744d2ac66e879818c073ec6 (patch) | |
tree | 98278957d27659cfa9fe5e9b1a4e2e550637fd73 /sfx2/source/control/templatelocalview.cxx | |
parent | fff501a3393b459c512ec155e2d2cd935e7885a2 (diff) |
Simplify containers iterations in sfx2, shell
Use range-based loop or replace with STL functions
Change-Id: I42361d6a73d201db8eb6dca09d79768e2d62051d
Reviewed-on: https://gerrit.libreoffice.org/64389
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/control/templatelocalview.cxx')
-rw-r--r-- | sfx2/source/control/templatelocalview.cxx | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx index 7272780bd32d..bb909106097f 100644 --- a/sfx2/source/control/templatelocalview.cxx +++ b/sfx2/source/control/templatelocalview.cxx @@ -444,28 +444,24 @@ bool TemplateLocalView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt if (pRegion->mnId == nSrcItemId) { TemplateContainerItem *pItem = pRegion.get(); - std::vector<TemplateItemProperties>::iterator pIter; - for (pIter = pItem->maTemplates.begin(); pIter != pItem->maTemplates.end(); ++pIter) + auto pIter = std::find_if(pItem->maTemplates.begin(), pItem->maTemplates.end(), + [nItemId](const TemplateItemProperties& rTemplate) { return rTemplate.nId == nItemId; }); + if (pIter != pItem->maTemplates.end()) { - if (pIter->nId == nItemId) - { - if (!mpDocTemplates->Delete(pItem->mnRegionId,pIter->nDocId)) - return false; - - pIter = pItem->maTemplates.erase(pIter); - - if (pRegion->mnRegionId == mnCurRegionId-1) - { - RemoveItem(nItemId); - Invalidate(); - } + if (!mpDocTemplates->Delete(pItem->mnRegionId,pIter->nDocId)) + return false; - // Update Doc Idx for all templates that follow - for (; pIter != pItem->maTemplates.end(); ++pIter) - pIter->nDocId = pIter->nDocId - 1; + pIter = pItem->maTemplates.erase(pIter); - break; + if (pRegion->mnRegionId == mnCurRegionId-1) + { + RemoveItem(nItemId); + Invalidate(); } + + // Update Doc Idx for all templates that follow + for (; pIter != pItem->maTemplates.end(); ++pIter) + pIter->nDocId = pIter->nDocId - 1; } CalculateItemPositions(); |