From 1d988778095ecbe84f1a1002511377d0708b3443 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 15 Nov 2018 16:35:31 +0000 Subject: Resolves: tdf#121432 don't insert an extra page when parent is tabcontrol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit but the new child is a toplevel widget Change-Id: Ib794e076e2626485b9d9231daf914db6dd9b5e2f Reviewed-on: https://gerrit.libreoffice.org/63431 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/source/window/builder.cxx | 52 +++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'vcl') diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 5f14f9cc0dc5..95a1fb996cd4 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1546,30 +1546,34 @@ VclPtr VclBuilder::makeObject(vcl::Window *pParent, const OString & if (pParent && pParent->GetType() == WindowType::TABCONTROL) { - //We have to add a page - - //make default pageid == position - TabControl *pTabControl = static_cast(pParent); - sal_uInt16 nNewPageCount = pTabControl->GetPageCount()+1; - sal_uInt16 nNewPageId = nNewPageCount; - pTabControl->InsertPage(nNewPageId, OUString()); - pTabControl->SetCurPageId(nNewPageId); - SAL_WARN_IF(bIsPlaceHolder, "vcl.layout", "we should have no placeholders for tabpages"); - if (!bIsPlaceHolder) - { - VclPtrInstance pPage(pTabControl); - pPage->Show(); - - //Make up a name for it - OString sTabPageId = get_by_window(pParent) + - OString("-page") + - OString::number(nNewPageCount); - m_aChildren.emplace_back(sTabPageId, pPage, false); - pPage->SetHelpId(m_sHelpRoot + sTabPageId); - - pParent = pPage; - - pTabControl->SetTabPage(nNewPageId, pPage); + bool bTopLevel(name == "GtkDialog" || name == "GtkMessageDialog" || + name == "GtkWindow" || name == "GtkPopover"); + if (!bTopLevel) + { + //We have to add a page + //make default pageid == position + TabControl *pTabControl = static_cast(pParent); + sal_uInt16 nNewPageCount = pTabControl->GetPageCount()+1; + sal_uInt16 nNewPageId = nNewPageCount; + pTabControl->InsertPage(nNewPageId, OUString()); + pTabControl->SetCurPageId(nNewPageId); + SAL_WARN_IF(bIsPlaceHolder, "vcl.layout", "we should have no placeholders for tabpages"); + if (!bIsPlaceHolder) + { + VclPtrInstance pPage(pTabControl); + pPage->Show(); + + //Make up a name for it + OString sTabPageId = get_by_window(pParent) + + OString("-page") + + OString::number(nNewPageCount); + m_aChildren.emplace_back(sTabPageId, pPage, false); + pPage->SetHelpId(m_sHelpRoot + sTabPageId); + + pParent = pPage; + + pTabControl->SetTabPage(nNewPageId, pPage); + } } } -- cgit