include/vcl/accessiblefactory.hxx | 60 ---------------------- solenv/clang-format/excludelist | 3 - toolkit/source/awt/vclxwindow.cxx | 9 --- vcl/Library_vcl.mk | 1 vcl/source/accessibility/acc_factory.cxx | 84 ------------------------------- vcl/source/window/accessibility.cxx | 38 +++++++++++++- 6 files changed, 38 insertions(+), 157 deletions(-)
New commits: commit f8b3427caaedb5f4c87ee208db72f3a61417dd9b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon May 26 09:45:11 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jun 19 19:37:45 2025 +0200 vcl a11y: Let vcl::Window create accessible directly, drop a11y factory This is basically the vcl::Window base class equivalent of commit f82aac71ede9c3f2dc059ca4c8b24f60e0841933 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Thu May 22 12:30:12 2025 +0200 vcl a11y: Let PushButton create its accessible directly , see that commit's message for more background and tips on what to do if this commit causes any issues. Now that Window::CreateAccessible and all overrides in subclasses no longer make use of the VCLXWindow for the XAccessible, VCLXWindow::CreateAccessibleContext should no longer be called. Add an assert that would trigger if that method was still called somehow. Drop the now unused AccessibleFactory. Further cleanup will be done in separate commits. Java a11y tests that were previously relying on the implementation detail that the XAccessible for many vcl::Window subclasses was their VCLXWindow have been adjusted in previous commit Change-Id: Id96a2104d87c998b0bdcbce36451499484d81272 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Wed Jun 18 17:49:48 2025 +0200 java a11y tests: Don't rely on XWindow being XAccessible Change-Id: I25de1ab0f8b47b12346abd01bad05cb54fb75f52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185843 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/vcl/accessiblefactory.hxx b/include/vcl/accessiblefactory.hxx deleted file mode 100644 index 1d119216e9d1..000000000000 --- a/include/vcl/accessiblefactory.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <vcl/dllapi.h> - -#include <com/sun/star/uno/Reference.hxx> - -namespace com::sun::star { - namespace accessibility { - class XAccessibleContext; - } -} - -namespace vcl { class Window; } - -class CheckBox; -class ComboBox; -class Edit; -class FixedHyperlink; -class FixedText; -class FormattedField; -class HeaderBar; -class ListBox; -class PushButton; -class RadioButton; -class ScrollBar; -class SvHeaderTabListBox; -class ToolBox; -class SvTreeListBox; -class TextEngine; -class TextView; - -class VCL_DLLPUBLIC AccessibleFactory -{ -public: - AccessibleFactory() = delete; - - static css::uno::Reference<css::accessibility::XAccessibleContext> - createAccessibleContext(vcl::Window* pWindow); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 80f85379e0a8..4ce000087699 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -5955,7 +5955,6 @@ include/toolkit/controls/unocontrolcontainer.hxx include/toolkit/controls/unocontrolcontainermodel.hxx include/toolkit/controls/unocontrolmodel.hxx include/toolkit/controls/unocontrols.hxx -include/toolkit/helper/accessiblefactory.hxx include/toolkit/helper/listenermultiplexer.hxx include/toolkit/helper/macros.hxx include/toolkit/helper/vclunohelper.hxx @@ -6126,7 +6125,6 @@ include/vcl/ImageTree.hxx include/vcl/Scanline.hxx include/vcl/abstdlg.hxx include/vcl/accessibility/vclxaccessiblecomponent.hxx -include/vcl/accessiblefactory.hxx include/vcl/accessibletableprovider.hxx include/vcl/alpha.hxx include/vcl/bitmap.hxx @@ -14122,7 +14120,6 @@ vcl/source/accessibility/AccessibleBrowseBoxHeaderCell.cxx vcl/source/accessibility/AccessibleBrowseBoxTable.cxx vcl/source/accessibility/AccessibleBrowseBoxTableBase.cxx vcl/source/accessibility/AccessibleBrowseBoxTableCell.cxx -vcl/source/accessibility/acc_factory.cxx vcl/source/accessibility/accessiblebrowseboxcell.cxx vcl/source/accessibility/accessibleiconchoicectrl.cxx vcl/source/accessibility/accessibleiconchoicectrlentry.cxx diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 12ea8d6a66ff..bca4764f9b85 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -46,7 +46,6 @@ #include <tools/color.hxx> #include <tools/fract.hxx> #include <tools/debug.hxx> -#include <vcl/accessiblefactory.hxx> #include <vcl/event.hxx> #include <vcl/dockwin.hxx> #include <vcl/pdfextoutdevdata.hxx> @@ -861,12 +860,8 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) uno::Reference< accessibility::XAccessibleContext > VCLXWindow::CreateAccessibleContext() { - SolarMutexGuard aGuard; - if (mpImpl->mbDisposing) - return nullptr; - - VclPtr<vcl::Window> pWindow = GetWindow(); - return AccessibleFactory::createAccessibleContext(pWindow); + assert(false && "This code path shouldn't be reached any more."); + return {}; } void VCLXWindow::SetSynthesizingVCLEvent( bool _b ) diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 040fde78ec48..1568ad506b52 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -106,7 +106,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/accessibility/AccessibleBrowseBoxTableBase \ vcl/source/accessibility/AccessibleBrowseBoxTableCell \ vcl/source/accessibility/AccessibleTextAttributeHelper \ - vcl/source/accessibility/acc_factory \ vcl/source/accessibility/accessiblebrowseboxcell \ vcl/source/accessibility/accessibleiconchoicectrl \ vcl/source/accessibility/accessibleiconchoicectrlentry \ diff --git a/vcl/source/accessibility/acc_factory.cxx b/vcl/source/accessibility/acc_factory.cxx deleted file mode 100644 index 3e7303f1244d..000000000000 --- a/vcl/source/accessibility/acc_factory.cxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <vcl/accessiblefactory.hxx> -#include <accessibility/floatingwindowaccessible.hxx> -#include <accessibility/vclxaccessiblefixedtext.hxx> -#include <accessibility/vclxaccessiblestatusbar.hxx> -#include <accessibility/vclxaccessibletabcontrol.hxx> -#include <accessibility/vclxaccessibletabpagewindow.hxx> -#include <vcl/accessibility/vclxaccessiblecomponent.hxx> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::accessibility; -using namespace ::vcl; - -namespace { - -bool hasFloatingChild(vcl::Window *pWindow) -{ - vcl::Window * pChild = pWindow->GetAccessibleChildWindow(0); - return pChild && pChild->GetType() == WindowType::FLOATINGWINDOW; -} -}; - -Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext(vcl::Window* pWindow) -{ - if (!pWindow) - return nullptr; - - WindowType eType = pWindow->GetType(); - - if ( eType == WindowType::STATUSBAR ) - { - return new VCLXAccessibleStatusBar(pWindow); - } - - else if ( eType == WindowType::TABCONTROL ) - { - return new VCLXAccessibleTabControl(pWindow); - } - - else if ( eType == WindowType::TABPAGE && pWindow->GetAccessibleParentWindow() && pWindow->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL ) - { - return new VCLXAccessibleTabPageWindow(pWindow); - } - - else if ( eType == WindowType::FLOATINGWINDOW ) - { - return new FloatingWindowAccessible(pWindow); - } - - else if ( eType == WindowType::BORDERWINDOW && hasFloatingChild( pWindow ) ) - { - return new FloatingWindowAccessible(pWindow); - } - - else if ( ( eType == WindowType::HELPTEXTWINDOW ) || ( eType == WindowType::FIXEDLINE ) ) - { - return new VCLXAccessibleFixedText(pWindow); - } - else - { - return new VCLXAccessibleComponent(pWindow); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx index 47c413a64cbf..1dfc1f319c80 100644 --- a/vcl/source/window/accessibility.cxx +++ b/vcl/source/window/accessibility.cxx @@ -22,9 +22,15 @@ #include <vcl/window.hxx> #include <vcl/menu.hxx> #include <vcl/mnemonic.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> #include <vcl/wrkwin.hxx> #include <comphelper/lok.hxx> +#include <accessibility/floatingwindowaccessible.hxx> +#include <accessibility/vclxaccessiblefixedtext.hxx> +#include <accessibility/vclxaccessiblestatusbar.hxx> +#include <accessibility/vclxaccessibletabcontrol.hxx> +#include <accessibility/vclxaccessibletabpagewindow.hxx> #include <window.h> #include <brdwin.hxx> @@ -75,10 +81,38 @@ css::uno::Reference< css::accessibility::XAccessible > Window::GetAccessible( bo return mpWindowImpl->mxAccessible; } +namespace { + +bool hasFloatingChild(vcl::Window *pWindow) +{ + vcl::Window * pChild = pWindow->GetAccessibleChildWindow(0); + return pChild && pChild->GetType() == WindowType::FLOATINGWINDOW; +} +}; + css::uno::Reference< css::accessibility::XAccessible > Window::CreateAccessible() { - css::uno::Reference< css::accessibility::XAccessible > xAcc( GetComponentInterface(), css::uno::UNO_QUERY ); - return xAcc; + const WindowType eType = GetType(); + + if (eType == WindowType::STATUSBAR) + return new VCLXAccessibleStatusBar(this); + + if (eType == WindowType::TABCONTROL) + return new VCLXAccessibleTabControl(this); + + if (eType == WindowType::TABPAGE && GetAccessibleParentWindow() && GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL) + return new VCLXAccessibleTabPageWindow(this); + + if (eType == WindowType::FLOATINGWINDOW) + return new FloatingWindowAccessible(this); + + if (eType == WindowType::BORDERWINDOW && hasFloatingChild(this)) + return new FloatingWindowAccessible(this); + + if ((eType == WindowType::HELPTEXTWINDOW) || (eType == WindowType::FIXEDLINE)) + return new VCLXAccessibleFixedText(this); + + return new VCLXAccessibleComponent(this); } void Window::SetAccessible( const css::uno::Reference< css::accessibility::XAccessible >& x )