30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <com/sun/star/frame/XFrame.hpp>
32#include <com/sun/star/lang/DisposedException.hpp>
33#include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
34#include <com/sun/star/drawing/framework/XView.hpp>
43using ::sd::framework::FrameworkHelper;
48const sal_Int32 ResourceActivationEvent = 0;
49const sal_Int32 ResourceDeactivationEvent = 1;
50const sal_Int32 ConfigurationUpdateEvent = 2;
56 css::beans::XPropertyChangeListener,
57 css::frame::XFrameActionListener,
58 css::view::XSelectionChangeListener,
59 css::drawing::framework::XConfigurationChangeListener
80 disposing (
const css::lang::EventObject& rEventObject)
override;
85 const css::beans::PropertyChangeEvent& rEvent)
override;
90 const css::lang::EventObject& rEvent)
override;
98 frameAction (
const css::frame::FrameActionEvent& rEvent)
override;
101 virtual void SAL_CALL
103 const css::drawing::framework::ConfigurationChangeEvent& rEvent)
override;
105 virtual void disposing(std::unique_lock<std::mutex>&)
override;
110 const SfxHint& rHint)
override;
125 css::uno::WeakReference<css::drawing::framework::XConfigurationController>
135 void const * pUserData =
nullptr);
167 mpImpl->AddEventListener(rCallback);
173 mpImpl->RemoveEventListener(rCallback);
178 void const * pUserData )
188 mbListeningToController (false),
189 mbListeningToFrame (false),
190 mxControllerWeak(nullptr),
191 mxFrameWeak(nullptr),
196 Reference<frame::XFrame>
xFrame =
201 xFrame->addFrameActionListener ( Reference<frame::XFrameActionListener>(
this) );
216 Reference<XConfigurationController> xConfigurationController (
219 if (!xConfigurationController.is())
222 Reference<XComponent> xComponent (xConfigurationController, UNO_QUERY);
224 xComponent->addEventListener(
static_cast<beans::XPropertyChangeListener*
>(
this));
226 xConfigurationController->addConfigurationChangeListener(
228 FrameworkHelper::msResourceActivationEvent,
229 Any(ResourceActivationEvent));
230 xConfigurationController->addConfigurationChangeListener(
232 FrameworkHelper::msResourceDeactivationEvent,
233 Any(ResourceDeactivationEvent));
234 xConfigurationController->addConfigurationChangeListener(
236 FrameworkHelper::msConfigurationUpdateEndEvent,
237 Any(ConfigurationUpdateEvent));
243 "sd::EventMultiplexer::Implementation::~Implementation(), disposing was not called!" );
248 if (mbListeningToFrame)
250 mbListeningToFrame =
false;
253 Reference<frame::XFrame>
xFrame (mxFrameWeak);
256 xFrame->removeFrameActionListener (
257 Reference<frame::XFrameActionListener>(
this) );
261 DisconnectFromController ();
263 if (mpDocument !=
nullptr)
265 EndListening (*mpDocument);
266 mpDocument =
nullptr;
270 Reference<XConfigurationController> xConfigurationController (mxConfigurationControllerWeak);
271 if (xConfigurationController.is())
273 Reference<XComponent> xComponent (xConfigurationController, UNO_QUERY);
275 xComponent->removeEventListener(
static_cast<beans::XPropertyChangeListener*
>(
this));
277 xConfigurationController->removeConfigurationChangeListener(
this);
284 for (
auto const &
i : maListeners)
287 maListeners.push_back(rCallback);
293 auto iListener = std::find(maListeners.begin(), maListeners.end(), rCallback);
294 if (iListener != maListeners.end())
295 maListeners.erase(iListener);
302 DisconnectFromController ();
309 Reference<frame::XController>
xController = mrBase.GetController();
310 mxControllerWeak = mrBase.GetController();
318 Reference<lang::XEventListener>(
319 static_cast<XWeak*
>(
this), UNO_QUERY));
320 mbListeningToController =
true;
324 Reference<beans::XPropertySet> xSet (
xController, UNO_QUERY);
331 catch (
const beans::UnknownPropertyException&)
333 SAL_WARN(
"sd",
"EventMultiplexer::ConnectToController: CurrentPage unknown");
340 catch (
const beans::UnknownPropertyException&)
342 SAL_WARN(
"sd",
"EventMultiplexer::ConnectToController: IsMasterPageMode unknown");
347 Reference<view::XSelectionSupplier> xSelection (
xController, UNO_QUERY);
350 xSelection->addSelectionChangeListener(
this);
353 catch (
const lang::DisposedException&)
355 mbListeningToController =
false;
361 if (!mbListeningToController)
364 mbListeningToController =
false;
366 Reference<frame::XController>
xController = mxControllerWeak;
368 Reference<beans::XPropertySet> xSet (
xController, UNO_QUERY);
376 catch (
const beans::UnknownPropertyException&)
378 SAL_WARN(
"sd",
"DisconnectFromController: CurrentPage unknown");
385 catch (
const beans::UnknownPropertyException&)
387 SAL_WARN(
"sd",
"DisconnectFromController: IsMasterPageMode unknown");
392 Reference<view::XSelectionSupplier> xSelection (
xController, UNO_QUERY);
395 xSelection->removeSelectionChangeListener(
this);
402 Reference<lang::XEventListener>(
static_cast<XWeak*
>(
this), UNO_QUERY));
409 const lang::EventObject& rEventObject)
411 if (mbListeningToController)
413 Reference<frame::XController>
xController (mxControllerWeak);
414 if (rEventObject.Source == xController)
416 mbListeningToController =
false;
420 Reference<XConfigurationController> xConfigurationController (
421 mxConfigurationControllerWeak);
422 if (xConfigurationController.is()
423 && rEventObject.Source == xConfigurationController)
425 mxConfigurationControllerWeak.clear();
432 const beans::PropertyChangeEvent& rEvent)
436 throw lang::DisposedException (
437 "SlideSorterController object has already been disposed",
438 static_cast<uno::XWeak*
>(
this));
447 bool bIsMasterPageMode (
false);
448 rEvent.NewValue >>= bIsMasterPageMode;
449 if (bIsMasterPageMode)
459 const frame::FrameActionEvent& rEvent)
461 Reference<frame::XFrame>
xFrame (mxFrameWeak);
462 if (rEvent.Frame !=
xFrame)
465 switch (rEvent.Action)
467 case frame::FrameAction_COMPONENT_DETACHING:
468 DisconnectFromController();
472 case frame::FrameAction_COMPONENT_REATTACHED:
474 DisconnectFromController();
475 ConnectToController();
479 case frame::FrameAction_COMPONENT_ATTACHED:
480 ConnectToController();
492 const lang::EventObject& )
500 const ConfigurationChangeEvent& rEvent)
502 sal_Int32 nEventType = 0;
503 rEvent.UserData >>= nEventType;
506 case ResourceActivationEvent:
507 if (rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix))
511 if (rEvent.ResourceId->isBoundToURL(
512 FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
518 if (rEvent.ResourceId->getResourceURL() == FrameworkHelper::msSlideSorterURL)
522 FrameworkHelper::GetViewShell(
523 Reference<XView>(rEvent.ResourceObject,UNO_QUERY)).get());
524 if (pViewShell !=
nullptr)
528 SlideSorterSelectionChangeListener));
533 case ResourceDeactivationEvent:
534 if (rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix))
536 if (rEvent.ResourceId->isBoundToURL(
537 FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
544 if (rEvent.ResourceId->getResourceURL() == FrameworkHelper::msSlideSorterURL)
548 FrameworkHelper::GetViewShell(
549 Reference<XView>(rEvent.ResourceObject, UNO_QUERY)).get());
550 if (pViewShell !=
nullptr)
554 SlideSorterSelectionChangeListener));
559 case ConfigurationUpdateEvent:
573 for (
const auto& rListener : aCopyListeners)
574 rListener.Call(rEvent);
585 if (rHint.
GetId() == SfxHintId::ThisIsAnSdrHint)
590 case SdrHintKind::ModelCleared:
591 case SdrHintKind::PageOrderChange:
595 case SdrHintKind::SwitchToPage:
599 case SdrHintKind::ObjectChange:
601 static_cast<const void*
>(pSdrHint->
GetPage()));
604 case SdrHintKind::ObjectInserted:
606 static_cast<const void*
>(pSdrHint->
GetPage()));
609 case SdrHintKind::ObjectRemoved:
611 static_cast<const void*
>(pSdrHint->
GetPage()));
619 if (rHint.
GetId() == SfxHintId::Dying)
620 mpDocument =
nullptr;
626 void const * pUserData)
635 for (
const auto& rListener : aCopyListeners)
637 rListener.Call(rEvent);
650 const void* pUserData)
651 : meEventId(eEventId),
652 mpUserData(pUserData)
@ EditViewSelection
The selection in the center pane has changed.
@ ControllerDetached
A UNO controller has been detached to the UNO frame.
@ ShapeRemoved
A shape has been removed from a page.
@ PageOrder
One or more pages have been inserted into or deleted from the model.
@ EditModeNormal
Edit mode was (or is being) switched to normal mode.
@ SlideSortedSelection
The selection in the slide sorter has changed, regardless of whether the slide sorter is displayed in...
@ EditModeMaster
Edit mode was (or is being) switched to master mode.
@ ViewAdded
A new ViewShell is being displayed in one of the panes.
@ Disposing
The EventMultiplexer itself is being disposed.
@ MainViewRemoved
The current MainViewShell (the ViewShell displayed in the center pane) has been removed.
@ ShapeChanged
The state of a shape has changed.
@ MainViewAdded
A new ViewShell has been made the MainViewShell.
@ ConfigurationUpdated
A configuration update has been completed.
@ CurrentPageChanged
The current page has changed.
@ ShapeInserted
A shape has been inserted to a page.
@ ControllerAttached
A UNO controller has been attached to the UNO frame.
const SdrPage * GetPage() const
SdrHintKind GetKind() const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
SfxViewFrame * GetFrame() const
SfxFrame & GetFrame() const
The DrawController is the UNO controller for Impress and Draw.
virtual css::uno::Reference< css::drawing::framework::XConfigurationController > SAL_CALL getConfigurationController() override
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
DrawController * GetDrawController() const
SdDrawDocument * GetDocument() const
void AddSelectionChangeListener(const Link< LinkParamNone *, void > &rListener)
Add a listener that is called when the selection of the slide sorter changes.
void RemoveSelectionChangeListener(const Link< LinkParamNone *, void > &rListener)
Remove a listener that was called when the selection of the slide sorter changes.
#define DBG_ASSERT(sCon, aError)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
Reference< XController > xController
Reference< XFrame > xFrame