Kaydet (Commit) 6a9b0aac authored tarafından Matteo Casalin's avatar Matteo Casalin

Bail out early

Change-Id: Id2a77996cfe9a9ec755766295141123870b4eaf2
üst cc9057b4
...@@ -750,20 +750,18 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) ...@@ -750,20 +750,18 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
{ {
while( nCntComp < CountCompChg() ) while( nCntComp < CountCompChg() )
{ {
if ( nChg > GetCompStart( nCntComp ) ) if ( nChg <= GetCompStart( nCntComp ) )
nCntComp++;
else
break; break;
nCntComp++;
} }
} }
if ( bAdjustBlock ) if ( bAdjustBlock )
{ {
while( nCntKash < CountKashida() ) while( nCntKash < CountKashida() )
{ {
if ( nChg > GetKashida( nCntKash ) ) if ( nChg <= GetKashida( nCntKash ) )
nCntKash++;
else
break; break;
nCntKash++;
} }
} }
} }
...@@ -888,10 +886,9 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) ...@@ -888,10 +886,9 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL )
while( com::sun::star::i18n::CTLScriptType::CTL_UNKNOWN == nCurrentScriptType || nScriptType == nCurrentScriptType ) while( com::sun::star::i18n::CTLScriptType::CTL_UNKNOWN == nCurrentScriptType || nScriptType == nCurrentScriptType )
{ {
nNextCTLScriptStart = ScriptTypeDetector::endOfCTLScriptType( rTxt, nNextCTLScriptStart ); nNextCTLScriptStart = ScriptTypeDetector::endOfCTLScriptType( rTxt, nNextCTLScriptStart );
if( nNextCTLScriptStart < rTxt.getLength() && nNextCTLScriptStart < nChg ) if( nNextCTLScriptStart >= rTxt.getLength() || nNextCTLScriptStart >= nChg )
nCurrentScriptType = ScriptTypeDetector::getCTLScriptType( rTxt, nNextCTLScriptStart );
else
break; break;
nCurrentScriptType = ScriptTypeDetector::getCTLScriptType( rTxt, nNextCTLScriptStart );
} }
nChg = std::min( nChg, nNextCTLScriptStart ); nChg = std::min( nChg, nNextCTLScriptStart );
} }
...@@ -1698,27 +1695,24 @@ long SwScriptInfo::Compress( sal_Int32* pKernArray, sal_Int32 nIdx, sal_Int32 nL ...@@ -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; nTmpChg = GetCompStart( nCompIdx );
if( ++nCompIdx < nCompCount ) if( nTmpChg > nLen )
{
nTmpChg = GetCompStart( nCompIdx );
if( nTmpChg > nLen )
nTmpChg = nLen;
nCompLen = GetCompLen( nCompIdx );
}
else
nTmpChg = nLen; nTmpChg = nLen;
while( nIdx < nTmpChg ) nCompLen = GetCompLen( nCompIdx );
{ }
nLast = pKernArray[ nI ];
pKernArray[ nI++ ] -= nSub; while( nIdx < nTmpChg )
++nIdx; {
} nLast = pKernArray[ nI ];
pKernArray[ nI++ ] -= nSub;
++nIdx;
} }
else
break;
} while( nIdx < nLen ); } while( nIdx < nLen );
return nSub; return nSub;
} }
...@@ -2015,12 +2009,10 @@ bool SwScriptInfo::MarkKashidasInvalid(sal_Int32 nCnt, sal_Int32* pKashidaPositi ...@@ -2015,12 +2009,10 @@ bool SwScriptInfo::MarkKashidasInvalid(sal_Int32 nCnt, sal_Int32* pKashidaPositi
continue; continue;
} }
if ( pKashidaPositions [nKashidaPosIdx] == GetKashida( nCntKash ) && IsKashidaValid ( nCntKash ) ) if ( pKashidaPositions [nKashidaPosIdx] != GetKashida( nCntKash ) || !IsKashidaValid ( nCntKash ) )
{
MarkKashidaInvalid ( nCntKash );
}
else
return false; // something is wrong return false; // something is wrong
MarkKashidaInvalid ( nCntKash );
nKashidaPosIdx++; nKashidaPosIdx++;
} }
return true; return true;
...@@ -2075,9 +2067,9 @@ SwScriptInfo* SwScriptInfo::GetScriptInfo( const SwTxtNode& rTNd, ...@@ -2075,9 +2067,9 @@ SwScriptInfo* SwScriptInfo::GetScriptInfo( const SwTxtNode& rTNd,
pScriptInfo = (SwScriptInfo*)pLast->GetScriptInfo(); pScriptInfo = (SwScriptInfo*)pLast->GetScriptInfo();
if ( pScriptInfo ) if ( pScriptInfo )
{ {
if ( !bAllowInvalid && COMPLETE_STRING != pScriptInfo->GetInvalidityA() ) if ( bAllowInvalid || COMPLETE_STRING == pScriptInfo->GetInvalidityA() )
pScriptInfo = 0; break;
else break; pScriptInfo = 0;
} }
} }
......
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