diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-09-22 22:29:12 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2014-10-04 16:04:02 +0200 |
commit | 44c9ba91ebe40223e5c1fa1735a8cc1d9adb0935 (patch) | |
tree | 348ad377df910e9b88addfa655a59b9b4377c789 /sw | |
parent | 1c088d2160acd7f484d5f62457c6f82d0189785c (diff) |
Test loop invariant outside of the loop itself
Change-Id: I203937cb68c805a8692926aa1c9189ff0dd2c54c
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/table/swtable.cxx | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 6799863a2c2d..196abd9227f0 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -429,46 +429,47 @@ static void lcl_SortedTabColInsert( SwTabCols &rToFill, const SwTableBox *pBox, { const long nWish = pTabFmt->GetFrmSize().GetWidth(); OSL_ENSURE(nWish, "weird <= 0 width frmfrm"); - const long nAct = rToFill.GetRight() - rToFill.GetLeft(); // +1 why? // The value for the left edge of the box is calculated from the // widths of the previous boxes. sal_uInt16 nPos = 0; - sal_uInt16 nSum = 0; sal_uInt16 nLeftMin = 0; sal_uInt16 nRightMax = 0; - const SwTableBox *pCur = pBox; - const SwTableLine *pLine = pBox->GetUpper(); - while ( pLine ) + if (nWish != 0) //fdo#33012 0 width frmfmt { - const SwTableBoxes &rBoxes = pLine->GetTabBoxes(); - for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i ) - { - SwTwips nWidth = rBoxes[i]->GetFrmFmt()->GetFrmSize().GetWidth(); - nSum = (sal_uInt16)(nSum + nWidth); - sal_uInt64 nTmp = nSum; - nTmp *= nAct; - - if (nWish == 0) //fdo#33012 0 width frmfmt - continue; + sal_uInt16 nSum = 0; + const SwTableBox *pCur = pBox; + const SwTableLine *pLine = pBox->GetUpper(); + const long nAct = rToFill.GetRight() - rToFill.GetLeft(); // +1 why? - nTmp /= nWish; - if (rBoxes[i] != pCur) - { - if ( pLine == pBox->GetUpper() || 0 == nLeftMin ) - nLeftMin = (sal_uInt16)(nTmp - nPos); - nPos = (sal_uInt16)nTmp; - } - else + while ( pLine ) + { + const SwTableBoxes &rBoxes = pLine->GetTabBoxes(); + for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i ) { - nSum = (sal_uInt16)(nSum - nWidth); - if ( 0 == nRightMax ) - nRightMax = (sal_uInt16)(nTmp - nPos); - break; + SwTwips nWidth = rBoxes[i]->GetFrmFmt()->GetFrmSize().GetWidth(); + nSum = (sal_uInt16)(nSum + nWidth); + sal_uInt64 nTmp = nSum; + nTmp *= nAct; + nTmp /= nWish; + + if (rBoxes[i] != pCur) + { + if ( pLine == pBox->GetUpper() || 0 == nLeftMin ) + nLeftMin = (sal_uInt16)(nTmp - nPos); + nPos = (sal_uInt16)nTmp; + } + else + { + nSum = (sal_uInt16)(nSum - nWidth); + if ( 0 == nRightMax ) + nRightMax = (sal_uInt16)(nTmp - nPos); + break; + } } + pCur = pLine->GetUpper(); + pLine = pCur ? pCur->GetUpper() : 0; } - pCur = pLine->GetUpper(); - pLine = pCur ? pCur->GetUpper() : 0; } bool bInsert = !bRefreshHidden; |