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

Julien Nabet serval2412 at yahoo.fr
Sat Mar 17 07:23:55 UTC 2018


 forms/source/component/DatabaseForm.cxx   |   13 +++++--------
 forms/source/component/Grid.cxx           |   10 +++++-----
 forms/source/component/ListBox.cxx        |   20 ++++++++++----------
 forms/source/misc/InterfaceContainer.cxx  |   17 ++++++++---------
 forms/source/richtext/richtextcontrol.cxx |   16 +++++-----------
 forms/source/richtext/richtextengine.cxx  |    7 ++-----
 6 files changed, 35 insertions(+), 48 deletions(-)

New commits:
commit 070dbae6b4dc497d6ae898e60203d25b0e608d73
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Fri Mar 16 23:17:38 2018 +0100

    Use for-range loops in forms
    
    Change-Id: I23f63f2a98ce64513f5cb4b06e373b5ec9509d62
    Reviewed-on: https://gerrit.libreoffice.org/51445
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 933a8fbff241..79047a5ac013 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -482,15 +482,12 @@ Sequence<sal_Int8> ODatabaseForm::GetDataMultiPartEncoded(const Reference<XContr
 
 
     // Aggregate Liste to OUString
-    for (   HtmlSuccessfulObjList::iterator pSuccObj = aSuccObjList.begin();
-            pSuccObj < aSuccObjList.end();
-            ++pSuccObj
-        )
+    for (auto const& succObj : aSuccObjList)
     {
-        if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_TEXT )
-            InsertTextPart( aParent, pSuccObj->aName, pSuccObj->aValue );
-        else if( pSuccObj->nRepresentation == SUCCESSFUL_REPRESENT_FILE )
-            InsertFilePart( aParent, pSuccObj->aName, pSuccObj->aValue );
+        if( succObj.nRepresentation == SUCCESSFUL_REPRESENT_TEXT )
+            InsertTextPart( aParent, succObj.aName, succObj.aValue );
+        else if( succObj.nRepresentation == SUCCESSFUL_REPRESENT_FILE )
+            InsertFilePart( aParent, succObj.aName, succObj.aValue );
     }
 
 
diff --git a/forms/source/component/Grid.cxx b/forms/source/component/Grid.cxx
index 41aef4c83fe6..ca4f6c45697c 100644
--- a/forms/source/component/Grid.cxx
+++ b/forms/source/component/Grid.cxx
@@ -137,12 +137,11 @@ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContain
     try
     {
         Reference< XCloneable > xColCloneable;
-        const OInterfaceArray::const_iterator pColumnStart = _pOriginalContainer->m_aItems.begin();
-        const OInterfaceArray::const_iterator pColumnEnd = _pOriginalContainer->m_aItems.end();
-        for ( OInterfaceArray::const_iterator pColumn = pColumnStart; pColumn != pColumnEnd; ++pColumn )
+        sal_Int32 nIndex = 0;
+        for (auto const& column : _pOriginalContainer->m_aItems)
         {
             // ask the col for a factory for the clone
-            xColCloneable.set(*pColumn, css::uno::UNO_QUERY);
+            xColCloneable.set(column, css::uno::UNO_QUERY);
             DBG_ASSERT( xColCloneable.is(), "OGridControlModel::cloneColumns: column is not cloneable!" );
             if ( xColCloneable.is() )
             {
@@ -152,9 +151,10 @@ void OGridControlModel::cloneColumns( const OGridControlModel* _pOriginalContain
                 if ( xColClone.is() )
                 {
                     // insert this clone into our own container
-                    insertByIndex( pColumn - pColumnStart, xColClone->queryInterface( m_aElementType ) );
+                    insertByIndex( nIndex, xColClone->queryInterface( m_aElementType ) );
                 }
             }
+            ++nIndex;
         }
     }
     catch( const Exception& )
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index 93b2fd63fc46..0df243d68b41 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -1072,23 +1072,24 @@ namespace frm
         assert(s_aEmptyValue.isNull());
         m_nNULLPos = -1;
         m_aConvertedBoundValues.resize(m_aBoundValues.size());
-        ValueList::const_iterator src = m_aBoundValues.begin();
-        const ValueList::const_iterator end = m_aBoundValues.end();
         ValueList::iterator dst = m_aConvertedBoundValues.begin();
-        for (; src != end; ++src, ++dst )
+        sal_Int16 nPos = 0;
+        for (auto const& src : m_aBoundValues)
         {
             if(m_nNULLPos == -1 &&
                !isRequired()    &&
-               (*src == s_aEmptyStringValue || *src == s_aEmptyValue || src->isNull()) )
+               (src == s_aEmptyStringValue || src == s_aEmptyValue || src.isNull()) )
             {
-                m_nNULLPos = src - m_aBoundValues.begin();
+                m_nNULLPos = nPos;
                 dst->setNull();
             }
             else
             {
-                *dst = *src;
+                *dst = src;
             }
             dst->setTypeKind(nFieldType);
+            ++dst;
+            ++nPos;
         }
         m_nConvertedBoundValuesType = nFieldType;
         OSL_ENSURE(dst == m_aConvertedBoundValues.end(), "OListBoxModel::convertBoundValues expected to have overwritten all of m_aConvertedBoundValues, but did not.");
