diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-22 11:26:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-22 17:32:16 +0200 |
commit | a5a8731ce214bcd5ce1c95155b0538ff2d9d337e (patch) | |
tree | 2a7777b98b461fd640a39db3891d57e7a2d8611a /vcl | |
parent | 568db2117af0e0b9b9ee812137ec5dfe321d11f3 (diff) |
add get_page_index
Change-Id: Id90e8fc3fc2f7fa88368e02eaa492b8fc21138e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96859
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 21 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 64 |
2 files changed, 51 insertions, 34 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 116c974d1d6a..3e294b4164e5 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -2175,12 +2175,21 @@ OString SalInstanceNotebook::get_current_page_ident() const return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId()); } -weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const +int SalInstanceNotebook::get_page_index(const OString& rIdent) const { sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(nPageId); if (nPageIndex == TAB_PAGE_NOTFOUND) + return -1; + return nPageIndex; +} + +weld::Container* SalInstanceNotebook::get_page(const OString& rIdent) const +{ + int nPageIndex = get_page_index(rIdent); + if (nPageIndex == -1) return nullptr; + sal_uInt16 nPageId = m_xNotebook->GetPageId(rIdent); TabPage* pPage = m_xNotebook->GetTabPage(nPageId); vcl::Window* pChild = pPage->GetChild(0); if (m_aPages.size() < nPageIndex + 1U) @@ -2304,10 +2313,18 @@ public: virtual OString get_current_page_ident() const override { return m_xNotebook->GetCurPageId(); } - virtual weld::Container* get_page(const OString& rIdent) const override + virtual int get_page_index(const OString& rIdent) const override { sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); if (nPageIndex == TAB_PAGE_NOTFOUND) + return -1; + return nPageIndex; + } + + virtual weld::Container* get_page(const OString& 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) diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 26e1742f7e61..df717239e62c 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -6108,36 +6108,6 @@ private: enable_notify_events(); } - gint get_page_number(const OString& rIdent) const - { - auto nMainIndex = get_page_number(m_pNotebook, rIdent); - auto nOverFlowIndex = get_page_number(m_pOverFlowNotebook, rIdent); - - if (nMainIndex == -1 && nOverFlowIndex == -1) - return -1; - - if (m_bOverFlowBoxIsStart) - { - if (nOverFlowIndex != -1) - return nOverFlowIndex; - else - { - auto nOverFlowLen = m_bOverFlowBoxActive ? gtk_notebook_get_n_pages(m_pOverFlowNotebook) - 1 : 0; - return nMainIndex + nOverFlowLen; - } - } - else - { - if (nMainIndex != -1) - return nMainIndex; - else - { - auto nMainLen = gtk_notebook_get_n_pages(m_pNotebook); - return nOverFlowIndex + nMainLen; - } - } - } - void make_overflow_boxes() { m_pOverFlowBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)); @@ -6417,9 +6387,39 @@ public: return nPage != -1 ? get_page_ident(nPage) : OString(); } + virtual int get_page_index(const OString& rIdent) const override + { + auto nMainIndex = get_page_number(m_pNotebook, rIdent); + auto nOverFlowIndex = get_page_number(m_pOverFlowNotebook, rIdent); + + if (nMainIndex == -1 && nOverFlowIndex == -1) + return -1; + + if (m_bOverFlowBoxIsStart) + { + if (nOverFlowIndex != -1) + return nOverFlowIndex; + else + { + auto nOverFlowLen = m_bOverFlowBoxActive ? gtk_notebook_get_n_pages(m_pOverFlowNotebook) - 1 : 0; + return nMainIndex + nOverFlowLen; + } + } + else + { + if (nMainIndex != -1) + return nMainIndex; + else + { + auto nMainLen = gtk_notebook_get_n_pages(m_pNotebook); + return nOverFlowIndex + nMainLen; + } + } + } + virtual weld::Container* get_page(const OString& rIdent) const override { - int nPage = get_page_number(rIdent); + int nPage = get_page_index(rIdent); if (nPage < 0) return nullptr; @@ -6492,7 +6492,7 @@ public: virtual void set_current_page(const OString& rIdent) override { - gint nPage = get_page_number(rIdent); + gint nPage = get_page_index(rIdent); set_current_page(nPage); } |