[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - accessibility/inc accessibility/source

Caolán McNamara caolanm at redhat.com
Thu Oct 13 16:16:52 UTC 2016


 accessibility/inc/accessibility/standard/vclxaccessiblelist.hxx     |    2 
 accessibility/inc/accessibility/standard/vclxaccessiblelistitem.hxx |   16 -
 accessibility/source/standard/vclxaccessiblelist.cxx                |    4 
 accessibility/source/standard/vclxaccessiblelistitem.cxx            |   82 +++++-----
 4 files changed, 51 insertions(+), 53 deletions(-)

New commits:
commit 8d403f337dde983aeccc8d6066abfda6c12599ca
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 11 10:04:13 2016 +0100

    Resolves: tdf#103032 a11y crash on listbox dispose in toolbar dropdown
    
    (cherry picked from commit 6c220995aa2485a9c5d23f0ec952a64151ab25b6)
    
    Change-Id: I70bce310ba9b46efdbdfdec8d2c6689d0ba2e655
    Reviewed-on: https://gerrit.libreoffice.org/29689
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/accessibility/inc/accessibility/standard/vclxaccessiblelist.hxx b/accessibility/inc/accessibility/standard/vclxaccessiblelist.hxx
index 86b3a04..f65e010 100644
--- a/accessibility/inc/accessibility/standard/vclxaccessiblelist.hxx
+++ b/accessibility/inc/accessibility/standard/vclxaccessiblelist.hxx
@@ -22,7 +22,6 @@
 
 #include <vector>
 #include <functional>
-#include "accessibility/standard/vclxaccessiblelistitem.hxx"
 #include <accessibility/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/accessibility/standard/vclxaccessiblelistitem.hxx b/accessibility/inc/accessibility/standard/vclxaccessiblelistitem.hxx
index f851060..0a9889d 100644
--- a/accessibility/inc/accessibility/standard/vclxaccessiblelistitem.hxx
+++ b/accessibility/inc/accessibility/standard/vclxaccessiblelistitem.hxx
@@ -30,6 +30,7 @@
 #include <cppuhelper/compbase6.hxx>
 #include <comphelper/broadcasthelper.hxx>
 #include <comphelper/accessibletexthelper.hxx>
+#include "accessibility/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;
+    rtl::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 rtl::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 c425f3c..a03888c 100644
--- a/accessibility/source/standard/vclxaccessiblelist.cxx
+++ b/accessibility/source/standard/vclxaccessiblelist.cxx
@@ -503,7 +503,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
@@ -512,7 +512,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 26cd9d8..1af4985 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 rtl::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()
@@ -184,7 +182,6 @@ void SAL_CALL VCLXAccessibleListItem::disposing()
 
         VCLXAccessibleListItem_BASE::disposing();
         m_sEntryText.clear();
-        m_pListBoxHelper    = nullptr;
         m_xParent           = nullptr;
         m_xParentContext    = nullptr;
 
@@ -243,7 +240,7 @@ Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent(
 {
     ::osl::MutexGuard aGuard( m_aMutex );
 
-    return m_xParent;
+    return m_xParent.get();
 }
 
 sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
@@ -290,7 +287,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 );
@@ -327,9 +325,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 ) );
     }
@@ -347,8 +346,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;
 }
@@ -359,9 +359,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 );
@@ -373,11 +374,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 );
 }
@@ -388,8 +390,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 );
 }
@@ -447,10 +450,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 );
     }
@@ -472,13 +476,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;
     }
@@ -569,9 +574,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 ) );


More information about the Libreoffice-commits mailing list