[Libreoffice-commits] core.git: basctl/source basegfx/source basic/source binaryurp/source canvas/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 15 12:01:30 UTC 2020


 basctl/source/basicide/baside2b.cxx           |   18 ++++++------------
 basctl/source/dlged/dlgedclip.cxx             |    4 ++--
 basegfx/source/tools/canvastools.cxx          |    8 ++++----
 basic/source/classes/propacc.cxx              |    5 ++---
 basic/source/classes/sbunoobj.cxx             |    8 ++++----
 basic/source/uno/dlgcont.cxx                  |    8 ++++----
 binaryurp/source/bridge.cxx                   |    6 +++---
 canvas/source/directx/dx_impltools.cxx        |    9 ++++-----
 canvas/source/tools/canvastools.cxx           |    6 +++---
 canvas/source/tools/parametricpolypolygon.cxx |    4 ++--
 10 files changed, 34 insertions(+), 42 deletions(-)

New commits:
commit 898cbb22f07a2c1487700326f134fe54e7a13f4d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri May 15 09:56:35 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 15 14:00:48 2020 +0200

    use for-range on Sequence in basctl..canvas
    
    Change-Id: Idad3d8fbe785c7b1b8b287a3227372adb2757de8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94260
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index a722b802a55c..2d500c4d2ca4 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2835,13 +2835,10 @@ std::vector< OUString > UnoTypeCodeCompletetor::GetXIdlClassMethods() const
     std::vector< OUString > aRetVect;
     if( bCanComplete && ( xClass != nullptr ) )
     {
-        Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
-        if( aMethods.hasElements() )
+        const Sequence< Reference< reflection::XIdlMethod > > aMethods = xClass->getMethods();
+        for(Reference< reflection::XIdlMethod > const & rMethod : aMethods)
         {
-            for(sal_Int32 l = 0; l < aMethods.getLength(); ++l)
-            {
-                aRetVect.push_back( aMethods[l]->getName() );
-            }
+            aRetVect.push_back( rMethod->getName() );
         }
     }
     return aRetVect;//this is empty when cannot code complete
@@ -2852,13 +2849,10 @@ std::vector< OUString > UnoTypeCodeCompletetor::GetXIdlClassFields() const
     std::vector< OUString > aRetVect;
     if( bCanComplete && ( xClass != nullptr ) )
     {
-        Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields();
-        if( aFields.hasElements() )
+        const Sequence< Reference< reflection::XIdlField > > aFields = xClass->getFields();
+        for(Reference< reflection::XIdlField > const & rxField : aFields)
         {
-            for(sal_Int32 l = 0; l < aFields.getLength(); ++l)
-            {
-                aRetVect.push_back( aFields[l]->getName() );
-            }
+            aRetVect.push_back( rxField->getName() );
         }
     }
     return aRetVect;//this is empty when cannot code complete
diff --git a/basctl/source/dlged/dlgedclip.cxx b/basctl/source/dlged/dlgedclip.cxx
index bb9787e4f5e6..931f10afe507 100644
--- a/basctl/source/dlged/dlgedclip.cxx
+++ b/basctl/source/dlged/dlgedclip.cxx
@@ -90,8 +90,8 @@ sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor
 {
     const SolarMutexGuard aGuard;
 
-    for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
-        if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
+    for ( auto const & i : std::as_const(m_SeqFlavors) )
+        if ( compareDataFlavors( i, rFlavor ) )
             return true;
     return false;
 }
diff --git a/basegfx/source/tools/canvastools.cxx b/basegfx/source/tools/canvastools.cxx
index 3ef52a85e197..67bba41a933f 100644
--- a/basegfx/source/tools/canvastools.cxx
+++ b/basegfx/source/tools/canvastools.cxx
@@ -196,9 +196,9 @@ namespace basegfx::unotools
         {
             ::basegfx::B2DPolyPolygon aRes;
 
-            for( sal_Int32 nCurrPoly=0; nCurrPoly<points.getLength(); ++nCurrPoly )
+            for( const auto & p : points )
             {
-                aRes.append( polygonFromPoint2DSequence( points[nCurrPoly] ) );
+                aRes.append( polygonFromPoint2DSequence( p ) );
             }
 
             return aRes;
@@ -240,9 +240,9 @@ namespace basegfx::unotools
         {
             ::basegfx::B2DPolyPolygon aRes;
 
-            for( sal_Int32 nCurrPoly=0; nCurrPoly<curves.getLength(); ++nCurrPoly )
+            for( const auto & c : curves )
             {
-                aRes.append( polygonFromBezier2DSequence( curves[nCurrPoly] ) );
+                aRes.append( polygonFromBezier2DSequence( c ) );
             }
 
             return aRes;
diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx
index 1ec508567197..45d13ffbbb1d 100644
--- a/basic/source/classes/propacc.cxx
+++ b/basic/source/classes/propacc.cxx
@@ -143,10 +143,9 @@ void SbPropertyValues::setPropertyValues(const Sequence< PropertyValue >& rPrope
     if (!m_aPropVals.empty())
         throw IllegalArgumentException();
 
-    const PropertyValue *pPropVals = rPropertyValues.getConstArray();
-    for (sal_Int32 n = 0; n < rPropertyValues.getLength(); ++n)
+    for (const PropertyValue& i : rPropertyValues)
     {
-        m_aPropVals.push_back(pPropVals[n]);
+        m_aPropVals.push_back(i);
     }
 }
 
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 1da0bf1b0314..15e8f6b91154 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -3258,18 +3258,18 @@ void VBAConstantHelper::init()
                 sLeafName = sFullName.copy( indexLastDot + 1);
             }
             aConstCache.push_back( sLeafName ); // assume constant group names are unique
-            Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
-            for (sal_Int32 i = 0; i != aConsts.getLength(); ++i)
+            const Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
+            for (const auto& ctd : aConsts)
             {
                 // store constant member name
-                sFullName = aConsts[i]->getName();
+                sFullName = ctd->getName();
                 indexLastDot = sFullName.lastIndexOf('.');
                 sLeafName = sFullName;
                 if ( indexLastDot > -1 )
                 {
                     sLeafName = sFullName.copy( indexLastDot + 1);
                 }
-                aConstHash[ sLeafName.toAsciiLowerCase() ] = aConsts[i]->getConstantValue();
+                aConstHash[ sLeafName.toAsciiLowerCase() ] = ctd->getConstantValue();
             }
         }
     }
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx
index c07fa682c909..eee4e8300339 100644
--- a/basic/source/uno/dlgcont.cxx
+++ b/basic/source/uno/dlgcont.cxx
@@ -213,12 +213,12 @@ void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< e
     // we need to export out any embedded image object(s)
     // associated with any Dialogs. First, we need to actually gather any such urls
     // for each dialog in this container