@@ -1118,12 +1119,11 @@ namespace frm
         const std::vector< OUString >& aStringItems( getStringItemList() );
         ValueList aValues( aStringItems.size() );
         ValueList::iterator dst = aValues.begin();
-        std::vector< OUString >::const_iterator src(aStringItems.begin());
-        std::vector< OUString >::const_iterator const end = aStringItems.end();
-        for (; src != end; ++src, ++dst )
+        for (auto const& src : aStringItems)
         {
-            *dst = *src;
+            *dst = src;
             dst->setTypeKind(nFieldType);
+            ++dst;
         }
         m_nConvertedBoundValuesType = nFieldType;
         OSL_ENSURE(dst == aValues.end(), "OListBoxModel::impl_getValues expected to have set all of aValues, but did not.");
diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx
index 402e433363b7..22f0de5e6279 100644
--- a/forms/source/misc/InterfaceContainer.cxx
+++ b/forms/source/misc/InterfaceContainer.cxx
@@ -292,12 +292,12 @@ namespace
         if ( !_rxManager.is() )
             return;
 
-        ::std::vector< Sequence< ScriptEventDescriptor > >::const_iterator aLoop = _rSave.begin();
-        ::std::vector< Sequence< ScriptEventDescriptor > >::const_iterator aEnd = _rSave.end();
-        for ( sal_Int32 i=0; aLoop != aEnd; ++aLoop, ++i )
+        sal_Int32 i=0;
+        for (auto const& elem : _rSave)
         {
             _rxManager->revokeScriptEvents( i );
-            _rxManager->registerScriptEvents( i, *aLoop );
+            _rxManager->registerScriptEvents(i, elem);
+            ++i;
         }
     }
 }
@@ -427,13 +427,12 @@ void SAL_CALL OInterfaceContainer::readEvents(const Reference<XObjectInputStream
     // Read Attachment
     if ( m_xEventAttacher.is() )
     {
-        OInterfaceArray::const_iterator aAttach = m_aItems.begin();
-        OInterfaceArray::const_iterator aAttachEnd = m_aItems.end();
-        for ( sal_Int32 i=0; aAttach != aAttachEnd; ++aAttach, ++i )
+        sal_Int32 i=0;
+        for (auto const& item : m_aItems)
         {
-            Reference< XInterface > xAsIFace( *aAttach, UNO_QUERY );    // important to normalize this ....
+            Reference< XInterface > xAsIFace( item, UNO_QUERY );    // important to normalize this ....
             Reference< XPropertySet > xAsSet( xAsIFace, UNO_QUERY );
-            m_xEventAttacher->attach( i, xAsIFace, makeAny( xAsSet ) );
+            m_xEventAttacher->attach( i++, xAsIFace, makeAny( xAsSet ) );
         }
     }
 }
diff --git a/forms/source/richtext/richtextcontrol.cxx b/forms/source/richtext/richtextcontrol.cxx
index 16acff075a43..0223d45360d7 100644
--- a/forms/source/richtext/richtextcontrol.cxx
+++ b/forms/source/richtext/richtextcontrol.cxx
@@ -293,13 +293,10 @@ namespace frm
 
             if ( pRichTextControl )
             {
-                for (   AttributeDispatchers::iterator aDisposeLoop = m_aDispatchers.begin();
-                        aDisposeLoop != m_aDispatchers.end();
-                        ++aDisposeLoop
-                    )
+                for (auto const& dispatcher : m_aDispatchers)
                 {
-                    pRichTextControl->disableAttributeNotification( aDisposeLoop->first );
-                    aDisposeLoop->second->dispose();
+                    pRichTextControl->disableAttributeNotification(dispatcher.first);
+                    dispatcher.second->dispose();
                 }
             }
 
@@ -382,12 +379,9 @@ namespace frm
             pControl->SetReadOnly( bReadOnly );
 
             // update the dispatchers
-            for (   AttributeDispatchers::iterator aDispatcherLoop = m_aDispatchers.begin();
-                    aDispatcherLoop != m_aDispatchers.end();
-                    ++aDispatcherLoop
-                )
+            for (auto const& dispatcher : m_aDispatchers)
             {
-                aDispatcherLoop->second->invalidate();
+                dispatcher.second->invalidate();
             }
         }
         else if ( _rPropertyName == PROPERTY_HIDEINACTIVESELECTION )
diff --git a/forms/source/richtext/richtextengine.cxx b/forms/source/richtext/richtextengine.cxx
index 740996b76a78..63a055a3a301 100644
--- a/forms/source/richtext/richtextengine.cxx
+++ b/forms/source/richtext/richtextengine.cxx
@@ -128,11 +128,8 @@ namespace frm
 
     IMPL_LINK( RichTextEngine, EditEngineStatusChanged, EditStatus&, _rStatus, void )
     {
-        for ( ::std::vector< IEngineStatusListener* >::const_iterator aLoop = m_aStatusListeners.begin();
-              aLoop != m_aStatusListeners.end();
-              ++aLoop
-            )
-            (*aLoop)->EditEngineStatusChanged( _rStatus );
+        for (auto const& statusListener : m_aStatusListeners)
+            statusListener->EditEngineStatusChanged( _rStatus );
     }
 
 


More information about the Libreoffice-commits mailing list