summaryrefslogtreecommitdiff
path: root/svx/source/accessibility/ChildrenManagerImpl.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-06-29 13:24:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-29 22:08:38 +0200
commitd1ed54948ea3ffb43092d1748c1b6b53ce42fd3d (patch)
tree3d22e45adccde46a97d648d6f196a6e35c0d71f5 /svx/source/accessibility/ChildrenManagerImpl.cxx
parentee013bd6af5acb6a12f596a7b32e12cb42755efb (diff)
ChildrenManagerImpl::GetChildShape was clearly written very late at night
Because it takes something that could be looked up by index, and instead looks it up by scanning an entire vector. been this way since commit 60f11adb950e4f9645cc9ecb0f5af8235cc97366 Date: Wed Nov 27 13:03:45 2013 +0000 Integrate branch of IAccessible2 Change-Id: I32d06a98a6fa074c8f6385611e12e1a64d5b7f45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136632 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/accessibility/ChildrenManagerImpl.cxx')
-rw-r--r--svx/source/accessibility/ChildrenManagerImpl.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx
index b557e00a9000..56b47c74b710 100644
--- a/svx/source/accessibility/ChildrenManagerImpl.cxx
+++ b/svx/source/accessibility/ChildrenManagerImpl.cxx
@@ -114,12 +114,12 @@ tools::Long ChildrenManagerImpl::GetChildCount() const noexcept
css::uno::Reference<css::drawing::XShape> ChildrenManagerImpl::GetChildShape(tools::Long nIndex)
{
- uno::Reference<XAccessible> xAcc = GetChild(nIndex);
- auto I = std::find_if(maVisibleChildren.begin(), maVisibleChildren.end(),
- [&xAcc](const ChildDescriptor& rChild) { return rChild.mxAccessibleShape == xAcc; });
- if (I != maVisibleChildren.end())
- return I->mxShape;
- return uno::Reference< drawing::XShape > ();
+ // Check whether the given index is valid.
+ if (nIndex < 0 || o3tl::make_unsigned(nIndex) >= maVisibleChildren.size())
+ throw lang::IndexOutOfBoundsException (
+ "no accessible child with index " + OUString::number(nIndex),
+ mxParent);
+ return maVisibleChildren[nIndex].mxShape;
}
/** Return the requested accessible child object. Create it if it is not