diff options
-rw-r--r-- | desktop/source/lib/init.cxx | 70 | ||||
-rw-r--r-- | include/sfx2/sidebar/AsynchronousCall.hxx | 1 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarController.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarDockingWindow.hxx | 5 | ||||
-rw-r--r-- | sfx2/source/sidebar/AsynchronousCall.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarDockingWindow.cxx | 6 | ||||
-rw-r--r-- | svx/source/sidebar/ContextChangeEventMultiplexer.cxx | 14 |
8 files changed, 104 insertions, 9 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b80980994c5a..dcbc466ce4b4 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -108,6 +108,8 @@ #include <sfx2/dispatch.hxx> #include <sfx2/lokcharthelper.hxx> #include <sfx2/DocumentSigner.hxx> +#include <sfx2/sidebar/SidebarChildWindow.hxx> +#include <sfx2/sidebar/SidebarDockingWindow.hxx> #include <svx/dialmgr.hxx> #include <svx/dialogs.hrc> #include <svx/strings.hrc> @@ -142,6 +144,7 @@ #include <osl/module.hxx> #include <comphelper/sequence.hxx> #include <sfx2/sfxbasemodel.hxx> +#include <svl/eitem.hxx> #include <svl/undo.hxx> #include <unotools/datetime.hxx> #include <i18nlangtag/mslangid.hxx> @@ -859,6 +862,57 @@ void ExecuteOrientationChange() mxUndoManager->leaveUndoContext(); } +void setupSidebar(bool bShow) +{ + SfxViewShell* pViewShell = SfxViewShell::Current(); + SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr; + if (pViewFrame) + { + if (bShow && !pViewFrame->GetChildWindow(SID_SIDEBAR)) + pViewFrame->SetChildWindow(SID_SIDEBAR, false /* create it */, true /* focus */); + + pViewFrame->ShowChildWindow(SID_SIDEBAR, bShow); + + if (!bShow) + return; + + // Force synchronous population of panels + SfxChildWindow *pChild = pViewFrame->GetChildWindow(SID_SIDEBAR); + if (!pChild) + return; + + auto pDockingWin = dynamic_cast<sfx2::sidebar::SidebarDockingWindow *>(pChild->GetWindow()); + if (!pDockingWin) + return; + pDockingWin->SyncUpdate(); + } + else + SetLastExceptionMsg("No view shell or sidebar"); +} + +VclPtr<Window> getSidebarWindow() +{ + VclPtr<Window> xRet; + + setupSidebar(true); + SfxViewShell* pViewShell = SfxViewShell::Current(); + SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr; + if (!pViewFrame) + return xRet; + + // really a SidebarChildWindow + SfxChildWindow *pChild = pViewFrame->GetChildWindow(SID_SIDEBAR); + if (!pChild) + return xRet; + + // really a SidebarDockingWindow + vcl::Window *pWin = pChild->GetWindow(); + if (!pWin) + return xRet; + xRet = pWin; + return xRet; +} + } // end anonymous namespace // Could be anonymous in principle, but for the unit testing purposes, we @@ -3454,7 +3508,7 @@ public: virtual void SAL_CALL disposing(const css::lang::EventObject&) override {} }; -} +} // anonymous namespace static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWindowId, const char* pArguments) { @@ -3462,6 +3516,10 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin StringMap aMap(jsonToStringMap(pArguments)); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nWindowId); + + if (!pWindow && nWindowId >= 1000000000 /* why unsigned? */) + pWindow = getSidebarWindow(); + if (!pWindow) { SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found."); @@ -3672,6 +3730,16 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma return; } } + else if (gImpl && aCommand == ".uno:SidebarShow") + { + setupSidebar(true); + return; + } + else if (gImpl && aCommand == ".uno:SidebarHide") + { + setupSidebar(false); + return; + } bool bResult = false; LokChartHelper aChartHelper(SfxViewShell::Current()); diff --git a/include/sfx2/sidebar/AsynchronousCall.hxx b/include/sfx2/sidebar/AsynchronousCall.hxx index b05c90dc86db..b2c868b653ec 100644 --- a/include/sfx2/sidebar/AsynchronousCall.hxx +++ b/include/sfx2/sidebar/AsynchronousCall.hxx @@ -40,6 +40,7 @@ public: void RequestCall(); void CancelRequest(); + void Sync(); private: Action const maAction; diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index e65bceb78b6f..abc122faa709 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -169,6 +169,8 @@ public: void saveDeckState(); + void SyncUpdate(); + private: SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame); diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx index 436f5ebce038..d9e3a177a5f5 100644 --- a/include/sfx2/sidebar/SidebarDockingWindow.hxx +++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx @@ -35,7 +35,7 @@ class SidebarController; class SidebarNotifyIdle; -class SidebarDockingWindow final : public SfxDockingWindow +class SFX2_DLLPUBLIC SidebarDockingWindow final : public SfxDockingWindow { public: SidebarDockingWindow(SfxBindings* pBindings, SidebarChildWindow& rChildWindow, @@ -45,6 +45,9 @@ public: virtual bool EventNotify(NotifyEvent& rEvent) override; virtual bool Close() override; + /// Force generation of all panels by completion. + void SyncUpdate(); + void NotifyResize(); using SfxDockingWindow::Close; diff --git a/sfx2/source/sidebar/AsynchronousCall.cxx b/sfx2/source/sidebar/AsynchronousCall.cxx index 495d62f8eb7b..0013ea5e5ceb 100644 --- a/sfx2/source/sidebar/AsynchronousCall.cxx +++ b/sfx2/source/sidebar/AsynchronousCall.cxx @@ -57,6 +57,14 @@ void AsynchronousCall::CancelRequest() } } +void AsynchronousCall::Sync() +{ + if (mnCallId != nullptr) { + maAction(); + CancelRequest(); + } +} + IMPL_LINK_NOARG(AsynchronousCall, HandleUserCall, void*, void ) { mnCallId = nullptr; diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 8d5e7f154650..b34f3b7452b6 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -495,6 +495,13 @@ void SidebarController::ProcessNewWidth (const sal_Int32 nNewWidth) } } +void SidebarController::SyncUpdate() +{ + maPropertyChangeForwarder.Sync(); + maContextChangeUpdate.Sync(); + maAsynchronousDeckSwitch.Sync(); +} + void SidebarController::UpdateConfigurations() { if (maCurrentContext == maRequestedContext diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index 3484799196c9..c3d9f32e2ee6 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -185,6 +185,12 @@ void SidebarDockingWindow::Resize() NotifyResize(); } +void SidebarDockingWindow::SyncUpdate() +{ + if (mpSidebarController.is()) + mpSidebarController->SyncUpdate(); +} + void SidebarDockingWindow::NotifyResize() { if (comphelper::LibreOfficeKit::isActive() && mpSidebarController.is() && SfxViewShell::Current()) diff --git a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx index 321a56c5024e..af804342fa34 100644 --- a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx +++ b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx @@ -39,13 +39,6 @@ void ContextChangeEventMultiplexer::NotifyContextChange ( { if (rxController.is() && rxController->getFrame().is()) { - // notify the LOK too - if (comphelper::LibreOfficeKit::isActive()) - { - if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController)) - SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext)); - } - const css::ui::ContextChangeEventObject aEvent( rxController, GetModuleName(rxController->getFrame()), @@ -56,6 +49,13 @@ void ContextChangeEventMultiplexer::NotifyContextChange ( ::comphelper::getProcessComponentContext())); if (xMultiplexer.is()) xMultiplexer->broadcastContextChangeEvent(aEvent, rxController); + + // notify the LOK too after all the change have taken effect. + if (comphelper::LibreOfficeKit::isActive()) + { + if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController)) + SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext)); + } } } |