include/vcl/treelistbox.hxx | 1 vcl/source/treelist/treelistbox.cxx | 41 +++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-)
New commits: commit 23dc7994f0219db282e32bf77f36315174c98905 Author: Attila Szűcs <szucs.atti...@nisz.hu> AuthorDate: Fri Feb 26 21:09:10 2021 +0100 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Thu Apr 29 10:50:37 2021 +0200 tdf#140136 sc: fix tree list expansion in AutoFilter Now clicking on +/- buttons (i.e. before the checkbox) only expands/collapses the tree without toggling the associated checkboxes, using the new GetItemPos() to get the position (and width) of the checkbox in the actual list item. Regression from commit 2471d6f44c7e8ecbe86a90eeb593b899a08a7408 "tdf#116675 vcl tree list: toggle by label click (e.g. in AutoFilter)". Note: Use generic VCL plugin to test it on Linux: SAL_USE_VCLPLUGIN=gen instdir/program/soffice Co-authored-by: Tibor Nagy (NISZ) Change-Id: Iceb17bc9b235d297c313361429ee89f04d809e96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111668 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 216f32464ccb0f096e5fdf77f82baf30ae7bab5f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112308 Tested-by: Jenkins Reviewed-by: Attila Szűcs <szucs.atti...@nisz.hu> Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114840 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/include/vcl/treelistbox.hxx b/include/vcl/treelistbox.hxx index 288314af8232..2da5fa5f41b2 100644 --- a/include/vcl/treelistbox.hxx +++ b/include/vcl/treelistbox.hxx @@ -673,6 +673,7 @@ public: void InvalidateEntry( SvTreeListEntry* ); SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab); SvLBoxItem* GetItem( SvTreeListEntry*, long nX ); + std::pair<long, long> GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx); void SetDragDropMode( DragDropMode ); void SetSelectionMode( SelectionMode ); diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index bbece8b674d9..6680f4828e0b 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -2343,7 +2343,7 @@ void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt ) { SvLBoxButton* pItemCheckBox = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button)); - if (pItemCheckBox) + if (pItemCheckBox && GetItemPos(pEntry, 0).first < aPnt.X() - GetMapMode().GetOrigin().X()) { pItemCheckBox->ClickHdl(pEntry); InvalidateEntry(pEntry); @@ -3085,6 +3085,45 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, long nX, return pItemClicked; } +std::pair<long, long> SvTreeListBox::GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx) +{ + sal_uInt16 nTabCount = aTabs.size(); + sal_uInt16 nItemCount = pEntry->ItemCount(); + if (nTabIdx >= nItemCount || nTabIdx >= nTabCount) + return std::make_pair(-1, -1); + + SvLBoxTab* pTab = aTabs.front().get(); + SvLBoxItem* pItem = &pEntry->GetItem(nTabIdx); + sal_uInt16 nNextItem = nTabIdx + 1; + + long nRealWidth = pImpl->GetOutputSize().Width(); + nRealWidth -= GetMapMode().GetOrigin().X(); + + SvLBoxTab* pNextTab = nNextItem < nTabCount ? aTabs[nNextItem].get() : nullptr; + long nStart = GetTabPos(pEntry, pTab); + + long nNextTabPos; + if (pNextTab) + nNextTabPos = GetTabPos(pEntry, pNextTab); + else + { + nNextTabPos = nRealWidth; + if (nStart > nRealWidth) + nNextTabPos += 50; + } + + auto nItemWidth(pItem->GetWidth(this, pEntry)); + nStart += pTab->CalcOffset(nItemWidth, nNextTabPos - nStart); + auto nLen = nItemWidth; + if (pNextTab) + { + long nTabWidth = GetTabPos(pEntry, pNextTab) - nStart; + if (nTabWidth < nLen) + nLen = nTabWidth; + } + return std::make_pair(nStart, nLen); +} + long SvTreeListBox::getPreferredDimensions(std::vector<long> &rWidths) const { long nHeight = 0; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits