summaryrefslogtreecommitdiff
path: root/framework/source/fwi/uielement/rootitemcontainer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/fwi/uielement/rootitemcontainer.cxx')
-rw-r--r--framework/source/fwi/uielement/rootitemcontainer.cxx54
1 files changed, 24 insertions, 30 deletions
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 >& )