sw/source/core/text/porlay.cxx | 142 +++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 81 deletions(-)
New commits: commit 59239c29269d69a7dec9b093b7832dd032dec1e8 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Jan 26 19:17:41 2014 +0100 Use += when possible Change-Id: I6dad55d3a397becab18f1159f3e8d84cffd7517b diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index d19515e..29861eb 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -352,7 +352,7 @@ void SwLineLayout::CalcLine( SwTxtFormatter &rLine, SwTxtFormatInfo &rInf ) } const sal_Int32 nPorSttIdx = rInf.GetLineStart() + nLineLength; - nLineLength = nLineLength + pPos->GetLen(); + nLineLength += pPos->GetLen(); AddPrtWidth( pPos->Width() ); // #i3952# @@ -1629,7 +1629,7 @@ long SwScriptInfo::Compress( sal_Int32* pKernArray, sal_Int32 nIdx, sal_Int32 nL sal_Int32 nChg = GetCompStart( nCompIdx ); sal_Int32 nCompLen = GetCompLen( nCompIdx ); sal_uInt16 nI = 0; - nLen = nLen + nIdx; + nLen += nIdx; if( nChg > nIdx ) { @@ -1650,7 +1650,7 @@ long SwScriptInfo::Compress( sal_Int32* pKernArray, sal_Int32 nIdx, sal_Int32 nL #ifdef DBG_UTIL SAL_WARN_IF( nType != CompType( nIdx ), "sw.core", "Gimme the right type!" ); #endif - nCompLen = nCompLen + nIdx; + nCompLen += nIdx; if( nCompLen > nLen ) nCompLen = nLen; @@ -2093,7 +2093,7 @@ sal_Int32 SwParaPortion::GetParLen() const const SwLineLayout *pLay = this; while( pLay ) { - nLen = nLen + pLay->GetLen(); + nLen += pLay->GetLen(); pLay = pLay->GetNext(); } return nLen; commit 6a9b0aac0362f98a11e9a1f33809b43a30b2c7c7 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Jan 26 18:32:50 2014 +0100 Bail out early Change-Id: Id2a77996cfe9a9ec755766295141123870b4eaf2 diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 09445be..d19515e 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -750,20 +750,18 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) { while( nCntComp < CountCompChg() ) { - if ( nChg > GetCompStart( nCntComp ) ) - nCntComp++; - else + if ( nChg <= GetCompStart( nCntComp ) ) break; + nCntComp++; } } if ( bAdjustBlock ) { while( nCntKash < CountKashida() ) { - if ( nChg > GetKashida( nCntKash ) ) - nCntKash++; - else + if ( nChg <= GetKashida( nCntKash ) ) break; + nCntKash++; } } } @@ -888,10 +886,9 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) while( com::sun::star::i18n::CTLScriptType::CTL_UNKNOWN == nCurrentScriptType || nScriptType == nCurrentScriptType ) { nNextCTLScriptStart = ScriptTypeDetector::endOfCTLScriptType( rTxt, nNextCTLScriptStart ); - if( nNextCTLScriptStart < rTxt.getLength() && nNextCTLScriptStart < nChg ) - nCurrentScriptType = ScriptTypeDetector::getCTLScriptType( rTxt, nNextCTLScriptStart ); - else + if( nNextCTLScriptStart >= rTxt.getLength() || nNextCTLScriptStart >= nChg ) break; + nCurrentScriptType = ScriptTypeDetector::getCTLScriptType( rTxt, nNextCTLScriptStart ); } nChg = std::min( nChg, nNextCTLScriptStart ); } @@ -1698,27 +1695,24 @@ long SwScriptInfo::Compress( sal_Int32* pKernArray, sal_Int32 nIdx, sal_Int32 nL } } - if( nIdx < nLen ) + if( nIdx >= nLen ) + break; + + sal_Int32 nTmpChg = nLen; + if( ++nCompIdx < nCompCount ) { - sal_Int32 nTmpChg; - if( ++nCompIdx < nCompCount ) - { - nTmpChg = GetCompStart( nCompIdx ); - if( nTmpChg > nLen ) - nTmpChg = nLen; - nCompLen = GetCompLen( nCompIdx ); - } - else + nTmpChg = GetCompStart( nCompIdx ); + if( nTmpChg > nLen ) nTmpChg = nLen; - while( nIdx < nTmpChg ) - { - nLast = pKernArray[ nI ]; - pKernArray[ nI++ ] -= nSub; - ++nIdx; - } + nCompLen = GetCompLen( nCompIdx ); + } + + while( nIdx < nTmpChg ) + { + nLast = pKernArray[ nI ]; + pKernArray[ nI++ ] -= nSub; + ++nIdx; } - else - break; } while( nIdx < nLen ); return nSub; } @@ -2015,12 +2009,10 @@ bool SwScriptInfo::MarkKashidasInvalid(sal_Int32 nCnt, sal_Int32* pKashidaPositi continue; } - if ( pKashidaPositions [nKashidaPosIdx] == GetKashida( nCntKash ) && IsKashidaValid ( nCntKash ) ) - { - MarkKashidaInvalid ( nCntKash ); - } - else + if ( pKashidaPositions [nKashidaPosIdx] != GetKashida( nCntKash ) || !IsKashidaValid ( nCntKash ) ) return false; // something is wrong + + MarkKashidaInvalid ( nCntKash ); nKashidaPosIdx++; } return true; @@ -2075,9 +2067,9 @@ SwScriptInfo* SwScriptInfo::GetScriptInfo( const SwTxtNode& rTNd, pScriptInfo = (SwScriptInfo*)pLast->GetScriptInfo(); if ( pScriptInfo ) { - if ( !bAllowInvalid && COMPLETE_STRING != pScriptInfo->GetInvalidityA() ) - pScriptInfo = 0; - else break; + if ( bAllowInvalid || COMPLETE_STRING == pScriptInfo->GetInvalidityA() ) + break; + pScriptInfo = 0; } } commit cc9057b42e3222de9a867c9342e522c60a4aa6a6 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Jan 26 18:20:06 2014 +0100 else is not needed after break/return Change-Id: I3c7a90345e9f748668cc2e5305bccae99a45c479 diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 16e94cb..09445be 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -192,11 +192,9 @@ sal_Bool SwLineLayout::Format( SwTxtFormatInfo &rInf ) { if( GetLen() ) return SwTxtPortion::Format( rInf ); - else - { - Height( rInf.GetTxtHeight() ); - return sal_True; - } + + Height( rInf.GetTxtHeight() ); + return sal_True; } /************************************************************************* @@ -1491,7 +1489,7 @@ bool SwScriptInfo::GetBoundsOfHiddenRange( const SwTxtNode& rNode, sal_Int32 nPo if ( nHiddenStart > nPos ) break; - else if ( nHiddenStart <= nPos && nPos < nHiddenEnd ) + if ( nHiddenStart <= nPos && nPos < nHiddenEnd ) { rnStartPos = nHiddenStart; rnEndPos = std::min<sal_Int32>(nHiddenEnd, @@ -1535,7 +1533,7 @@ bool SwScriptInfo::GetBoundsOfHiddenRange( sal_Int32 nPos, sal_Int32& rnStartPos if ( nHiddenStart > nPos ) break; - else if ( nHiddenStart <= nPos && nPos < nHiddenEnd ) + if ( nHiddenStart <= nPos && nPos < nHiddenEnd ) { rnStartPos = nHiddenStart; rnEndPos = nHiddenEnd; @@ -1752,8 +1750,7 @@ sal_Int32 SwScriptInfo::KashidaJustify( sal_Int32* pKernArray, { if ( nStt <= GetKashida( nCntKash ) ) break; - else - ++nCntKash; + ++nCntKash; } const sal_Int32 nEnd = nStt + nLen; @@ -1763,8 +1760,7 @@ sal_Int32 SwScriptInfo::KashidaJustify( sal_Int32* pKernArray, { if ( nEnd <= GetKashida( nCntKashEnd ) ) break; - else - ++nCntKashEnd; + ++nCntKashEnd; } size_t nActualKashCount = nCntKashEnd - nCntKash; @@ -1900,8 +1896,7 @@ bool SwScriptInfo::MarkOrClearKashidaInvalid(sal_Int32 nStt, sal_Int32 nLen, { if ( nStt <= GetKashida( nCntKash ) ) break; - else - nCntKash++; + nCntKash++; } const sal_Int32 nEnd = nStt + nLen; @@ -1910,24 +1905,21 @@ bool SwScriptInfo::MarkOrClearKashidaInvalid(sal_Int32 nStt, sal_Int32 nLen, { if ( nEnd <= GetKashida( nCntKash ) ) break; - else + if(bMark) { - if(bMark) + if ( IsKashidaValid ( nCntKash ) ) { - if ( IsKashidaValid ( nCntKash ) ) - { - MarkKashidaInvalid ( nCntKash ); - --nMarkCount; - if (!nMarkCount) - return true; - } + MarkKashidaInvalid ( nCntKash ); + --nMarkCount; + if (!nMarkCount) + return true; } - else - { - ClearKashidaInvalid ( nCntKash ); - } - nCntKash++; } + else + { + ClearKashidaInvalid ( nCntKash ); + } + nCntKash++; } return false; } @@ -1950,8 +1942,7 @@ sal_Int32 SwScriptInfo::GetKashidaPositions(sal_Int32 nStt, sal_Int32 nLen, { if ( nStt <= GetKashida( nCntKash ) ) break; - else - nCntKash++; + nCntKash++; } const sal_Int32 nEnd = nStt + nLen; @@ -1961,11 +1952,8 @@ sal_Int32 SwScriptInfo::GetKashidaPositions(sal_Int32 nStt, sal_Int32 nLen, { if ( nEnd <= GetKashida( nCntKashEnd ) ) break; - else - { - pKashidaPosition [ nCntKashEnd - nCntKash ] = GetKashida ( nCntKashEnd ); - nCntKashEnd++; - } + pKashidaPosition [ nCntKashEnd - nCntKash ] = GetKashida ( nCntKashEnd ); + nCntKashEnd++; } return nCntKashEnd - nCntKash; } commit 6b21d21066eacfec3ed0e5dc02e6bcdd97807ddf Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Jan 26 17:25:33 2014 +0100 Fix indentation Change-Id: Ic009b2d9cbb4bbd37aad044e63f1b19ae57e649e diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index a3edbf7..16e94cb 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -1761,7 +1761,7 @@ sal_Int32 SwScriptInfo::KashidaJustify( sal_Int32* pKernArray, size_t nCntKashEnd = nCntKash; while ( nCntKashEnd < CountKashida() ) { - if ( nEnd <= GetKashida( nCntKashEnd ) ) + if ( nEnd <= GetKashida( nCntKashEnd ) ) break; else ++nCntKashEnd; @@ -1876,8 +1876,8 @@ void SwScriptInfo::ClearKashidaInvalid(sal_Int32 nKashPos) { if ( aKashidaInvalid [ i ] == nKashPos ) { - aKashidaInvalid.erase ( aKashidaInvalid.begin() + i ); - return; + aKashidaInvalid.erase ( aKashidaInvalid.begin() + i ); + return; } } } @@ -1919,7 +1919,7 @@ bool SwScriptInfo::MarkOrClearKashidaInvalid(sal_Int32 nStt, sal_Int32 nLen, MarkKashidaInvalid ( nCntKash ); --nMarkCount; if (!nMarkCount) - return true; + return true; } } else @@ -1959,7 +1959,7 @@ sal_Int32 SwScriptInfo::GetKashidaPositions(sal_Int32 nStt, sal_Int32 nLen, size_t nCntKashEnd = nCntKash; while ( nCntKashEnd < CountKashida() ) { - if ( nEnd <= GetKashida( nCntKashEnd ) ) + if ( nEnd <= GetKashida( nCntKashEnd ) ) break; else { @@ -2084,14 +2084,14 @@ SwScriptInfo* SwScriptInfo::GetScriptInfo( const SwTxtNode& rTNd, for( SwTxtFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() ) { - pScriptInfo = (SwScriptInfo*)pLast->GetScriptInfo(); - if ( pScriptInfo ) - { - if ( !bAllowInvalid && COMPLETE_STRING != pScriptInfo->GetInvalidityA() ) - pScriptInfo = 0; - else break; - } + pScriptInfo = (SwScriptInfo*)pLast->GetScriptInfo(); + if ( pScriptInfo ) + { + if ( !bAllowInvalid && COMPLETE_STRING != pScriptInfo->GetInvalidityA() ) + pScriptInfo = 0; + else break; } + } return pScriptInfo; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits