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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 1 11:18:11 UTC 2020


 vcl/inc/jsdialog/jsdialogbuilder.hxx |   24 ++++++++++++++++++------
 vcl/jsdialog/executor.cxx            |   12 ++++++++++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   29 +++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 6 deletions(-)

New commits:
commit f74370e3875fcfac865f194b3110a458d43a6332
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Nov 17 14:32:04 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Dec 1 12:17:38 2020 +0100

    jsdialog: implemented Expander widget
    
    Change-Id: Ib0aee0e01c662a4d6a9231d9a1a951c9fa68eff4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106927
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 86bc0020eaea..3d7b6c62c24e 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -119,12 +119,14 @@ public:
     weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr,
                       FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr,
                       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;
-    std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id,
-                                                   bool bTakeOwnership = false) override;
+    virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OString& id,
+                                                        bool bTakeOwnership = true) override;
+    virtual std::unique_ptr<weld::TextView> weld_text_view(const OString& id,
+                                                           bool bTakeOwnership = false) override;
+    virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OString& id,
+                                                           bool bTakeOwnership = false) override;
+    virtual std::unique_ptr<weld::Expander> weld_expander(const OString& id,
+                                                          bool bTakeOwnership = false) override;
 
     static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent,
                                                     VclMessageType eMessageType,
@@ -323,4 +325,14 @@ public:
     virtual void select(int pos) override;
 };
 
+class JSExpander : public JSWidget<SalInstanceExpander, ::VclExpander>
+{
+public:
+    JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+               ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+               std::string sTypeOfJSON);
+
+    virtual void set_expanded(bool bExpand) 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 a4fb7093b4bf..8e1ec3cf8f7b 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -208,6 +208,18 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat
                 }
             }
         }
+        else if (sControlType == "expander")
+        {
+            auto pExpander = dynamic_cast<weld::Expander*>(pWidget);
+            if (pExpander)
+            {
+                if (sAction == "toggle")
+                {
+                    pExpander->set_expanded(!pExpander->get_expanded());
+                    return true;
+                }
+            }
+        }
     }
 
     return false;
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 5ae77f856e2f..f02d469dc701 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -463,6 +463,21 @@ std::unique_ptr<weld::TreeView> JSInstanceBuilder::weld_tree_view(const OString&
     return pWeldWidget;
 }
 
+std::unique_ptr<weld::Expander> JSInstanceBuilder::weld_expander(const OString& id,
+                                                                 bool bTakeOwnership)
+{
+    VclExpander* pExpander = m_xBuilder->get<VclExpander>(id);
+    auto pWeldWidget
+        = pExpander ? std::make_unique<JSExpander>(GetNotifierWindow(), GetContentWindow(),
+                                                   pExpander, this, bTakeOwnership, m_sTypeOfJSON)
+                    : nullptr;
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
+
+    return pWeldWidget;
+}
+
 weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent,
                                                             VclMessageType eMessageType,
                                                             VclButtonsType eButtonType,
@@ -791,4 +806,18 @@ void JSTreeView::select(int pos)
     enable_notify_events();
 }
 
+JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
+                       ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership,
+                       std::string sTypeOfJSON)
+    : JSWidget<SalInstanceExpander, ::VclExpander>(aNotifierWindow, aContentWindow, pExpander,
+                                                   pBuilder, bTakeOwnership, sTypeOfJSON)
+{
+}
+
+void JSExpander::set_expanded(bool bExpand)
+{
+    SalInstanceExpander::set_expanded(bExpand);
+    notifyDialogState();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list