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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 3 05:39:55 UTC 2020


 include/vcl/weld.hxx                 |    3 +++
 vcl/inc/jsdialog/jsdialogbuilder.hxx |   11 +++++++++++
 vcl/jsdialog/executor.cxx            |   11 +++++++++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   29 +++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+)

New commits:
commit aa420d6320317be2a40fb5ba30a6a48c988280ba
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Jul 2 14:44:24 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Jul 3 07:39:17 2020 +0200

    jsdialog: weld text view
    
    Change-Id: Ia3bae7a8b812e791fc6a8888e63adca17b8910d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97764
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index abe893bdf03a..95a63ce84f82 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1760,6 +1760,9 @@ public:
 
 class VCL_DLLPUBLIC TextView : virtual public Container
 {
+    friend VCL_DLLPUBLIC bool jsdialog::ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget,
+                                                      StringMap& rData);
+
 private:
     OUString m_sSavedValue;
 
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 79cd5ae41217..ffc67e98ac5e 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -22,6 +22,7 @@
 
 class ToolBox;
 class SfxViewShell;
+class VclMultiLineEdit;
 
 typedef std::map<OString, weld::Widget*> WidgetMap;
 
@@ -94,6 +95,8 @@ public:
                       bool bTakeOwnership = false) override;
     std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id,
                                                 bool bTakeOwnership = true) override;
+    std::unique_ptr<weld::TextView> weld_text_view(const OString& id,
+                                                   bool bTakeOwnership = false) override;
 
     static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent,
                                                     VclMessageType eMessageType,
@@ -251,4 +254,12 @@ public:
     void signal_clicked(const OString& rIdent) override;
 };
 
+class JSTextView : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit>
+{
+public:
+    JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView,
+               SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+    virtual void set_text(const OUString& rText) override;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index f5903fb8f5ba..2317258e3030 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -131,6 +131,17 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
                     return true;
                 }
             }
+
+            auto pTextView = dynamic_cast<weld::TextView*>(pWidget);
+            if (pTextView)
+            {
+                if (sAction == "change")
+                {
+                    pTextView->set_text(rData["data"]);
+                    pTextView->signal_changed();
+                    return true;
+                }
+            }
         }
     }
 
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 56970d32f6f3..4601a26d4cd1 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -14,6 +14,7 @@
 #include <vcl/dialog.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <vcl/toolbox.hxx>
+#include <vcl/vclmedit.hxx>
 
 using namespace weld;
 
@@ -324,6 +325,21 @@ std::unique_ptr<weld::Toolbar> JSInstanceBuilder::weld_toolbar(const OString& id
     return pWeldWidget;
 }
 
+std::unique_ptr<weld::TextView> JSInstanceBuilder::weld_text_view(const OString& id,
+                                                                  bool bTakeOwnership)
+{
+    VclMultiLineEdit* pTextView = m_xBuilder->get<VclMultiLineEdit>(id);
+    auto pWeldWidget = pTextView ? std::make_unique<JSTextView>(
+                                       m_bHasTopLevelDialog ? m_aOwnedToplevel : m_aParentDialog,
+                                       pTextView, this, bTakeOwnership)
+                                 : nullptr;
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
+
+    return pWeldWidget;
+}
+
 weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent,
                                                             VclMessageType eMessageType,
                                                             VclButtonsType eButtonType,
@@ -564,4 +580,17 @@ void JSToolbar::signal_clicked(const OString& rIdent)
     notifyDialogState();
 }
 
+JSTextView::JSTextView(VclPtr<vcl::Window> aOwnedToplevel, ::VclMultiLineEdit* pTextView,
+                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(aOwnedToplevel, pTextView, pBuilder,
+                                                        bTakeOwnership)
+{
+}
+
+void JSTextView::set_text(const OUString& rText)
+{
+    SalInstanceTextView::set_text(rText);
+    notifyDialogState();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list