diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-11-18 13:43:28 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-18 17:36:54 +0100 |
commit | 587ef41f75b8ea0bcd03366178d42a324dcf481c (patch) | |
tree | a672c557221d4fec8abbaf83568ed9e7242323a5 /svx/source/sdr | |
parent | 8b83659bb8f3368a1df949d5bc84d7b2dd0370b4 (diff) |
Simplify containers iterations in svx/source/[s-u]*
Use range-based loop or replace with STL functions
Change-Id: I2ec3e58cc46c9286ef863c732912ca7a729bab62
Reviewed-on: https://gerrit.libreoffice.org/63522
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/sdr')
-rw-r--r-- | svx/source/sdr/animation/scheduler.cxx | 11 | ||||
-rw-r--r-- | svx/source/sdr/overlay/overlaymanager.cxx | 20 | ||||
-rw-r--r-- | svx/source/sdr/overlay/overlaymanagerbuffered.cxx | 14 | ||||
-rw-r--r-- | svx/source/sdr/properties/defaultproperties.cxx | 4 | ||||
-rw-r--r-- | svx/source/sdr/properties/textproperties.cxx | 29 |
5 files changed, 35 insertions, 43 deletions
diff --git a/svx/source/sdr/animation/scheduler.cxx b/svx/source/sdr/animation/scheduler.cxx index a8fc3272be8b..4f32f101f999 100644 --- a/svx/source/sdr/animation/scheduler.cxx +++ b/svx/source/sdr/animation/scheduler.cxx @@ -88,12 +88,10 @@ namespace sdr } // execute events from the vector - ::std::vector< Event* >::const_iterator aEnd = aToBeExecutedList.end(); - for(::std::vector< Event* >::iterator aCandidate = aToBeExecutedList.begin(); - aCandidate != aEnd; ++aCandidate) + for(auto& rpCandidate : aToBeExecutedList) { // trigger event. This may re-insert the event to the scheduler again - (*aCandidate)->Trigger(mnTime); + rpCandidate->Trigger(mnTime); } } @@ -146,9 +144,8 @@ namespace sdr void Scheduler::InsertEvent(Event& rNew) { // insert maintaining time ordering - auto it = mvEvents.begin(); - while (it != mvEvents.end() && rNew.GetTime() >= (*it)->GetTime()) - it++; + auto it = std::find_if(mvEvents.begin(), mvEvents.end(), + [&rNew](const Event* pEvent) { return rNew.GetTime() < pEvent->GetTime(); }); mvEvents.insert(it, &rNew); checkTimeout(); } diff --git a/svx/source/sdr/overlay/overlaymanager.cxx b/svx/source/sdr/overlay/overlaymanager.cxx index 3660598a23f7..14460a3ac605 100644 --- a/svx/source/sdr/overlay/overlaymanager.cxx +++ b/svx/source/sdr/overlay/overlaymanager.cxx @@ -52,10 +52,10 @@ namespace sdr if(pProcessor) { - for(OverlayObjectVector::const_iterator aIter(maOverlayObjects.begin()); aIter != maOverlayObjects.end(); ++aIter) + for(const auto& rpOverlayObject : maOverlayObjects) { - OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)"); - const OverlayObject& rCandidate = **aIter; + OSL_ENSURE(rpOverlayObject, "Corrupted OverlayObject List (!)"); + const OverlayObject& rCandidate = *rpOverlayObject; if(rCandidate.isVisible()) { @@ -94,11 +94,10 @@ namespace sdr if(nSize) { - OverlayObjectVector::const_iterator aEnd(maOverlayObjects.end()); - for(OverlayObjectVector::iterator aIter(maOverlayObjects.begin()); aIter != aEnd; ++aIter) + for(const auto& rpOverlayObject : maOverlayObjects) { - OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)"); - OverlayObject& rCandidate = **aIter; + OSL_ENSURE(rpOverlayObject, "Corrupted OverlayObject List (!)"); + OverlayObject& rCandidate = *rpOverlayObject; rCandidate.stripeDefinitionHasChanged(); } } @@ -224,11 +223,10 @@ namespace sdr if(nSize) { - OverlayObjectVector::const_iterator aEnd = maOverlayObjects.end(); - for(OverlayObjectVector::iterator aIter(maOverlayObjects.begin()); aIter != aEnd; ++aIter) + for(const auto& rpOverlayObject : maOverlayObjects) { - OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)"); - OverlayObject& rCandidate = **aIter; + OSL_ENSURE(rpOverlayObject, "Corrupted OverlayObject List (!)"); + OverlayObject& rCandidate = *rpOverlayObject; impApplyRemoveActions(rCandidate); } diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx index 2d4514c90046..6a88e7633944 100644 --- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx +++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx @@ -121,7 +121,7 @@ namespace sdr RectangleVector aRectangles; rRegionPixel.GetRegionRectangles(aRectangles); - for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) + for(const auto& rRect : aRectangles) { #ifdef DBG_UTIL // #i72754# possible graphical region test only with non-pro @@ -131,13 +131,13 @@ namespace sdr { getOutputDevice().SetLineColor(COL_LIGHTGREEN); getOutputDevice().SetFillColor(); - getOutputDevice().DrawRect(*aRectIter); + getOutputDevice().DrawRect(rRect); } #endif // restore the area - const Point aTopLeft(aRectIter->TopLeft()); - const Size aSize(aRectIter->GetSize()); + const Point aTopLeft(rRect.TopLeft()); + const Size aSize(rRect.GetSize()); getOutputDevice().DrawOutDev( aTopLeft, aSize, // destination @@ -188,11 +188,11 @@ namespace sdr RectangleVector aRectangles; aRegion.GetRegionRectangles(aRectangles); - for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) + for(const auto& rRect : aRectangles) { // for each rectangle, save the area - const Point aTopLeft(aRectIter->TopLeft()); - const Size aSize(aRectIter->GetSize()); + const Point aTopLeft(rRect.TopLeft()); + const Size aSize(rRect.GetSize()); mpBufferDevice->DrawOutDev( aTopLeft, aSize, // destination diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index c39a827b02fd..063205ff405c 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -188,9 +188,9 @@ namespace sdr if(bDidChange) { - for (std::vector< sal_uInt16 >::const_iterator aIter(aPostItemChangeList.begin()), aEnd(aPostItemChangeList.end()); aIter != aEnd; ++aIter) + for (const auto& rItem : aPostItemChangeList) { - PostItemChange(*aIter); + PostItemChange(rItem); } ItemSetChanged(aSet); diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index 9926586837f8..7aeacdf7e3fc 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -451,23 +451,20 @@ namespace sdr std::vector<EECharAttrib> aAttribs; pEditEngine->GetCharAttribs(nPara, aAttribs); - for(std::vector<EECharAttrib>::const_iterator i = aAttribs.begin(), aEnd = aAttribs.end(); i != aEnd; ++i) + for(const auto& rAttrib : aAttribs) { - if(EE_FEATURE_FIELD == i->pAttr->Which()) + if(rAttrib.pAttr && EE_FEATURE_FIELD == rAttrib.pAttr->Which()) { - if(i->pAttr) + const SvxFieldItem* pFieldItem = static_cast<const SvxFieldItem*>(rAttrib.pAttr); + + if(pFieldItem) { - const SvxFieldItem* pFieldItem = static_cast<const SvxFieldItem*>(i->pAttr); + const SvxFieldData* pData = pFieldItem->GetField(); - if(pFieldItem) + if(dynamic_cast<const SvxURLField*>( pData)) { - const SvxFieldData* pData = pFieldItem->GetField(); - - if(dynamic_cast<const SvxURLField*>( pData)) - { - bHasURL = true; - break; - } + bHasURL = true; + break; } } } @@ -480,16 +477,16 @@ namespace sdr ESelection aSel(nPara, 0); - for(std::vector<EECharAttrib>::const_iterator i = aAttribs.begin(), aEnd = aAttribs.end(); i != aEnd; ++i) + for(const auto& rAttrib : aAttribs) { - if(EE_FEATURE_FIELD == i->pAttr->Which()) + if(EE_FEATURE_FIELD == rAttrib.pAttr->Which()) { - aSel.nEndPos = i->nStart; + aSel.nEndPos = rAttrib.nStart; if(aSel.nStartPos != aSel.nEndPos) pEditEngine->QuickSetAttribs(aColorSet, aSel); - aSel.nStartPos = i->nEnd; + aSel.nStartPos = rAttrib.nEnd; } } |