include/vcl/builder.hxx | 1 + vcl/source/window/builder.cxx | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-)
New commits: commit fd27f399b41bd5a2017026ce582eae75f7678522 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Feb 19 16:55:18 2026 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Feb 20 12:01:03 2026 +0100 If the treeview has a header or multiple columns it has to be a [tree]grid tree/listbox don't have headers, so reshuffle to only allow those for the single column and headerless case. Change-Id: I49cac527f22617847a7227979158384f3b7b4247 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199748 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 9c6299997426..6cf877fb3c09 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -223,6 +223,7 @@ private: sal_uInt16 m_nTreeViewExpanders; sal_uInt16 m_nTreeViewColumnCount; bool m_bTreeViewSeenTextInColumn; + bool m_bTreeHasHeader; VclParserState(); }; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 7d961167d5ca..2f74659aeffc 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1832,6 +1832,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OUString m_pVclParserState->m_nTreeViewExpanders = 0; m_pVclParserState->m_nTreeViewColumnCount = 0; m_pVclParserState->m_bTreeViewSeenTextInColumn = false; + m_pVclParserState->m_bTreeHasHeader = false; if (!isLegacy()) { @@ -1866,8 +1867,8 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OUString else { VclPtr<SvTabListBox> xBox; - bool bHeadersVisible = extractHeadersVisible(rMap); - if (bHeadersVisible) + m_pVclParserState->m_bTreeHasHeader = extractHeadersVisible(rMap); + if (m_pVclParserState->m_bTreeHasHeader) { VclPtr<VclVBox> xContainer = VclPtr<VclVBox>::Create(pRealParent); OUString containerid(id + "-container"); @@ -2629,15 +2630,22 @@ void VclBuilder::tweakInsertedChild(vcl::Window *pParent, vcl::Window* pCurrentC const bool bTree(pTabListBox->GetStyle() & (WB_HASBUTTONS | WB_HASBUTTONSATROOT)); const sal_uInt16 nRealColumns = m_pVclParserState->m_nTreeViewRenderers - m_pVclParserState->m_nTreeViewExpanders; + const bool bHasHeader = m_pVclParserState->m_bTreeHasHeader; const bool bMultiColumn = nRealColumns > 1; - if (bTree && bMultiColumn) - pTabListBox->SetRole(SvTabListBoxRole::TreeGrid); - else if (bTree) - pTabListBox->SetRole(SvTabListBoxRole::Tree); - else if (bMultiColumn) - pTabListBox->SetRole(SvTabListBoxRole::Grid); + if (bHasHeader || bMultiColumn) + { + if (bTree) + pTabListBox->SetRole(SvTabListBoxRole::TreeGrid); + else + pTabListBox->SetRole(SvTabListBoxRole::Grid); + } else - pTabListBox->SetRole(SvTabListBoxRole::ListBox); + { + if (bTree) + pTabListBox->SetRole(SvTabListBoxRole::Tree); + else + pTabListBox->SetRole(SvTabListBoxRole::ListBox); + } } //Select the first page if it's a notebook @@ -4054,6 +4062,7 @@ VclBuilder::VclParserState::VclParserState() , m_nTreeViewExpanders(0) , m_nTreeViewColumnCount(0) , m_bTreeViewSeenTextInColumn(false) + , m_bTreeHasHeader(false) {} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
