sw/source/uibase/uiview/viewtab.cxx | 51 +++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 21 deletions(-)
New commits: commit 3527b4e4cfa23c3459c53b091ddadd93c426d0c3 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Thu Aug 19 18:49:59 2021 +0530 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Aug 23 08:58:23 2021 +0200 LOK make sure single row/column table are resizable First row/column are treated as heading in the table, that's why need some special case handling for it First row/column are not counted in regular row/column Change-Id: If67b759911ea87f2b166a69243b85e98d90c4d22 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120725 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index f003d050d479..bce40514f752 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -1106,24 +1106,30 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) if (sType == "column-left") { - auto & rEntry = aTabCols.GetEntry(0); - tools::Long nNewPosition = aTabCols.GetLeft() + tools::Long(nOffset); - tools::Long nPosition = std::min(nNewPosition, rEntry.nPos - constDistanceOffset); - aTabCols.SetLeft(nPosition); + tools::Long nNewPosition = aTabCols.GetLeft() + nOffset; + if(aTabCols.Count() > 0) + { + auto & rEntry = aTabCols.GetEntry(0); + nNewPosition = std::min(nNewPosition, rEntry.nPos - constDistanceOffset); + } + aTabCols.SetLeft(nNewPosition); } else if (sType == "column-right") { - auto & rEntry = aTabCols.GetEntry(aTabCols.Count() - 1); - tools::Long nNewPosition = aTabCols.GetRight() + tools::Long(nOffset); - tools::Long nPosition = std::max(nNewPosition, rEntry.nPos + constDistanceOffset); - aTabCols.SetRight(nPosition); + tools::Long nNewPosition = aTabCols.GetRight() + nOffset; + if(aTabCols.Count() > 0) + { + auto & rEntry = aTabCols.GetEntry(aTabCols.Count() - 1); + nNewPosition = std::max(nNewPosition, rEntry.nPos + constDistanceOffset); + } + aTabCols.SetRight(nNewPosition); } else if (sType == "column-middle" && nIndex < aTabCols.Count()) { auto & rEntry = aTabCols.GetEntry(nIndex); - tools::Long nNewPosition = rEntry.nPos + tools::Long(nOffset); - tools::Long nPosition = std::clamp(nNewPosition, rEntry.nMin, rEntry.nMax - constDistanceOffset); - rEntry.nPos = nPosition; + tools::Long nNewPosition = rEntry.nPos + nOffset; + nNewPosition = std::clamp(nNewPosition, rEntry.nMin, rEntry.nMax - constDistanceOffset); + rEntry.nPos = nNewPosition; } rSh.SetTabCols(aTabCols, false); @@ -1136,23 +1142,26 @@ void SwView::ExecTabWin( SfxRequest const & rReq ) if (sType == "row-left") { auto & rEntry = aTabRows.GetEntry(0); - tools::Long nNewPosition = aTabRows.GetLeft() + tools::Long(nOffset); - tools::Long nPosition = std::min(nNewPosition, rEntry.nPos - constDistanceOffset); - aTabRows.SetLeft(nPosition); + tools::Long nNewPosition = aTabRows.GetLeft() + nOffset; + nNewPosition = std::min(nNewPosition, rEntry.nPos - constDistanceOffset); + aTabRows.SetLeft(nNewPosition); } else if (sType == "row-right") { - auto & rEntry = aTabRows.GetEntry(aTabRows.Count() - 1); - tools::Long nNewPosition = aTabRows.GetRight() + tools::Long(nOffset); - tools::Long nPosition = std::max(nNewPosition, rEntry.nPos + constDistanceOffset); - aTabRows.SetRight(nPosition); + tools::Long nNewPosition = aTabRows.GetRight() + nOffset; + if(aTabRows.Count() > 0) + { + auto & rEntry = aTabRows.GetEntry(aTabRows.Count() - 1); + nNewPosition = std::max(nNewPosition, rEntry.nPos + constDistanceOffset); + } + aTabRows.SetRight(nNewPosition); } else if (sType == "row-middle" && nIndex < aTabRows.Count()) { auto & rEntry = aTabRows.GetEntry(nIndex); - tools::Long nNewPosition = rEntry.nPos + tools::Long(nOffset); - tools::Long nPosition = std::clamp(nNewPosition, rEntry.nMin, rEntry.nMax - constDistanceOffset); - rEntry.nPos = nPosition; + tools::Long nNewPosition = rEntry.nPos + nOffset; + nNewPosition = std::clamp(nNewPosition, rEntry.nMin, rEntry.nMax - constDistanceOffset); + rEntry.nPos = nNewPosition; } rSh.SetTabRows(aTabRows, false);