summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-10-14 12:00:03 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-14 17:30:32 +0200
commit19be86249dcc5b13b3c95f5469600fa2bc1b749b (patch)
treee1468590650eea60e3897a8cb8b7c36bb9ab996b
parent7758115d15ded2afd81946df0865ecc831b179aa (diff)
Simplify containers iterations in vcl
Use range-based loop or replace with STL functions. Change-Id: Ide2f89194238ae6a1f21e8132e2297710d9e6dcd Reviewed-on: https://gerrit.libreoffice.org/61756 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--vcl/headless/svpframe.cxx5
-rw-r--r--vcl/inc/impdel.hxx5
-rw-r--r--vcl/osx/salnativewidgets.cxx10
-rw-r--r--vcl/qt5/Qt5Instance_Print.cxx6
-rw-r--r--vcl/quartz/ctfonts.cxx5
-rw-r--r--vcl/quartz/salgdicommon.cxx9
-rw-r--r--vcl/source/control/throbber.cxx7
-rw-r--r--vcl/source/filter/graphicfilter.cxx15
-rw-r--r--vcl/source/filter/wmf/wmfwr.cxx5
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx5
-rw-r--r--vcl/source/fontsubset/sft.cxx5
-rw-r--r--vcl/source/gdi/pdfextoutdevdata.cxx35
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx14
-rw-r--r--vcl/source/gdi/textlayout.cxx7
-rw-r--r--vcl/source/window/accmgr.cxx14
-rw-r--r--vcl/source/window/builder.cxx35
-rw-r--r--vcl/source/window/dialog.cxx18
-rw-r--r--vcl/source/window/dlgctrl.cxx27
-rw-r--r--vcl/source/window/layout.cxx9
-rw-r--r--vcl/source/window/menu.cxx6
-rw-r--r--vcl/source/window/printdlg.cxx20
-rw-r--r--vcl/source/window/taskpanelist.cxx130
-rw-r--r--vcl/source/window/toolbox.cxx61
-rw-r--r--vcl/source/window/toolbox2.cxx104
-rw-r--r--vcl/unx/generic/dtrans/X11_selection.cxx11
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx4
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx8
-rw-r--r--vcl/unx/generic/gdi/salbmp.cxx11
-rw-r--r--vcl/unx/generic/printer/ppdparser.cxx25
-rw-r--r--vcl/unx/generic/printer/printerinfomanager.cxx35
-rw-r--r--vcl/unx/gtk/gtksalframe.cxx19
-rw-r--r--vcl/unx/gtk/salprn-gtk.cxx5
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx19
-rw-r--r--vcl/win/gdi/salnativewidgets-luna.cxx8
-rw-r--r--vcl/workben/vcldemo.cxx11
35 files changed, 268 insertions, 445 deletions
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 20a3ffa68823..9bf3e9cb84e6 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -81,9 +81,8 @@ SvpSalFrame::~SvpSalFrame()
m_pInstance->deregisterFrame( this );
std::list<SvpSalFrame*> Children = m_aChildren;
- for( std::list<SvpSalFrame*>::iterator it = Children.begin();
- it != Children.end(); ++it )
- (*it)->SetParent( m_pParent );
+ for( auto& rChild : Children )
+ rChild->SetParent( m_pParent );
if( m_pParent )
m_pParent->m_aChildren.remove( this );
diff --git a/vcl/inc/impdel.hxx b/vcl/inc/impdel.hxx
index 95f373b1dcb9..308872b9c9eb 100644
--- a/vcl/inc/impdel.hxx
+++ b/vcl/inc/impdel.hxx
@@ -67,9 +67,8 @@ class DeletionListener
inline void DeletionNotifier::notifyDelete()
{
- for( std::list< DeletionListener* >::const_iterator it =
- m_aListeners.begin(); it != m_aListeners.end(); ++it )
- (*it)->deleted();
+ for( auto& rListener : m_aListeners )
+ rListener->deleted();
m_aListeners.clear();
}
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 9e5008703549..d89fecf1681e 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -74,12 +74,10 @@ public:
void AquaBlinker::Blink( AquaSalFrame* pFrame, const tools::Rectangle& rRect, int nTimeout )
{
// prevent repeated paints from triggering themselves all the time
- for( std::list< AquaBlinker* >::const_iterator it = pFrame->maBlinkers.begin();
- it != pFrame->maBlinkers.end(); ++it )
- {
- if( (*it)->maInvalidateRect == rRect )
- return;
- }
+ auto isRepeated = std::any_of(pFrame->maBlinkers.begin(), pFrame->maBlinkers.end(),
+ [&rRect](AquaBlinker* pBlinker) { return pBlinker->maInvalidateRect == rRect; });
+ if( isRepeated )
+ return;
AquaBlinker* pNew = new AquaBlinker( pFrame, rRect );
pNew->SetTimeout( nTimeout );
pNew->Start();
diff --git a/vcl/qt5/Qt5Instance_Print.cxx b/vcl/qt5/Qt5Instance_Print.cxx
index dd095f533c1a..501db07e7362 100644
--- a/vcl/qt5/Qt5Instance_Print.cxx
+++ b/vcl/qt5/Qt5Instance_Print.cxx
@@ -89,12 +89,12 @@ void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
::std::vector<OUString> aPrinters;
rManager.listPrinters(aPrinters);
- for (::std::vector<OUString>::iterator it = aPrinters.begin(); it != aPrinters.end(); ++it)
+ for (const auto& rPrinter : aPrinters)
{
- const PrinterInfo& rInfo(rManager.getPrinterInfo(*it));
+ const PrinterInfo& rInfo(rManager.getPrinterInfo(rPrinter));
// create new entry
SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
- pInfo->maPrinterName = *it;
+ pInfo->maPrinterName = rPrinter;
pInfo->maDriver = rInfo.m_aDriverName;
pInfo->maLocation = rInfo.m_aLocation;
pInfo->maComment = rInfo.m_aComment;
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index 65b3a85f5a43..6050badcdcca 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -537,10 +537,9 @@ void SystemFontList::AddFont( CoreTextFontFace* pFontData )
void SystemFontList::AnnounceFonts( PhysicalFontCollection& rFontCollection ) const
{
- auto it = maFontContainer.cbegin();
- for(; it != maFontContainer.cend(); ++it )
+ for(const auto& rEntry : maFontContainer )
{
- rFontCollection.Add( (*it).second.get() );
+ rFontCollection.Add( rEntry.second.get() );
}
}
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 65d158f98201..d7a21d3ccd30 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -1769,18 +1769,17 @@ bool AquaSalGraphics::setClipRegion( const vcl::Region& i_rClip )
RectangleVector aRectangles;
i_rClip.GetRegionRectangles(aRectangles);
- for(RectangleVector::const_iterator aRectIter(aRectangles.begin());
- aRectIter != aRectangles.end(); ++aRectIter)
+ for(const auto& rRect : aRectangles)
{
- const long nW(aRectIter->Right() - aRectIter->Left() + 1); // uses +1 logic in original
+ const long nW(rRect.Right() - rRect.Left() + 1); // uses +1 logic in original
if(nW)
{
- const long nH(aRectIter->Bottom() - aRectIter->Top() + 1); // uses +1 logic in original
+ const long nH(rRect.Bottom() - rRect.Top() + 1); // uses +1 logic in original
if(nH)
{
- const CGRect aRect = CGRectMake( aRectIter->Left(), aRectIter->Top(), nW, nH);
+ const CGRect aRect = CGRectMake( rRect.Left(), rRect.Top(), nW, nH);
SAL_INFO( "vcl.cg", "CGPathAddRect(" << mxClipPath << ",NULL," << aRect << ")" );
CGPathAddRect( mxClipPath, nullptr, aRect );
}
diff --git a/vcl/source/control/throbber.cxx b/vcl/source/control/throbber.cxx
index eae208bf1698..48f1f47733e6 100644
--- a/vcl/source/control/throbber.cxx
+++ b/vcl/source/control/throbber.cxx
@@ -78,13 +78,10 @@ namespace
aImages.reserve( aImageURLs.size() );
::comphelper::NamedValueCollection aMediaProperties;
- for ( ::std::vector< OUString >::const_iterator imageURL = aImageURLs.begin();
- imageURL != aImageURLs.end();
- ++imageURL
- )
+ for ( const auto& rImageURL : aImageURLs )
{
Reference< XGraphic > xGraphic;
- aMediaProperties.put( "URL", *imageURL );
+ aMediaProperties.put( "URL", rImageURL );
xGraphic.set( xGraphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY );
aImages.emplace_back( xGraphic );
}
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index be79226ffbef..6cd6043dba9e 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1080,17 +1080,10 @@ GraphicFilter::~GraphicFilter()
{
{
::osl::MutexGuard aGuard( getListMutex() );
- for(
- FilterList_impl::iterator it = pFilterHdlList->begin();
- it != pFilterHdlList->end();
- ++it
- ) {
- if( *it == this )
- {
- pFilterHdlList->erase( it );
- break;
- }
- }
+ auto it = std::find(pFilterHdlList->begin(), pFilterHdlList->end(), this);
+ if( it != pFilterHdlList->end() )
+ pFilterHdlList->erase( it );
+
if( pFilterHdlList->empty() )
{
delete pFilterHdlList;
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index a7eb3e212952..b0d40068f412 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -530,10 +530,9 @@ bool WMFWriter::WMFRecord_Escape_Unicode( const Point& rPoint, const OUString& r
aMemoryStream.WriteUInt32( nSkipActions );
WMFRecord_Escape( PRIVATE_ESCAPE_UNICODE, nStrmLen, static_cast<const sal_Int8*>(aMemoryStream.GetData()) );
- std::vector<tools::PolyPolygon>::iterator aIter( aPolyPolyVec.begin() );
- while ( aIter != aPolyPolyVec.end() )
+ for ( const auto& rPolyPoly : aPolyPolyVec )
{
- tools::PolyPolygon aPolyPoly( *aIter++ );
+ tools::PolyPolygon aPolyPoly( rPolyPoly );
aPolyPoly.Move( rPoint.X(), rPoint.Y() );
WMFRecord_PolyPolygon( aPolyPoly );
}
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index b58ce8503e14..9fd03b5dc683 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -907,9 +907,8 @@ std::unique_ptr<ImplDeviceFontSizeList> PhysicalFontCollection::GetDeviceFontSiz
std::set<int> rHeights;
pFontFamily->GetFontHeights( rHeights );
- std::set<int>::const_iterator it = rHeights.begin();
- for(; it != rHeights.begin(); ++it )
- pDeviceFontSizeList->Add( *it );
+ for( const auto& rHeight : rHeights )
+ pDeviceFontSizeList->Add( rHeight );
}
return pDeviceFontSizeList;
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 1f3634b38320..a945ee7cc7be 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -528,10 +528,9 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
fprintf(stderr, "Endless loop found in a compound glyph.\n");
fprintf(stderr, "%d -> ", index);
fprintf(stderr," [");
- for( std::vector< sal_uInt32 >::const_iterator it = glyphlist.begin();
- it != glyphlist.end(); ++it )
+ for( const auto& rGlyph : glyphlist )
{
- fprintf( stderr,"%d ", (int) *it );
+ fprintf( stderr,"%d ", (int) rGlyph );
}
fprintf(stderr,"]\n");
/**/
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index 371855861015..4b0c9cdc5725 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -394,31 +394,26 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
/* first determining if this BeginGroup is starting a GfxLink,
by searching for a EndGroup or a EndGroupGfxLink */
mbGroupIgnoreGDIMtfActions = false;
- std::deque< PDFExtOutDevDataSync >::iterator aBeg = mActions.begin();
- std::deque< PDFExtOutDevDataSync >::iterator aEnd = mActions.end();
- while ( aBeg != aEnd )
+ auto isStartingGfxLink = std::any_of(mActions.begin(), mActions.end(),
+ [](const PDFExtOutDevDataSync& rAction) { return rAction.eAct == PDFExtOutDevDataSync::EndGroupGfxLink; });
+ if ( isStartingGfxLink )
{
- if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
+ Graphic& rGraphic = mGraphics.front();
+ if ( rGraphic.IsGfxLink() && mParaRects.size() >= 2 )
{
- Graphic& rGraphic = mGraphics.front();
- if ( rGraphic.IsGfxLink() && mParaRects.size() >= 2 )
+ GfxLinkType eType = rGraphic.GetGfxLink().GetType();
+ if ( eType == GfxLinkType::NativeJpg )
{
- GfxLinkType eType = rGraphic.GetGfxLink().GetType();
- if ( eType == GfxLinkType::NativeJpg )
- {
- mbGroupIgnoreGDIMtfActions = rOutDevData.HasAdequateCompression(rGraphic, mParaRects[0], mParaRects[1]);
- if ( !mbGroupIgnoreGDIMtfActions )
- mCurrentGraphic = rGraphic;
- }
- else if ( eType == GfxLinkType::NativePng || eType == GfxLinkType::NativePdf )
- {
- if ( eType == GfxLinkType::NativePdf || rOutDevData.HasAdequateCompression(rGraphic, mParaRects[0], mParaRects[1]) )
- mCurrentGraphic = rGraphic;
- }
+ mbGroupIgnoreGDIMtfActions = rOutDevData.HasAdequateCompression(rGraphic, mParaRects[0], mParaRects[1]);
+ if ( !mbGroupIgnoreGDIMtfActions )
+ mCurrentGraphic = rGraphic;
+ }
+ else if ( eType == GfxLinkType::NativePng || eType == GfxLinkType::NativePdf )
+ {
+ if ( eType == GfxLinkType::NativePdf || rOutDevData.HasAdequateCompression(rGraphic, mParaRects[0], mParaRects[1]) )
+ mCurrentGraphic = rGraphic;
}
- break;
}
- ++aBeg;
}
}
break;
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index af54291d6c1f..0a25d2fd8120 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -10807,18 +10807,12 @@ sal_Int32 PDFWriterImpl::beginStructureElement( PDFWriter::StructElement eType,
// silently insert structure into document again if one properly exists
if( ! m_aStructure[ 0 ].m_aChildren.empty() )
{
- PDFWriter::StructElement childType = PDFWriter::NonStructElement;
- sal_Int32 nNewCurElement = 0;
const std::list< sal_Int32 >& rRootChildren = m_aStructure[0].m_aChildren;
- for( std::list< sal_Int32 >::const_iterator it = rRootChildren.begin();
- childType != PDFWriter::Document && it != rRootChildren.end(); ++it )
+ auto it = std::find_if(rRootChildren.begin(), rRootChildren.end(),
+ [&](sal_Int32 nElement) { return m_aStructure[ nElement ].m_eType == PDFWriter::Document; });
+ if( it != rRootChildren.end() )
{
- nNewCurElement = *it;
- childType = m_aStructure[ nNewCurElement ].m_eType;
- }
- if( childType == PDFWriter::Document )
- {
- m_nCurrentStructElement = nNewCurElement;
+ m_nCurrentStructElement = *it;
SAL_WARN( "vcl.pdfwriter", "Structure element inserted to StructTreeRoot that is not a document" );
}
else {
diff --git a/vcl/source/gdi/textlayout.cxx b/vcl/source/gdi/textlayout.cxx
index 6631afed284b..fab85035412c 100644
--- a/vcl/source/gdi/textlayout.cxx
+++ b/vcl/source/gdi/textlayout.cxx
@@ -290,12 +290,9 @@ namespace vcl
// convert the metric vector
if ( _pVector )
{
- for ( MetricVector::iterator charRect = _pVector->begin();
- charRect != _pVector->end();
- ++charRect
- )
+ for ( auto& rCharRect : *_pVector )
{
- *charRect = m_rTargetDevice.LogicToPixel( *charRect );
+ rCharRect = m_rTargetDevice.LogicToPixel( rCharRect );
}
}
diff --git a/vcl/source/window/accmgr.cxx b/vcl/source/window/accmgr.cxx
index 10e426b27f5c..f7a3ea0545a1 100644
--- a/vcl/source/window/accmgr.cxx
+++ b/vcl/source/window/accmgr.cxx
@@ -22,6 +22,8 @@
#include <vcl/accel.hxx>
#include <accmgr.hxx>
+#include <algorithm>
+
ImplAccelManager::~ImplAccelManager()
{
}
@@ -66,15 +68,9 @@ void ImplAccelManager::RemoveAccel( Accelerator const * pAccel )
}
// throw it away
- for ( auto it = mpAccelList->begin();
- it != mpAccelList->end();
- ++it
- ) {
- if ( *it == pAccel ) {
- mpAccelList->erase( it );
- break;
- }
- }
+ auto it = std::find(mpAccelList->begin(), mpAccelList->end(), pAccel);
+ if (it != mpAccelList->end())
+ mpAccelList->erase( it );
}
void ImplAccelManager::EndSequence()
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 03eee84e4a97..a57984c61925 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -160,11 +160,10 @@ namespace weld
if (pList)
{
// return unit's default string (ie, the first one )
- for (auto it = pList->begin(); it != pList->end(); ++it)
- {
- if (it->second == rUnit)
- return it->first;
- }
+ auto it = std::find_if(pList->begin(), pList->end(),
+ [&rUnit](std::pair<OUString, FieldUnit>& rItem) { return rItem.second == rUnit; });
+ if (it != pList->end())
+ return it->first;
}
return OUString();
@@ -3850,15 +3849,12 @@ void VclBuilder::set_response(const OString& sID, short nResponse)
void VclBuilder::delete_by_name(const OString& sID)
{
- for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
- aEnd = m_aChildren.end(); aI != aEnd; ++aI)
+ auto aI = std::find_if(m_aChildren.begin(), m_aChildren.end(),
+ [&sID](WinAndId& rItem) { return rItem.m_sID == sID; });
+ if (aI != m_aChildren.end())
{
- if (aI->m_sID == sID)
- {
- aI->m_pWindow.disposeAndClear();
- m_aChildren.erase(aI);
- break;
- }
+ aI->m_pWindow.disposeAndClear();
+ m_aChildren.erase(aI);
}
}
@@ -3870,15 +3866,10 @@ void VclBuilder::delete_by_window(vcl::Window *pWindow)
void VclBuilder::drop_ownership(const vcl::Window *pWindow)
{
- for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
- aEnd = m_aChildren.end(); aI != aEnd; ++aI)
- {
- if (aI->m_pWindow == pWindow)
- {
- m_aChildren.erase(aI);
- break;
- }
- }
+ auto aI = std::find_if(m_aChildren.begin(), m_aChildren.end(),
+ [&pWindow](WinAndId& rItem) { return rItem.m_pWindow == pWindow; });
+ if (aI != m_aChildren.end())
+ m_aChildren.erase(aI);
}
OString VclBuilder::get_by_window(const vcl::Window *pWindow) const
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index bc8da4fb219d..5b2ec3b225db 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -400,17 +400,13 @@ vcl::Window* Dialog::GetDefaultParent(WinBits nStyle)
{
ImplSVData* pSVData = ImplGetSVData();
auto& rExecuteDialogs = pSVData->maWinData.mpExecuteDialogs;
- for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
- {
- // only if visible and enabled
- if (pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(*it, true) &&
- (*it)->IsReallyVisible() &&
- (*it)->IsEnabled() && (*it)->IsInputEnabled() && !(*it)->IsInModalMode())
- {
- pParent = it->get();
- break;
- }
- }
+ auto it = std::find_if(rExecuteDialogs.rbegin(), rExecuteDialogs.rend(),
+ [&pParent](VclPtr<Dialog>& rDialogPtr) {
+ return pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(rDialogPtr, true) &&
+ rDialogPtr->IsReallyVisible() && rDialogPtr->IsEnabled() &&
+ rDialogPtr->IsInputEnabled() && !rDialogPtr->IsInModalMode(); });
+ if (it != rExecuteDialogs.rend())
+ pParent = it->get();
}
return pParent;
diff --git a/vcl/source/window/dlgctrl.cxx b/vcl/source/window/dlgctrl.cxx
index bda29cd62c1a..c46106f7665e 100644
--- a/vcl/source/window/dlgctrl.cxx
+++ b/vcl/source/window/dlgctrl.cxx
@@ -537,29 +537,18 @@ namespace
if (aStart != rGroup.end())
++aI;
- for (; aI != rGroup.end(); ++aI)
+ aI = std::find_if(aI, rGroup.end(), isSuitableDestination);
+ if (aI == rGroup.end())
{
- vcl::Window *pWindow = *aI;
-
- if (isSuitableDestination(pWindow))
- {
- pWindow->ImplControlFocus( GetFocusFlags::CURSOR | GetFocusFlags::Forward );
- return true;
- }
+ aI = std::find_if(rGroup.begin(), aStart, isSuitableDestination);
+ if (aI == aStart)
+ return false;
}
- for (aI = rGroup.begin(); aI != aStart; ++aI)
- {
- vcl::Window *pWindow = *aI;
-
- if (isSuitableDestination(pWindow))
- {
- pWindow->ImplControlFocus( GetFocusFlags::CURSOR | GetFocusFlags::Forward );
- return true;
- }
- }
+ vcl::Window *pWindow = *aI;
- return false;
+ pWindow->ImplControlFocus( GetFocusFlags::CURSOR | GetFocusFlags::Forward );
+ return true;
}
bool nextInGroup(RadioButton *pSourceWindow, bool bBackward)
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 2b4ac9c11b9c..d1a539acea09 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -549,9 +549,8 @@ Size VclButtonBox::addReqGroups(const VclButtonBox::Requisition &rReq) const
static long getMaxNonOutlier(const std::vector<long> &rG, long nAvgDimension)
{
long nMaxDimensionNonOutlier = 0;
- for (auto const& elem : rG)
+ for (auto const& nPrimaryChildDimension : rG)
{
- long nPrimaryChildDimension = elem;
if (nPrimaryChildDimension < nAvgDimension * 1.5)
{
nMaxDimensionNonOutlier = std::max(nPrimaryChildDimension,
@@ -569,13 +568,13 @@ static std::vector<long> setButtonSizes(const std::vector<long> &rG,
//set everything < 1.5 times the average to the same width, leave the
//outliers un-touched
std::vector<bool>::const_iterator aJ = rNonHomogeneous.begin();
- for (auto const& elem : rG)
+ auto nNonOutlierWidth = std::max(nMaxNonOutlier, nMinWidth);
+ for (auto const& nPrimaryChildDimension : rG)
{
- long nPrimaryChildDimension = elem;
bool bNonHomogeneous = *aJ;
if (!bNonHomogeneous && nPrimaryChildDimension < nAvgDimension * 1.5)
{
- aVec.push_back(std::max(nMaxNonOutlier, nMinWidth));
+ aVec.push_back(nNonOutlierWidth);
}
else
{
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index d1adaf25211c..30741a4ed620 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -400,14 +400,10 @@ void Menu::ImplCallEventListeners( VclEventId nEvent, sal_uInt16 nPos )
{
// Copy the list, because this can be destroyed when calling a Link...
std::list<Link<VclMenuEvent&,void>> aCopy( maEventListeners );
- std::list<Link<VclMenuEvent&,void>>::iterator aIter( aCopy.begin() );
- std::list<Link<VclMenuEvent&,void>>::const_iterator aEnd( aCopy.end() );
- while ( aIter != aEnd )
+ for ( const auto& rLink : aCopy )
{
- Link<VclMenuEvent&,void> &rLink = *aIter;
if( std::find(maEventListeners.begin(), maEventListeners.end(), rLink) != maEventListeners.end() )
rLink.Call( aEvent );
- ++aIter;
}
}
}
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 50726365af1e..be9eaeac97af 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -684,10 +684,9 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
// fill printer listbox
std::vector< OUString > rQueues( Printer::GetPrinterQueues() );
std::sort( rQueues.begin(), rQueues.end(), lcl_ListBoxCompare );
- for( std::vector< OUString >::const_iterator it = rQueues.begin();
- it != rQueues.end(); ++it )
+ for( const auto& rQueue : rQueues )
{
- maJobPage.mpPrinters->InsertEntry( *it );
+ maJobPage.mpPrinters->InsertEntry( rQueue );
}
// select current printer
if( maJobPage.mpPrinters->GetEntryPos( maPController->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND )
@@ -1303,24 +1302,23 @@ void PrintDialog::checkControlDependencies()
void PrintDialog::checkOptionalControlDependencies()
{
- for( auto it = maControlToPropertyMap.begin();
- it != maControlToPropertyMap.end(); ++it )
+ for( const auto& rEntry : maControlToPropertyMap )
{
- bool bShouldbeEnabled = maPController->isUIOptionEnabled( it->second );
+ bool bShouldbeEnabled = maPController->isUIOptionEnabled( rEntry.second );
- if( bShouldbeEnabled && dynamic_cast<RadioButton*>(it->first.get()) )
+ if( bShouldbeEnabled && dynamic_cast<RadioButton*>(rEntry.first.get()) )
{
- auto r_it = maControlToNumValMap.find( it->first );
+ auto r_it = maControlToNumValMap.find( rEntry.first );
if( r_it != maControlToNumValMap.end() )
{
- bShouldbeEnabled = maPController->isUIChoiceEnabled( it->second, r_it->second );
+ bShouldbeEnabled = maPController->isUIChoiceEnabled( rEntry.second, r_it->second );
}
}
- bool bIsEnabled = it->first->IsEnabled();
+ bool bIsEnabled = rEntry.first->IsEnabled();
// Enable does not do a change check first, so can be less cheap than expected
if( bShouldbeEnabled != bIsEnabled )
- it->first->Enable( bShouldbeEnabled );
+ rEntry.first->Enable( bShouldbeEnabled );
}
}
diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx
index d6825cf2b26c..1f382b824907 100644
--- a/vcl/source/window/taskpanelist.cxx
+++ b/vcl/source/window/taskpanelist.cxx
@@ -167,48 +167,45 @@ bool TaskPaneList::HandleKeyEvent(const KeyEvent& rKeyEvent)
bool bSplitterOnly = aKeyCode.IsMod1() && aKeyCode.IsShift();
// is the focus in the list ?
- auto p = mTaskPanes.begin();
- while( p != mTaskPanes.end() )
+ auto p = std::find_if(mTaskPanes.begin(), mTaskPanes.end(),
+ [](const VclPtr<vcl::Window>& rWinPtr) { return rWinPtr->HasChildPathFocus( true ); });
+ if( p != mTaskPanes.end() )
{
vcl::Window *pWin = p->get();
- if( pWin->HasChildPathFocus( true ) )
+
+ // Ctrl-F6 goes directly to the document
+ if( !pWin->IsDialog() && aKeyCode.IsMod1() && !aKeyCode.IsShift() )
{
- // Ctrl-F6 goes directly to the document
- if( !pWin->IsDialog() && aKeyCode.IsMod1() && !aKeyCode.IsShift() )
- {
- pWin->ImplGrabFocusToDocument( GetFocusFlags::F6 );
- return true;
- }
+ pWin->ImplGrabFocusToDocument( GetFocusFlags::F6 );
+ return true;
+ }
- // activate next task pane
- vcl::Window *pNextWin = nullptr;
+ // activate next task pane
+ vcl::Window *pNextWin = nullptr;
- if( bSplitterOnly )
- pNextWin = FindNextSplitter( *p );
- else
- pNextWin = FindNextFloat( *p, bForward );
-
- if( pNextWin != pWin )
- {
- ImplGetSVData()->maWinData.mbNoSaveFocus = true;
- ImplTaskPaneListGrabFocus( pNextWin, bForward );
- ImplGetSVData()->maWinData.mbNoSaveFocus = false;
- }
- else
- {
- // forward key if no splitter found
- if( bSplitterOnly )
- return false;
-
- // we did not find another taskpane, so
- // put focus back into document
- pWin->ImplGrabFocusToDocument( GetFocusFlags::F6 | (bForward ? GetFocusFlags::Forward : GetFocusFlags::Backward));
- }
+ if( bSplitterOnly )
+ pNextWin = FindNextSplitter( *p );
+ else
+ pNextWin = FindNextFloat( *p, bForward );
- return true;
+ if( pNextWin != pWin )
+ {
+ ImplGetSVData()->maWinData.mbNoSaveFocus = true;
+ ImplTaskPaneListGrabFocus( pNextWin, bForward );
+ ImplGetSVData()->maWinData.mbNoSaveFocus = false;
}
else
- ++p;
+ {
+ // forward key if no splitter found
+ if( bSplitterOnly )
+ return false;
+
+ // we did not find another taskpane, so
+ // put focus back into document
+ pWin->ImplGrabFocusToDocument( GetFocusFlags::F6 | (bForward ? GetFocusFlags::Forward : GetFocusFlags::Backward));
+ }
+
+ return true;
}
// the focus is not in the list: activate first float if F6 was pressed
@@ -233,29 +230,26 @@ vcl::Window* TaskPaneList::FindNextSplitter( vcl::Window *pWindow )
::std::stable_sort( mTaskPanes.begin(), mTaskPanes.end(), LTRSort() );
auto p = mTaskPanes.begin();
- while( p != mTaskPanes.end() )
+ if( pWindow )
+ p = std::find(mTaskPanes.begin(), mTaskPanes.end(), pWindow);
+
+ if( p != mTaskPanes.end() )
{
- if( !pWindow || *p == pWindow )
+ unsigned n = mTaskPanes.size();
+ while( --n )
{
- unsigned n = mTaskPanes.size();
- while( --n )
+ if( pWindow ) // increment before test
+ ++p;
+ if( p == mTaskPanes.end() )
+ p = mTaskPanes.begin();
+ if( (*p)->ImplIsSplitter() && (*p)->IsReallyVisible() && !(*p)->IsDialog() && (*p)->GetParent()->HasChildPathFocus() )
{
- if( pWindow ) // increment before test
- ++p;
- if( p == mTaskPanes.end() )
- p = mTaskPanes.begin();
- if( (*p)->ImplIsSplitter() && (*p)->IsReallyVisible() && !(*p)->IsDialog() && (*p)->GetParent()->HasChildPathFocus() )
- {
- pWindow = (*p).get();
- break;
- }
- if( !pWindow ) // increment after test, otherwise first element is skipped
- ++p;
+ pWindow = (*p).get();
+ break;
}
- break;
+ if( !pWindow ) // increment after test, otherwise first element is skipped
+ ++p;
}
- else
- ++p;
}
return pWindow;
@@ -270,30 +264,24 @@ vcl::Window* TaskPaneList::FindNextFloat( vcl::Window *pWindow, bool bForward )
::std::stable_sort( mTaskPanes.begin(), mTaskPanes.end(), LTRSortBackward() );
auto p = mTaskPanes.begin();
+ if( pWindow )
+ p = std::find(mTaskPanes.begin(), mTaskPanes.end(), pWindow);
+
while( p != mTaskPanes.end() )
{
- if( !pWindow || *p == pWindow )
+ if( pWindow ) // increment before test
+ ++p;
+ if( p == mTaskPanes.end() )
+ break; // do not wrap, send focus back to document at end of list
+ /* #i83908# do not use the menubar if it is native and invisible
+ */
+ if( (*p)->IsReallyVisible() && !(*p)->ImplIsSplitter() &&
+ ( (*p)->GetType() != WindowType::MENUBARWINDOW || static_cast<MenuBarWindow*>(p->get())->CanGetFocus() ) )
{
- while( p != mTaskPanes.end() )
- {
- if( pWindow ) // increment before test
- ++p;
- if( p == mTaskPanes.end() )
- break; // do not wrap, send focus back to document at end of list
- /* #i83908# do not use the menubar if it is native and invisible
- */
- if( (*p)->IsReallyVisible() && !(*p)->ImplIsSplitter() &&
- ( (*p)->GetType() != WindowType::MENUBARWINDOW || static_cast<MenuBarWindow*>(p->get())->CanGetFocus() ) )
- {
- pWindow = (*p).get();
- break;
- }
- if( !pWindow ) // increment after test, otherwise first element is skipped
- ++p;
- }
+ pWindow = (*p).get();
break;
}
- else
+ if( !pWindow ) // increment after test, otherwise first element is skipped
++p;
}
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 66563c6b9ee7..149aa0b99ef6 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1916,16 +1916,9 @@ void lcl_hideDoubleSeparators( ToolBox::ImplToolItems& rItems )
if ( !bLastSep )
{
// check if any visible items have to appear behind it
- ToolBox::ImplToolItems::iterator temp_it;
- for ( temp_it = it+1; temp_it != rItems.end(); ++temp_it )
- {
- if ( (temp_it->meType == ToolBoxItemType::BUTTON) &&
- temp_it->mbVisible )
- {
- it->mbVisible = true;
- break;
- }
- }
+ if (std::any_of(it + 1, rItems.end(), [](const ImplToolItem& rItem) {
+ return (rItem.meType == ToolBoxItemType::BUTTON) && rItem.mbVisible; }))
+ it->mbVisible = true;
}
bLastSep = true;
}
@@ -4889,30 +4882,20 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
if( bUp )
{
// select last valid non-clipped item
- ImplToolItems::iterator it = mpData->m_aItems.end();
ImplToolItem* pItem = nullptr;
- while( it != mpData->m_aItems.begin() )
- {
- --it;
- if ( ImplIsValidItem( &(*it), true ) )
- {
- pItem = &(*it);
- break;
- }
- }
+ auto it = std::find_if(mpData->m_aItems.rbegin(), mpData->m_aItems.rend(),
+ [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, true ); });
+ if( it != mpData->m_aItems.rend() )
+ pItem = &(*it);
+
InvalidateMenuButton();
ImplChangeHighlight( pItem );
}
else
{
// select first valid non-clipped item
- ImplToolItems::iterator it = mpData->m_aItems.begin();
- while( it != mpData->m_aItems.end() )
- {
- if ( ImplIsValidItem( &(*it), true ) )
- break;
- ++it;
- }
+ ImplToolItems::iterator it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, true ); });
if( it != mpData->m_aItems.end() )
{
InvalidateMenuButton();
@@ -4925,13 +4908,8 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
if( bUp )
{
// Select first valid item
- ImplToolItems::iterator it = mpData->m_aItems.begin();
- while( it != mpData->m_aItems.end() )
- {
- if ( ImplIsValidItem( &(*it), false ) )
- break;
- ++it;
- }
+ ImplToolItems::iterator it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, false ); });
// select the menu button if a clipped item would be selected
if( (it != mpData->m_aItems.end() && &(*it) == ImplGetFirstClippedItem()) && IsMenuEnabled() )
@@ -4955,17 +4933,12 @@ bool ToolBox::ImplChangeHighlightUpDn( bool bUp, bool bNoCycle )
}
else
{
- ImplToolItems::iterator it = mpData->m_aItems.end();
ImplToolItem* pItem = nullptr;
- while( it != mpData->m_aItems.begin() )
- {
- --it;
- if ( ImplIsValidItem( &(*it), false ) )
- {
- pItem = &(*it);
- break;
- }
- }
+ auto it = std::find_if(mpData->m_aItems.rbegin(), mpData->m_aItems.rend(),
+ [](const ImplToolItem& rItem) { return ImplIsValidItem( &rItem, false ); });
+ if( it != mpData->m_aItems.rend() )
+ pItem = &(*it);
+
ImplChangeHighlight( pItem );
}
return true;
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index c6ebf3916303..d03d96759d34 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -719,23 +719,13 @@ ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( sal_uInt16 nItemId ) cons
ToolBox::ImplToolItems::size_type ToolBox::GetItemPos( const Point& rPos ) const
{
// search the item position on the given point
- ImplToolItems::size_type nRet = ITEM_NOTFOUND;
- ImplToolItems::size_type nPos = 0;
- ImplToolItems::const_iterator it = mpData->m_aItems.begin();
- while( it != mpData->m_aItems.end() )
- {
- if ( it->maRect.IsInside( rPos ) )
- {
- // item found -> save position and break
- nRet = nPos;
- break;
- }
+ auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [&rPos](const ImplToolItem& rItem) { return rItem.maRect.IsInside( rPos ); });
- ++it;
- ++nPos;
- }
+ if( it != mpData->m_aItems.end() )
+ return std::distance(mpData->m_aItems.begin(), it);
- return nRet;
+ return ITEM_NOTFOUND;
}
sal_uInt16 ToolBox::GetItemId( ImplToolItems::size_type nPos ) const
@@ -746,20 +736,11 @@ sal_uInt16 ToolBox::GetItemId( ImplToolItems::size_type nPos ) const
sal_uInt16 ToolBox::GetItemId( const Point& rPos ) const
{
// find item that was clicked
- ImplToolItems::const_iterator it = mpData->m_aItems.begin();
- while( it != mpData->m_aItems.end() )
- {
- // is it this item?
- if ( it->maRect.IsInside( rPos ) )
- {
- if ( it->meType == ToolBoxItemType::BUTTON )
- return it->mnId;
- else
- return 0;
- }
+ auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [&rPos](const ImplToolItem& rItem) { return rItem.maRect.IsInside( rPos ); });
- ++it;
- }
+ if( (it != mpData->m_aItems.end()) && (it->meType == ToolBoxItemType::BUTTON) )
+ return it->mnId;
return 0;
}
@@ -781,11 +762,10 @@ sal_uInt16 ToolBox::GetItemId(const OUString &rCommand) const
if (!mpData)
return 0;
- for (ImplToolItems::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
- {
- if (it->maCommandStr == rCommand)
- return it->mnId;
- }
+ auto it = std::find_if(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [&rCommand](const ImplToolItem& rItem) { return rItem.maCommandStr == rCommand; });
+ if (it != mpData->m_aItems.end())
+ return it->mnId;
return 0;
}
@@ -1461,17 +1441,11 @@ void ToolBox::SetOutStyle( sal_uInt16 nNewStyle )
// disable key input if all items are disabled
void ToolBox::ImplUpdateInputEnable()
{
- for( ImplToolItems::const_iterator it = mpData->m_aItems.begin();
- it != mpData->m_aItems.end(); ++it )
- {
- if( it->mbEnabled )
- {
+ mpData->mbKeyInputDisabled = std::none_of(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [](const ImplToolItem& rItem) {
// at least one useful entry
- mpData->mbKeyInputDisabled = false;
- return;
- }
- }
- mpData->mbKeyInputDisabled = true;
+ return rItem.mbEnabled;
+ });
}
void ToolBox::ImplFillLayoutData()
@@ -1593,14 +1567,8 @@ bool ToolBox::ImplHasClippedItems()
{
// are any items currently clipped ?
ImplFormat();
- ImplToolItems::const_iterator it = mpData->m_aItems.begin();
- while ( it != mpData->m_aItems.end() )
- {
- if( it->IsClipped() )
- return true;
- ++it;
- }
- return false;
+ return std::any_of(mpData->m_aItems.begin(), mpData->m_aItems.end(),
+ [](const ImplToolItem& rItem) { return rItem.IsClipped(); });
}
namespace
@@ -1631,17 +1599,16 @@ void ToolBox::UpdateCustomMenu()
if ( !mpData->m_aItems.empty() )
{
// nStartPos will hold the number of clipped items appended from first loop
- for ( ImplToolItems::iterator it(mpData->m_aItems.begin());
- it != mpData->m_aItems.end(); ++it)
+ for ( const auto& rItem : mpData->m_aItems )
{
- if( it->IsClipped() )
+ if( rItem.IsClipped() )
{
- sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START;
- MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(it->mnBits);
- pMenu->InsertItem( id, it->maText, it->maImage, nMenuItemBits);
- pMenu->SetItemCommand( id, it->maCommandStr );
- pMenu->EnableItem( id, it->mbEnabled );
- pMenu->CheckItem ( id, it->meState == TRISTATE_TRUE );
+ sal_uInt16 id = rItem.mnId + TOOLBOX_MENUITEM_START;
+ MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(rItem.mnBits);
+ pMenu->InsertItem( id, rItem.maText, rItem.maImage, nMenuItemBits);
+ pMenu->SetItemCommand( id, rItem.maCommandStr );
+ pMenu->EnableItem( id, rItem.mbEnabled );
+ pMenu->CheckItem ( id, rItem.meState == TRISTATE_TRUE );
}
}
@@ -1649,17 +1616,16 @@ void ToolBox::UpdateCustomMenu()
pMenu->InsertSeparator();
// now append the items that are explicitly disabled
- for ( ImplToolItems::iterator it(mpData->m_aItems.begin());
- it != mpData->m_aItems.end(); ++it)
+ for ( const auto& rItem : mpData->m_aItems )
{
- if( it->IsItemHidden() )
+ if( rItem.IsItemHidden() )
{
- sal_uInt16 id = it->mnId + TOOLBOX_MENUITEM_START;
- MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(it->mnBits);
- pMenu->InsertItem( id, it->maText, it->maImage, nMenuItemBits );
- pMenu->SetItemCommand( id, it->maCommandStr );
- pMenu->EnableItem( id, it->mbEnabled );
- pMenu->CheckItem( id, it->meState == TRISTATE_TRUE );
+ sal_uInt16 id = rItem.mnId + TOOLBOX_MENUITEM_START;
+ MenuItemBits nMenuItemBits = ConvertBitsFromToolBoxToMenu(rItem.mnBits);
+ pMenu->InsertItem( id, rItem.maText, rItem.maImage, nMenuItemBits );
+ pMenu->SetItemCommand( id, rItem.maCommandStr );
+ pMenu->EnableItem( id, rItem.mbEnabled );
+ pMenu->CheckItem( id, rItem.meState == TRISTATE_TRUE );
}
}
diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx
index f7c0b6db6a8e..b77e542f7807 100644
--- a/vcl/unx/generic/dtrans/X11_selection.cxx
+++ b/vcl/unx/generic/dtrans/X11_selection.cxx
@@ -457,13 +457,10 @@ SelectionManager::~SelectionManager()
{
osl::MutexGuard aGuard( *osl::Mutex::getGlobalMutex() );
- std::unordered_map< OUString, SelectionManager* >::iterator it;
- for( it = getInstances().begin(); it != getInstances().end(); ++it )
- if( it->second == this )
- {
- getInstances().erase( it );
- break;
- }
+ auto it = std::find_if(getInstances().begin(), getInstances().end(),
+ [&](const std::pair< OUString, SelectionManager* >& rInstance) { return rInstance.second == this; });
+ if( it != getInstances().end() )
+ getInstances().erase( it );
}
if( m_aThread )
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index ca40710aa0bd..76598746bec6 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -560,9 +560,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int>& o
std::unique_ptr<PrintFont> xUpdate;
- auto second_font = aFonts.begin();
- ++second_font;
- if (second_font == aFonts.end()) // one font
+ if (aFonts.size() == 1) // one font
xUpdate = std::move(aFonts.front());
else // more than one font
{
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 40e1c5a8db3b..b7356eda56a5 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -129,10 +129,10 @@ void CairoFontsCache::CacheFont(void *pFont, const CairoFontsCache::CacheId &rId
void* CairoFontsCache::FindCachedFont(const CairoFontsCache::CacheId &rId)
{
- LRUFonts::iterator aEnd = maLRUFonts.end();
- for (LRUFonts::iterator aI = maLRUFonts.begin(); aI != aEnd; ++aI)
- if (aI->second == rId)
- return aI->first;
+ auto aI = std::find_if(maLRUFonts.begin(), maLRUFonts.end(),
+ [&rId](const LRUFonts::value_type& rFont) { return rFont.second == rId; });
+ if (aI != maLRUFonts.end())
+ return aI->first;
return nullptr;
}
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index a99dba3e77f2..8dfd446c4cd6 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -1077,14 +1077,11 @@ void ImplSalBitmapCache::ImplAdd( X11SalBitmap* pBmp )
void ImplSalBitmapCache::ImplRemove( X11SalBitmap const * pBmp )
{
- for( auto it = maBmpList.begin(); it != maBmpList.end(); ++it)
+ auto it = std::find(maBmpList.begin(), maBmpList.end(), pBmp);
+ if( it != maBmpList.end() )
{
- if( *it == pBmp )
- {
- (*it)->ImplRemovedFromCache();
- maBmpList.erase( it );
- break;
- }
+ (*it)->ImplRemovedFromCache();
+ maBmpList.erase( it );
}
}
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index 8b01494ddb44..105a350a27d6 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -1215,9 +1215,8 @@ void PPDParser::parse( ::std::vector< OString >& rLines )
}
// second pass: fill in defaults
- for( line = rLines.begin(); line != rLines.end(); ++line )
+ for( const auto& aLine : rLines )
{
- OString aLine(*line);
if (aLine.startsWith("*Default"))
{
SAL_INFO("vcl.unx.print", "Found a default: '" << aLine << "'");
@@ -1598,14 +1597,10 @@ void PPDKey::eraseValue( const OUString& rOption )
if( it == m_aValues.end() )
return;
- for( PPDKey::value_type::iterator vit = m_aOrderedValues.begin(); vit != m_aOrderedValues.end(); ++vit )
- {
- if( *vit == &(it->second ) )
- {
- m_aOrderedValues.erase( vit );
- break;
- }
- }
+ auto vit = std::find(m_aOrderedValues.begin(), m_aOrderedValues.end(), &(it->second ));
+ if( vit != m_aOrderedValues.end() )
+ m_aOrderedValues.erase( vit );
+
m_aValues.erase( it );
}
@@ -1649,10 +1644,12 @@ PPDContext& PPDContext::operator=( PPDContext&& rCopy )
const PPDKey* PPDContext::getModifiedKey( int n ) const
{
- hash_type::const_iterator it;
- for( it = m_aCurrentValues.begin(); it != m_aCurrentValues.end() && n--; ++it )
- ;
- return it != m_aCurrentValues.end() ? it->first : nullptr;
+ if( m_aCurrentValues.size() < static_cast<hash_type::size_type>(n) )
+ return nullptr;
+
+ hash_type::const_iterator it = m_aCurrentValues.begin();
+ std::advance(it, n);
+ return it->first;
}
void PPDContext::setParser( const PPDParser* pParser )
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx
index e97a7888a13f..30272c739029 100644
--- a/vcl/unx/generic/printer/printerinfomanager.cxx
+++ b/vcl/unx/generic/printer/printerinfomanager.cxx
@@ -712,30 +712,25 @@ static void lpgetSysQueueTokenHandler(
// find _all: line
OString aAllLine( "_all:" );
OString aAllAttr( "all=" );
- for( std::vector< OString >::const_iterator it = i_rLines.begin();
- it != i_rLines.end(); ++it )
+ auto it = std::find_if(i_rLines.begin(), i_rLines.end(),
+ [&aAllLine](const OString& rLine) { return rLine.indexOf( aAllLine, 0 ) == 0; });
+ if( it != i_rLines.end() )
{
- if( it->indexOf( aAllLine, 0 ) == 0 )
+ // now find the "all" attribute
+ ++it;
+ it = std::find_if(it, i_rLines.end(),
+ [&aAllAttr](const OString& rLine) { return WhitespaceToSpace( rLine ).startsWith( aAllAttr ); });
+ if( it != i_rLines.end() )
{
- // now find the "all" attribute
- ++it;
- while( it != i_rLines.end() )
+ // insert the comma separated entries into the set of printers to use
+ OString aClean( WhitespaceToSpace( *it ) );
+ sal_Int32 nPos = aAllAttr.getLength();
+ while( nPos != -1 )
{
- OString aClean( WhitespaceToSpace( *it ) );
- if( aClean.startsWith( aAllAttr ) )
- {
- // insert the comma separated entries into the set of printers to use
- sal_Int32 nPos = aAllAttr.getLength();
- while( nPos != -1 )
- {
- OString aTok( aClean.getToken( 0, ',', nPos ) );
- if( !aTok.isEmpty() )
- aOnlySet.insert( OStringToOUString( aTok, aEncoding ) );
- }
- break;
- }
+ OString aTok( aClean.getToken( 0, ',', nPos ) );
+ if( !aTok.isEmpty() )
+ aOnlySet.insert( OStringToOUString( aTok, aEncoding ) );
}
- break;
}
}
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 195093551d81..760744b0a80b 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -3396,19 +3396,14 @@ bool GtkSalFrame::IMHandler::handleKeyEvent( GdkEventKey* pEvent )
m_bPreeditJustChanged = false;
- std::list<PreviousKeyPress>::iterator iter = m_aPrevKeyPresses.begin();
- std::list<PreviousKeyPress>::iterator iter_end = m_aPrevKeyPresses.end();
- while (iter != iter_end)
+ auto iter = std::find(m_aPrevKeyPresses.begin(), m_aPrevKeyPresses.end(), pEvent);
+ // If we found a corresponding previous key press event, swallow the release
+ // and remove the earlier key press from our list
+ if (iter != m_aPrevKeyPresses.end())
{
- // If we found a corresponding previous key press event, swallow the release
- // and remove the earlier key press from our list
- if (*iter == pEvent)
- {
- m_aPrevKeyPresses.erase(iter);
- m_nPrevKeyPresses--;
- return true;
- }
- ++iter;
+ m_aPrevKeyPresses.erase(iter);
+ m_nPrevKeyPresses--;
+ return true;
}
if( bResult )
diff --git a/vcl/unx/gtk/salprn-gtk.cxx b/vcl/unx/gtk/salprn-gtk.cxx
index ddc9ba3ca234..235d3ccb005b 100644
--- a/vcl/unx/gtk/salprn-gtk.cxx
+++ b/vcl/unx/gtk/salprn-gtk.cxx
@@ -756,10 +756,9 @@ GtkPrintDialog::impl_initPrintContent(uno::Sequence<sal_Bool> const& i_rDisabled
void
GtkPrintDialog::impl_checkOptionalControlDependencies()
{
- for (std::map<GtkWidget*, OUString>::iterator it = m_aControlToPropertyMap.begin();
- it != m_aControlToPropertyMap.end(); ++it)
+ for (auto& rEntry : m_aControlToPropertyMap)
{
- gtk_widget_set_sensitive(it->first, m_rController.isUIOptionEnabled(it->second));
+ gtk_widget_set_sensitive(rEntry.first, m_rController.isUIOptionEnabled(rEntry.second));
}
}
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 09725122c13f..acdb3f9e0d9a 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -3937,19 +3937,14 @@ bool GtkSalFrame::IMHandler::handleKeyEvent( GdkEventKey* pEvent )
m_bPreeditJustChanged = false;
- std::list<PreviousKeyPress>::iterator iter = m_aPrevKeyPresses.begin();
- std::list<PreviousKeyPress>::iterator iter_end = m_aPrevKeyPresses.end();
- while (iter != iter_end)
+ auto iter = std::find(m_aPrevKeyPresses.begin(), m_aPrevKeyPresses.end(), pEvent);
+ // If we found a corresponding previous key press event, swallow the release
+ // and remove the earlier key press from our list
+ if (iter != m_aPrevKeyPresses.end())
{
- // If we found a corresponding previous key press event, swallow the release
- // and remove the earlier key press from our list
- if (*iter == pEvent)
- {
- m_aPrevKeyPresses.erase(iter);
- m_nPrevKeyPresses--;
- return true;
- }
- ++iter;
+ m_aPrevKeyPresses.erase(iter);
+ m_nPrevKeyPresses--;
+ return true;
}
if( bResult )
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 7db333117402..e890a09a8426 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -199,12 +199,8 @@ void SalData::initNWF()
// ********************************************************
void SalData::deInitNWF()
{
- ThemeMap::iterator iter = aThemeMap.begin();
- while( iter != aThemeMap.end() )
- {
- vsAPI.CloseThemeData(iter->second);
- ++iter;
- }
+ for( auto& rEntry : aThemeMap )
+ vsAPI.CloseThemeData(rEntry.second);
aThemeMap.clear();
}
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 9b9b088e9b94..6b2db288d87d 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -1504,14 +1504,9 @@ public:
void addInvalidate(vcl::Window *pWindow) { maInvalidates.emplace_back(pWindow); };
void removeInvalidate(vcl::Window *pWindow)
{
- for (auto aIt = maInvalidates.begin(); aIt != maInvalidates.end(); ++aIt)
- {
- if (*aIt == pWindow)
- {
- maInvalidates.erase(aIt);
- return;
- }
- }
+ auto aIt = std::find(maInvalidates.begin(), maInvalidates.end(), pWindow);
+ if (aIt != maInvalidates.end())
+ maInvalidates.erase(aIt);
}
void Invalidate()
{