[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 3 commits - desktop/source include/vcl vcl/jsdialog

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Thu May 21 08:09:13 UTC 2020


 desktop/source/lib/init.cxx              |   30 +++++++++++++++++++++
 include/vcl/jsdialog/jsdialogbuilder.hxx |   17 ++++++++++--
 vcl/jsdialog/jsdialogbuilder.cxx         |   43 +++++++++++++++++++++++--------
 3 files changed, 76 insertions(+), 14 deletions(-)

New commits:
commit e479e5ecfd42cb4e2c019a0454ae02b893f68180
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Mar 18 10:31:09 2020 +0100
Commit:     Szymon Kłos <eszkadev at gmail.com>
CommitDate: Thu May 21 10:07:18 2020 +0200

    jsdialog: implement plus/minus for welded spinfields
    
    Change-Id: I8a0bf4190c09520d7be78c44742902539cb9bf38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94483
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 8b556e757684..6f563d1cf22c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3640,6 +3640,23 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
                             bContinueWithLOKWindow = true;
                     }
                 }
+                else if (sControlType == "spinfield")
+                {
+                    auto pSpinField = dynamic_cast<weld::SpinButton*>(pWidget);
+                    if (pSpinField)
+                    {
+                        if (sAction == "plus")
+                        {
+                            pSpinField->set_value(pSpinField->get_value() + 1);
+                        }
+                        else if (sAction == "minus")
+                        {
+                            pSpinField->set_value(pSpinField->get_value() - 1);
+                        }
+                        else
+                            bContinueWithLOKWindow = true;
+                    }
+                }
                 else
                 {
                     bContinueWithLOKWindow = true;
commit b20592dbec651ad693c44869d4055e23b3dcdf20
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Mar 10 16:46:37 2020 +0100
Commit:     Szymon Kłos <eszkadev at gmail.com>
CommitDate: Thu May 21 10:07:11 2020 +0200

    jsdialog: use welding for button click event
    
    Change-Id: I0320dfb5cdc4f936eddff003bda7d16bdd1c4667
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94342
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a11f780b5714..8b556e757684 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3627,6 +3627,19 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
                             bContinueWithLOKWindow = true;
                     }
                 }
+                else if (sControlType == "pushbutton")
+                {
+                    auto pButton = dynamic_cast<weld::Button*>(pWidget);
+                    if (pButton)
+                    {
+                        if (sAction == "click")
+                        {
+                            pButton->clicked();
+                        }
+                        else
+                            bContinueWithLOKWindow = true;
+                    }
+                }
                 else
                 {
                     bContinueWithLOKWindow = true;
commit 72f8a10f7afa9919f943cbda144e465f1e8746f1
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Mar 31 15:42:28 2020 +0200
Commit:     Szymon Kłos <eszkadev at gmail.com>
CommitDate: Thu May 21 10:07:04 2020 +0200

    jsdialog: use Idle timer to send updates
    
    Change-Id: Ib4f18bab1279c622b576dca53169b40c4a2526bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94482
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index 6921384c9386..4c2173a7f009 100644
--- a/include/vcl/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -22,13 +22,24 @@
 
 typedef std::map<OString, weld::Widget*> WidgetMap;
 
-class JSDialogSender
+class JSDialogNotifyIdle : public Idle
 {
-    VclPtr<vcl::Window> m_aOwnedToplevel;
+    VclPtr<vcl::Window> m_aWindow;
+    std::string m_LastNotificationMessage;
+
+public:
+    JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow);
+
+    void Invoke() override;
+};
+
+class VCL_DLLPUBLIC JSDialogSender
+{
+    std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify;
 
 public:
     JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel)
-        : m_aOwnedToplevel(aOwnedToplevel)
+        : mpIdleNotify(new JSDialogNotifyIdle(aOwnedToplevel))
     {
     }
 
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 0ce65d586362..4a9fab076225 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -16,23 +16,44 @@
 
 using namespace weld;
 
-void JSDialogSender::notifyDialogState()
+JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow)
+    : Idle("JSDialog notify")
+    , m_aWindow(aWindow)
+    , m_LastNotificationMessage()
 {
-    if (!m_aOwnedToplevel)
-        return;
+    SetPriority(TaskPriority::POST_PAINT);
+}
 
-    const vcl::ILibreOfficeKitNotifier* pNotifier = m_aOwnedToplevel->GetLOKNotifier();
-    if (pNotifier)
+void JSDialogNotifyIdle::Invoke()
+{
+    try
     {
-        std::stringstream aStream;
-        boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree();
-        aTree.put("id", m_aOwnedToplevel->GetLOKWindowId());
-        boost::property_tree::write_json(aStream, aTree);
-        const std::string message = aStream.str();
-        pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+        if (!m_aWindow)
+            return;
+
+        const vcl::ILibreOfficeKitNotifier* pNotifier = m_aWindow->GetLOKNotifier();
+        if (pNotifier)
+        {
+            std::stringstream aStream;
+            boost::property_tree::ptree aTree = m_aWindow->DumpAsPropertyTree();
+            aTree.put("id", m_aWindow->GetLOKWindowId());
+            boost::property_tree::write_json(aStream, aTree);
+            const std::string message = aStream.str();
+            if (message != m_LastNotificationMessage)
+            {
+                m_LastNotificationMessage = message;
+                pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+            }
+        }
+    }
+    catch (boost::property_tree::json_parser::json_parser_error& rError)
+    {
+        SAL_WARN("vcl.jsdialog", rError.message());
     }
 }
 
+void JSDialogSender::notifyDialogState() { mpIdleNotify->Start(); }
+
 JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot,
                                      const OUString& rUIFile)
     : SalInstanceBuilder(dynamic_cast<SalInstanceWidget*>(pParent)


More information about the Libreoffice-commits mailing list