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

Arkadiy Illarionov (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 12 12:35:54 UTC 2019


 xmloff/source/draw/SignatureLineContext.cxx        |   57 ++++-----
 xmloff/source/draw/XMLImageMapExport.cxx           |    5 
 xmloff/source/draw/animationexport.cxx             |  128 ++++++++-------------
 xmloff/source/draw/sdxmlexp.cxx                    |   16 +-
 xmloff/source/draw/sdxmlimp.cxx                    |   44 ++-----
 xmloff/source/draw/shapeexport.cxx                 |  108 +++++++----------
 xmloff/source/draw/ximpcustomshape.cxx             |   17 +-
 xmloff/source/draw/ximpshap.cxx                    |   12 -
 xmloff/source/forms/elementexport.cxx              |   10 -
 xmloff/source/forms/elementimport.cxx              |   33 +----
 xmloff/source/forms/eventexport.cxx                |   19 +--
 xmloff/source/forms/propertyexport.cxx             |   11 -
 xmloff/source/meta/xmlmetae.cxx                    |   30 ++--
 xmloff/source/meta/xmlversion.cxx                  |    3 
 xmloff/source/script/XMLEventExport.cxx            |   72 +++++------
 xmloff/source/script/XMLScriptExportHandler.cxx    |    7 -
 xmloff/source/script/XMLStarBasicExportHandler.cxx |   11 -
 17 files changed, 246 insertions(+), 337 deletions(-)

New commits:
commit e1011ee3ee92ab043f0de547ec870ed87153e983
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sun May 12 16:34:32 2019 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jun 12 14:34:34 2019 +0200

    Simplify Sequence iterations in xmloff/source/{draw..script}
    
    Use range-based loops or replace with comphelper or STL functions
    
    Change-Id: I1d25ad2badccff476f3221829e8f1caf22ad3975
    Reviewed-on: https://gerrit.libreoffice.org/72191
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/draw/SignatureLineContext.cxx b/xmloff/source/draw/SignatureLineContext.cxx
index c95dfc8c72da..880d613e3f3f 100644
--- a/xmloff/source/draw/SignatureLineContext.cxx
+++ b/xmloff/source/draw/SignatureLineContext.cxx
@@ -82,37 +82,38 @@ SignatureLineContext::SignatureLineContext(SvXMLImport& rImport, sal_uInt16 nPrf
         Sequence<DocumentSignatureInformation> xSignatureInfo
             = xSignatures->verifyDocumentContentSignatures(xStorage, Reference<XInputStream>());
 
-        for (int i = 0; i < xSignatureInfo.getLength(); i++)
+        // Try to find matching signature line image - if none exists that is fine,
+        // then the signature line is not digitally signed.
+        auto pSignatureInfo = std::find_if(
+            xSignatureInfo.begin(), xSignatureInfo.end(),
+            [&xAttrList](const DocumentSignatureInformation& rSignatureInfo) {
+                return rSignatureInfo.SignatureLineId == xAttrList->getValueByName("loext:id");
+            });
+        if (pSignatureInfo != xSignatureInfo.end())
         {
-            // Try to find matching signature line image - if none exists that is fine,
-            // then the signature line is not digitally signed.
-            if (xSignatureInfo[i].SignatureLineId == xAttrList->getValueByName("loext:id"))
+            bIsSigned = true;
+            if (pSignatureInfo->SignatureIsValid)
             {
-                bIsSigned = true;
-                if (xSignatureInfo[i].SignatureIsValid)
-                {
-                    // Signature is valid, use the 'valid' image
-                    SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "xmloff",
-                                "No ValidSignatureLineImage!");
-                    xGraphic = xSignatureInfo[i].ValidSignatureLineImage;
-                }
-                else
-                {
-                    // Signature is invalid, use the 'invalid' image
-                    SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "xmloff",
-                                "No InvalidSignatureLineImage!");
-                    xGraphic = xSignatureInfo[i].InvalidSignatureLineImage;
-                }
-
-                // Save unsigned graphic
-                Reference<XGraphic> xUnsignedGraphic;
-                xPropSet->getPropertyValue("Graphic") >>= xUnsignedGraphic;
-                if (xUnsignedGraphic.is())
-                    xPropSet->setPropertyValue("SignatureLineUnsignedImage", Any(xUnsignedGraphic));
-
-                xPropSet->setPropertyValue("Graphic", Any(xGraphic));
-                break;
+                // Signature is valid, use the 'valid' image
+                SAL_WARN_IF(!pSignatureInfo->ValidSignatureLineImage.is(), "xmloff",
+                            "No ValidSignatureLineImage!");
+                xGraphic = pSignatureInfo->ValidSignatureLineImage;
             }
+            else
+            {
+                // Signature is invalid, use the 'invalid' image
+                SAL_WARN_IF(!pSignatureInfo->InvalidSignatureLineImage.is(), "xmloff",
+                            "No InvalidSignatureLineImage!");
+                xGraphic = pSignatureInfo->InvalidSignatureLineImage;
+            }
+
+            // Save unsigned graphic
+            Reference<XGraphic> xUnsignedGraphic;
+            xPropSet->getPropertyValue("Graphic") >>= xUnsignedGraphic;
+            if (xUnsignedGraphic.is())
+                xPropSet->setPropertyValue("SignatureLineUnsignedImage", Any(xUnsignedGraphic));
+
+            xPropSet->setPropertyValue("Graphic", Any(xGraphic));
         }
         xPropSet->setPropertyValue("SignatureLineIsSigned", Any(bIsSigned));
     }
diff --git a/xmloff/source/draw/XMLImageMapExport.cxx b/xmloff/source/draw/XMLImageMapExport.cxx
index 062f35815f6d..c9daabece5ce 100644
--- a/xmloff/source/draw/XMLImageMapExport.cxx
+++ b/xmloff/source/draw/XMLImageMapExport.cxx
@@ -136,11 +136,8 @@ void XMLImageMapExport::ExportMapEntry(
     // distinguish map entries by their service name
     Sequence<OUString> sServiceNames =
         xServiceInfo->getSupportedServiceNames();
-    sal_Int32 nLength = sServiceNames.getLength();
-    for( sal_Int32 i=0; i<nLength; i++ )
+    for( const OUString& rName : sServiceNames )
     {
-        OUString& rName = sServiceNames[i];
-
         if ( rName == "com.sun.star.image.ImageMapRectangleObject" )
         {
             eType = XML_AREA_RECTANGLE;
diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx
index e36109229975..8055e01515fe 100644
--- a/xmloff/source/draw/animationexport.cxx
+++ b/xmloff/source/draw/animationexport.cxx
@@ -724,20 +724,14 @@ void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNo
         }
 
         Sequence< NamedValue > aUserData( xNode->getUserData() );
-        if( aUserData.hasElements() )
+        for( const auto& rValue : aUserData )
         {
-            const NamedValue* pValue = aUserData.getConstArray();
-            const sal_Int32 nLength = aUserData.getLength();
-            sal_Int32 nElement;
-            for( nElement = 0; nElement < nLength; nElement++, pValue++ )
+            if( IsXMLToken( rValue.Name, XML_MASTER_ELEMENT ) )
             {
-                if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
-                {
-                    Reference< XInterface > xMaster;
-                    pValue->Value >>= xMaster;
-                    if( xMaster.is() )
-                        mxExport->getInterfaceToIdentifierMapper().registerReference( xMaster );
-                }
+                Reference< XInterface > xMaster;
+                rValue.Value >>= xMaster;
+                if( xMaster.is() )
+                    mxExport->getInterfaceToIdentifierMapper().registerReference( xMaster );
             }
         }
     }
@@ -881,69 +875,63 @@ void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNod
         sal_Int16 nContainerNodeType = EffectNodeType::DEFAULT;
         OUString aPresetId;
         Sequence< NamedValue > aUserData( xNode->getUserData() );
-        if( aUserData.hasElements() )
+        for( const auto& rValue : aUserData )
         {
-            const NamedValue* pValue = aUserData.getConstArray();
-            const sal_Int32 nLength = aUserData.getLength();
-            sal_Int32 nElement;
-            for( nElement = 0; nElement < nLength; nElement++, pValue++ )
+            if( IsXMLToken( rValue.Name, XML_NODE_TYPE ) )
             {
-                if( IsXMLToken( pValue->Name, XML_NODE_TYPE ) )
+                if( (rValue.Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
                 {
-                    if( (pValue->Value >>= nContainerNodeType) && (nContainerNodeType != EffectNodeType::DEFAULT) )
-                    {
-                        SvXMLUnitConverter::convertEnum( sTmp, nContainerNodeType, aAnimations_EnumMap_EffectNodeType );
-                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
-                    }
+                    SvXMLUnitConverter::convertEnum( sTmp, nContainerNodeType, aAnimations_EnumMap_EffectNodeType );
+                    mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NODE_TYPE, sTmp.makeStringAndClear() );
                 }
-                else if( IsXMLToken( pValue->Name, XML_PRESET_ID ) )
-                {
-                    if( pValue->Value >>= aPresetId )
-                    {
-                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
-                    }
-                }
-                else if( IsXMLToken( pValue->Name, XML_PRESET_SUB_TYPE ) )
-                {
-                    OUString aPresetSubType;
-                    if( pValue->Value >>= aPresetSubType )
-                    {
-                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
-                    }
-                }
-                else if( IsXMLToken( pValue->Name, XML_PRESET_CLASS ) )
+            }
+            else if( IsXMLToken( rValue.Name, XML_PRESET_ID ) )
+            {
+                if( rValue.Value >>= aPresetId )
                 {
-                    sal_Int16 nEffectPresetClass = sal_uInt16();
-                    if( pValue->Value >>= nEffectPresetClass )
-                    {
-                        SvXMLUnitConverter::convertEnum( sTmp, nEffectPresetClass, aAnimations_EnumMap_EffectPresetClass );
-                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
-                    }
+                    mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_ID, aPresetId );
                 }
-                else if( IsXMLToken( pValue->Name, XML_MASTER_ELEMENT ) )
+            }
+            else if( IsXMLToken( rValue.Name, XML_PRESET_SUB_TYPE ) )
+            {
+                OUString aPresetSubType;
+                if( rValue.Value >>= aPresetSubType )
                 {
-                    Reference< XInterface > xMaster;
-                    pValue->Value >>= xMaster;
-                    if( xMaster.is() )
-                    {
-                        const OUString& rIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier(xMaster);
-                        if( !rIdentifier.isEmpty() )
-                            mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
-                    }
+                    mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_SUB_TYPE, aPresetSubType );
                 }
-                else if( IsXMLToken( pValue->Name, XML_GROUP_ID ) )
+            }
+            else if( IsXMLToken( rValue.Name, XML_PRESET_CLASS ) )
+            {
+                sal_Int16 nEffectPresetClass = sal_uInt16();
+                if( rValue.Value >>= nEffectPresetClass )
                 {
-                    sal_Int32 nGroupId = 0;
-                    if( pValue->Value >>= nGroupId )
-                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::number( nGroupId ) );
+                    SvXMLUnitConverter::convertEnum( sTmp, nEffectPresetClass, aAnimations_EnumMap_EffectPresetClass );
+                    mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_PRESET_CLASS, sTmp.makeStringAndClear() );
                 }
-                else
+            }
+            else if( IsXMLToken( rValue.Name, XML_MASTER_ELEMENT ) )
+            {
+                Reference< XInterface > xMaster;
+                rValue.Value >>= xMaster;
+                if( xMaster.is() )
                 {
-                    OUString aTmp;
-                    if( pValue->Value >>= aTmp )
-                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, pValue->Name, aTmp );
+                    const OUString& rIdentifier = mxExport->getInterfaceToIdentifierMapper().getIdentifier(xMaster);
+                    if( !rIdentifier.isEmpty() )
+                        mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_MASTER_ELEMENT, rIdentifier );
                 }
             }
+            else if( IsXMLToken( rValue.Name, XML_GROUP_ID ) )
+            {
+                sal_Int32 nGroupId = 0;
+                if( rValue.Value >>= nGroupId )
+                    mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, OUString::number( nGroupId ) );
+            }
+            else
+            {
+                OUString aTmp;
+                if( rValue.Value >>= aTmp )
+                    mxExport->AddAttribute( XML_NAMESPACE_PRESENTATION, rValue.Name, aTmp );
+            }
         }
 
         nTemp = xNode->getType();
@@ -1175,15 +1163,12 @@ void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimat
             Sequence< double > aKeyTimes( xAnimate->getKeyTimes() );
             if( aKeyTimes.hasElements() )
             {
-                sal_Int32 nLength = aKeyTimes.getLength();
-                const double* p = aKeyTimes.getConstArray();
-
-                while( nLength-- )
+                for( const auto& rKeyTime : aKeyTimes )
                 {
                     if( !sTmp.isEmpty() )
                         sTmp.append( ';' );
 
-                    sTmp.append( *p++ );
+                    sTmp.append( rKeyTime );
                 }
                 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_KEYTIMES, sTmp.makeStringAndClear() );
             }
