summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2020-01-02 12:24:27 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-01-04 14:04:31 +0100
commit0c8848394df6e0c8ac3149ffde1314e8e1171869 (patch)
treeda5bbbd26ff867d45e5e0dd9fb0cfd771839a5f0 /editeng
parent3367c986b78397c05e051daede2a8b60d705bffb (diff)
tdf#129708 speed-up: reuse enumeration for each effect
Change-Id: I336278c5a9eec75a2a71fe4d04d2029a5a08e6a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86102 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit c97f9af5e47ea234ad709a1f66c1e8ed20640066) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86208 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/uno/unotext2.cxx57
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 );
}
}
}