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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Feb 9 12:49:14 UTC 2021


 vcl/inc/jsdialog/jsdialogbuilder.hxx |    2 ++
 vcl/jsdialog/executor.cxx            |    8 ++++++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   35 +++++++++++++++++++++++++++++++++++
 vcl/source/window/dialog.cxx         |   10 ++++++++++
 4 files changed, 55 insertions(+)

New commits:
commit 781d9d11c96c142f285a3d45af02207228f60672
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Feb 8 16:58:44 2021 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Feb 9 13:48:41 2021 +0100

    jsdialog: handle standard buttons like help
    
    - dump response bindings
    - execute help callback
    
    Change-Id: Ib0696b4ba74a186a2b80d49f21a1442d1c520821
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110586
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 00d94d8a03b5..0f3fddc0d69d 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -418,6 +418,8 @@ public:
     virtual void set_primary_text(const OUString& rText) override;
 
     virtual void set_secondary_text(const OUString& rText) override;
+
+    virtual void response(int response) override;
 };
 
 class JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox>
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 937064875248..4c40109a5057 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -343,6 +343,14 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
                     pDialog->response(RET_CANCEL);
                     return true;
                 }
+                else if (sAction == "response")
+                {
+                    OString nResponseString
+                        = OUStringToOString(rData["data"], RTL_TEXTENCODING_ASCII_US);
+                    int nResponse = std::atoi(nResponseString.getStr());
+                    pDialog->response(nResponse);
+                    return true;
+                }
             }
         }
         else if (sControlType == "radiobutton")
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index a07ac1959573..e1156bc88c78 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -21,6 +21,23 @@
 
 using namespace weld;
 
+namespace
+{
+void response_help(vcl::Window* pWindow)
+{
+    ::Dialog* pDialog = dynamic_cast<::Dialog*>(pWindow);
+    if (!pDialog)
+        return;
+
+    vcl::Window* pButtonWindow = pDialog->get_widget_for_response(RET_HELP);
+    ::Button* pButton = dynamic_cast<::Button*>(pButtonWindow);
+    if (!pButton)
+        return;
+
+    pButton->Click();
+}
+}
+
 JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow,
                                        VclPtr<vcl::Window> aContentWindow, std::string sTypeOfJSON)
     : Idle("JSDialog notify")
@@ -756,6 +773,12 @@ void JSDialog::undo_collapse()
 
 void JSDialog::response(int response)
 {
+    if (response == RET_HELP)
+    {
+        response_help(m_xWidget.get());
+        return;
+    }
+
     sendClose();
     SalInstanceDialog::response(response);
 }
@@ -930,6 +953,18 @@ void JSMessageDialog::set_secondary_text(const OUString& rText)
     sendFullUpdate();
 }
 
+void JSMessageDialog::response(int response)
+{
+    if (response == RET_HELP)
+    {
+        response_help(m_xWidget.get());
+        return;
+    }
+
+    sendClose();
+    SalInstanceMessageDialog::response(response);
+}
+
 JSCheckButton::JSCheckButton(JSDialogSender* pSender, ::CheckBox* pCheckBox,
                              SalInstanceBuilder* pBuilder, bool bTakeOwnership)
     : JSWidget<SalInstanceCheckButton, ::CheckBox>(pSender, pCheckBox, pBuilder, bTakeOwnership)
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index ab9a30430b4c..d4437116b725 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1630,6 +1630,16 @@ boost::property_tree::ptree Dialog::DumpAsPropertyTree()
     nStartPos = nStartPos >= 0 ? nStartPos + 1 : 0;
     aTree.put("dialogid", sDialogId.copy(nStartPos));
 
+    boost::property_tree::ptree aResponses;
+    for (auto& rResponse : mpDialogImpl->maResponses)
+    {
+        boost::property_tree::ptree aResponse;
+        aResponse.put("id", rResponse.first->get_id());
+        aResponse.put("response", rResponse.second);
+        aResponses.push_back(std::make_pair("", aResponse));
+    }
+    aTree.add_child("responses", aResponses);
+
     return aTree;
 }
 


More information about the Libreoffice-commits mailing list