diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-20 15:03:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-21 15:18:57 +0200 |
commit | ac80f048f2bb23651ddc3c6608e9ef24635698d7 (patch) | |
tree | 925ece62dd2e859170d1267d8e7122c4f9b762e8 /comphelper/source/container/IndexedPropertyValuesContainer.cxx | |
parent | b5450f4afe2af6620fbbbdf686853dfa3293ff90 (diff) |
loplugin:flatten in basctl..configmgr
Change-Id: I674cad57ce30a885e126d3bcc921f8fcb53dc36d
Reviewed-on: https://gerrit.libreoffice.org/42577
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper/source/container/IndexedPropertyValuesContainer.cxx')
-rw-r--r-- | comphelper/source/container/IndexedPropertyValuesContainer.cxx | 92 |
1 files changed, 43 insertions, 49 deletions
diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx b/comphelper/source/container/IndexedPropertyValuesContainer.cxx index d577ebe1ca24..1853ba71918b 100644 --- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx +++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx @@ -70,47 +70,15 @@ IndexedPropertyValuesContainer::IndexedPropertyValuesContainer() throw() void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( sal_Int32 nIndex, const css::uno::Any& aElement ) { sal_Int32 nSize(maProperties.size()); - if ((nSize >= nIndex) && (nIndex >= 0)) - { - uno::Sequence<beans::PropertyValue> aProps; - if (!(aElement >>= aProps)) - throw lang::IllegalArgumentException(); - if (nSize == nIndex) - maProperties.push_back(aProps); - else - { - IndexedPropertyValues::iterator aItr; - if ((nIndex * 2) < nSize) - { - aItr = maProperties.begin(); - sal_Int32 i(0); - while(i < nIndex) - { - ++i; - ++aItr; - } - } - else - { - aItr = maProperties.end(); - sal_Int32 i(nSize); - while(i > nIndex) - { - --i; - --aItr; - } - } - maProperties.insert(aItr, aProps); - } - } - else + if ((nSize < nIndex) || (nIndex < 0)) throw lang::IndexOutOfBoundsException(); -} -void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex ) -{ - sal_Int32 nSize(maProperties.size()); - if ((nIndex < nSize) && (nIndex >= 0)) + uno::Sequence<beans::PropertyValue> aProps; + if (!(aElement >>= aProps)) + throw lang::IllegalArgumentException(); + if (nSize == nIndex) + maProperties.push_back(aProps); + else { IndexedPropertyValues::iterator aItr; if ((nIndex * 2) < nSize) @@ -133,25 +101,51 @@ void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex ) --aItr; } } - maProperties.erase(aItr); + maProperties.insert(aItr, aProps); } - else - throw lang::IndexOutOfBoundsException(); } -// XIndexReplace -void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, const css::uno::Any& aElement ) +void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex ) { sal_Int32 nSize(maProperties.size()); - if ((nIndex < nSize) && (nIndex >= 0)) + if ((nIndex >= nSize) || (nIndex < 0)) + throw lang::IndexOutOfBoundsException(); + + IndexedPropertyValues::iterator aItr; + if ((nIndex * 2) < nSize) { - uno::Sequence<beans::PropertyValue> aProps; - if (!(aElement >>= aProps)) - throw lang::IllegalArgumentException(); - maProperties[nIndex] = aProps; + aItr = maProperties.begin(); + sal_Int32 i(0); + while(i < nIndex) + { + ++i; + ++aItr; + } } else + { + aItr = maProperties.end(); + sal_Int32 i(nSize); + while(i > nIndex) + { + --i; + --aItr; + } + } + maProperties.erase(aItr); +} + +// XIndexReplace +void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, const css::uno::Any& aElement ) +{ + sal_Int32 nSize(maProperties.size()); + if ((nIndex >= nSize) || (nIndex < 0)) throw lang::IndexOutOfBoundsException(); + + uno::Sequence<beans::PropertyValue> aProps; + if (!(aElement >>= aProps)) + throw lang::IllegalArgumentException(); + maProperties[nIndex] = aProps; } // XIndexAccess |