-    Sequence< OUString > sLibraries = getElementNames();
-    for ( sal_Int32 i=0; i < sLibraries.getLength(); ++i )
+    const Sequence< OUString > sLibraries = getElementNames();
+    for ( const OUString& rName : sLibraries )
     {
-        loadLibrary( sLibraries[ i ] );
+        loadLibrary( rName );
         Reference< XNameContainer > xLib;
-        getByName( sLibraries[ i ] ) >>= xLib;
+        getByName( rName ) >>= xLib;
         if ( xLib.is() )
         {
             Sequence< OUString > sDialogs = xLib->getElementNames();
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 5664558f55cd..1be59b933a70 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -769,8 +769,8 @@ void Bridge::handleCommitChangeRequest(
     css::uno::Sequence< css::bridge::ProtocolProperty > s;
     [[maybe_unused]] bool ok = (mapBinaryToCppAny(inArguments[0]) >>= s);
     assert(ok);
-    for (sal_Int32 i = 0; i != s.getLength(); ++i) {
-        if (s[i].Name == "CurrentContext") {
+    for (const auto & pp : std::as_const(s)) {
+        if (pp.Name == "CurrentContext") {
             bCcMode = true;
         } else {
             bCcMode = false;
@@ -779,7 +779,7 @@ void Bridge::handleCommitChangeRequest(
                 css::uno::Any(
                     css::bridge::InvalidProtocolChangeException(
                         "InvalidProtocolChangeException",
-                        css::uno::Reference< css::uno::XInterface >(), s[i],
+                        css::uno::Reference< css::uno::XInterface >(), pp,
                         1)));
             break;
         }
diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx
index 18113ee34394..21778b4843fb 100644
--- a/canvas/source/directx/dx_impltools.cxx
+++ b/canvas/source/directx/dx_impltools.cxx
@@ -408,10 +408,9 @@ namespace dxcanvas
             GraphicsPathSharedPtr pRes = std::make_shared<Gdiplus::GraphicsPath>();
             std::vector< Gdiplus::PointF > aPoints;
 
-            sal_Int32 nCurrPoly;
-            for( nCurrPoly=0; nCurrPoly<points.getLength(); ++nCurrPoly )
+            for( uno::Sequence< geometry::RealPoint2D > const & seqPoints : points )
             {
-                const sal_Int32 nCurrSize( points[nCurrPoly].getLength() );
+                const sal_Int32 nCurrSize( seqPoints.getLength() );
                 if( nCurrSize )
                 {
                     aPoints.resize( nCurrSize );
@@ -419,8 +418,8 @@ namespace dxcanvas
                     // TODO(F1): Closed/open polygons
 
                     // convert from RealPoint2D array to Gdiplus::PointF array
-                    std::transform( points[nCurrPoly].getConstArray(),
-                                      points[nCurrPoly].getConstArray()+nCurrSize,
+                    std::transform( seqPoints.getConstArray(),
+                                      seqPoints.getConstArray()+nCurrSize,
                                       aPoints.begin(),
                                       implGdiPlusPointFromRealPoint2D );
 
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index 2ca1b5081724..53ab7e71f0c5 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -1314,10 +1314,10 @@ namespace canvas::tools
         void extractExtraFontProperties(const uno::Sequence<beans::PropertyValue>& rExtraFontProperties,
                         sal_uInt32 &rEmphasisMark)
         {
-            for(sal_Int32 nIdx = 0; nIdx < rExtraFontProperties.getLength(); ++nIdx)
+            for(const beans::PropertyValue& rPropVal : rExtraFontProperties)
             {
-                if (rExtraFontProperties[nIdx].Name == "EmphasisMark")
-                    rExtraFontProperties[nIdx].Value >>= rEmphasisMark;
+                if (rPropVal.Name == "EmphasisMark")
+                    rPropVal.Value >>= rEmphasisMark;
             }
         }
 
diff --git a/canvas/source/tools/parametricpolypolygon.cxx b/canvas/source/tools/parametricpolypolygon.cxx
index 5bbd50576f2e..a0a9a7880219 100644
--- a/canvas/source/tools/parametricpolypolygon.cxx
+++ b/canvas/source/tools/parametricpolypolygon.cxx
@@ -58,10 +58,10 @@ namespace canvas
         colorStops[1] = 1;
 
         // extract args
-        for( sal_Int32 i=0; i<rArgs.getLength(); ++i )
+        for( const uno::Any& rArg : rArgs )
         {
             beans::PropertyValue aProp;
-            if( rArgs[i] >>= aProp )
+            if( rArg >>= aProp )
             {
                 if ( aProp.Name == "Colors" )
                 {


More information about the Libreoffice-commits mailing list