diff options
author | Arnaud Versini <Arnaud.Versini@libreoffice.org> | 2017-07-23 16:25:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-15 11:28:21 +0200 |
commit | 5d060fd07a16c80bd94d27b08fefe1d0aaf418f7 (patch) | |
tree | 38801d4f83a905409de9a85871ac3f8f012465f2 /accessibility/source | |
parent | 359201c9b4ad26fd445688de2c9a1d15f253d37d (diff) |
accessibility: remove useless calls to virtual methods.
This also removes a lot of useless recursive locks.
Change-Id: Ifee7dbf2095bf0431eb27e8022e7f5299c46388f
Reviewed-on: https://gerrit.libreoffice.org/42122
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'accessibility/source')
13 files changed, 42 insertions, 40 deletions
diff --git a/accessibility/source/extended/accessibletabbar.cxx b/accessibility/source/extended/accessibletabbar.cxx index 66ffc402a915..662e1b745338 100644 --- a/accessibility/source/extended/accessibletabbar.cxx +++ b/accessibility/source/extended/accessibletabbar.cxx @@ -233,7 +233,7 @@ namespace accessibility { OExternalLockGuard aGuard( this ); - if ( i < 0 || i >= getAccessibleChildCount() ) + if ( i < 0 || i >= static_cast<sal_Int32>(m_aAccessibleChildren.size()) ) throw IndexOutOfBoundsException(); Reference< XAccessible > xChild = m_aAccessibleChildren[i]; diff --git a/accessibility/source/extended/accessibletabbarpage.cxx b/accessibility/source/extended/accessibletabbarpage.cxx index 272d357cb440..a69d434ada75 100644 --- a/accessibility/source/extended/accessibletabbarpage.cxx +++ b/accessibility/source/extended/accessibletabbarpage.cxx @@ -254,14 +254,11 @@ namespace accessibility } - Reference< XAccessible > AccessibleTabBarPage::getAccessibleChild( sal_Int32 i ) + Reference< XAccessible > AccessibleTabBarPage::getAccessibleChild( sal_Int32 ) { OExternalLockGuard aGuard( this ); - if ( i < 0 || i >= getAccessibleChildCount() ) - throw IndexOutOfBoundsException(); - - return Reference< XAccessible >(); + throw IndexOutOfBoundsException(); } diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx index c1df7719f323..f4586da3c1c2 100644 --- a/accessibility/source/standard/vclxaccessiblebox.cxx +++ b/accessibility/source/standard/vclxaccessiblebox.cxx @@ -274,6 +274,11 @@ sal_Int32 SAL_CALL VCLXAccessibleBox::getAccessibleChildCount() SolarMutexGuard aSolarGuard; ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + return implGetAccessibleChildCount(); +} + +sal_Int32 VCLXAccessibleBox::implGetAccessibleChildCount() +{ // Usually a box has a text field and a list of items as its children. // Non drop down list boxes have no text field. Additionally check // whether the object is valid. @@ -297,7 +302,7 @@ Reference<XAccessible> SAL_CALL VCLXAccessibleBox::getAccessibleChild (sal_Int32 SolarMutexGuard aSolarGuard; ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - if (i<0 || i>=getAccessibleChildCount()) + if (i<0 || i>=implGetAccessibleChildCount()) throw IndexOutOfBoundsException(); Reference< XAccessible > xChild; @@ -382,7 +387,7 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex) SolarMutexGuard aSolarGuard; ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - if (nIndex<0 || nIndex>=getAccessibleActionCount()) + if (nIndex!=0 || !m_bIsDropDownBox) throw css::lang::IndexOutOfBoundsException( ("VCLXAccessibleBox::doAccessibleAction: index " + OUString::number(nIndex) + " not among 0.." @@ -418,7 +423,7 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex) OUString SAL_CALL VCLXAccessibleBox::getAccessibleActionDescription (sal_Int32 nIndex) { ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - if (nIndex<0 || nIndex>=getAccessibleActionCount()) + if (nIndex!=0 || !m_bIsDropDownBox) throw css::lang::IndexOutOfBoundsException(); if (m_bIsDropDownBox) diff --git a/accessibility/source/standard/vclxaccessiblebutton.cxx b/accessibility/source/standard/vclxaccessiblebutton.cxx index c95004327f86..df67584bdccc 100644 --- a/accessibility/source/standard/vclxaccessiblebutton.cxx +++ b/accessibility/source/standard/vclxaccessiblebutton.cxx @@ -187,7 +187,7 @@ sal_Bool VCLXAccessibleButton::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); VclPtr< PushButton > pButton = GetAs< PushButton >(); @@ -202,7 +202,7 @@ OUString VCLXAccessibleButton::getAccessibleActionDescription ( sal_Int32 nIndex { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); return OUString(RID_STR_ACC_ACTION_CLICK); @@ -213,7 +213,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleButton::getAccessibleActionKeyB { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper(); diff --git a/accessibility/source/standard/vclxaccessiblecheckbox.cxx b/accessibility/source/standard/vclxaccessiblecheckbox.cxx index f8243bfc7254..d411c8ca54a2 100644 --- a/accessibility/source/standard/vclxaccessiblecheckbox.cxx +++ b/accessibility/source/standard/vclxaccessiblecheckbox.cxx @@ -184,7 +184,7 @@ sal_Bool VCLXAccessibleCheckBox::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); VclPtr< CheckBox > pCheckBox = GetAs< CheckBox >(); @@ -214,7 +214,7 @@ OUString VCLXAccessibleCheckBox::getAccessibleActionDescription ( sal_Int32 nInd { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); if(IsChecked()) @@ -228,7 +228,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleCheckBox::getAccessibleActionKe { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper(); diff --git a/accessibility/source/standard/vclxaccessiblemenu.cxx b/accessibility/source/standard/vclxaccessiblemenu.cxx index fd709766618c..99edb949eb4c 100644 --- a/accessibility/source/standard/vclxaccessiblemenu.cxx +++ b/accessibility/source/standard/vclxaccessiblemenu.cxx @@ -182,6 +182,11 @@ sal_Int32 VCLXAccessibleMenu::getSelectedAccessibleChildCount( ) { OExternalLockGuard aGuard( this ); + return implGetSelectedAccessibleChildCount(); +} + +sal_Int32 VCLXAccessibleMenu::implGetSelectedAccessibleChildCount( ) +{ sal_Int32 nRet = 0; for ( sal_Int32 i = 0, nCount = GetChildCount(); i < nCount; i++ ) @@ -193,7 +198,6 @@ sal_Int32 VCLXAccessibleMenu::getSelectedAccessibleChildCount( ) return nRet; } - Reference< XAccessible > VCLXAccessibleMenu::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) { OExternalLockGuard aGuard( this ); diff --git a/accessibility/source/standard/vclxaccessiblemenuitem.cxx b/accessibility/source/standard/vclxaccessiblemenuitem.cxx index 60de73778696..259501bfe4dd 100644 --- a/accessibility/source/standard/vclxaccessiblemenuitem.cxx +++ b/accessibility/source/standard/vclxaccessiblemenuitem.cxx @@ -405,7 +405,7 @@ sal_Bool VCLXAccessibleMenuItem::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); Click(); @@ -418,7 +418,7 @@ OUString VCLXAccessibleMenuItem::getAccessibleActionDescription ( sal_Int32 nInd { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); return OUString(RID_STR_ACC_ACTION_SELECT); @@ -429,7 +429,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleMenuItem::getAccessibleActionKe { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper(); diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx index 9606092e92f4..bff33c10647c 100644 --- a/accessibility/source/standard/vclxaccessibleradiobutton.cxx +++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx @@ -162,7 +162,7 @@ sal_Bool VCLXAccessibleRadioButton::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() ); @@ -176,7 +176,7 @@ OUString VCLXAccessibleRadioButton::getAccessibleActionDescription ( sal_Int32 n { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); return OUString(RID_STR_ACC_ACTION_SELECT); @@ -186,7 +186,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleRadioButton::getAccessibleActio { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper(); diff --git a/accessibility/source/standard/vclxaccessiblescrollbar.cxx b/accessibility/source/standard/vclxaccessiblescrollbar.cxx index bb83d7ac832d..242f09f69a27 100644 --- a/accessibility/source/standard/vclxaccessiblescrollbar.cxx +++ b/accessibility/source/standard/vclxaccessiblescrollbar.cxx @@ -117,12 +117,13 @@ Sequence< OUString > VCLXAccessibleScrollBar::getSupportedServiceNames() // XAccessibleAction +static constexpr sal_Int32 ACCESSIBLE_ACTION_COUNT=4; sal_Int32 VCLXAccessibleScrollBar::getAccessibleActionCount( ) { OExternalLockGuard aGuard( this ); - return 4; + return ACCESSIBLE_ACTION_COUNT; } @@ -130,7 +131,7 @@ sal_Bool VCLXAccessibleScrollBar::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex < 0 || nIndex >= ACCESSIBLE_ACTION_COUNT ) throw IndexOutOfBoundsException(); bool bReturn = false; @@ -158,7 +159,7 @@ OUString VCLXAccessibleScrollBar::getAccessibleActionDescription ( sal_Int32 nIn { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex < 0 || nIndex >= ACCESSIBLE_ACTION_COUNT ) throw IndexOutOfBoundsException(); OUString sDescription; @@ -180,7 +181,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleScrollBar::getAccessibleActionK { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex < 0 || nIndex >= ACCESSIBLE_ACTION_COUNT ) throw IndexOutOfBoundsException(); return Reference< XAccessibleKeyBinding >(); diff --git a/accessibility/source/standard/vclxaccessiblestatusbar.cxx b/accessibility/source/standard/vclxaccessiblestatusbar.cxx index 9f7bcee9b19c..05281f20189a 100644 --- a/accessibility/source/standard/vclxaccessiblestatusbar.cxx +++ b/accessibility/source/standard/vclxaccessiblestatusbar.cxx @@ -295,7 +295,7 @@ Reference< XAccessible > VCLXAccessibleStatusBar::getAccessibleChild( sal_Int32 { OExternalLockGuard aGuard( this ); - if ( i < 0 || i >= getAccessibleChildCount() ) + if ( i < 0 || i >= static_cast<sal_Int32> (m_aAccessibleChildren.size()) ) throw IndexOutOfBoundsException(); Reference< XAccessible > xChild = m_aAccessibleChildren[i]; diff --git a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx index 6bd311c8a960..7b0ce47daa84 100644 --- a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx +++ b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx @@ -254,14 +254,9 @@ sal_Int32 VCLXAccessibleStatusBarItem::getAccessibleChildCount() } -Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleChild( sal_Int32 i ) +Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleChild( sal_Int32 ) { - OExternalLockGuard aGuard( this ); - - if ( i < 0 || i >= getAccessibleChildCount() ) - throw IndexOutOfBoundsException(); - - return Reference< XAccessible >(); + throw IndexOutOfBoundsException(); } diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx b/accessibility/source/standard/vclxaccessibletoolbox.cxx index 0dd0134a54d5..83828e6b0b65 100644 --- a/accessibility/source/standard/vclxaccessibletoolbox.cxx +++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx @@ -44,7 +44,7 @@ namespace /** XAccessibleContext implementation for a toolbox item which is represented by a VCL Window */ - class OToolBoxWindowItemContext : public OAccessibleContextWrapper + class OToolBoxWindowItemContext final : public OAccessibleContextWrapper { sal_Int32 m_nIndexInParent; public: diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx index 5dbc3b4d1050..4713e382f1e4 100644 --- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx +++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx @@ -357,7 +357,7 @@ OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription( ) { OExternalLockGuard aGuard( this ); - if (m_nRole == AccessibleRole::PANEL && getAccessibleChildCount() > 0) + if (m_nRole == AccessibleRole::PANEL && m_xChild.is()) { return AccResId( RID_STR_ACC_PANEL_DESCRIPTION ); } @@ -512,7 +512,7 @@ sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sa Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pToolBox->GetClipboard(); if ( xClipboard.is() ) { - OUString sText( getTextRange( nStartIndex, nEndIndex ) ); + OUString sText( OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex ) ); vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( sText ); @@ -621,7 +621,7 @@ sal_Bool VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); if ( m_pToolBox ) @@ -634,7 +634,7 @@ OUString VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 n { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); return OUString(RID_STR_ACC_ACTION_CLICK); @@ -644,7 +644,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleToolBoxItem::getAccessibleActio { OContextEntryGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); return Reference< XAccessibleKeyBinding >(); |