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

New commits:
commit 97f6fc9f752bc8bb34f2793442922ead59008757
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Sat Jul 16 06:32:04 2022 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Sat Jul 16 16:01:32 2022 +0200

    tdf#64242 sw table: improve Optimal Column Width function logic
    
    This affects both Writer's minimze and optimize table functions.
    
    Instead of basing equal-width on the current table size,
    allow each column to have access to an equal portion
    of the full table size (in case that it can grow wider).
    
    This will help to maintain symmetry - one of the two primary
    intentions of these functions.
    
    [This is irrelevant for Draw - since the table size does not grow.]
    
    Change-Id: I0e8c499b66c538f06df52eb74374bad3b690e8d2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137120
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/source/core/docnode/ndtbl1.cxx 
b/sw/source/core/docnode/ndtbl1.cxx
index 35f4b8e7e943..ee030b5f1d4c 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1645,7 +1645,8 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor,
     // only afterwards.
     // The first column's desired width would be discarded as it would cause
     // the Table's width to exceed the maximum width.
-    const sal_uInt16 nEqualWidth = (aTabCols.GetRight() - aTabCols.GetLeft()) 
/ (aTabCols.Count() + 1);
+    const tools::Long nMaxRight = std::max(aTabCols.GetRightMax(), nOldRight);
+    const sal_uInt16 nEqualWidth = (nMaxRight - aTabCols.GetLeft()) / 
(aTabCols.Count() + 1);
     const sal_Int16 nTablePadding = nSelectedWidth - fTotalWish;
     for ( int k = 0; k < 2; ++k )
     {
@@ -1678,7 +1679,6 @@ 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 (or is already) too wide,
                 // restrict the column growth to the allowed maximum.

Reply via email to