diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-12-19 11:16:15 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-12-19 12:53:14 +0000 |
commit | 2d90583fb9026b3c8ee466029423dad3e957eb7e (patch) | |
tree | 7cbda326ba156775558f05f5b3da3a9eb16754c9 /desktop | |
parent | 904e0583d6918a78a88cd73772e2e3e2e32de59a (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
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index c779682e1d71..5d369a996e0c 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -108,6 +108,8 @@ #include <sfx2/lokcharthelper.hxx> #include <sfx2/lokhelper.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> @@ -3302,12 +3305,67 @@ public: virtual void SAL_CALL disposing(const css::lang::EventObject&) override {} }; +static 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"); +} + +static 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; +} + static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWindowId, const char* pArguments) { SolarMutexGuard aGuard; 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."); @@ -3515,6 +3573,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()); |