diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-17 18:48:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-18 10:41:34 +0200 |
commit | 392f19c957b55de1ce834cb465f51f27c2c7cf60 (patch) | |
tree | 20ffca6114a023bd2114436323e1c640c25b6ba3 /comphelper | |
parent | 2665fe320363d03559cd29e75b78077b4a78e91f (diff) |
improve SvxShapeCollection::getByIndex
Change-Id: I4cca7c0b6344241256d038902069a20ece314358
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120618
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/container/interfacecontainer2.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/comphelper/source/container/interfacecontainer2.cxx b/comphelper/source/container/interfacecontainer2.cxx index 9ad26cc64cea..0881ccbe44cf 100644 --- a/comphelper/source/container/interfacecontainer2.cxx +++ b/comphelper/source/container/interfacecontainer2.cxx @@ -240,6 +240,20 @@ sal_Int32 OInterfaceContainerHelper2::removeInterface( const Reference<XInterfac return aData.pAsInterface ? 1 : 0; } +Reference<XInterface> OInterfaceContainerHelper2::getInterface( sal_Int32 nIndex ) const +{ + MutexGuard aGuard( rMutex ); + + if( bIsList ) + return (*aData.pAsVector)[nIndex]; + else if( aData.pAsInterface ) + { + if (nIndex == 0) + return aData.pAsInterface; + } + throw std::out_of_range("index out of range"); +} + void OInterfaceContainerHelper2::disposeAndClear( const EventObject & rEvt ) { ClearableMutexGuard aGuard( rMutex ); |