diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 910a62d05bbc..35ca30cf5bb8 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1366,7 +1366,6 @@ SwOutlineNodes::size_type SwCursorShell::GetOutlinePos(sal_uInt8 nLevel, SwPaM* void SwCursorShell::MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren , bool bKillPams, SwOutlineNodesInline* pOutlNdsInline) { - SwOutlineNodesInline::size_type nEndPosInline = SwOutlineNodesInline::npos; const SwNodes& rNds = GetDoc()->GetNodes(); const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds(); if( rOutlNds.empty() ) @@ -1384,47 +1383,55 @@ void SwCursorShell::MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineN SwNode* pSttNd = rOutlNds[ nSttPos ]; SwNode* pEndNd = rOutlNds[ nEndPos ]; - if( pOutlNdsInline ) + if (pOutlNdsInline) { pSttNd = const_cast(SwOutlineNodes::GetRootNode(pSttNd)); + + SwOutlineNodesInline::size_type nEndPosInline; pOutlNdsInline->Seek_Entry( pEndNd, &nEndPosInline ); - } + assert(nEndPosInline != SwOutlineNodesInline::npos && "always sets some number <= pOutlNdsInline->size()"); - if( bWithChildren && !pOutlNdsInline ) - { - const int nLevel = pEndNd->GetTextNode()->GetAttrOutlineLevel()-1; - for( ++nEndPos; nEndPos < rOutlNds.size(); ++nEndPos ) + // headings in flys + if (bWithChildren) { + 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(SwOutlineNodes::GetRootNode(pEndNd)); + } + else if (++nEndPosInline < pOutlNdsInline->size()) + pEndNd = const_cast(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 ]; - 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(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(SwOutlineNodes::GetRootNode((*pOutlNdsInline)[nEndPosInline])); - if( ( pOutlNdsInline && nEndPosInline == pOutlNdsInline->size() ) || - ( !pOutlNdsInline && nEndPos == rOutlNds.size() ) ) // no end found - pEndNd = &rNds.GetEndOfContent(); + if (nEndPos == rOutlNds.size()) // no end found + pEndNd = &rNds.GetEndOfContent(); + } if( bKillPams ) KillPams();