diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-27 09:11:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-27 11:02:56 +0200 |
commit | cc1ed7fbce20f90650f96acc2846b6f232c8ab0f (patch) | |
tree | fcd441cdf9568861363894f63107967adf571f81 /forms | |
parent | b50f595b34585f2927adfd44b4eaaafb8f600972 (diff) |
loplugin:flatten in various
Change-Id: I42dca691ffadbddad38a7e8f978b1da9d5d9a7b0
Reviewed-on: https://gerrit.libreoffice.org/42842
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/xforms/NameContainer.hxx | 25 | ||||
-rw-r--r-- | forms/source/xforms/binding.cxx | 26 | ||||
-rw-r--r-- | forms/source/xforms/collection.hxx | 35 | ||||
-rw-r--r-- | forms/source/xforms/namedcollection.hxx | 6 |
4 files changed, 38 insertions, 54 deletions
diff --git a/forms/source/xforms/NameContainer.hxx b/forms/source/xforms/NameContainer.hxx index f5aad0950ea2..99a667a1baca 100644 --- a/forms/source/xforms/NameContainer.hxx +++ b/forms/source/xforms/NameContainer.hxx @@ -127,13 +127,11 @@ public: const css::uno::Any& aElement ) override { T aItem; - if( aElement >>= aItem ) - if( hasByName( rName ) ) - replace( rName, aItem ); - else - throw css::container::NoSuchElementException(); - else + if( !(aElement >>= aItem) ) throw css::lang::IllegalArgumentException(); + if( !hasByName( rName ) ) + throw css::container::NoSuchElementException(); + replace( rName, aItem ); } @@ -145,22 +143,19 @@ public: const css::uno::Any& aElement ) override { T aItem; - if( aElement >>= aItem ) - if( ! hasByName( rName ) ) - insert( rName, aItem ); - else - throw css::container::ElementExistException(); - else + if( !(aElement >>= aItem) ) throw css::lang::IllegalArgumentException(); + if( hasByName( rName ) ) + throw css::container::ElementExistException(); + insert( rName, aItem ); } virtual void SAL_CALL removeByName( const OUString& rName ) override { - if( hasByName( rName ) ) - remove( rName ); - else + if( !hasByName( rName ) ) throw css::container::NoSuchElementException(); + remove( rName ); } }; diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx index 247286ad643d..2b9cc9f97390 100644 --- a/forms/source/xforms/binding.cxx +++ b/forms/source/xforms/binding.cxx @@ -1028,21 +1028,19 @@ void Binding::setValue( const css::uno::Any& aValue ) if( ! supportsType( aValue.getValueType() ) ) throw IncompatibleTypesException( EXCEPT( "type unsupported" ) ); - if( maBindingExpression.hasValue() ) - { - css::uno::Reference<css::xml::dom::XNode> xNode = maBindingExpression.getNode(); - if( xNode.is() ) - { - OUString sValue = Convert::get().toXSD( aValue ); - bool bSuccess = getModelImpl()->setSimpleContent( xNode, sValue ); - if( ! bSuccess ) - throw InvalidBindingStateException( EXCEPT( "can't set value" ) ); - } - else - throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) ); - } - else + if( !maBindingExpression.hasValue() ) throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) ); + + css::uno::Reference<css::xml::dom::XNode> xNode = maBindingExpression.getNode(); + if( !xNode.is() ) + throw InvalidBindingStateException( EXCEPT( "no suitable node found" ) ); + + OUString sValue = Convert::get().toXSD( aValue ); + bool bSuccess = getModelImpl()->setSimpleContent( xNode, sValue ); + if( ! bSuccess ) + throw InvalidBindingStateException( EXCEPT( "can't set value" ) ); + + } diff --git a/forms/source/xforms/collection.hxx b/forms/source/xforms/collection.hxx index fe40dc4c9633..f38d75ce458c 100644 --- a/forms/source/xforms/collection.hxx +++ b/forms/source/xforms/collection.hxx @@ -162,10 +162,9 @@ public: virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override { - if( isValidIndex( nIndex ) ) - return css::uno::makeAny( getItem( nIndex ) ); - else + if( !isValidIndex( nIndex ) ) throw css::lang::IndexOutOfBoundsException(); + return css::uno::makeAny( getItem( nIndex ) ); } // XIndexReplace : XIndexAccess @@ -173,13 +172,11 @@ public: const css::uno::Any& aElement ) override { T t; - if( isValidIndex( nIndex) ) - if( ( aElement >>= t ) && isValid( t ) ) - setItem( nIndex, t ); - else - throw css::lang::IllegalArgumentException(); - else + if( !isValidIndex( nIndex) ) throw css::lang::IndexOutOfBoundsException(); + if( !( aElement >>= t ) || !isValid( t ) ) + throw css::lang::IllegalArgumentException(); + setItem( nIndex, t ); } // XEnumerationAccess : XElementAccess @@ -199,25 +196,21 @@ public: virtual void SAL_CALL insert( const css::uno::Any& aElement ) override { T t; - if( ( aElement >>= t ) && isValid( t ) ) - if( ! hasItem( t ) ) - addItem( t ); - else - throw css::container::ElementExistException(); - else + if( !( aElement >>= t ) || !isValid( t ) ) throw css::lang::IllegalArgumentException(); + if( hasItem( t ) ) + throw css::container::ElementExistException(); + addItem( t ); } virtual void SAL_CALL remove( const css::uno::Any& aElement ) override { T t; - if( aElement >>= t ) - if( hasItem( t ) ) - removeItem( t ); - else - throw css::container::NoSuchElementException(); - else + if( !(aElement >>= t) ) throw css::lang::IllegalArgumentException(); + if( !hasItem( t ) ) + throw css::container::NoSuchElementException(); + removeItem( t ); } diff --git a/forms/source/xforms/namedcollection.hxx b/forms/source/xforms/namedcollection.hxx index c0a31bd99b83..7546ba271035 100644 --- a/forms/source/xforms/namedcollection.hxx +++ b/forms/source/xforms/namedcollection.hxx @@ -98,11 +98,9 @@ public: virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override { - if( hasItem( aName ) ) - return css::uno::makeAny( getItem( aName ) ); - else + if( !hasItem( aName ) ) throw css::container::NoSuchElementException(); - + return css::uno::makeAny( getItem( aName ) ); } virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() override |