summaryrefslogtreecommitdiff
path: root/accessibility/source/standard/accessiblemenubasecomponent.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 15:11:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 21:46:57 +0200
commit4f3f61a621a0e66fd0eab4886a3aa51e10513ad3 (patch)
tree03fa6f0fa067e6d7805cfa95e1c234f7821d4f42 /accessibility/source/standard/accessiblemenubasecomponent.cxx
parent8d4fd3418322f3f6852054c44be2cd74b0db76ee (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/source/standard/accessiblemenubasecomponent.cxx')
-rw-r--r--accessibility/source/standard/accessiblemenubasecomponent.cxx156
1 files changed, 78 insertions, 78 deletions
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();
}