diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-02-26 21:45:06 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-02-27 09:12:59 +0100 |
commit | 573f87f6ea57a248c79f52b1cd4e5f1978112567 (patch) | |
tree | d5425462ab8c9a4a0c2f18e8bf79fe6bef1380ac /configmgr | |
parent | 59363e639b67a8acbd6da240635de47921b2c955 (diff) |
Use for-range loops in comphelper and configmgr
Change-Id: I91033395cb30a4ba9e65adb89712b3c70a39a508
Reviewed-on: https://gerrit.libreoffice.org/50396
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/access.cxx | 148 | ||||
-rw-r--r-- | configmgr/source/components.cxx | 29 | ||||
-rw-r--r-- | configmgr/source/nodemap.cxx | 5 | ||||
-rw-r--r-- | configmgr/source/partial.cxx | 15 | ||||
-rw-r--r-- | configmgr/source/rootaccess.cxx | 10 | ||||
-rw-r--r-- | configmgr/source/writemodfile.cxx | 10 | ||||
-rw-r--r-- | configmgr/source/xcsparser.cxx | 28 |
7 files changed, 101 insertions, 144 deletions
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx index 718f6339967b..80ca2af1c9ce 100644 --- a/configmgr/source/access.cxx +++ b/configmgr/source/access.cxx @@ -413,11 +413,9 @@ css::uno::Sequence< OUString > Access::getElementNames() checkLocalizedPropertyAccess(); std::vector< rtl::Reference< ChildAccess > > children(getAllChildren()); std::vector<OUString> names; - for (std::vector< rtl::Reference< ChildAccess > >::iterator i( - children.begin()); - i != children.end(); ++i) + for (auto const& child : children) { - names.push_back((*i)->getNameInternal()); + names.push_back(child->getNameInternal()); } return comphelper::containerToSequence(names); } @@ -541,11 +539,9 @@ css::uno::Sequence< css::beans::Property > Access::getProperties() osl::MutexGuard g(*lock_); std::vector< rtl::Reference< ChildAccess > > children(getAllChildren()); std::vector< css::beans::Property > properties; - for (std::vector< rtl::Reference< ChildAccess > >::iterator i( - children.begin()); - i != children.end(); ++i) + for (auto const& child : children) { - properties.push_back((*i)->asProperty()); + properties.push_back(child->asProperty()); } return comphelper::containerToSequence(properties); } @@ -1226,50 +1222,42 @@ Access::~Access() {} void Access::initDisposeBroadcaster(Broadcaster * broadcaster) { assert(broadcaster != nullptr); - for (DisposeListeners::iterator i(disposeListeners_.begin()); - i != disposeListeners_.end(); ++i) + for (auto const& disposeListener : disposeListeners_) { broadcaster->addDisposeNotification( - *i, + disposeListener, css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); } - for (ContainerListeners::iterator i(containerListeners_.begin()); - i != containerListeners_.end(); ++i) + for (auto const& containerListener : containerListeners_) { broadcaster->addDisposeNotification( - i->get(), + containerListener.get(), css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); } - for (PropertyChangeListeners::iterator i(propertyChangeListeners_.begin()); - i != propertyChangeListeners_.end(); ++i) + for (auto const& propertyChangeListener : propertyChangeListeners_) { - for (PropertyChangeListenersElement::iterator j(i->second.begin()); - j != i->second.end(); ++j) + for (auto const& propertyChangeListenerElement : propertyChangeListener.second) { broadcaster->addDisposeNotification( - j->get(), + propertyChangeListenerElement.get(), css::lang::EventObject( static_cast< cppu::OWeakObject * >(this))); } } - for (VetoableChangeListeners::iterator i(vetoableChangeListeners_.begin()); - i != vetoableChangeListeners_.end(); ++i) + for (auto const& vetoableChangeListener : vetoableChangeListeners_) { - for (VetoableChangeListenersElement::iterator j(i->second.begin()); - j != i->second.end(); ++j) + for (auto const& vetoableChangeListenerElement : vetoableChangeListener.second) { broadcaster->addDisposeNotification( - j->get(), + vetoableChangeListenerElement.get(), css::lang::EventObject( static_cast< cppu::OWeakObject * >(this))); } } - for (PropertiesChangeListeners::iterator i( - propertiesChangeListeners_.begin()); - i != propertiesChangeListeners_.end(); ++i) + for (auto const& propertiesChangeListener : propertiesChangeListeners_) { broadcaster->addDisposeNotification( - i->get(), + propertiesChangeListener.get(), css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); } //TODO: iterate over children w/ listeners (incl. unmodified ones): @@ -1416,17 +1404,15 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) { locale.indexOf('_') == -1); std::vector< rtl::Reference< ChildAccess > > children( getAllChildren()); - for (std::vector< rtl::Reference< ChildAccess > >::iterator i( - children.begin()); - i != children.end(); ++i) + for (auto const& child : children) { - OUString name2((*i)->getNameInternal()); + OUString name2(child->getNameInternal()); if (name2.startsWith(locale) && (name2.getLength() == locale.getLength() || name2[locale.getLength()] == '-' || name2[locale.getLength()] == '_')) { - return *i; + return child; } } } @@ -1460,9 +1446,10 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) { std::vector< rtl::Reference< ChildAccess > > Access::getAllChildren() { std::vector< rtl::Reference< ChildAccess > > vec; NodeMap const & members = getNode()->getMembers(); - for (NodeMap::const_iterator i(members.begin()); i != members.end(); ++i) { - if (modifiedChildren_.find(i->first) == modifiedChildren_.end()) { - vec.push_back(getUnmodifiedChild(i->first)); + for (auto const& member : members) + { + if (modifiedChildren_.find(member.first) == modifiedChildren_.end()) { + vec.push_back(getUnmodifiedChild(member.first)); assert(vec.back().is()); } } @@ -1618,13 +1605,11 @@ void Access::initBroadcasterAndChanges( } else { //TODO: filter child mods that are irrelevant for // locale: - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster-> addContainerElementReplacedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >( this), @@ -1635,12 +1620,10 @@ void Access::initBroadcasterAndChanges( PropertyChangeListeners::iterator j( propertyChangeListeners_.find(i.first)); if (j != propertyChangeListeners_.end()) { - for (PropertyChangeListenersElement::iterator k( - j->second.begin()); - k != j->second.end(); ++k) + for (auto const& propertyChangeListenerElement : j->second) { broadcaster->addPropertyChangeNotification( - *k, + propertyChangeListenerElement, css::beans::PropertyChangeEvent( static_cast< cppu::OWeakObject * >( this), @@ -1650,12 +1633,10 @@ void Access::initBroadcasterAndChanges( } j = propertyChangeListeners_.find(""); if (j != propertyChangeListeners_.end()) { - for (PropertyChangeListenersElement::iterator k( - j->second.begin()); - k != j->second.end(); ++k) + for (auto const& propertyChangeListenerElement : j->second) { broadcaster->addPropertyChangeNotification( - *k, + propertyChangeListenerElement, css::beans::PropertyChangeEvent( static_cast< cppu::OWeakObject * >( this), @@ -1683,12 +1664,10 @@ void Access::initBroadcasterAndChanges( break; case Node::KIND_LOCALIZED_VALUE: assert(Components::allLocales(getRootAccess()->getLocale())); - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster->addContainerElementReplacedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >(this), css::uno::Any(i.first), child->asValue(), @@ -1707,12 +1686,10 @@ void Access::initBroadcasterAndChanges( break; case Node::KIND_PROPERTY: { - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster->addContainerElementReplacedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >(this), css::uno::Any(i.first), child->asValue(), @@ -1723,12 +1700,10 @@ void Access::initBroadcasterAndChanges( PropertyChangeListeners::iterator j( propertyChangeListeners_.find(i.first)); if (j != propertyChangeListeners_.end()) { - for (PropertyChangeListenersElement::iterator k( - j->second.begin()); - k != j->second.end(); ++k) + for (auto const& propertyChangeListenerElement : j->second) { broadcaster->addPropertyChangeNotification( - *k, + propertyChangeListenerElement, css::beans::PropertyChangeEvent( static_cast< cppu::OWeakObject * >(this), i.first, false, -1, css::uno::Any(), @@ -1737,12 +1712,10 @@ void Access::initBroadcasterAndChanges( } j = propertyChangeListeners_.find(""); if (j != propertyChangeListeners_.end()) { - for (PropertyChangeListenersElement::iterator k( - j->second.begin()); - k != j->second.end(); ++k) + for (auto const& propertyChangeListenerElement : j->second) { broadcaster->addPropertyChangeNotification( - *k, + propertyChangeListenerElement, css::beans::PropertyChangeEvent( static_cast< cppu::OWeakObject * >(this), i.first, false, -1, css::uno::Any(), @@ -1769,13 +1742,11 @@ void Access::initBroadcasterAndChanges( case Node::KIND_SET: if (i.second.children.empty()) { if (!child->getNode()->getTemplateName().isEmpty()) { - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster-> addContainerElementInsertedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >( this), @@ -1809,12 +1780,10 @@ void Access::initBroadcasterAndChanges( case Node::KIND_LOCALIZED_PROPERTY: // Removed localized property value: assert(Components::allLocales(getRootAccess()->getLocale())); - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster->addContainerElementRemovedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >(this), css::uno::Any(i.first), css::uno::Any(), @@ -1838,12 +1807,10 @@ void Access::initBroadcasterAndChanges( case Node::KIND_GROUP: { // Removed (non-localized) extension property: - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster->addContainerElementRemovedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >(this), css::uno::Any(i.first), css::uno::Any(), @@ -1853,12 +1820,10 @@ void Access::initBroadcasterAndChanges( PropertyChangeListeners::iterator j( propertyChangeListeners_.find(i.first)); if (j != propertyChangeListeners_.end()) { - for (PropertyChangeListenersElement::iterator k( - j->second.begin()); - k != j->second.end(); ++k) + for (auto const& propertyChangeListenerElement : j->second) { broadcaster->addPropertyChangeNotification( - *k, + propertyChangeListenerElement, css::beans::PropertyChangeEvent( static_cast< cppu::OWeakObject * >(this), i.first, false, -1, css::uno::Any(), @@ -1867,12 +1832,10 @@ void Access::initBroadcasterAndChanges( } j = propertyChangeListeners_.find(""); if (j != propertyChangeListeners_.end()) { - for (PropertyChangeListenersElement::iterator k( - j->second.begin()); - k != j->second.end(); ++k) + for (auto const& propertyChangeListenerElement : j->second) { broadcaster->addPropertyChangeNotification( - *k, + propertyChangeListenerElement, css::beans::PropertyChangeEvent( static_cast< cppu::OWeakObject * >(this), i.first, false, -1, css::uno::Any(), @@ -1903,12 +1866,10 @@ void Access::initBroadcasterAndChanges( case Node::KIND_SET: // Removed set member: if (i.second.children.empty()) { - for (ContainerListeners::iterator j( - containerListeners_.begin()); - j != containerListeners_.end(); ++j) + for (auto const& containerListener : containerListeners_) { broadcaster->addContainerElementRemovedNotification( - *j, + containerListener, css::container::ContainerEvent( static_cast< cppu::OWeakObject * >(this), css::uno::Any(i.first), @@ -1940,11 +1901,9 @@ void Access::initBroadcasterAndChanges( if (!propChanges.empty()) { css::uno::Sequence< css::beans::PropertyChangeEvent > seq( comphelper::containerToSequence(propChanges)); - for (PropertiesChangeListeners::iterator i( - propertiesChangeListeners_.begin()); - i != propertiesChangeListeners_.end(); ++i) + for (auto const& propertyChangeListener : propertiesChangeListeners_) { - broadcaster->addPropertiesChangeNotification(*i, seq); + broadcaster->addPropertiesChangeNotification(propertyChangeListener, seq); } } } @@ -2009,7 +1968,8 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { return rtl::Reference< ChildAccess >(); } std::vector<OUString> abs(getAbsolutePath()); - for (auto j(abs.begin()); j != abs.end(); ++j) { + for (auto const& elem : abs) + { OUString name1; bool setElement1; OUString templateName1; @@ -2021,7 +1981,7 @@ rtl::Reference< ChildAccess > Access::getSubChild(OUString const & path) { OUString name2; bool setElement2; OUString templateName2; - Data::parseSegment(*j, 0, &name2, &setElement2, &templateName2); + Data::parseSegment(elem, 0, &name2, &setElement2, &templateName2); if (name1 != name2 || setElement1 != setElement2 || (setElement1 && !Data::equalTemplateNames(templateName1, templateName2))) diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 5354763b0c95..3f99191bb2d4 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -130,10 +130,9 @@ bool canRemoveFromLayer(int layer, rtl::Reference< Node > const & node) { switch (node->kind()) { case Node::KIND_LOCALIZED_PROPERTY: case Node::KIND_GROUP: - for (NodeMap::const_iterator i(node->getMembers().begin()); - i != node->getMembers().end(); ++i) + for (auto const& member : node->getMembers()) { - if (!canRemoveFromLayer(layer, i->second)) { + if (!canRemoveFromLayer(layer, member.second)) { return false; } } @@ -241,19 +240,21 @@ void Components::initGlobalBroadcaster( rtl::Reference< RootAccess > const & exclude, Broadcaster * broadcaster) { //TODO: Iterate only over roots w/ listeners: - for (WeakRootSet::iterator i(roots_.begin()); i != roots_.end(); ++i) { + for (auto const& elemRoot : roots_) + { rtl::Reference< RootAccess > root; - if ((*i)->acquireCounting() > 1) { - root.set(*i); // must not throw + if (elemRoot->acquireCounting() > 1) { + root.set(elemRoot); // must not throw } - (*i)->releaseNondeleting(); + elemRoot->releaseNondeleting(); if (root.is()) { if (root != exclude) { std::vector<OUString> path(root->getAbsolutePath()); Modifications::Node const * mods = &modifications.getRoot(); - for (auto j(path.begin()); j != path.end(); ++j) { + for (auto const& pathElem : path) + { Modifications::Node::Children::const_iterator k( - mods->children.find(*j)); + mods->children.find(pathElem)); if (k == mods->children.end()) { mods = nullptr; break; @@ -362,9 +363,10 @@ void Components::removeExtensionXcuFile( rtl::Reference< Node > parent; NodeMap const * map = &data_.getComponents(); rtl::Reference< Node > node; - for (auto j(i->begin()); j != i->end(); ++j) { + for (auto const& j : *i) + { parent = node; - node = map->findNode(Data::NO_LAYER, *j); + node = map->findNode(Data::NO_LAYER, j); if (!node.is()) { break; } @@ -638,8 +640,9 @@ Components::~Components() flushModifications(); } - for (WeakRootSet::iterator i(roots_.begin()); i != roots_.end(); ++i) { - (*i)->setAlive(false); + for (auto const& rootElem : roots_) + { + rootElem->setAlive(false); } } diff --git a/configmgr/source/nodemap.cxx b/configmgr/source/nodemap.cxx index d2f3cffeb795..71c814138706 100644 --- a/configmgr/source/nodemap.cxx +++ b/configmgr/source/nodemap.cxx @@ -33,8 +33,9 @@ void NodeMap::cloneInto(NodeMap * target) const { assert(target != nullptr && target->empty()); NodeMapImpl clone(maImpl); - for (NodeMapImpl::iterator i(clone.begin()); i != clone.end(); ++i) { - i->second = i->second->clone(true); + for (auto & elem : clone) + { + elem.second = elem.second->clone(true); } std::swap(clone, target->maImpl); target->clearCache(); diff --git a/configmgr/source/partial.cxx b/configmgr/source/partial.cxx index cba7147aa8bc..911a2ae62d59 100644 --- a/configmgr/source/partial.cxx +++ b/configmgr/source/partial.cxx @@ -68,13 +68,12 @@ Partial::Partial( // * Inner node, !startInclude: contains in-/excluded sub-trees // * Leaf node, startInclude: an include starts here // * Leaf node, !startInclude: an exclude starts here - for (std::set< OUString >::const_iterator i(includedPaths.begin()); - i != includedPaths.end(); ++i) + for (auto const& includedPath : includedPaths) { sal_Int32 n = 0; for (Node * p = &root_;;) { OUString seg; - bool end = parseSegment(*i, &n, &seg); + bool end = parseSegment(includedPath, &n, &seg); p = &p->children[seg]; if (p->startInclude) { break; @@ -86,13 +85,12 @@ Partial::Partial( } } } - for (std::set< OUString >::const_iterator i(excludedPaths.begin()); - i != excludedPaths.end(); ++i) + for (auto const& excludedPath : excludedPaths) { sal_Int32 n = 0; for (Node * p = &root_;;) { OUString seg; - bool end = parseSegment(*i, &n, &seg); + bool end = parseSegment(excludedPath, &n, &seg); if (end) { p->children[seg].clear(); break; @@ -120,8 +118,9 @@ Partial::Containment Partial::contains(std::vector<OUString> const & path) const // ** If there is no startInclude along its trace: => CONTAINS_SUBNODES Node const * p = &root_; bool bIncludes = false; - for (auto i(path.begin()); i != path.end(); ++i) { - Node::Children::const_iterator j(p->children.find(*i)); + for (auto const& elemPath : path) + { + Node::Children::const_iterator j(p->children.find(elemPath)); if (j == p->children.end()) { return p->startInclude ? CONTAINS_NODE : CONTAINS_NOT; } diff --git a/configmgr/source/rootaccess.cxx b/configmgr/source/rootaccess.cxx index 4601cef9e908..8b707bbe87d1 100644 --- a/configmgr/source/rootaccess.cxx +++ b/configmgr/source/rootaccess.cxx @@ -80,13 +80,12 @@ void RootAccess::initBroadcaster( modifications, broadcaster, changesListeners_.empty() ? nullptr : &changes); if (!changes.empty()) { css::util::ChangesSet set(comphelper::containerToSequence(changes)); - for (ChangesListeners::iterator i(changesListeners_.begin()); - i != changesListeners_.end(); ++i) + for (auto const& changesListener : changesListeners_) { cppu::OWeakObject* pSource = static_cast< cppu::OWeakObject * >(this); css::uno::Reference< css::uno::XInterface > xBase( pSource, css::uno::UNO_QUERY ); broadcaster->addChangesNotification( - *i, + changesListener, css::util::ChangesEvent( pSource, css::uno::Any( xBase ), set)); } @@ -267,11 +266,10 @@ void RootAccess::addSupportedServiceNames( void RootAccess::initDisposeBroadcaster(Broadcaster * broadcaster) { assert(broadcaster != nullptr); - for (ChangesListeners::iterator i(changesListeners_.begin()); - i != changesListeners_.end(); ++i) + for (auto const& changesListener : changesListeners_) { broadcaster->addDisposeNotification( - i->get(), + changesListener.get(), css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); } Access::initDisposeBroadcaster(broadcaster); diff --git a/configmgr/source/writemodfile.cxx b/configmgr/source/writemodfile.cxx index e34b604dafd5..ffb1287b82da 100644 --- a/configmgr/source/writemodfile.cxx +++ b/configmgr/source/writemodfile.cxx @@ -334,10 +334,9 @@ void writeNode( handle.writeString("<prop oor:name=\""); writeAttributeValue(handle, name); handle.writeString("\" oor:op=\"fuse\">"); - for (NodeMap::const_iterator i(node->getMembers().begin()); - i != node->getMembers().end(); ++i) + for (auto const& member : node->getMembers()) { - writeNode(components, handle, node, i->first, i->second); + writeNode(components, handle, node, member.first, member.second); } handle.writeString("</prop>"); break; @@ -380,10 +379,9 @@ void writeNode( handle.writeString("\" oor:op=\"replace"); } handle.writeString("\">"); - for (NodeMap::const_iterator i(node->getMembers().begin()); - i != node->getMembers().end(); ++i) + for (auto const& member : node->getMembers()) { - writeNode(components, handle, node, i->first, i->second); + writeNode(components, handle, node, member.first, member.second); } handle.writeString("</node>"); break; diff --git a/configmgr/source/xcsparser.cxx b/configmgr/source/xcsparser.cxx index 50415391e55e..271d617e5019 100644 --- a/configmgr/source/xcsparser.cxx +++ b/configmgr/source/xcsparser.cxx @@ -67,40 +67,38 @@ void merge( case Node::KIND_LOCALIZED_VALUE: break; //TODO: merge certain parts? case Node::KIND_GROUP: - for (NodeMap::const_iterator i2(update->getMembers().begin()); - i2 != update->getMembers().end(); ++i2) + for (auto const& updateMember : update->getMembers()) { NodeMap & members = original->getMembers(); - NodeMap::iterator i1(members.find(i2->first)); + NodeMap::iterator i1(members.find(updateMember.first)); if (i1 == members.end()) { - if (i2->second->kind() == Node::KIND_PROPERTY && + if (updateMember.second->kind() == Node::KIND_PROPERTY && static_cast< GroupNode * >( original.get())->isExtensible()) { - members.insert(*i2); + members.insert(updateMember); } - } else if (i2->second->kind() == i1->second->kind()) { - merge(i1->second, i2->second); + } else if (updateMember.second->kind() == i1->second->kind()) { + merge(i1->second, updateMember.second); } } break; case Node::KIND_SET: - for (NodeMap::const_iterator i2(update->getMembers().begin()); - i2 != update->getMembers().end(); ++i2) + for (auto const& updateMember : update->getMembers()) { NodeMap & members = original->getMembers(); - NodeMap::iterator i1(members.find(i2->first)); + NodeMap::iterator i1(members.find(updateMember.first)); if (i1 == members.end()) { if (static_cast< SetNode * >(original.get())-> - isValidTemplate(i2->second->getTemplateName())) + isValidTemplate(updateMember.second->getTemplateName())) { - members.insert(*i2); + members.insert(updateMember); } - } else if (i2->second->kind() == i1->second->kind() && - (i2->second->getTemplateName() == + } else if (updateMember.second->kind() == i1->second->kind() && + (updateMember.second->getTemplateName() == i1->second->getTemplateName())) { - merge(i1->second, i2->second); + merge(i1->second, updateMember.second); } } break; |