@@ -1219,17 +1204,12 @@ void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimat
             Sequence< TimeFilterPair > aTimeFilter( xAnimate->getTimeFilter() );
             if( aTimeFilter.hasElements() )
             {
-                sal_Int32 nLength = aTimeFilter.getLength();
-                const TimeFilterPair* p = aTimeFilter.getConstArray();
-
-                while( nLength-- )
+                for( const auto& rPair : aTimeFilter )
                 {
                     if( !sTmp.isEmpty() )
                         sTmp.append( ';' );
 
-                    sTmp.append( OUString::number(p->Time) ).append( "," ).append( OUString::number(p->Progress) );
-
-                    p++;
+                    sTmp.append( OUString::number(rPair.Time) ).append( "," ).append( OUString::number(rPair.Progress) );
                 }
 
                 mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_KEYSPLINES, sTmp.makeStringAndClear() );
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 7ef1932f588e..f16050f08243 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -1964,8 +1964,7 @@ void SdXMLExport::exportPresentationSettings()
 
         Reference< container::XNameContainer > xShows;
         Sequence< OUString > aShowNames;
-        const OUString* pShowNames = nullptr;
-        sal_Int32 nShowCount = 0;
+        bool bHasNames = false;
 
         Reference< XCustomPresentationSupplier > xSup( GetModel(), UNO_QUERY );
         if( xSup.is() )
@@ -1974,16 +1973,15 @@ void SdXMLExport::exportPresentationSettings()
             if( xShows.is() )
             {
                 aShowNames = xShows->getElementNames();
-                pShowNames = aShowNames.getArray();
-                nShowCount = aShowNames.getLength();
+                bHasNames = aShowNames.hasElements();
             }
         }
 
-        if( bHasAttr || nShowCount != 0 )
+        if( bHasAttr || bHasNames )
         {
             SvXMLElementExport aSettings(*this, XML_NAMESPACE_PRESENTATION, XML_SETTINGS, true, true);
 
-            if( nShowCount == 0 )
+            if( !bHasNames )
                 return;
 
             Reference< XIndexContainer > xShow;
@@ -1991,11 +1989,11 @@ void SdXMLExport::exportPresentationSettings()
 
             OUStringBuffer sTmp;
 
-            for( sal_Int32 nIndex = 0; nIndex < nShowCount; nIndex++, pShowNames++ )
+            for( const auto& rShowName : aShowNames )
             {
-                AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, *pShowNames );
+                AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, rShowName );
 
-                xShows->getByName( *pShowNames ) >>= xShow;
+                xShows->getByName( rShowName ) >>= xShow;
                 SAL_WARN_IF( !xShow.is(), "xmloff", "invalid custom show!" );
                 if( !xShow.is() )
                     continue;
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index 0c502c5b49d6..b7720ad4cd61 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -20,6 +20,7 @@
 #include <osl/thread.h>
 #include <sal/log.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <xmloff/xmlscripti.hxx>
 #include <facreg.hxx>
@@ -397,16 +398,8 @@ void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XCompo
     if( xFac.is() )
     {
         uno::Sequence< OUString > sSNS( xFac->getAvailableServiceNames() );
-        sal_Int32 n = sSNS.getLength();
-        const OUString* pSNS( sSNS.getConstArray() );
-        while( --n > 0 )
-        {
-            if( (*pSNS++) == "com.sun.star.drawing.TableShape" )
-            {
-                mbIsTableShapeSupported = true;
-                break;
-            }
-        }
+        if (comphelper::findValue(sSNS, "com.sun.star.drawing.TableShape") != -1)
+            mbIsTableShapeSupported = true;
     }
 }
 
