Kaydet (Commit) 40ab4d8f authored tarafından Arkadiy Illarionov's avatar Arkadiy Illarionov Kaydeden (comit) Noel Grandin

Simplify containers iterations in unotools, unoxml, uui, vbahelper

Use range-based loop or replace with STL functions.

Change-Id: I5a43f6fc62c81453dcef3820bb715f4da76915af
Reviewed-on: https://gerrit.libreoffice.org/61762
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 9ec8bf8f
......@@ -244,10 +244,10 @@ Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions_Impl::GetList() co
lProperties[i].Name = SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
sal_Int32 j = 0;
for ( std::vector< SvtCompatibilityEntry >::const_iterator pItem = m_aOptions.begin(); pItem != m_aOptions.end(); ++pItem )
for ( const auto& rItem : m_aOptions )
{
for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Name); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
lProperties[i].Value = pItem->getValue( SvtCompatibilityEntry::Index(i) );
lProperties[i].Value = rItem.getValue( SvtCompatibilityEntry::Index(i) );
lResult[ j++ ] = lProperties;
}
......
......@@ -94,8 +94,6 @@ class SvtDynMenu
// convert internal list to external format
// for using it on right menus really
// Notice: We build a property list with 4 entries and set it on result list then.
// The while-loop starts with pointer on internal member list lSetupEntries, change to
// lUserEntries then and stop after that with NULL!
// Separator entries will be packed in another way then normal entries! We define
// special string "sSeparator" to perform too ...
Sequence< Sequence< PropertyValue > > GetList() const
......@@ -106,20 +104,17 @@ class SvtDynMenu
Sequence< PropertyValue > lProperties ( PROPERTYCOUNT );
Sequence< Sequence< PropertyValue > > lResult ( nSetupCount+nUserCount );
OUString sSeparator ( "private:separator" );
const vector< SvtDynMenuEntry >* pList = &lSetupEntries;
lProperties[OFFSET_URL ].Name = PROPERTYNAME_URL;
lProperties[OFFSET_TITLE ].Name = PROPERTYNAME_TITLE;
lProperties[OFFSET_IMAGEIDENTIFIER].Name = PROPERTYNAME_IMAGEIDENTIFIER;
lProperties[OFFSET_TARGETNAME ].Name = PROPERTYNAME_TARGETNAME;
while( pList != nullptr )
for( const auto& pList : {&lSetupEntries, &lUserEntries} )
{
for( vector< SvtDynMenuEntry >::const_iterator pItem =pList->begin();
pItem!=pList->end();
++pItem )
for( const auto& rItem : *pList )
{
if( pItem->sURL == sSeparator )
if( rItem.sURL == sSeparator )
{
lProperties[OFFSET_URL ].Value <<= sSeparator;
lProperties[OFFSET_TITLE ].Value <<= OUString();
......@@ -128,18 +123,14 @@ class SvtDynMenu
}
else
{
lProperties[OFFSET_URL ].Value <<= pItem->sURL;
lProperties[OFFSET_TITLE ].Value <<= pItem->sTitle;
lProperties[OFFSET_IMAGEIDENTIFIER ].Value <<= pItem->sImageIdentifier;
lProperties[OFFSET_TARGETNAME ].Value <<= pItem->sTargetName;
lProperties[OFFSET_URL ].Value <<= rItem.sURL;
lProperties[OFFSET_TITLE ].Value <<= rItem.sTitle;
lProperties[OFFSET_IMAGEIDENTIFIER ].Value <<= rItem.sImageIdentifier;
lProperties[OFFSET_TARGETNAME ].Value <<= rItem.sTargetName;
}
lResult[nStep] = lProperties;
++nStep;
}
if( pList == &lSetupEntries )
pList = &lUserEntries;
else
pList = nullptr;
}
return lResult;
}
......@@ -501,15 +492,12 @@ void SvtDynamicMenuOptions_Impl::impl_SortAndExpandPropertyNames( const Sequence
// Copy sorted entries to destination and expand every item with
// 4 supported sub properties.
for( vector< OUString >::const_iterator pItem =lTemp.begin();
pItem!=lTemp.end();
++pItem )
for( const auto& rItem : lTemp )
{
OUString sFixPath(sSetNode + PATHDELIMITER + *pItem + PATHDELIMITER);
OUString sFixPath(sSetNode + PATHDELIMITER + rItem + PATHDELIMITER);
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_URL;
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_TITLE;
lDestination[nDestinationStep++] = sFixPath
+ PROPERTYNAME_IMAGEIDENTIFIER;
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_IMAGEIDENTIFIER;
lDestination[nDestinationStep++] = sFixPath + PROPERTYNAME_TARGETNAME;
}
}
......
......@@ -161,24 +161,22 @@ void GlobalEventConfig_Impl::ImplCommit()
{
//DF need to check it this is correct??
SAL_INFO("unotools", "In GlobalEventConfig_Impl::ImplCommit");
EventBindingHash::const_iterator it = m_eventBindingHash.begin();
EventBindingHash::const_iterator it_end = m_eventBindingHash.end();
// clear the existing nodes
ClearNodeSet( SETNODE_BINDINGS );
Sequence< beans::PropertyValue > seqValues( 1 );
OUString sNode;
//step through the list of events
for(int i=0;it!=it_end;++it,++i)
for(const auto& rEntry : m_eventBindingHash)
{
//no point in writing out empty bindings!
if(it->second.isEmpty() )
if(rEntry.second.isEmpty() )
continue;
sNode = SETNODE_BINDINGS PATHDELIMITER "BindingType['" +
it->first +
rEntry.first +
"']" PATHDELIMITER PROPERTYNAME_BINDINGURL;
SAL_INFO("unotools", "writing binding for: " << sNode);
seqValues[ 0 ].Name = sNode;
seqValues[ 0 ].Value <<= it->second;
seqValues[ 0 ].Value <<= rEntry.second;
//write the data to the registry
SetSetProperties(SETNODE_BINDINGS,seqValues);
}
......
......@@ -216,10 +216,11 @@ OUString DefaultFontConfiguration::getDefaultFont( const LanguageTag& rLanguageT
else
{
::std::vector< OUString > aFallbacks( rLanguageTag.getFallbackStrings( false));
for (::std::vector< OUString >::const_iterator it( aFallbacks.begin());
it != aFallbacks.end() && aRet.isEmpty(); ++it)
for (const auto& rFallback : aFallbacks)
{
aRet = tryLocale( *it, aType );
aRet = tryLocale( rFallback, aType );
if (!aRet.isEmpty())
break;
}
}
}
......@@ -1064,13 +1065,13 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN
if (aLanguageTag.getLanguage() != "en")
aFallbacks.emplace_back("en");
for (::std::vector< OUString >::const_iterator fb( aFallbacks.begin()); fb != aFallbacks.end(); ++fb)
for (const auto& rFallback : aFallbacks)
{
std::unordered_map< OUString, LocaleSubst >::const_iterator lang = m_aSubst.find( *fb );
std::unordered_map< OUString, LocaleSubst >::const_iterator lang = m_aSubst.find( rFallback );
if( lang != m_aSubst.end() )
{
if( ! lang->second.bConfigRead )
readLocaleSubst( *fb );
readLocaleSubst( rFallback );
// try to find an exact match
// because the list is sorted this will also find fontnames of the form searchfontname*
std::vector< FontNameAttr >::const_iterator it = ::std::lower_bound( lang->second.aSubstAttributes.begin(), lang->second.aSubstAttributes.end(), aSearchAttr, StrictStringSort() );
......
......@@ -20,6 +20,8 @@
#include <sal/config.h>
#include <unotools/options.hxx>
#include <algorithm>
using utl::detail::Options;
using utl::ConfigurationBroadcaster;
......@@ -64,15 +66,9 @@ void ConfigurationBroadcaster::AddListener( utl::ConfigurationListener* pListene
void ConfigurationBroadcaster::RemoveListener( utl::ConfigurationListener const * pListener )
{
if ( mpList ) {
for ( IMPL_ConfigurationListenerList::iterator it = mpList->begin();
it != mpList->end();
++it
) {
if ( *it == pListener ) {
mpList->erase( it );
break;
}
}
auto it = std::find(mpList->begin(), mpList->end(), pListener);
if ( it != mpList->end() )
mpList->erase( it );
}
}
......
......@@ -549,10 +549,10 @@ OUString GetSubsFontName( const OUString& rName, SubsFontFlags nFlags )
}
if( ! pVector )
continue;
for( ::std::vector< OUString >::const_iterator it = pVector->begin(); it != pVector->end(); ++it )
if( ! ImplIsFontToken( rName, *it ) )
for( const auto& rSubstitution : *pVector )
if( ! ImplIsFontToken( rName, rSubstitution ) )
{
ImplAppendFontToken( aName, *it );
ImplAppendFontToken( aName, rSubstitution );
if( nFlags & SubsFontFlags::ONLYONE )
{
i = 4;
......
......@@ -361,18 +361,11 @@ bool utl::UCBContentHelper::Exists(OUString const & url) {
o.removeFinalSlash();
std::vector<OUString> cs(
getContents(o.GetMainURL(INetURLObject::DecodeMechanism::NONE)));
for (std::vector<OUString>::iterator i(cs.begin()); i != cs.end();
++i)
{
if (INetURLObject(*i).getName(
INetURLObject::LAST_SEGMENT, true,
INetURLObject::DecodeMechanism::WithCharset).
equalsIgnoreAsciiCase(name))
{
return true;
}
}
return false;
return std::any_of(cs.begin(), cs.end(),
[&name](const OUString& rItem) {
return INetURLObject(rItem).
getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset).
equalsIgnoreAsciiCase(name); });
}
}
......
......@@ -110,10 +110,9 @@ namespace DOM
::osl::MutexGuard const g(m_Mutex);
#ifdef DBG_UTIL
// node map must be empty now, otherwise CDocument must not die!
for (nodemap_t::iterator i = m_NodeMap.begin();
i != m_NodeMap.end(); ++i)
for (const auto& rEntry : m_NodeMap)
{
Reference<XNode> const xNode(i->second.first);
Reference<XNode> const xNode(rEntry.second.first);
OSL_ENSURE(!xNode.is(),
"CDocument::~CDocument(): ERROR: live node in document node map!");
}
......@@ -377,11 +376,9 @@ namespace DOM
}
// notify listeners about start
listenerlist_t::const_iterator iter1 = streamListeners.begin();
while (iter1 != streamListeners.end()) {
Reference< XStreamListener > aListener = *iter1;
for (const auto& rStreamListener : streamListeners) {
Reference< XStreamListener > aListener = rStreamListener;
aListener->started();
++iter1;
}
{
......@@ -398,11 +395,9 @@ namespace DOM
}
// call listeners
listenerlist_t::const_iterator iter2 = streamListeners.begin();
while (iter2 != streamListeners.end()) {
Reference< XStreamListener > aListener = *iter2;
for (const auto& rStreamListener : streamListeners) {
Reference< XStreamListener > aListener = rStreamListener;
aListener->closed();
++iter2;
}
}
......
......@@ -1491,13 +1491,11 @@ void SAL_CALL librdf_Repository::setStatementRDFa(
}
try
{
for (::std::vector< std::shared_ptr<librdf_TypeConverter::Resource> >
::iterator iter = predicates.begin(); iter != predicates.end();
++iter)
for (const auto& rPredicatePtr : predicates)
{
addStatementGraph_Lock(
librdf_TypeConverter::Statement(pSubject,
std::dynamic_pointer_cast<librdf_TypeConverter::URI>(*iter),
std::dynamic_pointer_cast<librdf_TypeConverter::URI>(rPredicatePtr),
pContent),
sContext, true);
}
......
......@@ -120,16 +120,14 @@ namespace XPath
xmlXPathContextPtr ctx,
const nsmap_t& nsmap)
{
nsmap_t::const_iterator i = nsmap.begin();
OString oprefix, ouri;
while (i != nsmap.end())
for (const auto& rEntry : nsmap)
{
oprefix = OUStringToOString(i->first, RTL_TEXTENCODING_UTF8);
ouri = OUStringToOString(i->second, RTL_TEXTENCODING_UTF8);
oprefix = OUStringToOString(rEntry.first, RTL_TEXTENCODING_UTF8);
ouri = OUStringToOString(rEntry.second, RTL_TEXTENCODING_UTF8);
xmlChar const *p = reinterpret_cast<xmlChar const *>(oprefix.getStr());
xmlChar const *u = reinterpret_cast<xmlChar const *>(ouri.getStr());
(void)xmlXPathRegisterNs(ctx, p, u);
++i;
}
}
......@@ -166,10 +164,9 @@ namespace XPath
{
nsmap_t namespaces;
lcl_collectNamespaces(namespaces, xNamespaceNode);
for (nsmap_t::const_iterator iter = namespaces.begin();
iter != namespaces.end(); ++iter)
for (const auto& rEntry : namespaces)
{
rAPI.registerNS(iter->first, iter->second);
rAPI.registerNS(rEntry.first, rEntry.second);
}
}
......@@ -179,10 +176,9 @@ namespace XPath
xmlXPathContextPtr ctx,
const extensions_t& extensions)
{
extensions_t::const_iterator i = extensions.begin();
while (i != extensions.end())
for (const auto& rExtensionRef : extensions)
{
Libxml2ExtensionHandle aHandle = (*i)->getLibxml2ExtensionHandle();
Libxml2ExtensionHandle aHandle = rExtensionRef->getLibxml2ExtensionHandle();
if ( aHandle.functionLookupFunction != 0 )
{
xmlXPathRegisterFuncLookup(ctx,
......@@ -199,7 +195,6 @@ namespace XPath
reinterpret_cast<void*>(
sal::static_int_cast<sal_IntPtr>(aHandle.variableData)));
}
++i;
}
}
......
......@@ -93,11 +93,9 @@ void FilterDialog::ChangeFilters( const FilterNameList* pFilterNames )
m_xLbFilters->clear();
if( m_pFilterNames != nullptr )
{
for( FilterNameListPtr pItem = m_pFilterNames->begin();
pItem != m_pFilterNames->end() ;
++pItem )
for( const auto& rItem : *m_pFilterNames )
{
m_xLbFilters->append_text(pItem->sUI);
m_xLbFilters->append_text(rItem.sUI);
}
}
}
......
......@@ -284,15 +284,8 @@ UUIInteractionHelper::tryOtherInteractionHandler(
InteractionHandlerDataList dataList;
getInteractionHandlerList(dataList);
InteractionHandlerDataList::const_iterator aEnd(dataList.end());
for (InteractionHandlerDataList::const_iterator aIt(dataList.begin());
aIt != aEnd;
++aIt)
{
if ( handleCustomRequest( rRequest, aIt->ServiceName ) )
return true;
}
return false;
return std::any_of(dataList.cbegin(), dataList.cend(),
[&](const InteractionHandlerData& rData) { return handleCustomRequest( rRequest, rData.ServiceName ); });
}
namespace
......
......@@ -73,13 +73,10 @@ public:
OUString findBuildinToolbar( const OUString& sToolbarName )
{
MSO2OOCommandbarMap::iterator it = maBuildinToolbarMap.begin();
for(; it != maBuildinToolbarMap.end(); ++it )
{
OUString sName = it->first;
if( sName.equalsIgnoreAsciiCase( sToolbarName ) )
return it->second;
}
auto it = std::find_if(maBuildinToolbarMap.begin(), maBuildinToolbarMap.end(),
[&sToolbarName](const MSO2OOCommandbarMap::value_type& rItem) { return rItem.first.equalsIgnoreAsciiCase( sToolbarName ); });
if( it != maBuildinToolbarMap.end() )
return it->second;
return OUString();
}
};
......
......@@ -344,9 +344,9 @@ VbaEventsHelperBase::ModulePathMap& VbaEventsHelperBase::updateModulePathMap( co
sal_Int32 nModuleType = getModuleType( rModuleName );
// search for all event handlers
ModulePathMap& rPathMap = maEventPaths[ rModuleName ];
for( EventHandlerInfoMap::iterator aIt = maEventInfos.begin(), aEnd = maEventInfos.end(); aIt != aEnd; ++aIt )
for( const auto& rEventInfo : maEventInfos )
{
const EventHandlerInfo& rInfo = aIt->second;
const EventHandlerInfo& rInfo = rEventInfo.second;
if( rInfo.mnModuleType == nModuleType )
rPathMap[ rInfo.mnEventId ] = resolveVBAMacro( mpShell, maLibraryName, rModuleName, rInfo.maMacroName );
}
......
......@@ -724,12 +724,9 @@ void setCursorHelper( const uno::Reference< frame::XModel >& xModel, const Point
}
}
for ( ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin();
controller != aControllers.end();
++controller
)
for ( const auto& rController : aControllers )
{
const uno::Reference< frame::XFrame > xFrame ( (*controller)->getFrame(), uno::UNO_SET_THROW );
const uno::Reference< frame::XFrame > xFrame ( rController->getFrame(), uno::UNO_SET_THROW );
const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment