From 667823e412ac2b08d1a2f929e0347fc9ef54256c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 13 Dec 2024 09:41:24 +0100 Subject: [PATCH] a11y: Get text window doc accessible from Window on demand Instead of storing a reference to the VCLXWindow (which is a TextWindowPeer), which is the EditorWindow's accessible as Document::m_xAccessible member, adjust Document::getAccessible to get the accessible on demand via vcl::Window::GetAccessible instead. This also prepares for no more passing the VCLXWindow to the ctor in an upcoming commit. Change-Id: I498f90a456eda453508a4f1ed84983006594ea86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178402 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- accessibility/inc/extended/textwindowaccessibility.hxx | 4 +--- accessibility/source/extended/textwindowaccessibility.cxx | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/accessibility/inc/extended/textwindowaccessibility.hxx b/accessibility/inc/extended/textwindowaccessibility.hxx index e998ac3c443e..60511460991d 100644 --- a/accessibility/inc/extended/textwindowaccessibility.hxx +++ b/accessibility/inc/extended/textwindowaccessibility.hxx @@ -319,8 +319,7 @@ public: Document(::VCLXWindow * pVclXWindow, ::TextEngine & rEngine, ::TextView & rView); - const css::uno::Reference< css::accessibility::XAccessible >& - getAccessible() const { return m_xAccessible; } + css::uno::Reference getAccessible() const; css::lang::Locale retrieveLocale(); @@ -531,7 +530,6 @@ private: Paragraphs::iterator visibleEnd() { return getIter(m_nVisibleEnd); } Paragraphs::iterator focused() { return getIter(m_nFocused); } - css::uno::Reference< css::accessibility::XAccessible > m_xAccessible; ::TextEngine & m_rEngine; ::TextView & m_rView; diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index e19915407e00..78e6ea3932c4 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -704,7 +704,6 @@ void Paragraph::checkDisposed() Document::Document(::VCLXWindow * pVclXWindow, ::TextEngine & rEngine, ::TextView & rView): VCLXAccessibleComponent(pVclXWindow->GetWindow()), - m_xAccessible(pVclXWindow), m_rEngine(rEngine), m_rView(rView), m_aEngineListener(*this), @@ -729,6 +728,13 @@ Document::Document(::VCLXWindow * pVclXWindow, ::TextEngine & rEngine, m_aViewListener.startListening(*m_rView.GetWindow()); } +css::uno::Reference Document::getAccessible() const +{ + if (vcl::Window* pWindow = GetWindow()) + return pWindow->GetAccessible(); + return nullptr; +} + css::lang::Locale Document::retrieveLocale() { SolarMutexGuard aGuard;