From 2a612907aef4c9987f906c6b98aa9b400f58f617 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 20 Sep 2017 16:14:49 +0200 Subject: loplugin:flatten in connectivity..desktop Change-Id: Iff59d3049ba40b4338ef8eec67d08a96b0834d2b Reviewed-on: https://gerrit.libreoffice.org/42578 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cppuhelper/source/servicemanager.cxx | 48 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx index c77526de6441..7e6c178c4e7c 100644 --- a/cppuhelper/source/servicemanager.cxx +++ b/cppuhelper/source/servicemanager.cxx @@ -410,23 +410,22 @@ rtl::OUString Parser::getNameAttribute() { xmlreader::Span name; int nsId; while (reader_.nextAttribute(&nsId, &name)) { - if (nsId == xmlreader::XmlReader::NAMESPACE_NONE - && name.equals(RTL_CONSTASCII_STRINGPARAM("name"))) + if (nsId != xmlreader::XmlReader::NAMESPACE_NONE + || !name.equals(RTL_CONSTASCII_STRINGPARAM("name"))) { - if (!attrName.isEmpty()) { - throw css::registry::InvalidRegistryException( - reader_.getUrl() - + ": element has multiple \"name\" attributes"); - } - attrName = reader_.getAttributeValue(false).convertFromUtf8(); - if (attrName.isEmpty()) { - throw css::registry::InvalidRegistryException( - reader_.getUrl() + ": element has empty \"name\" attribute"); - } - } else { throw css::registry::InvalidRegistryException( reader_.getUrl() + ": expected element attribute \"name\""); } + if (!attrName.isEmpty()) { + throw css::registry::InvalidRegistryException( + reader_.getUrl() + + ": element has multiple \"name\" attributes"); + } + attrName = reader_.getAttributeValue(false).convertFromUtf8(); + if (attrName.isEmpty()) { + throw css::registry::InvalidRegistryException( + reader_.getUrl() + ": element has empty \"name\" attribute"); + } } if (attrName.isEmpty()) { throw css::registry::InvalidRegistryException( @@ -910,15 +909,14 @@ void cppuhelper::ServiceManager::initialize( css::uno::Sequence const & aArguments) { OUString arg; - if (aArguments.getLength() == 1 && (aArguments[0] >>= arg) - && arg == "preload") + if (aArguments.getLength() != 1 || !(aArguments[0] >>= arg) + || arg != "preload") { - preloadImplementations(); - } else { throw css::lang::IllegalArgumentException( "invalid ServiceManager::initialize argument", css::uno::Reference(), 0); } + preloadImplementations(); } rtl::OUString cppuhelper::ServiceManager::getImplementationName() @@ -1106,19 +1104,17 @@ void cppuhelper::ServiceManager::remove(css::uno::Any const & aElement) if (aElement >>= args) { std::vector< rtl::OUString > uris; for (sal_Int32 i = 0; i < args.getLength(); ++i) { - if (args[i].Name == "uri") { - rtl::OUString uri; - if (!(args[i].Value >>= uri)) { - throw css::lang::IllegalArgumentException( - "Bad uri argument", - static_cast< cppu::OWeakObject * >(this), 0); - } - uris.push_back(uri); - } else { + if (args[i].Name != "uri") { throw css::lang::IllegalArgumentException( "Bad argument " + args[i].Name, static_cast< cppu::OWeakObject * >(this), 0); + } rtl::OUString uri; + if (!(args[i].Value >>= uri)) { + throw css::lang::IllegalArgumentException( + "Bad uri argument", + static_cast< cppu::OWeakObject * >(this), 0); } + uris.push_back(uri); } removeRdbFiles(uris); return; -- cgit