[Libreoffice-commits] core.git: sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 26 17:42:56 UTC 2020


 sw/source/core/access/accmap.cxx |   25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

New commits:
commit 2376cc7ce9bd4319f0f011ab13445ceb6817c7f1
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Feb 26 10:21:40 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Feb 26 18:42:13 2020 +0100

    fix assert in fdo66141-1.odt
    
    after
        commit ec940941e0bd7db15c5cf7d43df82226e0d849dc
        Date:   Tue Aug 20 17:03:13 2019 +0200
        tdf#119388 add new UNO listener/broadcaster
    it appears that we can have more than one listener per shape because
    shapes can be in multiple accessibility contexts.
    
    Change-Id: I3724f27d5bfe8b5ab3548d4f062d60b071f3f2af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89500
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 814fd99c91ef..ba71be7d8caa 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -24,6 +24,7 @@
 #include <svx/unomod.hxx>
 #include <algorithm>
 #include <map>
+#include <unordered_map>
 #include <list>
 #include <vector>
 #include <accmap.hxx>
@@ -133,7 +134,7 @@ class SwDrawModellListener_Impl : public SfxListener,
 {
     mutable ::osl::Mutex maListenerMutex;
     ::comphelper::OInterfaceContainerHelper2 maEventListeners;
-    std::unordered_map<css::uno::Reference< css::drawing::XShape >, css::uno::Reference< css::document::XShapeEventListener >> maShapeListeners;
+    std::unordered_multimap<css::uno::Reference< css::drawing::XShape >, css::uno::Reference< css::document::XShapeEventListener >> maShapeListeners;
     SdrModel *mpDrawModel;
 protected:
     virtual ~SwDrawModellListener_Impl() override;
@@ -182,9 +183,7 @@ void SAL_CALL SwDrawModellListener_Impl::addShapeEventListener(
 {
     assert(xShape.is() && "no shape?");
     osl::MutexGuard aGuard(maListenerMutex);
-    auto rv = maShapeListeners.emplace(xShape, xListener);
-    assert(rv.second && "duplicate listener?");
-    (void)rv;
+    maShapeListeners.emplace(xShape, xListener);
 }
 
 void SAL_CALL SwDrawModellListener_Impl::removeShapeEventListener(
@@ -192,13 +191,13 @@ void SAL_CALL SwDrawModellListener_Impl::removeShapeEventListener(
                 const uno::Reference< document::XShapeEventListener >& xListener )
 {
     osl::MutexGuard aGuard(maListenerMutex);
-    auto it = maShapeListeners.find(xShape);
-    if (it != maShapeListeners.end())
-    {
-        assert(it->second == xListener);
-        (void)xListener;
-        maShapeListeners.erase(it);
-    }
+    auto [itBegin, itEnd] = maShapeListeners.equal_range(xShape);
+    for (auto it = itBegin; it != itEnd; ++it)
+        if (it->second == xListener)
+        {
+            maShapeListeners.erase(it);
+            return;
+        }
 }
 
 void SwDrawModellListener_Impl::Notify( SfxBroadcaster& /*rBC*/,
@@ -246,8 +245,8 @@ void SwDrawModellListener_Impl::Notify( SfxBroadcaster& /*rBC*/,
         auto pSdrObject = const_cast<SdrObject*>(pSdrHint->GetObject());
         uno::Reference<drawing::XShape> xShape(pSdrObject->getUnoShape(), uno::UNO_QUERY);
         osl::MutexGuard aGuard(maListenerMutex);
-        auto it = maShapeListeners.find(xShape);
-        if (it != maShapeListeners.end())
+        auto [itBegin, itEnd] = maShapeListeners.equal_range(xShape);
+        for (auto it = itBegin; it != itEnd; ++it)
             it->second->notifyShapeEvent(aEvent);
     }
 }


More information about the Libreoffice-commits mailing list