accessibility/source/standard/vclxaccessibletoolbox.cxx | 41 +++------------- 1 file changed, 8 insertions(+), 33 deletions(-)
New commits: commit e151ea63b0fb1d099410dab141953621a2d67328 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Sep 5 15:12:43 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Sep 6 07:50:08 2023 +0200 a11y: Drop unnecessary casting/code for toolbox items All (top-level) toolbox items have always been `VCLXAccessibleToolBoxItem` ever since commit f7da8972336b8ce3e0fb71b0c50464508837a5f3 Author: Jens-Heiner Rechtien <h...@openoffice.org> Date: Wed Jun 27 14:41:59 2007 +0000 INTEGRATION: CWS a11ysep (1.1.2); FILE ADDED 2007/02/28 07:29:13 fs 1.1.2.4: #i10000# 2006/10/05 08:20:15 fs 1.1.2.3: MANUAL RESYNC m130->m185: file had been modified in MWS, but moved herein in CWS 2005/09/28 11:35:38 fs 1.1.2.2: manual resync (files have been moved herein from another location): licence change 2005/03/07 08:29:10 fs 1.1.2.1: #i44293# moved implementations herein from toolkit module , so the dynamic_cast to check whether an item is a `OToolBoxWindowItem` is unnecessary and misleading when reading the code. This is even easier to see now after commit af08e6c2f46a6d99b2e18fe176c15ec2b6edb2fd Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Aug 30 14:02:11 2023 +0200 use concrete type for ToolBoxItemsMap `OToolBoxWindowItem`s are only set as children for the `VCLXAccessibleToolBoxItem`s, s. `VCLXAccessibleToolBox::getAccessibleChild`. Also drop now unused `OToolBoxWindowItem::getIndexInParent` and `OToolBoxWindowItem::setIndexInParent`. Change-Id: I7dcef304942ed25b77918f01cf9b679b6be6e23c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156566 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx index a3ea0ec99d72..acb1d2547133 100644 --- a/accessibility/source/standard/vclxaccessibletoolbox.cxx +++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx @@ -83,10 +83,6 @@ namespace private: sal_Int32 m_nIndexInParent; - public: - sal_Int32 getIndexInParent() const { return m_nIndexInParent; } - void setIndexInParent( sal_Int32 _nNewIndex ) { m_nIndexInParent = _nNewIndex; } - public: OToolBoxWindowItem(sal_Int32 _nIndexInParent, const css::uno::Reference< css::uno::XComponentContext >& _rxContext, @@ -253,26 +249,17 @@ void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( ToolBox::ImplToolItems::si void VCLXAccessibleToolBox::implReleaseToolboxItem( ToolBoxItemsMap::iterator const & _rMapPos, bool _bNotifyRemoval ) { - Reference< XAccessible > xItemAcc( _rMapPos->second ); + rtl::Reference<VCLXAccessibleToolBoxItem> xItemAcc(_rMapPos->second); if ( !xItemAcc.is() ) return; if ( _bNotifyRemoval ) { - NotifyAccessibleEvent( AccessibleEventId::CHILD, Any( xItemAcc ), Any() ); + NotifyAccessibleEvent(AccessibleEventId::CHILD, Any(Reference<XAccessible>(xItemAcc)), Any()); } - auto pWindowItem = dynamic_cast<OToolBoxWindowItem*>(xItemAcc.get()); - if ( !pWindowItem ) - { - static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() )->ReleaseToolBox(); - ::comphelper::disposeComponent( xItemAcc ); - } - else - { - Reference< XAccessibleContext > xContext( pWindowItem->getContextNoCreate() ); - ::comphelper::disposeComponent( xContext ); - } + xItemAcc->ReleaseToolBox(); + xItemAcc->dispose(); } void VCLXAccessibleToolBox::UpdateItem_Impl( ToolBox::ImplToolItems::size_type _nPos) @@ -292,24 +279,12 @@ void VCLXAccessibleToolBox::UpdateItem_Impl( ToolBox::ImplToolItems::size_type _ //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! while ( m_aAccessibleChildren.end() != aIndexAdjust ) { - Reference< XAccessible > xItemAcc( aIndexAdjust->second ); - - auto pWindowItem = dynamic_cast<OToolBoxWindowItem*>(xItemAcc.get()); - if ( !pWindowItem ) - { - VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() ); - if ( pItem ) - { - sal_Int32 nIndex = pItem->getIndexInParent( ); - nIndex++; - pItem->setIndexInParent( nIndex ); - } - } - else + rtl::Reference<VCLXAccessibleToolBoxItem> xItem(aIndexAdjust->second); + if (xItem.is()) { - sal_Int32 nIndex = pWindowItem->getIndexInParent( ); + sal_Int32 nIndex = xItem->getIndexInParent(); nIndex++; - pWindowItem->setIndexInParent( nIndex ); + xItem->setIndexInParent(nIndex); } ++aIndexAdjust;