qadevOOo/runner/util/AccessibilityTools.java | 5 qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java | 13 toolkit/source/awt/vclxwindow.cxx | 418 ++++++++-------- 3 files changed, 216 insertions(+), 220 deletions(-)
New commits: commit 97d084a57d83f12dc9b928c9887df3fc4daba8c6 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Jun 17 15:04:23 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Jun 18 08:08:05 2025 +0200 java a11y tests: Use more specific XWindow param Now after Change-Id: I9636c920ad44213d58b3848c2d85eb7c9af45e6e Author: Michael Weghorn <[email protected]> Date: Tue Jun 17 14:53:23 2025 +0200 java a11y test: Avoid detour to get XAccessibleContext , all callers of AccessibilityTools.getAccessibleObject pass an XWindow param, so switch the param to that type instead of the more generic XInterface. This prepares for adjusting the implementation to no longer rely on the XWindow implementing the XAccessible interface itself. Change-Id: I198d29bd142ee9deaf3c8f9fa118473b622074b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186616 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java index 672754d80f1a..e897e6478f6b 100644 --- a/qadevOOo/runner/util/AccessibilityTools.java +++ b/qadevOOo/runner/util/AccessibilityTools.java @@ -25,7 +25,6 @@ import com.sun.star.frame.XController; import com.sun.star.frame.XFrame; import com.sun.star.frame.XModel; import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; import java.io.PrintWriter; @@ -36,8 +35,8 @@ public class AccessibilityTools { private AccessibilityTools() {} - public static XAccessible getAccessibleObject(XInterface xObject) { - return UnoRuntime.queryInterface(XAccessible.class, xObject); + public static XAccessible getAccessibleObject(XWindow xWindow) { + return UnoRuntime.queryInterface(XAccessible.class, xWindow); } public static XWindow getCurrentContainerWindow(XModel xModel) { commit 29f2b10108b3c38393bb53b9f75f9b11b985e7cc Author: Michael Weghorn <[email protected]> AuthorDate: Tue Jun 17 14:53:23 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Jun 18 08:07:59 2025 +0200 java a11y test: Avoid detour to get XAccessibleContext AccessibilityTools.getAccessibleObjectForRole already returns an XAccessibleContext, so use that type directly instead of an XInterface, and then getting access to the same XAccessibleContext via an unnecessary detour. Change-Id: I9636c920ad44213d58b3848c2d85eb7c9af45e6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186615 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java index 868eac149735..162373db694d 100644 --- a/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java @@ -20,12 +20,12 @@ package mod._toolkit; import com.sun.star.accessibility.AccessibleRole; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.awt.XWindow; import com.sun.star.frame.XModel; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; import java.io.PrintWriter; @@ -112,8 +112,6 @@ public class AccessibleToolBox extends TestCase { log.println("creating a text document"); xTextDoc = SOF.createTextDoc(null); - XInterface oObj = null; - XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xTextDoc). getCurrentController().getFrame().getContainerWindow(); @@ -121,19 +119,18 @@ public class AccessibleToolBox extends TestCase { AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); - oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TOOL_BAR); + XAccessibleContext xAccContext = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TOOL_BAR); - log.println("ImplementationName: " + util.utils.getImplName(oObj)); + log.println("ImplementationName: " + util.utils.getImplName(xAccContext)); - TestEnvironment tEnv = new TestEnvironment(oObj); + TestEnvironment tEnv = new TestEnvironment(xAccContext); tEnv.addObjRelation("LimitedBounds", "yes"); - XAccessible acc = AccessibilityTools.getAccessibleObject(oObj); XAccessible child = null; try { - child = acc.getAccessibleContext().getAccessibleChild(0); + child = xAccContext.getAccessibleChild(0); } catch (com.sun.star.lang.IndexOutOfBoundsException e) { } commit 6c211387c29c0e1799a79369dc2ea491a63626db Author: Michael Weghorn <[email protected]> AuthorDate: Tue Jun 17 14:36:44 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Wed Jun 18 08:07:54 2025 +0200 toolkit: Flatten VCLXWindow::getProperty Return early in case GetWindow() returns null, which allows to drop one indentation level. Change-Id: Idfd4cc96f2a1c25d2f266f1f4ed20f23147609e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186614 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index eacf4189270a..df41f15c0228 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -1941,242 +1941,242 @@ css::uno::Any VCLXWindow::getProperty( const OUString& PropertyName ) SolarMutexGuard aGuard; css::uno::Any aProp; - if ( GetWindow() ) + if (!GetWindow()) + return aProp; + + if (PropertyName == "ParentIs100thmm") { - if (PropertyName == "ParentIs100thmm") + bool bParentIs100thmm = false; + VclPtr<vcl::Window> pWindow = GetWindow(); + if (pWindow) { - bool bParentIs100thmm = false; - VclPtr<vcl::Window> pWindow = GetWindow(); - if (pWindow) + pWindow = pWindow->GetParent(); + if(pWindow && MapUnit::Map100thMM == pWindow->GetMapMode().GetMapUnit()) { - pWindow = pWindow->GetParent(); - if(pWindow && MapUnit::Map100thMM == pWindow->GetMapMode().GetMapUnit()) - { - bParentIs100thmm = true; - } + bParentIs100thmm = true; } - aProp <<= bParentIs100thmm; - return aProp; } - WindowType eWinType = GetWindow()->GetType(); - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + aProp <<= bParentIs100thmm; + return aProp; + } + WindowType eWinType = GetWindow()->GetType(); + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_REFERENCE_DEVICE: { - case BASEPROPERTY_REFERENCE_DEVICE: - { - VclPtr<Control> pControl = GetAsDynamic<Control >(); - OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); - if ( !pControl ) - break; - - rtl::Reference<VCLXDevice> pDevice = new VCLXDevice; - pDevice->SetOutputDevice( pControl->GetReferenceDevice() ); - aProp <<= Reference< XDevice >( pDevice ); - } - break; - - case BASEPROPERTY_CONTEXT_WRITING_MODE: - aProp <<= mpImpl->mnContextWritingMode; + VclPtr<Control> pControl = GetAsDynamic<Control >(); + OSL_ENSURE( pControl, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" ); + if ( !pControl ) break; - case BASEPROPERTY_WRITING_MODE: - aProp <<= mpImpl->mnWritingMode; - break; + rtl::Reference<VCLXDevice> pDevice = new VCLXDevice; + pDevice->SetOutputDevice( pControl->GetReferenceDevice() ); + aProp <<= Reference< XDevice >( pDevice ); + } + break; - case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: - { - MouseWheelBehaviour nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior(); - sal_uInt16 nBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; - switch ( nVclBehavior ) - { - case MouseWheelBehaviour::Disable: nBehavior = css::awt::MouseWheelBehavior::SCROLL_DISABLED; break; - case MouseWheelBehaviour::FocusOnly: nBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; break; - case MouseWheelBehaviour::ALWAYS: nBehavior = css::awt::MouseWheelBehavior::SCROLL_ALWAYS; break; - default: - OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" ); - } - aProp <<= nBehavior; - } + case BASEPROPERTY_CONTEXT_WRITING_MODE: + aProp <<= mpImpl->mnContextWritingMode; break; - case BASEPROPERTY_NATIVE_WIDGET_LOOK: - aProp <<= GetWindow()->IsNativeWidgetEnabled(); - break; - - case BASEPROPERTY_ENABLED: - aProp <<= GetWindow()->IsEnabled(); - break; - - case BASEPROPERTY_ENABLEVISIBLE: - aProp <<= mpImpl->isEnableVisible(); - break; - - case BASEPROPERTY_HIGHCONTRASTMODE: - aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode(); - break; - - case BASEPROPERTY_TEXT: - case BASEPROPERTY_LABEL: - case BASEPROPERTY_TITLE: - { - OUString aText = GetWindow()->GetText(); - aProp <<= aText; - } - break; - case BASEPROPERTY_ACCESSIBLENAME: - { - OUString aText = GetWindow()->GetAccessibleName(); - aProp <<= aText; - } - break; - case BASEPROPERTY_HELPTEXT: - { - OUString aText = GetWindow()->GetQuickHelpText(); - aProp <<= aText; - } - break; - case BASEPROPERTY_HELPURL: - aProp <<= GetWindow()->GetHelpId(); + case BASEPROPERTY_WRITING_MODE: + aProp <<= mpImpl->mnWritingMode; break; - case BASEPROPERTY_FONTDESCRIPTOR: + + case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: + { + MouseWheelBehaviour nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior(); + sal_uInt16 nBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; + switch ( nVclBehavior ) { - vcl::Font aFont = GetWindow()->GetControlFont(); - css::awt::FontDescriptor aFD = VCLUnoHelper::CreateFontDescriptor( aFont ); - aProp <<= aFD; + case MouseWheelBehaviour::Disable: nBehavior = css::awt::MouseWheelBehavior::SCROLL_DISABLED; break; + case MouseWheelBehaviour::FocusOnly: nBehavior = css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY; break; + case MouseWheelBehaviour::ALWAYS: nBehavior = css::awt::MouseWheelBehavior::SCROLL_ALWAYS; break; + default: + OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" ); } + aProp <<= nBehavior; + } + break; + + case BASEPROPERTY_NATIVE_WIDGET_LOOK: + aProp <<= GetWindow()->IsNativeWidgetEnabled(); break; - case BASEPROPERTY_BACKGROUNDCOLOR: - aProp <<= GetWindow()->GetControlBackground(); - break; - case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR: - aProp <<= GetWindow()->GetBackgroundColor(); - break; - case BASEPROPERTY_FONTRELIEF: - aProp <<= static_cast<sal_Int16>(GetWindow()->GetControlFont().GetRelief()); - break; - case BASEPROPERTY_FONTEMPHASISMARK: - aProp <<= static_cast<sal_Int16>(GetWindow()->GetControlFont().GetEmphasisMark()); - break; - case BASEPROPERTY_TEXTCOLOR: - aProp <<= GetWindow()->GetControlForeground(); - break; - case BASEPROPERTY_TEXTLINECOLOR: - aProp <<= GetWindow()->GetTextLineColor(); - break; - case BASEPROPERTY_FILLCOLOR: - aProp <<= GetWindow()->GetOutDev()->GetFillColor(); - break; - case BASEPROPERTY_LINECOLOR: - aProp <<= GetWindow()->GetOutDev()->GetLineColor(); - break; - case BASEPROPERTY_HIGHLIGHT_COLOR: - aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighlightColor(); - break; - case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR: - aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighlightTextColor(); - break; - case BASEPROPERTY_BORDER: - { - WindowBorderStyle nBorder = WindowBorderStyle::NONE; - if ( GetWindow()->GetStyle() & WB_BORDER ) - nBorder = GetWindow()->GetBorderStyle(); - aProp <<= static_cast<sal_uInt16>(nBorder); - } + + case BASEPROPERTY_ENABLED: + aProp <<= GetWindow()->IsEnabled(); break; - case BASEPROPERTY_TABSTOP: - aProp <<= ( GetWindow()->GetStyle() & WB_TABSTOP ) != 0; + + case BASEPROPERTY_ENABLEVISIBLE: + aProp <<= mpImpl->isEnableVisible(); break; - case BASEPROPERTY_VERTICALALIGN: - { - WinBits nStyle = GetWindow()->GetStyle(); - if ( nStyle & WB_TOP ) - aProp <<= VerticalAlignment_TOP; - else if ( nStyle & WB_VCENTER ) - aProp <<= VerticalAlignment_MIDDLE; - else if ( nStyle & WB_BOTTOM ) - aProp <<= VerticalAlignment_BOTTOM; - } + + case BASEPROPERTY_HIGHCONTRASTMODE: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode(); break; - case BASEPROPERTY_ALIGN: + + case BASEPROPERTY_TEXT: + case BASEPROPERTY_LABEL: + case BASEPROPERTY_TITLE: + { + OUString aText = GetWindow()->GetText(); + aProp <<= aText; + } + break; + case BASEPROPERTY_ACCESSIBLENAME: + { + OUString aText = GetWindow()->GetAccessibleName(); + aProp <<= aText; + } + break; + case BASEPROPERTY_HELPTEXT: + { + OUString aText = GetWindow()->GetQuickHelpText(); + aProp <<= aText; + } + break; + case BASEPROPERTY_HELPURL: + aProp <<= GetWindow()->GetHelpId(); + break; + case BASEPROPERTY_FONTDESCRIPTOR: + { + vcl::Font aFont = GetWindow()->GetControlFont(); + css::awt::FontDescriptor aFD = VCLUnoHelper::CreateFontDescriptor( aFont ); + aProp <<= aFD; + } + break; + case BASEPROPERTY_BACKGROUNDCOLOR: + aProp <<= GetWindow()->GetControlBackground(); + break; + case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR: + aProp <<= GetWindow()->GetBackgroundColor(); + break; + case BASEPROPERTY_FONTRELIEF: + aProp <<= static_cast<sal_Int16>(GetWindow()->GetControlFont().GetRelief()); + break; + case BASEPROPERTY_FONTEMPHASISMARK: + aProp <<= static_cast<sal_Int16>(GetWindow()->GetControlFont().GetEmphasisMark()); + break; + case BASEPROPERTY_TEXTCOLOR: + aProp <<= GetWindow()->GetControlForeground(); + break; + case BASEPROPERTY_TEXTLINECOLOR: + aProp <<= GetWindow()->GetTextLineColor(); + break; + case BASEPROPERTY_FILLCOLOR: + aProp <<= GetWindow()->GetOutDev()->GetFillColor(); + break; + case BASEPROPERTY_LINECOLOR: + aProp <<= GetWindow()->GetOutDev()->GetLineColor(); + break; + case BASEPROPERTY_HIGHLIGHT_COLOR: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighlightColor(); + break; + case BASEPROPERTY_HIGHLIGHT_TEXT_COLOR: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetHighlightTextColor(); + break; + case BASEPROPERTY_BORDER: + { + WindowBorderStyle nBorder = WindowBorderStyle::NONE; + if ( GetWindow()->GetStyle() & WB_BORDER ) + nBorder = GetWindow()->GetBorderStyle(); + aProp <<= static_cast<sal_uInt16>(nBorder); + } + break; + case BASEPROPERTY_TABSTOP: + aProp <<= ( GetWindow()->GetStyle() & WB_TABSTOP ) != 0; + break; + case BASEPROPERTY_VERTICALALIGN: + { + WinBits nStyle = GetWindow()->GetStyle(); + if ( nStyle & WB_TOP ) + aProp <<= VerticalAlignment_TOP; + else if ( nStyle & WB_VCENTER ) + aProp <<= VerticalAlignment_MIDDLE; + else if ( nStyle & WB_BOTTOM ) + aProp <<= VerticalAlignment_BOTTOM; + } + break; + case BASEPROPERTY_ALIGN: + { + switch ( eWinType ) { - switch ( eWinType ) + case WindowType::FIXEDTEXT: + case WindowType::EDIT: + case WindowType::MULTILINEEDIT: + case WindowType::CHECKBOX: + case WindowType::RADIOBUTTON: + case WindowType::LISTBOX: + case WindowType::COMBOBOX: + case WindowType::PUSHBUTTON: + case WindowType::OKBUTTON: + case WindowType::CANCELBUTTON: + case WindowType::HELPBUTTON: { - case WindowType::FIXEDTEXT: - case WindowType::EDIT: - case WindowType::MULTILINEEDIT: - case WindowType::CHECKBOX: - case WindowType::RADIOBUTTON: - case WindowType::LISTBOX: - case WindowType::COMBOBOX: - case WindowType::PUSHBUTTON: - case WindowType::OKBUTTON: - case WindowType::CANCELBUTTON: - case WindowType::HELPBUTTON: - { - WinBits nStyle = GetWindow()->GetStyle(); - if ( nStyle & WB_LEFT ) - aProp <<= sal_Int16(PROPERTY_ALIGN_LEFT); - else if ( nStyle & WB_CENTER ) - aProp <<= sal_Int16(PROPERTY_ALIGN_CENTER); - else if ( nStyle & WB_RIGHT ) - aProp <<= sal_Int16(PROPERTY_ALIGN_RIGHT); - } - break; - default: break; + WinBits nStyle = GetWindow()->GetStyle(); + if ( nStyle & WB_LEFT ) + aProp <<= sal_Int16(PROPERTY_ALIGN_LEFT); + else if ( nStyle & WB_CENTER ) + aProp <<= sal_Int16(PROPERTY_ALIGN_CENTER); + else if ( nStyle & WB_RIGHT ) + aProp <<= sal_Int16(PROPERTY_ALIGN_RIGHT); } + break; + default: break; } - break; - case BASEPROPERTY_MULTILINE: - { - if ( ( eWinType == WindowType::FIXEDTEXT ) - || ( eWinType == WindowType::CHECKBOX ) - || ( eWinType == WindowType::RADIOBUTTON ) - || ( eWinType == WindowType::PUSHBUTTON ) - || ( eWinType == WindowType::OKBUTTON ) - || ( eWinType == WindowType::CANCELBUTTON ) - || ( eWinType == WindowType::HELPBUTTON ) - ) - aProp <<= ( GetWindow()->GetStyle() & WB_WORDBREAK ) != 0; - } - break; - case BASEPROPERTY_AUTOMNEMONICS: - { - bool bAutoMnemonics = GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic(); - aProp <<= bAutoMnemonics; - } - break; - case BASEPROPERTY_MOUSETRANSPARENT: - { - bool bMouseTransparent = GetWindow()->IsMouseTransparent(); - aProp <<= bMouseTransparent; - } - break; - case BASEPROPERTY_PAINTTRANSPARENT: - { - bool bPaintTransparent = GetWindow()->IsPaintTransparent(); - aProp <<= bPaintTransparent; - } + } + break; + case BASEPROPERTY_MULTILINE: + { + if ( ( eWinType == WindowType::FIXEDTEXT ) + || ( eWinType == WindowType::CHECKBOX ) + || ( eWinType == WindowType::RADIOBUTTON ) + || ( eWinType == WindowType::PUSHBUTTON ) + || ( eWinType == WindowType::OKBUTTON ) + || ( eWinType == WindowType::CANCELBUTTON ) + || ( eWinType == WindowType::HELPBUTTON ) + ) + aProp <<= ( GetWindow()->GetStyle() & WB_WORDBREAK ) != 0; + } + break; + case BASEPROPERTY_AUTOMNEMONICS: + { + bool bAutoMnemonics = GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic(); + aProp <<= bAutoMnemonics; + } + break; + case BASEPROPERTY_MOUSETRANSPARENT: + { + bool bMouseTransparent = GetWindow()->IsMouseTransparent(); + aProp <<= bMouseTransparent; + } + break; + case BASEPROPERTY_PAINTTRANSPARENT: + { + bool bPaintTransparent = GetWindow()->IsPaintTransparent(); + aProp <<= bPaintTransparent; + } + break; + + case BASEPROPERTY_REPEAT: + aProp <<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT ) ); break; - case BASEPROPERTY_REPEAT: - aProp <<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT ) ); - break; + case BASEPROPERTY_REPEAT_DELAY: + { + sal_Int32 nButtonRepeat = GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat(); + aProp <<= nButtonRepeat; + } + break; - case BASEPROPERTY_REPEAT_DELAY: - { - sal_Int32 nButtonRepeat = GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat(); - aProp <<= nButtonRepeat; - } + case BASEPROPERTY_SYMBOL_COLOR: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor(); break; - case BASEPROPERTY_SYMBOL_COLOR: - aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor(); - break; - - case BASEPROPERTY_BORDERCOLOR: - aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetMonoColor(); - break; - } + case BASEPROPERTY_BORDERCOLOR: + aProp <<= GetWindow()->GetSettings().GetStyleSettings().GetMonoColor(); + break; } return aProp; }
