accessibility/inc/standard/vclxaccessiblescrollbar.hxx | 2 accessibility/source/standard/vclxaccessibleradiobutton.cxx | 30 ++--- accessibility/source/standard/vclxaccessiblescrollbar.cxx | 63 +++++------- 3 files changed, 46 insertions(+), 49 deletions(-)
New commits: commit 85e17c7ff9c8af34847a1d26f234a06f1aff2af2 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Dec 10 16:24:52 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Dec 10 18:31:56 2024 +0100 a11y: Directly use vcl ScrollBar in VCLXAccessibleScrollBar ... instead of using the toolkit/UNO wrapper class VCLXScrollBar. WIP: simplify Change-Id: I9df8efb514d2bcf555bd163a7fe418c5c8d9e903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178241 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/source/standard/vclxaccessiblescrollbar.cxx b/accessibility/source/standard/vclxaccessiblescrollbar.cxx index 14dc6c7b0651..2136f54c75ff 100644 --- a/accessibility/source/standard/vclxaccessiblescrollbar.cxx +++ b/accessibility/source/standard/vclxaccessiblescrollbar.cxx @@ -165,9 +165,9 @@ Any VCLXAccessibleScrollBar::getCurrentValue( ) Any aValue; - VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() ); - if ( pVCLXScrollBar ) - aValue <<= pVCLXScrollBar->getValue(); + VclPtr<ScrollBar> pScrollBar = GetAs<ScrollBar>(); + if (pScrollBar) + aValue <<= sal_Int32(pScrollBar->GetThumbPos()); return aValue; } @@ -179,20 +179,19 @@ sal_Bool VCLXAccessibleScrollBar::setCurrentValue( const Any& aNumber ) bool bReturn = false; - VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() ); - if ( pVCLXScrollBar ) + VclPtr<ScrollBar> pScrollBar = GetAs<ScrollBar>(); + if (pScrollBar) { - sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0; + sal_Int32 nValue = 0; OSL_VERIFY( aNumber >>= nValue ); - OSL_VERIFY( getMinimumValue() >>= nValueMin ); - OSL_VERIFY( getMaximumValue() >>= nValueMax ); + sal_Int32 nValueMax = pScrollBar->GetRangeMax(); - if ( nValue < nValueMin ) - nValue = nValueMin; + if (nValue < 0) + nValue = 0; else if ( nValue > nValueMax ) nValue = nValueMax; - pVCLXScrollBar->setValue( nValue ); + pScrollBar->DoScroll(nValue); bReturn = true; } @@ -206,9 +205,9 @@ Any VCLXAccessibleScrollBar::getMaximumValue( ) Any aValue; - VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() ); - if ( pVCLXScrollBar ) - aValue <<= pVCLXScrollBar->getMaximum(); + VclPtr<ScrollBar> pScrollBar = GetAs<ScrollBar>(); + if (pScrollBar) + aValue <<= sal_Int32(pScrollBar->GetRangeMax()); return aValue; } commit 6f6e920a294a20c48c5ff59ba13433b91fa84ae1 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Dec 10 16:07:40 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Dec 10 18:31:49 2024 +0100 a11y: Extract a VCLXAccessibleScrollBar::GetOrientationState helper See also VCLXScrollBar::getOrientation which uses the same logic and was called earlier. This is in preparation of using the vcl ScrollBar directly instead of depending on its VCLXScrollbar toolkit/UNO peer. Change-Id: Ie2a1a104c69d56036890e995fc97849d5acc137a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178240 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/inc/standard/vclxaccessiblescrollbar.hxx b/accessibility/inc/standard/vclxaccessiblescrollbar.hxx index ffaa7f689a78..c8f1dd719878 100644 --- a/accessibility/inc/standard/vclxaccessiblescrollbar.hxx +++ b/accessibility/inc/standard/vclxaccessiblescrollbar.hxx @@ -62,6 +62,8 @@ public: // XAccessibleContext OUString SAL_CALL getAccessibleName( ) override; +private: + sal_Int64 GetOrientationState() const; }; diff --git a/accessibility/source/standard/vclxaccessiblescrollbar.cxx b/accessibility/source/standard/vclxaccessiblescrollbar.cxx index cc58f17efa06..14dc6c7b0651 100644 --- a/accessibility/source/standard/vclxaccessiblescrollbar.cxx +++ b/accessibility/source/standard/vclxaccessiblescrollbar.cxx @@ -62,16 +62,9 @@ void VCLXAccessibleScrollBar::FillAccessibleStateSet( sal_Int64& rStateSet ) { VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); - VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() ); - if ( pVCLXScrollBar ) - { - // IA2 CWS: scroll bar should not have FOCUSABLE state. - // rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL ) - rStateSet |= AccessibleStateType::HORIZONTAL; - else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL ) - rStateSet |= AccessibleStateType::VERTICAL; - } + // IA2 CWS: scroll bar should not have FOCUSABLE state. + // rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + rStateSet |= GetOrientationState(); } @@ -243,16 +236,19 @@ OUString VCLXAccessibleScrollBar::getAccessibleName( ) { OExternalLockGuard aGuard( this ); - OUString aName; - VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() ); - if ( pVCLXScrollBar ) - { - if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL ) - aName = AccResId( RID_STR_ACC_SCROLLBAR_NAME_HORIZONTAL ); - else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL ) - aName = AccResId( RID_STR_ACC_SCROLLBAR_NAME_VERTICAL ); - } - return aName; + if (VCLXAccessibleScrollBar::GetOrientationState() == AccessibleStateType::HORIZONTAL) + return AccResId(RID_STR_ACC_SCROLLBAR_NAME_HORIZONTAL); + + return AccResId(RID_STR_ACC_SCROLLBAR_NAME_VERTICAL); +} + +sal_Int64 VCLXAccessibleScrollBar::GetOrientationState() const +{ + VclPtr<ScrollBar> pScrollBar = GetAs<ScrollBar>(); + if (!pScrollBar || pScrollBar->GetStyle() & WB_HORZ) + return AccessibleStateType::HORIZONTAL; + + return AccessibleStateType::VERTICAL; } commit 26cdc1f5a964417089c966f521b123c3f2cb3286 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Dec 10 15:36:10 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Dec 10 18:31:42 2024 +0100 a11y: Directly use vcl RadioButton in VCLXAccessibleRadioButton ... instead of using the toolkit/UNO wrapper class VCLXRadioButton. While at it, also switch the single use of VCLXAccessibleComponent::GetAsDynamic to VCLXAccessibleComponent::GetAs, too, as the control is known to be a RadioButton. Change-Id: I9d26e0ca165c8df16095a3bc460907567c04ccd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178239 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx index 03d12bb3ffc0..53dc04bae9ee 100644 --- a/accessibility/source/standard/vclxaccessibleradiobutton.cxx +++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx @@ -55,8 +55,8 @@ void VCLXAccessibleRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWi Any aOldValue; Any aNewValue; - VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() ); - if ( pVCLXRadioButton && pVCLXRadioButton->getState() ) + VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>(); + if (pRadioButton && pRadioButton->IsChecked()) aNewValue <<= AccessibleStateType::CHECKED; else aOldValue <<= AccessibleStateType::CHECKED; @@ -74,7 +74,7 @@ void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelati { VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet ); - VclPtr< RadioButton > pRadioButton = GetAsDynamic< RadioButton >(); + VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>(); if ( !pRadioButton ) return; @@ -95,12 +95,12 @@ void VCLXAccessibleRadioButton::FillAccessibleStateSet( sal_Int64& rStateSet ) { VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet ); - VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() ); - if ( pVCLXRadioButton ) + VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>(); + if (pRadioButton) { rStateSet |= AccessibleStateType::CHECKABLE; rStateSet |= AccessibleStateType::FOCUSABLE; - if ( pVCLXRadioButton->getState() ) + if (pRadioButton->IsChecked()) rStateSet |= AccessibleStateType::CHECKED; } } @@ -139,9 +139,9 @@ sal_Bool VCLXAccessibleRadioButton::doAccessibleAction ( sal_Int32 nIndex ) if ( nIndex != 0 ) throw IndexOutOfBoundsException(); - VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() ); - if ( pVCLXRadioButton && !pVCLXRadioButton->getState() ) - pVCLXRadioButton->setState( true ); + VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>(); + if (pRadioButton && !pRadioButton->IsChecked()) + pRadioButton->Check(true); return true; } @@ -202,9 +202,9 @@ Any VCLXAccessibleRadioButton::getCurrentValue( ) Any aValue; - VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() ); - if ( pVCLXRadioButton ) - aValue <<= static_cast<sal_Int32>(pVCLXRadioButton->getState()); + VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>(); + if (pRadioButton) + aValue <<= static_cast<sal_Int32>(pRadioButton->IsChecked() ? 1 : 0); return aValue; } @@ -216,8 +216,8 @@ sal_Bool VCLXAccessibleRadioButton::setCurrentValue( const Any& aNumber ) bool bReturn = false; - VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() ); - if ( pVCLXRadioButton ) + VclPtr<RadioButton> pRadioButton = GetAs<RadioButton>(); + if (pRadioButton) { sal_Int32 nValue = 0; OSL_VERIFY( aNumber >>= nValue ); @@ -227,7 +227,7 @@ sal_Bool VCLXAccessibleRadioButton::setCurrentValue( const Any& aNumber ) else if ( nValue > 1 ) nValue = 1; - pVCLXRadioButton->setState( nValue == 1 ); + pRadioButton->Check(nValue == 1); bReturn = true; }