[Libreoffice-commits] core.git: desktop/source include/sfx2 sfx2/source svx/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Thu Jan 2 11:04:39 UTC 2020


 desktop/source/lib/init.cxx                          |   70 ++++++++++++++++++-
 include/sfx2/sidebar/AsynchronousCall.hxx            |    1 
 include/sfx2/sidebar/SidebarController.hxx           |    2 
 include/sfx2/sidebar/SidebarDockingWindow.hxx        |    5 +
 sfx2/source/sidebar/AsynchronousCall.cxx             |    8 ++
 sfx2/source/sidebar/SidebarController.cxx            |    7 +
 sfx2/source/sidebar/SidebarDockingWindow.cxx         |    6 +
 svx/source/sidebar/ContextChangeEventMultiplexer.cxx |   14 +--
 8 files changed, 104 insertions(+), 9 deletions(-)

New commits:
commit 0778991057fd4592aacc193a5a30a0ee09a8be18
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Dec 19 11:16:15 2019 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Jan 2 12:04:01 2020 +0100

    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 at collabora.com>

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));
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list