diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-12-08 18:27:03 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-10 10:18:46 +0100 |
commit | 7c7ec84c26a3a92635811e4cf491b7e21796e1fa (patch) | |
tree | a53b2dfcb3c717a4c13c4ebe7d5c6b5165054272 /sd/source/ui/sidebar/MasterPageContainer.cxx | |
parent | 86abd3ec30bac181df228569b70aaf9086ed5f4a (diff) |
Simplify containers iterations in sd/source/ui/[s-v]*
Use range-based loop or replace with STL functions
Change-Id: I13c9982ad1e1aadbc6189068c5a5e29dfb171e97
Reviewed-on: https://gerrit.libreoffice.org/64811
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui/sidebar/MasterPageContainer.cxx')
-rw-r--r-- | sd/source/ui/sidebar/MasterPageContainer.cxx | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/sd/source/ui/sidebar/MasterPageContainer.cxx b/sd/source/ui/sidebar/MasterPageContainer.cxx index c76105eae2eb..2a58f3619ff0 100644 --- a/sd/source/ui/sidebar/MasterPageContainer.cxx +++ b/sd/source/ui/sidebar/MasterPageContainer.cxx @@ -565,20 +565,20 @@ void MasterPageContainer::Implementation::UpdatePreviewSizePixel() int nHeight (3); // Search for the first entry with an existing master page. - MasterPageContainerType::const_iterator iDescriptor; - MasterPageContainerType::const_iterator iContainerEnd(maContainer.end()); - for (iDescriptor=maContainer.begin(); iDescriptor!=iContainerEnd; ++iDescriptor) - if (*iDescriptor!=nullptr && (*iDescriptor)->mpMasterPage != nullptr) - { - Size aPageSize ((*iDescriptor)->mpMasterPage->GetSize()); - OSL_ASSERT(aPageSize.Width() > 0 && aPageSize.Height() > 0); - if (aPageSize.Width() > 0) - nWidth = aPageSize.Width(); - if (aPageSize.Height() > 0) - nHeight = aPageSize.Height(); - mbFirstPageObjectSeen = true; - break; - } + auto iDescriptor = std::find_if(maContainer.begin(), maContainer.end(), + [](const SharedMasterPageDescriptor& rxDescriptor) { + return rxDescriptor != nullptr && rxDescriptor->mpMasterPage != nullptr; + }); + if (iDescriptor != maContainer.end()) + { + Size aPageSize ((*iDescriptor)->mpMasterPage->GetSize()); + OSL_ASSERT(aPageSize.Width() > 0 && aPageSize.Height() > 0); + if (aPageSize.Width() > 0) + nWidth = aPageSize.Width(); + if (aPageSize.Height() > 0) + nHeight = aPageSize.Height(); + mbFirstPageObjectSeen = true; + } maSmallPreviewSizePixel.setWidth( SMALL_PREVIEW_WIDTH ); maLargePreviewSizePixel.setWidth( LARGE_PREVIEW_WIDTH ); @@ -667,10 +667,9 @@ MasterPageContainer::Token MasterPageContainer::Implementation::PutMasterPage ( // appropriate events to the listeners. UpdateDescriptor(*aEntry,false,false, true); - std::vector<MasterPageContainerChangeEvent::EventType>::const_iterator iEventType; - for (iEventType=pEventTypes->begin(); iEventType!=pEventTypes->end(); ++iEventType) + for (auto& rEventType : *pEventTypes) { - FireContainerChange( *iEventType,(*aEntry)->maToken); + FireContainerChange(rEventType, (*aEntry)->maToken); } } } @@ -915,12 +914,11 @@ void MasterPageContainer::Implementation::FireContainerChange ( Token aToken) { ::std::vector<Link<MasterPageContainerChangeEvent&,void>> aCopy(maChangeListeners.begin(),maChangeListeners.end()); - ::std::vector<Link<MasterPageContainerChangeEvent&,void>>::iterator iListener; MasterPageContainerChangeEvent aEvent; aEvent.meEventType = eType; aEvent.maChildToken = aToken; - for (iListener=aCopy.begin(); iListener!=aCopy.end(); ++iListener) - iListener->Call(aEvent); + for (auto& rListener : aCopy) + rListener.Call(aEvent); } bool MasterPageContainer::Implementation::UpdateDescriptor ( |