diff options
Diffstat (limited to 'editeng/source')
-rw-r--r-- | editeng/source/uno/unotext2.cxx | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx index ba9c66f3c37f..c76abfb581a8 100644 --- a/editeng/source/uno/unotext2.cxx +++ b/editeng/source/uno/unotext2.cxx @@ -45,40 +45,41 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase if( mrText.GetEditSource() ) mpEditSource = mrText.GetEditSource()->Clone(); mnNextParagraph = 0; - for( sal_Int32 currentPara = 0; currentPara < mrText.GetEditSource()->GetTextForwarder()->GetParagraphCount(); currentPara++ ) + + const SvxTextForwarder* pTextForwarder = mrText.GetEditSource()->GetTextForwarder(); + const sal_Int32 maxParaIndex = std::min( rSel.nEndPara + 1, pTextForwarder->GetParagraphCount() ); + + for( sal_Int32 currentPara = rSel.nStartPara; currentPara < maxParaIndex; currentPara++ ) { - if( currentPara>=rSel.nStartPara && currentPara<=rSel.nEndPara ) + const SvxUnoTextRangeBaseVec& rRanges( mpEditSource->getRanges() ); + SvxUnoTextContent* pContent = nullptr; + sal_Int32 nStartPos = 0; + sal_Int32 nEndPos = pTextForwarder->GetTextLen( currentPara ); + if( currentPara == rSel.nStartPara ) + nStartPos = std::max(nStartPos, rSel.nStartPos); + if( currentPara == rSel.nEndPara ) + nEndPos = std::min(nEndPos, rSel.nEndPos); + ESelection aCurrentParaSel( currentPara, nStartPos, currentPara, nEndPos ); + for (auto const& elemRange : rRanges) { - const SvxUnoTextRangeBaseVec& rRanges( mpEditSource->getRanges() ); - SvxUnoTextContent* pContent = nullptr; - sal_Int32 nStartPos = 0; - sal_Int32 nEndPos = mrText.GetEditSource()->GetTextForwarder()->GetTextLen( currentPara ); - if( currentPara == rSel.nStartPara ) - nStartPos = std::max(nStartPos, rSel.nStartPos); - if( currentPara == rSel.nEndPara ) - nEndPos = std::min(nEndPos, rSel.nEndPos); - ESelection aCurrentParaSel( currentPara, nStartPos, currentPara, nEndPos ); - for (auto const& elemRange : rRanges) + if (pContent) + break; + SvxUnoTextContent* pIterContent = dynamic_cast< SvxUnoTextContent* >( elemRange ); + if( pIterContent && (pIterContent->mnParagraph == currentPara) ) { - if (pContent) - break; - SvxUnoTextContent* pIterContent = dynamic_cast< SvxUnoTextContent* >( elemRange ); - if( pIterContent && (pIterContent->mnParagraph == currentPara) ) + ESelection aIterSel = pIterContent->GetSelection(); + if( aIterSel == aCurrentParaSel ) { - ESelection aIterSel = pIterContent->GetSelection(); - if( aIterSel == aCurrentParaSel ) - { - pContent = pIterContent; - maContents.emplace_back(pContent ); - } + pContent = pIterContent; + maContents.emplace_back(pContent ); } } - if( pContent == nullptr ) - { - pContent = new SvxUnoTextContent( mrText, currentPara ); - pContent->SetSelection( aCurrentParaSel ); - maContents.emplace_back(pContent ); - } + } + if( pContent == nullptr ) + { + pContent = new SvxUnoTextContent( mrText, currentPara ); + pContent->SetSelection( aCurrentParaSel ); + maContents.emplace_back(pContent ); } } } |