vcl/inc/jsdialog/jsdialogbuilder.hxx | 10 + vcl/inc/salvtables.hxx | 43 ++++++++ vcl/jsdialog/jsdialogbuilder.cxx | 51 ++++++++- vcl/source/app/salvtables.cxx | 181 ++++++++++++++++------------------- 4 files changed, 184 insertions(+), 101 deletions(-)
New commits: commit ba81501e6094d89c18629dc1ad9b7eb6e3837e50 Author: Szymon Kłos <[email protected]> AuthorDate: Thu Aug 17 09:24:09 2023 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Mon Sep 18 20:22:39 2023 +0200 jsdialog: vertical notebook Change-Id: I584509bfd3d367c8b1c4183c8d176ba7b7ad0cfe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155755 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Attila Szűcs <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157027 Tested-by: Jenkins Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index f632753d35b1..33f5bdcbe881 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -634,6 +634,16 @@ public: virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override; }; +class JSVerticalNotebook final : public JSWidget<SalInstanceVerticalNotebook, ::VerticalTabControl> +{ +public: + JSVerticalNotebook(JSDialogSender* pSender, ::VerticalTabControl* pControl, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void remove_page(const OUString& rIdent) override; + virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override; +}; + class JSSpinButton final : public JSWidget<SalInstanceSpinButton, ::FormattedField> { public: diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index cd191d15a9d8..fcabfc67bbbc 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -7,10 +7,26 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <boost/property_tree/json_parser.hpp> - +#include <jsdialog/jsdialogbuilder.hxx> +#include <sal/log.hxx> #include <comphelper/base64.hxx> #include <comphelper/lok.hxx> +#include <utility> +#include <vcl/tabpage.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/toolkit/button.hxx> +#include <vcl/toolkit/combobox.hxx> +#include <vcl/toolkit/dialog.hxx> +#include <vcl/toolkit/treelistentry.hxx> +#include <vcl/toolkit/vclmedit.hxx> +#include <verticaltabctrl.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <messagedialog.hxx> +#include <tools/json_writer.hxx> +#include <o3tl/deleter.hxx> +#include <memory> +#include <boost/property_tree/json_parser.hpp> +#include <vcl/jsdialog/executor.hxx> #include <cppuhelper/supportsservice.hxx> #include <jsdialog/jsdialogbuilder.hxx> @@ -1043,9 +1059,15 @@ std::unique_ptr<weld::ComboBox> JSInstanceBuilder::weld_combo_box(const OUString std::unique_ptr<weld::Notebook> JSInstanceBuilder::weld_notebook(const OUString& id) { - TabControl* pNotebook = m_xBuilder->get<TabControl>(id); - auto pWeldWidget - = pNotebook ? std::make_unique<JSNotebook>(this, pNotebook, this, false) : nullptr; + std::unique_ptr<weld::Notebook> pWeldWidget; + vcl::Window* pNotebook = m_xBuilder->get(id); + + if (pNotebook && pNotebook->GetType() == WindowType::TABCONTROL) + pWeldWidget + = std::make_unique<JSNotebook>(this, static_cast<TabControl*>(pNotebook), this, false); + else if (pNotebook->GetType() == WindowType::VERTICALTABCONTROL) + pWeldWidget = std::make_unique<JSVerticalNotebook>( + this, static_cast<VerticalTabControl*>(pNotebook), this, false); if (pWeldWidget) RememberWidget(id, pWeldWidget.get()); @@ -1711,6 +1733,25 @@ void JSNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, int sendFullUpdate(); } +JSVerticalNotebook::JSVerticalNotebook(JSDialogSender* pSender, ::VerticalTabControl* pControl, + SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : JSWidget<SalInstanceVerticalNotebook, ::VerticalTabControl>(pSender, pControl, pBuilder, + bTakeOwnership) +{ +} + +void JSVerticalNotebook::remove_page(const OUString& rIdent) +{ + SalInstanceVerticalNotebook::remove_page(rIdent); + sendFullUpdate(); +} + +void JSVerticalNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) +{ + SalInstanceVerticalNotebook::insert_page(rIdent, rLabel, nPos); + sendFullUpdate(); +} + JSSpinButton::JSSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceSpinButton, ::FormattedField>(pSender, pSpin, pBuilder, bTakeOwnership) commit fa2e2757f35883f61841c49f53ad5f80979c8a76 Author: Szymon Kłos <[email protected]> AuthorDate: Mon Sep 18 18:49:55 2023 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Mon Sep 18 20:22:30 2023 +0200 Move SalInstanceVerticalNotebook decl to header Change-Id: I38c7ed846c8a19f72f5738bd137cefebd6a33070 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157026 Tested-by: Jenkins Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 505720629a5e..09186972a3ab 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -31,6 +31,7 @@ #include "calendar.hxx" #include "iconview.hxx" #include "messagedialog.hxx" +#include "verticaltabctrl.hxx" namespace vcl { @@ -2250,4 +2251,46 @@ public: virtual ~SalInstanceFormattedSpinButton() override; }; +class SalInstanceVerticalNotebook : public SalInstanceWidget, public virtual weld::Notebook +{ +private: + VclPtr<VerticalTabControl> m_xNotebook; + mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; + + DECL_LINK(DeactivatePageHdl, VerticalTabControl*, bool); + DECL_LINK(ActivatePageHdl, VerticalTabControl*, void); + +public: + SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + + virtual int get_current_page() const override; + + virtual OUString get_page_ident(int nPage) const override; + + virtual OUString get_current_page_ident() const override; + + virtual int get_page_index(const OUString& rIdent) const override; + + virtual weld::Container* get_page(const OUString& rIdent) const override; + + virtual void set_current_page(int nPage) override; + + virtual void set_current_page(const OUString& rIdent) override; + + virtual void remove_page(const OUString& rIdent) override; + + virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override; + + virtual int get_n_pages() const override; + + virtual void set_tab_label_text(const OUString& rIdent, const OUString& rText) override; + + virtual OUString get_tab_label_text(const OUString& rIdent) const override; + + virtual void set_show_tabs(bool /*bShow*/) override; + + virtual ~SalInstanceVerticalNotebook() override; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 780c6baae79e..1ace1412ffdc 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -78,7 +78,6 @@ #include <bitmaps.hlst> #include <listbox.hxx> #include <menutogglebutton.hxx> -#include <verticaltabctrl.hxx> #include <window.h> #include <wizdlg.hxx> #include <salvtables.hxx> @@ -2734,120 +2733,110 @@ IMPL_LINK_NOARG(SalInstanceNotebook, ActivatePageHdl, TabControl*, void) m_aEnterPageHdl.Call(get_current_page_ident()); } -namespace -{ -class SalInstanceVerticalNotebook : public SalInstanceWidget, public virtual weld::Notebook +SalInstanceVerticalNotebook::SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, + SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceWidget(pNotebook, pBuilder, bTakeOwnership) + , m_xNotebook(pNotebook) { -private: - VclPtr<VerticalTabControl> m_xNotebook; - mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; + m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook, ActivatePageHdl)); + m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceVerticalNotebook, DeactivatePageHdl)); +} - DECL_LINK(DeactivatePageHdl, VerticalTabControl*, bool); - DECL_LINK(ActivatePageHdl, VerticalTabControl*, void); +int SalInstanceVerticalNotebook::get_current_page() const +{ + return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); +} -public: - SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, SalInstanceBuilder* pBuilder, - bool bTakeOwnership) - : SalInstanceWidget(pNotebook, pBuilder, bTakeOwnership) - , m_xNotebook(pNotebook) - { - m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook, ActivatePageHdl)); - m_xNotebook->SetDeactivatePageHdl( - LINK(this, SalInstanceVerticalNotebook, DeactivatePageHdl)); - } +OUString SalInstanceVerticalNotebook::get_page_ident(int nPage) const +{ + return m_xNotebook->GetPageId(nPage); +} - virtual int get_current_page() const override - { - return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); - } +OUString SalInstanceVerticalNotebook::get_current_page_ident() const +{ + return m_xNotebook->GetCurPageId(); +} - virtual OUString get_page_ident(int nPage) const override - { - return m_xNotebook->GetPageId(nPage); - } +int SalInstanceVerticalNotebook::get_page_index(const OUString& rIdent) const +{ + sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); + if (nPageIndex == TAB_PAGE_NOTFOUND) + return -1; + return nPageIndex; +} - virtual OUString get_current_page_ident() const override { return m_xNotebook->GetCurPageId(); } +weld::Container* SalInstanceVerticalNotebook::get_page(const OUString& rIdent) const +{ + int nPageIndex = get_page_index(rIdent); + if (nPageIndex == -1) + return nullptr; + auto pChild = m_xNotebook->GetPage(rIdent); + 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)); + return m_aPages[nPageIndex].get(); +} - virtual int get_page_index(const OUString& rIdent) const override - { - sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); - if (nPageIndex == TAB_PAGE_NOTFOUND) - return -1; - return nPageIndex; - } +void SalInstanceVerticalNotebook::set_current_page(int nPage) +{ + m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); +} - virtual weld::Container* get_page(const OUString& rIdent) const override - { - int nPageIndex = get_page_index(rIdent); - if (nPageIndex == -1) - return nullptr; - auto pChild = m_xNotebook->GetPage(rIdent); - 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)); - return m_aPages[nPageIndex].get(); - } +void SalInstanceVerticalNotebook::set_current_page(const OUString& rIdent) +{ + m_xNotebook->SetCurPageId(rIdent); +} - virtual void set_current_page(int nPage) override - { - m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); - } +void SalInstanceVerticalNotebook::remove_page(const OUString& rIdent) +{ + sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); + if (nPageIndex == TAB_PAGE_NOTFOUND) + return; + m_xNotebook->RemovePage(rIdent); + if (nPageIndex < m_aPages.size()) + m_aPages.erase(m_aPages.begin() + nPageIndex); +} - virtual void set_current_page(const OUString& rIdent) override - { - m_xNotebook->SetCurPageId(rIdent); - } +void SalInstanceVerticalNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, + int nPos) +{ + VclPtrInstance<VclGrid> xGrid(m_xNotebook->GetPageParent()); + xGrid->set_hexpand(true); + xGrid->set_vexpand(true); + m_xNotebook->InsertPage(rIdent, rLabel, Image(), "", xGrid, nPos); - virtual void remove_page(const OUString& rIdent) override + if (nPos != -1) { - sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); - if (nPageIndex == TAB_PAGE_NOTFOUND) - return; - m_xNotebook->RemovePage(rIdent); + unsigned int nPageIndex = static_cast<unsigned int>(nPos); if (nPageIndex < m_aPages.size()) - m_aPages.erase(m_aPages.begin() + nPageIndex); - } - - virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override - { - VclPtrInstance<VclGrid> xGrid(m_xNotebook->GetPageParent()); - xGrid->set_hexpand(true); - xGrid->set_vexpand(true); - m_xNotebook->InsertPage(rIdent, rLabel, Image(), "", xGrid, nPos); - - if (nPos != -1) - { - unsigned int nPageIndex = static_cast<unsigned int>(nPos); - if (nPageIndex < m_aPages.size()) - m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); - } + m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); } +} - virtual int get_n_pages() const override { return m_xNotebook->GetPageCount(); } +int SalInstanceVerticalNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); } - virtual void set_tab_label_text(const OUString& rIdent, const OUString& rText) override - { - return m_xNotebook->SetPageText(rIdent, rText); - } +void SalInstanceVerticalNotebook::set_tab_label_text(const OUString& rIdent, const OUString& rText) +{ + return m_xNotebook->SetPageText(rIdent, rText); +} - virtual OUString get_tab_label_text(const OUString& rIdent) const override - { - return m_xNotebook->GetPageText(rIdent); - } +OUString SalInstanceVerticalNotebook::get_tab_label_text(const OUString& rIdent) const +{ + return m_xNotebook->GetPageText(rIdent); +} - virtual void set_show_tabs(bool /*bShow*/) override - { - // if someone needs this they will have to implement it in VerticalTabControl - assert(false && "not implemented"); - } +void SalInstanceVerticalNotebook::set_show_tabs(bool /*bShow*/) +{ + // if someone needs this they will have to implement it in VerticalTabControl + assert(false && "not implemented"); +} - virtual ~SalInstanceVerticalNotebook() override - { - m_xNotebook->SetActivatePageHdl(Link<VerticalTabControl*, void>()); - m_xNotebook->SetDeactivatePageHdl(Link<VerticalTabControl*, bool>()); - } -}; +SalInstanceVerticalNotebook::~SalInstanceVerticalNotebook() +{ + m_xNotebook->SetActivatePageHdl(Link<VerticalTabControl*, void>()); + m_xNotebook->SetDeactivatePageHdl(Link<VerticalTabControl*, bool>()); } IMPL_LINK_NOARG(SalInstanceVerticalNotebook, DeactivatePageHdl, VerticalTabControl*, bool)