@@ -759,14 +752,11 @@ void SdXMLImport::SetViewSettings(const css::uno::Sequence<css::beans::PropertyV
         return;
 
     awt::Rectangle aVisArea( 0,0, 28000, 21000 );
-    sal_Int32 nCount = aViewProps.getLength();
 
-    const beans::PropertyValue* pValues = aViewProps.getConstArray();
-
-    while( nCount-- )
+    for( const auto& rViewProp : aViewProps )
     {
-        const OUString& rName = pValues->Name;
-        const uno::Any rValue = pValues->Value;
+        const OUString& rName = rViewProp.Name;
+        const uno::Any rValue = rViewProp.Value;
 
         if ( rName == "VisibleAreaTop" )
         {
@@ -784,8 +774,6 @@ void SdXMLImport::SetViewSettings(const css::uno::Sequence<css::beans::PropertyV
         {
             rValue >>= aVisArea.Height;
         }
-
-        pValues++;
     }
 
     try
@@ -815,8 +803,7 @@ void SdXMLImport::SetConfigurationSettings(const css::uno::Sequence<css::beans::
     if( !xInfo.is() )
         return;
 
-    sal_Int32 nCount = aConfigProps.getLength();
-    const beans::PropertyValue* pValues = aConfigProps.getConstArray();
+    const uno::Sequence<beans::PropertyValue>* pValues = &aConfigProps;
 
     DocumentSettingsSerializer *pFilter;
     pFilter = dynamic_cast<DocumentSettingsSerializer *>(xProps.get());
@@ -824,24 +811,21 @@ void SdXMLImport::SetConfigurationSettings(const css::uno::Sequence<css::beans::
     if( pFilter )
     {
         aFiltered = pFilter->filterStreamsFromStorage( GetDocumentBase(), GetSourceStorage(), aConfigProps );
-        nCount = aFiltered.getLength();
-        pValues = aFiltered.getConstArray();
+        pValues = &aFiltered;
     }
 
-    while( nCount-- )
+    for( const auto& rValue : *pValues )
     {
         try
         {
-            const OUString& rProperty = pValues->Name;
+            const OUString& rProperty = rValue.Name;
             if( xInfo->hasPropertyByName( rProperty ) )
-                xProps->setPropertyValue( rProperty, pValues->Value );
+                xProps->setPropertyValue( rProperty, rValue.Value );
         }
         catch(const uno::Exception&)
         {
             SAL_INFO("xmloff.draw",  "#SdXMLImport::SetConfigurationSettings: Exception!" );
         }
-
-        pValues++;
     }
 }
 
@@ -857,11 +841,11 @@ void SdXMLImport::SetStatistics(
     SvXMLImport::SetStatistics(i_rStats);
 
     sal_uInt32 nCount(10);
-    for (sal_Int32 i = 0; i < i_rStats.getLength(); ++i) {
+    for (const auto& rStat : i_rStats) {
         for (const char** pStat = s_stats; *pStat != nullptr; ++pStat) {
-            if (i_rStats[i].Name.equalsAscii(*pStat)) {
+            if (rStat.Name.equalsAscii(*pStat)) {
                 sal_Int32 val = 0;
-                if (i_rStats[i].Value >>= val) {
+                if (rStat.Value >>= val) {
                     nCount = val;
                 } else {
                     SAL_WARN("xmloff.draw", "SdXMLImport::SetStatistics: invalid entry");
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index e6495a68da05..d798a8a382a7 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -1206,10 +1206,8 @@ void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape
 
     uno::Sequence< sal_Int32 > aIdSequence( xGluePoints->getIdentifiers() );
 
-    const sal_Int32 nCount = aIdSequence.getLength();
-    for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+    for( const sal_Int32 nIdentifier : aIdSequence )
     {
-        const sal_Int32 nIdentifier = aIdSequence[nIndex];
         if( (xGluePoints->getByIdentifier( nIdentifier ) >>= aGluePoint) && aGluePoint.IsUserDefined )
         {
             // export only user defined glue points
@@ -1599,58 +1597,56 @@ void XMLShapeExport::ImpExportEvents( const uno::Reference< drawing::XShape >& x
     uno::Sequence< beans::PropertyValue > aClickProperties;
     if( xEvents->hasByName( gsOnClick ) && (xEvents->getByName( gsOnClick ) >>= aClickProperties) )
     {
-        const beans::PropertyValue* pProperty = aClickProperties.getConstArray();
-        const beans::PropertyValue* pPropertyEnd = pProperty + aClickProperties.getLength();
-        for( ; pProperty != pPropertyEnd; ++pProperty )
+        for( const auto& rProperty : aClickProperties )
         {
-            if( !( nFound & Found::CLICKEVENTTYPE ) && pProperty->Name == gsEventType )
+            if( !( nFound & Found::CLICKEVENTTYPE ) && rProperty.Name == gsEventType )
             {
-                if( pProperty->Value >>= aClickEventType )
+                if( rProperty.Value >>= aClickEventType )
                     nFound |= Found::CLICKEVENTTYPE;
             }
-            else if( !( nFound & Found::CLICKACTION ) && pProperty->Name == gsClickAction )
+            else if( !( nFound & Found::CLICKACTION ) && rProperty.Name == gsClickAction )
             {
-                if( pProperty->Value >>= eClickAction )
+                if( rProperty.Value >>= eClickAction )
                     nFound |= Found::CLICKACTION;
             }
-            else if( !( nFound & Found::MACRO ) && ( pProperty->Name == gsMacroName || pProperty->Name == gsScript ) )
+            else if( !( nFound & Found::MACRO ) && ( rProperty.Name == gsMacroName || rProperty.Name == gsScript ) )
             {
-                if( pProperty->Value >>= aStrMacro )
+                if( rProperty.Value >>= aStrMacro )
                     nFound |= Found::MACRO;
             }
-            else if( !( nFound & Found::LIBRARY ) && pProperty->Name == gsLibrary )
+            else if( !( nFound & Found::LIBRARY ) && rProperty.Name == gsLibrary )
             {
-                if( pProperty->Value >>= aStrLibrary )
+                if( rProperty.Value >>= aStrLibrary )
                     nFound |= Found::LIBRARY;
             }
-            else if( !( nFound & Found::EFFECT ) && pProperty->Name == gsEffect )
+            else if( !( nFound & Found::EFFECT ) && rProperty.Name == gsEffect )
             {
-                if( pProperty->Value >>= eEffect )
+                if( rProperty.Value >>= eEffect )
                     nFound |= Found::EFFECT;
             }
-            else if( !( nFound & Found::BOOKMARK ) && pProperty->Name == gsBookmark )
+            else if( !( nFound & Found::BOOKMARK ) && rProperty.Name == gsBookmark )
             {
-                if( pProperty->Value >>= aStrBookmark )
+                if( rProperty.Value >>= aStrBookmark )
                     nFound |= Found::BOOKMARK;
             }
-            else if( !( nFound & Found::SPEED ) && pProperty->Name == gsSpeed )
+            else if( !( nFound & Found::SPEED ) && rProperty.Name == gsSpeed )
             {
-                if( pProperty->Value >>= eSpeed )
+                if( rProperty.Value >>= eSpeed )
                     nFound |= Found::SPEED;
             }
-            else if( !( nFound & Found::SOUNDURL ) && pProperty->Name == gsSoundURL )
+            else if( !( nFound & Found::SOUNDURL ) && rProperty.Name == gsSoundURL )
             {
-                if( pProperty->Value >>= aStrSoundURL )
+                if( rProperty.Value >>= aStrSoundURL )
                     nFound |= Found::SOUNDURL;
             }
-            else if( !( nFound & Found::PLAYFULL ) && pProperty->Name == gsPlayFull )
+            else if( !( nFound & Found::PLAYFULL ) && rProperty.Name == gsPlayFull )
             {
-                if( pProperty->Value >>= bPlayFull )
+                if( rProperty.Value >>= bPlayFull )
                     nFound |= Found::PLAYFULL;
             }
-            else if( !( nFound & Found::VERB ) && pProperty->Name == gsVerb )
+            else if( !( nFound & Found::VERB ) && rProperty.Name == gsVerb )
             {
-                if( pProperty->Value >>= nVerb )
+                if( rProperty.Value >>= nVerb )
                     nFound |= Found::VERB;
             }
         }
@@ -3118,11 +3114,10 @@ void XMLShapeExport::ImpExportAppletShape(
         // export parameters
         uno::Sequence< beans::PropertyValue > aCommands;
         xPropSet->getPropertyValue("AppletCommands") >>= aCommands;
-        const sal_Int32 nCount = aCommands.getLength();
-        for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+        for( const auto& rCommand : aCommands )
         {
-            aCommands[nIndex].Value >>= aStr;
-            mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
+            rCommand.Value >>= aStr;
+            mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, rCommand.Name );
             mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
             SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
         }
@@ -3165,11 +3160,10 @@ void XMLShapeExport::ImpExportPluginShape(
         // export parameters
         uno::Sequence< beans::PropertyValue > aCommands;
         xPropSet->getPropertyValue("PluginCommands") >>= aCommands;
-        const sal_Int32 nCount = aCommands.getLength();
-        for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+        for( const auto& rCommand : aCommands )
         {
-            aCommands[nIndex].Value >>= aStr;
-            mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aCommands[nIndex].Name );
+            rCommand.Value >>= aStr;
+            mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, rCommand.Name );
             mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
             SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
         }
@@ -3797,19 +3791,16 @@ static void ImpExportEquations( SvXMLExport& rExport, const uno::Sequence< OUStr
 
 static void ImpExportHandles( SvXMLExport& rExport, const uno::Sequence< beans::PropertyValues >& rHandles )
 {
-    sal_uInt32 i, j, nElements = rHandles.getLength();
-    if ( nElements )
+    if ( rHandles.hasElements() )
     {
         OUString       aStr;
         OUStringBuffer aStrBuffer;
 
-        for ( i = 0; i < nElements; i++ )
+        for ( const uno::Sequence< beans::PropertyValue >& rPropSeq : rHandles )
         {
             bool bPosition = false;
-            const uno::Sequence< beans::PropertyValue >& rPropSeq = rHandles[ i ];
-            for ( j = 0; j < static_cast<sal_uInt32>(rPropSeq.getLength()); j++ )
+            for ( const beans::PropertyValue& rPropVal : rPropSeq )
             {
-                const beans::PropertyValue& rPropVal = rPropSeq[ j ];
                 switch( EASGet( rPropVal.Name ) )
                 {
                     case EAS_Position :
@@ -4130,10 +4121,8 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
             bool bCoordinates = false;
             OUString aCustomShapeType( "non-primitive" );
 
-            sal_Int32 j, nGeoPropCount = aGeoPropSeq.getLength();
-            for ( j = 0; j < nGeoPropCount; j++ )
+            for ( const beans::PropertyValue& rGeoProp : aGeoPropSeq )
             {
-                const beans::PropertyValue& rGeoProp = aGeoPropSeq[ j ];
                 switch( EASGet( rGeoProp.Name ) )
                 {
                     case EAS_Type :
@@ -4185,10 +4174,8 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
                         uno::Sequence< beans::PropertyValue > aExtrusionPropSeq;
                         if ( rGeoProp.Value >>= aExtrusionPropSeq )
                         {
-                            sal_Int32 i, nCount = aExtrusionPropSeq.getLength();
-                            for ( i = 0; i < nCount; i++ )
+                            for ( const beans::PropertyValue& rProp : aExtrusionPropSeq )
                             {
-                                const beans::PropertyValue& rProp = aExtrusionPropSeq[ i ];
                                 switch( EASGet( rProp.Name ) )
                                 {
                                     case EAS_Extrusion :
@@ -4495,10 +4482,8 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
                         uno::Sequence< beans::PropertyValue > aTextPathPropSeq;
                         if ( rGeoProp.Value >>= aTextPathPropSeq )
                         {
-                            sal_Int32 i, nCount = aTextPathPropSeq.getLength();
-                            for ( i = 0; i < nCount; i++ )
+                            for ( const beans::PropertyValue& rProp : aTextPathPropSeq )
                             {
-                                const beans::PropertyValue& rProp = aTextPathPropSeq[ i ];
                                 switch( EASGet( rProp.Name ) )
                                 {
                                     case EAS_TextPath :
@@ -4557,11 +4542,8 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
                         uno::Sequence< beans::PropertyValue > aPathPropSeq;
                         if ( rGeoProp.Value >>= aPathPropSeq )
                         {
-                            sal_Int32 i, nCount = aPathPropSeq.getLength();
-                            for ( i = 0; i < nCount; i++ )
+                            for ( const beans::PropertyValue& rProp : aPathPropSeq )
                             {
-                                const beans::PropertyValue& rProp = aPathPropSeq[ i ];
-
                                 switch( EASGet( rProp.Name ) )
                                 {
                                     case EAS_SubViewSize:
@@ -4615,13 +4597,12 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
                                         css::uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair> aGluePoints;
                                         if ( rProp.Value >>= aGluePoints )
                                         {
-                                            sal_Int32 k, nElements = aGluePoints.getLength();
-                                            if ( nElements )
+                                            if ( aGluePoints.hasElements() )
                                             {
-                                                for( k = 0; k < nElements; k++ )
+                                                for( const auto& rGluePoint : aGluePoints )
                                                 {
-                                                    ExportParameter( aStrBuffer, aGluePoints[ k ].First );
-                                                    ExportParameter( aStrBuffer, aGluePoints[ k ].Second );
+                                                    ExportParameter( aStrBuffer, rGluePoint.First );
+                                                    ExportParameter( aStrBuffer, rGluePoint.Second );
                                                 }
                                                 aStr = aStrBuffer.makeStringAndClear();
                                             }
@@ -4676,13 +4657,12 @@ static void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Referenc
                                         {
                                             if ( aPathTextFrames.hasElements() )
                                             {
-                                                sal_uInt16 k, nElements = static_cast<sal_uInt16>(aPathTextFrames.getLength());
-                                                for ( k = 0; k < nElements; k++ )
+                                                for ( const auto& rPathTextFrame : aPathTextFrames )
                                                 {
-                                                    ExportParameter( aStrBuffer, aPathTextFrames[ k ].TopLeft.First );
-                                                    ExportParameter( aStrBuffer, aPathTextFrames[ k ].TopLeft.Second );
-                                                    ExportParameter( aStrBuffer, aPathTextFrames[ k ].BottomRight.First );
-                                                    ExportParameter( aStrBuffer, aPathTextFrames[ k ].BottomRight.Second );
+                                                    ExportParameter( aStrBuffer, rPathTextFrame.TopLeft.First );
+                                                    ExportParameter( aStrBuffer, rPathTextFrame.TopLeft.Second );
+                                                    ExportParameter( aStrBuffer, rPathTextFrame.BottomRight.First );
+                                                    ExportParameter( aStrBuffer, rPathTextFrame.BottomRight.Second );
                                                 }
                                                 aStr = aStrBuffer.makeStringAndClear();
                                             }
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index a3e0ffc13427..4c1e0e5121d6 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -1227,7 +1227,6 @@ void XMLEnhancedCustomShapeContext::EndElement()
         }
 
         // Path
-        sal_Int32 i;
         for ( beans::PropertyValue& rPathItem : maPath )
         {
             switch( EASGet( rPathItem.Name ) )
@@ -1238,10 +1237,10 @@ void XMLEnhancedCustomShapeContext::EndElement()
                     uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > const & rSeq =
                         *o3tl::doAccess<uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > >(
                             rPathItem.Value);
-                    for ( i = 0; i < rSeq.getLength(); i++ )
+                    for ( const auto& rElem : rSeq )
                     {
-                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].First), pH.get() );
-                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].Second), pH.get() );
+                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.First), pH.get() );
+                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.Second), pH.get() );
                     }
                 }
                 break;
@@ -1250,12 +1249,12 @@ void XMLEnhancedCustomShapeContext::EndElement()
                     uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > const & rSeq =
                         *o3tl::doAccess<uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > >(
                             rPathItem.Value);
-                    for ( i = 0; i < rSeq.getLength(); i++ )
+                    for ( const auto& rElem : rSeq )
                     {
-                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.First), pH.get() );
-                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.Second), pH.get() );
-                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].BottomRight.First), pH.get() );
-                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].BottomRight.Second), pH.get() );
+                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.TopLeft.First), pH.get() );
+                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.TopLeft.Second), pH.get() );
+                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.BottomRight.First), pH.get() );
+                        CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rElem.BottomRight.Second), pH.get() );
                     }
                 }
                 break;
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 6b19c48742c2..58c3e512dc54 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3105,28 +3105,28 @@ void SdXMLPluginShapeContext::EndElement()
 
             xProps->setPropertyValue("MediaMimeType", uno::makeAny(maMimeType) );
 
-            for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam )
+            for( const auto& rParam : maParams )
             {
-                const OUString& rName = maParams[ nParam ].Name;
+                const OUString& rName = rParam.Name;
 
                 if( rName == "Loop" )
                 {
                     OUString aValueStr;
-                    maParams[ nParam ].Value >>= aValueStr;
+                    rParam.Value >>= aValueStr;
                     xProps->setPropertyValue("Loop",
                         uno::makeAny( aValueStr == "true" ) );
                 }
                 else if( rName == "Mute" )
                 {
                     OUString aValueStr;
-                    maParams[ nParam ].Value >>= aValueStr;
+                    rParam.Value >>= aValueStr;
                     xProps->setPropertyValue("Mute",
                         uno::makeAny( aValueStr == "true" ) );
                 }
                 else if( rName == "VolumeDB" )
                 {
                     OUString aValueStr;
-                    maParams[ nParam ].Value >>= aValueStr;
+                    rParam.Value >>= aValueStr;
                     xProps->setPropertyValue("VolumeDB",
                                                 uno::makeAny( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
                 }
@@ -3135,7 +3135,7 @@ void SdXMLPluginShapeContext::EndElement()
                     OUString            aZoomStr;
                     media::ZoomLevel    eZoomLevel;
 
-                    maParams[ nParam ].Value >>= aZoomStr;
+                    rParam.Value >>= aZoomStr;
 
                     if( aZoomStr == "25%" )
                         eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx
index 20aebd730727..a2e61bdc7c6a 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -400,14 +400,13 @@ namespace xmloff
                     Sequence< OUString > aListItems;
                     m_xProps->getPropertyValue(PROPERTY_STRING_ITEM_LIST) >>= aListItems;
                     // loop through it and write the sub elements
-                    const OUString* pListItems = aListItems.getConstArray();
-                    for (sal_Int32 i=0; i<aListItems.getLength(); ++i, ++pListItems)
+                    for (const auto& rListItem : aListItems)
                     {
                         m_rContext.getGlobalContext().ClearAttrList();
                         AddAttribute(
                             OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Label),
                             OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Label),
-                            *pListItems);
+                            rListItem);
                         SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "item", true, true);
                     }
                 }
@@ -1261,9 +1260,8 @@ namespace xmloff
         DBG_CHECK_PROPERTY(_rPropertyName, Sequence< sal_Int16 >);
         m_xProps->getPropertyValue(_rPropertyName) >>= aValueSequence;
 
-        const sal_Int16* pValues = aValueSequence.getConstArray();
-        for (sal_Int32 i=0; i<aValueSequence.getLength(); ++i, ++pValues)
-            _rOut.insert(*pValues);
+        for (const auto& rValue : aValueSequence)
+            _rOut.insert(rValue);
     }
 
     void OControlExport::exportListSourceAsElements()
diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx
index 8adb230b5b62..e118e0d942fb 100644
--- a/xmloff/source/forms/elementimport.cxx
+++ b/xmloff/source/forms/elementimport.cxx
@@ -362,16 +362,13 @@ namespace xmloff
                     rPropValues.Value >>= aXMLValueList;
                     Sequence< sal_Int16 > aPropertyValueList( aXMLValueList.getLength() );
 
-                    const Any*       pXMLValue = aXMLValueList.getConstArray();
-                    sal_Int16* pPropValue = aPropertyValueList.getArray();
-
-                    for ( sal_Int32 i=0; i<aXMLValueList.getLength(); ++i, ++pXMLValue, ++pPropValue )
-                    {
-                        // only value sequences of numeric types implemented so far.
-                        double nVal( 0 );
-                        OSL_VERIFY( *pXMLValue >>= nVal );
-                        *pPropValue = static_cast< sal_Int16 >( nVal );
-                    }
+                    std::transform(aXMLValueList.begin(), aXMLValueList.end(), aPropertyValueList.begin(),
+                        [](const Any& rXMLValue) -> sal_Int16 {
+                            // only value sequences of numeric types implemented so far.
+                            double nVal( 0 );
+                            OSL_VERIFY( rXMLValue >>= nVal );
+                            return static_cast< sal_Int16 >( nVal );
+                        });
 
                     rPropValues.Value <<= aPropertyValueList;
                 }
