diff options
Diffstat (limited to 'scripting/source')
-rw-r--r-- | scripting/source/basprov/basscript.cxx | 8 | ||||
-rw-r--r-- | scripting/source/provider/BrowseNodeFactoryImpl.cxx | 24 | ||||
-rw-r--r-- | scripting/source/stringresource/stringresource.cxx | 76 | ||||
-rw-r--r-- | scripting/source/vbaevents/eventhelper.cxx | 14 |
4 files changed, 55 insertions, 67 deletions
diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 6eac074750a9..fbefb064dc97 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -266,10 +266,12 @@ namespace basprov aOutParam.realloc( nOutParamCount ); sal_Int16* pOutParamIndex = aOutParamIndex.getArray(); Any* pOutParam = aOutParam.getArray(); - for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam ) + for ( const auto& rEntry : aOutParamMap ) { - *pOutParamIndex = aIt->first; - *pOutParam = aIt->second; + *pOutParamIndex = rEntry.first; + ++pOutParamIndex; + *pOutParam = rEntry.second; + ++pOutParam; } } } diff --git a/scripting/source/provider/BrowseNodeFactoryImpl.cxx b/scripting/source/provider/BrowseNodeFactoryImpl.cxx index a0ff04cf2e1f..6621d5453737 100644 --- a/scripting/source/provider/BrowseNodeFactoryImpl.cxx +++ b/scripting/source/provider/BrowseNodeFactoryImpl.cxx @@ -105,17 +105,17 @@ public: } } - std::vector< Sequence< Reference < browse::XBrowseNode > > >::const_iterator it = seqs.begin(); - std::vector< Sequence< Reference < browse::XBrowseNode > > >::const_iterator it_end = seqs.end(); - Sequence< Reference < browse::XBrowseNode > > result( numChildren ); - for ( sal_Int32 index = 0; it != it_end && index < numChildren ; ++it ) + sal_Int32 index = 0; + for ( Sequence< Reference < browse::XBrowseNode > >& children : seqs ) { - Sequence< Reference < browse::XBrowseNode > > children = *it; for ( sal_Int32 j = 0; j < children.getLength(); j++ ) { result[ index++ ] = children[ j ]; } + + if (index >= numChildren) + break; } return result; } @@ -411,10 +411,11 @@ public: ::std::sort( aVNodes.begin(), aVNodes.end(), alphaSortForBNodes() ); Sequence < Reference< browse::XBrowseNode > > children( aVNodes.size() ); - vXBrowseNodes::const_iterator it = aVNodes.begin(); - for ( sal_Int32 i=0; it != aVNodes.end() && i<children.getLength(); i++, ++it ) + sal_Int32 i = 0; + for ( const auto& rxNode : aVNodes ) { - children[ i ].set( *it ); + children[ i ].set( rxNode ); + i++; } return children; } @@ -501,10 +502,11 @@ public: // no need to sort user, share, doc1...docN //::std::sort( m_vNodes.begin(), m_vNodes.end(), alphaSortForBNodes() ); Sequence < Reference< browse::XBrowseNode > > children( m_vNodes.size() ); - vXBrowseNodes::const_iterator it = m_vNodes.begin(); - for ( sal_Int32 i=0; it != m_vNodes.end() && i<children.getLength(); i++, ++it ) + sal_Int32 i = 0; + for ( const auto& rxNode : m_vNodes ) { - children[ i ].set( *it ); + children[ i ].set( rxNode ); + i++; } return children; } diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx index bf4260646caa..81639ef1ea3e 100644 --- a/scripting/source/stringresource/stringresource.cxx +++ b/scripting/source/stringresource/stringresource.cxx @@ -220,11 +220,10 @@ Sequence< OUString > StringResourceImpl::implGetResourceIDs( LocaleItem* pLocale aIDSeq.realloc( nResourceIDCount ); OUString* pStrings = aIDSeq.getArray(); - IdToStringMap::const_iterator it; int iTarget = 0; - for( it = rHashMap.begin(); it != rHashMap.end(); ++it ) + for( const auto& rEntry : rHashMap ) { - OUString aStr = (*it).first; + OUString aStr = rEntry.first; pStrings[iTarget] = aStr; iTarget++; } @@ -445,21 +444,19 @@ void StringResourceImpl::newLocale( const Locale& locale ) { const IdToStringMap& rSourceMap = pCopyFromItem->m_aIdToStringMap; IdToStringMap& rTargetMap = pLocaleItem->m_aIdToStringMap; - IdToStringMap::const_iterator it; - for( it = rSourceMap.begin(); it != rSourceMap.end(); ++it ) + for( const auto& rEntry : rSourceMap ) { - OUString aId = (*it).first; - OUString aStr = (*it).second; + OUString aId = rEntry.first; + OUString aStr = rEntry.second; rTargetMap[ aId ] = aStr; } const IdToIndexMap& rSourceIndexMap = pCopyFromItem->m_aIdToIndexMap; IdToIndexMap& rTargetIndexMap = pLocaleItem->m_aIdToIndexMap; - IdToIndexMap::const_iterator it_index; - for( it_index = rSourceIndexMap.begin(); it_index != rSourceIndexMap.end(); ++it_index ) + for( const auto& rIndex : rSourceIndexMap ) { - OUString aId = (*it_index).first; - sal_Int32 nIndex = (*it_index).second; + OUString aId = rIndex.first; + sal_Int32 nIndex = rIndex.second; rTargetIndexMap[ aId ] = nIndex; } pLocaleItem->m_nNextIndex = pCopyFromItem->m_nNextIndex; @@ -511,31 +508,29 @@ void StringResourceImpl::removeLocale( const Locale& locale ) } } } - for( auto it = m_aLocaleItemVector.begin(); it != m_aLocaleItemVector.end(); ++it ) + auto it = std::find_if(m_aLocaleItemVector.begin(), m_aLocaleItemVector.end(), + [&pRemoveItem](const std::unique_ptr<LocaleItem>& rxItem) { return rxItem.get() == pRemoveItem; }); + if (it != m_aLocaleItemVector.end()) { - if( it->get() == pRemoveItem ) - { - // Remember locale item to delete file while storing - m_aDeletedLocaleItemVector.push_back( std::move(*it) ); + // Remember locale item to delete file while storing + m_aDeletedLocaleItemVector.push_back( std::move(*it) ); - // Last locale? - if( nLocaleCount == 1 ) + // Last locale? + if( nLocaleCount == 1 ) + { + m_nNextUniqueNumericId = 0; + if( m_pDefaultLocaleItem ) { - m_nNextUniqueNumericId = 0; - if( m_pDefaultLocaleItem ) - { - m_aChangedDefaultLocaleVector.push_back( - o3tl::make_unique<LocaleItem>( m_pDefaultLocaleItem->m_locale ) ); - } - m_pCurrentLocaleItem = nullptr; - m_pDefaultLocaleItem = nullptr; + m_aChangedDefaultLocaleVector.push_back( + o3tl::make_unique<LocaleItem>( m_pDefaultLocaleItem->m_locale ) ); } + m_pCurrentLocaleItem = nullptr; + m_pDefaultLocaleItem = nullptr; + } - m_aLocaleItemVector.erase( it ); + m_aLocaleItemVector.erase( it ); - implModified(); - break; - } + implModified(); } } } @@ -2019,29 +2014,22 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem const * { // Sort ids according to read order const IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap; - IdToIndexMap::const_iterator it_index; // Find max/min index - sal_Int32 nMinIndex = -1; - sal_Int32 nMaxIndex = -1; - for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index ) - { - sal_Int32 nIndex = (*it_index).second; - if( nMinIndex > nIndex || nMinIndex == -1 ) - nMinIndex = nIndex; - if( nMaxIndex < nIndex ) - nMaxIndex = nIndex; - } + auto itMinMax = std::minmax_element(rIndexMap.begin(), rIndexMap.end(), + [](const IdToIndexMap::value_type& a, const IdToIndexMap::value_type& b) { return a.second < b.second; }); + sal_Int32 nMinIndex = itMinMax.first->second; + sal_Int32 nMaxIndex = itMinMax.second->second; sal_Int32 nTabSize = nMaxIndex - nMinIndex + 1; // Create sorted array of pointers to the id strings std::unique_ptr<const OUString*[]> pIdPtrs( new const OUString*[nTabSize] ); for(sal_Int32 i = 0 ; i < nTabSize ; i++ ) pIdPtrs[i] = nullptr; - for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index ) + for( const auto& rIndex : rIndexMap ) { - sal_Int32 nIndex = (*it_index).second; - pIdPtrs[nIndex - nMinIndex] = &((*it_index).first); + sal_Int32 nIndex = rIndex.second; + pIdPtrs[nIndex - nMinIndex] = &(rIndex.first); } // Write lines in correct order diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index 408539cb7038..c0859edfaa4e 100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -844,10 +844,6 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) } if ( xScriptProvider.is() && mpShell ) { - std::list< TranslateInfo >::const_iterator txInfo = - eventInfo_it->second.begin(); - std::list< TranslateInfo >::const_iterator txInfo_end = eventInfo_it->second.end(); - BasicManager* pBasicManager = mpShell->GetBasicManager(); OUString sProject; OUString sScriptCode( evt.ScriptCode ); @@ -871,7 +867,7 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) } OUString sMacroLoc = sProject + "." + sScriptCode + "."; - for ( ; txInfo != txInfo_end; ++txInfo ) + for (const auto& rTxInfo : eventInfo_it->second) { // If the document is closed, we should not execute macro. if (m_bDocClosed) @@ -879,7 +875,7 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) break; } - OUString sTemp = sName.concat( (*txInfo).sVBAName ); + OUString sTemp = sName.concat( rTxInfo.sVBAName ); // see if we have a match for the handlerextension // where ScriptCode is methodname_handlerextension OUString sToResolve = sMacroLoc.concat( sTemp ); @@ -888,16 +884,16 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* pRet ) if ( aMacroResolvedInfo.mbFound ) { - if (! txInfo->ApproveRule(evt, txInfo->pPara) ) + if (! rTxInfo.ApproveRule(evt, rTxInfo.pPara) ) { continue; } // !! translate arguments & emulate events where necessary Sequence< Any > aArguments; - if ( (*txInfo).toVBA ) + if ( rTxInfo.toVBA ) { - aArguments = (*txInfo).toVBA( evt.Arguments ); + aArguments = rTxInfo.toVBA( evt.Arguments ); } else { |