[Libreoffice-commits] core.git: include/sfx2 sfx2/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 26 13:23:25 UTC 2019
include/sfx2/sidebar/SidebarDockingWindow.hxx | 3 +++
sfx2/source/sidebar/SidebarController.cxx | 16 +++++++++++++---
sfx2/source/sidebar/SidebarDockingWindow.cxx | 15 ++++++++++++++-
3 files changed, 30 insertions(+), 4 deletions(-)
New commits:
commit b01f4eb13e15d5149379561e9608bed5d670271b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Tue Nov 27 09:26:27 2018 -0500
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 26 15:22:23 2019 +0200
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
Reviewed-on: https://gerrit.libreoffice.org/73516
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx
index 5e54f00b53ad..e54d55f2b791 100644
--- a/include/sfx2/sidebar/SidebarDockingWindow.hxx
+++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx
@@ -23,6 +23,8 @@
#include <rtl/ref.hxx>
+class SfxViewShell;
+
namespace svt { class AcceleratorExecute; }
namespace sfx2 { namespace sidebar {
@@ -65,6 +67,7 @@ private:
void DoDispose();
const bool mbSidebarVisibleInLOK;
+ const SfxViewShell* mpOldViewShell;
};
} } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index bbdb1a4c8c67..b2094e04631b 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1076,10 +1076,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:
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index a12bb6f4d12e..f76e71fc2d45 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -43,6 +43,7 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi
, mpSidebarController()
, mbIsReadyToDrag(false)
, mbSidebarVisibleInLOK(rChildWindow.IsSidebarVisibleInLOK())
+ , mpOldViewShell(SfxViewShell::Current())
{
// Get the XFrame from the bindings.
if (pSfxBindings==nullptr || pSfxBindings->GetDispatcher()==nullptr)
@@ -113,7 +114,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())
More information about the Libreoffice-commits
mailing list