[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - sw/source

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 20 08:17:14 UTC 2021


 sw/source/uibase/uiview/viewtab.cxx |   51 +++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 21 deletions(-)

New commits:
commit 549dd4b3849435b4f4331e33fe056fb9832b6c6c
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Thu Aug 19 18:49:59 2021 +0530
Commit:     Pranam Lashkari <lpranam at collabora.com>
CommitDate: Fri Aug 20 10:16:35 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/+/120672
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index d4f34c04d7cb..3da5f0d8ad0d 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -1105,24 +1105,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);
@@ -1135,23 +1141,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);


More information about the Libreoffice-commits mailing list