summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAttila Szűcs <szucs.attila3@nisz.hu>2021-02-26 21:09:10 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2021-03-24 14:33:26 +0100
commit6e620bdb227e499d6422e680cc63d67079ddd154 (patch)
tree359cff46f6673593e19959cb41f63f0490cd2297
parenttdf#118693: no need to use convertMm100ToTwip() for line shapes anymore (diff)
downloadcore-6e620bdb227e499d6422e680cc63d67079ddd154.tar.gz
core-6e620bdb227e499d6422e680cc63d67079ddd154.zip
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@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.attila3@nisz.hu> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> (cherry picked from commit 8265193e3dd350ce48119c85d09f058aa58a5542) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112429 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--include/vcl/toolkit/treelistbox.hxx1
-rw-r--r--vcl/source/treelist/treelistbox.cxx41
2 files changed, 41 insertions, 1 deletions
diff --git a/include/vcl/toolkit/treelistbox.hxx b/include/vcl/toolkit/treelistbox.hxx
index 199f37c093e8..7f3bf814bd19 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -635,6 +635,7 @@ public:
void InvalidateEntry( SvTreeListEntry* );
SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab);
SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX );
+ std::pair<tools::Long, tools::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 bbafb2a4ba95..ba24d0e6cc73 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -2302,7 +2302,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);
@@ -3033,6 +3033,45 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvTreeListEntry* pEntry, tools::Long nX
return pItemClicked;
}
+std::pair<tools::Long, tools::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;
+
+ tools::Long nRealWidth = pImpl->GetOutputSize().Width();
+ nRealWidth -= GetMapMode().GetOrigin().X();
+
+ SvLBoxTab* pNextTab = nNextItem < nTabCount ? aTabs[nNextItem].get() : nullptr;
+ tools::Long nStart = GetTabPos(pEntry, pTab);
+
+ tools::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)
+ {
+ tools::Long nTabWidth = GetTabPos(pEntry, pNextTab) - nStart;
+ if (nTabWidth < nLen)
+ nLen = nTabWidth;
+ }
+ return std::make_pair(nStart, nLen);
+}
+
tools::Long SvTreeListBox::getPreferredDimensions(std::vector<tools::Long> &rWidths) const
{
tools::Long nHeight = 0;