diff options
Diffstat (limited to 'framework/source/fwe/helper/propertysetcontainer.cxx')
-rw-r--r-- | framework/source/fwe/helper/propertysetcontainer.cxx | 83 |
1 files changed, 34 insertions, 49 deletions
diff --git a/framework/source/fwe/helper/propertysetcontainer.cxx b/framework/source/fwe/helper/propertysetcontainer.cxx index 9f856691e343..5051d776f470 100644 --- a/framework/source/fwe/helper/propertysetcontainer.cxx +++ b/framework/source/fwe/helper/propertysetcontainer.cxx @@ -79,64 +79,54 @@ void SAL_CALL PropertySetContainer::insertByIndex( sal_Int32 Index, const css::u sal_Int32 nSize = m_aPropertySetVector.size(); - if ( nSize >= Index ) + if ( nSize < Index ) + throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + Reference< XPropertySet > aPropertySetElement; + + if ( !(Element >>= aPropertySetElement) ) { - Reference< XPropertySet > aPropertySetElement; - - if ( Element >>= aPropertySetElement ) - { - if ( nSize == Index ) - m_aPropertySetVector.push_back( aPropertySetElement ); - else - { - PropertySetVector::iterator aIter = m_aPropertySetVector.begin(); - aIter += Index; - m_aPropertySetVector.insert( aIter, aPropertySetElement ); - } - } - else - { - throw IllegalArgumentException( - WRONG_TYPE_EXCEPTION, - static_cast<OWeakObject *>(this), 2 ); - } + throw IllegalArgumentException( + WRONG_TYPE_EXCEPTION, + static_cast<OWeakObject *>(this), 2 ); } + + if ( nSize == Index ) + m_aPropertySetVector.push_back( aPropertySetElement ); else - throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + { + PropertySetVector::iterator aIter = m_aPropertySetVector.begin(); + aIter += Index; + m_aPropertySetVector.insert( aIter, aPropertySetElement ); + } } void SAL_CALL PropertySetContainer::removeByIndex( sal_Int32 nIndex ) { SolarMutexGuard g; - if ( (sal_Int32)m_aPropertySetVector.size() > nIndex ) - { - m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex); - } - else + if ( !((sal_Int32)m_aPropertySetVector.size() > nIndex) ) throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + m_aPropertySetVector.erase(m_aPropertySetVector.begin() + nIndex); } // XIndexReplace void SAL_CALL PropertySetContainer::replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) { - if ( (sal_Int32)m_aPropertySetVector.size() > Index ) + if ( !((sal_Int32)m_aPropertySetVector.size() > Index) ) + throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + Reference< XPropertySet > aPropertySetElement; + + if ( !(Element >>= aPropertySetElement) ) { - Reference< XPropertySet > aPropertySetElement; - - if ( Element >>= aPropertySetElement ) - { - m_aPropertySetVector[ Index ] = aPropertySetElement; - } - else - { - throw IllegalArgumentException( - WRONG_TYPE_EXCEPTION, - static_cast<OWeakObject *>(this), 2 ); - } + throw IllegalArgumentException( + WRONG_TYPE_EXCEPTION, + static_cast<OWeakObject *>(this), 2 ); } - else - throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + m_aPropertySetVector[ Index ] = aPropertySetElement; } // XIndexAccess @@ -151,15 +141,10 @@ Any SAL_CALL PropertySetContainer::getByIndex( sal_Int32 Index ) { SolarMutexGuard g; - if ( (sal_Int32)m_aPropertySetVector.size() > Index ) - { - Any a; - - a <<= m_aPropertySetVector[ Index ]; - return a; - } - else + if ( (sal_Int32)m_aPropertySetVector.size() <= Index ) throw IndexOutOfBoundsException( OUString(), static_cast<OWeakObject *>(this) ); + + return Any(m_aPropertySetVector[ Index ]); } // XElementAccess |