diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-26 11:53:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-27 10:28:52 +0100 |
commit | 980c859480be431311ba803c5251694160dcb3d5 (patch) | |
tree | 57766be2cf7a0867e90148a3cb4ee32fc925d0d2 /sw | |
parent | 2fcc04722d72dbadf8d3decd7a5014ec39b93d27 (diff) |
tdf#108642 load accessibility children faster
Reduces the cost of repeatedly iterating over the page objects, by
adding a new XAccessibleContext3 interface to return accesibility
children in one call.
This takes the load time from 5.6s to 3.2s.
Change-Id: Ifcc20fa7e7ab8ad50417073882c8c3a2405d1eaa
Reviewed-on: https://gerrit.libreoffice.org/83850
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/access/acccontext.cxx | 42 | ||||
-rw-r--r-- | sw/source/core/access/acccontext.hxx | 5 |
2 files changed, 47 insertions, 0 deletions
diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index d3bb318584b5..0e8d45f91a24 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -620,6 +620,48 @@ uno::Reference< XAccessible> SAL_CALL return xChild; } +css::uno::Sequence<uno::Reference<XAccessible>> SAL_CALL + SwAccessibleContext::getAccessibleChildren() +{ + SolarMutexGuard aGuard; + + ThrowIfDisposed(); + + std::list< sw::access::SwAccessibleChild > aChildren; + GetChildren( *GetMap(), aChildren ); + + std::vector<uno::Reference<XAccessible>> aRet; + aRet.reserve(aChildren.size()); + for (const auto & rSwChild : aChildren) + { + uno::Reference< XAccessible > xChild; + if( rSwChild.GetSwFrame() ) + { + ::rtl::Reference < SwAccessibleContext > xChildImpl( + GetMap()->GetContextImpl( rSwChild.GetSwFrame(), !m_isDisposing ) ); + if( xChildImpl.is() ) + { + xChildImpl->SetParent( this ); + xChild = xChildImpl.get(); + } + } + else if ( rSwChild.GetDrawObject() ) + { + ::rtl::Reference < ::accessibility::AccessibleShape > xChildImpl( + GetMap()->GetContextImpl( rSwChild.GetDrawObject(), + this, !m_isDisposing) ); + if( xChildImpl.is() ) + xChild = xChildImpl.get(); + } + else if ( rSwChild.GetWindow() ) + { + xChild = rSwChild.GetWindow()->GetAccessible(); + } + aRet.push_back(xChild); + } + return comphelper::containerToSequence(aRet); +} + uno::Reference< XAccessible> SwAccessibleContext::getAccessibleParentImpl() { SolarMutexGuard aGuard; diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index 52dfe42827d9..ddbc019b2e6a 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -23,6 +23,7 @@ #include "accframe.hxx" #include <accmap.hxx> #include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext3.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase.hxx> @@ -46,6 +47,7 @@ class SwAccessibleContext : public ::cppu::WeakImplHelper< css::accessibility::XAccessible, css::accessibility::XAccessibleContext, + css::accessibility::XAccessibleContext3, css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleEventBroadcaster, css::lang::XServiceInfo @@ -220,6 +222,9 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int32 nIndex) override; + virtual css::uno::Sequence<css::uno::Reference< css::accessibility::XAccessible>> SAL_CALL + getAccessibleChildren() override; + // Return a reference to the parent. virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override; |