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

Simplify

Change-Id: Iabfbe854f97b92127f1118b0982be39c4d0a2b8b
üst 007edeb7
...@@ -566,9 +566,9 @@ static SwTxtNode* lcl_FindOutlineName( const SwOutlineNodes& rOutlNds, const OUS ...@@ -566,9 +566,9 @@ static SwTxtNode* lcl_FindOutlineName( const SwOutlineNodes& rOutlNds, const OUS
bool bExact ) bool bExact )
{ {
SwTxtNode* pSavedNode = nullptr; SwTxtNode* pSavedNode = nullptr;
for( SwOutlineNodes::size_type n = 0; n < rOutlNds.size(); ++n ) for( auto pOutlNd : rOutlNds )
{ {
SwTxtNode* pTxtNd = rOutlNds[ n ]->GetTxtNode(); SwTxtNode* pTxtNd = pOutlNd->GetTxtNode();
const OUString sTxt( pTxtNd->GetExpandTxt() ); const OUString sTxt( pTxtNd->GetExpandTxt() );
if (sTxt.startsWith(rName)) if (sTxt.startsWith(rName))
{ {
...@@ -601,22 +601,25 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& ...@@ -601,22 +601,25 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString&
sal_uInt16 nLevelVal[ MAXLEVEL ]; // numbers of all levels sal_uInt16 nLevelVal[ MAXLEVEL ]; // numbers of all levels
memset( nLevelVal, 0, MAXLEVEL * sizeof( nLevelVal[0] )); memset( nLevelVal, 0, MAXLEVEL * sizeof( nLevelVal[0] ));
sal_uInt8 nLevel = 0; int nLevel = 0;
OUString sName( rName ); OUString sName( rName );
while( -1 != nPos ) while( -1 != nPos )
{ {
sal_uInt16 nVal = 0; sal_uInt16 nVal = 0;
sal_Unicode c;
for( sal_Int32 n = 0; n < sNum.getLength(); ++n ) for( sal_Int32 n = 0; n < sNum.getLength(); ++n )
if( '0' <= ( c = sNum[ n ]) && c <= '9' ) {
const sal_Unicode c {sNum[ n ]};
if( '0' <= c && c <= '9' )
{ {
nVal *= 10; nVal += c - '0'; nVal *= 10;
nVal += c - '0';
} }
else if( nLevel ) else if( nLevel )
break; // "almost" valid number break; // "almost" valid number
else else
return nullptr; // invalid number! return nullptr; // invalid number!
}
if( MAXLEVEL > nLevel ) if( MAXLEVEL > nLevel )
nLevelVal[ nLevel++ ] = nVal; nLevelVal[ nLevel++ ] = nVal;
...@@ -626,7 +629,7 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& ...@@ -626,7 +629,7 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString&
sNum = sName.getToken( 0, '.', nPos ); sNum = sName.getToken( 0, '.', nPos );
// #i4533# without this check all parts delimited by a dot are treated as outline numbers // #i4533# without this check all parts delimited by a dot are treated as outline numbers
if(!comphelper::string::isdigitAsciiString(sNum)) if(!comphelper::string::isdigitAsciiString(sNum))
nPos = -1; break;
} }
rName = sName; // that's the follow-up text rName = sName; // that's the follow-up text
...@@ -637,32 +640,26 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& ...@@ -637,32 +640,26 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString&
if( rOutlNds.empty() ) if( rOutlNds.empty() )
return nullptr; return nullptr;
SwTxtNode* pNd;
nPos = 0;
// search in the existing outline nodes for the required outline num array // search in the existing outline nodes for the required outline num array
for( ; nPos < (sal_Int32) rOutlNds.size(); ++nPos ) for( auto pOutlNd : rOutlNds )
{ {
pNd = rOutlNds[ nPos ]->GetTxtNode(); SwTxtNode* pNd = pOutlNd->GetTxtNode();
const int nLvl = pNd->GetAttrOutlineLevel()-1; if ( pNd->GetAttrOutlineLevel() == nLevel )
if( nLvl == nLevel - 1)
{ {
// #i51089#, #i68289# // #i51089#, #i68289#
// Assure, that text node has the correct numbering level. Otherwise, // Assure, that text node has the correct numbering level. Otherwise,
// its number vector will not fit to the searched level. // its number vector will not fit to the searched level.
if ( pNd->GetNum() && if ( pNd->GetNum() && pNd->GetActualListLevel() == nLevel - 1 )
pNd->GetActualListLevel() == ( nLevel - 1 ) )
{ {
const SwNodeNum & rNdNum = *(pNd->GetNum()); const SwNodeNum & rNdNum = *(pNd->GetNum());
SwNumberTree::tNumberVector aLevelVal = rNdNum.GetNumberVector(); SwNumberTree::tNumberVector aLevelVal = rNdNum.GetNumberVector();
// now compare with the one searched for // now compare with the one searched for
bool bEqual = true; for( int n = 0; n < nLevel; ++n )
for( sal_uInt8 n = 0; (n < nLevel) && bEqual; ++n )
{
bEqual = aLevelVal[n] == nLevelVal[n];
}
if(bEqual)
{ {
break; if ( aLevelVal[n] == nLevelVal[n] )
{
return pNd;
}
} }
} }
else else
...@@ -676,10 +673,8 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString& ...@@ -676,10 +673,8 @@ static SwTxtNode* lcl_FindOutlineNum( const SwOutlineNodes& rOutlNds, OUString&
} }
} }
} }
if( nPos >= (sal_Int32) rOutlNds.size() )
return nullptr;
return rOutlNds[ nPos ]->GetTxtNode(); return nullptr;
} }
// Add this bullet point: // Add this bullet point:
......
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