summaryrefslogtreecommitdiff
path: root/framework/source/fwi
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 09:11:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-27 11:02:56 +0200
commitcc1ed7fbce20f90650f96acc2846b6f232c8ab0f (patch)
treefcd441cdf9568861363894f63107967adf571f81 /framework/source/fwi
parentb50f595b34585f2927adfd44b4eaaafb8f600972 (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')
-rw-r--r--framework/source/fwi/uielement/itemcontainer.cxx56
-rw-r--r--framework/source/fwi/uielement/rootitemcontainer.cxx54
2 files changed, 49 insertions, 61 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
diff --git a/framework/source/fwi/uielement/rootitemcontainer.cxx b/framework/source/fwi/uielement/rootitemcontainer.cxx
index 5b065a835f3c..72f41e761a1e 100644
--- a/framework/source/fwi/uielement/rootitemcontainer.cxx
+++ b/framework/source/fwi/uielement/rootitemcontainer.cxx
@@ -182,58 +182,52 @@ sal_Int32 SAL_CALL RootItemContainer::getCount()
Any SAL_CALL RootItemContainer::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 RootItemContainer::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 RootItemContainer::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 RootItemContainer::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;
}
Reference< XInterface > SAL_CALL RootItemContainer::createInstanceWithContext( const Reference< XComponentContext >& )