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 /framework/source/fwi/uielement/itemcontainer.cxx | |
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 'framework/source/fwi/uielement/itemcontainer.cxx')
-rw-r--r-- | framework/source/fwi/uielement/itemcontainer.cxx | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/framework/source/fwi/uielement/itemcontainer.cxx b/framework/source/fwi/uielement/itemcontainer.cxx index fd9149376162..ec57f33b07a4 100644 --- a/framework/source/fwi/uielement/itemcontainer.cxx +++ b/framework/source/fwi/uielement/itemcontainer.cxx @@ -166,60 +166,54 @@ sal_Int32 SAL_CALL ItemContainer::getCount() Any SAL_CALL ItemContainer::getByIndex( sal_Int32 Index ) { ShareGuard aLock( m_aShareMutex ); - if ( sal_Int32( m_aItemVector.size()) > Index ) - return makeAny( m_aItemVector[Index] ); - else + if ( sal_Int32( m_aItemVector.size()) <= Index ) throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + return makeAny( m_aItemVector[Index] ); } // XIndexContainer void SAL_CALL ItemContainer::insertByIndex( sal_Int32 Index, const Any& aItem ) { Sequence< PropertyValue > aSeq; - if ( aItem >>= aSeq ) + if ( !(aItem >>= aSeq) ) + throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, + static_cast<OWeakObject *>(this), 2 ); + + ShareGuard aLock( m_aShareMutex ); + if ( sal_Int32( m_aItemVector.size()) == Index ) + m_aItemVector.push_back( aSeq ); + else if ( sal_Int32( m_aItemVector.size()) >Index ) { - ShareGuard aLock( m_aShareMutex ); - if ( sal_Int32( m_aItemVector.size()) == Index ) - m_aItemVector.push_back( aSeq ); - else if ( sal_Int32( m_aItemVector.size()) >Index ) - { - std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin(); - aIter += Index; - m_aItemVector.insert( aIter, aSeq ); - } - else - throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + std::vector< Sequence< PropertyValue > >::iterator aIter = m_aItemVector.begin(); + aIter += Index; + m_aItemVector.insert( aIter, aSeq ); } else - throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, - static_cast<OWeakObject *>(this), 2 ); + throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); } void SAL_CALL ItemContainer::removeByIndex( sal_Int32 nIndex ) { ShareGuard aLock( m_aShareMutex ); - if ( (sal_Int32)m_aItemVector.size() > nIndex ) - { - m_aItemVector.erase(m_aItemVector.begin() + nIndex); - } - else + if ( (sal_Int32)m_aItemVector.size() <= nIndex ) throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + m_aItemVector.erase(m_aItemVector.begin() + nIndex); } void SAL_CALL ItemContainer::replaceByIndex( sal_Int32 Index, const Any& aItem ) { Sequence< PropertyValue > aSeq; - if ( aItem >>= aSeq ) - { - ShareGuard aLock( m_aShareMutex ); - if ( sal_Int32( m_aItemVector.size()) > Index ) - m_aItemVector[Index] = aSeq; - else - throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); - } - else + if ( !(aItem >>= aSeq) ) throw IllegalArgumentException( WRONG_TYPE_EXCEPTION, static_cast<OWeakObject *>(this), 2 ); + + ShareGuard aLock( m_aShareMutex ); + if ( !(sal_Int32( m_aItemVector.size()) > Index) ) + throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + m_aItemVector[Index] = aSeq; } } // namespace framework |