0354f03
From 47b299c7de49edd3bddd743d6d9bdcf49a09ec39 Mon Sep 17 00:00:00 2001
0354f03
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
0354f03
Date: Fri, 25 May 2018 14:37:03 +0100
0354f03
Subject: [PATCH] tdf#117601 a11y crash after merging cells
0354f03
0354f03
this is similar to tdf#87199, in this case the accessibiles for the merged
0354f03
cells are not visible so not removed when their frame is deleted, but remain
0354f03
in the cache pointing to invalid frames.
0354f03
0354f03
Change-Id: Ibc5b9f27541683b8f3604839fa3d1431380a4039
0354f03
---
0354f03
 sw/inc/accmap.hxx                    |  3 +++
0354f03
 sw/source/core/access/acccontext.cxx |  6 +++++-
0354f03
 sw/source/core/access/accmap.cxx     | 11 ++++++++---
0354f03
 3 files changed, 16 insertions(+), 4 deletions(-)
0354f03
0354f03
diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
0354f03
index fc7f665da383..c78bea3e0e51 100644
0354f03
--- a/sw/inc/accmap.hxx
0354f03
+++ b/sw/inc/accmap.hxx
0354f03
@@ -277,6 +277,9 @@ public:
0354f03
     Point PixelToCore (const Point& rPoint) const;
0354f03
     tools::Rectangle CoreToPixel (const tools::Rectangle& rRect) const;
0354f03
 
0354f03
+    // is there a known accessibility impl cached for the frame
0354f03
+    bool Contains(const SwFrame *pFrame) const;
0354f03
+
0354f03
 private:
0354f03
     /** get mapping mode for LogicToPixel and PixelToLogic conversions
0354f03
 
0354f03
diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
0354f03
index 628ad727dc47..efb6b415d372 100644
0354f03
--- a/sw/source/core/access/acccontext.cxx
0354f03
+++ b/sw/source/core/access/acccontext.cxx
0354f03
@@ -402,8 +402,12 @@ void SwAccessibleContext::DisposeChildren(const SwFrame *pFrame,
0354f03
         if( pLower )
0354f03
         {
0354f03
             ::rtl::Reference< SwAccessibleContext > xAccImpl;
0354f03
-            if( rLower.IsAccessible( GetShell()->IsPreview() ) )
0354f03
+            if (rLower.IsAccessible(GetShell()->IsPreview())
0354f03
+                       // tdf#117601 dispose the darn thing if it ever was accessible
0354f03
+                    || GetMap()->Contains(pLower))
0354f03
+            {
0354f03
                 xAccImpl = GetMap()->GetContextImpl( pLower, false );
0354f03
+            }
0354f03
             if( xAccImpl.is() )
0354f03
                 xAccImpl->Dispose( bRecursive );
0354f03
             else
0354f03
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
0354f03
index 712b70873507..43cc0974625e 100644
0354f03
--- a/sw/source/core/access/accmap.cxx
0354f03
+++ b/sw/source/core/access/accmap.cxx
0354f03
@@ -2158,6 +2158,11 @@ void SwAccessibleMap::RemoveContext( const SdrObject *pObj )
0354f03
     }
0354f03
 }
0354f03
 
0354f03
+bool SwAccessibleMap::Contains(const SwFrame *pFrame) const
0354f03
+{
0354f03
+    return (pFrame && mpFrameMap && mpFrameMap->find(pFrame) != mpFrameMap->end());
0354f03
+}
0354f03
+
0354f03
 void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
0354f03
                                    const SdrObject *pObj,
0354f03
                                    vcl::Window* pWindow,
0354f03
@@ -2173,9 +2178,9 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame,
0354f03
     OSL_ENSURE( !aFrameOrObj.GetSwFrame() || aFrameOrObj.GetSwFrame()->IsAccessibleFrame(),
0354f03
             "non accessible frame should be disposed" );
0354f03
 
0354f03
-    if (aFrameOrObj.IsAccessible( GetShell()->IsPreview() )
0354f03
-            // fdo#87199 dispose the darn thing if it ever was accessible
0354f03
-        || (pFrame && mpFrameMap && mpFrameMap->find(pFrame) != mpFrameMap->end()))
0354f03
+    if (aFrameOrObj.IsAccessible(GetShell()->IsPreview())
0354f03
+               // fdo#87199 dispose the darn thing if it ever was accessible
0354f03
+            || Contains(pFrame))
0354f03
     {
0354f03
         ::rtl::Reference< SwAccessibleContext > xAccImpl;
0354f03
         ::rtl::Reference< SwAccessibleContext > xParentAccImpl;
0354f03
-- 
0354f03
2.14.3
0354f03