diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-19 19:16:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-20 08:37:46 +0200 |
commit | 9a0faf09a8963556eafe172ae16735472f24659d (patch) | |
tree | 1791665f1840951aeebcfa85d3b525e839ab90a5 /cppuhelper | |
parent | 442c7b95e2ee94b66a9854d0cb22f8ecb76532c6 (diff) |
use for-range on Sequence in cppuhelper,cui
Change-Id: I482d48e29ddc9690d9c671cde2f6b0c611ec378d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94550
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/propertysetmixin.cxx | 52 | ||||
-rw-r--r-- | cppuhelper/source/servicemanager.cxx | 28 | ||||
-rw-r--r-- | cppuhelper/source/tdmgr.cxx | 16 | ||||
-rw-r--r-- | cppuhelper/source/typemanager.cxx | 19 |
4 files changed, 57 insertions, 58 deletions
diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx index 899567e85686..c7c8154896a4 100644 --- a/cppuhelper/source/propertysetmixin.cxx +++ b/cppuhelper/source/propertysetmixin.cxx @@ -137,26 +137,26 @@ void Data::initProperties( if (!seen->insert(ifc->getName()).second) return; - css::uno::Sequence< - css::uno::Reference< css::reflection::XTypeDescription > > bases( + const css::uno::Sequence< + css::uno::Reference< css::reflection::XTypeDescription > > bases( ifc->getBaseTypes()); - for (sal_Int32 i = 0; i < bases.getLength(); ++i) { - initProperties(bases[i], absentOptional, handleNames, seen); + for (const auto & i : bases) { + initProperties(i, absentOptional, handleNames, seen); } - css::uno::Sequence< - css::uno::Reference< - css::reflection::XInterfaceMemberTypeDescription > > members( + const css::uno::Sequence< + css::uno::Reference< + css::reflection::XInterfaceMemberTypeDescription > > members( ifc->getMembers()); OUString const * absentBegin = absentOptional.getConstArray(); OUString const * absentEnd = absentBegin + absentOptional.getLength(); - for (sal_Int32 i = 0; i < members.getLength(); ++i) { - if (members[i]->getTypeClass() + for (const auto & m : members) { + if (m->getTypeClass() == css::uno::TypeClass_INTERFACE_ATTRIBUTE) { css::uno::Reference< css::reflection::XInterfaceAttributeTypeDescription2 > attr( - members[i], css::uno::UNO_QUERY_THROW); + m, css::uno::UNO_QUERY_THROW); sal_Int16 attrAttribs = 0; if (attr->isBound()) { attrAttribs |= css::beans::PropertyAttribute::BOUND; @@ -174,19 +174,19 @@ void Data::initProperties( //XXX Special interpretation of getter/setter exceptions only // works if the specified exceptions are of the exact type, not // of a supertype: - for (sal_Int32 j = 0; j < excs.getLength(); ++j) { - if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" ) + for (const auto & ex : std::as_const(excs)) { + if ( ex->getName() == "com.sun.star.beans.UnknownPropertyException" ) { bGetUnknown = true; break; } } excs = attr->getSetExceptions(); - for (sal_Int32 j = 0; j < excs.getLength(); ++j) { - if ( excs[j]->getName() == "com.sun.star.beans.UnknownPropertyException" ) + for (const auto & ex : std::as_const(excs)) { + if ( ex->getName() == "com.sun.star.beans.UnknownPropertyException" ) { bSetUnknown = true; - } else if ( excs[j]->getName() == "com.sun.star.beans.PropertyVetoException" ) + } else if ( ex->getName() == "com.sun.star.beans.PropertyVetoException" ) { attrAttribs |= css::beans::PropertyAttribute::CONSTRAINED; @@ -239,7 +239,7 @@ void Data::initProperties( throw css::uno::RuntimeException( "interface type has too many attributes"); } - OUString name(members[i]->getMemberName()); + OUString name(m->getMemberName()); if (!properties.emplace( name, PropertyData( @@ -1117,23 +1117,23 @@ PropertySetMixinImpl::getPropertyValues() void PropertySetMixinImpl::setPropertyValues( css::uno::Sequence< css::beans::PropertyValue > const & props) { - for (sal_Int32 i = 0; i < props.getLength(); ++i) { - if (props[i].Handle != -1 - && (props[i].Name + for (const auto & p : props) { + if (p.Handle != -1 + && (p.Name != m_impl->translateHandle( static_cast< css::beans::XPropertySet * >(this), - props[i].Handle))) + p.Handle))) { throw css::beans::UnknownPropertyException( - ("name " + props[i].Name + " does not match handle " - + OUString::number(props[i].Handle)), + ("name " + p.Name + " does not match handle " + + OUString::number(p.Handle)), static_cast< css::beans::XPropertySet * >(this)); } m_impl->setProperty( - static_cast< css::beans::XPropertySet * >(this), props[i].Name, - props[i].Value, - props[i].State == css::beans::PropertyState_AMBIGUOUS_VALUE, - props[i].State == css::beans::PropertyState_DEFAULT_VALUE, 0); + static_cast< css::beans::XPropertySet * >(this), p.Name, + p.Value, + p.State == css::beans::PropertyState_AMBIGUOUS_VALUE, + p.State == css::beans::PropertyState_DEFAULT_VALUE, 0); } } diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index 00b9c40213d5..2ba6ae51a888 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -1001,29 +1001,29 @@ void cppuhelper::ServiceManager::insert(css::uno::Any const & aElement) if (aElement >>= args) { std::vector< OUString > uris; css::uno::Reference< css::uno::XComponentContext > alienContext; - for (sal_Int32 i = 0; i < args.getLength(); ++i) { - if (args[i].Name == "uri") { + for (const auto & arg : std::as_const(args)) { + if (arg.Name == "uri") { OUString uri; - if (!(args[i].Value >>= uri)) { + if (!(arg.Value >>= uri)) { throw css::lang::IllegalArgumentException( "Bad uri argument", static_cast< cppu::OWeakObject * >(this), 0); } uris.push_back(uri); - } else if (args[i].Name == "component-context") { + } else if (arg.Name == "component-context") { if (alienContext.is()) { throw css::lang::IllegalArgumentException( "Multiple component-context arguments", static_cast< cppu::OWeakObject * >(this), 0); } - if (!(args[i].Value >>= alienContext) || !alienContext.is()) { + if (!(arg.Value >>= alienContext) || !alienContext.is()) { throw css::lang::IllegalArgumentException( "Bad component-context argument", static_cast< cppu::OWeakObject * >(this), 0); } } else { throw css::lang::IllegalArgumentException( - "Bad argument " + args[i].Name, + "Bad argument " + arg.Name, static_cast< cppu::OWeakObject * >(this), 0); } } @@ -1063,14 +1063,14 @@ void cppuhelper::ServiceManager::remove(css::uno::Any const & aElement) css::uno::Sequence< css::beans::NamedValue > args; if (aElement >>= args) { std::vector< OUString > uris; - for (sal_Int32 i = 0; i < args.getLength(); ++i) { - if (args[i].Name != "uri") { + for (const auto & i : std::as_const(args)) { + if (i.Name != "uri") { throw css::lang::IllegalArgumentException( - "Bad argument " + args[i].Name, + "Bad argument " + i.Name, static_cast< cppu::OWeakObject * >(this), 0); } OUString uri; - if (!(args[i].Value >>= uri)) { + if (!(i.Value >>= uri)) { throw css::lang::IllegalArgumentException( "Bad uri argument", static_cast< cppu::OWeakObject * >(this), 0); @@ -1528,11 +1528,11 @@ void cppuhelper::ServiceManager::insertLegacyFactory( extra.namedImplementations.emplace(name, impl); } extra.dynamicImplementations.emplace(factoryInfo, impl); - css::uno::Sequence< OUString > services( + const css::uno::Sequence< OUString > services( factoryInfo->getSupportedServiceNames()); - for (sal_Int32 i = 0; i != services.getLength(); ++i) { - impl->services.push_back(services[i]); - extra.services[services[i]].push_back(impl); + for (const auto & i : services) { + impl->services.push_back(i); + extra.services[i].push_back(impl); } if (insertExtraData(extra) && comp.is()) { comp->addEventListener(this); diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx index e11b6d6077f3..1e5826e248c7 100644 --- a/cppuhelper/source/tdmgr.cxx +++ b/cppuhelper/source/tdmgr.cxx @@ -204,20 +204,20 @@ static typelib_TypeDescription * createCTD( Reference< XTypeDescription > xType( xAttribute->getType() ); OUString aMemberTypeName( xType->getName() ); std::vector< rtl_uString * > getExc; - Sequence< Reference< XCompoundTypeDescription > > getExcs( + const Sequence< Reference< XCompoundTypeDescription > > getExcs( xAttribute->getGetExceptions() ); - for (sal_Int32 i = 0; i != getExcs.getLength(); ++i) + for (const auto & ctd : getExcs) { - OSL_ASSERT( getExcs[i].is() ); - getExc.push_back( getExcs[i]->getName().pData ); + OSL_ASSERT( ctd.is() ); + getExc.push_back( ctd->getName().pData ); } std::vector< rtl_uString * > setExc; - Sequence< Reference< XCompoundTypeDescription > > setExcs( + const Sequence< Reference< XCompoundTypeDescription > > setExcs( xAttribute->getSetExceptions() ); - for (sal_Int32 i = 0; i != setExcs.getLength(); ++i) + for (const auto & ctd : setExcs) { - OSL_ASSERT( setExcs[i].is() ); - setExc.push_back( setExcs[i]->getName().pData ); + OSL_ASSERT( ctd.is() ); + setExc.push_back( ctd->getName().pData ); } typelib_typedescription_newExtendedInterfaceAttribute( reinterpret_cast<typelib_InterfaceAttributeTypeDescription **>(&pRet), diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx index f3fa99ac9769..3a3866b60f6d 100644 --- a/cppuhelper/source/typemanager.cxx +++ b/cppuhelper/source/typemanager.cxx @@ -838,13 +838,13 @@ void BaseOffset::calculateBases( css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > const & description) { - css::uno::Sequence< + const css::uno::Sequence< css::uno::Reference < css::reflection::XTypeDescription > > bases( description->getBaseTypes()); - for (sal_Int32 i = 0; i != bases.getLength(); ++i) { + for (const auto & i : bases) { calculate( css::uno::Reference< css::reflection::XInterfaceTypeDescription2 >( - resolveTypedefs(css::uno::makeAny(bases[i])), + resolveTypedefs(css::uno::makeAny(i)), css::uno::UNO_QUERY_THROW)); } } @@ -1693,8 +1693,8 @@ bool Enumeration::matches(css::uno::TypeClass tc) const { if (!types_.hasElements()) { return true; } - for (sal_Int32 i = 0; i != types_.getLength(); ++i) { - if (types_[i] == tc) { + for (const auto & i : types_) { + if (i == tc) { return true; } } @@ -2133,15 +2133,14 @@ css::uno::Any cppuhelper::TypeManager::getInterfaceMember( return css::uno::Any(); } OUString member(name.copy(separator + std::strlen("::"))); - css::uno::Sequence< + const css::uno::Sequence< css::uno::Reference< css::reflection::XInterfaceMemberTypeDescription > > mems( ifc->getMembers()); - for (sal_Int32 i = 0; i != mems.getLength(); ++i) { - if (mems[i]->getMemberName() == member) { + for (const auto & m : mems) { + if (m->getMemberName() == member) { return css::uno::makeAny< - css::uno::Reference< css::reflection::XTypeDescription > >( - mems[i]); + css::uno::Reference< css::reflection::XTypeDescription > >(m); } } return css::uno::Any(); |