[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/inc vcl/jsdialog

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 19 01:03:28 UTC 2021


 vcl/inc/jsdialog/jsdialogbuilder.hxx |    4 ++
 vcl/jsdialog/jsdialogbuilder.cxx     |   50 +++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

New commits:
commit e104272ac452d39a0f926f508051bd6af6613d24
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Thu Dec 17 11:34:46 2020 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Tue Jan 19 02:02:53 2021 +0100

    jsdialog: use "WindowPaint" event to update
    
    If the idle notifier is disabled instead it uses
    the "WindowPaint" when the model has changed to
    notify update status to client side.
    
    Anyway the "WindowPaint" is supposed to be
    asynchronous.
    
    Change-Id: I0bb99526c72510a97e3906340c1e9269478da8cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107916
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109143
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 297b150e2f13..bba976debfd3 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -52,6 +52,7 @@ public:
     void ForceUpdate();
     void sendClose();
     VclPtr<vcl::Window> getNotifierWindow() { return m_aNotifierWindow; }
+    void updateStatus(VclPtr<vcl::Window> pWindow);
 
 private:
     void send(const boost::property_tree::ptree& rTree);
@@ -73,6 +74,7 @@ public:
     void notifyDialogState(bool bForce = false);
     void sendClose();
     void dumpStatus();
+    void sendUpdate(VclPtr<vcl::Window> pWindow);
 };
 
 class JSDropTarget final
@@ -380,6 +382,8 @@ public:
 
 class JSTreeView : public JSWidget<SalInstanceTreeView, ::SvTabListBox>
 {
+    DECL_LINK(on_window_event, VclWindowEvent&, void);
+
 public:
     JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
                ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 0d5f2c8f77ce..0cd9661b76ec 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -91,6 +91,40 @@ boost::property_tree::ptree JSDialogNotifyIdle::dumpStatus() const
     return aTree;
 }
 
+void JSDialogNotifyIdle::updateStatus(VclPtr<vcl::Window> pWindow)
+{
+    if (!m_aNotifierWindow)
+        return;
+
+    if (m_aNotifierWindow->IsReallyVisible())
+    {
+        if (const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier())
+        {
+            boost::property_tree::ptree aTree;
+
+            aTree.put("commandName", ".uno:jsdialog");
+            aTree.put("success", "true");
+            {
+                boost::property_tree::ptree aResult;
+                aResult.put("dialog_id", m_aNotifierWindow->GetLOKWindowId());
+                aResult.put("control_id", pWindow->get_id());
+                {
+                    boost::property_tree::ptree aControl;
+                    aControl = pWindow->DumpAsPropertyTree();
+                    aResult.add_child("control", aControl);
+                }
+                aTree.add_child("result", aResult);
+            }
+
+            std::stringstream aStream;
+            boost::property_tree::write_json(aStream, aTree);
+            const std::string message = aStream.str();
+            pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT,
+                                                  message.c_str());
+        }
+    }
+}
+
 boost::property_tree::ptree JSDialogNotifyIdle::generateCloseMessage() const
 {
     boost::property_tree::ptree aTree;
@@ -120,6 +154,11 @@ void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); }
 
 void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); }
 
+void JSDialogSender::sendUpdate(VclPtr<vcl::Window> pWindow)
+{
+    mpIdleNotify->updateStatus(pWindow);
+}
+
 // Drag and drop
 
 class JSDropTargetDropContext
@@ -935,6 +974,8 @@ JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window>
     : JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, aContentWindow, pTreeView,
                                                     pBuilder, bTakeOwnership, sTypeOfJSON)
 {
+    if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify())
+        pTreeView->AddEventListener(LINK(this, JSTreeView, on_window_event));
 }
 
 void JSTreeView::set_toggle(int pos, TriState eState, int col)
@@ -1024,6 +1065,15 @@ void JSTreeView::set_text(const weld::TreeIter& rIter, const OUString& rStr, int
     notifyDialogState();
 }
 
+IMPL_LINK(JSTreeView, on_window_event, VclWindowEvent&, rEvent, void)
+{
+    if (rEvent.GetId() == VclEventId::WindowPaint && get_visible() && m_xTreeView->IsDirtyModel())
+    {
+        sendUpdate(m_xTreeView);
+        m_xTreeView->SetDirtyModel(false);
+    }
+}
+
 JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
                        ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
                        std::string sTypeOfJSON)


More information about the Libreoffice-commits mailing list