diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-22 13:02:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-22 17:32:33 +0200 |
commit | 64b3ab56cbf2c48f211ad588a5d0a69d74f3bf3b (patch) | |
tree | 95873500c3fbfb0273f00415688b5e7a60c3fa2f /vcl | |
parent | a5a8731ce214bcd5ce1c95155b0538ff2d9d337e (diff) |
move existing pages if inserting a page before an existing one
Change-Id: I661550cecab48c3173bb46c65ca4adc9ade5f927
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96860
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 16 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 7 |
2 files changed, 23 insertions, 0 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 3e294b4164e5..6d11b07444d0 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -2234,6 +2234,8 @@ void SalInstanceNotebook::insert_page(const OString& rIdent, const OUString& rLa sal_uInt16 nPageCount = m_xNotebook->GetPageCount(); sal_uInt16 nLastPageId = nPageCount ? m_xNotebook->GetPageId(nPageCount - 1) : 0; sal_uInt16 nNewPageId = nLastPageId + 1; + while (m_xNotebook->GetPagePos(nNewPageId) != TAB_PAGE_NOTFOUND) + ++nNewPageId; m_xNotebook->InsertPage(nNewPageId, rLabel, nPos == -1 ? TAB_APPEND : nPos); VclPtrInstance<TabPage> xPage(m_xNotebook); VclPtrInstance<VclGrid> xGrid(xPage); @@ -2244,6 +2246,13 @@ void SalInstanceNotebook::insert_page(const OString& rIdent, const OUString& rLa m_xNotebook->SetTabPage(nNewPageId, xPage); m_xNotebook->SetPageName(nNewPageId, rIdent); m_aAddedPages.try_emplace(rIdent, xPage, xGrid); + + if (nPos != -1) + { + unsigned int nPageIndex = static_cast<unsigned int>(nPos); + if (nPageIndex < m_aPages.size()) + m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); + } } int SalInstanceNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); } @@ -2360,6 +2369,13 @@ public: 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); + } } virtual int get_n_pages() const override { return m_xNotebook->GetPageCount(); } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index df717239e62c..b273a7fd47f1 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -6105,6 +6105,13 @@ private: gtk_widget_show(pChild); gtk_widget_show(pTabWidget); + if (nPos != -1) + { + unsigned int nPageIndex = static_cast<unsigned int>(nPos); + if (nPageIndex < m_aPages.size()) + m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); + } + enable_notify_events(); } |