Kaydet (Commit) 5c726cdc authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Jan Holesovsky

LOK: sidebar: publish notifications to the correct view

The ViewShell, which represents the view in question and therefore
which view gets the window notifications, is incorrect when
the sidebar is first created upon creating/attaching a new view.

This leads us to a workaround to make sure that we publish
notifications to the correct view.

We also have to hide the sidebar instead of closing because
the workaround wouldn't work when re-creating the sidebar
on an existing view. See comments in code.

Change-Id: I9d3be901688291b04d634b68e1e20c7add77381f
üst 259ce91c
......@@ -56,6 +56,7 @@ private:
void DoDispose();
const bool mbSidebarVisibleInLOK;
const SfxViewShell* mpOldViewShell;
};
} } // end of namespace sfx2::sidebar
......
......@@ -1059,10 +1059,20 @@ IMPL_LINK(SidebarController, OnMenuItemSelected, Menu*, pMenu, bool)
case MID_HIDE_SIDEBAR:
{
const util::URL aURL (Tools::GetURL(".uno:Sidebar"));
Reference<frame::XDispatch> xDispatch (Tools::GetDispatch(mxFrame, aURL));
if (xDispatch.is())
if (!comphelper::LibreOfficeKit::isActive())
{
const util::URL aURL(Tools::GetURL(".uno:Sidebar"));
Reference<frame::XDispatch> xDispatch(Tools::GetDispatch(mxFrame, aURL));
if (xDispatch.is())
xDispatch->dispatch(aURL, Sequence<beans::PropertyValue>());
}
else
{
// In LOK we don't really destroy the sidebar when "closing";
// we simply hide it. This is because recreating it is problematic
// See notes in SidebarDockingWindow::NotifyResize().
RequestCloseDeck();
}
break;
}
default:
......
......@@ -36,6 +36,7 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi
: SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits)
, mpSidebarController()
, mbSidebarVisibleInLOK(rChildWindow.IsSidebarVisibleInLOK())
, mpOldViewShell(SfxViewShell::Current())
{
// Get the XFrame from the bindings.
if (pSfxBindings==nullptr || pSfxBindings->GetDispatcher()==nullptr)
......@@ -97,7 +98,19 @@ void SidebarDockingWindow::NotifyResize()
{
if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && mbSidebarVisibleInLOK)
{
if (mpSidebarController.is() && !GetLOKNotifier())
// When a new view is attached, and Sidebar is created (SidebarDockingWindow is constructed),
// unfortunately we still have the *old* ViewShell (and ViewFrame). This happens because
// we get multiple NotifyResize are called while SfxBaseController::ConnectSfxFrame_Impl
// goes through the motions of creating and attaching a new frame/view.
// Problem is that once we SetLOKNotifier on a window, we can't change it. So we better
// set the correct one. Worse, if we set the old one, we will change the sidebar of the
// wrong view, messing things up badly for the users.
// Knowing the above, we wait until the dust settles, by observing when the ViewShell is
// changed from the time we were created.
// Note: this means we *cannot* create a sidebar post attaching a new view because the
// ViewShell will not change, and therefore we will never SetLOKNotifier. To avoid that
// we hide sidebars instead of closing (see OnMenuItemSelected in SidebarController).
if (mpSidebarController.is() && !GetLOKNotifier() && mpOldViewShell != SfxViewShell::Current())
SetLOKNotifier(SfxViewShell::Current());
if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
......
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