From 392f19c957b55de1ce834cb465f51f27c2c7cf60 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 17 Aug 2021 18:48:06 +0200 Subject: improve SvxShapeCollection::getByIndex Change-Id: I4cca7c0b6344241256d038902069a20ece314358 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120618 Tested-by: Jenkins Reviewed-by: Noel Grandin --- comphelper/source/container/interfacecontainer2.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'comphelper') 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 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 ); -- cgit