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 | |
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')
44 files changed, 265 insertions, 428 deletions
diff --git a/sd/source/ui/sidebar/AllMasterPagesSelector.cxx b/sd/source/ui/sidebar/AllMasterPagesSelector.cxx index 6c768d00d2ae..4520f9ecb005 100644 --- a/sd/source/ui/sidebar/AllMasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/AllMasterPagesSelector.cxx @@ -174,10 +174,8 @@ void AllMasterPagesSelector::AddItem (MasterPageContainer::Token aToken) void AllMasterPagesSelector::UpdatePageSet (ItemList& rItemList) { - SortedMasterPageDescriptorList::const_iterator iDescriptor; - SortedMasterPageDescriptorList::const_iterator iEnd (mpSortedMasterPages->end()); - for (iDescriptor=mpSortedMasterPages->begin(); iDescriptor!=iEnd; ++iDescriptor) - rItemList.push_back((*iDescriptor)->maToken); + for (const auto& rxDescriptor : *mpSortedMasterPages) + rItemList.push_back(rxDescriptor->maToken); } } } // end of namespace sd::sidebar diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx index 9392d5fa4ab6..31a4b1df7c16 100644 --- a/sd/source/ui/sidebar/DocumentHelper.cxx +++ b/sd/source/ui/sidebar/DocumentHelper.cxx @@ -301,17 +301,16 @@ void DocumentHelper::AssignMasterPageToPageList ( // Create a second list that contains only the valid pointers to // pages for which an assignment is necessary. - ::std::vector<SdPage*>::const_iterator iPage; ::std::vector<SdPage*> aCleanedList; - for (iPage=rpPageList->begin(); iPage!=rpPageList->end(); ++iPage) + for (const auto& rpPage : *rpPageList) { - OSL_ASSERT(*iPage!=nullptr && &(*iPage)->getSdrModelFromSdrPage() == &rTargetDocument); - if (*iPage != nullptr && (*iPage)->GetLayoutName() != sFullLayoutName) + OSL_ASSERT(rpPage!=nullptr && &rpPage->getSdrModelFromSdrPage() == &rTargetDocument); + if (rpPage != nullptr && rpPage->GetLayoutName() != sFullLayoutName) { - aCleanedList.push_back(*iPage); + aCleanedList.push_back(rpPage); } } - if (aCleanedList.empty() ) + if (aCleanedList.empty() ) return; SfxUndoManager* pUndoMgr = rTargetDocument.GetDocSh()->GetUndoManager(); @@ -323,14 +322,12 @@ void DocumentHelper::AssignMasterPageToPageList ( return; // Assign the master pages to the given list of pages. - for (iPage=aCleanedList.begin(); - iPage!=aCleanedList.end(); - ++iPage) + for (const auto& rpPage : aCleanedList) { AssignMasterPageToPage ( pMasterPageInDocument, sBaseLayoutName, - *iPage); + rpPage); } if( pUndoMgr ) diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index e0da346e9d6a..eb81998a3a37 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -430,18 +430,17 @@ void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout) if (pPageSelection->empty()) break; - ::std::vector<SdPage*>::iterator iPage; - for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage) - { - if ((*iPage) == nullptr) - continue; - - // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters. - SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT); - aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2)); - aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); - pMainViewShell->ExecuteSlot (aRequest, false); - } + for (const auto& rpPage : *pPageSelection) + { + if (rpPage == nullptr) + continue; + + // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters. + SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT); + aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, (rpPage->GetPageNum()-1)/2)); + aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); + pMainViewShell->ExecuteSlot (aRequest, false); + } } while(false); } 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 ( diff --git a/sd/source/ui/sidebar/MasterPageObserver.cxx b/sd/source/ui/sidebar/MasterPageObserver.cxx index 501d0f55ceac..93d6f4cfd7e0 100644 --- a/sd/source/ui/sidebar/MasterPageObserver.cxx +++ b/sd/source/ui/sidebar/MasterPageObserver.cxx @@ -191,14 +191,11 @@ void MasterPageObserver::Implementation::AddEventListener ( // Tell the new listener about all the master pages that are // currently in use. - MasterPageContainer::iterator aDocumentIterator; - for (aDocumentIterator=maUsedMasterPages.begin(); - aDocumentIterator!=maUsedMasterPages.end(); - ++aDocumentIterator) + for (const auto& rDocument : maUsedMasterPages) { ::std::set<OUString>::reverse_iterator aNameIterator; - for (aNameIterator=aDocumentIterator->second.rbegin(); - aNameIterator!=aDocumentIterator->second.rend(); + for (aNameIterator=rDocument.second.rbegin(); + aNameIterator!=rDocument.second.rend(); ++aNameIterator) { MasterPageObserverEvent aEvent ( diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index 4fea1417a7a9..86b6ab52e7e3 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -139,18 +139,15 @@ void MasterPagesSelector::UpdateLocks (const ItemList& rItemList) // deletion and re-creation of MasterPageDescriptor objects. // Lock the master pages in the given list. - ItemList::const_iterator iItem; - for (iItem=rItemList.begin(); iItem!=rItemList.end(); ++iItem) + for (const auto& rItem : rItemList) { - mpContainer->AcquireToken(*iItem); - aNewLockList.push_back(*iItem); + mpContainer->AcquireToken(rItem); + aNewLockList.push_back(rItem); } // Release the previously locked master pages. - ItemList::const_iterator iPage; - ItemList::const_iterator iEnd (maLockedMasterPages.end()); - for (iPage=maLockedMasterPages.begin(); iPage!=iEnd; ++iPage) - mpContainer->ReleaseToken(*iPage); + for (const auto& rPage : maLockedMasterPages) + mpContainer->ReleaseToken(rPage); maLockedMasterPages.swap(aNewLockList); } @@ -622,15 +619,9 @@ void MasterPagesSelector::InvalidateItem (MasterPageContainer::Token aToken) { const ::osl::MutexGuard aGuard (maMutex); - ItemList::iterator iItem; - for (iItem=maCurrentItemList.begin(); iItem!=maCurrentItemList.end(); ++iItem) - { - if (*iItem == aToken) - { - *iItem = MasterPageContainer::NIL_TOKEN; - break; - } - } + auto iItem = std::find(maCurrentItemList.begin(), maCurrentItemList.end(), aToken); + if (iItem != maCurrentItemList.end()) + *iItem = MasterPageContainer::NIL_TOKEN; } void MasterPagesSelector::UpdateItemList (::std::unique_ptr<ItemList> && pNewItemList) diff --git a/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx b/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx index 5d471b11d53f..dce1e79aa17b 100644 --- a/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx +++ b/sd/source/ui/sidebar/RecentlyUsedMasterPages.cxx @@ -205,11 +205,8 @@ void RecentlyUsedMasterPages::SavePersistentValues() xSet, UNO_QUERY); if ( ! xChildFactory.is()) return; - MasterPageList::const_iterator iDescriptor; sal_Int32 nIndex(0); - for (iDescriptor=mvMasterPages.begin(); - iDescriptor!=mvMasterPages.end(); - ++iDescriptor,++nIndex) + for (const auto& rDescriptor : mvMasterPages) { // Create new child. OUString sKey ("index_"); @@ -220,12 +217,13 @@ void RecentlyUsedMasterPages::SavePersistentValues() { xSet->insertByName (sKey, makeAny(xChild)); - aValue <<= iDescriptor->msURL; + aValue <<= rDescriptor.msURL; xChild->replaceByName (sURLMemberName, aValue); - aValue <<= iDescriptor->msName; + aValue <<= rDescriptor.msName; xChild->replaceByName (sNameMemberName, aValue); } + ++nIndex; } // Write the data back to disk. @@ -356,21 +354,20 @@ void RecentlyUsedMasterPages::ResolveList() { bool bNotify (false); - MasterPageList::iterator iDescriptor; - for (iDescriptor=mvMasterPages.begin(); iDescriptor!=mvMasterPages.end(); ++iDescriptor) + for (auto& rDescriptor : mvMasterPages) { - if (iDescriptor->maToken == MasterPageContainer::NIL_TOKEN) + if (rDescriptor.maToken == MasterPageContainer::NIL_TOKEN) { - MasterPageContainer::Token aToken (mpContainer->GetTokenForURL(iDescriptor->msURL)); - iDescriptor->maToken = aToken; + MasterPageContainer::Token aToken (mpContainer->GetTokenForURL(rDescriptor.msURL)); + rDescriptor.maToken = aToken; if (aToken != MasterPageContainer::NIL_TOKEN) bNotify = true; } else { - if ( ! mpContainer->HasToken(iDescriptor->maToken)) + if ( ! mpContainer->HasToken(rDescriptor.maToken)) { - iDescriptor->maToken = MasterPageContainer::NIL_TOKEN; + rDescriptor.maToken = MasterPageContainer::NIL_TOKEN; bNotify = true; } } diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index dc9549be6888..1fe733db069a 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -1183,13 +1183,10 @@ void SlideshowImpl::removeShapeEvents() { if( mxShow.is() && mxListenerProxy.is() ) try { - WrappedShapeEventImplMap::iterator aIter; - const WrappedShapeEventImplMap::iterator aEnd( maShapeEventMap.end() ); - - for( aIter = maShapeEventMap.begin(); aIter != aEnd; ++aIter ) + for( const auto& rEntry : maShapeEventMap ) { - mxListenerProxy->removeShapeEventListener( (*aIter).first ); - mxShow->setShapeCursor( (*aIter).first, awt::SystemPointer::ARROW ); + mxListenerProxy->removeShapeEventListener( rEntry.first ); + mxShow->setShapeCursor( rEntry.first, awt::SystemPointer::ARROW ); } maShapeEventMap.clear(); @@ -2283,11 +2280,9 @@ void SlideshowImpl::createSlideList( bool bAll, const OUString& rPresSlide ) mpSlideController->insertSlideNumber( static_cast<sal_uInt16>(nSlide) ); } - sal_Int32 nSlideIndex = 0; - for( SdCustomShow::PageVec::iterator it = pCustomShow->PagesVector().begin(); - it != pCustomShow->PagesVector().end(); ++it, nSlideIndex++ ) + for( const auto& rpPage : pCustomShow->PagesVector() ) { - const sal_uInt16 nSdSlide = ( (*it)->GetPageNum() - 1 ) / 2; + const sal_uInt16 nSdSlide = ( rpPage->GetPageNum() - 1 ) / 2; if( ! mpDoc->GetSdPage( nSdSlide, PageKind::Standard )->IsExcluded()) mpSlideController->insertSlideNumber( nSdSlide ); diff --git a/sd/source/ui/slideshow/slideshowviewimpl.cxx b/sd/source/ui/slideshow/slideshowviewimpl.cxx index b5de0743c336..4e1e24b07f65 100644 --- a/sd/source/ui/slideshow/slideshowviewimpl.cxx +++ b/sd/source/ui/slideshow/slideshowviewimpl.cxx @@ -94,10 +94,9 @@ void SlideShowViewListeners::disposing( const lang::EventObject& _rEventSource ) { ::osl::MutexGuard aGuard( mrMutex ); - ViewListenerVector::iterator aIter( maListeners.begin() ); - while( aIter != maListeners.end() ) + for( const auto& rxListener : maListeners ) { - Reference< util::XModifyListener > xListener( *aIter++ ); + Reference< util::XModifyListener > xListener( rxListener ); if( xListener.is() ) xListener->disposing( _rEventSource ); } diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx index 9cfd0867d6fc..01659b9211aa 100644 --- a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx +++ b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx @@ -249,10 +249,9 @@ void BitmapCache::InvalidateCache() { ::osl::MutexGuard aGuard (maMutex); - CacheBitmapContainer::iterator iEntry; - for (iEntry=mpBitmapContainer->begin(); iEntry!=mpBitmapContainer->end(); ++iEntry) + for (auto& rEntry : *mpBitmapContainer) { - iEntry->second.Invalidate(); + rEntry.second.Invalidate(); } ReCalculateTotalCacheSize(); } @@ -330,13 +329,12 @@ void BitmapCache::ReCalculateTotalCacheSize() mnNormalCacheSize = 0; mnPreciousCacheSize = 0; - CacheBitmapContainer::iterator iEntry; - for (iEntry=mpBitmapContainer->begin(); iEntry!=mpBitmapContainer->end(); ++iEntry) + for (const auto& rEntry : *mpBitmapContainer) { - if (iEntry->second.IsPrecious()) - mnPreciousCacheSize += iEntry->second.GetMemorySize(); + if (rEntry.second.IsPrecious()) + mnPreciousCacheSize += rEntry.second.GetMemorySize(); else - mnNormalCacheSize += iEntry->second.GetMemorySize(); + mnNormalCacheSize += rEntry.second.GetMemorySize(); } mbIsFull = (mnNormalCacheSize >= mnMaximalNormalCacheSize); @@ -347,16 +345,13 @@ void BitmapCache::Recycle (const BitmapCache& rCache) { ::osl::MutexGuard aGuard (maMutex); - CacheBitmapContainer::const_iterator iOtherEntry; - for (iOtherEntry=rCache.mpBitmapContainer->begin(); - iOtherEntry!=rCache.mpBitmapContainer->end(); - ++iOtherEntry) + for (const auto& rOtherEntry : *rCache.mpBitmapContainer) { - CacheBitmapContainer::iterator iEntry (mpBitmapContainer->find(iOtherEntry->first)); + CacheBitmapContainer::iterator iEntry (mpBitmapContainer->find(rOtherEntry.first)); if (iEntry == mpBitmapContainer->end()) { iEntry = mpBitmapContainer->emplace( - iOtherEntry->first, + rOtherEntry.first, CacheEntry(mnCurrentAccessTime++, true) ).first; UpdateCacheSize(iEntry->second, ADD); @@ -364,7 +359,7 @@ void BitmapCache::Recycle (const BitmapCache& rCache) if (iEntry != mpBitmapContainer->end()) { UpdateCacheSize(iEntry->second, REMOVE); - iEntry->second.Recycle(iOtherEntry->second); + iEntry->second.Recycle(rOtherEntry.second); UpdateCacheSize(iEntry->second, ADD); } } @@ -379,16 +374,15 @@ void BitmapCache::Recycle (const BitmapCache& rCache) aSortedContainer.reserve(mpBitmapContainer->size()); // Copy the relevant entries. - CacheBitmapContainer::iterator iEntry; - for (iEntry=mpBitmapContainer->begin(); iEntry!=mpBitmapContainer->end(); ++iEntry) + for (const auto& rEntry : *mpBitmapContainer) { - if ( iEntry->second.IsPrecious()) + if ( rEntry.second.IsPrecious()) continue; - if ( ! iEntry->second.HasPreview()) + if ( ! rEntry.second.HasPreview()) continue; - aSortedContainer.emplace_back(iEntry->first,iEntry->second); + aSortedContainer.emplace_back(rEntry.first, rEntry.second); } // Sort the remaining entries. @@ -396,10 +390,9 @@ void BitmapCache::Recycle (const BitmapCache& rCache) // Return a list with the keys of the sorted entries. ::std::unique_ptr<CacheIndex> pIndex(new CacheIndex); - SortableBitmapContainer::iterator iIndexEntry; pIndex->reserve(aSortedContainer.size()); - for (iIndexEntry=aSortedContainer.begin(); iIndexEntry!=aSortedContainer.end(); ++iIndexEntry) - pIndex->push_back(iIndexEntry->first); + for (const auto& rIndexEntry : aSortedContainer) + pIndex->push_back(rIndexEntry.first); return pIndex; } diff --git a/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx b/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx index b6955b78c9e4..e1b04310893f 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx @@ -172,13 +172,12 @@ void CacheCompactionByCompression::Run() ::std::unique_ptr< ::sd::slidesorter::cache::BitmapCache::CacheIndex> pIndex ( mrCache.GetCacheIndex()); - ::sd::slidesorter::cache::BitmapCache::CacheIndex::iterator iIndex; - for (iIndex=pIndex->begin(); iIndex!=pIndex->end(); ++iIndex) + for (const auto& rpIndex : *pIndex) { - if (*iIndex == nullptr) + if (rpIndex == nullptr) continue; - mrCache.Compress(*iIndex, mpCompressor); + mrCache.Compress(rpIndex, mpCompressor); if (mrCache.GetSize() < mnMaximalCacheSize) break; } diff --git a/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx b/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx index 5471e62c6602..3077acb40a19 100644 --- a/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx +++ b/sd/source/ui/slidesorter/cache/SlsPageCacheManager.cxx @@ -228,30 +228,27 @@ void PageCacheManager::Recycle ( BestFittingPageCaches aCaches; // Add bitmap caches from active caches. - PageCacheContainer::iterator iActiveCache; - for (iActiveCache=mpPageCaches->begin(); iActiveCache!=mpPageCaches->end(); ++iActiveCache) + for (auto& rActiveCache : *mpPageCaches) { - if (iActiveCache->first.mpDocument == pDocument) + if (rActiveCache.first.mpDocument == pDocument) aCaches.emplace_back( - iActiveCache->first.maPreviewSize, iActiveCache->second); + rActiveCache.first.maPreviewSize, rActiveCache.second); } // Add bitmap caches from recently used caches. RecentlyUsedPageCaches::iterator iQueue (mpRecentlyUsedPageCaches->find(pDocument)); if (iQueue != mpRecentlyUsedPageCaches->end()) { - RecentlyUsedQueue::const_iterator iRecentCache; - for (iRecentCache=iQueue->second.begin();iRecentCache!=iQueue->second.end();++iRecentCache) + for (const auto& rRecentCache : iQueue->second) aCaches.emplace_back( - iRecentCache->maPreviewSize, iRecentCache->mpCache); + rRecentCache.maPreviewSize, rRecentCache.mpCache); } ::std::sort(aCaches.begin(), aCaches.end(), BestFittingCacheComparer(rPreviewSize)); - BestFittingPageCaches::const_iterator iBestCache; - for (iBestCache=aCaches.begin(); iBestCache!=aCaches.end(); ++iBestCache) + for (const auto& rBestCache : aCaches) { - rpCache->Recycle(*iBestCache->second); + rpCache->Recycle(*rBestCache.second); } } @@ -322,18 +319,17 @@ bool PageCacheManager::InvalidatePreviewBitmap ( // Iterate over all caches that are currently in use and invalidate // the previews in those that belong to the document. PageCacheContainer::iterator iCache; - for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache) - if (iCache->first.mpDocument == pDocument) - bHasChanged |= iCache->second->InvalidateBitmap(pKey); + for (auto& rCache : *mpPageCaches) + if (rCache.first.mpDocument == pDocument) + bHasChanged |= rCache.second->InvalidateBitmap(pKey); // Invalidate the previews in the recently used caches belonging to // the given document. RecentlyUsedPageCaches::iterator iQueue (mpRecentlyUsedPageCaches->find(pDocument)); if (iQueue != mpRecentlyUsedPageCaches->end()) { - RecentlyUsedQueue::const_iterator iCache2; - for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2) - bHasChanged |= iCache2->mpCache->InvalidateBitmap(pKey); + for (const auto& rCache2 : iQueue->second) + bHasChanged |= rCache2.mpCache->InvalidateBitmap(pKey); } } @@ -347,19 +343,17 @@ void PageCacheManager::InvalidateAllPreviewBitmaps (const DocumentKey& pDocument // Iterate over all caches that are currently in use and invalidate the // previews in those that belong to the document. - PageCacheContainer::iterator iCache; - for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache) - if (iCache->first.mpDocument == pDocument) - iCache->second->InvalidateCache(); + for (auto& rCache : *mpPageCaches) + if (rCache.first.mpDocument == pDocument) + rCache.second->InvalidateCache(); // Invalidate the previews in the recently used caches belonging to the // given document. RecentlyUsedPageCaches::iterator iQueue (mpRecentlyUsedPageCaches->find(pDocument)); if (iQueue != mpRecentlyUsedPageCaches->end()) { - RecentlyUsedQueue::const_iterator iCache2; - for (iCache2=iQueue->second.begin(); iCache2!=iQueue->second.end(); ++iCache2) - iCache2->mpCache->InvalidateCache(); + for (const auto& rCache2 : iQueue->second) + rCache2.mpCache->InvalidateCache(); } } @@ -367,9 +361,8 @@ void PageCacheManager::InvalidateAllCaches() { // Iterate over all caches that are currently in use and invalidate // them. - PageCacheContainer::iterator iCache; - for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache) - iCache->second->InvalidateCache(); + for (auto& rCache : *mpPageCaches) + rCache.second->InvalidateCache(); // Remove all recently used caches, there is not much sense in storing // invalidated and unused caches. @@ -378,9 +371,8 @@ void PageCacheManager::InvalidateAllCaches() void PageCacheManager::ReleasePreviewBitmap (const SdrPage* pPage) { - PageCacheContainer::iterator iCache; - for (iCache=mpPageCaches->begin(); iCache!=mpPageCaches->end(); ++iCache) - iCache->second->ReleaseBitmap(pPage); + for (auto& rCache : *mpPageCaches) + rCache.second->ReleaseBitmap(pPage); } std::shared_ptr<BitmapCache> PageCacheManager::GetRecentlyUsedCache ( @@ -393,14 +385,13 @@ std::shared_ptr<BitmapCache> PageCacheManager::GetRecentlyUsedCache ( RecentlyUsedPageCaches::iterator iQueue (mpRecentlyUsedPageCaches->find(pDocument)); if (iQueue != mpRecentlyUsedPageCaches->end()) { - RecentlyUsedQueue::iterator iCache; - for (iCache=iQueue->second.begin(); iCache!= iQueue->second.end(); ++iCache) - if (iCache->maPreviewSize == rPreviewSize) - { - pCache = iCache->mpCache; - iQueue->second.erase(iCache); - break; - } + RecentlyUsedQueue::iterator iCache = std::find_if(iQueue->second.begin(), iQueue->second.end(), + [&rPreviewSize](const RecentlyUsedCacheDescriptor& rCache) { return rCache.maPreviewSize == rPreviewSize; }); + if (iCache != iQueue->second.end()) + { + pCache = iCache->mpCache; + iQueue->second.erase(iCache); + } } return pCache; diff --git a/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx b/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx index 471b8b47147e..c0993f92b96d 100644 --- a/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx +++ b/sd/source/ui/slidesorter/cache/SlsRequestFactory.cxx @@ -40,20 +40,16 @@ void RequestFactory::operator()( aKeys = rpCacheContext->GetEntryList(true); if (aKeys != nullptr) { - std::vector<CacheKey>::const_iterator iKey; - std::vector<CacheKey>::const_iterator iEnd (aKeys->end()); - for (iKey=aKeys->begin(); iKey!=iEnd; ++iKey) - rRequestQueue.AddRequest(*iKey, VISIBLE_NO_PREVIEW); + for (const auto& rKey : *aKeys) + rRequestQueue.AddRequest(rKey, VISIBLE_NO_PREVIEW); } // Add the requests for the non-visible pages. aKeys = rpCacheContext->GetEntryList(false); if (aKeys != nullptr) { - std::vector<CacheKey>::const_iterator iKey; - std::vector<CacheKey>::const_iterator iEnd (aKeys->end()); - for (iKey=aKeys->begin(); iKey!=iEnd; ++iKey) - rRequestQueue.AddRequest(*iKey, NOT_VISIBLE); + for (const auto& rKey : *aKeys) + rRequestQueue.AddRequest(rKey, NOT_VISIBLE); } } diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx index ce31c1258de0..9f7c5c59f8f9 100644 --- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx +++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx @@ -255,9 +255,9 @@ void RequestQueue::Clear() { ::osl::MutexGuard aGuard (maMutex); - for (Container::iterator aI = mpRequestQueue->begin(), aEnd = mpRequestQueue->end(); aI != aEnd; ++aI) + for (const auto& rItem : *mpRequestQueue) { - SdrPage *pPage = const_cast<SdrPage*>(aI->maKey); + SdrPage *pPage = const_cast<SdrPage*>(rItem.maKey); pPage->RemovePageUser(*this); } diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 6d9bf0bd1de3..121e0067b891 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -802,12 +802,9 @@ void SlideSorterController::FinishEditModeChange() // Restore the selection. mpPageSelector->DeselectAllPages(); - ::std::vector<SdPage*>::iterator iPage; - for (iPage=maSelectionBeforeSwitch.begin(); - iPage!=maSelectionBeforeSwitch.end(); - ++iPage) + for (const auto& rpPage : maSelectionBeforeSwitch) { - mpPageSelector->SelectPage(*iPage); + mpPageSelector->SelectPage(rpPage); } maSelectionBeforeSwitch.clear( ); } diff --git a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx index 5ead8fad8ee1..3b0b183801f6 100644 --- a/sd/source/ui/slidesorter/controller/SlsAnimator.cxx +++ b/sd/source/ui/slidesorter/controller/SlsAnimator.cxx @@ -84,9 +84,8 @@ void Animator::Dispose() mbIsDisposed = true; AnimationList aCopy (maAnimations); - AnimationList::const_iterator iAnimation; - for (iAnimation=aCopy.begin(); iAnimation!=aCopy.end(); ++iAnimation) - (*iAnimation)->Expire(); + for (const auto& rxAnimation : aCopy) + rxAnimation->Expire(); maIdle.Stop(); if (mpDrawLock) @@ -171,10 +170,9 @@ bool Animator::ProcessAnimations (const double nTime) return bExpired; AnimationList aCopy (maAnimations); - AnimationList::const_iterator iAnimation; - for (iAnimation=aCopy.begin(); iAnimation!=aCopy.end(); ++iAnimation) + for (const auto& rxAnimation : aCopy) { - bExpired |= (*iAnimation)->Run(nTime); + bExpired |= rxAnimation->Run(nTime); } return bExpired; @@ -188,11 +186,10 @@ void Animator::CleanUpAnimationList() AnimationList aActiveAnimations; - AnimationList::const_iterator iAnimation; - for (iAnimation=maAnimations.begin(); iAnimation!=maAnimations.end(); ++iAnimation) + for (const auto& rxAnimation : maAnimations) { - if ( ! (*iAnimation)->IsExpired()) - aActiveAnimations.push_back(*iAnimation); + if ( ! rxAnimation->IsExpired()) + aActiveAnimations.push_back(rxAnimation); } maAnimations.swap(aActiveAnimations); diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx index 31f64af88d7f..ab02f7e4ae5d 100644 --- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx +++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx @@ -609,12 +609,9 @@ IMPL_LINK(Clipboard, ProcessDragFinished, void*, pUserData, void) // Remove the pages that have been moved to another place (possibly // in the same document.) rSelector.DeselectAllPages(); - PageList::iterator aDraggedPage; - for (aDraggedPage=maPagesToRemove.begin(); - aDraggedPage!=maPagesToRemove.end(); - ++aDraggedPage) + for (const auto& rpDraggedPage : maPagesToRemove) { - rSelector.SelectPage(*aDraggedPage); + rSelector.SelectPage(rpDraggedPage); } mrController.GetSelectionManager()->DeleteSelectedPages(); } diff --git a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx index c39a56908c1a..232457574de2 100644 --- a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx @@ -220,11 +220,9 @@ void FocusManager::NotifyFocusChangeListeners() const ::std::vector<Link<LinkParamNone*,void>> aListeners (maFocusChangeListeners); // Tell the selection change listeners that the selection has changed. - ::std::vector<Link<LinkParamNone*,void>>::iterator iListener (aListeners.begin()); - ::std::vector<Link<LinkParamNone*,void>>::iterator iEnd (aListeners.end()); - for (; iListener!=iEnd; ++iListener) + for (auto& rListener : aListeners) { - iListener->Call(nullptr); + rListener.Call(nullptr); } } diff --git a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx index 1115d05227a9..a7c935698bb7 100644 --- a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx +++ b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx @@ -278,9 +278,8 @@ void PageSelector::SetPageSelection ( const std::shared_ptr<PageSelection>& rpSelection, const bool bUpdateCurrentPage) { - PageSelection::const_iterator iPage; - for (iPage=rpSelection->begin(); iPage!=rpSelection->end(); ++iPage) - SelectPage(*iPage); + for (const auto& rpPage : *rpSelection) + SelectPage(rpPage); if (bUpdateCurrentPage) UpdateCurrentPage(); } diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx index ed2d3c500d5c..d6daf3dd0826 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionObserver.cxx @@ -119,13 +119,9 @@ void SelectionObserver::EndObservation() if ( ! maInsertedPages.empty()) { // Select the inserted pages. - for (::std::vector<const SdPage*>::const_iterator - iPage(maInsertedPages.begin()), - iEnd(maInsertedPages.end()); - iPage!=iEnd; - ++iPage) + for (const auto& rpPage : maInsertedPages) { - rSelector.SelectPage(*iPage); + rSelector.SelectPage(rpPage); } maInsertedPages.clear(); } diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 0a8f11f58271..5512970a9590 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -1098,15 +1098,12 @@ void SlotManager::DuplicateSelectedSlides (SfxRequest& rRequest) mrSlideSorter.GetView().BegUndo(SdResId(STR_INSERTPAGE)); ::std::vector<SdPage*> aPagesToSelect; - for(::std::vector<SdPage*>::const_iterator - iPage(aPagesToDuplicate.begin()), - iEnd(aPagesToDuplicate.end()); - iPage!=iEnd; - ++iPage, nInsertPosition+=2) + for(const auto& rpPage : aPagesToDuplicate) { aPagesToSelect.push_back( mrSlideSorter.GetViewShell()->CreateOrDuplicatePage( - rRequest, PageKind::Standard, *iPage, nInsertPosition)); + rRequest, PageKind::Standard, rpPage, nInsertPosition)); + nInsertPosition += 2; } aPagesToDuplicate.clear(); diff --git a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx index 49c8ea58953e..967606b4484f 100644 --- a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx @@ -143,21 +143,17 @@ void VisibleAreaManager::MakeVisible() const sal_Int32 nVisibleHeight (aVisibleArea.GetHeight()); // Find the longest run of boxes whose union fits into the visible area. - for (::std::vector<::tools::Rectangle>::const_iterator - iBox(maVisibleRequests.begin()), - iEnd(maVisibleRequests.end()); - iBox!=iEnd; - ++iBox) + for (const auto& rBox : maVisibleRequests) { - if (nVisibleTop+nVisibleHeight <= iBox->Bottom()) - nVisibleTop = iBox->Bottom()-nVisibleHeight; - if (nVisibleTop > iBox->Top()) - nVisibleTop = iBox->Top(); - - if (nVisibleLeft+nVisibleWidth <= iBox->Right()) - nVisibleLeft = iBox->Right()-nVisibleWidth; - if (nVisibleLeft > iBox->Left()) - nVisibleLeft = iBox->Left(); + if (nVisibleTop+nVisibleHeight <= rBox.Bottom()) + nVisibleTop = rBox.Bottom()-nVisibleHeight; + if (nVisibleTop > rBox.Top()) + nVisibleTop = rBox.Top(); + + if (nVisibleLeft+nVisibleWidth <= rBox.Right()) + nVisibleLeft = rBox.Right()-nVisibleWidth; + if (nVisibleLeft > rBox.Left()) + nVisibleLeft = rBox.Left(); // Make sure the visible area does not move outside the model area. if (nVisibleTop + nVisibleHeight > aModelArea.Bottom()) diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx index 2965b5808eb1..ee836281e3ba 100644 --- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx +++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx @@ -318,22 +318,20 @@ void SlideSorterModel::ClearDescriptorList() aDescriptors.swap(maPageDescriptors); } - for (::std::vector<SharedPageDescriptor>::iterator iDescriptor=aDescriptors.begin(), iEnd=aDescriptors.end(); - iDescriptor!=iEnd; - ++iDescriptor) + for (auto& rxDescriptor : aDescriptors) { - if (*iDescriptor != nullptr) + if (rxDescriptor != nullptr) { - if (iDescriptor->use_count() > 1) + if (rxDescriptor.use_count() > 1) { SAL_INFO( "sd.sls", "trying to delete page descriptor that is still used with" - " count " << iDescriptor->use_count()); + " count " << rxDescriptor.use_count()); // No assertion here because that can hang the office when // opening a dialog from here. } - iDescriptor->reset(); + rxDescriptor.reset(); } } } diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx index 4811c360b4b4..16ff14db9f2f 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx @@ -706,15 +706,15 @@ std::pair<sal_uInt16, sal_uInt16> SlideSorterViewShell::SyncPageSelectionToDocum sal_uInt16 lastSelectedPageNo = 0; GetDoc()->UnselectAllPages(); - for (auto it = rpSelection->begin(); it != rpSelection->end(); ++it) + for (auto& rpPage : *rpSelection) { // Check page number - sal_uInt16 pageNo = (*it)->GetPageNum(); + sal_uInt16 pageNo = rpPage->GetPageNum(); if (pageNo > lastSelectedPageNo) lastSelectedPageNo = pageNo; if (pageNo < firstSelectedPageNo) firstSelectedPageNo = pageNo; - GetDoc()->SetSelected(*it, true); + GetDoc()->SetSelected(rpPage, true); } return std::make_pair(firstSelectedPageNo, lastSelectedPageNo); @@ -879,12 +879,9 @@ void SlideSorterViewShell::PostMoveSlidesActions(const std::shared_ptr<SlideSort } mpSlideSorter->GetController().GetPageSelector().DeselectAllPages(); - ::std::vector<SdPage*>::iterator iPage; - for (iPage=rpSelection->begin(); - iPage!=rpSelection->end(); - ++iPage) + for (const auto& rpPage : *rpSelection) { - mpSlideSorter->GetController().GetPageSelector().SelectPage(*iPage); + mpSlideSorter->GetController().GetPageSelector().SelectPage(rpPage); } // Refresh toolbar icons diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx index 0e87021d7155..69997e1357dc 100644 --- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx +++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx @@ -475,13 +475,9 @@ void SlideSorterView::DeterminePageObjectVisibilities() // Tell the listeners that the visibility of some objects has // changed. ::std::vector<Link<LinkParamNone*,void>>& aChangeListeners (maVisibilityChangeListeners); - for (::std::vector<Link<LinkParamNone*,void>>::const_iterator - iLink(aChangeListeners.begin()), - iEnd(aChangeListeners.end()); - iLink!=iEnd; - ++iLink) + for (const auto& rLink : aChangeListeners) { - iLink->Call(nullptr); + rLink.Call(nullptr); } } diff --git a/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx b/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx index cd05e4c04401..38a0aa9fec59 100644 --- a/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx +++ b/sd/source/ui/slidesorter/view/SlsLayeredDevice.cxx @@ -85,9 +85,9 @@ void ForAllRectangles (const vcl::Region& rRegion, const std::function<void (con } else { - for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) + for(const auto& rRect : aRectangles) { - aFunction(*aRectIter); + aFunction(rRect); } //Region aMutableRegionCopy (rRegion); @@ -424,13 +424,9 @@ void Layer::ValidateRectangle (const ::tools::Rectangle& rBox) const vcl::Region aSavedClipRegion (mpLayerDevice->GetClipRegion()); mpLayerDevice->IntersectClipRegion(rBox); - for (::std::vector<SharedILayerPainter>::const_iterator - iPainter(maPainters.begin()), - iEnd(maPainters.end()); - iPainter!=iEnd; - ++iPainter) + for (const auto& rxPainter : maPainters) { - (*iPainter)->Paint(*mpLayerDevice, rBox); + rxPainter->Paint(*mpLayerDevice, rBox); } mpLayerDevice->SetClipRegion(aSavedClipRegion); diff --git a/sd/source/ui/tools/EventMultiplexer.cxx b/sd/source/ui/tools/EventMultiplexer.cxx index 61434853df2e..3b135db46ad7 100644 --- a/sd/source/ui/tools/EventMultiplexer.cxx +++ b/sd/source/ui/tools/EventMultiplexer.cxx @@ -303,14 +303,9 @@ void EventMultiplexer::Implementation::AddEventListener ( void EventMultiplexer::Implementation::RemoveEventListener ( const Link<EventMultiplexerEvent&,void>& rCallback) { - ListenerList::iterator iListener (maListeners.begin()); - ListenerList::const_iterator iEnd (maListeners.end()); - for (;iListener!=iEnd; ++iListener) - if (*iListener == rCallback) - { - maListeners.erase(iListener); - break; - } + auto iListener = std::find(maListeners.begin(), maListeners.end(), rCallback); + if (iListener != maListeners.end()) + maListeners.erase(iListener); } void EventMultiplexer::Implementation::ConnectToController() @@ -641,11 +636,9 @@ void EventMultiplexer::Implementation::CallListeners ( void EventMultiplexer::Implementation::CallListeners (EventMultiplexerEvent& rEvent) { ListenerList aCopyListeners( maListeners ); - ListenerList::iterator iListener (aCopyListeners.begin()); - ListenerList::const_iterator iListenerEnd (aCopyListeners.end()); - for (; iListener!=iListenerEnd; ++iListener) + for (auto& rListener : aCopyListeners) { - iListener->Call(rEvent); + rListener.Call(rEvent); } } diff --git a/sd/source/ui/tools/SlotStateListener.cxx b/sd/source/ui/tools/SlotStateListener.cxx index 1e41ea37ec1a..4598f4cbcdcb 100644 --- a/sd/source/ui/tools/SlotStateListener.cxx +++ b/sd/source/ui/tools/SlotStateListener.cxx @@ -125,17 +125,12 @@ void SlotStateListener::statusChanged ( void SlotStateListener::ReleaseListeners() { - if ( ! maRegisteredURLList.empty()) + for (const auto& rURL : maRegisteredURLList) { - RegisteredURLList::iterator iURL (maRegisteredURLList.begin()); - RegisteredURLList::iterator iEnd (maRegisteredURLList.end()); - for (; iURL!=iEnd; ++iURL) + uno::Reference<frame::XDispatch> xDispatch (GetDispatch(rURL)); + if (xDispatch.is()) { - uno::Reference<frame::XDispatch> xDispatch (GetDispatch(*iURL)); - if (xDispatch.is()) - { - xDispatch->removeStatusListener(this,*iURL); - } + xDispatch->removeStatusListener(this,rURL); } } } diff --git a/sd/source/ui/unoidl/SdUnoDrawView.cxx b/sd/source/ui/unoidl/SdUnoDrawView.cxx index 27ae9bb8afbf..e865853c8c1b 100644 --- a/sd/source/ui/unoidl/SdUnoDrawView.cxx +++ b/sd/source/ui/unoidl/SdUnoDrawView.cxx @@ -224,11 +224,8 @@ sal_Bool SAL_CALL SdUnoDrawView::select( const Any& aSelection ) // first deselect all mrView.UnmarkAllObj( pPV ); - ::std::vector<SdrObject*>::iterator aIter( aObjects.begin() ); - const ::std::vector<SdrObject*>::iterator aEnd( aObjects.end() ); - while( aIter != aEnd ) + for( SdrObject* pObj : aObjects ) { - SdrObject* pObj = *aIter++; mrView.MarkObj( pObj, pPV ); } } diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index c7b8b6b4950a..23319a1734c2 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2127,21 +2127,18 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r // resolving links found in this page by the method ImpEditEngine::Paint std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks(); - std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIBeg = rBookmarks.begin(); - std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end(); - while ( aIBeg != aIEnd ) + for ( const auto& rBookmark : rBookmarks ) { - sal_Int32 nPage = ImplPDFGetBookmarkPage( aIBeg->aBookmark, *mpDoc ); + sal_Int32 nPage = ImplPDFGetBookmarkPage( rBookmark.aBookmark, *mpDoc ); if ( nPage != -1 ) { - if ( aIBeg->nLinkId != -1 ) - pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ) ); + if ( rBookmark.nLinkId != -1 ) + pPDFExtOutDevData->SetLinkDest( rBookmark.nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ) ); else - pPDFExtOutDevData->DescribeRegisteredDest( aIBeg->nDestId, aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ); + pPDFExtOutDevData->DescribeRegisteredDest( rBookmark.nDestId, aPageRect, nPage, vcl::PDFWriter::DestAreaType::FitRectangle ); } else - pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aIBeg->aBookmark ); - ++aIBeg; + pPDFExtOutDevData->SetLinkURL( rBookmark.nLinkId, rBookmark.aBookmark ); } rBookmarks.clear(); //---> #i56629, #i40318 diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 6ffa9cd930f8..d4423676e52e 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2088,9 +2088,8 @@ Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() // Join those types in a sequence. maTypeSequence.realloc(aTypes.size() + nBaseTypes); uno::Type* pTypes = maTypeSequence.getArray(); - ::std::vector<uno::Type>::const_iterator iType; - for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType) - *pTypes++ = *iType; + for (const auto& rType : aTypes) + *pTypes++ = rType; for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) *pTypes++ = *pBaseTypes++; } @@ -2714,9 +2713,8 @@ Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() // Join those types in a sequence. maTypeSequence.realloc(aTypes.size() + nBaseTypes); uno::Type* pTypes = maTypeSequence.getArray(); - ::std::vector<uno::Type>::const_iterator iType; - for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType) - *pTypes++ = *iType; + for (const auto& rType : aTypes) + *pTypes++ = rType; for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) *pTypes++ = *pBaseTypes++; } @@ -2814,18 +2812,15 @@ void SdMasterPage::setBackground( const Any& rValue ) Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY ); PropertyEntryVector_t aBackgroundProperties = ImplGetPageBackgroundPropertySet()->getPropertyMap().getPropertyEntries(); - PropertyEntryVector_t::const_iterator aIt = aBackgroundProperties.begin(); - while( aIt != aBackgroundProperties.end() ) + for( const auto& rProp : aBackgroundProperties ) { - if( xSetInfo->hasPropertyByName( aIt->sName ) ) + if( xSetInfo->hasPropertyByName( rProp.sName ) ) { - if( !xSetStates.is() || xSetStates->getPropertyState( aIt->sName ) == beans::PropertyState_DIRECT_VALUE ) - xStyleSet->setPropertyValue( aIt->sName, xInputSet->getPropertyValue( aIt->sName ) ); + if( !xSetStates.is() || xSetStates->getPropertyState( rProp.sName ) == beans::PropertyState_DIRECT_VALUE ) + xStyleSet->setPropertyValue( rProp.sName, xInputSet->getPropertyValue( rProp.sName ) ); else - xSetStates->setPropertyToDefault( aIt->sName ); + xSetStates->setPropertyToDefault( rProp.sName ); } - - ++aIt; } } else diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index aed0fb2eec6b..3770f6c6e87e 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -104,26 +104,25 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) if( mpPropSet->AreThereOwnUsrAnys() ) { PropertyEntryVector_t aProperties = mpPropSet->getPropertyMap().getPropertyEntries(); - PropertyEntryVector_t::const_iterator aIt = aProperties.begin(); - while( aIt != aProperties.end() ) + for( const auto& rProp : aProperties ) { - uno::Any* pAny = mpPropSet->GetUsrAnyForID( aIt->nWID ); + uno::Any* pAny = mpPropSet->GetUsrAnyForID( rProp.nWID ); if( pAny ) { - OUString aPropertyName( aIt->sName ); - switch( aIt->nWID ) + OUString aPropertyName( rProp.sName ); + switch( rProp.nWID ) { case XATTR_FILLFLOATTRANSPARENCE : case XATTR_FILLGRADIENT : { if ( ( pAny->getValueType() == ::cppu::UnoType< css::awt::Gradient>::get() ) - && ( aIt->nMemberId == MID_FILLGRADIENT ) ) + && ( rProp.nMemberId == MID_FILLGRADIENT ) ) { setPropertyValue( aPropertyName, *pAny ); } else if ( ( pAny->getValueType() == ::cppu::UnoType<OUString>::get() ) && - ( aIt->nMemberId == MID_NAME ) ) + ( rProp.nMemberId == MID_NAME ) ) { setPropertyValue( aPropertyName, *pAny ); } @@ -132,12 +131,12 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) case XATTR_FILLHATCH : { if ( ( pAny->getValueType() == ::cppu::UnoType< css::drawing::Hatch>::get() ) - && ( aIt->nMemberId == MID_FILLHATCH ) ) + && ( rProp.nMemberId == MID_FILLHATCH ) ) { setPropertyValue( aPropertyName, *pAny ); } else if ( ( pAny->getValueType() == ::cppu::UnoType<OUString>::get() ) && - ( aIt->nMemberId == MID_NAME ) ) + ( rProp.nMemberId == MID_NAME ) ) { setPropertyValue( aPropertyName, *pAny ); } @@ -145,13 +144,13 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) break; case XATTR_FILLBITMAP : { - if (aIt->nMemberId == MID_BITMAP && + if (rProp.nMemberId == MID_BITMAP && (pAny->getValueType() == cppu::UnoType<css::awt::XBitmap>::get() || pAny->getValueType() == cppu::UnoType<css::graphic::XGraphic>::get())) { setPropertyValue( aPropertyName, *pAny ); } - else if (pAny->getValueType() == ::cppu::UnoType<OUString>::get() && aIt->nMemberId == MID_NAME) + else if (pAny->getValueType() == ::cppu::UnoType<OUString>::get() && rProp.nMemberId == MID_NAME) { setPropertyValue( aPropertyName, *pAny ); } @@ -162,7 +161,6 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) setPropertyValue( aPropertyName, *pAny ); } } - ++aIt; } } } diff --git a/sd/source/ui/view/ToolBarManager.cxx b/sd/source/ui/view/ToolBarManager.cxx index 20f8a7979534..1f0cbdac0f95 100644 --- a/sd/source/ui/view/ToolBarManager.cxx +++ b/sd/source/ui/view/ToolBarManager.cxx @@ -1326,28 +1326,11 @@ ToolBarShellList::ToolBarShellList() void ToolBarShellList::ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup) { - // In every loop we erase the first member of the specified group. - // Because that invalidates the iterator another loop is started after - // that. The loop is left only when no member of the group is found and - // no element is erased - bool bLoop; - do - { - bLoop = false; - - GroupedShellList::iterator iDescriptor; - for (iDescriptor=maNewList.begin(); iDescriptor!=maNewList.end(); ++iDescriptor) - if (iDescriptor->meGroup == eGroup) - { - maNewList.erase(iDescriptor); - // Erasing the descriptor invalidated the iterator so we - // have to exit the for loop and start anew to search for - // further elements of the group. - bLoop = true; - break; - } - } - while (bLoop); + for (GroupedShellList::iterator iDescriptor = maNewList.begin(); iDescriptor != maNewList.end(); ) + if (iDescriptor->meGroup == eGroup) + iDescriptor = maNewList.erase(iDescriptor); + else + ++iDescriptor; } void ToolBarShellList::AddShellId (sd::ToolBarManager::ToolBarGroup eGroup, sd::ShellId nId) @@ -1377,10 +1360,9 @@ void ToolBarShellList::ReleaseAllShells (ToolBarRules& rRules) { // Release the currently active tool bars. GroupedShellList aList (maCurrentList); - GroupedShellList::iterator iDescriptor; - for (iDescriptor=aList.begin(); iDescriptor!=aList.end(); ++iDescriptor) + for (const auto& rDescriptor : aList) { - rRules.SubShellRemoved(iDescriptor->meGroup, iDescriptor->mnId); + rRules.SubShellRemoved(rDescriptor.meGroup, rDescriptor.mnId); } // Clear the list of requested tool bars. @@ -1400,10 +1382,10 @@ void ToolBarShellList::UpdateShells ( ::std::set_difference(maCurrentList.begin(), maCurrentList.end(), maNewList.begin(), maNewList.end(), std::insert_iterator<GroupedShellList>(aList,aList.begin())); - for (GroupedShellList::iterator iShell=aList.begin(); iShell!=aList.end(); ++iShell) + for (const auto& rShell : aList) { - SAL_INFO("sd.view", OSL_THIS_FUNC << ": deactivating tool bar shell " << static_cast<sal_uInt32>(iShell->mnId)); - rpManager->DeactivateSubShell(*rpMainViewShell, iShell->mnId); + SAL_INFO("sd.view", OSL_THIS_FUNC << ": deactivating tool bar shell " << static_cast<sal_uInt32>(rShell.mnId)); + rpManager->DeactivateSubShell(*rpMainViewShell, rShell.mnId); } // Activate shells that are in maNewList, but not in @@ -1412,10 +1394,10 @@ void ToolBarShellList::UpdateShells ( ::std::set_difference(maNewList.begin(), maNewList.end(), maCurrentList.begin(), maCurrentList.end(), std::insert_iterator<GroupedShellList>(aList,aList.begin())); - for (GroupedShellList::iterator iShell=aList.begin(); iShell!=aList.end(); ++iShell) + for (const auto& rShell : aList) { - SAL_INFO("sd.view", OSL_THIS_FUNC << ": activating tool bar shell " << static_cast<sal_uInt32>(iShell->mnId)); - rpManager->ActivateSubShell(*rpMainViewShell, iShell->mnId); + SAL_INFO("sd.view", OSL_THIS_FUNC << ": activating tool bar shell " << static_cast<sal_uInt32>(rShell.mnId)); + rpManager->ActivateSubShell(*rpMainViewShell, rShell.mnId); } // The maNewList now reflects the current state and thus is made diff --git a/sd/source/ui/view/ViewClipboard.cxx b/sd/source/ui/view/ViewClipboard.cxx index f70147316439..1256a4b677ff 100644 --- a/sd/source/ui/view/ViewClipboard.cxx +++ b/sd/source/ui/view/ViewClipboard.cxx @@ -80,10 +80,8 @@ SdPage* ViewClipboard::GetFirstMasterPage (const SdTransferable& rTransferable) if (pDocument == nullptr) break; - std::vector<OUString>::const_iterator pIter; - for ( pIter = rBookmarks.begin(); pIter != rBookmarks.end(); ++pIter ) + for (const OUString& sName : rBookmarks) { - OUString sName (*pIter); bool bIsMasterPage; // SdPage* GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind); diff --git a/sd/source/ui/view/ViewShellManager.cxx b/sd/source/ui/view/ViewShellManager.cxx index 7a1e70cc58a3..d2c2975499c4 100644 --- a/sd/source/ui/view/ViewShellManager.cxx +++ b/sd/source/ui/view/ViewShellManager.cxx @@ -737,15 +737,10 @@ void ViewShellManager::Implementation::UpdateShellStack() #endif // 4. Find the lowest shell in which the two stacks differ. - ShellStack::iterator iSfxShell (aSfxShellStack.begin()); - ShellStack::iterator iTargetShell (aTargetStack.begin()); - while (iSfxShell != aSfxShellStack.end() - && iTargetShell!=aTargetStack.end() - && (*iSfxShell)==(*iTargetShell)) - { - ++iSfxShell; - ++iTargetShell; - } + auto mismatchIters = std::mismatch(aSfxShellStack.begin(), aSfxShellStack.end(), + aTargetStack.begin(), aTargetStack.end()); + ShellStack::iterator iSfxShell (mismatchIters.first); + ShellStack::iterator iTargetShell (mismatchIters.second); // 5. Remove all shells above and including the differing shell from the // SFX stack starting with the shell on top of the stack. diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx index c2ebaa71e3a1..2efe1d1bb5bb 100644 --- a/sd/source/ui/view/ViewTabBar.cxx +++ b/sd/source/ui/view/ViewTabBar.cxx @@ -514,19 +514,20 @@ void ViewTabBar::UpdateActiveButton() void ViewTabBar::UpdateTabBarButtons() { - TabBarButtonList::const_iterator iTab; sal_uInt16 nPageCount (mpTabControl->GetPageCount()); - sal_uInt16 nIndex; - for (iTab=maTabBarButtons.begin(),nIndex=1; iTab!=maTabBarButtons.end(); ++iTab,++nIndex) + sal_uInt16 nIndex = 1; + for (const auto& rTab : maTabBarButtons) { // Create a new tab when there are not enough. if (nPageCount < nIndex) - mpTabControl->InsertPage(nIndex, iTab->ButtonLabel); + mpTabControl->InsertPage(nIndex, rTab.ButtonLabel); // Update the tab. - mpTabControl->SetPageText(nIndex, iTab->ButtonLabel); - mpTabControl->SetHelpText(nIndex, iTab->HelpText); + mpTabControl->SetPageText(nIndex, rTab.ButtonLabel); + mpTabControl->SetHelpText(nIndex, rTab.HelpText); mpTabControl->SetTabPage(nIndex, mpTabPage.get()); + + ++nIndex; } // Delete tabs that are no longer used. diff --git a/sd/source/ui/view/WindowUpdater.cxx b/sd/source/ui/view/WindowUpdater.cxx index e93228d4134e..a49928184dd8 100644 --- a/sd/source/ui/view/WindowUpdater.cxx +++ b/sd/source/ui/view/WindowUpdater.cxx @@ -117,18 +117,16 @@ void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) { // Set the current state at all registered output devices. - tWindowList::iterator aWindowIterator (maWindowList.begin()); - while (aWindowIterator != maWindowList.end()) - Update (*aWindowIterator++); + for (auto& rxWindow : maWindowList) + Update (rxWindow); // Reformat the document for the modified state to take effect. if (mpDocument != nullptr) mpDocument->ReformatAllTextObjects(); // Invalidate the windows to make the modified state visible. - aWindowIterator = maWindowList.begin(); - while (aWindowIterator != maWindowList.end()) - (*aWindowIterator++)->Invalidate(); + for (auto& rxWindow : maWindowList) + rxWindow->Invalidate(); } } // end of namespace sd diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index 28903c556424..fc55682275e9 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -302,9 +302,9 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) } } - for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter) + for (const auto& rpItem : aSelList) { - pPara = *iter; + pPara = rpItem; sal_Int16 nDepth = pOutl->GetDepth( pOutl->GetAbsPos( pPara ) ); diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx index aadd9820f7ec..e6f2e0edaf86 100644 --- a/sd/source/ui/view/frmview.cxx +++ b/sd/source/ui/view/frmview.cxx @@ -457,11 +457,11 @@ void FrameView::WriteUserDataSequence ( css::uno::Sequence < css::beans::Propert PropertyValue* pValue = &(rValues.getArray()[nOldLength]); - std::vector< std::pair< OUString, Any > >::iterator aIter( aUserData.begin() ); - for( ; aIter != aUserData.end(); ++aIter, ++pValue ) + for( const auto& rItem : aUserData ) { - pValue->Name = (*aIter).first; - pValue->Value = (*aIter).second; + pValue->Name = rItem.first; + pValue->Value = rItem.second; + ++pValue; } } #undef addValue diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 97e34e69ccc7..1c72f1ff5009 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -798,18 +798,12 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet ) if (!aSelList.empty()) { - std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); - Paragraph* pPara = *iter; + sal_Int16 nTmpDepth = rOutl.GetDepth( rOutl.GetAbsPos( aSelList.front() ) ); + bool bPage = ::Outliner::HasParaFlag( aSelList.front(), ParaFlag::ISPAGE ); - sal_Int16 nDepth; - sal_Int16 nTmpDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) ); - bool bPage = ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ); - - while (iter != aSelList.begin()) + for (const Paragraph* pPara : aSelList) { - pPara = *iter; - - nDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) ); + sal_Int16 nDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) ); if( nDepth != nTmpDepth || bPage != ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE )) bUnique = false; @@ -821,8 +815,6 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet ) else bDisableCollapse = false; } - - ++iter; } } diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index c2b3576dbfce..32ead7b49988 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -544,15 +544,11 @@ IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner::DepthChangeHdlParam, aParam std::vector<Paragraph*> aSelList; pOlView->CreateSelectionList(aSelList); - Paragraph *pParagraph = nullptr; - for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter) - { - pParagraph = *iter; - - if( !::Outliner::HasParaFlag( pParagraph, ParaFlag::ISPAGE ) && - (pOutliner->GetDepth( pOutliner->GetAbsPos( pParagraph ) ) <= 0) ) - mnPagesToProcess++; - } + mnPagesToProcess = std::count_if(aSelList.begin(), aSelList.end(), + [&pOutliner](const Paragraph *pParagraph) { + return !Outliner::HasParaFlag(pParagraph, ParaFlag::ISPAGE) && + (pOutliner->GetDepth(pOutliner->GetAbsPos(pParagraph)) <= 0); + }); mnPagesToProcess++; // the paragraph being in level 0 already // should be included @@ -773,13 +769,9 @@ IMPL_LINK( OutlineView, BeginMovingHdl, ::Outliner *, pOutliner, void ) // list of selected title paragraphs mpOutlinerViews[0]->CreateSelectionList(maSelectedParas); - for (std::vector<Paragraph*>::iterator it = maSelectedParas.begin(); it != maSelectedParas.end();) - { - if (!::Outliner::HasParaFlag(*it, ParaFlag::ISPAGE)) - it = maSelectedParas.erase(it); - else - ++it; - } + maSelectedParas.erase(std::remove_if(maSelectedParas.begin(), maSelectedParas.end(), + [](const Paragraph* pPara) { return !Outliner::HasParaFlag(pPara, ParaFlag::ISPAGE); }), + maSelectedParas.end()); // select the pages belonging to the paragraphs on level 0 to select sal_uInt16 nPos = 0; @@ -1250,13 +1242,9 @@ void OutlineView::SetSelectedPages() std::vector<Paragraph*> aSelParas; mpOutlinerViews[0]->CreateSelectionList(aSelParas); - for (std::vector<Paragraph*>::iterator it = aSelParas.begin(); it != aSelParas.end();) - { - if (!::Outliner::HasParaFlag(*it, ParaFlag::ISPAGE)) - it = aSelParas.erase(it); - else - ++it; - } + aSelParas.erase(std::remove_if(aSelParas.begin(), aSelParas.end(), + [](const Paragraph* pPara) { return !Outliner::HasParaFlag(pPara, ParaFlag::ISPAGE); }), + aSelParas.end()); // select the pages belonging to the paragraphs on level 0 to select sal_uInt16 nPos = 0; diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx index cf5fc2cc27a4..e9fd56d3d8d0 100644 --- a/sd/source/ui/view/sdview2.cxx +++ b/sd/source/ui/view/sdview2.cxx @@ -859,10 +859,9 @@ bool View::GetExchangeList (std::vector<OUString> &rExchangeList, bool bListIdentical = true; ///< Bookmark list and exchange list are identical bool bNameOK = true; ///< name is unique - std::vector<OUString>::const_iterator pIter; - for ( pIter = rBookmarkList.begin(); bNameOK && pIter != rBookmarkList.end(); ++pIter ) + for ( const auto& rBookmark : rBookmarkList ) { - OUString aNewName = *pIter; + OUString aNewName = rBookmark; if( nType == 0 || nType == 2 ) bNameOK = mpDocSh->CheckPageName(mpViewSh->GetFrameWeld(), aNewName); @@ -892,9 +891,12 @@ bool View::GetExchangeList (std::vector<OUString> &rExchangeList, } } - bListIdentical = *pIter == aNewName; + bListIdentical = rBookmark == aNewName; rExchangeList.push_back(aNewName); + + if (!bNameOK) + break; } // Exchange list is identical to bookmark list diff --git a/sd/source/ui/view/sdview5.cxx b/sd/source/ui/view/sdview5.cxx index 2d434b17e788..da608462db7e 100644 --- a/sd/source/ui/view/sdview5.cxx +++ b/sd/source/ui/view/sdview5.cxx @@ -101,14 +101,10 @@ SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind ) { const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList(); - for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter ) - { - if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) ) - { - pEmptyObj = (*iter); - break; - } - } + auto iter = std::find_if(rShapes.begin(), rShapes.end(), + [&pPage](SdrObject* pShape) { return pShape->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(pShape)); }); + if (iter != rShapes.end()) + pEmptyObj = (*iter); } } diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx index 2f1c148c5c37..fac12ad627b2 100644 --- a/sd/source/ui/view/viewoverlaymanager.cxx +++ b/sd/source/ui/view/viewoverlaymanager.cxx @@ -471,11 +471,11 @@ bool ViewOverlayManager::CreateTags() { const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList(); - for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter ) + for( SdrObject* pShape : rShapes ) { - if( (*iter)->IsEmptyPresObj() && ((*iter)->GetObjIdentifier() == OBJ_OUTLINETEXT) && (mrBase.GetDrawView()->GetTextEditObject() != (*iter)) ) + if( pShape->IsEmptyPresObj() && (pShape->GetObjIdentifier() == OBJ_OUTLINETEXT) && (mrBase.GetDrawView()->GetTextEditObject() != pShape) ) { - rtl::Reference< SmartTag > xTag( new ChangePlaceholderTag( *mrBase.GetMainViewShell()->GetView(), *(*iter) ) ); + rtl::Reference< SmartTag > xTag( new ChangePlaceholderTag( *mrBase.GetMainViewShell()->GetView(), *pShape ) ); maTagVector.push_back(xTag); bChanges = true; } @@ -492,12 +492,8 @@ bool ViewOverlayManager::DisposeTags() ViewTagVector vec; vec.swap( maTagVector ); - ViewTagVector::iterator iter = vec.begin(); - do - { - (*iter++)->Dispose(); - } - while( iter != vec.end() ); + for (auto& rxViewTag : vec) + rxViewTag->Dispose(); return true; } |