[Libreoffice-commits] core.git: canvas/source

Daniel Robertson danlrobertson89 at gmail.com
Fri Jul 31 10:04:07 PDT 2015


 canvas/source/factory/cf_service.cxx |   84 ++++++++++++++---------------------
 1 file changed, 35 insertions(+), 49 deletions(-)

New commits:
commit 1a5e176e626d70d19abe4ad6e3b5c8d54a7badd7
Author: Daniel Robertson <danlrobertson89 at gmail.com>
Date:   Wed Jul 29 23:07:45 2015 -0400

    tdf#92459 Replace select1st for lambda expressions
    
    Replace all instances of select1st with lambda functions in
    canvas/source/factory/cf_service.cxx.
    
    Change-Id: I935282817fdf6496bd03752b8adb89e827ff28c5
    Reviewed-on: https://gerrit.libreoffice.org/17409
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Ostrovsky <david at ostrovsky.org>

diff --git a/canvas/source/factory/cf_service.cxx b/canvas/source/factory/cf_service.cxx
index 5177989..301001c 100644
--- a/canvas/source/factory/cf_service.cxx
+++ b/canvas/source/factory/cf_service.cxx
@@ -35,10 +35,8 @@
 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 
-#include <boost/bind.hpp>
 #include <vector>
 #include <utility>
-#include <o3tl/compat_functional.hxx>
 #include <algorithm>
 
 
@@ -54,10 +52,8 @@ class CanvasFactory
                                       lang::XMultiComponentFactory,
                                       lang::XMultiServiceFactory >
 {
-    typedef std::pair<OUString,Sequence<OUString> > AvailPair;
-    typedef std::pair<OUString,OUString>            CachePair;
-    typedef std::vector< AvailPair >                AvailVector;
-    typedef std::vector< CachePair >                CacheVector;
+    typedef std::vector<std::pair<OUString, Sequence<OUString> > > AvailVector;
+    typedef std::vector<std::pair<OUString, OUString> >            CacheVector;
 
 
     mutable ::osl::Mutex              m_mutex;
@@ -242,7 +238,9 @@ Sequence<OUString> CanvasFactory::getAvailableServiceNames()
     std::transform(m_aAvailableImplementations.begin(),
                    m_aAvailableImplementations.end(),
                    aServiceNames.getArray(),
-                   o3tl::select1st<AvailPair>());
+                   [](std::pair<OUString, Sequence<OUString> > const& ap)
+                   { return ap.first; }
+            );
     return aServiceNames;
 }
 
@@ -325,14 +323,12 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
     // try to reuse last working implementation for given service name
     const CacheVector::iterator aEnd(m_aCachedImplementations.end());
     CacheVector::iterator aMatch;
-    if( (aMatch=std::find_if(m_aCachedImplementations.begin(),
-                             aEnd,
-                             boost::bind(&OUString::equals,
-                                         boost::cref(serviceName),
-                                         boost::bind(
-                                             o3tl::select1st<CachePair>(),
-                                             _1)))) != aEnd )
-    {
+    if( (aMatch=std::find_if(
+                    m_aCachedImplementations.begin(),
+                    aEnd,
+                    [&serviceName](std::pair<OUString, OUString> const& cp)
+                    { return serviceName.equals(cp.first); }
+                    )) != aEnd) {
         Reference<XInterface> xCanvas( use( aMatch->second, args, xContext ) );
         if(xCanvas.is())
             return xCanvas;
@@ -341,40 +337,34 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
     // lookup in available service list
     const AvailVector::const_iterator aAvailEnd(m_aAvailableImplementations.end());
     AvailVector::const_iterator aAvailImplsMatch;
-    if( (aAvailImplsMatch=std::find_if(m_aAvailableImplementations.begin(),
-                                       aAvailEnd,
-                                       boost::bind(&OUString::equals,
-                                                   boost::cref(serviceName),
-                                                   boost::bind(
-                                                       o3tl::select1st<AvailPair>(),
-                                                       _1)))) == aAvailEnd )
-    {
+    if( (aAvailImplsMatch=std::find_if(
+                    m_aAvailableImplementations.begin(),
+                    aAvailEnd,
+                    [&serviceName](std::pair<OUString, Sequence<OUString> > const& ap)
+                    { return serviceName.equals(ap.first); }
+                    )) == aAvailEnd ) {
         return Reference<XInterface>();
     }
 
     const AvailVector::const_iterator aAAEnd(m_aAAImplementations.end());
     AvailVector::const_iterator aAAImplsMatch;
-    if( (aAAImplsMatch=std::find_if(m_aAAImplementations.begin(),
-                                    aAAEnd,
-                                    boost::bind(&OUString::equals,
-                                                boost::cref(serviceName),
-                                                boost::bind(
-                                                    o3tl::select1st<AvailPair>(),
-                                                    _1)))) == aAAEnd )
-    {
+    if( (aAAImplsMatch=std::find_if(
+                    m_aAAImplementations.begin(),
+                    aAAEnd,
+                    [&serviceName](std::pair<OUString, Sequence<OUString> > const& ap)
+                    { return serviceName.equals(ap.first); }
+                    )) == aAAEnd) {
         return Reference<XInterface>();
     }
 
     const AvailVector::const_iterator aAccelEnd(m_aAcceleratedImplementations.end());
     AvailVector::const_iterator aAccelImplsMatch;
-    if( (aAccelImplsMatch=std::find_if(m_aAcceleratedImplementations.begin(),
-                                       aAccelEnd,
-                                       boost::bind(&OUString::equals,
-                                                   boost::cref(serviceName),
-                                                   boost::bind(
-                                                       o3tl::select1st<AvailPair>(),
-                                                       _1)))) == aAccelEnd )
-    {
+    if( (aAccelImplsMatch=std::find_if(
+                    m_aAcceleratedImplementations.begin(),
+                    aAccelEnd,
+                    [&serviceName](std::pair<OUString, Sequence<OUString> > const& ap)
+                    { return serviceName.equals(ap.first); }
+                    )) == aAccelEnd ) {
         return Reference<XInterface>();
     }
 
@@ -403,22 +393,18 @@ Reference<XInterface> CanvasFactory::lookupAndUse(
         const bool bIsAcceleratedImpl(
             std::any_of(pFirstAccelImpl,
                          pEndAccelImpl,
-                         boost::bind(&OUString::equals,
-                                     boost::cref(aCurrName),
-                                     boost::bind(
-                                         &OUString::trim,
-                                         _1))) );
+                         [&aCurrName](OUString const& src)
+                         { return aCurrName.equals(src.trim()); }
+                ));
 
         // check whether given canvas service is listed in the
         // sequence of "antialiasing canvas implementations"
         const bool bIsAAImpl(
             std::any_of(pFirstAAImpl,
                          pEndAAImpl,
-                         boost::bind(&OUString::equals,
-                                     boost::cref(aCurrName),
-                                     boost::bind(
-                                         &OUString::trim,
-                                         _1))) );
+                         [&aCurrName](OUString const& src)
+                         { return aCurrName.equals(src.trim()); }
+                ));
 
         // try to instantiate canvas *only* if either accel and AA
         // property match preference, *or*, if there's a mismatch, only


More information about the Libreoffice-commits mailing list