summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2018-09-21 20:06:03 +0300
committerJustin Luth <justin_luth@sil.org>2018-09-26 18:22:56 +0200
commit32fc5661ba1da1c386e495c7b8141b2848afae47 (patch)
tree6713f7042070c448ebc2d8ac60377341d6bb2215 /sw/source
parent3bb54d3a046feabaa35df39b7a753c385c3c4101 (diff)
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@sil.org>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/docnode/ndtbl1.cxx21
1 files changed, 9 insertions, 12 deletions
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();