summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-12-10 16:07:40 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-12-10 18:31:49 +0100
commit6f6e920a294a20c48c5ff59ba13433b91fa84ae1 (patch)
tree7ac8517f25457d157dea7e275427b03d5ecc8543
parent26cdc1f5a964417089c966f521b123c3f2cb3286 (diff)
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.weghorn@posteo.de>
-rw-r--r--accessibility/inc/standard/vclxaccessiblescrollbar.hxx2
-rw-r--r--accessibility/source/standard/vclxaccessiblescrollbar.cxx36
2 files changed, 18 insertions, 20 deletions
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;
}