sw/source/core/docnode/ndtbl1.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
New commits: commit 8e5fb64aa9f80941ae1336955f1fe63281d41acc Author: Justin Luth <justin_l...@sil.org> AuthorDate: Tue Oct 5 15:32:06 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Oct 7 13:01:16 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_l...@sil.org> (cherry picked from commit 7e201916169aca254c0824fb71ed83ca69f4adce) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123156 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index 06dc701883ad..b0fb85487a1e 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -1612,15 +1612,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 );