summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-08-20 17:03:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-08-23 15:11:27 +0200
commitec940941e0bd7db15c5cf7d43df82226e0d849dc (patch)
treea876a500dfa6a32bc8b284b3b07525480ba60765 /svx
parent1d524bc7a331e8381e88cfd1b6dea4678ad32514 (diff)
tdf#119388 add new UNO listener/broadcaster
so that we only need to fire each event to the exact shape that wants it, instead of spamming all the shapes. Takes deleting a column from 20s to 10s for me. Note that none of the broadcasters are calling disposing(EventObject), so I did not make XShapeEventListener extend lang::XEventListener. If a memory leak regression points at this commit, possibly I missed something. Change-Id: I2b8db08247d3e0203d41faf77491368168994e4d Reviewed-on: https://gerrit.libreoffice.org/77857 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/accessibility/AccessibleShape.cxx57
-rw-r--r--svx/source/accessibility/AccessibleShapeTreeInfo.cxx2
-rw-r--r--svx/source/accessibility/ChildrenManagerImpl.cxx2
3 files changed, 24 insertions, 37 deletions
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
index 779ad7b4fba3..e9966e3c63ef 100644
--- a/svx/source/accessibility/AccessibleShape.cxx
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -30,7 +30,7 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/drawing/XShapeDescriptor.hpp>
-#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/document/XShapeEventBroadcaster.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/text/XText.hpp>
@@ -141,8 +141,8 @@ void AccessibleShape::Init()
// Register at model as document::XEventListener.
if (maShapeTreeInfo.GetModelBroadcaster().is())
- maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
- static_cast<document::XEventListener*>(this));
+ maShapeTreeInfo.GetModelBroadcaster()->addShapeEventListener(mxShape,
+ static_cast<document::XShapeEventListener*>(this));
// Beware! Here we leave the paths of the UNO API and descend into the
// depths of the core. Necessary for making the edit engine
@@ -750,8 +750,7 @@ css::uno::Any SAL_CALL
static_cast<XAccessibleExtendedComponent*>(this),
static_cast< css::accessibility::XAccessibleSelection* >(this),
static_cast< css::accessibility::XAccessibleExtendedAttributes* >(this),
- static_cast<lang::XEventListener*>(this),
- static_cast<document::XEventListener*>(this),
+ static_cast<document::XShapeEventListener*>(this),
static_cast<lang::XUnoTunnel*>(this),
static_cast<XAccessibleGroupPosition*>(this),
static_cast<XAccessibleHypertext*>(this)
@@ -937,8 +936,7 @@ uno::Sequence<uno::Type> SAL_CALL
reference to the model in the shape tree info. Otherwise this object
remains functional.
*/
-void SAL_CALL
- AccessibleShape::disposing (const lang::EventObject& aEvent)
+void AccessibleShape::disposing (const lang::EventObject& aEvent)
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard (maMutex);
@@ -959,33 +957,27 @@ void SAL_CALL
}
}
-// document::XEventListener
+// document::XShapeEventListener
void SAL_CALL
- AccessibleShape::notifyEvent (const document::EventObject& rEventObject)
+ AccessibleShape::notifyShapeEvent (const document::EventObject& rEventObject)
{
- // First check if the event is for us.
- uno::Reference<drawing::XShape> xShape (
- rEventObject.Source, uno::UNO_QUERY);
- if ( xShape.get() == mxShape.get() )
+ if (rEventObject.EventName == "ShapeModified")
{
- if (rEventObject.EventName == "ShapeModified")
- {
- //Need to update text children when receiving ShapeModified hint when exiting edit mode for text box
- if (mpText)
- mpText->UpdateChildren();
+ //Need to update text children when receiving ShapeModified hint when exiting edit mode for text box
+ if (mpText)
+ mpText->UpdateChildren();
- // Some property of a shape has been modified. Send an event
- // that indicates a change of the visible data to all listeners.
- CommitChange (
- AccessibleEventId::VISIBLE_DATA_CHANGED,
- uno::Any(),
- uno::Any());
+ // Some property of a shape has been modified. Send an event
+ // that indicates a change of the visible data to all listeners.
+ CommitChange (
+ AccessibleEventId::VISIBLE_DATA_CHANGED,
+ uno::Any(),
+ uno::Any());
- // Name and Description may have changed. Update the local
- // values accordingly.
- UpdateNameAndDescription();
- }
+ // Name and Description may have changed. Update the local
+ // values accordingly.
+ UpdateNameAndDescription();
}
}
@@ -1071,15 +1063,10 @@ void AccessibleShape::disposing()
if (pStateSet != nullptr)
pStateSet->RemoveState (AccessibleStateType::FOCUSED);
- // Unregister from broadcasters.
- Reference<lang::XComponent> xComponent (mxShape, uno::UNO_QUERY);
- if (xComponent.is())
- xComponent->removeEventListener (this);
-
// Unregister from model.
if (maShapeTreeInfo.GetModelBroadcaster().is())
- maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
- static_cast<document::XEventListener*>(this));
+ maShapeTreeInfo.GetModelBroadcaster()->removeShapeEventListener(mxShape,
+ static_cast<document::XShapeEventListener*>(this));
// Release the child containers.
if (mpChildrenManager != nullptr)
diff --git a/svx/source/accessibility/AccessibleShapeTreeInfo.cxx b/svx/source/accessibility/AccessibleShapeTreeInfo.cxx
index 88d24ac1d86f..edc7ef8a9641 100644
--- a/svx/source/accessibility/AccessibleShapeTreeInfo.cxx
+++ b/svx/source/accessibility/AccessibleShapeTreeInfo.cxx
@@ -86,7 +86,7 @@ void AccessibleShapeTreeInfo::SetDocumentWindow (
}
void AccessibleShapeTreeInfo::SetModelBroadcaster (
- const Reference<document::XEventBroadcaster>& rxModelBroadcaster)
+ const Reference<document::XShapeEventBroadcaster>& rxModelBroadcaster)
{
mxModelBroadcaster = rxModelBroadcaster;
}
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx
index e08a5c2b0a6e..2c0b953dc459 100644
--- a/svx/source/accessibility/ChildrenManagerImpl.cxx
+++ b/svx/source/accessibility/ChildrenManagerImpl.cxx
@@ -31,7 +31,7 @@
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/document/XShapeEventBroadcaster.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>