diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 15:11:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-18 21:46:57 +0200 |
commit | 4f3f61a621a0e66fd0eab4886a3aa51e10513ad3 (patch) | |
tree | 03fa6f0fa067e6d7805cfa95e1c234f7821d4f42 /accessibility | |
parent | 8d4fd3418322f3f6852054c44be2cd74b0db76ee (diff) |
loplugin:flatten in accessibility
Change-Id: I5e02fe0288845210f1d8e41db0342967858098fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92487
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'accessibility')
22 files changed, 974 insertions, 974 deletions
diff --git a/accessibility/source/extended/AccessibleBrowseBoxBase.cxx b/accessibility/source/extended/AccessibleBrowseBoxBase.cxx index 1bdb03948087..7b519e57ab4a 100644 --- a/accessibility/source/extended/AccessibleBrowseBoxBase.cxx +++ b/accessibility/source/extended/AccessibleBrowseBoxBase.cxx @@ -268,21 +268,21 @@ void SAL_CALL AccessibleBrowseBoxBase::addAccessibleEventListener( void SAL_CALL AccessibleBrowseBoxBase::removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener>& _rxListener ) { - if( _rxListener.is() && getClientId( ) ) + if( !(_rxListener.is() && getClientId( )) ) + return; + + ::osl::MutexGuard aGuard( getMutex() ); + sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener ); + if ( !nListenerCount ) { - ::osl::MutexGuard aGuard( getMutex() ); - sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - - AccessibleEventNotifier::TClientId nId( getClientId( ) ); - setClientId( 0 ); - AccessibleEventNotifier::revokeClient( nId ); - } + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + + AccessibleEventNotifier::TClientId nId( getClientId( ) ); + setClientId( 0 ); + AccessibleEventNotifier::revokeClient( nId ); } } diff --git a/accessibility/source/extended/AccessibleGridControl.cxx b/accessibility/source/extended/AccessibleGridControl.cxx index b98104c7695e..5738c6f3fd98 100644 --- a/accessibility/source/extended/AccessibleGridControl.cxx +++ b/accessibility/source/extended/AccessibleGridControl.cxx @@ -293,56 +293,56 @@ void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNew void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue) { - if ( m_xTable.is() ) + if ( !m_xTable.is() ) + return; + + if(_nEventId == AccessibleEventId::ACTIVE_DESCENDANT_CHANGED) { - if(_nEventId == AccessibleEventId::ACTIVE_DESCENDANT_CHANGED) + const sal_Int32 nCurrentRow = m_aTable.GetCurrentRow(); + const sal_Int32 nCurrentCol = m_aTable.GetCurrentColumn(); + css::uno::Reference< css::accessibility::XAccessible > xChild; + if (nCurrentRow > -1 && nCurrentCol > -1) { - const sal_Int32 nCurrentRow = m_aTable.GetCurrentRow(); - const sal_Int32 nCurrentCol = m_aTable.GetCurrentColumn(); - css::uno::Reference< css::accessibility::XAccessible > xChild; - if (nCurrentRow > -1 && nCurrentCol > -1) - { - sal_Int32 nColumnCount = m_aTable.GetColumnCount(); - xChild = m_xTable->getAccessibleChild(nCurrentRow * nColumnCount + nCurrentCol); - } - m_xTable->commitEvent(_nEventId, Any(xChild),_rOldValue); + sal_Int32 nColumnCount = m_aTable.GetColumnCount(); + xChild = m_xTable->getAccessibleChild(nCurrentRow * nColumnCount + nCurrentCol); } - else if(_nEventId == AccessibleEventId::TABLE_MODEL_CHANGED) + m_xTable->commitEvent(_nEventId, Any(xChild),_rOldValue); + } + else if(_nEventId == AccessibleEventId::TABLE_MODEL_CHANGED) + { + AccessibleTableModelChange aChange; + if(_rNewValue >>= aChange) { - AccessibleTableModelChange aChange; - if(_rNewValue >>= aChange) + if(aChange.Type == AccessibleTableModelChangeType::DELETE) { - if(aChange.Type == AccessibleTableModelChangeType::DELETE) + std::vector< AccessibleGridControlTableCell* >& rCells = + m_xTable->getCellVector(); + std::vector< css::uno::Reference< css::accessibility::XAccessible > >& rAccCells = + m_xTable->getAccessibleCellVector(); + int nColCount = m_aTable.GetColumnCount(); + // check valid index - entries are inserted lazily + size_t const nStart = nColCount * aChange.FirstRow; + size_t const nEnd = nColCount * aChange.LastRow; + if (nStart < rCells.size()) + { + m_xTable->getCellVector().erase( + rCells.begin() + nStart, + rCells.begin() + std::min(rCells.size(), nEnd)); + } + if (nStart < rAccCells.size()) { - std::vector< AccessibleGridControlTableCell* >& rCells = - m_xTable->getCellVector(); - std::vector< css::uno::Reference< css::accessibility::XAccessible > >& rAccCells = - m_xTable->getAccessibleCellVector(); - int nColCount = m_aTable.GetColumnCount(); - // check valid index - entries are inserted lazily - size_t const nStart = nColCount * aChange.FirstRow; - size_t const nEnd = nColCount * aChange.LastRow; - if (nStart < rCells.size()) - { - m_xTable->getCellVector().erase( - rCells.begin() + nStart, - rCells.begin() + std::min(rCells.size(), nEnd)); - } - if (nStart < rAccCells.size()) - { - m_xTable->getAccessibleCellVector().erase( - rAccCells.begin() + nStart, - rAccCells.begin() + std::min(rAccCells.size(), nEnd)); - } - m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); + m_xTable->getAccessibleCellVector().erase( + rAccCells.begin() + nStart, + rAccCells.begin() + std::min(rAccCells.size(), nEnd)); } - else - m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); + m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); } + else + m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); } - else - m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); } + else + m_xTable->commitEvent(_nEventId,_rNewValue,_rOldValue); } // = AccessibleGridControlAccess diff --git a/accessibility/source/extended/AccessibleGridControlBase.cxx b/accessibility/source/extended/AccessibleGridControlBase.cxx index 4ba0ee1a90cd..befe2b7c686b 100644 --- a/accessibility/source/extended/AccessibleGridControlBase.cxx +++ b/accessibility/source/extended/AccessibleGridControlBase.cxx @@ -226,21 +226,21 @@ void SAL_CALL AccessibleGridControlBase::addAccessibleEventListener( void SAL_CALL AccessibleGridControlBase::removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener>& _rxListener ) { - if( _rxListener.is() && getClientId( ) ) - { - SolarMutexGuard g; + if( !(_rxListener.is() && getClientId( )) ) + return; - sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - AccessibleEventNotifier::TClientId nId( getClientId( ) ); - setClientId( 0 ); - AccessibleEventNotifier::revokeClient( nId ); - } + SolarMutexGuard g; + + sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( getClientId( ), _rxListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + AccessibleEventNotifier::TClientId nId( getClientId( ) ); + setClientId( 0 ); + AccessibleEventNotifier::revokeClient( nId ); } } diff --git a/accessibility/source/extended/accessibleiconchoicectrl.cxx b/accessibility/source/extended/accessibleiconchoicectrl.cxx index bf2999034722..679a6157de0c 100644 --- a/accessibility/source/extended/accessibleiconchoicectrl.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrl.cxx @@ -53,60 +53,60 @@ namespace accessibility void AccessibleIconChoiceCtrl::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { - if ( isAlive() ) + if ( !isAlive() ) + return; + + switch ( rVclWindowEvent.GetId() ) { - switch ( rVclWindowEvent.GetId() ) + case VclEventId::ListboxSelect : { - case VclEventId::ListboxSelect : - { - // First send an event that tells the listeners of a - // modified selection. The active descendant event is - // send after that so that the receiving AT has time to - // read the text or name of the active child. + // First send an event that tells the listeners of a + // modified selection. The active descendant event is + // send after that so that the receiving AT has time to + // read the text or name of the active child. // NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); - if ( getCtrl() && getCtrl()->HasFocus() ) + if ( getCtrl() && getCtrl()->HasFocus() ) + { + SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) { - SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) - { - sal_Int32 nPos = getCtrl()->GetEntryListPos( pEntry ); - Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *getCtrl(), nPos, this ); - uno::Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); - - NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOldValue, aNewValue ); - - } + sal_Int32 nPos = getCtrl()->GetEntryListPos( pEntry ); + Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *getCtrl(), nPos, this ); + uno::Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); + + NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOldValue, aNewValue ); + } - break; } - case VclEventId::WindowGetFocus : + break; + } + case VclEventId::WindowGetFocus : + { + VclPtr<SvtIconChoiceCtrl> pCtrl = getCtrl(); + if ( pCtrl && pCtrl->HasFocus() ) { - VclPtr<SvtIconChoiceCtrl> pCtrl = getCtrl(); - if ( pCtrl && pCtrl->HasFocus() ) + SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry == nullptr ) { - SvxIconChoiceCtrlEntry* pEntry = static_cast< SvxIconChoiceCtrlEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry == nullptr ) - { - pEntry = getCtrl()->GetSelectedEntry(); - } - if ( pEntry ) - { - sal_Int32 nPos = pCtrl->GetEntryListPos( pEntry ); - Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *pCtrl, nPos, this ); - uno::Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); - NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOldValue, aNewValue ); - } + pEntry = getCtrl()->GetSelectedEntry(); + } + if ( pEntry ) + { + sal_Int32 nPos = pCtrl->GetEntryListPos( pEntry ); + Reference< XAccessible > xChild = new AccessibleIconChoiceCtrlEntry( *pCtrl, nPos, this ); + uno::Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); + NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOldValue, aNewValue ); } - break; } - default: - VCLXAccessibleComponent::ProcessWindowChildEvent (rVclWindowEvent); + break; } + default: + VCLXAccessibleComponent::ProcessWindowChildEvent (rVclWindowEvent); } } diff --git a/accessibility/source/extended/accessibleiconchoicectrlentry.cxx b/accessibility/source/extended/accessibleiconchoicectrlentry.cxx index 38f9e4afbeaf..2add209c4d65 100644 --- a/accessibility/source/extended/accessibleiconchoicectrlentry.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrlentry.cxx @@ -489,21 +489,21 @@ namespace accessibility void SAL_CALL AccessibleIconChoiceCtrlEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) { - if (xListener.is()) - { - ::osl::MutexGuard aGuard( m_aMutex ); + if (!xListener.is()) + return; - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - sal_Int32 nId = m_nClientId; - m_nClientId = 0; - comphelper::AccessibleEventNotifier::revokeClient( nId ); - } + ::osl::MutexGuard aGuard( m_aMutex ); + + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + sal_Int32 nId = m_nClientId; + m_nClientId = 0; + comphelper::AccessibleEventNotifier::revokeClient( nId ); } } diff --git a/accessibility/source/extended/accessiblelistbox.cxx b/accessibility/source/extended/accessiblelistbox.cxx index d56df44e0080..1e1946fe4224 100644 --- a/accessibility/source/extended/accessiblelistbox.cxx +++ b/accessibility/source/extended/accessiblelistbox.cxx @@ -64,137 +64,137 @@ namespace accessibility void AccessibleListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { - if ( isAlive() ) + if ( !isAlive() ) + return; + + switch ( rVclWindowEvent.GetId() ) { - switch ( rVclWindowEvent.GetId() ) + case VclEventId::CheckboxToggle : { - case VclEventId::CheckboxToggle : + if ( !getListBox() || !getListBox()->HasFocus() ) { - if ( !getListBox() || !getListBox()->HasFocus() ) - { - return; - } - AccessibleListBoxEntry* pCurOpEntry = GetCurEventEntry(rVclWindowEvent); - if(!pCurOpEntry) - { - return ; - } - uno::Any aValue; - aValue <<= AccessibleStateType::CHECKED; - - if ( getListBox()->GetCheckButtonState( pCurOpEntry->GetSvLBoxEntry() ) == SvButtonState::Checked ) - { - pCurOpEntry->NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), aValue ); - } - else - { - pCurOpEntry->NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aValue,uno::Any() ); - } - break; + return; } + AccessibleListBoxEntry* pCurOpEntry = GetCurEventEntry(rVclWindowEvent); + if(!pCurOpEntry) + { + return ; + } + uno::Any aValue; + aValue <<= AccessibleStateType::CHECKED; - case VclEventId::ListboxSelect : + if ( getListBox()->GetCheckButtonState( pCurOpEntry->GetSvLBoxEntry() ) == SvButtonState::Checked ) + { + pCurOpEntry->NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), aValue ); + } + else { - OSL_FAIL("Debug: Treelist shouldn't use VclEventId::ListboxSelect"); - break; + pCurOpEntry->NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aValue,uno::Any() ); } + break; + } + + case VclEventId::ListboxSelect : + { + OSL_FAIL("Debug: Treelist shouldn't use VclEventId::ListboxSelect"); + break; + } - case VclEventId::ListboxTreeSelect: + case VclEventId::ListboxTreeSelect: + { + if ( getListBox() && getListBox()->HasFocus() ) { - if ( getListBox() && getListBox()->HasFocus() ) + AccessibleListBoxEntry* pEntry =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get()); + if (pEntry) { - AccessibleListBoxEntry* pEntry =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get()); - if (pEntry) - { - pEntry->NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); - } + pEntry->NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); } } - break; - case VclEventId::ListboxTreeFocus: + } + break; + case VclEventId::ListboxTreeFocus: + { + VclPtr<SvTreeListBox> pBox = getListBox(); + if( pBox && pBox->HasFocus() ) { - VclPtr<SvTreeListBox> pBox = getListBox(); - if( pBox && pBox->HasFocus() ) + uno::Any aNewValue; + SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) { - uno::Any aNewValue; - SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) + AccessibleListBoxEntry* pEntryFocus =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get()); + if (pEntryFocus && pEntryFocus->GetSvLBoxEntry() == pEntry) { - AccessibleListBoxEntry* pEntryFocus =static_cast< AccessibleListBoxEntry* >(m_xFocusedChild.get()); - if (pEntryFocus && pEntryFocus->GetSvLBoxEntry() == pEntry) - { - aNewValue <<= m_xFocusedChild; - NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(), aNewValue ); - return ; - } + aNewValue <<= m_xFocusedChild; + NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(), aNewValue ); + return ; + } - uno::Any aOldValue; - aOldValue <<= m_xFocusedChild; + uno::Any aOldValue; + aOldValue <<= m_xFocusedChild; - m_xFocusedChild.set(implGetAccessible(*pEntry).get()); + m_xFocusedChild.set(implGetAccessible(*pEntry).get()); - aNewValue <<= m_xFocusedChild; - NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); - } - else - { - aNewValue <<= AccessibleStateType::FOCUSED; - NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), aNewValue ); - } + aNewValue <<= m_xFocusedChild; + NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldValue, aNewValue ); + } + else + { + aNewValue <<= AccessibleStateType::FOCUSED; + NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), aNewValue ); } } - break; - case VclEventId::ListboxItemRemoved: + } + break; + case VclEventId::ListboxItemRemoved: + { + SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) { - SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) + RemoveChildEntries(pEntry); + } + else + { + // NULL means Clear() + for (auto const& entry : m_mapEntry) { - RemoveChildEntries(pEntry); + uno::Any aNewValue; + uno::Any aOldValue; + aOldValue <<= uno::Reference<XAccessible>(entry.second.get()); + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); } - else - { - // NULL means Clear() - for (auto const& entry : m_mapEntry) - { - uno::Any aNewValue; - uno::Any aOldValue; - aOldValue <<= uno::Reference<XAccessible>(entry.second.get()); - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - } - for (auto const& entry : m_mapEntry) - { // release references ... - entry.second->dispose(); - } - m_mapEntry.clear(); + for (auto const& entry : m_mapEntry) + { // release references ... + entry.second->dispose(); } + m_mapEntry.clear(); } - break; + } + break; - // #i92103# - case VclEventId::ItemExpanded : - case VclEventId::ItemCollapsed : + // #i92103# + case VclEventId::ItemExpanded : + case VclEventId::ItemCollapsed : + { + SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) { - SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) + Reference<XAccessible> const xChild(implGetAccessible(*pEntry).get()); + const short nAccEvent = + ( rVclWindowEvent.GetId() == VclEventId::ItemExpanded ) + ? AccessibleEventId::LISTBOX_ENTRY_EXPANDED + : AccessibleEventId::LISTBOX_ENTRY_COLLAPSED; + uno::Any aListBoxEntry; + aListBoxEntry <<= xChild; + NotifyAccessibleEvent( nAccEvent, Any(), aListBoxEntry ); + if ( getListBox() && getListBox()->HasFocus() ) { - Reference<XAccessible> const xChild(implGetAccessible(*pEntry).get()); - const short nAccEvent = - ( rVclWindowEvent.GetId() == VclEventId::ItemExpanded ) - ? AccessibleEventId::LISTBOX_ENTRY_EXPANDED - : AccessibleEventId::LISTBOX_ENTRY_COLLAPSED; - uno::Any aListBoxEntry; - aListBoxEntry <<= xChild; - NotifyAccessibleEvent( nAccEvent, Any(), aListBoxEntry ); - if ( getListBox() && getListBox()->HasFocus() ) - { - NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), aListBoxEntry ); - } + NotifyAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), aListBoxEntry ); } } - break; - default: - VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent); } + break; + default: + VCLXAccessibleComponent::ProcessWindowEvent (rVclWindowEvent); } } diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx b/accessibility/source/extended/accessiblelistboxentry.cxx index 7b5b055f4d95..22dc36aef3a1 100644 --- a/accessibility/source/extended/accessiblelistboxentry.cxx +++ b/accessibility/source/extended/accessiblelistboxentry.cxx @@ -96,20 +96,20 @@ namespace accessibility OSL_ENSURE( rEvent.GetWindow() , "AccessibleListBoxEntry::WindowEventListener: no event window!" ); OSL_ENSURE( rEvent.GetWindow() == m_pTreeListBox, "AccessibleListBoxEntry::WindowEventListener: where did this come from?" ); - if ( m_pTreeListBox != nullptr ) + if ( m_pTreeListBox == nullptr ) + return; + + switch ( rEvent.GetId() ) { - switch ( rEvent.GetId() ) + case VclEventId::ObjectDying : { - case VclEventId::ObjectDying : - { - if ( m_pTreeListBox ) - m_pTreeListBox->RemoveEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) ); - m_pTreeListBox = nullptr; - dispose(); - break; - } - default: break; + if ( m_pTreeListBox ) + m_pTreeListBox->RemoveEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) ); + m_pTreeListBox = nullptr; + dispose(); + break; } + default: break; } } @@ -710,22 +710,22 @@ namespace accessibility void SAL_CALL AccessibleListBoxEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) { - if (xListener.is()) - { - ::osl::MutexGuard aGuard( m_aMutex ); + if (!xListener.is()) + return; - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - sal_Int32 nId = m_nClientId; - m_nClientId = 0; - comphelper::AccessibleEventNotifier::revokeClient( nId ); + ::osl::MutexGuard aGuard( m_aMutex ); + + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + sal_Int32 nId = m_nClientId; + m_nClientId = 0; + comphelper::AccessibleEventNotifier::revokeClient( nId ); - } } } diff --git a/accessibility/source/extended/accessibletabbar.cxx b/accessibility/source/extended/accessibletabbar.cxx index 6f36c75e3721..2ba95b88bfb8 100644 --- a/accessibility/source/extended/accessibletabbar.cxx +++ b/accessibility/source/extended/accessibletabbar.cxx @@ -113,27 +113,27 @@ namespace accessibility void AccessibleTabBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) { - if ( m_pTabBar ) + if ( !m_pTabBar ) + return; + + if ( m_pTabBar->IsEnabled() ) { - if ( m_pTabBar->IsEnabled() ) - { - rStateSet.AddState( AccessibleStateType::ENABLED ); - rStateSet.AddState( AccessibleStateType::SENSITIVE ); - } + rStateSet.AddState( AccessibleStateType::ENABLED ); + rStateSet.AddState( AccessibleStateType::SENSITIVE ); + } - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - if ( m_pTabBar->HasFocus() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); + if ( m_pTabBar->HasFocus() ) + rStateSet.AddState( AccessibleStateType::FOCUSED ); - rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( m_pTabBar->IsVisible() ) - rStateSet.AddState( AccessibleStateType::SHOWING ); + if ( m_pTabBar->IsVisible() ) + rStateSet.AddState( AccessibleStateType::SHOWING ); - if ( m_pTabBar->GetStyle() & WB_SIZEABLE ) - rStateSet.AddState( AccessibleStateType::RESIZABLE ); - } + if ( m_pTabBar->GetStyle() & WB_SIZEABLE ) + rStateSet.AddState( AccessibleStateType::RESIZABLE ); } diff --git a/accessibility/source/extended/accessibletabbarpagelist.cxx b/accessibility/source/extended/accessibletabbarpagelist.cxx index 6b8d03c2420a..680e0e70ba97 100644 --- a/accessibility/source/extended/accessibletabbarpagelist.cxx +++ b/accessibility/source/extended/accessibletabbarpagelist.cxx @@ -88,17 +88,17 @@ namespace accessibility void AccessibleTabBarPageList::UpdatePageText( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; + + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( xChild.is() ) { - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - if ( xChild.is() ) + AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() ); + if ( pAccessibleTabBarPage && m_pTabBar ) { - AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() ); - if ( pAccessibleTabBarPage && m_pTabBar ) - { - OUString sPageText = m_pTabBar->GetPageText( m_pTabBar->GetPageId( static_cast<sal_uInt16>(i) ) ); - pAccessibleTabBarPage->SetPageText( sPageText ); - } + OUString sPageText = m_pTabBar->GetPageText( m_pTabBar->GetPageId( static_cast<sal_uInt16>(i) ) ); + pAccessibleTabBarPage->SetPageText( sPageText ); } } } @@ -106,65 +106,65 @@ namespace accessibility void AccessibleTabBarPageList::InsertChild( sal_Int32 i ) { - if ( i >= 0 && i <= static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // insert entry in child list - m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + if ( !(i >= 0 && i <= static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // send accessible child event - Reference< XAccessible > xChild( getAccessibleChild( i ) ); - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - } + // insert entry in child list + m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + + // send accessible child event + Reference< XAccessible > xChild( getAccessibleChild( i ) ); + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); } } void AccessibleTabBarPageList::RemoveChild( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // get the accessible of the removed page - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // remove entry in child list - m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); + // get the accessible of the removed page + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - // send accessible child event - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aOldValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + // remove entry in child list + m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } + // send accessible child event + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aOldValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + + Reference< XComponent > xComponent( xChild, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } } void AccessibleTabBarPageList::MoveChild( sal_Int32 i, sal_Int32 j ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) && - j >= 0 && j <= static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - if ( i < j ) - --j; + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) && + j >= 0 && j <= static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // get the accessible of the moved page - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( i < j ) + --j; - // remove entry in child list at old position - m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); + // get the accessible of the moved page + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - // insert entry in child list at new position - m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + j, xChild ); - } + // remove entry in child list at old position + m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); + + // insert entry in child list at new position + m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + j, xChild ); } @@ -296,19 +296,19 @@ namespace accessibility void AccessibleTabBarPageList::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) { - if ( m_pTabBar ) + if ( !m_pTabBar ) + return; + + if ( m_pTabBar->IsEnabled() ) { - if ( m_pTabBar->IsEnabled() ) - { - rStateSet.AddState( AccessibleStateType::ENABLED ); - rStateSet.AddState( AccessibleStateType::SENSITIVE ); - } + rStateSet.AddState( AccessibleStateType::ENABLED ); + rStateSet.AddState( AccessibleStateType::SENSITIVE ); + } - rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( m_pTabBar->IsVisible() ) - rStateSet.AddState( AccessibleStateType::SHOWING ); - } + if ( m_pTabBar->IsVisible() ) + rStateSet.AddState( AccessibleStateType::SHOWING ); } diff --git a/accessibility/source/extended/accessibletablistboxtable.cxx b/accessibility/source/extended/accessibletablistboxtable.cxx index 9b324862e1ef..14d48bcad280 100644 --- a/accessibility/source/extended/accessibletablistboxtable.cxx +++ b/accessibility/source/extended/accessibletablistboxtable.cxx @@ -63,135 +63,135 @@ namespace accessibility void AccessibleTabListBoxTable::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { - if ( isAlive() ) + if ( !isAlive() ) + return; + + switch ( VclEventId nEventId = rVclWindowEvent.GetId(); nEventId ) { - switch ( VclEventId nEventId = rVclWindowEvent.GetId(); nEventId ) + case VclEventId::ObjectDying : { - case VclEventId::ObjectDying : - { - m_pTabListBox->RemoveEventListener( LINK( this, AccessibleTabListBoxTable, WindowEventListener ) ); - m_pTabListBox = nullptr; - break; - } + m_pTabListBox->RemoveEventListener( LINK( this, AccessibleTabListBoxTable, WindowEventListener ) ); + m_pTabListBox = nullptr; + break; + } + + case VclEventId::ControlGetFocus : + case VclEventId::ControlLoseFocus : + { + uno::Any aOldValue, aNewValue; + if ( nEventId == VclEventId::ControlGetFocus ) + aNewValue <<= AccessibleStateType::FOCUSED; + else + aOldValue <<= AccessibleStateType::FOCUSED; + commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue ); + break; + } - case VclEventId::ControlGetFocus : - case VclEventId::ControlLoseFocus : + case VclEventId::ListboxSelect : + { + // First send an event that tells the listeners of a + // modified selection. The active descendant event is + // send after that so that the receiving AT has time to + // read the text or name of the active child. + commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); + if ( m_pTabListBox && m_pTabListBox->HasFocus() ) { - uno::Any aOldValue, aNewValue; - if ( nEventId == VclEventId::ControlGetFocus ) - aNewValue <<= AccessibleStateType::FOCUSED; - else - aOldValue <<= AccessibleStateType::FOCUSED; - commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue ); - break; + SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) + { + sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); + sal_uInt16 nCol = m_pTabListBox->GetCurrColumn(); + Reference< XAccessible > xChild = + m_pTabListBox->CreateAccessibleCell( nRow, nCol ); + uno::Any aOldValue, aNewValue; + aNewValue <<= xChild; + commitEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aNewValue, aOldValue ); + } } + break; + } + case VclEventId::WindowGetFocus : + { + uno::Any aOldValue, aNewValue; + aNewValue <<= AccessibleStateType::FOCUSED; + commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue ); + break; - case VclEventId::ListboxSelect : + } + case VclEventId::WindowLoseFocus : + { + uno::Any aOldValue, aNewValue; + aOldValue <<= AccessibleStateType::FOCUSED; + commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue ); + break; + } + case VclEventId::ListboxTreeSelect: { - // First send an event that tells the listeners of a - // modified selection. The active descendant event is - // send after that so that the receiving AT has time to - // read the text or name of the active child. - commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); - if ( m_pTabListBox && m_pTabListBox->HasFocus() ) + SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); + if (pEntry) { - SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) + sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); + Reference< XAccessible > xChild = m_pTabListBox->CreateAccessibleCell( nRow, m_pTabListBox->GetCurrColumn() ); + TriState eState = TRISTATE_INDET; + if ( m_pTabListBox->IsCellCheckBox( nRow, m_pTabListBox->GetCurrColumn(), eState ) ) { - sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); - sal_uInt16 nCol = m_pTabListBox->GetCurrColumn(); - Reference< XAccessible > xChild = - m_pTabListBox->CreateAccessibleCell( nRow, nCol ); - uno::Any aOldValue, aNewValue; - aNewValue <<= xChild; - commitEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aNewValue, aOldValue ); + AccessibleCheckBoxCell* pCell = static_cast< AccessibleCheckBoxCell* >( xChild.get() ); + pCell->commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); + } + else + { + AccessibleBrowseBoxTableCell* pCell = static_cast< AccessibleBrowseBoxTableCell* >( xChild.get() ); + pCell->commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); } } - break; - } - case VclEventId::WindowGetFocus : - { - uno::Any aOldValue, aNewValue; - aNewValue <<= AccessibleStateType::FOCUSED; - commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue ); - break; - } - case VclEventId::WindowLoseFocus : + break; + case VclEventId::ListboxTreeFocus: { - uno::Any aOldValue, aNewValue; - aOldValue <<= AccessibleStateType::FOCUSED; - commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue ); - break; - } - case VclEventId::ListboxTreeSelect: + if ( m_pTabListBox && m_pTabListBox->HasFocus() ) { + uno::Any aOldValue, aNewValue; SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if (pEntry) + if ( pEntry ) { sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); - Reference< XAccessible > xChild = m_pTabListBox->CreateAccessibleCell( nRow, m_pTabListBox->GetCurrColumn() ); - TriState eState = TRISTATE_INDET; - if ( m_pTabListBox->IsCellCheckBox( nRow, m_pTabListBox->GetCurrColumn(), eState ) ) - { - AccessibleCheckBoxCell* pCell = static_cast< AccessibleCheckBoxCell* >( xChild.get() ); - pCell->commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); - } - else - { - AccessibleBrowseBoxTableCell* pCell = static_cast< AccessibleBrowseBoxTableCell* >( xChild.get() ); - pCell->commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); - } + m_xCurChild = m_pTabListBox->CreateAccessibleCell( nRow, m_pTabListBox->GetCurrColumn() ); + aNewValue <<= m_xCurChild; + commitEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aNewValue ,aOldValue); } - } - break; - case VclEventId::ListboxTreeFocus: - { - if ( m_pTabListBox && m_pTabListBox->HasFocus() ) + else { - uno::Any aOldValue, aNewValue; - SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) - { - sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); - m_xCurChild = m_pTabListBox->CreateAccessibleCell( nRow, m_pTabListBox->GetCurrColumn() ); - aNewValue <<= m_xCurChild; - commitEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aNewValue ,aOldValue); - } - else - { - aNewValue <<= AccessibleStateType::FOCUSED; - commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue ,aOldValue); - } + aNewValue <<= AccessibleStateType::FOCUSED; + commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue ,aOldValue); } } - break; + } + break; - case VclEventId::CheckboxToggle : + case VclEventId::CheckboxToggle : + { + if ( m_pTabListBox && m_pTabListBox->HasFocus() ) { - if ( m_pTabListBox && m_pTabListBox->HasFocus() ) + SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); + if ( pEntry ) { - SvTreeListEntry* pEntry = static_cast< SvTreeListEntry* >( rVclWindowEvent.GetData() ); - if ( pEntry ) + sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); + sal_uInt16 nCol = m_pTabListBox->GetCurrColumn(); + TriState eState = TRISTATE_INDET; + if ( m_pTabListBox->IsCellCheckBox( nRow, nCol, eState ) ) { - sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry ); - sal_uInt16 nCol = m_pTabListBox->GetCurrColumn(); - TriState eState = TRISTATE_INDET; - if ( m_pTabListBox->IsCellCheckBox( nRow, nCol, eState ) ) - { - Reference< XAccessible > xChild = - m_pTabListBox->CreateAccessibleCell( nRow, nCol ); - AccessibleCheckBoxCell* pCell = - static_cast< AccessibleCheckBoxCell* >( xChild.get() ); - pCell->SetChecked( SvHeaderTabListBox::IsItemChecked( pEntry, nCol ) ); - } + Reference< XAccessible > xChild = + m_pTabListBox->CreateAccessibleCell( nRow, nCol ); + AccessibleCheckBoxCell* pCell = + static_cast< AccessibleCheckBoxCell* >( xChild.get() ); + pCell->SetChecked( SvHeaderTabListBox::IsItemChecked( pEntry, nCol ) ); } } - break; } - - default: break; + break; } + + default: break; } } diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index 882f38124def..7ab7c52aff12 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -570,21 +570,21 @@ void SAL_CALL Paragraph::addAccessibleEventListener( css::uno::Reference< css::accessibility::XAccessibleEventListener > const & rListener) { - if (rListener.is()) + if (!rListener.is()) + return; + + ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); + if (rBHelper.bDisposed || rBHelper.bInDispose) { - ::osl::ClearableMutexGuard aGuard(rBHelper.rMutex); - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - aGuard.clear(); - rListener->disposing(css::lang::EventObject( - static_cast< ::cppu::OWeakObject * >(this))); - } - else - { - if (!m_nClientId) - m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); - comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, rListener ); - } + aGuard.clear(); + rListener->disposing(css::lang::EventObject( + static_cast< ::cppu::OWeakObject * >(this))); + } + else + { + if (!m_nClientId) + m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); + comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, rListener ); } } @@ -1396,101 +1396,101 @@ void SAL_CALL Document::disposing() void Document::Notify(::SfxBroadcaster &, ::SfxHint const & rHint) { const TextHint* pTextHint = dynamic_cast<const TextHint*>(&rHint); - if (pTextHint) + if (!pTextHint) + return; + + ::TextHint const & rTextHint = *pTextHint; + switch (rTextHint.GetId()) { - ::TextHint const & rTextHint = *pTextHint; - switch (rTextHint.GetId()) + case SfxHintId::TextParaInserted: + case SfxHintId::TextParaRemoved: + // SfxHintId::TextParaInserted and SfxHintId::TextParaRemoved are sent at + // "unsafe" times (when the text engine has not yet re-formatted its + // content), so that for example calling ::TextEngine::GetTextHeight + // from within the code that handles SfxHintId::TextParaInserted causes + // trouble within the text engine. Therefore, these hints are just + // buffered until a following ::TextEngine::FormatDoc causes a + // SfxHintId::TextFormatted to come in: + case SfxHintId::TextFormatPara: + // ::TextEngine::FormatDoc sends a sequence of + // SfxHintId::TextFormatParas, followed by an optional + // SfxHintId::TextHeightChanged, followed in all cases by one + // SfxHintId::TextFormatted. Only the SfxHintId::TextFormatParas contain + // the numbers of the affected paragraphs, but they are sent + // before the changes are applied. Therefore, SfxHintId::TextFormatParas + // are just buffered until another hint comes in: { - case SfxHintId::TextParaInserted: - case SfxHintId::TextParaRemoved: - // SfxHintId::TextParaInserted and SfxHintId::TextParaRemoved are sent at - // "unsafe" times (when the text engine has not yet re-formatted its - // content), so that for example calling ::TextEngine::GetTextHeight - // from within the code that handles SfxHintId::TextParaInserted causes - // trouble within the text engine. Therefore, these hints are just - // buffered until a following ::TextEngine::FormatDoc causes a - // SfxHintId::TextFormatted to come in: - case SfxHintId::TextFormatPara: - // ::TextEngine::FormatDoc sends a sequence of - // SfxHintId::TextFormatParas, followed by an optional - // SfxHintId::TextHeightChanged, followed in all cases by one - // SfxHintId::TextFormatted. Only the SfxHintId::TextFormatParas contain - // the numbers of the affected paragraphs, but they are sent - // before the changes are applied. Therefore, SfxHintId::TextFormatParas - // are just buffered until another hint comes in: - { - ::osl::MutexGuard aInternalGuard(GetMutex()); - if (!isAlive()) - break; + ::osl::MutexGuard aInternalGuard(GetMutex()); + if (!isAlive()) + break; - m_aParagraphNotifications.push(rTextHint); + m_aParagraphNotifications.push(rTextHint); + break; + } + case SfxHintId::TextFormatted: + case SfxHintId::TextHeightChanged: + case SfxHintId::TextModified: + { + ::osl::MutexGuard aInternalGuard(GetMutex()); + if (!isAlive()) break; - } - case SfxHintId::TextFormatted: - case SfxHintId::TextHeightChanged: - case SfxHintId::TextModified: - { - ::osl::MutexGuard aInternalGuard(GetMutex()); - if (!isAlive()) - break; - handleParagraphNotifications(); + handleParagraphNotifications(); + break; + } + case SfxHintId::TextViewScrolled: + { + ::osl::MutexGuard aInternalGuard(GetMutex()); + if (!isAlive()) break; - } - case SfxHintId::TextViewScrolled: - { - ::osl::MutexGuard aInternalGuard(GetMutex()); - if (!isAlive()) - break; - handleParagraphNotifications(); + handleParagraphNotifications(); - ::sal_Int32 nOffset = static_cast< ::sal_Int32 >( - m_rView.GetStartDocPos().Y()); - // XXX numeric overflow - if (nOffset != m_nViewOffset) - { - m_nViewOffset = nOffset; + ::sal_Int32 nOffset = static_cast< ::sal_Int32 >( + m_rView.GetStartDocPos().Y()); + // XXX numeric overflow + if (nOffset != m_nViewOffset) + { + m_nViewOffset = nOffset; - Paragraphs::iterator aOldVisibleBegin( - m_aVisibleBegin); - Paragraphs::iterator aOldVisibleEnd(m_aVisibleEnd); + Paragraphs::iterator aOldVisibleBegin( + m_aVisibleBegin); + Paragraphs::iterator aOldVisibleEnd(m_aVisibleEnd); - determineVisibleRange(); + determineVisibleRange(); - notifyVisibleRangeChanges(aOldVisibleBegin, - aOldVisibleEnd, - m_xParagraphs->end()); - } + notifyVisibleRangeChanges(aOldVisibleBegin, + aOldVisibleEnd, + m_xParagraphs->end()); + } + break; + } + case SfxHintId::TextViewSelectionChanged: + case SfxHintId::TextViewCaretChanged: + { + ::osl::MutexGuard aInternalGuard(GetMutex()); + if (!isAlive()) break; + + if (m_aParagraphNotifications.empty()) + { + handleSelectionChangeNotification(); } - case SfxHintId::TextViewSelectionChanged: - case SfxHintId::TextViewCaretChanged: + else { - ::osl::MutexGuard aInternalGuard(GetMutex()); - if (!isAlive()) - break; - - if (m_aParagraphNotifications.empty()) - { - handleSelectionChangeNotification(); - } - else - { - // SfxHintId::TextViewSelectionChanged is sometimes sent at - // "unsafe" times (when the text engine has not yet re- - // formatted its content), so that for example calling - // ::TextEngine::GetTextHeight from within the code that - // handles a previous SfxHintId::TextParaInserted causes - // trouble within the text engine. Therefore, these - // hints are just buffered (along with - // SfxHintId::TextParaInserted/REMOVED/FORMATPARA) until a - // following ::TextEngine::FormatDoc causes a - // SfxHintId::TextFormatted to come in: - m_bSelectionChangedNotification = true; - } - break; + // SfxHintId::TextViewSelectionChanged is sometimes sent at + // "unsafe" times (when the text engine has not yet re- + // formatted its content), so that for example calling + // ::TextEngine::GetTextHeight from within the code that + // handles a previous SfxHintId::TextParaInserted causes + // trouble within the text engine. Therefore, these + // hints are just buffered (along with + // SfxHintId::TextParaInserted/REMOVED/FORMATPARA) until a + // following ::TextEngine::FormatDoc causes a + // SfxHintId::TextFormatted to come in: + m_bSelectionChangedNotification = true; } - default: break; + break; } + default: break; } } @@ -1575,31 +1575,31 @@ IMPL_LINK(Document, WindowEventHandler, ::VclWindowEvent&, rEvent, void) void Document::init() { - if (m_xParagraphs == nullptr) - { - const ::sal_uInt32 nCount = m_rEngine.GetParagraphCount(); - m_xParagraphs.reset(new Paragraphs); - m_xParagraphs->reserve(static_cast< Paragraphs::size_type >(nCount)); - // numeric overflow is harmless here - for (::sal_uInt32 i = 0; i < nCount; ++i) - m_xParagraphs->push_back(ParagraphInfo(static_cast< ::sal_Int32 >( - m_rEngine.GetTextHeight(i)))); - // XXX numeric overflow - m_nViewOffset = static_cast< ::sal_Int32 >( - m_rView.GetStartDocPos().Y()); // XXX numeric overflow - m_nViewHeight = static_cast< ::sal_Int32 >( - m_rView.GetWindow()->GetOutputSizePixel().Height()); + if (m_xParagraphs != nullptr) + return; + + const ::sal_uInt32 nCount = m_rEngine.GetParagraphCount(); + m_xParagraphs.reset(new Paragraphs); + m_xParagraphs->reserve(static_cast< Paragraphs::size_type >(nCount)); + // numeric overflow is harmless here + for (::sal_uInt32 i = 0; i < nCount; ++i) + m_xParagraphs->push_back(ParagraphInfo(static_cast< ::sal_Int32 >( + m_rEngine.GetTextHeight(i)))); // XXX numeric overflow - determineVisibleRange(); - m_nSelectionFirstPara = -1; - m_nSelectionFirstPos = -1; - m_nSelectionLastPara = -1; - m_nSelectionLastPos = -1; - m_aFocused = m_xParagraphs->end(); - m_bSelectionChangedNotification = false; - m_aEngineListener.startListening(m_rEngine); - m_aViewListener.startListening(*m_rView.GetWindow()); - } + m_nViewOffset = static_cast< ::sal_Int32 >( + m_rView.GetStartDocPos().Y()); // XXX numeric overflow + m_nViewHeight = static_cast< ::sal_Int32 >( + m_rView.GetWindow()->GetOutputSizePixel().Height()); + // XXX numeric overflow + determineVisibleRange(); + m_nSelectionFirstPara = -1; + m_nSelectionFirstPos = -1; + m_nSelectionLastPara = -1; + m_nSelectionLastPos = -1; + m_aFocused = m_xParagraphs->end(); + m_bSelectionChangedNotification = false; + m_aEngineListener.startListening(m_rEngine); + m_aViewListener.startListening(*m_rView.GetWindow()); } ::rtl::Reference< Paragraph > diff --git a/accessibility/source/standard/accessiblemenubasecomponent.cxx b/accessibility/source/standard/accessiblemenubasecomponent.cxx index 5431efd0d112..d3070d1bacb6 100644 --- a/accessibility/source/standard/accessiblemenubasecomponent.cxx +++ b/accessibility/source/standard/accessiblemenubasecomponent.cxx @@ -107,28 +107,28 @@ void OAccessibleMenuBaseComponent::SetStates() void OAccessibleMenuBaseComponent::SetEnabled( bool bEnabled ) { - if ( m_bEnabled != bEnabled ) + if ( m_bEnabled == bEnabled ) + return; + + sal_Int16 nStateType=AccessibleStateType::ENABLED; + if (IsMenuHideDisabledEntries()) { - sal_Int16 nStateType=AccessibleStateType::ENABLED; - if (IsMenuHideDisabledEntries()) - { - nStateType = AccessibleStateType::VISIBLE; - } - std::array<Any, 2> aOldValue, aNewValue; - if ( m_bEnabled ) - { - aOldValue[0] <<= AccessibleStateType::SENSITIVE; - aOldValue[1] <<= nStateType; - } - else - { - aNewValue[0] <<= nStateType; - aNewValue[1] <<= AccessibleStateType::SENSITIVE; - } - m_bEnabled = bEnabled; - NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] ); - NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] ); + nStateType = AccessibleStateType::VISIBLE; + } + std::array<Any, 2> aOldValue, aNewValue; + if ( m_bEnabled ) + { + aOldValue[0] <<= AccessibleStateType::SENSITIVE; + aOldValue[1] <<= nStateType; + } + else + { + aNewValue[0] <<= nStateType; + aNewValue[1] <<= AccessibleStateType::SENSITIVE; } + m_bEnabled = bEnabled; + NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] ); + NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] ); } @@ -378,68 +378,68 @@ void OAccessibleMenuBaseComponent::InsertChild( sal_Int32 i ) if ( i > static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) i = m_aAccessibleChildren.size(); - if ( i >= 0 ) - { - // insert entry in child list - m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + if ( i < 0 ) + return; - // update item position of accessible children - for ( sal_uInt32 j = i, nCount = m_aAccessibleChildren.size(); j < nCount; ++j ) - { - Reference< XAccessible > xAcc( m_aAccessibleChildren[j] ); - if ( xAcc.is() ) - { - OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xAcc.get() ); - if ( pComp ) - pComp->SetItemPos( static_cast<sal_uInt16>(j) ); - } - } + // insert entry in child list + m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); - // send accessible child event - Reference< XAccessible > xChild( GetChild( i ) ); - if ( xChild.is() ) + // update item position of accessible children + for ( sal_uInt32 j = i, nCount = m_aAccessibleChildren.size(); j < nCount; ++j ) + { + Reference< XAccessible > xAcc( m_aAccessibleChildren[j] ); + if ( xAcc.is() ) { - Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xAcc.get() ); + if ( pComp ) + pComp->SetItemPos( static_cast<sal_uInt16>(j) ); } } + + // send accessible child event + Reference< XAccessible > xChild( GetChild( i ) ); + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + } } void OAccessibleMenuBaseComponent::RemoveChild( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // keep the accessible of the removed item - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; + + // keep the accessible of the removed item + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - // remove entry in child list - m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); + // remove entry in child list + m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); - // update item position of accessible children - for ( sal_uInt32 j = i, nCount = m_aAccessibleChildren.size(); j < nCount; ++j ) + // update item position of accessible children + for ( sal_uInt32 j = i, nCount = m_aAccessibleChildren.size(); j < nCount; ++j ) + { + Reference< XAccessible > xAcc( m_aAccessibleChildren[j] ); + if ( xAcc.is() ) { - Reference< XAccessible > xAcc( m_aAccessibleChildren[j] ); - if ( xAcc.is() ) - { - OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xAcc.get() ); - if ( pComp ) - pComp->SetItemPos( static_cast<sal_uInt16>(j) ); - } + OAccessibleMenuItemComponent* pComp = static_cast< OAccessibleMenuItemComponent* >( xAcc.get() ); + if ( pComp ) + pComp->SetItemPos( static_cast<sal_uInt16>(j) ); } + } - // send accessible child event - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aOldValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + // send accessible child event + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aOldValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } + Reference< XComponent > xComponent( xChild, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } } @@ -641,21 +641,21 @@ void OAccessibleMenuBaseComponent::disposing() { OAccessibleExtendedComponentHelper::disposing(); - if ( m_pMenu ) - { - m_pMenu->RemoveEventListener( LINK( this, OAccessibleMenuBaseComponent, MenuEventListener ) ); + if ( !m_pMenu ) + return; - m_pMenu = nullptr; + m_pMenu->RemoveEventListener( LINK( this, OAccessibleMenuBaseComponent, MenuEventListener ) ); - // dispose all menu items - for (const Reference<XAccessible>& i : m_aAccessibleChildren) - { - Reference< XComponent > xComponent( i, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } - m_aAccessibleChildren.clear(); + m_pMenu = nullptr; + + // dispose all menu items + for (const Reference<XAccessible>& i : m_aAccessibleChildren) + { + Reference< XComponent > xComponent( i, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } + m_aAccessibleChildren.clear(); } diff --git a/accessibility/source/standard/accessiblemenuitemcomponent.cxx b/accessibility/source/standard/accessiblemenuitemcomponent.cxx index 15112bfa4e24..c4e08609fe04 100644 --- a/accessibility/source/standard/accessiblemenuitemcomponent.cxx +++ b/accessibility/source/standard/accessiblemenuitemcomponent.cxx @@ -117,37 +117,37 @@ void OAccessibleMenuItemComponent::Click() } // click the menu item - if ( m_pParent ) + if ( !m_pParent ) + return; + + vcl::Window* pWindow = m_pParent->GetWindow(); + if ( !pWindow ) + return; + + // #102438# Menu items are not selectable + // Popup menus are executed asynchronously, triggered by a timer. + // As Menu::SelectItem only works, if the corresponding menu window is + // already created, we have to set the menu delay to 0, so + // that the popup menus are executed synchronously. + AllSettings aSettings = pWindow->GetSettings(); + MouseSettings aMouseSettings = aSettings.GetMouseSettings(); + sal_uLong nDelay = aMouseSettings.GetMenuDelay(); + aMouseSettings.SetMenuDelay( 0 ); + aSettings.SetMouseSettings( aMouseSettings ); + pWindow->SetSettings( aSettings ); + + m_pParent->SelectItem( m_pParent->GetItemId( m_nItemPos ) ); + + // meanwhile the window pointer may be invalid + pWindow = m_pParent->GetWindow(); + if ( pWindow ) { - vcl::Window* pWindow = m_pParent->GetWindow(); - if ( pWindow ) - { - // #102438# Menu items are not selectable - // Popup menus are executed asynchronously, triggered by a timer. - // As Menu::SelectItem only works, if the corresponding menu window is - // already created, we have to set the menu delay to 0, so - // that the popup menus are executed synchronously. - AllSettings aSettings = pWindow->GetSettings(); - MouseSettings aMouseSettings = aSettings.GetMouseSettings(); - sal_uLong nDelay = aMouseSettings.GetMenuDelay(); - aMouseSettings.SetMenuDelay( 0 ); - aSettings.SetMouseSettings( aMouseSettings ); - pWindow->SetSettings( aSettings ); - - m_pParent->SelectItem( m_pParent->GetItemId( m_nItemPos ) ); - - // meanwhile the window pointer may be invalid - pWindow = m_pParent->GetWindow(); - if ( pWindow ) - { - // set the menu delay back to the old value - aSettings = pWindow->GetSettings(); - aMouseSettings = aSettings.GetMouseSettings(); - aMouseSettings.SetMenuDelay( nDelay ); - aSettings.SetMouseSettings( aMouseSettings ); - pWindow->SetSettings( aSettings ); - } - } + // set the menu delay back to the old value + aSettings = pWindow->GetSettings(); + aMouseSettings = aSettings.GetMouseSettings(); + aMouseSettings.SetMenuDelay( nDelay ); + aSettings.SetMouseSettings( aMouseSettings ); + pWindow->SetSettings( aSettings ); } } diff --git a/accessibility/source/standard/vclxaccessiblebutton.cxx b/accessibility/source/standard/vclxaccessiblebutton.cxx index b5289d7ed9d8..f0ade105ce27 100644 --- a/accessibility/source/standard/vclxaccessiblebutton.cxx +++ b/accessibility/source/standard/vclxaccessiblebutton.cxx @@ -73,25 +73,25 @@ void VCLXAccessibleButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet ); VclPtr< PushButton > pButton = GetAs< PushButton >(); - if ( pButton ) - { - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + if ( !pButton ) + return; - if ( pButton->GetState() == TRISTATE_TRUE ) - rStateSet.AddState( AccessibleStateType::CHECKED ); + rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - if ( pButton->IsPressed() ) - rStateSet.AddState( AccessibleStateType::PRESSED ); + if ( pButton->GetState() == TRISTATE_TRUE ) + rStateSet.AddState( AccessibleStateType::CHECKED ); - // IA2 CWS: if the button has a popup menu, it should has the state EXPANDABLE - if( pButton->GetType() == WindowType::MENUBUTTON ) - { - rStateSet.AddState( AccessibleStateType::EXPANDABLE ); - } - if( pButton->GetStyle() & WB_DEFBUTTON ) - { - rStateSet.AddState( AccessibleStateType::DEFAULT ); - } + if ( pButton->IsPressed() ) + rStateSet.AddState( AccessibleStateType::PRESSED ); + + // IA2 CWS: if the button has a popup menu, it should has the state EXPANDABLE + if( pButton->GetType() == WindowType::MENUBUTTON ) + { + rStateSet.AddState( AccessibleStateType::EXPANDABLE ); + } + if( pButton->GetStyle() & WB_DEFBUTTON ) + { + rStateSet.AddState( AccessibleStateType::DEFAULT ); } } diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx index de2dfc399311..5eae30ecd602 100644 --- a/accessibility/source/standard/vclxaccessiblelist.cxx +++ b/accessibility/source/standard/vclxaccessiblelist.cxx @@ -176,21 +176,21 @@ void VCLXAccessibleList::notifyVisibleStates(bool _bSetNew ) void VCLXAccessibleList::UpdateSelection_Acc (const OUString& /*sTextOfSelectedItem*/, bool b_IsDropDownList) { - if ( m_aBoxType == COMBOBOX ) - { - /* FIXME: is there something missing here? nIndex is unused. Looks like - * copy-paste from VCLXAccessibleList::UpdateSelection() */ - // VclPtr< ComboBox > pBox = GetAs< ComboBox >(); - // if ( pBox ) - // { - // // Find the index of the selected item inside the VCL control... - // sal_Int32 nIndex = pBox->GetEntryPos(sTextOfSelectedItem); - // // ...and then find the associated accessibility object. - // if ( nIndex == LISTBOX_ENTRY_NOTFOUND ) - // nIndex = 0; - UpdateSelection_Impl_Acc(b_IsDropDownList); - // } - } + if ( m_aBoxType != COMBOBOX ) + return; + + /* FIXME: is there something missing here? nIndex is unused. Looks like + * copy-paste from VCLXAccessibleList::UpdateSelection() */ + // VclPtr< ComboBox > pBox = GetAs< ComboBox >(); + // if ( pBox ) + // { + // // Find the index of the selected item inside the VCL control... + // sal_Int32 nIndex = pBox->GetEntryPos(sTextOfSelectedItem); + // // ...and then find the associated accessibility object. + // if ( nIndex == LISTBOX_ENTRY_NOTFOUND ) + // nIndex = 0; + UpdateSelection_Impl_Acc(b_IsDropDownList); + // } } @@ -437,18 +437,18 @@ void VCLXAccessibleList::ProcessWindowEvent (const VclWindowEvent& rVclWindowEve */ void VCLXAccessibleList::UpdateSelection (const OUString& sTextOfSelectedItem) { - if ( m_aBoxType == COMBOBOX ) + if ( m_aBoxType != COMBOBOX ) + return; + + VclPtr< ComboBox > pBox = GetAs< ComboBox >(); + if ( pBox ) { - VclPtr< ComboBox > pBox = GetAs< ComboBox >(); - if ( pBox ) - { - // Find the index of the selected item inside the VCL control... - sal_Int32 nIndex = pBox->GetEntryPos(sTextOfSelectedItem); - // ...and then find the associated accessibility object. - if ( nIndex == LISTBOX_ENTRY_NOTFOUND ) - nIndex = 0; - UpdateSelection_Impl(nIndex); - } + // Find the index of the selected item inside the VCL control... + sal_Int32 nIndex = pBox->GetEntryPos(sTextOfSelectedItem); + // ...and then find the associated accessibility object. + if ( nIndex == LISTBOX_ENTRY_NOTFOUND ) + nIndex = 0; + UpdateSelection_Impl(nIndex); } } diff --git a/accessibility/source/standard/vclxaccessiblelistitem.cxx b/accessibility/source/standard/vclxaccessiblelistitem.cxx index 6dda80fe0112..90f8656c8858 100644 --- a/accessibility/source/standard/vclxaccessiblelistitem.cxx +++ b/accessibility/source/standard/vclxaccessiblelistitem.cxx @@ -574,22 +574,22 @@ void SAL_CALL VCLXAccessibleListItem::addAccessibleEventListener( const Referenc void SAL_CALL VCLXAccessibleListItem::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) { - if ( xListener.is() && m_nClientId ) + if ( !(xListener.is() && m_nClientId) ) + return; + + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); + if ( nListenerCount ) + return; + + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + if ( m_nClientId ) { - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - if ( m_nClientId ) - { - comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId ); - m_nClientId = 0; - comphelper::AccessibleEventNotifier::revokeClient( nId ); - } - } + comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId ); + m_nClientId = 0; + comphelper::AccessibleEventNotifier::revokeClient( nId ); } } diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx index bafd89152648..4b408cb35b57 100644 --- a/accessibility/source/standard/vclxaccessibleradiobutton.cxx +++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx @@ -75,18 +75,18 @@ void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelati VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet ); VclPtr< RadioButton > pRadioButton = GetAsDynamic< RadioButton >(); - if ( pRadioButton ) + if ( !pRadioButton ) + return; + + std::vector< VclPtr<RadioButton> > aGroup(pRadioButton->GetRadioButtonGroup()); + if (!aGroup.empty()) { - std::vector< VclPtr<RadioButton> > aGroup(pRadioButton->GetRadioButtonGroup()); - if (!aGroup.empty()) - { - std::vector< Reference< XInterface > > aVec; - aVec.reserve(aGroup.size()); - std::transform(aGroup.begin(), aGroup.end(), std::back_inserter(aVec), - [](const VclPtr<RadioButton>& rxItem) { return rxItem->GetAccessible(); }); - rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, - comphelper::containerToSequence(aVec) ) ); - } + std::vector< Reference< XInterface > > aVec; + aVec.reserve(aGroup.size()); + std::transform(aGroup.begin(), aGroup.end(), std::back_inserter(aVec), + [](const VclPtr<RadioButton>& rxItem) { return rxItem->GetAccessible(); }); + rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, + comphelper::containerToSequence(aVec) ) ); } } diff --git a/accessibility/source/standard/vclxaccessiblestatusbar.cxx b/accessibility/source/standard/vclxaccessiblestatusbar.cxx index c432ef8c4c5d..ff6351c6bd7c 100644 --- a/accessibility/source/standard/vclxaccessiblestatusbar.cxx +++ b/accessibility/source/standard/vclxaccessiblestatusbar.cxx @@ -62,17 +62,17 @@ void VCLXAccessibleStatusBar::UpdateShowing( sal_Int32 i, bool bShowing ) void VCLXAccessibleStatusBar::UpdateItemName( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; + + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( xChild.is() ) { - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - if ( xChild.is() ) + VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() ); + if ( pVCLXAccessibleStatusBarItem ) { - VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() ); - if ( pVCLXAccessibleStatusBarItem ) - { - OUString sItemName = pVCLXAccessibleStatusBarItem->GetItemName(); - pVCLXAccessibleStatusBarItem->SetItemName( sItemName ); - } + OUString sItemName = pVCLXAccessibleStatusBarItem->GetItemName(); + pVCLXAccessibleStatusBarItem->SetItemName( sItemName ); } } } @@ -80,17 +80,17 @@ void VCLXAccessibleStatusBar::UpdateItemName( sal_Int32 i ) void VCLXAccessibleStatusBar::UpdateItemText( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; + + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( xChild.is() ) { - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - if ( xChild.is() ) + VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() ); + if ( pVCLXAccessibleStatusBarItem ) { - VCLXAccessibleStatusBarItem* pVCLXAccessibleStatusBarItem = static_cast< VCLXAccessibleStatusBarItem* >( xChild.get() ); - if ( pVCLXAccessibleStatusBarItem ) - { - OUString sItemText = pVCLXAccessibleStatusBarItem->GetItemText(); - pVCLXAccessibleStatusBarItem->SetItemText( sItemText ); - } + OUString sItemText = pVCLXAccessibleStatusBarItem->GetItemText(); + pVCLXAccessibleStatusBarItem->SetItemText( sItemText ); } } } @@ -98,44 +98,44 @@ void VCLXAccessibleStatusBar::UpdateItemText( sal_Int32 i ) void VCLXAccessibleStatusBar::InsertChild( sal_Int32 i ) { - if ( i >= 0 && i <= static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // insert entry in child list - m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + if ( !(i >= 0 && i <= static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // send accessible child event - Reference< XAccessible > xChild( getAccessibleChild( i ) ); - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - } + // insert entry in child list + m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + + // send accessible child event + Reference< XAccessible > xChild( getAccessibleChild( i ) ); + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); } } void VCLXAccessibleStatusBar::RemoveChild( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // get the accessible of the removed page - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // remove entry in child list - m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); + // get the accessible of the removed page + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - // send accessible child event - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aOldValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + // remove entry in child list + m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } + // send accessible child event + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aOldValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + + Reference< XComponent > xComponent( xChild, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } } @@ -244,19 +244,19 @@ void VCLXAccessibleStatusBar::disposing() { VCLXAccessibleComponent::disposing(); - if ( m_pStatusBar ) - { - m_pStatusBar = nullptr; + if ( !m_pStatusBar ) + return; - // dispose all children - for (const Reference<XAccessible>& i : m_aAccessibleChildren) - { - Reference< XComponent > xComponent( i, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } - m_aAccessibleChildren.clear(); + m_pStatusBar = nullptr; + + // dispose all children + for (const Reference<XAccessible>& i : m_aAccessibleChildren) + { + Reference< XComponent > xComponent( i, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } + m_aAccessibleChildren.clear(); } diff --git a/accessibility/source/standard/vclxaccessibletabcontrol.cxx b/accessibility/source/standard/vclxaccessibletabcontrol.cxx index d65e74b242e3..4842e43b2c6c 100644 --- a/accessibility/source/standard/vclxaccessibletabcontrol.cxx +++ b/accessibility/source/standard/vclxaccessibletabcontrol.cxx @@ -116,44 +116,44 @@ void VCLXAccessibleTabControl::UpdateTabPage( sal_Int32 i, bool bNew ) void VCLXAccessibleTabControl::InsertChild( sal_Int32 i ) { - if ( i >= 0 && i <= static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // insert entry in child list - m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + if ( !(i >= 0 && i <= static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // send accessible child event - Reference< XAccessible > xChild( getAccessibleChild( i ) ); - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - } + // insert entry in child list + m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() ); + + // send accessible child event + Reference< XAccessible > xChild( getAccessibleChild( i ) ); + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); } } void VCLXAccessibleTabControl::RemoveChild( sal_Int32 i ) { - if ( i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) - { - // get the accessible of the removed page - Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); + if ( !(i >= 0 && i < static_cast<sal_Int32>(m_aAccessibleChildren.size())) ) + return; - // remove entry in child list - m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); + // get the accessible of the removed page + Reference< XAccessible > xChild( m_aAccessibleChildren[i] ); - // send accessible child event - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aOldValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + // remove entry in child list + m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } + // send accessible child event + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aOldValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + + Reference< XComponent > xComponent( xChild, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } } @@ -309,19 +309,19 @@ void VCLXAccessibleTabControl::disposing() { VCLXAccessibleComponent::disposing(); - if ( m_pTabControl ) - { - m_pTabControl = nullptr; + if ( !m_pTabControl ) + return; - // dispose all tab pages - for (const Reference<XAccessible>& i : m_aAccessibleChildren) - { - Reference< XComponent > xComponent( i, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } - m_aAccessibleChildren.clear(); + m_pTabControl = nullptr; + + // dispose all tab pages + for (const Reference<XAccessible>& i : m_aAccessibleChildren) + { + Reference< XComponent > xComponent( i, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } + m_aAccessibleChildren.clear(); } diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx index 2b5cdb033d2a..9bb86195ac7a 100644 --- a/accessibility/source/standard/vclxaccessibletabpage.cxx +++ b/accessibility/source/standard/vclxaccessibletabpage.cxx @@ -141,22 +141,22 @@ OUString VCLXAccessibleTabPage::GetPageText() void VCLXAccessibleTabPage::Update( bool bNew ) { - if ( m_pTabControl ) + if ( !m_pTabControl ) + return; + + TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId ); + if ( !pTabPage ) + return; + + Reference< XAccessible > xChild( pTabPage->GetAccessible( bNew ) ); + if ( xChild.is() ) { - TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId ); - if ( pTabPage ) - { - Reference< XAccessible > xChild( pTabPage->GetAccessible( bNew ) ); - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - if ( bNew ) - aNewValue <<= xChild; - else - aOldValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - } - } + Any aOldValue, aNewValue; + if ( bNew ) + aNewValue <<= xChild; + else + aOldValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); } } diff --git a/accessibility/source/standard/vclxaccessibletabpagewindow.cxx b/accessibility/source/standard/vclxaccessibletabpagewindow.cxx index 8ac6a5118137..30dc29b34213 100644 --- a/accessibility/source/standard/vclxaccessibletabpagewindow.cxx +++ b/accessibility/source/standard/vclxaccessibletabpagewindow.cxx @@ -37,21 +37,21 @@ VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindo m_pTabPage = static_cast< TabPage* >( GetWindow().get() ); m_pTabControl = nullptr; m_nPageId = 0; - if ( m_pTabPage ) + if ( !m_pTabPage ) + return; + + vcl::Window* pParent = m_pTabPage->GetAccessibleParentWindow(); + if ( !(pParent && pParent->GetType() == WindowType::TABCONTROL) ) + return; + + m_pTabControl = static_cast< TabControl* >( pParent ); + if ( m_pTabControl ) { - vcl::Window* pParent = m_pTabPage->GetAccessibleParentWindow(); - if ( pParent && pParent->GetType() == WindowType::TABCONTROL ) + for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i ) { - m_pTabControl = static_cast< TabControl* >( pParent ); - if ( m_pTabControl ) - { - for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i ) - { - sal_uInt16 nPageId = m_pTabControl->GetPageId( i ); - if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage.get() ) - m_nPageId = nPageId; - } - } + sal_uInt16 nPageId = m_pTabControl->GetPageId( i ); + if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage.get() ) + m_nPageId = nPageId; } } } diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx index 762b2a58ba39..1b63c38b373b 100644 --- a/accessibility/source/standard/vclxaccessibletoolbox.cxx +++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx @@ -197,35 +197,35 @@ void VCLXAccessibleToolBox::UpdateFocus_Impl() bHasFocus = true; } - if ( bHasFocus ) + if ( !bHasFocus ) + return; + + sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId(); + sal_uInt16 nFocusCount = 0; + for ( const auto& [rPos, rxChild] : m_aAccessibleChildren ) { - sal_uInt16 nHighlightItemId = pToolBox->GetHighlightItemId(); - sal_uInt16 nFocusCount = 0; - for ( const auto& [rPos, rxChild] : m_aAccessibleChildren ) - { - sal_uInt16 nItemId = pToolBox->GetItemId( rPos ); + sal_uInt16 nItemId = pToolBox->GetItemId( rPos ); - if ( rxChild.is() ) + if ( rxChild.is() ) + { + VCLXAccessibleToolBoxItem* pItem = + static_cast< VCLXAccessibleToolBoxItem* >( rxChild.get() ); + if ( pItem->HasFocus() && nItemId != nHighlightItemId ) { - VCLXAccessibleToolBoxItem* pItem = - static_cast< VCLXAccessibleToolBoxItem* >( rxChild.get() ); - if ( pItem->HasFocus() && nItemId != nHighlightItemId ) - { - // reset the old focused item - pItem->SetFocus( false ); - nFocusCount++; - } - if ( nItemId == nHighlightItemId ) - { - // set the new focused item - pItem->SetFocus( true ); - nFocusCount++; - } + // reset the old focused item + pItem->SetFocus( false ); + nFocusCount++; + } + if ( nItemId == nHighlightItemId ) + { + // set the new focused item + pItem->SetFocus( true ); + nFocusCount++; } - // both items changed? - if ( nFocusCount > 1 ) - break; } + // both items changed? + if ( nFocusCount > 1 ) + break; } } @@ -249,43 +249,43 @@ void VCLXAccessibleToolBox::ReleaseFocus_Impl( ToolBox::ImplToolItems::size_type void VCLXAccessibleToolBox::UpdateChecked_Impl( ToolBox::ImplToolItems::size_type _nPos ) { VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); - if ( pToolBox ) - { - sal_uInt16 nFocusId = pToolBox->GetItemId( _nPos ); - VCLXAccessibleToolBoxItem* pFocusItem = nullptr; + if ( !pToolBox ) + return; - for ( const auto& [rPos, rxChild] : m_aAccessibleChildren ) - { - sal_uInt16 nItemId = pToolBox->GetItemId( rPos ); + sal_uInt16 nFocusId = pToolBox->GetItemId( _nPos ); + VCLXAccessibleToolBoxItem* pFocusItem = nullptr; - VCLXAccessibleToolBoxItem* pItem = - static_cast< VCLXAccessibleToolBoxItem* >( rxChild.get() ); - pItem->SetChecked( pToolBox->IsItemChecked( nItemId ) ); - if ( nItemId == nFocusId ) - pFocusItem = pItem; - } - //Solution:If the position is not a child item,the focus should not be called - if ( pFocusItem && _nPos != ToolBox::ITEM_NOTFOUND ) - pFocusItem->SetFocus( true ); + for ( const auto& [rPos, rxChild] : m_aAccessibleChildren ) + { + sal_uInt16 nItemId = pToolBox->GetItemId( rPos ); + + VCLXAccessibleToolBoxItem* pItem = + static_cast< VCLXAccessibleToolBoxItem* >( rxChild.get() ); + pItem->SetChecked( pToolBox->IsItemChecked( nItemId ) ); + if ( nItemId == nFocusId ) + pFocusItem = pItem; } + //Solution:If the position is not a child item,the focus should not be called + if ( pFocusItem && _nPos != ToolBox::ITEM_NOTFOUND ) + pFocusItem->SetFocus( true ); } void VCLXAccessibleToolBox::UpdateIndeterminate_Impl( ToolBox::ImplToolItems::size_type _nPos ) { VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); - if ( pToolBox ) - { - sal_uInt16 nItemId = pToolBox->GetItemId( _nPos ); + if ( !pToolBox ) + return; - ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos ); - //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! - if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() ) - { - VCLXAccessibleToolBoxItem* pItem = - static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() ); - if ( pItem ) - pItem->SetIndeterminate( pToolBox->GetItemState( nItemId ) == TRISTATE_INDET ); - } + sal_uInt16 nItemId = pToolBox->GetItemId( _nPos ); + + ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.find( _nPos ); + //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! + if ( aIter != m_aAccessibleChildren.end() && aIter->second.is() ) + { + VCLXAccessibleToolBoxItem* pItem = + static_cast< VCLXAccessibleToolBoxItem* >( aIter->second.get() ); + if ( pItem ) + pItem->SetIndeterminate( pToolBox->GetItemState( nItemId ) == TRISTATE_INDET ); } } @@ -323,90 +323,90 @@ void VCLXAccessibleToolBox::UpdateItem_Impl( ToolBox::ImplToolItems::size_type _ } VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); - if ( pToolBox ) + if ( !pToolBox ) + return; + + // adjust the "index-in-parent"s + ToolBoxItemsMap::iterator aIndexAdjust = m_aAccessibleChildren.upper_bound( _nPos ); + //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! + while ( m_aAccessibleChildren.end() != aIndexAdjust ) { - // adjust the "index-in-parent"s - ToolBoxItemsMap::iterator aIndexAdjust = m_aAccessibleChildren.upper_bound( _nPos ); - //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! - while ( m_aAccessibleChildren.end() != aIndexAdjust ) - { - Reference< XAccessible > xItemAcc( aIndexAdjust->second ); + Reference< XAccessible > xItemAcc( aIndexAdjust->second ); - auto pWindowItem = comphelper::getUnoTunnelImplementation<OToolBoxWindowItem>(xItemAcc); - if ( !pWindowItem ) - { - VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() ); - if ( pItem ) - { - sal_Int32 nIndex = pItem->getIndexInParent( ); - nIndex++; - pItem->setIndexInParent( nIndex ); - } - } - else + auto pWindowItem = comphelper::getUnoTunnelImplementation<OToolBoxWindowItem>(xItemAcc); + if ( !pWindowItem ) + { + VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xItemAcc.get() ); + if ( pItem ) { - sal_Int32 nIndex = pWindowItem->getIndexInParent( ); + sal_Int32 nIndex = pItem->getIndexInParent( ); nIndex++; - pWindowItem->setIndexInParent( nIndex ); + pItem->setIndexInParent( nIndex ); } - - ++aIndexAdjust; + } + else + { + sal_Int32 nIndex = pWindowItem->getIndexInParent( ); + nIndex++; + pWindowItem->setIndexInParent( nIndex ); } - // TODO: we should make this dependent on the existence of event listeners - // with the current implementation, we always create accessible object - Any aNewChild( getAccessibleChild( static_cast<sal_Int32>(_nPos) ) ); - //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! - NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewChild ); + ++aIndexAdjust; } + + // TODO: we should make this dependent on the existence of event listeners + // with the current implementation, we always create accessible object + Any aNewChild( getAccessibleChild( static_cast<sal_Int32>(_nPos) ) ); + //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! + NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewChild ); } void VCLXAccessibleToolBox::UpdateAllItems_Impl() { VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); - if ( pToolBox ) + if ( !pToolBox ) + return; + + // deregister the old items + for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin(); + aIter != m_aAccessibleChildren.end(); ++aIter ) { - // deregister the old items - for ( ToolBoxItemsMap::iterator aIter = m_aAccessibleChildren.begin(); - aIter != m_aAccessibleChildren.end(); ++aIter ) - { - implReleaseToolboxItem( aIter, true ); - } - m_aAccessibleChildren.clear(); + implReleaseToolboxItem( aIter, true ); + } + m_aAccessibleChildren.clear(); - // register the new items - ToolBox::ImplToolItems::size_type i, nCount = pToolBox->GetItemCount(); - for ( i = 0; i < nCount; ++i ) - { - Any aNewValue; - aNewValue <<= getAccessibleChild( static_cast<sal_Int32>(i) ); - //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! - NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue ); - } + // register the new items + ToolBox::ImplToolItems::size_type i, nCount = pToolBox->GetItemCount(); + for ( i = 0; i < nCount; ++i ) + { + Any aNewValue; + aNewValue <<= getAccessibleChild( static_cast<sal_Int32>(i) ); + //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! + NotifyAccessibleEvent( AccessibleEventId::CHILD, Any(), aNewValue ); } } void VCLXAccessibleToolBox::UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, bool bOpen ) { VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); - if( pWindow && pToolBox ) - { - const sal_uInt16 nDownItem = pToolBox->GetDownItemId(); - if ( !nDownItem ) - // No item is currently in down state. - // Moreover, calling GetItemPos with 0 will find a separator if there is any. - return; + if( !(pWindow && pToolBox) ) + return; - Reference< XAccessible > xChild( pWindow->GetAccessible() ); - if( xChild.is() ) - { - Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( nDownItem ) ) ) ); - //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! - VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xChildItem.get() ); + const sal_uInt16 nDownItem = pToolBox->GetDownItemId(); + if ( !nDownItem ) + // No item is currently in down state. + // Moreover, calling GetItemPos with 0 will find a separator if there is any. + return; - pItem->SetChild( xChild ); - pItem->NotifyChildEvent( xChild, bOpen ); - } + Reference< XAccessible > xChild( pWindow->GetAccessible() ); + if( xChild.is() ) + { + Reference< XAccessible > xChildItem( getAccessibleChild( static_cast< sal_Int32 >( pToolBox->GetItemPos( nDownItem ) ) ) ); + //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! + VCLXAccessibleToolBoxItem* pItem = static_cast< VCLXAccessibleToolBoxItem* >( xChildItem.get() ); + + pItem->SetChild( xChild ); + pItem->NotifyChildEvent( xChild, bOpen ); } } @@ -428,28 +428,28 @@ void VCLXAccessibleToolBox::HandleSubToolBarEvent( const VclWindowEvent& rVclWin { vcl::Window* pChildWindow = static_cast<vcl::Window *>(rVclWindowEvent.GetData()); VclPtr< ToolBox > pToolBox = GetAs< ToolBox >(); - if ( pChildWindow + if ( !(pChildWindow && pToolBox && pToolBox == pChildWindow->GetParent() - && pChildWindow->GetType() == WindowType::TOOLBOX ) - { - const sal_uInt16 nCurItemId( pToolBox->GetCurItemId() ); - if ( !nCurItemId ) - // No item is currently active (might happen when opening the overflow popup). - // Moreover, calling GetItemPos with 0 will find a separator if there is any. - return; + && pChildWindow->GetType() == WindowType::TOOLBOX) ) + return; - ToolBox::ImplToolItems::size_type nIndex = pToolBox->GetItemPos( nCurItemId ); - Reference< XAccessible > xItem = getAccessibleChild( nIndex ); - //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! - if ( xItem.is() ) - { - Reference< XAccessible > xChild = pChildWindow->GetAccessible(); - VCLXAccessibleToolBoxItem* pItem = - static_cast< VCLXAccessibleToolBoxItem* >( xItem.get() ); - pItem->SetChild( xChild ); - pItem->NotifyChildEvent( xChild, true/*_bShow*/ ); - } + const sal_uInt16 nCurItemId( pToolBox->GetCurItemId() ); + if ( !nCurItemId ) + // No item is currently active (might happen when opening the overflow popup). + // Moreover, calling GetItemPos with 0 will find a separator if there is any. + return; + + ToolBox::ImplToolItems::size_type nIndex = pToolBox->GetItemPos( nCurItemId ); + Reference< XAccessible > xItem = getAccessibleChild( nIndex ); + //TODO: ToolBox::ImplToolItems::size_type -> sal_Int32! + if ( xItem.is() ) + { + Reference< XAccessible > xChild = pChildWindow->GetAccessible(); + VCLXAccessibleToolBoxItem* pItem = + static_cast< VCLXAccessibleToolBoxItem* >( xItem.get() ); + pItem->SetChild( xChild ); + pItem->NotifyChildEvent( xChild, true/*_bShow*/ ); } } |