@@ -441,24 +438,14 @@ namespace xmloff
             return OUString(sUnnamedName);
         Sequence< OUString > aNames = m_xParentContainer->getElementNames();
 
-        const OUString* pNames = nullptr;
-        const OUString* pNamesEnd = aNames.getConstArray() + aNames.getLength();
         for (sal_Int32 i=0; i<32768; ++i)   // the limit is nearly arbitrary ...
         {
             // assemble the new name (suggestion)
             OUString sReturn = sUnnamedName + OUString::number(i);
             // check the existence (this is the bad performance part ....)
-            for (pNames = aNames.getConstArray(); pNames<pNamesEnd; ++pNames)
-            {
-                if (*pNames == sReturn)
-                {
-                    break;
-                }
-            }
-            if (pNames<pNamesEnd)
-                // found the name
-                continue;
-            return sReturn;
+            if (comphelper::findValue(aNames, sReturn) == -1)
+                // not found the name
+                return sReturn;
         }
         OSL_FAIL("OElementImport::implGetDefaultName: did not find a free name!");
         return OUString(sUnnamedName);
diff --git a/xmloff/source/forms/eventexport.cxx b/xmloff/source/forms/eventexport.cxx
index 9d27751a6c6a..f9ce49ee27c9 100644
--- a/xmloff/source/forms/eventexport.cxx
+++ b/xmloff/source/forms/eventexport.cxx
@@ -34,23 +34,20 @@ namespace xmloff
     //= OEventDescriptorMapper
     OEventDescriptorMapper::OEventDescriptorMapper(const Sequence< ScriptEventDescriptor >& _rEvents)
     {
-        sal_Int32 nEvents = _rEvents.getLength();
-
         // translate the events
-        const ScriptEventDescriptor* pEvents = _rEvents.getConstArray();
         OUString sLibrary, sLocalMacroName;
-        for (sal_Int32 i=0; i<nEvents; ++i, ++pEvents)
+        for (const auto& rEvent : _rEvents)
         {
             // the name of the event is build from listener interface and listener method name
-            OUString sName = pEvents->ListenerType
+            OUString sName = rEvent.ListenerType
                 + EVENT_NAME_SEPARATOR
-                + pEvents->EventMethod;
+                + rEvent.EventMethod;
 
             Sequence< PropertyValue >& rMappedEvent = m_aMappedEvents[sName];
 
-            sLocalMacroName = pEvents->ScriptCode;
+            sLocalMacroName = rEvent.ScriptCode;
             sLibrary.clear();
-            if (pEvents->ScriptType == EVENT_STARBASIC)
+            if (rEvent.ScriptType == EVENT_STARBASIC)
             {   // for StarBasic, the library name is part of the ScriptCode
                 sal_Int32 nPrefixLen = sLocalMacroName.indexOf( ':' );
                 SAL_WARN_IF( 0 > nPrefixLen, "xmloff", "OEventDescriptorMapper::OEventDescriptorMapper: invalid script code prefix!" );
@@ -67,7 +64,7 @@ namespace xmloff
                 rMappedEvent.realloc( sLibrary.isEmpty() ? 2 : 3 );
 
                 // ... the type
-                rMappedEvent[0] = PropertyValue(EVENT_TYPE, -1, makeAny(pEvents->ScriptType), PropertyState_DIRECT_VALUE);
+                rMappedEvent[0] = PropertyValue(EVENT_TYPE, -1, makeAny(rEvent.ScriptType), PropertyState_DIRECT_VALUE);
 
                 // and the macro name
                 rMappedEvent[1] = PropertyValue(EVENT_LOCALMACRONAME, -1, makeAny(sLocalMacroName), PropertyState_DIRECT_VALUE);
@@ -79,9 +76,9 @@ namespace xmloff
             else
             {
                 rMappedEvent.realloc( 2 );
-                rMappedEvent[0] = PropertyValue(EVENT_TYPE, -1, makeAny(pEvents->ScriptType), PropertyState_DIRECT_VALUE);
+                rMappedEvent[0] = PropertyValue(EVENT_TYPE, -1, makeAny(rEvent.ScriptType), PropertyState_DIRECT_VALUE);
                 // and the macro name
-                rMappedEvent[1] = PropertyValue(EVENT_SCRIPTURL, -1, makeAny(pEvents->ScriptCode), PropertyState_DIRECT_VALUE);
+                rMappedEvent[1] = PropertyValue(EVENT_SCRIPTURL, -1, makeAny(rEvent.ScriptCode), PropertyState_DIRECT_VALUE);
             }
         }
     }
diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx
index 708848670c1f..16cd00ada288 100644
--- a/xmloff/source/forms/propertyexport.cxx
+++ b/xmloff/source/forms/propertyexport.cxx
@@ -224,18 +224,17 @@ namespace xmloff
     {
         m_aRemainingProps.clear();
         Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
-        const Property* pProperties = aProperties.getConstArray();
-        for (sal_Int32 i=0; i<aProperties.getLength(); ++i, ++pProperties)
+        for (const auto& rProp : aProperties)
         {
             // no transient props
-            if ( pProperties->Attributes & PropertyAttribute::TRANSIENT )
+            if ( rProp.Attributes & PropertyAttribute::TRANSIENT )
                 continue;
             // no read-only props
-            if ( ( pProperties->Attributes & PropertyAttribute::READONLY ) != 0 )
+            if ( ( rProp.Attributes & PropertyAttribute::READONLY ) != 0 )
                 // except they're dynamically added
-                if ( ( pProperties->Attributes & PropertyAttribute::REMOVABLE ) == 0 )
+                if ( ( rProp.Attributes & PropertyAttribute::REMOVABLE ) == 0 )
                     continue;
-            m_aRemainingProps.insert(pProperties->Name);
+            m_aRemainingProps.insert(rProp.Name);
         }
     }
 
diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx
index 9ee67dd9bf63..ac4a1da506f5 100644
--- a/xmloff/source/meta/xmlmetae.cxx
+++ b/xmloff/source/meta/xmlmetae.cxx
@@ -136,10 +136,10 @@ void SvXMLMetaExport::MExport_()
 
     //  keywords
     const uno::Sequence< OUString > keywords = mxDocProps->getKeywords();
-    for (sal_Int32 i = 0; i < keywords.getLength(); ++i) {
+    for (const auto& rKeyword : keywords) {
         SvXMLElementExport aKwElem( mrExport, XML_NAMESPACE_META, XML_KEYWORD,
                                     true, false );
-        mrExport.Characters( keywords[i] );
+        mrExport.Characters( rKeyword );
     }
 
     //  document language
@@ -236,14 +236,14 @@ void SvXMLMetaExport::MExport_()
         mxDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
     const uno::Sequence< beans::PropertyValue > props =
         xUserDefined->getPropertyValues();
-    for (sal_Int32 i = 0; i < props.getLength(); ++i) {
+    for (const auto& rProp : props) {
         OUStringBuffer sValueBuffer;
         OUStringBuffer sType;
-        if (!::sax::Converter::convertAny(sValueBuffer, sType, props[i].Value))
+        if (!::sax::Converter::convertAny(sValueBuffer, sType, rProp.Value))
         {
             continue;
         }
-        mrExport.AddAttribute( XML_NAMESPACE_META, XML_NAME, props[i].Name );
+        mrExport.AddAttribute( XML_NAMESPACE_META, XML_NAME, rProp.Name );
         mrExport.AddAttribute( XML_NAMESPACE_META, XML_VALUE_TYPE,
                               sType.makeStringAndClear() );
         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_META,
@@ -256,34 +256,34 @@ void SvXMLMetaExport::MExport_()
     // write document statistic if there is any provided
     if ( aDocStatistic.hasElements() )
     {
-        for ( sal_Int32 nInd = 0; nInd < aDocStatistic.getLength(); nInd++ )
+        for ( const auto& rDocStat : aDocStatistic )
         {
             sal_Int32 nValue = 0;
-            if ( aDocStatistic[nInd].Value >>= nValue )
+            if ( rDocStat.Value >>= nValue )
             {
                 OUString aValue = OUString::number( nValue );
-                if ( aDocStatistic[nInd].Name == "TableCount" )
+                if ( rDocStat.Name == "TableCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_TABLE_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "ObjectCount" )
+                else if ( rDocStat.Name == "ObjectCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_OBJECT_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "ImageCount" )
+                else if ( rDocStat.Name == "ImageCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_IMAGE_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "PageCount" )
+                else if ( rDocStat.Name == "PageCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_PAGE_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "ParagraphCount" )
+                else if ( rDocStat.Name == "ParagraphCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_PARAGRAPH_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "WordCount" )
+                else if ( rDocStat.Name == "WordCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_WORD_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "CharacterCount" )
+                else if ( rDocStat.Name == "CharacterCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_CHARACTER_COUNT, aValue );
-                else if ( aDocStatistic[nInd].Name == "CellCount" )
+                else if ( rDocStat.Name == "CellCount" )
                     mrExport.AddAttribute(
                         XML_NAMESPACE_META, XML_CELL_COUNT, aValue );
                 else
diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx
index d31107faec32..08e92e00dd0a 100644
--- a/xmloff/source/meta/xmlversion.cxx
+++ b/xmloff/source/meta/xmlversion.cxx
@@ -76,9 +76,8 @@ ErrCode XMLVersionListExport::exportDoc( enum ::xmloff::token::XMLTokenEnum )
         // the following object will write all collected attributes in its dtor
         SvXMLElementExport aRoot( *this, XML_NAMESPACE_FRAMEWORK, xmloff::token::XML_VERSION_LIST, true, true );
 
-        for ( sal_Int32 n=0; n<maVersions.getLength(); n++ )
+        for ( const util::RevisionTag& rInfo : maVersions )
         {
-            const util::RevisionTag& rInfo = maVersions[n];
             AddAttribute( XML_NAMESPACE_FRAMEWORK,
                           xmloff::token::XML_TITLE,
                           rInfo.Identifier );
diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx
index f676af8e3467..f6d5b3b07912 100644
--- a/xmloff/source/script/XMLEventExport.cxx
+++ b/xmloff/source/script/XMLEventExport.cxx
@@ -112,17 +112,16 @@ void XMLEventExport::Export( Reference<XNameAccess> const & rAccess,
 
     // iterate over all event types
     Sequence<OUString> aNames = rAccess->getElementNames();
-    sal_Int32 nCount = aNames.getLength();
-    for(sal_Int32 i = 0; i < nCount; i++)
+    for(const auto& rName : aNames)
     {
         // translate name
-        NameMap::iterator aIter = aNameTranslationMap.find(aNames[i]);
+        NameMap::iterator aIter = aNameTranslationMap.find(rName);
         if (aIter != aNameTranslationMap.end())
         {
             const XMLEventName& rXmlName = aIter->second;
 
             // get PropertyValues for this event
-            Any aAny = rAccess->getByName( aNames[i] );
+            Any aAny = rAccess->getByName( rName );
             Sequence<PropertyValue> aValues;
             aAny >>= aValues;
 
@@ -132,7 +131,7 @@ void XMLEventExport::Export( Reference<XNameAccess> const & rAccess,
         else
         {
             // don't proceed further
-            SAL_WARN("xmloff", "Unknown event name:" << aNames[i] );
+            SAL_WARN("xmloff", "Unknown event name:" << rName );
         }
     }
 
@@ -190,49 +189,42 @@ void XMLEventExport::ExportEvent(
     bool& rExported )
 {
     // search for EventType value and then delegate to EventHandler
-    sal_Int32 nValues = rEventValues.getLength();
-    const PropertyValue* pValues = rEventValues.getConstArray();
+    const PropertyValue* pValue = std::find_if(rEventValues.begin(), rEventValues.end(),
+        [](const PropertyValue& rValue) { return gsEventType == rValue.Name; });
 
-    for(sal_Int32 nVal = 0; nVal < nValues; nVal++)
+    if (pValue != rEventValues.end())
     {
-        if (gsEventType == pValues[nVal].Name)
-        {
-            // found! Now find handler and delegate
-            OUString sType;
-            pValues[nVal].Value >>= sType;
+        // found! Now find handler and delegate
+        OUString sType;
+        pValue->Value >>= sType;
 
-            if (aHandlerMap.count(sType))
+        if (aHandlerMap.count(sType))
+        {
+            if (! rExported)
             {
-                if (! rExported)
-                {
-                    // OK, we have't yet exported the enclosing
-                    // element. So we do that now.
-                    rExported = true;
-                    StartElement(bUseWhitespace);
-                }
-
-                OUString aEventQName(
-                    rExport.GetNamespaceMap().GetQNameByKey(
-                            rXmlEventName.m_nPrefix, rXmlEventName.m_aName ) );
-
-                // delegate to proper ExportEventHandler
-                aHandlerMap[sType]->Export(rExport, aEventQName,
-                                           rEventValues, bUseWhitespace);
+                // OK, we have't yet exported the enclosing
+                // element. So we do that now.
+                rExported = true;
+                StartElement(bUseWhitespace);
             }
-            else
+
+            OUString aEventQName(
+                rExport.GetNamespaceMap().GetQNameByKey(
+                        rXmlEventName.m_nPrefix, rXmlEventName.m_aName ) );
+
+            // delegate to proper ExportEventHandler
+            aHandlerMap[sType]->Export(rExport, aEventQName,
+                                       rEventValues, bUseWhitespace);
+        }
+        else
+        {
+            if ( sType != "None" )
             {
-                if ( sType != "None" )
-                {
-                    OSL_FAIL("unknown event type returned by API");
-                    // unknown type -> error (ignore)
-                }
-                // else: we ignore None fields
+                OSL_FAIL("unknown event type returned by API");
+                // unknown type -> error (ignore)
             }
-
-            // early out: we don't need to look for another type
-            break;
+            // else: we ignore None fields
         }
-        // else: we only care for EventType -> ignore
     }
 }
 
diff --git a/xmloff/source/script/XMLScriptExportHandler.cxx b/xmloff/source/script/XMLScriptExportHandler.cxx
index 6dde942c9907..b2fe8d6497c5 100644
--- a/xmloff/source/script/XMLScriptExportHandler.cxx
+++ b/xmloff/source/script/XMLScriptExportHandler.cxx
@@ -53,13 +53,12 @@ void XMLScriptExportHandler::Export(
                              XML_NAMESPACE_OOO, GetXMLToken(XML_SCRIPT) ) );
     rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, rEventQName);
 
-    sal_Int32 nCount = rValues.getLength();
-    for(sal_Int32 i = 0; i < nCount; i++)
+    for(const auto& rValue : rValues)
     {
-        if (gsURL == rValues[i].Name)
+        if (gsURL == rValue.Name)
         {
             OUString sTmp;
-            rValues[i].Value >>= sTmp;
+            rValue.Value >>= sTmp;
             rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sTmp);
 
             // #i110911# xlink:type="simple" is required
diff --git a/xmloff/source/script/XMLStarBasicExportHandler.cxx b/xmloff/source/script/XMLStarBasicExportHandler.cxx
index 50bc55e4fa5e..0502bbedcd00 100644
--- a/xmloff/source/script/XMLStarBasicExportHandler.cxx
+++ b/xmloff/source/script/XMLStarBasicExportHandler.cxx
@@ -58,21 +58,20 @@ void XMLStarBasicExportHandler::Export(
     rExport.AddAttribute(XML_NAMESPACE_SCRIPT, XML_EVENT_NAME, rEventQName);
 
     OUString sLocation, sName;
-    sal_Int32 nCount = rValues.getLength();
-    for(sal_Int32 i = 0; i < nCount; i++)
+    for(const auto& rValue : rValues)
     {
-        if (gsLibrary == rValues[i].Name)
+        if (gsLibrary == rValue.Name)
         {
             OUString sTmp;
-            rValues[i].Value >>= sTmp;
+            rValue.Value >>= sTmp;
             sLocation = GetXMLToken(
                 (sTmp.equalsIgnoreAsciiCase(gsApplication) ||
                  sTmp.equalsIgnoreAsciiCase(gsStarOffice) ) ? XML_APPLICATION
                                                            : XML_DOCUMENT );
         }
-        else if (gsMacroName == rValues[i].Name)
+        else if (gsMacroName == rValue.Name)
         {
-            rValues[i].Value >>= sName;
+            rValue.Value >>= sName;
         }
         // else: disregard
     }


More information about the Libreoffice-commits mailing list