diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-10-11 10:04:13 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-10-11 10:06:03 +0100 |
commit | 6c220995aa2485a9c5d23f0ec952a64151ab25b6 (patch) | |
tree | 2d9603afacfdefa0dba45fb3a413af4d8a5743dd /accessibility | |
parent | d0304a8f57b3fe0065193a2a3f7089f414b1ffd9 (diff) |
Resolves: tdf#103032 a11y crash on listbox dispose in toolbar dropdown
Change-Id: I70bce310ba9b46efdbdfdec8d2c6689d0ba2e655
Diffstat (limited to 'accessibility')
4 files changed, 50 insertions, 52 deletions
diff --git a/accessibility/inc/standard/vclxaccessiblelist.hxx b/accessibility/inc/standard/vclxaccessiblelist.hxx index 9b20b0b04d54..a8aa753ca479 100644 --- a/accessibility/inc/standard/vclxaccessiblelist.hxx +++ b/accessibility/inc/standard/vclxaccessiblelist.hxx @@ -22,7 +22,6 @@ #include <vector> #include <functional> -#include "standard/vclxaccessiblelistitem.hxx" #include <standard/vclxaccessibleedit.hxx> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/XAccessibleAction.hpp> @@ -136,6 +135,7 @@ public: void UpdateFocus_Impl_Acc ( sal_Int32 nPos, bool b_IsDropDownList) ; static void NotifyListItem(css::uno::Any& val); + ::accessibility::IComboListBoxHelper* getListBoxHelper() { return m_pListBoxHelper; } protected: BoxType m_aBoxType; ::accessibility::IComboListBoxHelper* m_pListBoxHelper; diff --git a/accessibility/inc/standard/vclxaccessiblelistitem.hxx b/accessibility/inc/standard/vclxaccessiblelistitem.hxx index 405ecb5e6496..fb5cab491606 100644 --- a/accessibility/inc/standard/vclxaccessiblelistitem.hxx +++ b/accessibility/inc/standard/vclxaccessiblelistitem.hxx @@ -30,6 +30,7 @@ #include <cppuhelper/compbase6.hxx> #include <cppuhelper/basemutex.hxx> #include <comphelper/accessibletexthelper.hxx> +#include <standard/vclxaccessiblelist.hxx> // forward --------------------------------------------------------------- @@ -40,11 +41,6 @@ namespace com { namespace sun { namespace star { namespace awt { class XFocusListener; } } } } -namespace accessibility -{ - class IComboListBoxHelper; -} - // class VCLXAccessibleListItem ------------------------------------------ typedef ::cppu::WeakAggComponentImplHelper6< css::accessibility::XAccessible @@ -69,9 +65,8 @@ private: protected: /// client id in the AccessibleEventNotifier queue sal_uInt32 m_nClientId; - ::accessibility::IComboListBoxHelper* m_pListBoxHelper; - css::uno::Reference< css::accessibility::XAccessible > m_xParent; + css::uno::Reference< VCLXAccessibleList > m_xParent; css::uno::Reference< css::accessibility::XAccessibleContext > m_xParentContext; protected: @@ -87,16 +82,13 @@ protected: public: /** OAccessibleBase needs a valid view - @param _pListBoxHelper - is the list- or combobox for which we implement an accessible object @param _nIndexInParent is the position of the entry inside the listbox @param _xParent is our parent accessible object */ - VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, - sal_Int32 _nIndexInParent, - const css::uno::Reference< css::accessibility::XAccessible >& _xParent ); + VCLXAccessibleListItem(sal_Int32 _nIndexInParent, + const css::uno::Reference< VCLXAccessibleList >& _xParent); void NotifyAccessibleEvent( sal_Int16 _nEventId, const css::uno::Any& _aOldValue, const css::uno::Any& _aNewValue ); diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx index 42747d74cb3b..38f6c39e282c 100644 --- a/accessibility/source/standard/vclxaccessiblelist.cxx +++ b/accessibility/source/standard/vclxaccessiblelist.cxx @@ -507,7 +507,7 @@ Reference<XAccessible> VCLXAccessibleList::CreateChild (sal_Int32 nPos) m_aAccessibleChildren.resize(nPos + 1); // insert into the container - xChild = new VCLXAccessibleListItem(m_pListBoxHelper, nPos, this); + xChild = new VCLXAccessibleListItem(nPos, this); m_aAccessibleChildren[nPos] = xChild; } else @@ -516,7 +516,7 @@ Reference<XAccessible> VCLXAccessibleList::CreateChild (sal_Int32 nPos) // check if position is empty and can be used else we have to adjust all entries behind this if (!xChild.is()) { - xChild = new VCLXAccessibleListItem(m_pListBoxHelper, nPos, this); + xChild = new VCLXAccessibleListItem(nPos, this); m_aAccessibleChildren[nPos] = xChild; } } diff --git a/accessibility/source/standard/vclxaccessiblelistitem.cxx b/accessibility/source/standard/vclxaccessiblelistitem.cxx index 49b9e8f83136..53090a7f9141 100644 --- a/accessibility/source/standard/vclxaccessiblelistitem.cxx +++ b/accessibility/source/standard/vclxaccessiblelistitem.cxx @@ -61,23 +61,21 @@ using namespace ::com::sun::star; // Ctor() and Dtor() -VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) : - - VCLXAccessibleListItem_BASE ( m_aMutex ), - - m_nIndexInParent( _nIndexInParent ), - m_bSelected ( false ), - m_bVisible ( false ), - m_nClientId ( 0 ), - m_pListBoxHelper( _pListBoxHelper ), - m_xParent ( _xParent ) - -{ - if ( m_xParent.is() ) +VCLXAccessibleListItem::VCLXAccessibleListItem(sal_Int32 _nIndexInParent, const Reference< VCLXAccessibleList >& _xParent) + : VCLXAccessibleListItem_BASE(m_aMutex) + , m_nIndexInParent(_nIndexInParent) + , m_bSelected(false) + , m_bVisible(false) + , m_nClientId(0) + , m_xParent(_xParent) +{ + if (m_xParent.is()) + { m_xParentContext = m_xParent->getAccessibleContext(); - - if ( m_pListBoxHelper ) - m_sEntryText = m_pListBoxHelper->GetEntry( (sal_uInt16)_nIndexInParent ); + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent->getListBoxHelper(); + if (pListBoxHelper) + m_sEntryText = pListBoxHelper->GetEntry((sal_uInt16)_nIndexInParent); + } } VCLXAccessibleListItem::~VCLXAccessibleListItem() @@ -162,7 +160,6 @@ void SAL_CALL VCLXAccessibleListItem::disposing() VCLXAccessibleListItem_BASE::disposing(); m_sEntryText.clear(); - m_pListBoxHelper = nullptr; m_xParent = nullptr; m_xParentContext = nullptr; @@ -266,7 +263,8 @@ Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleS { pStateSetHelper->AddState( AccessibleStateType::TRANSIENT ); - if(m_pListBoxHelper->IsEnabled()) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper && pListBoxHelper->IsEnabled()) { pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); pStateSetHelper->AddState( AccessibleStateType::ENABLED ); @@ -303,9 +301,10 @@ sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoi ::osl::MutexGuard aGuard( m_aMutex ); bool bInside = false; - if ( m_pListBoxHelper ) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) { - Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) ); + Rectangle aRect(pListBoxHelper->GetBoundingRectangle((sal_uInt16)m_nIndexInParent)); aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y()); bInside = aRect.IsInside( VCLPoint( _aPoint ) ); } @@ -323,8 +322,9 @@ awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds( ) throw (RuntimeExce ::osl::MutexGuard aGuard( m_aMutex ); awt::Rectangle aRect; - if ( m_pListBoxHelper ) - aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) ); + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) + aRect = AWTRectangle(pListBoxHelper->GetBoundingRectangle((sal_uInt16)m_nIndexInParent)); return aRect; } @@ -335,9 +335,10 @@ awt::Point SAL_CALL VCLXAccessibleListItem::getLocation( ) throw (RuntimeExcept ::osl::MutexGuard aGuard( m_aMutex ); Point aPoint(0,0); - if ( m_pListBoxHelper ) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) { - Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); + Rectangle aRect = pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); aPoint = aRect.TopLeft(); } return AWTPoint( aPoint ); @@ -349,11 +350,12 @@ awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen( ) throw (Runti ::osl::MutexGuard aGuard( m_aMutex ); Point aPoint(0,0); - if ( m_pListBoxHelper ) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) { - Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); + Rectangle aRect = pListBoxHelper->GetBoundingRectangle((sal_uInt16)m_nIndexInParent); aPoint = aRect.TopLeft(); - aPoint += m_pListBoxHelper->GetWindowExtentsRelative().TopLeft(); + aPoint += pListBoxHelper->GetWindowExtentsRelative().TopLeft(); } return AWTPoint( aPoint ); } @@ -364,8 +366,9 @@ awt::Size SAL_CALL VCLXAccessibleListItem::getSize( ) throw (RuntimeException, ::osl::MutexGuard aGuard( m_aMutex ); Size aSize; - if ( m_pListBoxHelper ) - aSize = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize(); + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) + aSize = pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize(); return AWTSize( aSize ); } @@ -423,10 +426,11 @@ awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nI throw IndexOutOfBoundsException(); awt::Rectangle aBounds( 0, 0, 0, 0 ); - if ( m_pListBoxHelper ) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) { - Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex ); - Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); + Rectangle aCharRect = pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex ); + Rectangle aItemRect = pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() ); aBounds = AWTRectangle( aCharRect ); } @@ -448,13 +452,14 @@ sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aP ::osl::MutexGuard aGuard( m_aMutex ); sal_Int32 nIndex = -1; - if ( m_pListBoxHelper ) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) { sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND; - Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); + Rectangle aItemRect = pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ); Point aPnt( VCLPoint( aPoint ) ); aPnt += aItemRect.TopLeft(); - sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos ); + sal_Int32 nI = pListBoxHelper->GetIndexForPoint( aPnt, nPos ); if ( nI != -1 && m_nIndexInParent == nPos ) nIndex = nI; } @@ -545,9 +550,10 @@ sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_I checkIndex_Impl( nEndIndex, m_sEntryText ); bool bRet = false; - if ( m_pListBoxHelper ) + ::accessibility::IComboListBoxHelper* pListBoxHelper = m_xParent.is() ? m_xParent->getListBoxHelper() : nullptr; + if (pListBoxHelper) { - Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard(); + Reference< datatransfer::clipboard::XClipboard > xClipboard = pListBoxHelper->GetClipboard(); if ( xClipboard.is() ) { OUString sText( getTextRange( nStartIndex, nEndIndex ) ); |