summaryrefslogtreecommitdiff
path: root/sfx2/source/control/templatelocalview.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/control/templatelocalview.cxx')
-rw-r--r--sfx2/source/control/templatelocalview.cxx32
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();