include/comphelper/interfacecontainer3.hxx | 12 ++++++++++++ svx/source/unodraw/unoshcol.cxx | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
New commits: commit 134cbe4c3b94a5ec46849abd1eef2c3acb5f789e Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Nov 28 16:16:37 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Nov 28 21:07:13 2021 +0100 use more OInterfaceContainerHelper3 in SvxShapeCollection which requires adding a getInterface method to OInterfaceContainerHelper3 Change-Id: I0962aa42c19859d7b78c998b8b4448a7ebfc19e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125981 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/comphelper/interfacecontainer3.hxx b/include/comphelper/interfacecontainer3.hxx index 82fa1f5e6b3d..9d4709918024 100644 --- a/include/comphelper/interfacecontainer3.hxx +++ b/include/comphelper/interfacecontainer3.hxx @@ -166,6 +166,9 @@ public: the new count of elements in the container */ sal_Int32 removeInterface(const css::uno::Reference<ListenerT>& rxIFace); + /** Return an interface by index + */ + const css::uno::Reference<ListenerT>& getInterface(sal_Int32 nIndex) const; /** Call disposing on all object in the container that support XEventListener. Then clear the container. @@ -319,6 +322,15 @@ sal_Int32 OInterfaceContainerHelper3<ListenerT>::removeInterface( return maData->size(); } +template <class ListenerT> +const css::uno::Reference<ListenerT>& +OInterfaceContainerHelper3<ListenerT>::getInterface(sal_Int32 nIndex) const +{ + osl::MutexGuard aGuard(rMutex); + + return (*maData)[nIndex]; +} + template <class ListenerT> void OInterfaceContainerHelper3<ListenerT>::disposeAndClear(const css::lang::EventObject& rEvt) { diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx index 450de874753b..80ad53cc1f88 100644 --- a/svx/source/unodraw/unoshcol.cxx +++ b/svx/source/unodraw/unoshcol.cxx @@ -26,7 +26,7 @@ #include <cppuhelper/implbase3.hxx> #include <cppuhelper/interfacecontainer.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <cppuhelper/supportsservice.hxx> #include <osl/mutex.hxx> #include <sal/log.hxx> @@ -47,7 +47,7 @@ class SvxShapeCollection : public SvxShapeCollectionMutex { private: - comphelper::OInterfaceContainerHelper2 maShapeContainer; + comphelper::OInterfaceContainerHelper3<drawing::XShape> maShapeContainer; cppu::OBroadcastHelper mrBHelper; @@ -213,8 +213,8 @@ uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index ) if( Index < 0 || Index >= getCount() ) throw lang::IndexOutOfBoundsException(); - Reference< uno::XInterface> xInterface = maShapeContainer.getInterface(Index); - return uno::makeAny( Reference< drawing::XShape>(static_cast< drawing::XShape* >( xInterface.get())) ); + Reference<drawing::XShape> xShape = maShapeContainer.getInterface(Index); + return uno::makeAny( xShape ); } // XElementAccess