Kaydet (Commit) 32fc5661 authored tarafından Justin Luth's avatar Justin Luth

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: 's avatarJustin Luth <justin_luth@sil.org>
üst 3bb54d3a
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment