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 <jluth@mail.com>
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 35f4b8e..ee030b5 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.