diff options
Diffstat (limited to 'accessibility/source/extended')
11 files changed, 542 insertions, 542 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 > |