From a758956bb5fce66d1590109f3ce5593ac25967d8 Mon Sep 17 00:00:00 2001 From: Arnaud Versini Date: Sun, 2 Jul 2017 11:55:59 +0200 Subject: accessbility: Don't double lock mutexes in VCLXAccessibleEdit. Also simplify this class. Change-Id: I7abccd19287101918a6d9b4636ce2faecf169123 Reviewed-on: https://gerrit.libreoffice.org/39446 Tested-by: Jenkins Reviewed-by: Noel Grandin --- accessibility/inc/standard/vclxaccessibleedit.hxx | 5 ++- .../source/standard/vclxaccessibleedit.cxx | 37 +++------------------- 2 files changed, 6 insertions(+), 36 deletions(-) (limited to 'accessibility') diff --git a/accessibility/inc/standard/vclxaccessibleedit.hxx b/accessibility/inc/standard/vclxaccessibleedit.hxx index f0aaf6492de8..8e0c6635d566 100644 --- a/accessibility/inc/standard/vclxaccessibleedit.hxx +++ b/accessibility/inc/standard/vclxaccessibleedit.hxx @@ -34,15 +34,14 @@ typedef ::cppu::ImplHelper2< css::accessibility::XAccessibleAction, css::accessibility::XAccessibleEditableText > VCLXAccessibleEdit_BASE; -class VCLXAccessibleEdit : public VCLXAccessibleTextComponent, - public VCLXAccessibleEdit_BASE +class VCLXAccessibleEdit final : public VCLXAccessibleTextComponent, + public VCLXAccessibleEdit_BASE { friend class VCLXAccessibleBox; private: sal_Int32 m_nCaretPosition; -protected: virtual ~VCLXAccessibleEdit() override; virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx index 4bfa8e544636..c508ce434afe 100644 --- a/accessibility/source/standard/vclxaccessibleedit.cxx +++ b/accessibility/source/standard/vclxaccessibleedit.cxx @@ -246,7 +246,7 @@ sal_Bool VCLXAccessibleEdit::doAccessibleAction ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); bool bDoAction = false; @@ -265,7 +265,7 @@ OUString VCLXAccessibleEdit::getAccessibleActionDescription ( sal_Int32 nIndex ) { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0) throw IndexOutOfBoundsException(); return OUString( "activate" ); @@ -276,7 +276,7 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleEdit::getAccessibleActionKeyBin { OExternalLockGuard aGuard( this ); - if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) + if ( nIndex != 0 ) throw IndexOutOfBoundsException(); return Reference< XAccessibleKeyBinding >(); @@ -300,8 +300,6 @@ sal_Bool VCLXAccessibleEdit::setCaretPosition( sal_Int32 nIndex ) sal_Unicode VCLXAccessibleEdit::getCharacter( sal_Int32 nIndex ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getCharacter( nIndex ); } @@ -396,40 +394,30 @@ awt::Rectangle VCLXAccessibleEdit::getCharacterBounds( sal_Int32 nIndex ) sal_Int32 VCLXAccessibleEdit::getCharacterCount( ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getCharacterCount(); } sal_Int32 VCLXAccessibleEdit::getIndexAtPoint( const awt::Point& aPoint ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getIndexAtPoint( aPoint ); } OUString VCLXAccessibleEdit::getSelectedText( ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getSelectedText(); } sal_Int32 VCLXAccessibleEdit::getSelectionStart( ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getSelectionStart(); } sal_Int32 VCLXAccessibleEdit::getSelectionEnd( ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getSelectionEnd(); } @@ -458,27 +446,22 @@ sal_Bool VCLXAccessibleEdit::setSelection( sal_Int32 nStartIndex, sal_Int32 nEnd OUString VCLXAccessibleEdit::getText( ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getText(); } OUString VCLXAccessibleEdit::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getTextRange( nStartIndex, nEndIndex ); } css::accessibility::TextSegment VCLXAccessibleEdit::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) { - OExternalLockGuard aGuard( this ); - // Override general text component behavior: MultiLineEdit can have more text portions if ( aTextType == AccessibleTextType::ATTRIBUTE_RUN ) { + OExternalLockGuard aGuard( this ); VclPtr pMulitLineEdit = GetAsDynamic< VclMultiLineEdit >(); if ( pMulitLineEdit ) { @@ -496,24 +479,18 @@ css::accessibility::TextSegment VCLXAccessibleEdit::getTextAtIndex( sal_Int32 nI css::accessibility::TextSegment VCLXAccessibleEdit::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getTextBeforeIndex( nIndex, aTextType ); } css::accessibility::TextSegment VCLXAccessibleEdit::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::getTextBehindIndex( nIndex, aTextType ); } sal_Bool VCLXAccessibleEdit::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) { - OExternalLockGuard aGuard( this ); - return VCLXAccessibleTextComponent::copyText( nStartIndex, nEndIndex ); } @@ -523,8 +500,6 @@ sal_Bool VCLXAccessibleEdit::copyText( sal_Int32 nStartIndex, sal_Int32 nEndInde sal_Bool VCLXAccessibleEdit::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) { - OExternalLockGuard aGuard( this ); - return copyText( nStartIndex, nEndIndex ) && deleteText( nStartIndex, nEndIndex ); } @@ -566,16 +541,12 @@ sal_Bool VCLXAccessibleEdit::pasteText( sal_Int32 nIndex ) sal_Bool VCLXAccessibleEdit::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) { - OExternalLockGuard aGuard( this ); - return replaceText( nStartIndex, nEndIndex, OUString() ); } sal_Bool VCLXAccessibleEdit::insertText( const OUString& sText, sal_Int32 nIndex ) { - OExternalLockGuard aGuard( this ); - return replaceText( nIndex, nIndex, sText ); } -- cgit