cid#1635776 Overflowed constant

there is intended to be no logic change here, just rearrangement
and acknowledgement that SwOutlineNodesInline::Seek_Entry always
sets nEndPosInline to some value.

Change-Id: I10d694e20c8619ae297a61f612590556c9a9effa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178037
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Caolán McNamara 2024-12-06 15:24:36 +00:00
parent e92db94e19
commit 5528f9c8b8

View file

@ -1366,7 +1366,6 @@ SwOutlineNodes::size_type SwCursorShell::GetOutlinePos(sal_uInt8 nLevel, SwPaM*
void SwCursorShell::MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, void SwCursorShell::MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos,
bool bWithChildren , bool bKillPams, SwOutlineNodesInline* pOutlNdsInline) bool bWithChildren , bool bKillPams, SwOutlineNodesInline* pOutlNdsInline)
{ {
SwOutlineNodesInline::size_type nEndPosInline = SwOutlineNodesInline::npos;
const SwNodes& rNds = GetDoc()->GetNodes(); const SwNodes& rNds = GetDoc()->GetNodes();
const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds(); const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
if( rOutlNds.empty() ) if( rOutlNds.empty() )
@ -1384,47 +1383,55 @@ void SwCursorShell::MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineN
SwNode* pSttNd = rOutlNds[ nSttPos ]; SwNode* pSttNd = rOutlNds[ nSttPos ];
SwNode* pEndNd = rOutlNds[ nEndPos ]; SwNode* pEndNd = rOutlNds[ nEndPos ];
if( pOutlNdsInline ) if (pOutlNdsInline)
{ {
pSttNd = const_cast<SwNode*>(SwOutlineNodes::GetRootNode(pSttNd)); pSttNd = const_cast<SwNode*>(SwOutlineNodes::GetRootNode(pSttNd));
SwOutlineNodesInline::size_type nEndPosInline;
pOutlNdsInline->Seek_Entry( pEndNd, &nEndPosInline ); pOutlNdsInline->Seek_Entry( pEndNd, &nEndPosInline );
} assert(nEndPosInline != SwOutlineNodesInline::npos && "always sets some number <= pOutlNdsInline->size()");
if( bWithChildren && !pOutlNdsInline ) // headings in flys
{ if (bWithChildren)
const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
for( ++nEndPos; nEndPos < rOutlNds.size(); ++nEndPos )
{ {
const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel() - 1;
for( ++nEndPosInline; nEndPosInline < pOutlNdsInline->size(); ++nEndPosInline )
{
pEndNd = (*pOutlNdsInline)[ nEndPosInline ];
const int nNxtLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
if( nNxtLevel <= nLevel )
break; // EndPos is now on the next one
}
// set anchor node of the fly node
if ( nEndPosInline < pOutlNdsInline->size() )
pEndNd = const_cast<SwNode*>(SwOutlineNodes::GetRootNode(pEndNd));
}
else if (++nEndPosInline < pOutlNdsInline->size())
pEndNd = const_cast<SwNode*>(SwOutlineNodes::GetRootNode((*pOutlNdsInline)[nEndPosInline]));
if (nEndPosInline == pOutlNdsInline->size()) // no end found
pEndNd = &rNds.GetEndOfContent();
}
else
{
if (bWithChildren)
{
const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
for( ++nEndPos; nEndPos < rOutlNds.size(); ++nEndPos )
{
pEndNd = rOutlNds[ nEndPos ];
const int nNxtLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
if( nNxtLevel <= nLevel )
break; // EndPos is now on the next one
}
}
// if without children then set onto next one
else if (++nEndPos < rOutlNds.size())
pEndNd = rOutlNds[ nEndPos ]; pEndNd = rOutlNds[ nEndPos ];
const int nNxtLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
if( nNxtLevel <= nLevel )
break; // EndPos is now on the next one
}
}
// headings in flys
else if( bWithChildren && pOutlNdsInline )
{
const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel() - 1;
for( ++nEndPosInline; nEndPosInline < pOutlNdsInline->size(); ++nEndPosInline )
{
pEndNd = (*pOutlNdsInline)[ nEndPosInline ];
const int nNxtLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1;
if( nNxtLevel <= nLevel )
break; // EndPos is now on the next one
}
// set anchor node of the fly node
if ( nEndPosInline < pOutlNdsInline->size() )
pEndNd = const_cast<SwNode*>(SwOutlineNodes::GetRootNode(pEndNd));
}
// if without children then set onto next one
else if( !pOutlNdsInline && ++nEndPos < rOutlNds.size() )
pEndNd = rOutlNds[ nEndPos ];
else if( pOutlNdsInline && ++nEndPosInline < pOutlNdsInline->size() )
pEndNd = const_cast<SwNode*>(SwOutlineNodes::GetRootNode((*pOutlNdsInline)[nEndPosInline]));
if( ( pOutlNdsInline && nEndPosInline == pOutlNdsInline->size() ) || if (nEndPos == rOutlNds.size()) // no end found
( !pOutlNdsInline && nEndPos == rOutlNds.size() ) ) // no end found pEndNd = &rNds.GetEndOfContent();
pEndNd = &rNds.GetEndOfContent(); }
if( bKillPams ) if( bKillPams )
KillPams(); KillPams();