[Libreoffice-commits] core.git: vcl/inc vcl/jsdialog vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed May 20 12:32:15 UTC 2020


 vcl/inc/jsdialog/jsdialogbuilder.hxx |   17 ++++++++++++++
 vcl/inc/salvtables.hxx               |    2 -
 vcl/jsdialog/jsdialogbuilder.cxx     |   40 +++++++++++++++++++++++++++++++++++
 vcl/source/app/salvtables.cxx        |    2 -
 4 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit 8099c7363c6ddee8390a02389a7dedf7ab9c72b6
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Mar 4 16:05:10 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed May 20 14:31:37 2020 +0200

    jsdialog: refresh on notebook changes
    
    Change-Id: I81159d043add3d8bdd1b81f26f642f99c1430f73
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94183
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94558
    Tested-by: Jenkins

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 24b1ef7808c1..ae8261871ee7 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -37,6 +37,8 @@ public:
                                                     bool bTakeOwnership = false) override;
     virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id,
                                                            bool bTakeOwnership = false) override;
+    virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id,
+                                                          bool bTakeOwnership = false) override;
 };
 
 template <class BaseInstanceClass, class VclClass>
@@ -113,4 +115,19 @@ public:
     virtual void set_entry_text(const OUString& rText) override;
 };
 
+class VCL_DLLPUBLIC JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl>
+{
+public:
+    JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl,
+               SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+    virtual void set_current_page(int nPage) override;
+
+    virtual void set_current_page(const OString& rIdent) override;
+
+    virtual void remove_page(const OString& rIdent) override;
+
+    virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override;
+};
+
 #endif
\ No newline at end of file
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index ad41e5707218..b42440f4b477 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1028,7 +1028,7 @@ class SalInstanceNotebook : public SalInstanceContainer, public virtual weld::No
 {
 private:
     VclPtr<TabControl> m_xNotebook;
-    mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages;
+    mutable std::vector<std::shared_ptr<SalInstanceContainer>> m_aPages;
     std::map<OString, std::pair<VclPtr<TabPage>, VclPtr<VclGrid>>> m_aAddedPages;
 
     DECL_LINK(DeactivatePageHdl, TabControl*, bool);
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index dc6951105763..facd3991746a 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -89,6 +89,15 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OString&
                     : nullptr;
 }
 
+std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OString& id,
+                                                                 bool bTakeOwnership)
+{
+    TabControl* pNotebook = m_xBuilder->get<TabControl>(id);
+    return pNotebook
+               ? std::make_unique<JSNotebook>(m_aOwnedToplevel, pNotebook, this, bTakeOwnership)
+               : nullptr;
+}
+
 JSLabel::JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel,
                  SalInstanceBuilder* pBuilder, bool bTakeOwnership)
     : JSWidget<SalInstanceLabel, FixedText>(aOwnedToplevel, pLabel, pBuilder, bTakeOwnership)
@@ -164,3 +173,34 @@ void JSComboBox::set_entry_text(const OUString& rText)
     SalInstanceComboBoxWithEdit::set_entry_text(rText);
     notifyDialogState();
 }
+
+JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl,
+                       SalInstanceBuilder* pBuilder, bool bTakeOwnership)
+    : JSWidget<SalInstanceNotebook, ::TabControl>(aOwnedToplevel, pControl, pBuilder,
+                                                  bTakeOwnership)
+{
+}
+
+void JSNotebook::set_current_page(int nPage)
+{
+    SalInstanceNotebook::set_current_page(nPage);
+    notifyDialogState();
+}
+
+void JSNotebook::set_current_page(const OString& rIdent)
+{
+    SalInstanceNotebook::set_current_page(rIdent);
+    notifyDialogState();
+}
+
+void JSNotebook::remove_page(const OString& rIdent)
+{
+    SalInstanceNotebook::remove_page(rIdent);
+    notifyDialogState();
+}
+
+void JSNotebook::insert_page(const OString& rIdent, const OUString& rLabel, int nPos)
+{
+    SalInstanceNotebook::insert_page(rIdent, rLabel, nPos);
+    notifyDialogState();
+}
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 82b813a819b8..c53c7603a8c4 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2157,7 +2157,7 @@ weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const
     if (m_aPages.size() < nPageIndex + 1U)
         m_aPages.resize(nPageIndex + 1U);
     if (!m_aPages[nPageIndex])
-        m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false));
+        m_aPages[nPageIndex] = std::make_shared<SalInstanceContainer>(pChild, m_pBuilder, false);
     return m_aPages[nPageIndex].get();
 }
 


More information about the Libreoffice-commits mailing list