diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-12-19 11:16:15 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-01-02 12:04:01 +0100 |
commit | 0778991057fd4592aacc193a5a30a0ee09a8be18 (patch) | |
tree | c7d7b5f3e04d6fcc17917083c67e4afba45574b0 /desktop/source | |
parent | 8d3548e9f05d9ea9fd7880ffe217257cdf5c8585 (diff) |
sidebar: bring new sidebar commands in-house & be more assertive with sfx2
Force the sidebar to do it's asynchronous things synchronously to help
keep things sane. Also emit our (in-process on Android / iOS) context
change notification after everyone else got it & updated their panels.
Change-Id: If94de6c83f1b783d7deee515fc2ee9a8d3754765
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86088
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/lib/init.cxx | 70 |
1 files changed, 69 insertions, 1 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()); |