diff options
Diffstat (limited to 'sfx2/source/sidebar/SidebarDockingWindow.cxx')
-rw-r--r-- | sfx2/source/sidebar/SidebarDockingWindow.cxx | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index ff0976b29ff4..c0aa3050ef64 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -91,8 +91,6 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi : SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits) , mpSidebarController() , mbIsReadyToDrag(false) - , mbSidebarVisibleInLOK(rChildWindow.IsSidebarVisibleInLOK()) - , mpOldViewShell(SfxViewShell::Current()) , mpIdleNotify(new SidebarNotifyIdle(*this)) { // Get the XFrame from the bindings. @@ -115,26 +113,26 @@ SidebarDockingWindow::~SidebarDockingWindow() void SidebarDockingWindow::dispose() { - DoDispose(); - SfxDockingWindow::dispose(); -} - -void SidebarDockingWindow::DoDispose() -{ if (comphelper::LibreOfficeKit::isActive()) - { - if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) - { - pNotifier->notifyWindow(GetLOKWindowId(), "close"); - ReleaseLOKNotifier(); - } - } + LOKClose(); Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY); mpSidebarController.clear(); if (xComponent.is()) - { xComponent->dispose(); + + SfxDockingWindow::dispose(); +} + +void SidebarDockingWindow::LOKClose() +{ + assert(comphelper::LibreOfficeKit::isActive()); + if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) + { + mpIdleNotify->Stop(); + + pNotifier->notifyWindow(GetLOKWindowId(), "close"); + ReleaseLOKNotifier(); } } @@ -151,7 +149,9 @@ void SidebarDockingWindow::GetFocus() bool SidebarDockingWindow::Close() { - mpSidebarController->SetFloatingDeckClosed( true ); + if (mpSidebarController.is()) + mpSidebarController->SetFloatingDeckClosed(true); + return SfxDockingWindow::Close(); } @@ -170,25 +170,16 @@ void SidebarDockingWindow::SyncUpdate() void SidebarDockingWindow::NotifyResize() { - if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && mbSidebarVisibleInLOK) + if (comphelper::LibreOfficeKit::isActive() && mpSidebarController.is() && SfxViewShell::Current()) { - // 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()) - SetLOKNotifier(SfxViewShell::Current()); - - if (GetLOKNotifier()) + const vcl::ILibreOfficeKitNotifier* pCurrentView = SfxViewShell::Current(); + if (GetLOKNotifier() != pCurrentView) { + // ViewShell not yet set, or has changed. Reset it. + // Note GetLOKWindowId will return a new value after resetting, so we must notify clients. + LOKClose(); + + SetLOKNotifier(pCurrentView); mpIdleNotify->Start(); } } |