[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Sep 26 16:23:19 UTC 2018
sw/source/core/docnode/ndtbl1.cxx | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
New commits:
commit 32fc5661ba1da1c386e495c7b8141b2848afae47
Author: Justin Luth <justin_luth at sil.org>
AuthorDate: Fri Sep 21 20:06:03 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Wed Sep 26 18:22:56 2018 +0200
sw AdjustCellWidth rewrite for clarity
This section has absolutely nothing to do with the previous
idea of a "wish" width. It is dealing with actual, current
cell width regardless of content.
Change-Id: I53b615cb7ea61554ff3f83d253b97b0e1f38d547
Reviewed-on: https://gerrit.libreoffice.org/60904
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 a7568a0991f0..553a66407773 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1507,30 +1507,27 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor, bool bBalance )
pEnd = pEnd->GetUpper();
::lcl_CalcColValues( aMins, aTabCols, pStart, pEnd, false );
+ sal_uInt16 nSelectedWidth = 0, nCols = 0;
if( bBalance )
{
- // All Columns, which are now selected, have a desired value.
- // We add up the current values, divide the result by their
- // count and get a desired value for balancing.
- sal_uInt16 nWish = 0, nCnt = 0;
+ // Find the combined size of the selected columns, and distribute evenly
for ( size_t i = 0; i <= aTabCols.Count(); ++i )
{
- int nDiff = aWish[i];
- if ( nDiff )
+ if ( aWish[i] )
{
if ( i == 0 )
- nWish += aTabCols[i] - aTabCols.GetLeft();
+ nSelectedWidth += aTabCols[i] - aTabCols.GetLeft();
else if ( i == aTabCols.Count() )
- nWish += aTabCols.GetRight() - aTabCols[i-1];
+ nSelectedWidth += aTabCols.GetRight() - aTabCols[i-1];
else
- nWish += aTabCols[i] - aTabCols[i-1];
- ++nCnt;
+ nSelectedWidth += aTabCols[i] - aTabCols[i-1];
+ ++nCols;
}
}
- nWish /= nCnt;
+ const sal_uInt16 nEqualWidth = nSelectedWidth / nCols;
for (sal_uInt16 & rn : aWish)
if ( rn )
- rn = nWish;
+ rn = nEqualWidth;
}
const long nOldRight = aTabCols.GetRight();
More information about the Libreoffice-commits
mailing list