Kaydet (Commit) 3e27ba70 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#104884 print preview replaces the frame controller

so the sidebar is listening to the old controller which has been disposed[1] so
when print preview exits and yet another controller replaces the print preview
one then the sidebar still doesn't listen to the current one.

framework broadcasts COMPONENT_DETACHING/COMPONENT_REATTACHED around these
changes, so if we listen to them we can keep attached to whatever is the
current component

[1] note that ContextChangeEventMultipler doesn't inform clients that the
controller has been disposed, this remains unchanged here

Change-Id: I141509d4a262307afd7dcfc3d77de6cdd6dbfa5f
Reviewed-on: https://gerrit.libreoffice.org/33758Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst aaf41776
...@@ -45,7 +45,8 @@ typedef cppu::WeakComponentImplHelper < ...@@ -45,7 +45,8 @@ typedef cppu::WeakComponentImplHelper <
css::ui::XContextChangeEventListener, css::ui::XContextChangeEventListener,
css::beans::XPropertyChangeListener, css::beans::XPropertyChangeListener,
css::ui::XSidebar, css::ui::XSidebar,
css::frame::XStatusListener css::frame::XStatusListener,
css::frame::XFrameActionListener
> SidebarControllerInterfaceBase; > SidebarControllerInterfaceBase;
class SfxSplitWindow; class SfxSplitWindow;
...@@ -97,6 +98,9 @@ public: ...@@ -97,6 +98,9 @@ public:
// frame::XStatusListener // frame::XStatusListener
virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) override; virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) override;
// frame::XFrameActionListener
virtual void SAL_CALL frameAction (const css::frame::FrameActionEvent& rEvent) override;
// ui::XSidebar // ui::XSidebar
virtual void SAL_CALL requestLayout() override; virtual void SAL_CALL requestLayout() override;
......
...@@ -126,6 +126,7 @@ rtl::Reference<SidebarController> SidebarController::create( ...@@ -126,6 +126,7 @@ rtl::Reference<SidebarController> SidebarController::create(
new SidebarController(pParentWindow, rxFrame)); new SidebarController(pParentWindow, rxFrame));
registerSidebarForFrame(instance.get(), rxFrame->getController()); registerSidebarForFrame(instance.get(), rxFrame->getController());
rxFrame->addFrameActionListener(instance.get());
// Listen for window events. // Listen for window events.
instance->mpParentWindow->AddEventListener(LINK(instance.get(), SidebarController, WindowEventHandler)); instance->mpParentWindow->AddEventListener(LINK(instance.get(), SidebarController, WindowEventHandler));
...@@ -236,6 +237,7 @@ void SAL_CALL SidebarController::disposing() ...@@ -236,6 +237,7 @@ void SAL_CALL SidebarController::disposing()
if (!xController.is()) if (!xController.is())
xController = mxCurrentController; xController = mxCurrentController;
mxFrame->removeFrameActionListener(this);
unregisterSidebarForFrame(this, xController); unregisterSidebarForFrame(this, xController);
if (mxReadOnlyModeDispatch.is()) if (mxReadOnlyModeDispatch.is())
...@@ -1316,6 +1318,16 @@ void SidebarController::FadeIn() ...@@ -1316,6 +1318,16 @@ void SidebarController::FadeIn()
mpSplitWindow->FadeIn(); mpSplitWindow->FadeIn();
} }
void SidebarController::frameAction(const css::frame::FrameActionEvent& rEvent)
{
if (rEvent.Frame == mxFrame)
{
if (rEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING)
unregisterSidebarForFrame(this, mxFrame->getController());
else if (rEvent.Action == css::frame::FrameAction_COMPONENT_REATTACHED)
registerSidebarForFrame(this, mxFrame->getController());
}
}
} } // end of namespace sfx2::sidebar } } // end of namespace sfx2::sidebar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment