From a3f77a61c03340b79930e89d5c4045d814b93edf Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 30 Aug 2023 14:43:18 +0200 Subject: [PATCH] use concrete type for VCLXAccessibleTabControl::m_aAccessibleChildren avoid some unnecessary casting Change-Id: I2f6ed71fbffbcdfad18ed03dd45c12ea1f52fff6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156291 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../inc/standard/vclxaccessibletabcontrol.hxx | 4 +- .../standard/vclxaccessibletabcontrol.cxx | 67 ++++++------------- 2 files changed, 23 insertions(+), 48 deletions(-) diff --git a/accessibility/inc/standard/vclxaccessibletabcontrol.hxx b/accessibility/inc/standard/vclxaccessibletabcontrol.hxx index dcf515775bd7..32565c6d80ad 100644 --- a/accessibility/inc/standard/vclxaccessibletabcontrol.hxx +++ b/accessibility/inc/standard/vclxaccessibletabcontrol.hxx @@ -27,7 +27,7 @@ #include - +class VCLXAccessibleTabPage; class VCLXAccessibleTabControl final : public cppu::ImplInheritanceHelper< @@ -35,7 +35,7 @@ class VCLXAccessibleTabControl final : public cppu::ImplInheritanceHelper< css::accessibility::XAccessibleSelection> { private: - typedef std::vector< css::uno::Reference< css::accessibility::XAccessible > > AccessibleChildren; + typedef std::vector< rtl::Reference< VCLXAccessibleTabPage > > AccessibleChildren; AccessibleChildren m_aAccessibleChildren; VclPtr m_pTabControl; diff --git a/accessibility/source/standard/vclxaccessibletabcontrol.cxx b/accessibility/source/standard/vclxaccessibletabcontrol.cxx index 9963b51aef5f..0855b0f177aa 100644 --- a/accessibility/source/standard/vclxaccessibletabcontrol.cxx +++ b/accessibility/source/standard/vclxaccessibletabcontrol.cxx @@ -52,20 +52,16 @@ VCLXAccessibleTabControl::VCLXAccessibleTabControl( VCLXWindow* pVCLXWindow ) m_pTabControl.clear(); return; } - m_aAccessibleChildren.assign( m_pTabControl->GetPageCount(), Reference< XAccessible >() ); + m_aAccessibleChildren.assign( m_pTabControl->GetPageCount(), rtl::Reference< VCLXAccessibleTabPage >() ); } void VCLXAccessibleTabControl::UpdateFocused() { - for (const Reference& xChild : m_aAccessibleChildren) + for (const rtl::Reference& pVCLXAccessibleTabPage : m_aAccessibleChildren) { - if ( xChild.is() ) - { - VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); - if ( pVCLXAccessibleTabPage ) - pVCLXAccessibleTabPage->SetFocused( pVCLXAccessibleTabPage->IsFocused() ); - } + if ( pVCLXAccessibleTabPage ) + pVCLXAccessibleTabPage->SetFocused( pVCLXAccessibleTabPage->IsFocused() ); } } @@ -74,13 +70,9 @@ void VCLXAccessibleTabControl::UpdateSelected( sal_Int32 i, bool bSelected ) { if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() ) { - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - if ( xChild.is() ) - { - VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); - if ( pVCLXAccessibleTabPage ) - pVCLXAccessibleTabPage->SetSelected( bSelected ); - } + rtl::Reference< VCLXAccessibleTabPage > pVCLXAccessibleTabPage( m_aAccessibleChildren[i] ); + if ( pVCLXAccessibleTabPage ) + pVCLXAccessibleTabPage->SetSelected( bSelected ); } } @@ -89,13 +81,9 @@ void VCLXAccessibleTabControl::UpdatePageText( sal_Int32 i ) { if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() ) { - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - if ( xChild.is() ) - { - VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); - if ( pVCLXAccessibleTabPage ) - pVCLXAccessibleTabPage->SetPageText( pVCLXAccessibleTabPage->GetPageText() ); - } + rtl::Reference< VCLXAccessibleTabPage > pVCLXAccessibleTabPage( m_aAccessibleChildren[i] ); + if ( pVCLXAccessibleTabPage ) + pVCLXAccessibleTabPage->SetPageText( pVCLXAccessibleTabPage->GetPageText() ); } } @@ -104,13 +92,9 @@ void VCLXAccessibleTabControl::UpdateTabPage( sal_Int32 i, bool bNew ) { if ( i >= 0 && o3tl::make_unsigned(i) < m_aAccessibleChildren.size() ) { - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - if ( xChild.is() ) - { - VCLXAccessibleTabPage* pVCLXAccessibleTabPage = static_cast< VCLXAccessibleTabPage* >( xChild.get() ); - if ( pVCLXAccessibleTabPage ) - pVCLXAccessibleTabPage->Update( bNew ); - } + rtl::Reference< VCLXAccessibleTabPage > pVCLXAccessibleTabPage( m_aAccessibleChildren[i] ); + if ( pVCLXAccessibleTabPage ) + pVCLXAccessibleTabPage->Update( bNew ); } } @@ -121,7 +105,7 @@ void VCLXAccessibleTabControl::InsertChild( sal_Int32 i ) return; // insert entry in child list - m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, rtl::Reference< VCLXAccessibleTabPage >() ); // send accessible child event Reference< XAccessible > xChild( getAccessibleChild( i ) ); @@ -140,7 +124,7 @@ void VCLXAccessibleTabControl::RemoveChild( sal_Int32 i ) return; // get the accessible of the removed page - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + rtl::Reference< VCLXAccessibleTabPage > xChild( m_aAccessibleChildren[i] ); // remove entry in child list m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); @@ -149,12 +133,10 @@ void VCLXAccessibleTabControl::RemoveChild( sal_Int32 i ) if ( xChild.is() ) { Any aOldValue, aNewValue; - aOldValue <<= xChild; + aOldValue <<= uno::Reference(xChild); NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); + xChild->dispose(); } } @@ -235,12 +217,8 @@ void VCLXAccessibleTabControl::ProcessWindowEvent( const VclWindowEvent& rVclWin m_pTabControl = nullptr; // dispose all tab pages - for (const Reference& i : m_aAccessibleChildren) - { - Reference< XComponent > xComponent( i, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } + for (const rtl::Reference& i : m_aAccessibleChildren) + i->dispose(); m_aAccessibleChildren.clear(); } @@ -304,12 +282,9 @@ void VCLXAccessibleTabControl::disposing() m_pTabControl = nullptr; // dispose all tab pages - for (const Reference& i : m_aAccessibleChildren) - { - Reference< XComponent > xComponent( i, UNO_QUERY ); + for (const rtl::Reference& xComponent : m_aAccessibleChildren) if ( xComponent.is() ) xComponent->dispose(); - } m_aAccessibleChildren.clear(); } @@ -352,7 +327,7 @@ Reference< XAccessible > VCLXAccessibleTabControl::getAccessibleChild( sal_Int64 Reference< XAccessible > VCLXAccessibleTabControl::implGetAccessibleChild( sal_Int64 i ) { - Reference< XAccessible > xChild = m_aAccessibleChildren[i]; + rtl::Reference< VCLXAccessibleTabPage > xChild = m_aAccessibleChildren[i]; if ( !xChild.is() ) { sal_uInt16 nPageId = m_pTabControl ? m_pTabControl->GetPageId(static_cast(i)) : 0;