diff options
-rw-r--r-- | accessibility/inc/accessibility/standard/vclxaccessibleedit.hxx | 3 | ||||
-rw-r--r-- | accessibility/source/standard/vclxaccessibleedit.cxx | 52 |
2 files changed, 25 insertions, 30 deletions
diff --git a/accessibility/inc/accessibility/standard/vclxaccessibleedit.hxx b/accessibility/inc/accessibility/standard/vclxaccessibleedit.hxx index 0e3f1a929f8d..03b38bec80d4 100644 --- a/accessibility/inc/accessibility/standard/vclxaccessibleedit.hxx +++ b/accessibility/inc/accessibility/standard/vclxaccessibleedit.hxx @@ -56,13 +56,12 @@ class VCLXAccessibleEdit : public VCLXAccessibleTextComponent, friend class VCLXAccessibleBox; private: + sal_Int32 m_nSelectionStart; sal_Int32 m_nCaretPosition; protected: virtual ~VCLXAccessibleEdit(); - void UpdateCaretPosition(); - virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ); diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx index 06dd0e1e094c..2ae7ab149bbc 100644 --- a/accessibility/source/standard/vclxaccessibleedit.cxx +++ b/accessibility/source/standard/vclxaccessibleedit.cxx @@ -70,6 +70,7 @@ using namespace ::comphelper; VCLXAccessibleEdit::VCLXAccessibleEdit( VCLXWindow* pVCLWindow ) :VCLXAccessibleTextComponent( pVCLWindow ) { + m_nSelectionStart = getSelectionStart(); m_nCaretPosition = getCaretPosition(); } @@ -81,22 +82,6 @@ VCLXAccessibleEdit::~VCLXAccessibleEdit() // ----------------------------------------------------------------------------- -void VCLXAccessibleEdit::UpdateCaretPosition() -{ - sal_Int32 nCaretPosition = getCaretPosition(); - - if ( m_nCaretPosition != nCaretPosition ) - { - Any aOldValue, aNewValue; - aOldValue <<= (sal_Int32) m_nCaretPosition; - aNewValue <<= (sal_Int32) nCaretPosition; - m_nCaretPosition = nCaretPosition; - NotifyAccessibleEvent( AccessibleEventId::CARET_CHANGED, aOldValue, aNewValue ); - } -} - -// ----------------------------------------------------------------------------- - void VCLXAccessibleEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { switch ( rVclWindowEvent.GetId() ) @@ -108,11 +93,31 @@ void VCLXAccessibleEdit::ProcessWindowEvent( const VclWindowEvent& rVclWindowEve break; case VCLEVENT_EDIT_SELECTIONCHANGED: { + sal_Int32 nOldCaretPosition = m_nCaretPosition; + sal_Int32 nOldSelectionStart = m_nSelectionStart; + + m_nCaretPosition = getCaretPosition(); + m_nSelectionStart = getSelectionStart(); + Window* pWindow = GetWindow(); if ( pWindow && pWindow->HasChildPathFocus() ) { - NotifyAccessibleEvent( AccessibleEventId::TEXT_SELECTION_CHANGED, Any(), Any() ); - UpdateCaretPosition(); + if ( m_nCaretPosition != nOldCaretPosition ) + { + Any aOldValue, aNewValue; + aOldValue <<= (sal_Int32) nOldCaretPosition; + aNewValue <<= (sal_Int32) m_nCaretPosition; + NotifyAccessibleEvent( AccessibleEventId::CARET_CHANGED, aOldValue, aNewValue ); + } + + // #i104470# VCL only has SELECTION_CHANGED, but UAA distinguishes between SELECTION_CHANGED and CARET_CHANGED + sal_Bool bHasSelection = ( m_nSelectionStart != m_nCaretPosition ); + sal_Bool bHadSelection = ( nOldSelectionStart != nOldCaretPosition ); + if ( ( bHasSelection != bHadSelection ) || ( bHasSelection && ( ( m_nCaretPosition != nOldCaretPosition ) || ( m_nSelectionStart != nOldSelectionStart ) ) ) ) + { + NotifyAccessibleEvent( AccessibleEventId::TEXT_SELECTION_CHANGED, Any(), Any() ); + } + } } break; @@ -308,22 +313,13 @@ Reference< XAccessibleKeyBinding > VCLXAccessibleEdit::getAccessibleActionKeyBin sal_Int32 VCLXAccessibleEdit::getCaretPosition( ) throw (RuntimeException) { - OExternalLockGuard aGuard( this ); - - awt::Selection aSelection; - VCLXEdit* pVCLXEdit = static_cast< VCLXEdit* >( GetVCLXWindow() ); - if ( pVCLXEdit ) - aSelection = pVCLXEdit->getSelection(); - - return aSelection.Max; + return getSelectionEnd(); } // ----------------------------------------------------------------------------- sal_Bool VCLXAccessibleEdit::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) { - OExternalLockGuard aGuard( this ); - return setSelection( nIndex, nIndex ); } |