diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2022-06-07 10:11:48 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2022-06-12 10:38:27 +0200 |
commit | 881774e9e35055cbaed36324542bae006eedb4fb (patch) | |
tree | 43fabaeb51de72e5eaca85d61e6c7d7f850bff82 /sc | |
parent | 932257c50c1dc9302b14862424e24e975f88bcc2 (diff) |
Related: tdf#125040 NB: rework print preview context
Current implementation broadcasts the context change before the
new controller was set on the frame (via XFrame::setComponent).
This isn't going to work for anything LayoutManager based, as
it responds to frame events by recreating all toolbars, so the
newly created toolbar won't see the context sent for the old
controller.
Solve that by delaying the context change to SfxShell::Activate,
like anywhere else in the codebase. And make NB listen to frame
events, so it could also switch listening to the new controller.
Also fixed a crash when switching to print preview in Writer with
the navigator in the sidebar being active. Ideally we shouldn't
even try to create sidebar panels in print preview, as the sidebar
as a whole is disabled. But left that for a future investigation.
Change-Id: I07759c676d2a2eb6f752fe778b559b15d2d759ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135492
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/prevwsh.cxx | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 18cae40634d7..d38b4311f143 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -155,26 +155,7 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, nMaxVertPos(0) { Construct( &pViewFrame->GetWindow() ); - - try - { - SfxShell::SetContextBroadcasterEnabled(true); - SfxShell::SetContextName( - vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Printpreview)); - SfxShell::BroadcastContextForActivation(true); - } - catch (const css::uno::RuntimeException& e) - { - // tdf#130559: allow BackingComp to fail adding listener when opening document - css::uno::Reference<css::lang::XServiceInfo> xServiceInfo(e.Context, css::uno::UNO_QUERY); - if (!xServiceInfo || !xServiceInfo->supportsService("com.sun.star.frame.StartModule")) - throw; - SAL_WARN("sc.ui", "Opening file from StartModule straight into print preview"); - } - - auto& pNotebookBar = pViewFrame->GetWindow().GetSystemWindow()->GetNotebookBar(); - if (pNotebookBar) - pNotebookBar->ControlListenerForCurrentController(false); // stop listening + SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Printpreview)); if ( auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pOldSh) ) { @@ -202,9 +183,6 @@ ScPreviewShell::~ScPreviewShell() if (mpFrameWindow) mpFrameWindow->SetCloseHdl(Link<SystemWindow&,void>()); // Remove close handler. - if (auto& pBar = GetViewFrame()->GetWindow().GetSystemWindow()->GetNotebookBar()) - pBar->ControlListenerForCurrentController(true); // let it start listening now - // #108333#; notify Accessibility that Shell is dying and before destroy all BroadcastAccessibility( SfxHint( SfxHintId::Dying ) ); pAccessibilityBroadcaster.reset(); @@ -560,6 +538,8 @@ void ScPreviewShell::Activate(bool bMDI) if ( pInputHdl ) pInputHdl->NotifyChange( nullptr ); } + + SfxShell::Activate(bMDI); } void ScPreviewShell::Execute( SfxRequest& rReq ) |