diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-12-13 00:42:49 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-13 18:07:25 +0100 |
commit | 0f0f8bdc3e5c1534d608f8475d9d3e3df4faddaa (patch) | |
tree | ddeb138aafb32e64b7e065406359a79c2d12c4ff /sd | |
parent | 3e06873d124c9f8f4cd2e5f5d619de3c99ca09bf (diff) |
Simplify containers iterations in sd/source/ui/[a-r]*
Use range-based loop or replace with STL functions
Change-Id: I063dc78205a4cd982c252a9b62c456e9660b8790
Reviewed-on: https://gerrit.libreoffice.org/65063
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
29 files changed, 220 insertions, 429 deletions
diff --git a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx index 8e0124f53641..bb55af18a6f3 100644 --- a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx +++ b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx @@ -478,19 +478,14 @@ uno::Sequence< sal_Int32 > SAL_CALL } std::sort( vXShapes.begin(), vXShapes.end(), XShapePosCompareHelper() ); //get the index of the selected object in the group - std::vector< uno::Reference<drawing::XShape> >::iterator aIter; - //we start counting position from 1 - sal_Int32 nPos = 1; - for ( aIter = vXShapes.begin(); aIter != vXShapes.end(); ++aIter, nPos++ ) - { - if ( (*aIter).get() == xCurShape.get() ) - { - sal_Int32* pArray = aRet.getArray(); - pArray[0] = 1; //it should be 1 based, not 0 based. - pArray[1] = vXShapes.size(); - pArray[2] = nPos; - break; - } + auto aIter = std::find_if(vXShapes.begin(), vXShapes.end(), + [&xCurShape](const uno::Reference<drawing::XShape>& rxShape) { return rxShape.get() == xCurShape.get(); }); + if (aIter != vXShapes.end()) + { + sal_Int32* pArray = aRet.getArray(); + pArray[0] = 1; //it should be 1 based, not 0 based. + pArray[1] = vXShapes.size(); + pArray[2] = static_cast<sal_Int32>(std::distance(vXShapes.begin(), aIter)) + 1; //we start counting position from 1 } return aRet; } diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx index 4d363de2eca7..3c0193e5c552 100644 --- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx +++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx @@ -692,20 +692,18 @@ void AccessibleSlideSorterView::Implementation::UpdateChildren() void AccessibleSlideSorterView::Implementation::Clear() { - PageObjectList::iterator iPageObject; - PageObjectList::iterator iEnd = maPageObjects.end(); - for (iPageObject=maPageObjects.begin(); iPageObject!=iEnd; ++iPageObject) - if (*iPageObject != nullptr) + for (auto& rxPageObject : maPageObjects) + if (rxPageObject != nullptr) { mrAccessibleSlideSorter.FireAccessibleEvent( AccessibleEventId::CHILD, - Any(Reference<XAccessible>(iPageObject->get())), + Any(Reference<XAccessible>(rxPageObject.get())), Any()); - Reference<XComponent> xComponent (Reference<XWeak>(iPageObject->get()), UNO_QUERY); + Reference<XComponent> xComponent (Reference<XWeak>(rxPageObject.get()), UNO_QUERY); if (xComponent.is()) xComponent->dispose(); - *iPageObject = nullptr; + rxPageObject = nullptr; } maPageObjects.clear(); } diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index fedff46553e8..d8306a805def 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -730,12 +730,8 @@ void CustomAnimationPane::updateControls() MainSequenceRebuildGuard aGuard( mpMainSequence ); EffectSequenceHelper* pSequence = nullptr; - EffectSequence::iterator aRebuildIter( maListSelection.begin() ); - const EffectSequence::iterator aRebuildEnd( maListSelection.end() ); - while( aRebuildIter != aRebuildEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aRebuildIter++; - if( pEffect.get() ) { if( pSequence == nullptr ) @@ -775,18 +771,15 @@ static bool updateMotionPathImpl( CustomAnimationPane& rPane, ::sd::View& rView, { rtl::Reference< MotionPathTag > xMotionPathTag; // first try to find if there is already a tag for this - MotionPathTagVector::iterator aMIter( rOldTags.begin() ); - for( ; aMIter != rOldTags.end(); ++aMIter ) + auto aMIter = std::find_if(rOldTags.begin(), rOldTags.end(), + [&pEffect](const rtl::Reference<MotionPathTag>& xTag) { return xTag->getEffect() == pEffect; }); + if (aMIter != rOldTags.end()) { rtl::Reference< MotionPathTag > xTag( *aMIter ); - if( xTag->getEffect() == pEffect ) + if( !xTag->isDisposed() ) { - if( !xTag->isDisposed() ) - { - xMotionPathTag = xTag; - rOldTags.erase( aMIter ); - } - break; + xMotionPathTag = xTag; + rOldTags.erase( aMIter ); } } @@ -835,10 +828,8 @@ void CustomAnimationPane::updateMotionPathTags() if( !aTags.empty() ) { bChanges = true; - MotionPathTagVector::iterator aIter( aTags.begin() ); - while( aIter != aTags.end() ) + for( rtl::Reference< MotionPathTag >& xTag : aTags ) { - rtl::Reference< MotionPathTag > xTag( *aIter++ ); xTag->Dispose(); } } @@ -1127,13 +1118,9 @@ std::unique_ptr<STLPropertySet> CustomAnimationPane::createSelectionSet() sal_Int32 nMaxParaDepth = 0; // get options from selected effects - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); const CustomAnimationPresets& rPresets (getPresets()); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; - EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence(); if( !pEffectSequence ) pEffectSequence = mpMainSequence.get(); @@ -1245,12 +1232,8 @@ void CustomAnimationPane::changeSelection( STLPropertySet const * pResultSet, ST MainSequenceRebuildGuard aGuard( mpMainSequence ); - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; - DBG_ASSERT( pEffect->getEffectSequence(), "sd::CustomAnimationPane::changeSelection(), dead effect in selection!" ); if( !pEffect->getEffectSequence() ) continue; @@ -1516,12 +1499,8 @@ void CustomAnimationPane::changeSelection( STLPropertySet const * pResultSet, ST pOldSet->getPropertyValue(nHandleTextReverse) >>= bTextReverse; EffectSequence const aSelectedEffects( maListSelection ); - EffectSequence::const_iterator iter( aSelectedEffects.begin() ); - const EffectSequence::const_iterator iEnd( aSelectedEffects.end() ); - while( iter != iEnd ) + for( CustomAnimationEffectPtr const& pEffect : aSelectedEffects ) { - CustomAnimationEffectPtr const& pEffect = *iter++; - EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence(); if( !pEffectSequence ) pEffectSequence = mpMainSequence.get(); @@ -1808,10 +1787,9 @@ void CustomAnimationPane::onAdd() ParagraphTarget aParaTarget; aParaTarget.Shape = xShape; - std::vector< sal_Int16 >::iterator aIter( aParaList.begin() ); - for( ; aIter != aParaList.end(); ++aIter ) + for( const auto& rPara : aParaList ) { - aParaTarget.Paragraph = (*aIter); + aParaTarget.Paragraph = rPara; aTargets.push_back( makeAny( aParaTarget ) ); } } @@ -1849,17 +1827,15 @@ void CustomAnimationPane::onAdd() mpCustomAnimationList->SelectAll( false ); // gather shapes from the selection - std::vector< Any >::iterator aIter( aTargets.begin() ); - const std::vector< Any >::iterator aEnd( aTargets.end() ); bool bFirst = true; - for( ; aIter != aEnd; ++aIter ) + for( const auto& rTarget : aTargets ) { - CustomAnimationEffectPtr pCreated = mpMainSequence->append( pDescriptor, (*aIter), fDuration ); + CustomAnimationEffectPtr pCreated = mpMainSequence->append( pDescriptor, rTarget, fDuration ); // if only one shape with text and no fill or outline is selected, animate only by first level paragraphs if( bHasText && (aTargets.size() == 1) ) { - Reference< XShape > xShape( (*aIter), UNO_QUERY ); + Reference< XShape > xShape( rTarget, UNO_QUERY ); if( xShape.is() && !hasVisibleShape( xShape ) ) { mpMainSequence->createTextGroup( pCreated, 1, -1.0, false, false ); @@ -1893,11 +1869,8 @@ void CustomAnimationPane::onRemove() EffectSequence aList( maListSelection ); - EffectSequence::iterator aIter( aList.begin() ); - const EffectSequence::iterator aEnd( aList.end() ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : aList ) { - CustomAnimationEffectPtr pEffect = *aIter++; if( pEffect->getEffectSequence() ) pEffect->getEffectSequence()->remove( pEffect ); } @@ -1943,11 +1916,8 @@ void CustomAnimationPane::onChangeStart( sal_Int16 nNodeType ) bool bNeedRebuild = false; - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; if( pEffect->getNodeType() != nNodeType ) { pEffect->setNodeType( nNodeType ); @@ -1976,11 +1946,8 @@ void CustomAnimationPane::onChangeSpeed() MainSequenceRebuildGuard aGuard( mpMainSequence ); // change selected effect - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; pEffect->setDuration( fDuration ); } @@ -2073,12 +2040,8 @@ IMPL_LINK_NOARG(CustomAnimationPane, implPropertyHdl, LinkParamNone*, void) bool bNeedUpdate = false; // change selected effect - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; - if( setProperty1Value( mnPropertyType, pEffect, aValue ) ) bNeedUpdate = true; } @@ -2107,11 +2070,8 @@ IMPL_LINK_NOARG(CustomAnimationPane, DelayLoseFocusHdl, Control&, void) MainSequenceRebuildGuard aGuard( mpMainSequence ); // change selected effect - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; pEffect->setBegin( fBegin/10.0 ); } @@ -2134,18 +2094,14 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void) VclPtr<vcl::Window> xSaveFocusId = Window::SaveFocus(); - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - if ( ePathKind != PathKind::NONE ) { std::vector< Any > aTargets; MainSequenceRebuildGuard aGuard( mpMainSequence ); - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - aTargets.push_back( (*aIter)->getTarget() ); - CustomAnimationEffectPtr pEffect = *aIter++; + aTargets.push_back( pEffect->getTarget() ); EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence(); if( !pEffectSequence ) @@ -2167,10 +2123,8 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void) MainSequenceRebuildGuard aGuard( mpMainSequence ); // get selected effect - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; - // Dispose the deprecated motion path tag. It will be rebuilt later. if (pEffect->getPresetClass() == css::presentation::EffectPresetClass::MOTIONPATH) { @@ -2229,8 +2183,6 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) sal_uInt32 nFirstEffect = LISTBOX_ENTRY_NOTFOUND; - PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() ); - const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() ); mpLBAnimation->Clear(); if(nPosition == gnMotionPathPos) @@ -2242,9 +2194,8 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) mnFreeformPathPos = mpLBAnimation->InsertEntry( SvxResId(STR_ObjNameSingulFREELINE) ); } - while(aCategoryIter != aCategoryEnd) + for (PresetCategoryPtr& pCategory : rCategoryList) { - PresetCategoryPtr pCategory( *aCategoryIter++ ); if( pCategory.get() ) { mpLBAnimation->InsertCategory( pCategory->maLabel ); @@ -2252,11 +2203,8 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) std::vector< CustomAnimationPresetPtr > aSortedVector(pCategory->maEffects.size()); std::copy( pCategory->maEffects.begin(), pCategory->maEffects.end(), aSortedVector.begin() ); - std::vector< CustomAnimationPresetPtr >::const_iterator aIter( aSortedVector.begin() ); - const std::vector< CustomAnimationPresetPtr >::const_iterator aEnd( aSortedVector.end() ); - while( aIter != aEnd ) + for( CustomAnimationPresetPtr& pDescriptor : aSortedVector ) { - CustomAnimationPresetPtr pDescriptor = *aIter++; // ( !isTextOnly || ( isTextOnly && bHasText ) ) <=> !isTextOnly || bHasText if( pDescriptor.get() && ( !pDescriptor->isTextOnly() || bHasText ) ) { @@ -2334,13 +2282,8 @@ void CustomAnimationPane::moveSelection( bool bUp ) if( bUp ) { - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; - EffectSequence::iterator aUpEffectPos( pSequence->find( pEffect ) ); // coverity[copy_paste_error : FALSE] - this is correct, checking if it exists if( aUpEffectPos != rEffectSequence.end() ) @@ -2416,15 +2359,10 @@ void CustomAnimationPane::onPreview( bool bForcePreview ) if( maListSelection.empty() ) { rtl::Reference< MotionPathTag > xMotionPathTag; - MotionPathTagVector::iterator aIter; - for( aIter = maMotionPathTags.begin(); aIter != maMotionPathTags.end(); ++aIter ) - { - if( (*aIter)->isSelected() ) - { - xMotionPathTag = *aIter; - break; - } - } + auto aIter = std::find_if(maMotionPathTags.begin(), maMotionPathTags.end(), + [](const MotionPathTagVector::value_type& rxMotionPathTag) { return rxMotionPathTag->isSelected(); }); + if (aIter != maMotionPathTags.end()) + xMotionPathTag = *aIter; if( xMotionPathTag.is() ) { @@ -2445,12 +2383,8 @@ void CustomAnimationPane::onPreview( bool bForcePreview ) { MainSequencePtr pSequence( new MainSequence() ); - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - - while( aIter != aEnd ) + for( CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; pSequence->append( pEffect->clone() ); } @@ -2493,12 +2427,8 @@ void CustomAnimationPane::onSelect() if( pView ) { pView->UnmarkAllObj(); - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); - while( aIter != aEnd ) + for( const CustomAnimationEffectPtr& pEffect : maListSelection ) { - CustomAnimationEffectPtr pEffect = *aIter++; - Reference< XShape > xShape( pEffect->getTargetShape() ); SdrObject* pObj = GetSdrObjectFromXShape( xShape ); if( pObj ) diff --git a/sd/source/ui/animations/SlideTransitionPane.cxx b/sd/source/ui/animations/SlideTransitionPane.cxx index 826c307b25fd..311d5356f36d 100644 --- a/sd/source/ui/animations/SlideTransitionPane.cxx +++ b/sd/source/ui/animations/SlideTransitionPane.cxx @@ -226,11 +226,9 @@ void lcl_ApplyToPages( const ::sd::slidesorter::SharedPageSelection& rpPages, const ::sd::impl::TransitionEffect & rEffect ) { - ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin()); - const ::std::vector< SdPage * >::const_iterator aEndIt( rpPages->end()); - for( ; aIt != aEndIt; ++aIt ) + for( const auto& rpPage : *rpPages ) { - rEffect.applyTo( *(*aIt) ); + rEffect.applyTo( *rpPage ); } } @@ -253,11 +251,9 @@ void lcl_CreateUndoForPages( std::unique_ptr<SdUndoGroup> pUndoGroup(new SdUndoGroup( pDoc )); pUndoGroup->SetComment( aComment ); - ::std::vector< SdPage * >::const_iterator aIt( rpPages->begin()); - const ::std::vector< SdPage * >::const_iterator aEndIt( rpPages->end()); - for( ; aIt != aEndIt; ++aIt ) + for( const auto& rpPage : *rpPages ) { - pUndoGroup->AddAction( new sd::UndoTransition( pDoc, (*aIt) ) ); + pUndoGroup->AddAction( new sd::UndoTransition( pDoc, rpPage ) ); } pManager->AddUndoAction( std::move(pUndoGroup) ); @@ -612,16 +608,12 @@ void SlideTransitionPane::updateControls() impl::TransitionEffect aEffect( *pFirstPage ); // merge with other pages - ::sd::slidesorter::SlideSorterViewShell::PageSelection::const_iterator aPageIt( - pSelectedPages->begin()); - ::sd::slidesorter::SlideSorterViewShell::PageSelection::const_iterator aPageEndIt( - pSelectedPages->end()); // start with second page (note aIt != aEndIt, because ! aSelectedPages.empty()) - for( ++aPageIt; aPageIt != aPageEndIt; ++aPageIt ) + for( const auto& rpPage : *pSelectedPages ) { - if( *aPageIt ) - aEffect.compareWith( *(*aPageIt) ); + if( rpPage ) + aEffect.compareWith( *rpPage ); } // detect current slide effect diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index dc85ab59c397..b1d117f87f09 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -270,14 +270,12 @@ Reference<XAnnotation> AnnotationManagerImpl::GetAnnotationById(sal_uInt32 nAnno if( pPage && !pPage->getAnnotations().empty() ) { AnnotationVector aAnnotations(pPage->getAnnotations()); - for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter ) - { - Reference<XAnnotation> xAnnotation(*iter); - if( sd::getAnnotationId(xAnnotation) == nAnnotationId ) - { - return xAnnotation; - } - } + auto iter = std::find_if(aAnnotations.begin(), aAnnotations.end(), + [nAnnotationId](const Reference<XAnnotation>& xAnnotation) { + return sd::getAnnotationId(xAnnotation) == nAnnotationId; + }); + if (iter != aAnnotations.end()) + return *iter; } } while( pPage ); @@ -457,9 +455,9 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) ::tools::Rectangle aNewRect( x, y, x + width - 1, y + height - 1 ); bool bFree = true; - for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter ) + for( const auto& rxAnnotation : aAnnotations ) { - RealPoint2D aPoint( (*iter)->getPosition() ); + RealPoint2D aPoint( rxAnnotation->getPosition() ); aTagRect.SetLeft( sal::static_int_cast< long >( aPoint.X * 100.0 ) ); aTagRect.SetTop( sal::static_int_cast< long >( aPoint.Y * 100.0 ) ); aTagRect.SetRight( aTagRect.Left() + width - 1 ); @@ -645,9 +643,8 @@ void AnnotationManagerImpl::DeleteAnnotationsByAuthor( const OUString& sAuthor ) if( pPage && !pPage->getAnnotations().empty() ) { AnnotationVector aAnnotations( pPage->getAnnotations() ); - for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter ) + for( Reference< XAnnotation >& xAnnotation : aAnnotations ) { - Reference< XAnnotation > xAnnotation( *iter ); if( xAnnotation->getAuthor() == sAuthor ) { if( mxSelectedAnnotation == xAnnotation ) @@ -676,9 +673,9 @@ void AnnotationManagerImpl::DeleteAllAnnotations() { AnnotationVector aAnnotations( pPage->getAnnotations() ); - for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter ) + for( const auto& rxAnnotation : aAnnotations ) { - pPage->removeAnnotation( *iter ); + pPage->removeAnnotation( rxAnnotation ); } } } @@ -755,17 +752,14 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForeward) { if( xCurrent.is() ) { - for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter ) + auto iter = std::find(aAnnotations.begin(), aAnnotations.end(), xCurrent); + if (iter != aAnnotations.end()) { - if( (*iter) == xCurrent ) + ++iter; + if( iter != aAnnotations.end() ) { - ++iter; - if( iter != aAnnotations.end() ) - { - SelectAnnotation( (*iter) ); - return; - } - break; + SelectAnnotation( (*iter) ); + return; } } } @@ -779,18 +773,12 @@ void AnnotationManagerImpl::SelectNextAnnotation(bool bForeward) { if( xCurrent.is() ) { - for( AnnotationVector::iterator iter = aAnnotations.begin(); iter != aAnnotations.end(); ++iter ) + auto iter = std::find(aAnnotations.begin(), aAnnotations.end(), xCurrent); + if (iter != aAnnotations.end() && iter != aAnnotations.begin()) { - if( (*iter) == xCurrent ) - { - if( iter != aAnnotations.begin() ) - { - --iter; - SelectAnnotation( (*iter) ); - return; - } - break; - } + --iter; + SelectAnnotation( (*iter) ); + return; } } else if( !aAnnotations.empty() ) @@ -866,17 +854,13 @@ void AnnotationManagerImpl::SelectAnnotation( const css::uno::Reference< css::of { mxSelectedAnnotation = xAnnotation; - const AnnotationTagVector::const_iterator aEnd( maTagVector.end() ); - for( AnnotationTagVector::const_iterator iter( maTagVector.begin() ); - iter != aEnd; ++iter) + auto iter = std::find_if(maTagVector.begin(), maTagVector.end(), + [&xAnnotation](const rtl::Reference<AnnotationTag>& rxTag) { return rxTag->GetAnnotation() == xAnnotation; }); + if (iter != maTagVector.end()) { - if( (*iter)->GetAnnotation() == xAnnotation ) - { - SmartTagReference xTag( (*iter).get() ); - mrBase.GetMainViewShell()->GetView()->getSmartTags().select( xTag ); - (*iter)->OpenPopup( bEdit ); - break; - } + SmartTagReference xTag( (*iter).get() ); + mrBase.GetMainViewShell()->GetView()->getSmartTags().select( xTag ); + (*iter)->OpenPopup( bEdit ); } } @@ -992,17 +976,12 @@ void AnnotationManagerImpl::CreateTags() void AnnotationManagerImpl::DisposeTags() { - if( !maTagVector.empty() ) + for (auto& rxTag : maTagVector) { - AnnotationTagVector::iterator iter = maTagVector.begin(); - do - { - (*iter++)->Dispose(); - } - while( iter != maTagVector.end() ); - - maTagVector.clear(); + rxTag->Dispose(); } + + maTagVector.clear(); } void AnnotationManagerImpl::addListener() diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index 560f5f0bee7d..99d7050e2888 100644 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -389,10 +389,9 @@ void SdTransferable::AddSupportedFormats() AddFormat( SotClipboardFormatId::EMBED_SOURCE ); DataFlavorExVector aVector( mpOLEDataHelper->GetDataFlavorExVector() ); - DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() ); - while( aIter != aEnd ) - AddFormat( *aIter++ ); + for( const auto& rItem : aVector ) + AddFormat( rItem ); } else if( mpGraphic ) { diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx index c2869b8732de..002cfaf088ce 100644 --- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx +++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx @@ -642,12 +642,9 @@ void ClientBox::populateEntries() vector< std::shared_ptr< ClientInfo > > aClients( RemoteServer::getClients() ); - const vector< std::shared_ptr<ClientInfo > >::const_iterator aEnd( aClients.end() ); - - for ( vector< std::shared_ptr< ClientInfo > >::const_iterator aIt( aClients.begin() ); - aIt != aEnd; ++aIt ) + for ( const auto& rxClient : aClients ) { - addEntry( *aIt ); + addEntry( rxClient ); } #endif diff --git a/sd/source/ui/dlg/assclass.cxx b/sd/source/ui/dlg/assclass.cxx index 7123fc7a7ebd..dda1db947d9e 100644 --- a/sd/source/ui/dlg/assclass.cxx +++ b/sd/source/ui/dlg/assclass.cxx @@ -83,25 +83,19 @@ bool Assistent::GotoPage(const int nPageToGo) { int nIndex=mnCurrentPage-1; - auto iter = maPages[nIndex].begin(); - auto iterEnd = maPages[nIndex].end(); - - for(; iter != iterEnd; ++iter) + for(auto& rxPage : maPages[nIndex]) { - (*iter)->Disable(); - (*iter)->Hide(); + rxPage->Disable(); + rxPage->Hide(); } mnCurrentPage=nPageToGo; nIndex=mnCurrentPage-1; - iter = maPages[nIndex].begin(); - iterEnd = maPages[nIndex].end(); - - for(; iter != iterEnd; ++iter) + for(auto& rxPage : maPages[nIndex]) { - (*iter)->Enable(); - (*iter)->Show(); + rxPage->Enable(); + rxPage->Show(); } return true; diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx index 0df36988aa9a..44b8b5730665 100644 --- a/sd/source/ui/dlg/custsdlg.cxx +++ b/sd/source/ui/dlg/custsdlg.cxx @@ -303,10 +303,9 @@ SdDefineCustomShowDlg::SdDefineCustomShowDlg(weld::Window* pWindow, SdDrawDocume m_xEdtName->set_text( aOldName ); // fill ListBox with CustomShow pages - for( SdCustomShow::PageVec::iterator it = rpCustomShow->PagesVector().begin(); - it != rpCustomShow->PagesVector().end(); ++it ) + for( const auto& rpPage : rpCustomShow->PagesVector() ) { - m_xLbCustomPages->append(OUString::number(reinterpret_cast<sal_uInt64>(*it)) ,(*it)->GetName(), ""); + m_xLbCustomPages->append(OUString::number(reinterpret_cast<sal_uInt64>(rpPage)), rpPage->GetName(), ""); } } else @@ -420,17 +419,18 @@ void SdDefineCustomShowDlg::CheckCustomShow() // compare page pointer if( !bDifferent ) { - SdCustomShow::PageVec::iterator it1 = rpCustomShow->PagesVector().begin(); size_t i = 0; - for( ; it1 != rpCustomShow->PagesVector().end() && i < nCount && !bDifferent; - ++it1, ++i ) + for (const auto& rpPage : rpCustomShow->PagesVector()) { SdPage* pPage = reinterpret_cast<SdPage*>(m_xLbCustomPages->get_id(i).toUInt64()); - if (*it1 != pPage) + if (rpPage != pPage) { rpCustomShow->PagesVector().clear(); bDifferent = true; + break; } + + ++i; } } diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx index 7d34fd8cf1ef..99b283d13116 100644 --- a/sd/source/ui/dlg/present.cxx +++ b/sd/source/ui/dlg/present.cxx @@ -77,8 +77,8 @@ SdStartPresentationDlg::SdStartPresentationDlg(weld::Window* pWindow, const SfxI m_xTmfPause->connect_value_changed( LINK( this, SdStartPresentationDlg, ChangePauseHdl ) ); // fill Listbox with page names - for (std::vector<OUString>::const_iterator pIter = rPageNames.begin(); pIter != rPageNames.end(); ++pIter) - m_xLbDias->append_text(*pIter); + for (const auto& rPageName : rPageNames) + m_xLbDias->append_text(rPageName); if( pCustomShowList ) { diff --git a/sd/source/ui/dlg/sdpreslt.cxx b/sd/source/ui/dlg/sdpreslt.cxx index 5929e734a0fc..3e7e8a325ed1 100644 --- a/sd/source/ui/dlg/sdpreslt.cxx +++ b/sd/source/ui/dlg/sdpreslt.cxx @@ -197,24 +197,18 @@ IMPL_LINK_NOARG(SdPresLayoutDlg, ClickLoadHdl, weld::Button&, void) if( !bCancel ) { // check if template already exists - bool bExists = false; OUString aCompareStr(maName); if (aCompareStr.isEmpty()) aCompareStr = maStrNone; - sal_uInt16 aPos = 0; - for (std::vector<OUString>::iterator it = maLayoutNames.begin(); - it != maLayoutNames.end() && !bExists; ++it, ++aPos) + auto it = std::find(maLayoutNames.begin(), maLayoutNames.end(), aCompareStr); + if (it != maLayoutNames.end()) { - if( aCompareStr == *it ) - { - bExists = true; - // select template - m_xVS->SelectItem( aPos + 1 ); - } + sal_uInt16 aPos = static_cast<sal_uInt16>(std::distance(maLayoutNames.begin(), it)); + // select template + m_xVS->SelectItem( aPos + 1 ); } - - if( !bExists ) + else { // load document in order to determine preview bitmap (if template is selected) if (!maName.isEmpty()) diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index 70ecaebf96f0..1d7805360d79 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -599,17 +599,10 @@ void SdPageObjsTLB::AddShapeList ( bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs); if (mbSaveTreeItemState) { - std::vector<OUString>::iterator iteStart = maTreeItem.begin(); - while (iteStart != maTreeItem.end()) - { - OUString strEntry = GetEntryText(pEntry); - if (*iteStart == strEntry) - { - Expand( pEntry ); - break; - } - ++iteStart; - } + OUString strEntry = GetEntryText(pEntry); + auto it = std::find(maTreeItem.begin(), maTreeItem.end(), strEntry); + if (it != maTreeItem.end()) + Expand( pEntry ); } else Expand( pEntry ); diff --git a/sd/source/ui/framework/configuration/Configuration.cxx b/sd/source/ui/framework/configuration/Configuration.cxx index 1d9639c611b1..a28e52b316ad 100644 --- a/sd/source/ui/framework/configuration/Configuration.cxx +++ b/sd/source/ui/framework/configuration/Configuration.cxx @@ -137,12 +137,9 @@ Sequence<Reference<XResourceId> > SAL_CALL Configuration::getResources ( // Collect the matching resources in a vector. ::std::vector<Reference<XResourceId> > aResources; - ResourceContainer::const_iterator iResource; - for (iResource=mpResourceContainer->begin(); - iResource!=mpResourceContainer->end(); - ++iResource) + for (const auto& rxResource : *mpResourceContainer) { - if ( ! (*iResource)->isBoundTo(rxAnchorId,eMode)) + if ( ! rxResource->isBoundTo(rxAnchorId,eMode)) continue; if (bFilterResources) @@ -151,19 +148,19 @@ Sequence<Reference<XResourceId> > SAL_CALL Configuration::getResources ( // Make sure that the resource is bound directly to the anchor. if (eMode != AnchorBindingMode_DIRECT - && ! (*iResource)->isBoundTo(rxAnchorId, AnchorBindingMode_DIRECT)) + && ! rxResource->isBoundTo(rxAnchorId, AnchorBindingMode_DIRECT)) { continue; } // Make sure that the resource URL matches the given prefix. - if ( ! (*iResource)->getResourceURL().match(rsResourceURLPrefix)) + if ( ! rxResource->getResourceURL().match(rsResourceURLPrefix)) { continue; } } - aResources.push_back(*iResource); + aResources.push_back(rxResource); } return comphelper::containerToSequence(aResources); diff --git a/sd/source/ui/framework/configuration/ConfigurationClassifier.cxx b/sd/source/ui/framework/configuration/ConfigurationClassifier.cxx index 2bc51836e78a..a53ec16229ca 100644 --- a/sd/source/ui/framework/configuration/ConfigurationClassifier.cxx +++ b/sd/source/ui/framework/configuration/ConfigurationClassifier.cxx @@ -73,12 +73,11 @@ void ConfigurationClassifier::PartitionResources ( CopyResources(aC2minusC1, mxConfiguration2, maC2minusC1); // Process the unique resources that belong to both configurations. - ResourceIdVector::const_iterator iResource; - for (iResource=aC1andC2.begin(); iResource!=aC1andC2.end(); ++iResource) + for (const auto& rxResource : aC1andC2) { PartitionResources( - mxConfiguration1->getResources(*iResource, OUString(), AnchorBindingMode_DIRECT), - mxConfiguration2->getResources(*iResource, OUString(), AnchorBindingMode_DIRECT)); + mxConfiguration1->getResources(rxResource, OUString(), AnchorBindingMode_DIRECT), + mxConfiguration2->getResources(rxResource, OUString(), AnchorBindingMode_DIRECT)); } } @@ -131,22 +130,20 @@ void ConfigurationClassifier::CopyResources ( ResourceIdVector& rTarget) { // Copy all resources bound to the ones in aC1minusC2Unique to rC1minusC2. - ResourceIdVector::const_iterator iResource (rSource.begin()); - ResourceIdVector::const_iterator iEnd(rSource.end()); - for ( ; iResource!=iEnd; ++iResource) + for (const auto& rxResource : rSource) { const Sequence<Reference<XResourceId> > aBoundResources ( rxConfiguration->getResources( - *iResource, + rxResource, OUString(), AnchorBindingMode_INDIRECT)); const sal_Int32 nL (aBoundResources.getLength()); rTarget.reserve(rTarget.size() + 1 + nL); - rTarget.push_back(*iResource); + rTarget.push_back(rxResource); SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": copying " << - FrameworkHelper::ResourceIdToString(*iResource)); + FrameworkHelper::ResourceIdToString(rxResource)); const Reference<XResourceId>* aA = aBoundResources.getConstArray(); for (sal_Int32 i=0; i<nL; ++i) @@ -166,10 +163,9 @@ void ConfigurationClassifier::TraceResourceIdVector ( { SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": " << pMessage); - ResourceIdVector::const_iterator iResource; - for (iResource=rResources.begin(); iResource!=rResources.end(); ++iResource) + for (const auto& rxResource : rResources) { - OUString sResource (FrameworkHelper::ResourceIdToString(*iResource)); + OUString sResource (FrameworkHelper::ResourceIdToString(rxResource)); SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": " << sResource); } } diff --git a/sd/source/ui/framework/configuration/ConfigurationController.cxx b/sd/source/ui/framework/configuration/ConfigurationController.cxx index 018a814ed525..28db962a0eb2 100644 --- a/sd/source/ui/framework/configuration/ConfigurationController.cxx +++ b/sd/source/ui/framework/configuration/ConfigurationController.cxx @@ -422,28 +422,22 @@ void SAL_CALL ConfigurationController::restoreConfiguration ( "requested and current resources:\n", aClassifier.GetC1andC2()); #endif - ConfigurationClassifier::ResourceIdVector::const_iterator iResource; - // Request the deactivation of resources that are not requested in the // new configuration. const ConfigurationClassifier::ResourceIdVector& rResourcesToDeactivate ( aClassifier.GetC2minusC1()); - for (iResource=rResourcesToDeactivate.begin(); - iResource!=rResourcesToDeactivate.end(); - ++iResource) + for (const auto& rxResource : rResourcesToDeactivate) { - requestResourceDeactivation(*iResource); + requestResourceDeactivation(rxResource); } // Request the activation of resources that are requested in the // new configuration but are not part of the current configuration. const ConfigurationClassifier::ResourceIdVector& rResourcesToActivate ( aClassifier.GetC1minusC2()); - for (iResource=rResourcesToActivate.begin(); - iResource!=rResourcesToActivate.end(); - ++iResource) + for (const auto& rxResource : rResourcesToActivate) { - requestResourceActivation(*iResource, ResourceActivationMode_ADD); + requestResourceActivation(rxResource, ResourceActivationMode_ADD); } pLock.reset(); diff --git a/sd/source/ui/framework/configuration/ConfigurationControllerBroadcaster.cxx b/sd/source/ui/framework/configuration/ConfigurationControllerBroadcaster.cxx index 32e67427ee58..55eead6e0d96 100644 --- a/sd/source/ui/framework/configuration/ConfigurationControllerBroadcaster.cxx +++ b/sd/source/ui/framework/configuration/ConfigurationControllerBroadcaster.cxx @@ -61,18 +61,13 @@ void ConfigurationControllerBroadcaster::RemoveListener( mxConfigurationController, 0); - ListenerMap::iterator iMap; ListenerList::iterator iList; - for (iMap=maListenerMap.begin(); iMap!=maListenerMap.end(); ++iMap) + for (auto& rMap : maListenerMap) { - for (iList=iMap->second.begin(); iList!=iMap->second.end(); ++iList) - { - if (iList->mxListener == rxListener) - { - iMap->second.erase(iList); - break; - } - } + iList = std::find_if(rMap.second.begin(), rMap.second.end(), + [&rxListener](const ListenerDescriptor& rList) { return rList.mxListener == rxListener; }); + if (iList != rMap.second.end()) + rMap.second.erase(iList); } } @@ -84,20 +79,19 @@ void ConfigurationControllerBroadcaster::NotifyListeners ( // for every listener. ConfigurationChangeEvent aEvent (rEvent); - ListenerList::const_iterator iListener; - for (iListener=rList.begin(); iListener!=rList.end(); ++iListener) + for (const auto& rListener : rList) { try { - aEvent.UserData = iListener->maUserData; - iListener->mxListener->notifyConfigurationChange(aEvent); + aEvent.UserData = rListener.maUserData; + rListener.mxListener->notifyConfigurationChange(aEvent); } catch (const lang::DisposedException& rException) { // When the exception comes from the listener itself then // unregister it. - if (rException.Context == iListener->mxListener) - RemoveListener(iListener->mxListener); + if (rException.Context == rListener.mxListener) + RemoveListener(rListener.mxListener); } catch (const RuntimeException&) { diff --git a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx index afc114b2ebfa..e6e332b53fad 100644 --- a/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx +++ b/sd/source/ui/framework/configuration/ConfigurationUpdater.cxx @@ -198,10 +198,9 @@ void ConfigurationUpdater::CleanRequestedConfiguration() { Reference<XConfigurationController> xCC ( mxControllerManager->getConfigurationController()); - vector<Reference<XResourceId> >::iterator iId; - for (iId=aResourcesToDeactivate.begin(); iId!=aResourcesToDeactivate.end(); ++iId) - if (iId->is()) - xCC->requestResourceDeactivation(*iId); + for (auto& rxId : aResourcesToDeactivate) + if (rxId.is()) + xCC->requestResourceDeactivation(rxId); } } } diff --git a/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx b/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx index 80b140f0c418..10941783dce7 100644 --- a/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx +++ b/sd/source/ui/framework/configuration/ResourceFactoryManager.cxx @@ -51,12 +51,10 @@ ResourceFactoryManager::ResourceFactoryManager (const Reference<XControllerManag ResourceFactoryManager::~ResourceFactoryManager() { - for (auto iXInterfaceResource = maFactoryMap.begin(); - iXInterfaceResource != maFactoryMap.end(); - ++iXInterfaceResource) + for (auto& rXInterfaceResource : maFactoryMap) { - Reference<lang::XComponent> xComponent (iXInterfaceResource->second, UNO_QUERY); - iXInterfaceResource->second = nullptr; + Reference<lang::XComponent> xComponent (rXInterfaceResource.second, UNO_QUERY); + rXInterfaceResource.second = nullptr; if (xComponent.is()) xComponent->dispose(); } @@ -112,17 +110,12 @@ void ResourceFactoryManager::RemoveFactoryForURL ( else { // The URL may be a pattern. Look that up. - FactoryPatternList::iterator iPattern; - for (iPattern=maFactoryPatternList.begin(); - iPattern!=maFactoryPatternList.end(); - ++iPattern) + auto iPattern = std::find_if(maFactoryPatternList.begin(), maFactoryPatternList.end(), + [&rsURL](const FactoryPatternList::value_type& rPattern) { return rPattern.first == rsURL; }); + if (iPattern != maFactoryPatternList.end()) { - if (iPattern->first == rsURL) - { - // Found the pattern. Remove it. - maFactoryPatternList.erase(iPattern); - break; - } + // Found the pattern. Remove it. + maFactoryPatternList.erase(iPattern); } } } @@ -134,25 +127,22 @@ void ResourceFactoryManager::RemoveFactoryForReference( // Collect a list with all keys that map to the given factory. ::std::vector<OUString> aKeys; - FactoryMap::const_iterator iFactory; - for (iFactory=maFactoryMap.begin(); iFactory!=maFactoryMap.end(); ++iFactory) - if (iFactory->second == rxFactory) - aKeys.push_back(iFactory->first); + for (const auto& rFactory : maFactoryMap) + if (rFactory.second == rxFactory) + aKeys.push_back(rFactory.first); // Remove the entries whose keys we just have collected. - ::std::vector<OUString>::const_iterator iKey; - for (iKey=aKeys.begin(); iKey!=aKeys.end(); ++iKey) - maFactoryMap.erase(*iKey); + for (const auto& rKey : aKeys) + maFactoryMap.erase(rKey); // Remove the pattern entries whose factories are identical to the given // factory. - FactoryPatternList::iterator iNewEnd ( + maFactoryPatternList.erase( std::remove_if( maFactoryPatternList.begin(), maFactoryPatternList.end(), - [&] (FactoryPatternList::value_type const& it) { return it.second == rxFactory; })); - if (iNewEnd != maFactoryPatternList.end()) - maFactoryPatternList.erase(iNewEnd, maFactoryPatternList.end()); + [&] (FactoryPatternList::value_type const& it) { return it.second == rxFactory; }), + maFactoryPatternList.end()); } Reference<XResourceFactory> ResourceFactoryManager::GetFactory ( @@ -195,15 +185,13 @@ Reference<XResourceFactory> ResourceFactoryManager::FindFactory (const OUString& else { // Check the URL patterns. - FactoryPatternList::const_iterator iPattern; - for (iPattern=maFactoryPatternList.begin(); - iPattern!=maFactoryPatternList.end(); - ++iPattern) - { - WildCard aWildCard (iPattern->first); - if (aWildCard.Matches(rsURLBase)) - return iPattern->second; - } + auto iPattern = std::find_if(maFactoryPatternList.begin(), maFactoryPatternList.end(), + [&rsURLBase](const FactoryPatternList::value_type& rPattern) { + WildCard aWildCard (rPattern.first); + return aWildCard.Matches(rsURLBase); + }); + if (iPattern != maFactoryPatternList.end()) + return iPattern->second; } return nullptr; } diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx index 432b459087b4..44a64d838cb9 100644 --- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx +++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx @@ -109,13 +109,11 @@ void SAL_CALL BasicPaneFactory::disposing() mxConfigurationControllerWeak.clear(); } - for (PaneContainer::const_iterator iDescriptor = mpPaneContainer->begin(); - iDescriptor != mpPaneContainer->end(); - ++iDescriptor) + for (const auto& rDescriptor : *mpPaneContainer) { - if (iDescriptor->mbIsReleased) + if (rDescriptor.mbIsReleased) { - Reference<XComponent> xComponent (iDescriptor->mxPane, UNO_QUERY); + Reference<XComponent> xComponent (rDescriptor.mxPane, UNO_QUERY); if (xComponent.is()) { xComponent->removeEventListener(this); diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx index d76eccbde220..7537882625ea 100644 --- a/sd/source/ui/framework/factories/BasicViewFactory.cxx +++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx @@ -109,10 +109,9 @@ void SAL_CALL BasicViewFactory::disposing() } // Release the view cache. - ViewShellContainer::const_iterator iView; - for (iView=mpViewCache->begin(); iView!=mpViewCache->end(); ++iView) + for (const auto& rxView : *mpViewCache) { - ReleaseView(*iView, true); + ReleaseView(rxView, true); } // Release the view shell container. At this point no one other than us @@ -120,9 +119,9 @@ void SAL_CALL BasicViewFactory::disposing() // trivial requirement, because no one other than us holds a shared // pointer). // ViewShellContainer::const_iterator iView; - for (iView=mpViewShellContainer->begin(); iView!=mpViewShellContainer->end(); ++iView) + for (const auto& rxView : *mpViewShellContainer) { - OSL_ASSERT((*iView)->mpViewShell.use_count() == 1); + OSL_ASSERT(rxView->mpViewShell.use_count() == 1); } mpViewShellContainer.reset(); } @@ -452,15 +451,8 @@ bool BasicViewFactory::IsCacheable (const std::shared_ptr<ViewDescriptor>& rpDes return tmp; }(); - ::std::vector<Reference<XResourceId> >::const_iterator iId; - for (iId=s_aCacheableResources.begin(); iId!=s_aCacheableResources.end(); ++iId) - { - if ((*iId)->compareTo(rpDescriptor->mxViewId) == 0) - { - bIsCacheable = true; - break; - } - } + bIsCacheable = std::any_of(s_aCacheableResources.begin(), s_aCacheableResources.end(), + [&rpDescriptor](const Reference<XResourceId>& rxId) { return rxId->compareTo(rpDescriptor->mxViewId) == 0; }); } return bIsCacheable; @@ -473,15 +465,12 @@ std::shared_ptr<BasicViewFactory::ViewDescriptor> BasicViewFactory::GetViewFromC std::shared_ptr<ViewDescriptor> pDescriptor; // Search for the requested view in the cache. - ViewCache::iterator iEntry; - for (iEntry=mpViewCache->begin(); iEntry!=mpViewCache->end(); ++iEntry) + ViewCache::iterator iEntry = std::find_if(mpViewCache->begin(), mpViewCache->end(), + [&rxViewId](const ViewCache::value_type& rxEntry) { return rxEntry->mxViewId->compareTo(rxViewId) == 0; }); + if (iEntry != mpViewCache->end()) { - if ((*iEntry)->mxViewId->compareTo(rxViewId) == 0) - { - pDescriptor = *iEntry; - mpViewCache->erase(iEntry); - break; - } + pDescriptor = *iEntry; + mpViewCache->erase(iEntry); } // When the view has been found then relocate it to the given pane and diff --git a/sd/source/ui/framework/module/ModuleController.cxx b/sd/source/ui/framework/module/ModuleController.cxx index eefe774dd8a9..bfb6507b7f01 100644 --- a/sd/source/ui/framework/module/ModuleController.cxx +++ b/sd/source/ui/framework/module/ModuleController.cxx @@ -133,11 +133,10 @@ void ModuleController::ProcessFactory (const ::std::vector<Any>& rValues) SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ModuleController::adding factory " << sServiceName); // Add the resource URLs to the map. - ::std::vector<OUString>::const_iterator iResource; - for (iResource=aURLs.begin(); iResource!=aURLs.end(); ++iResource) + for (const auto& rResource : aURLs) { - (*mpResourceToFactoryMap)[*iResource] = sServiceName; - SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": " << *iResource); + (*mpResourceToFactoryMap)[rResource] = sServiceName; + SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": " << rResource); } } diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index affbf5da2af8..7702ece5925e 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -79,11 +79,10 @@ namespace OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc > const& rFilterDescList ) { OUStringBuffer aExtensions; - ::std::vector< FilterDesc >::const_iterator aIter( rFilterDescList.begin() ); - while (aIter != rFilterDescList.end()) + for (const auto& rFilterDesc : rFilterDescList) { - OUString sWildcard = (*aIter).second; + OUString sWildcard = rFilterDesc.second; if ( aExtensions.indexOf( sWildcard ) == -1 ) { @@ -92,7 +91,6 @@ OUString lcl_GetExtensionsList ( ::std::vector< FilterDesc > const& rFilterDescL aExtensions.append(sWildcard); } - ++aIter; } return aExtensions.makeStringAndClear(); @@ -206,14 +204,10 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) lcl_AddFilter( aFilterVector, pFilter ); // add additional supported filters - ::std::vector< OUString >::const_iterator aOtherIter( aOtherFilterVector.begin() ); - - while( aOtherIter != aOtherFilterVector.end() ) + for( const auto& rOtherFilter : aOtherFilterVector ) { - if( ( pFilter = rMatcher.GetFilter4Mime( *aOtherIter ) ) != nullptr ) + if( ( pFilter = rMatcher.GetFilter4Mime( rOtherFilter ) ) != nullptr ) lcl_AddFilter( aFilterVector, pFilter ); - - ++aOtherIter; } // set "All supported formats" as the default filter @@ -225,12 +219,9 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) xFilterManager->setCurrentFilter( aAllSpec ); // append individual filters - ::std::vector< ::std::pair < OUString, OUString > >::const_iterator aIter( aFilterVector.begin() ); - - while( aIter != aFilterVector.end() ) + for( const auto& rFilter : aFilterVector ) { - xFilterManager->appendFilter( (*aIter).first, (*aIter).second ); - ++aIter; + xFilterManager->appendFilter( rFilter.first, rFilter.second ); } // end with "All files" as fallback diff --git a/sd/source/ui/func/fuprlout.cxx b/sd/source/ui/func/fuprlout.cxx index 5cea52322ca9..9f33a572bd84 100644 --- a/sd/source/ui/func/fuprlout.cxx +++ b/sd/source/ui/func/fuprlout.cxx @@ -108,9 +108,8 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq ) pSlideSorterViewShell->GetPageSelection()); if (xSelection) { - for (auto it = xSelection->begin(); it != xSelection->end(); ++it) + for (SdPage *pPage : *xSelection) { - SdPage *pPage = *it; if (pPage->IsSelected() || pPage->GetPageKind() != PageKind::Standard) continue; mpDoc->SetSelected(pPage, true); diff --git a/sd/source/ui/func/fuprobjs.cxx b/sd/source/ui/func/fuprobjs.cxx index 0b7c4c94a338..9524590fab16 100644 --- a/sd/source/ui/func/fuprobjs.cxx +++ b/sd/source/ui/func/fuprobjs.cxx @@ -83,17 +83,14 @@ void FuPresentationObjects::DoExecute( SfxRequest& ) std::vector<Paragraph*> aSelList; pOutlinerView->CreateSelectionList(aSelList); - std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); - Paragraph* pPara = aSelList.empty() ? nullptr : *iter; + Paragraph* pPara = aSelList.empty() ? nullptr : aSelList.front(); nDepth = pOutl->GetDepth(pOutl->GetAbsPos( pPara ) ); bool bPage = ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ); - while( iter != aSelList.end() ) + for( const auto& rpPara : aSelList ) { - pPara = *iter; - - nTmp = pOutl->GetDepth( pOutl->GetAbsPos( pPara ) ); + nTmp = pOutl->GetDepth( pOutl->GetAbsPos( rpPara ) ); if( nDepth != nTmp ) { @@ -101,13 +98,12 @@ void FuPresentationObjects::DoExecute( SfxRequest& ) break; } - if( ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) != bPage ) + if( ::Outliner::HasParaFlag( rpPara, ParaFlag::ISPAGE ) != bPage ) { bUnique = false; break; } bUnique = true; - ++iter; } if( bUnique ) diff --git a/sd/source/ui/func/smarttag.cxx b/sd/source/ui/func/smarttag.cxx index a08a47c5cd93..0b2e531e1eed 100644 --- a/sd/source/ui/func/smarttag.cxx +++ b/sd/source/ui/func/smarttag.cxx @@ -148,8 +148,8 @@ void SmartTagSet::Dispose() { std::set< SmartTagReference > aSet; aSet.swap( maSet ); - for( std::set< SmartTagReference >::iterator aIter( aSet.begin() ); aIter != aSet.end(); ) - (*aIter++)->Dispose(); + for( auto& rxItem : aSet ) + rxItem->Dispose(); mrView.InvalidateAllWin(); mxMouseOverTag.clear(); mxSelectedTag.clear(); @@ -276,8 +276,8 @@ bool SmartTagSet::Command( const CommandEvent& rCEvt ) void SmartTagSet::addCustomHandles( SdrHdlList& rHandlerList ) { - for( std::set< SmartTagReference >::iterator aIter( maSet.begin() ); aIter != maSet.end(); ) - (*aIter++)->addCustomHandles( rHandlerList ); + for( auto& rxItem : maSet ) + rxItem->addCustomHandles( rHandlerList ); } /** returns true if the currently selected smart tag has diff --git a/sd/source/ui/func/unmovss.cxx b/sd/source/ui/func/unmovss.cxx index 8805b324a1cc..77391d606a68 100644 --- a/sd/source/ui/func/unmovss.cxx +++ b/sd/source/ui/func/unmovss.cxx @@ -59,9 +59,9 @@ void SdMoveStyleSheetsUndoAction::Undo() for (auto& a : maStyles) { OUString aParent(a.m_xStyleSheet->GetName()); - for( SdStyleSheetVector::iterator childiter = (*childlistiter).begin(); childiter != (*childlistiter).end(); ++childiter ) + for( auto& rxChild : *childlistiter ) { - (*childiter)->SetParent(aParent); + rxChild->SetParent(aParent); } ++childlistiter; } diff --git a/sd/source/ui/presenter/PresenterPreviewCache.cxx b/sd/source/ui/presenter/PresenterPreviewCache.cxx index 1894a8cdd25c..b0de97d6997d 100644 --- a/sd/source/ui/presenter/PresenterPreviewCache.cxx +++ b/sd/source/ui/presenter/PresenterPreviewCache.cxx @@ -234,13 +234,9 @@ void PresenterPreviewCache::PresenterCacheContext::AddPreviewCreationNotifyListe void PresenterPreviewCache::PresenterCacheContext::RemovePreviewCreationNotifyListener ( const Reference<drawing::XSlidePreviewCacheListener>& rxListener) { - ListenerContainer::iterator iListener; - for (iListener=maListeners.begin(); iListener!=maListeners.end(); ++iListener) - if (*iListener == rxListener) - { - maListeners.erase(iListener); - return; - } + auto iListener = std::find(maListeners.begin(), maListeners.end(), rxListener); + if (iListener != maListeners.end()) + maListeners.erase(iListener); } //----- CacheContext ---------------------------------------------------------- @@ -341,16 +337,15 @@ void PresenterPreviewCache::PresenterCacheContext::CallListeners ( const sal_Int32 nIndex) { ListenerContainer aListeners (maListeners); - ListenerContainer::const_iterator iListener; - for (iListener=aListeners.begin(); iListener!=aListeners.end(); ++iListener) + for (const auto& rxListener : aListeners) { try { - (*iListener)->notifyPreviewCreation(nIndex); + rxListener->notifyPreviewCreation(nIndex); } catch (lang::DisposedException&) { - RemovePreviewCreationNotifyListener(*iListener); + RemovePreviewCreationNotifyListener(rxListener); } } } diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index 14a61315c86e..589b43f2bb9c 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -1148,9 +1148,8 @@ void BluetoothServer::doRestoreDiscoverable() // re-bind to the same port number it appears. void BluetoothServer::cleanupCommunicators() { - for (std::vector<Communicator *>::iterator it = mpCommunicators->begin(); - it != mpCommunicators->end(); ++it) - (*it)->forceClose(); + for (auto& rpCommunicator : *mpCommunicators) + rpCommunicator->forceClose(); // the hope is that all the threads then terminate cleanly and // clean themselves up. } diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index d3551eeccec0..57adc01cc127 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -202,10 +202,9 @@ void RemoteServer::presentationStarted( const css::uno::Reference< if ( !spServer ) return; MutexGuard aGuard( sDataMutex ); - for ( vector<Communicator*>::const_iterator aIt = sCommunicators.begin(); - aIt != sCommunicators.end(); ++aIt ) + for ( const auto& rpCommunicator : sCommunicators ) { - (*aIt)->presentationStarted( rController ); + rpCommunicator->presentationStarted( rController ); } } void RemoteServer::presentationStopped() @@ -213,10 +212,9 @@ void RemoteServer::presentationStopped() if ( !spServer ) return; MutexGuard aGuard( sDataMutex ); - for ( vector<Communicator*>::const_iterator aIt = sCommunicators.begin(); - aIt != sCommunicators.end(); ++aIt ) + for ( const auto& rpCommunicator : sCommunicators ) { - (*aIt)->disposeListener(); + rpCommunicator->disposeListener(); } } @@ -225,15 +223,9 @@ void RemoteServer::removeCommunicator( Communicator const * mCommunicator ) if ( !spServer ) return; MutexGuard aGuard( sDataMutex ); - for ( vector<Communicator*>::iterator aIt = sCommunicators.begin(); - aIt != sCommunicators.end(); ++aIt ) - { - if ( mCommunicator == *aIt ) - { - sCommunicators.erase( aIt ); - break; - } - } + auto aIt = std::find(sCommunicators.begin(), sCommunicators.end(), mCommunicator); + if (aIt != sCommunicators.end()) + sCommunicators.erase( aIt ); } std::vector< std::shared_ptr< ClientInfo > > RemoteServer::getClients() @@ -318,15 +310,9 @@ bool RemoteServer::connectClient( const std::shared_ptr< ClientInfo >& pClient, sCommunicators.push_back( pCommunicator ); - for ( vector< std::shared_ptr< ClientInfoInternal > >::iterator aIt = spServer->mAvailableClients.begin(); - aIt != spServer->mAvailableClients.end(); ++aIt ) - { - if ( pClient == *aIt ) - { - spServer->mAvailableClients.erase( aIt ); - break; - } - } + auto aIt = std::find(spServer->mAvailableClients.begin(), spServer->mAvailableClients.end(), pClient); + if (aIt != spServer->mAvailableClients.end()) + spServer->mAvailableClients.erase( aIt ); pCommunicator->launch(); return true; } |