[Libreoffice-commits] core.git: sw/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 7 07:01:36 UTC 2021


 sw/source/core/docnode/ndtbl1.cxx |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit 7e201916169aca254c0824fb71ed83ca69f4adce
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Tue Oct 5 15:32:06 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Oct 7 09:01:05 2021 +0200

    tdf#144317 sw table minimize: fix signed->unsigned table growth
    
    In the case where the table was already rather oversized,
    the minimize and optimize functions would attempt to shrink
    the table to the maximum recommended size. But that was done
    without checking whether that would result in a negative
    position for the column boundary. (At least that is what I
    think was happening. This code is a bit too cryptic...)
    
    I tried to make a unit test, but the table size didn't
    grow or shrink as I expected it to (and as it seems to
    when the command is run by hand...)
    An F12 with SW_DEBUG=true ./instdir/program/soffice
    shows that the cell gains a huge width, but that didn't
    show up either in a parseDump, even after a
    Scheduler::ProcessEventsToIdle(). So I gave up (again).
    
    Change-Id: Id4b9defae718694aa76a3db01f6b02ead5f98e6b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123108
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>

diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 8a0455eabcfe..98b7b9401800 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1640,15 +1640,18 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor,
                     nDiff -= aTabCols[i] - aTabCols[i-1];
 
                 tools::Long nTabRight = aTabCols.GetRight() + nDiff;
+                const tools::Long nMaxRight = std::max(aTabCols.GetRightMax(), nOldRight);
 
-                // If the Table would become too wide, we restrict the
-                // adjusted amount to the allowed maximum.
-                if ( !bBalance && nTabRight > aTabCols.GetRightMax() )
+                // If the Table would become (or is already) too wide,
+                // restrict the column growth to the allowed maximum.
+                if (!bBalance && nTabRight > nMaxRight)
                 {
-                    const tools::Long nTmpD = nTabRight - aTabCols.GetRightMax();
+                    const tools::Long nTmpD = nTabRight - nMaxRight;
                     nDiff     -= nTmpD;
                     nTabRight -= nTmpD;
                 }
+
+                // all the remaining columns need to be shifted by the same amount
                 for ( size_t i2 = i; i2 < aTabCols.Count(); ++i2 )
                     aTabCols[i2] += nDiff;
                 aTabCols.SetRight( nTabRight );


More information about the Libreoffice-commits mailing list